5191: Fix UI elements not conforming to dark mode (#5193)

* feedback dialog: fix black font in dark mode

* LocationPickerActivity: fix light map in dark mode

* Fix #5182 Switch From Mapbox to MapLibre (#5184)

* Fix #5182 Switch From Mapbox to MapLibre

* Fix #5182 Switch From Mapbox to MapLibre - Resolved requestFeature() issue

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on two screens

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on additional screens

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on notification screen

* Fix #5182 Switch From Mapbox to MapLibre - Test errors

* fix issue #5015 - custom image selector not identifying photo location (#5190)

Co-authored-by: Siva <doodsiva@gmail.com>

* feedback dialog: fix black font in dark mode

* LocationPickerActivity: fix light map in dark mode

* LocationPicker: use predefined style based on device theme

* LocationPickerActivityTest: add additional target exception in catch block

* LocationPickerConstants: remove extra newline introduced

---------

Co-authored-by: Kartikay Kaushik <93285364+kartikaykaushik14@users.noreply.github.com>
Co-authored-by: Siva Subramaniam <112970189+siva-subramaniam-v@users.noreply.github.com>
Co-authored-by: Siva <doodsiva@gmail.com>
This commit is contained in:
Ritika Pahwa 2023-04-03 10:57:52 +05:30 committed by GitHub
parent 0f1e526326
commit a5a65fc1ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 9 deletions

View file

@ -57,6 +57,7 @@ import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils; import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.kvstore.JsonKvStore; import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.theme.BaseActivity; import fr.free.nrw.commons.theme.BaseActivity;
import fr.free.nrw.commons.utils.SystemThemeUtils;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -139,12 +140,21 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
@Named("default_preferences") @Named("default_preferences")
public public
JsonKvStore applicationKvStore; JsonKvStore applicationKvStore;
/**
* isDarkTheme: for keeping a track of the device theme and modifying the map theme accordingly
*/
@Inject
SystemThemeUtils systemThemeUtils;
private boolean isDarkTheme;
@Override @Override
protected void onCreate(@Nullable final Bundle savedInstanceState) { protected void onCreate(@Nullable final Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR); getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
isDarkTheme = systemThemeUtils.isDeviceInNightMode();
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
final ActionBar actionBar = getSupportActionBar(); final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
actionBar.hide(); actionBar.hide();
@ -238,7 +248,8 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
@Override @Override
public void onMapReady(final MapboxMap mapboxMap) { public void onMapReady(final MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap; this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), this::onStyleLoaded); mapboxMap.setStyle(isDarkTheme ? LocationPickerConstants.DARK_MAP_STYLE :
LocationPickerConstants.STREETS_MAP_STYLE, this::onStyleLoaded);
} }
/** /**

View file

@ -1,5 +1,7 @@
package fr.free.nrw.commons.LocationPicker; package fr.free.nrw.commons.LocationPicker;
import com.mapbox.mapboxsdk.maps.Style;
/** /**
* Constants need for location picking * Constants need for location picking
*/ */
@ -11,6 +13,12 @@ public final class LocationPickerConstants {
public static final String MAP_CAMERA_POSITION public static final String MAP_CAMERA_POSITION
= "location.picker.cameraPosition"; = "location.picker.cameraPosition";
public static final String DARK_MAP_STYLE
= Style.getPredefinedStyle("Dark");
public static final String STREETS_MAP_STYLE
= Style.getPredefinedStyle("Streets");
private LocationPickerConstants() { private LocationPickerConstants() {
} }

View file

@ -15,7 +15,7 @@
android:layout_margin="@dimen/dimen_6" android:layout_margin="@dimen/dimen_6"
android:padding="@dimen/tiny_gap" android:padding="@dimen/tiny_gap"
android:textSize="24sp" android:textSize="24sp"
android:textColor="@color/black" android:textColor="?android:attr/textColorPrimary"
android:text="@string/navigation_item_feedback" android:text="@string/navigation_item_feedback"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -44,7 +44,7 @@
android:layout_margin="@dimen/dimen_6" android:layout_margin="@dimen/dimen_6"
android:padding="4dp" android:padding="4dp"
android:textSize="21sp" android:textSize="21sp"
android:textColor="@color/black" android:textColor="?android:attr/textColorPrimary"
android:text="@string/select_feedback_data_choice" android:text="@string/select_feedback_data_choice"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />

View file

@ -143,7 +143,9 @@ class LocationPickerActivityUnitTests {
method.invoke(activity, mapboxMap) method.invoke(activity, mapboxMap)
fail("Expected an exception to be thrown") fail("Expected an exception to be thrown")
} catch (e: InvocationTargetException) { } catch (e: InvocationTargetException) {
assertTrue(e.targetException is MapboxConfigurationException) assertTrue((e.targetException is MapboxConfigurationException) ||
(e.targetException is ExceptionInInitializerError))
if (e.targetException is MapboxConfigurationException) {
assertEquals( assertEquals(
"\nUsing MapView requires calling Mapbox.getInstance(Context context, String apiKey," "\nUsing MapView requires calling Mapbox.getInstance(Context context, String apiKey,"
+ " WellKnownTileServer wellKnownTileServer) before inflating or creating the view.", + " WellKnownTileServer wellKnownTileServer) before inflating or creating the view.",
@ -151,6 +153,7 @@ class LocationPickerActivityUnitTests {
) )
} }
} }
}
@Test @Test
@Throws(Exception::class) @Throws(Exception::class)