Added Support for System Wide Dark Theme (#3460)

* Added Support for System Wide Dark Theme

* changed methods to private

* Moved Strings to strings.xml

* Used Dagger to reduce code repetition

* Changes made as per review suggestions

* Minor Changes

* Fixes as per suggestions

* Minor Fixes as per suggestion

* made the variables static

* removed irrelevant code
This commit is contained in:
Seán Mac Gillicuddy 2020-03-05 14:33:57 +00:00 committed by GitHub
parent 65ec071493
commit 1584ffe0e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 139 additions and 42 deletions

View file

@ -9,7 +9,6 @@ import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
@ -93,6 +92,7 @@ import fr.free.nrw.commons.utils.LocationUtils;
import fr.free.nrw.commons.utils.NearbyFABUtils;
import fr.free.nrw.commons.utils.NetworkUtils;
import fr.free.nrw.commons.utils.PermissionUtils;
import fr.free.nrw.commons.utils.SystemThemeUtils;
import fr.free.nrw.commons.utils.UiUtils;
import fr.free.nrw.commons.utils.ViewUtil;
import fr.free.nrw.commons.wikidata.WikidataEditListener;
@ -156,6 +156,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
@Inject ContributionController controller;
@Inject WikidataEditListener wikidataEditListener;
@Inject
SystemThemeUtils systemThemeUtils;
private NearbyFilterSearchRecyclerViewAdapter nearbyFilterSearchRecyclerViewAdapter;
private BottomSheetBehavior bottomSheetListBehavior;
@ -210,7 +213,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
isDarkTheme = applicationKvStore.getBoolean("theme", false);
isDarkTheme = systemThemeUtils.isDeviceInNightMode();
cameraMoveListener= () -> presenter.onCameraMove(mapBox.getCameraPosition().target);
addCheckBoxCallback();
presenter.attachView(this);
@ -821,10 +824,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
}
private void showFABs() {
NearbyFABUtils.addAnchorToBigFABs(fabPlus, bottomSheetDetails.getId());
fabPlus.show();
NearbyFABUtils.addAnchorToSmallFABs(fabGallery, getView().findViewById(R.id.empty_view).getId());
NearbyFABUtils.addAnchorToSmallFABs(fabCamera, getView().findViewById(R.id.empty_view1).getId());
NearbyFABUtils.addAnchorToBigFABs(fabPlus, bottomSheetDetails.getId());
fabPlus.show();
NearbyFABUtils.addAnchorToSmallFABs(fabGallery, getView().findViewById(R.id.empty_view).getId());
NearbyFABUtils.addAnchorToSmallFABs(fabCamera, getView().findViewById(R.id.empty_view1).getId());
}
/**