quick action dark mode

This commit is contained in:
Rosty 2017-01-05 16:32:38 +02:00
parent 0f31e291d8
commit 7fad600bc4
12 changed files with 55 additions and 30 deletions

View file

@ -19,7 +19,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="@color/icon_color" android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_flag_dark" /> android:src="@drawable/ic_action_flag_dark" />
<TextView <TextView

View file

@ -74,7 +74,7 @@
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="@color/icon_color" android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_fav_dark"/> android:src="@drawable/ic_action_fav_dark"/>
</LinearLayout> </LinearLayout>
@ -149,7 +149,7 @@
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="@color/icon_color" android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_folder"/> android:src="@drawable/ic_action_folder"/>
</LinearLayout> </LinearLayout>

View file

@ -74,7 +74,7 @@
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="@color/icon_color" android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_fav_dark"/> android:src="@drawable/ic_action_fav_dark"/>
</LinearLayout> </LinearLayout>
@ -149,7 +149,7 @@
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="@color/icon_color" android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_folder"/> android:src="@drawable/ic_action_folder"/>
</LinearLayout> </LinearLayout>

View file

@ -32,12 +32,14 @@
android:contentInsetLeft="72dp" android:contentInsetLeft="72dp"
app:contentInsetLeft="72dp" app:contentInsetLeft="72dp"
app:contentInsetStart="72dp" app:contentInsetStart="72dp"
android:background="@color/actionbar_light_color"/> android:background="?attr/actionModeBackground"/>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="72dp" android:layout_height="72dp"
android:background="@color/actionbar_light_color"> android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:background="?attr/actionModeBackground">
<ImageView <ImageView
android:id="@+id/image" android:id="@+id/image"
@ -89,7 +91,7 @@
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/dashboard_background" android:background="?attr/spinnerListBackground"
android:layout_marginBottom="56dp"> android:layout_marginBottom="56dp">
<FrameLayout <FrameLayout

View file

@ -22,7 +22,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="4dp" android:layout_marginRight="4dp"
android:focusable="false" android:focusable="false"
android:tint="@color/icon_color" android:tint="?attr/secondary_icon_color"
android:scaleType="centerInside" android:scaleType="centerInside"
android:src="@drawable/ic_action_reorder"/> android:src="@drawable/ic_action_reorder"/>
@ -45,7 +45,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="?android:selectableItemBackground" android:background="?android:selectableItemBackground"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="@color/icon_color_light" android:tint="?attr/secondary_icon_color"
android:src="@drawable/ic_action_remove_dark"/> android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout> </LinearLayout>

View file

@ -10,7 +10,7 @@
android:id="@+id/custom_toolbar" android:id="@+id/custom_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize" android:layout_height="?android:attr/actionBarSize"
android:background="@color/actionbar_light_color"/> android:background="?attr/actionModeBackground"/>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"

View file

@ -23,6 +23,7 @@
android:layout_marginRight="4dp" android:layout_marginRight="4dp"
android:focusable="false" android:focusable="false"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="?attr/secondary_icon_color"
android:src="@drawable/ic_action_reorder"/> android:src="@drawable/ic_action_reorder"/>
<ImageView <ImageView
@ -70,6 +71,7 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="?android:selectableItemBackground" android:background="?android:selectableItemBackground"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="?attr/secondary_icon_color"
android:src="@drawable/ic_action_remove_dark"/> android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout> </LinearLayout>

View file

@ -442,10 +442,22 @@
<item name="android:background">@color/xmas_blue</item> <item name="android:background">@color/xmas_blue</item>
</style> </style>
<style name="Dialog90" parent="Base.Theme.AppCompat.Light.Dialog"> <style name="Dialog90Light" parent="Base.Theme.AppCompat.Light.Dialog">
<item name="android:windowMinWidthMajor">90%</item> <item name="android:windowMinWidthMajor">90%</item>
<item name="android:windowMinWidthMinor">90%</item> <item name="android:windowMinWidthMinor">90%</item>
<item name="secondary_icon_color">@color/icon_color_light</item>
<item name="primary_icon_color">@color/icon_color</item>
</style>
<style name="Dialog90Dark" parent="Base.Theme.AppCompat.Dialog">
<item name="android:windowMinWidthMajor">90%</item>
<item name="android:windowMinWidthMinor">90%</item>
<item name="secondary_icon_color">@color/dialog_inactive_text_color_dark</item>
<item name="primary_icon_color">@color/color_white</item>
</style> </style>
<style name="WhiteControls" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="WhiteControls" parent="Theme.AppCompat.Light.DarkActionBar">

View file

@ -16,6 +16,7 @@ import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -32,7 +33,13 @@ public class AddQuickActionDialog extends DialogFragment {
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
return new Dialog(new ContextThemeWrapper(getActivity(), R.style.Dialog90), getTheme());
OsmandApplication application = (OsmandApplication) getActivity().getApplication();
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
return new Dialog(new ContextThemeWrapper(getActivity(), light
? R.style.Dialog90Light
: R.style.Dialog90Dark), getTheme());
} }
@Nullable @Nullable

View file

@ -70,7 +70,13 @@ public class CreateEditActionDialog extends DialogFragment {
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(new ContextThemeWrapper(getActivity(), R.style.OsmandLightTheme), getTheme()); OsmandApplication application = (OsmandApplication) getActivity().getApplication();
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
Dialog dialog = new Dialog(new ContextThemeWrapper(getActivity(), light
? R.style.Dialog90Light
: R.style.Dialog90Dark), getTheme());
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setLayout( dialog.getWindow().setLayout(
@ -86,7 +92,12 @@ public class CreateEditActionDialog extends DialogFragment {
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, R.style.OsmandLightTheme); OsmandApplication application = (OsmandApplication) getActivity().getApplication();
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
setStyle(DialogFragment.STYLE_NORMAL, light
? R.style.OsmandLightTheme
: R.style.OsmandDarkTheme);
} }
@Nullable @Nullable
@ -180,7 +191,7 @@ public class CreateEditActionDialog extends DialogFragment {
} }
}); });
name.setEnabled(!action.isSingle() && !action.toggle); name.setEnabled(!action.autogeneratedTitle);
action.setAutoGeneratedTitle(name); action.setAutoGeneratedTitle(name);
if (savedInstanceState == null) name.setText(action.getName(getContext())); if (savedInstanceState == null) name.setText(action.getName(getContext()));

View file

@ -35,8 +35,7 @@ public class QuickAction {
protected @StringRes int nameRes; protected @StringRes int nameRes;
protected @DrawableRes int iconRes; protected @DrawableRes int iconRes;
protected boolean toggle; protected boolean autogeneratedTitle;
protected boolean single;
private String name; private String name;
private HashMap<String, String> params; private HashMap<String, String> params;
@ -62,8 +61,7 @@ public class QuickAction {
this.iconRes = quickAction.iconRes; this.iconRes = quickAction.iconRes;
this.name = quickAction.name; this.name = quickAction.name;
this.params = quickAction.params; this.params = quickAction.params;
this.single = quickAction.single; this.autogeneratedTitle = quickAction.autogeneratedTitle;
this.toggle = quickAction.toggle;
} }
public int getNameRes() { public int getNameRes() {
@ -82,10 +80,6 @@ public class QuickAction {
return name == null || name.isEmpty() ? nameRes > 0 ? context.getString(nameRes) : "" : name; return name == null || name.isEmpty() ? nameRes > 0 ? context.getString(nameRes) : "" : name;
} }
public boolean isSingle() {
return single;
}
public HashMap<String, String> getParams() { public HashMap<String, String> getParams() {
if (params == null) params = new HashMap<>(); if (params == null) params = new HashMap<>();

View file

@ -587,8 +587,7 @@ public class QuickActionFactory {
type = TYPE; type = TYPE;
nameRes = R.string.quick_action_showhide_favorites_title; nameRes = R.string.quick_action_showhide_favorites_title;
iconRes = R.drawable.ic_action_fav_dark; iconRes = R.drawable.ic_action_fav_dark;
single = true; autogeneratedTitle = true;
toggle = true;
} }
public ShowHideFavoritesAction(QuickAction quickAction) { public ShowHideFavoritesAction(QuickAction quickAction) {
@ -644,7 +643,7 @@ public class QuickActionFactory {
type = TYPE; type = TYPE;
nameRes = R.string.quick_action_showhide_poi_title; nameRes = R.string.quick_action_showhide_poi_title;
iconRes = R.drawable.ic_action_gabout_dark; iconRes = R.drawable.ic_action_gabout_dark;
toggle = true; autogeneratedTitle = true;
} }
public ShowHidePoiAction(QuickAction quickAction) { public ShowHidePoiAction(QuickAction quickAction) {
@ -1271,8 +1270,7 @@ public class QuickActionFactory {
type = TYPE; type = TYPE;
nameRes = R.string.quick_action_navigation_voice; nameRes = R.string.quick_action_navigation_voice;
iconRes = R.drawable.ic_action_volume_up; iconRes = R.drawable.ic_action_volume_up;
toggle = true; autogeneratedTitle = true;
single = true;
} }
public NavigationVoiceAction(QuickAction quickAction) { public NavigationVoiceAction(QuickAction quickAction) {
@ -1581,7 +1579,6 @@ public class QuickActionFactory {
type = TYPE; type = TYPE;
nameRes = R.string.quick_action_map_style; nameRes = R.string.quick_action_map_style;
iconRes = R.drawable.ic_map; iconRes = R.drawable.ic_map;
toggle = true;
} }
public MapStyleAction(QuickAction quickAction) { public MapStyleAction(QuickAction quickAction) {