quick_action_controls_background resource fix

This commit is contained in:
Korusn Oleksandr 2017-01-11 15:28:48 +02:00
parent b30352ee32
commit fac9e9c392
2 changed files with 18 additions and 5 deletions

View file

@ -2,7 +2,7 @@
<shape android:shape="rectangle" <shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?attr/dashboard_divider" /> <solid android:color="@color/dashboard_divider_light" />
<corners android:bottomLeftRadius="2dp" android:bottomRightRadius="2dp"/> <corners android:bottomLeftRadius="2dp" android:bottomRightRadius="2dp"/>
</shape> </shape>

View file

@ -2,6 +2,10 @@ package net.osmand.plus.quickaction;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.support.annotation.StyleRes; import android.support.annotation.StyleRes;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter; import android.support.v4.view.PagerAdapter;
@ -15,18 +19,17 @@ import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication; 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.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import java.util.List; import java.util.List;
import static net.osmand.plus.R.id.imageView;
public class QuickActionsWidget extends LinearLayout { public class QuickActionsWidget extends LinearLayout {
@ -155,6 +158,16 @@ public class QuickActionsWidget extends LinearLayout {
controls = (LinearLayout) findViewById(R.id.controls); controls = (LinearLayout) findViewById(R.id.controls);
controls.setVisibility(pageCount > 1 ? VISIBLE : GONE); controls.setVisibility(pageCount > 1 ? VISIBLE : GONE);
Drawable background = controls.getBackground();
int backgroundColor = ContextCompat.getColor(context, light ? R.color.dashboard_divider_light : R.color.dashboard_divider_dark);
if (background instanceof ShapeDrawable) {
((ShapeDrawable)background).getPaint().setColor(backgroundColor);
} else if (background instanceof GradientDrawable) {
((GradientDrawable)background).setColor(backgroundColor);
} else if (background instanceof ColorDrawable) {
((ColorDrawable)background).setColor(backgroundColor);
}
updateControls(viewPager.getCurrentItem()); updateControls(viewPager.getCurrentItem());
} }
@ -208,7 +221,7 @@ public class QuickActionsWidget extends LinearLayout {
final QuickAction action = QuickActionFactory.produceAction( final QuickAction action = QuickActionFactory.produceAction(
actions.get(i + (position * ELEMENT_PER_PAGE))); actions.get(i + (position * ELEMENT_PER_PAGE)));
((ImageView) view.findViewById(R.id.imageView)) ((ImageView) view.findViewById(imageView))
.setImageResource(action.getIconRes(getContext())); .setImageResource(action.getIconRes(getContext()));
((TextView) view.findViewById(R.id.title)) ((TextView) view.findViewById(R.id.title))