Fix Resources NotFoundException for api less then 21

This commit is contained in:
Chumva 2019-02-12 19:07:11 +02:00
parent 4e9bbf4648
commit d749944950
18 changed files with 130 additions and 34 deletions

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<stroke android:width="1dp" android:color="@color/route_info_go_btn_inking_dark" />
</shape>
</item>
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/activity_background_dark" />
<corners android:radius="4dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@null" />
<corners android:radius="4dp" />
<stroke android:width="1dp" android:color="@color/divider_dark" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_light" />
</shape>
</item>
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/activity_background_light" />
<corners android:radius="4dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@null" />
<corners android:radius="4dp" />
<stroke android:width="1dp" android:color="@color/divider_light" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="18dp" />
<stroke android:width="1dp" android:color="@color/route_info_go_btn_inking_dark" />
</shape>
</item>
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/activity_background_dark" />
<corners android:radius="18dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@null" />
<corners android:radius="18dp" />
<stroke android:width="1dp" android:color="@color/divider_dark" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="18dp" />
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_light" />
</shape>
</item>
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/activity_background_light" />
<corners android:radius="18dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@null" />
<corners android:radius="18dp" />
<stroke android:width="1dp" android:color="@color/divider_light" />
</shape>
</item>
</selector>

View file

@ -3,7 +3,8 @@
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<stroke android:width="1dp" android:color="@color/route_info_go_btn_inking_dark" />
<solid android:color="@color/active_buttons_and_links_trans_dark" />
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_dark" />
</shape>
</item>
<item android:state_enabled="false">

View file

@ -3,6 +3,7 @@
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="@color/active_buttons_and_links_trans_light" />
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_light" />
</shape>
</item>

View file

@ -3,6 +3,7 @@
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="18dp" />
<solid android:color="@color/active_buttons_and_links_trans_dark" />
<stroke android:width="1dp" android:color="@color/route_info_go_btn_inking_dark" />
</shape>
</item>

View file

@ -3,6 +3,7 @@
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="18dp" />
<solid android:color="@color/active_buttons_and_links_trans_light" />
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_light" />
</shape>
</item>

View file

@ -24,6 +24,6 @@
android:layout_marginBottom="@dimen/route_info_icon_vertical_padding"
android:layout_marginTop="@dimen/route_info_icon_vertical_padding"
android:scaleType="center"
tools:background="@drawable/btn_border_trans_light" />
tools:background="@drawable/btn_border_light" />
</FrameLayout>

View file

@ -141,7 +141,7 @@
android:layout_marginTop="@dimen/route_info_icon_vertical_padding"
android:layout_marginRight="@dimen/context_menu_padding_margin_medium"
android:layout_marginBottom="@dimen/route_info_icon_vertical_padding"
tools:background="@drawable/btn_border_trans_rounded_dark">
tools:background="@drawable/btn_border_rounded_dark">
<LinearLayout
android:id="@+id/from_button_container"
@ -253,7 +253,7 @@
android:layout_marginTop="@dimen/route_info_icon_vertical_padding"
android:layout_marginRight="@dimen/context_menu_padding_margin_medium"
android:layout_marginBottom="@dimen/route_info_icon_vertical_padding"
tools:background="@drawable/btn_border_trans_rounded_dark">
tools:background="@drawable/btn_border_rounded_dark">
<LinearLayout
android:id="@+id/via_button_container"
@ -360,7 +360,7 @@
android:layout_marginTop="@dimen/route_info_icon_vertical_padding"
android:layout_marginRight="@dimen/context_menu_padding_margin_medium"
android:layout_marginBottom="@dimen/route_info_icon_vertical_padding"
tools:background="@drawable/btn_border_trans_rounded_dark">
tools:background="@drawable/btn_border_rounded_dark">
<LinearLayout
android:id="@+id/to_button_container"

View file

@ -13,7 +13,7 @@
android:layout_height="match_parent"
android:gravity="start"
android:visibility="visible"
tools:background="@drawable/btn_border_trans_dark">
tools:background="@drawable/btn_border_dark">
<ImageView
android:id="@+id/route_option_image_view"
@ -56,6 +56,6 @@
android:gravity="center"
android:orientation="horizontal"
android:visibility="visible"
tools:background="@drawable/btn_border_trans_dark" />
tools:background="@drawable/btn_border_dark" />
</LinearLayout>

View file

@ -6,7 +6,7 @@
android:layout_width="100dp"
android:layout_height="32dp"
android:orientation="horizontal"
tools:background="@drawable/btn_border_trans_dark">
tools:background="@drawable/btn_border_dark">
<FrameLayout
android:id="@+id/removable_option"

View file

@ -127,7 +127,7 @@ public class AppModeDialog {
}
}
public static void updateButtonState2(final OsmandApplication ctx, final List<ApplicationMode> visible,
public static void updateButtonStateForRoute(final OsmandApplication ctx, final List<ApplicationMode> visible,
final Set<ApplicationMode> selected, final View.OnClickListener onClickListener, final View[] buttons,
int i, final boolean singleChoice, final boolean useMapTheme, final boolean nightMode) {
if (buttons[i] != null) {
@ -143,11 +143,11 @@ public class AppModeDialog {
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.btn_border_trans_light, R.drawable.ripple_dark);
} else {
if (useMapTheme) {
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getSmallIconDark(), nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
@ -164,7 +164,6 @@ public class AppModeDialog {
} else {
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getSmallIconDark()));
}
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.btn_border_pressed_light, R.drawable.btn_border_pressed_dark);
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
}
tb.setOnClickListener(new View.OnClickListener() {
@ -188,7 +187,7 @@ public class AppModeDialog {
onClickListener.onClick(null);
}
for (int i = 0; i < visible.size(); i++) {
updateButtonState2(ctx, visible, selected, onClickListener, buttons, i, singleChoice, useMapTheme, nightMode);
updateButtonStateForRoute(ctx, visible, selected, onClickListener, buttons, i, singleChoice, useMapTheme, nightMode);
}
}
});

View file

@ -124,9 +124,11 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
buttonDescription.setTextColor(getResolvedColor(nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
FrameLayout buttonContainer = buttonView.findViewById(R.id.button_container);
AndroidUtils.setBackground(app, buttonContainer, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, buttonContainer, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, buttonDescription, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, buttonContainer, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
buttonContainer.setOnClickListener(new View.OnClickListener() {

View file

@ -537,7 +537,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
buttons[k++] = toggle;
}
for (int i = 0; i < buttons.length; i++) {
AppModeDialog.updateButtonState2((OsmandApplication) mapActivity.getApplication(), values, selected, listener, buttons, i, true, true, nightMode);
AppModeDialog.updateButtonStateForRoute((OsmandApplication) mapActivity.getApplication(), values, selected, listener, buttons, i, true, true, nightMode);
}
}
@ -675,7 +675,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
updateOptionsButtons(mainView);
}
});
AndroidUtils.setBackground(app, container, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
AndroidUtils.setBackground(app, container, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
item.addView(container, newLp);
optionsContainer.addView(item, lp);
}
@ -689,7 +689,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
updateOptionsButtons(mainView);
}
});
AndroidUtils.setBackground(app, container, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
AndroidUtils.setBackground(app, container, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
item.addView(container, newLp);
optionsContainer.addView(item, lp);
}
@ -832,9 +832,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
final int colorActive = ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
final int colorDisabled = ContextCompat.getColor(app, R.color.description_font_and_bottom_sheet_icons);
AndroidUtils.setBackground(app, item, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, item.findViewById(R.id.route_option_container), nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
AndroidUtils.setBackground(app, item, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
} else {
AndroidUtils.setBackground(app, item, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
Drawable itemDrawable = null;
@ -956,11 +958,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
});
LinearLayout viaButtonContainer = (LinearLayout) parentView.findViewById(R.id.via_button_container);
AndroidUtils.setBackground(app, viaButton, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, viaButton, nightMode, R.drawable.btn_border_rounded_light, R.drawable.btn_border_rounded_dark);
AndroidUtils.setBackground(app, viaButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
} else {
AndroidUtils.setBackground(app, viaButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
AndroidUtils.setBackground(app, viaButtonContainer, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
}
ImageView viaButtonImageView = (ImageView) parentView.findViewById(R.id.via_button_image_view);
@ -1027,11 +1029,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
final FrameLayout toButton = (FrameLayout) parentView.findViewById(R.id.to_button);
final LinearLayout toButtonContainer = (LinearLayout) parentView.findViewById(R.id.to_button_container);
AndroidUtils.setBackground(app, toButton, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, toButton, nightMode, R.drawable.btn_border_rounded_light, R.drawable.btn_border_rounded_dark);
AndroidUtils.setBackground(app, toButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
} else {
AndroidUtils.setBackground(app, toButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
AndroidUtils.setBackground(app, toButtonContainer, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
}
ImageView toButtonImageView = (ImageView) parentView.findViewById(R.id.to_button_image_view);
@ -1120,11 +1122,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
FrameLayout fromButton = (FrameLayout) parentView.findViewById(R.id.from_button);
final LinearLayout fromButtonContainer = (LinearLayout) parentView.findViewById(R.id.from_button_container);
AndroidUtils.setBackground(app, fromButton, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, fromButton, nightMode, R.drawable.btn_border_rounded_light, R.drawable.btn_border_rounded_dark);
AndroidUtils.setBackground(app, fromButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
} else {
AndroidUtils.setBackground(app, fromButtonContainer, nightMode, R.drawable.ripple_rounded_light, R.drawable.ripple_rounded_dark);
AndroidUtils.setBackground(app, fromButtonContainer, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
}
ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.from_button_image_view);

View file

@ -411,11 +411,11 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
addButtonDescr.setText(R.string.shared_string_add);
addButtonDescr.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_plus, R.color.active_buttons_and_links_light), null, null, null);
AndroidUtils.setBackground(app, addButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, addButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, addButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, addButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
AndroidUtils.setBackground(app, addButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
int colorActive = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
@ -426,7 +426,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
TextView clearButtonDescr = (TextView) view.findViewById(R.id.clear_all_button_descr);
clearButtonDescr.setText(R.string.shared_string_clear_all);
clearButtonDescr.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_clear_all, R.color.active_buttons_and_links_light), null, null, null);
AndroidUtils.setBackground(app, clearButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
AndroidUtils.setBackground(app, clearButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, clearButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);

View file

@ -2,6 +2,7 @@ package net.osmand.plus.routepreparationmenu.routeCards;
import android.graphics.Typeface;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.text.SpannableString;
@ -96,11 +97,11 @@ public class PublicTransportCard extends BaseRouteCard {
FrameLayout detailsButton = (FrameLayout) view.findViewById(R.id.details_button);
TextView detailsButtonDescr = (TextView) view.findViewById(R.id.details_button_descr);
AndroidUtils.setBackground(app, detailsButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, detailsButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, detailsButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, detailsButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
AndroidUtils.setBackground(app, detailsButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
int color = ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
detailsButtonDescr.setTextColor(color);
@ -108,11 +109,11 @@ public class PublicTransportCard extends BaseRouteCard {
FrameLayout showButton = (FrameLayout) view.findViewById(R.id.show_button);
if (secondButtonVisible) {
TextView showButtonDescr = (TextView) view.findViewById(R.id.show_button_descr);
AndroidUtils.setBackground(app, showButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, showButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, showButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, showButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
AndroidUtils.setBackground(app, showButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
showButtonDescr.setTextColor(color);
showButton.setVisibility(View.VISIBLE);

View file

@ -110,11 +110,11 @@ public class SimpleRouteCard extends BaseRouteCard {
protected void applyDayNightMode() {
FrameLayout detailsButton = view.findViewById(R.id.details_button);
AndroidUtils.setBackground(app, detailsButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, detailsButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.details_button_descr), nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, view.findViewById(R.id.details_button_descr), nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
AndroidUtils.setBackground(app, view.findViewById(R.id.details_button_descr), nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
int color = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
AndroidUtils.setBackground(app, view.findViewById(R.id.dividerToDropDown), nightMode, R.color.divider_light, R.color.divider_dark);