Skip to content

Commit

Permalink
popupMenu for map type and edit modes - dark mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
jclark118 committed Jul 3, 2023
1 parent 7086030 commit 5819b00
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.app.ActivityCompat;
Expand Down Expand Up @@ -1246,7 +1247,8 @@ public void onCancelButtonClicked() {
*/
public void openMapSelect() {
if (getActivity() != null) {
PopupMenu pm = new PopupMenu(getActivity(), mapSelectButton);
Context wrapper = new ContextThemeWrapper(getContext(), R.style.MyPopupMenu);
PopupMenu pm = new PopupMenu(wrapper, mapSelectButton);
// Needed to make the icons visible
try {
Method method = pm.getMenu().getClass().getDeclaredMethod("setOptionalIconsVisible", boolean.class);
Expand Down Expand Up @@ -1291,7 +1293,8 @@ public void openMapSelect() {
*/
public void openEditMenu() {
if (getActivity() != null) {
PopupMenu pm = new PopupMenu(getActivity(), editFeaturesButton);
Context wrapper = new ContextThemeWrapper(getContext(), R.style.MyPopupMenu);
PopupMenu pm = new PopupMenu(wrapper, editFeaturesButton);
// Needed to make the icons visible
try {
Method method = pm.getMenu().getClass().getDeclaredMethod("setOptionalIconsVisible", boolean.class);
Expand Down
2 changes: 1 addition & 1 deletion mapcache/src/main/res/drawable/outlined_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:color="@color/textLinkColor" android:width="1dp"/>
<stroke android:color="@color/outlineBoxColor" android:width="1dp"/>
<corners android:radius="8dp"/>
</shape>
</item>
Expand Down
28 changes: 22 additions & 6 deletions mapcache/src/main/res/layout/edit_features_selection.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >

Expand All @@ -22,51 +23,66 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="@drawable/material_feature" />
android:src="@drawable/material_feature"
app:tint="@color/textSecondaryColor" />

<TextView
android:id="@+id/new_layer_title"
style="@style/Base.TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:textColor="@color/textPrimaryColor"
android:text="Edit Features Layer" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
android:orientation="vertical" >

<TextView
android:id="@+id/edit_features_selection_geopackage_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/textSecondaryColor"
android:text="@string/edit_features_selection_geopackage_label" />

<Spinner
android:id="@+id/edit_features_selection_geopackage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="@string/edit_features_selection_geopackage_prompt" />
android:prompt="@string/edit_features_selection_geopackage_prompt"
android:theme="@style/TextLabel"
android:background="@drawable/outlined_background"
android:popupBackground="@color/backgroundPrimaryColor"
android:paddingRight="8dp"
android:spinnerMode="dropdown"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
android:layout_marginTop="16dp"
android:orientation="vertical" >

<TextView
android:id="@+id/edit_features_selection_features_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Layer:" />
android:textColor="@color/textSecondaryColor"
android:text="Layer" />

<Spinner
android:id="@+id/edit_features_selection_features"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="@string/edit_features_selection_features_prompt" />
android:prompt="@string/edit_features_selection_features_prompt"
android:theme="@style/TextLabel"
android:paddingRight="8dp"
android:background="@drawable/outlined_background"
android:popupBackground="@color/backgroundPrimaryColor"
android:spinnerMode="dropdown"/>
</LinearLayout>
</LinearLayout>

Expand Down
3 changes: 2 additions & 1 deletion mapcache/src/main/res/layout/spinner_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:paddingBottom="8dp"
android:textColor="@color/textSecondaryColor"
android:textStyle="bold"
android:textColor="@color/textPrimaryColor"
/>
1 change: 1 addition & 0 deletions mapcache/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<color name="mutedAccentColor">@color/nga_accent_muted_dark</color>
<color name="offsetBackgroundColor">@color/midDarkBackground</color>
<color name="outlineBoxColor">@color/nga_accent_muted_dark</color>

<!-- Text inputs -->
<color name="mtrl_textinput_default_box_stroke_color" tools:override="true">@color/white50</color>
Expand Down
8 changes: 8 additions & 0 deletions mapcache/src/main/res/values-v14/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
<item name="colorSecondary">@color/nga_primary_light</item>
<item name="colorSecondaryVariant">@android:color/holo_red_light</item>
<item name="colorOnSecondary">@color/black87</item>
<item name="android:itemBackground">@color/backgroundSecondaryColor</item>
</style>

<!-- Popup menus for edit button on map and map styles -->
<style name="MyPopupMenu" parent="Widget.AppCompat.PopupMenu">
<item name="android:textColor">@color/textPrimaryColor</item>
<item name="android:itemBackground">@color/backgroundSecondaryColor</item>
<item name="popupMenuBackground">@color/backgroundSecondaryColor</item>
</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
Expand Down
1 change: 1 addition & 0 deletions mapcache/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<color name="mutedAccentColor">@color/nga_accent_bright</color>
<color name="offsetBackgroundColor">@color/light_blue_bg</color>
<color name="outlineBoxColor">@color/nga_primary_light</color>

<!-- Text inputs -->
<color name="mtrl_textinput_default_box_stroke_color" tools:override="true">@color/black50</color>
Expand Down
2 changes: 1 addition & 1 deletion mapcache/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
<item>SURFACE</item>
</array>
<string name="edit_features_geometry_type_prompt">Geometry Type</string>
<string name="edit_features_selection_geopackage_label">GeoPackage: </string>
<string name="edit_features_selection_geopackage_label">GeoPackage</string>
<string name="edit_features_selection_geopackage_prompt">GeoPackage</string>
<string name="edit_features_selection_features_label">Features: </string>
<string name="edit_features_selection_features_prompt">Features</string>
Expand Down

0 comments on commit 5819b00

Please sign in to comment.