diff --git a/OsmAnd/res/drawable/quick_action_controls_background.xml b/OsmAnd/res/drawable/quick_action_controls_background.xml
index 96870ed8ca..3deb76f852 100644
--- a/OsmAnd/res/drawable/quick_action_controls_background.xml
+++ b/OsmAnd/res/drawable/quick_action_controls_background.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/quick_action_widget.xml b/OsmAnd/res/layout/quick_action_widget.xml
index ca0b14d38d..67fb3a02f5 100644
--- a/OsmAnd/res/layout/quick_action_widget.xml
+++ b/OsmAnd/res/layout/quick_action_widget.xml
@@ -6,6 +6,7 @@
android:background="@drawable/quick_action_background">
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java
index 5e6d313af5..a60e592914 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java
@@ -2,8 +2,11 @@ package net.osmand.plus.quickaction;
import android.app.Activity;
import android.content.Context;
+import android.support.annotation.StyleRes;
+import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
+import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.GridLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -19,6 +22,7 @@ import android.widget.TextView;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import java.util.List;
@@ -38,20 +42,18 @@ public class QuickActionsWidget extends LinearLayout {
private ViewPager viewPager;
private LinearLayout dots;
private LinearLayout controls;
+ private View container;
public QuickActionsWidget(Context context) {
super(context);
- inflate(context, R.layout.quick_action_widget, this);
}
public QuickActionsWidget(Context context, AttributeSet attrs) {
super(context, attrs);
- inflate(context, R.layout.quick_action_widget, this);
}
public QuickActionsWidget(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- inflate(context, R.layout.quick_action_widget, this);
}
public void setActions(List actions){
@@ -59,6 +61,7 @@ public class QuickActionsWidget extends LinearLayout {
this.actions = actions;
this.actions.add(new QuickActionFactory.NewAction());
+ removeAllViews();
setupLayout(getContext(), countPage());
}
@@ -68,9 +71,20 @@ public class QuickActionsWidget extends LinearLayout {
private void setupLayout(Context context, int pageCount){
+ boolean light = ((OsmandApplication) context.getApplicationContext()).getSettings().isLightContent();
+
+ inflate(new ContextThemeWrapper(context, light
+ ? R.style.OsmandLightTheme
+ : R.style.OsmandDarkTheme), R.layout.quick_action_widget, this);
+
+ container = findViewById(R.id.container);
viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPager.setAdapter(new ViewsPagerAdapter());
+ container.setBackgroundResource(light
+ ? R.drawable.bg_card_light
+ : R.drawable.bg_card_dark);
+
viewPager.getLayoutParams().height = actions.size() > ELEMENT_PER_PAGE / 2
? (int) getResources().getDimension(R.dimen.quick_action_widget_height_big)
: (int) getResources().getDimension(R.dimen.quick_action_widget_height_small);
@@ -122,6 +136,8 @@ public class QuickActionsWidget extends LinearLayout {
if (pageCount > 1) {
+ int color = light ? R.color.icon_color_light : R.color.white_50_transparent;
+
for (int i = 0; i < pageCount; i++) {
ImageView dot = (ImageView) getLayoutInflater()
@@ -129,7 +145,7 @@ public class QuickActionsWidget extends LinearLayout {
dot.setImageDrawable(i == 0
? getIconsCache().getIcon(R.drawable.ic_dot_position, R.color.dashboard_blue)
- : getIconsCache().getIcon(R.drawable.ic_dot_position, R.color.icon_color_light));
+ : getIconsCache().getIcon(R.drawable.ic_dot_position, color));
dots.addView(dot);
}
@@ -143,27 +159,37 @@ public class QuickActionsWidget extends LinearLayout {
private void updateControls(int position) {
+ boolean light = ((OsmandApplication) getContext().getApplicationContext()).getSettings().isLightContent();
+
+ int colorEnabled = light ? R.color.icon_color : R.color.color_white;
+ int colorDisabled = light ? R.color.icon_color_light : R.color.white_50_transparent;
+
next.setEnabled(viewPager.getAdapter().getCount() > position + 1);
next.setImageDrawable(next.isEnabled()
- ? getIconsCache().getIcon(R.drawable.ic_arrow_forward, R.color.icon_color)
- : getIconsCache().getIcon(R.drawable.ic_arrow_forward, R.color.icon_color_light));
+ ? getIconsCache().getIcon(R.drawable.ic_arrow_forward, colorEnabled)
+ : getIconsCache().getIcon(R.drawable.ic_arrow_forward, colorDisabled));
prev.setEnabled(position > 0);
prev.setImageDrawable(prev.isEnabled()
- ? getIconsCache().getIcon(R.drawable.ic_arrow_back, R.color.icon_color)
- : getIconsCache().getIcon(R.drawable.ic_arrow_back, R.color.icon_color_light));
+ ? getIconsCache().getIcon(R.drawable.ic_arrow_back, colorEnabled)
+ : getIconsCache().getIcon(R.drawable.ic_arrow_back, colorDisabled));
for (int i = 0; i < dots.getChildCount(); i++){
((ImageView) dots.getChildAt(i)).setImageDrawable(i == position
? getIconsCache().getIcon(R.drawable.ic_dot_position, R.color.dashboard_blue)
- : getIconsCache().getIcon(R.drawable.ic_dot_position, R.color.icon_color_light));
+ : getIconsCache().getIcon(R.drawable.ic_dot_position, colorDisabled));
}
}
private View createPageView(ViewGroup container, int position){
- LayoutInflater li = getLayoutInflater();
+ boolean light = ((OsmandApplication) getContext().getApplicationContext()).getSettings().isLightContent();
+
+ LayoutInflater li = getLayoutInflater(light
+ ? R.style.OsmandLightTheme
+ : R.style.OsmandDarkTheme);
+
View page = li.inflate(R.layout.quick_action_widget_page, container, false);
GridLayout gridLayout = (GridLayout) page.findViewById(R.id.grid);
@@ -179,8 +205,7 @@ public class QuickActionsWidget extends LinearLayout {
final QuickAction action = actions.get(i + (position * ELEMENT_PER_PAGE));
((ImageView) view.findViewById(R.id.imageView))
- .setImageDrawable(getIconsCache()
- .getIcon(action.getIconRes(), R.color.icon_color_dark));
+ .setImageResource(action.getIconRes());
((TextView) view.findViewById(R.id.title))
.setText(action.getName(getContext()));
@@ -243,6 +268,10 @@ public class QuickActionsWidget extends LinearLayout {
return (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
+ private LayoutInflater getLayoutInflater(@StyleRes int style){
+ return (LayoutInflater) new ContextThemeWrapper(getContext(), style).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
private OsmandApplication getApplication(){
return (OsmandApplication)(getContext().getApplicationContext());
}