Merge pull request #11500 from osmandapp/FixRtl

RTL
This commit is contained in:
Vitaliy 2021-04-22 15:17:56 +03:00 committed by GitHub
commit c1b416448f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 60 additions and 113 deletions

View file

@ -0,0 +1,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="@dimen/list_item_button_padding"
android:topLeftRadius="@dimen/list_item_button_padding" />
<solid android:color="@color/list_background_color_dark" />
</shape>

View file

@ -0,0 +1,11 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/active_buttons_and_links_trans_light">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="@dimen/list_item_button_padding"
android:topLeftRadius="@dimen/list_item_button_padding" />
<solid android:color="@color/active_color_primary_light" />
</shape>
</item>
</ripple>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/background">
<shape android:shape="rectangle">
<solid android:color="#4d007eb3" />
<corners android:radius="30dp" />
</shape>
</item>
<item android:id="@+id/progress">
<shape android:shape="rectangle">
<solid android:color="@color/color_white" />
<corners android:radius="30dp" />
</shape>
</item>
</layer-list>

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<item android:id="@+id/thump">
<shape android:shape="oval">
<size
android:width="12dp"
android:height="12dp" />
<solid android:color="@color/profile_icon_color_blue_light" />
</shape>
</item>
</layer-list>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="2dp"
android:height="2dp" />
<solid android:color="#17181A" />
</shape>

View file

@ -62,18 +62,12 @@
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
tools:text="Normal" /> tools:text="Normal" />
<SeekBar <com.google.android.material.slider.Slider
android:id="@+id/seek_bar_arrival" android:id="@+id/arrival_slider"
style="@style/Widget.AppCompat.SeekBar.Discrete"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/pages_item_margin" android:layout_marginLeft="@dimen/content_padding"
android:maxHeight="2dp" android:layout_marginRight="@dimen/content_padding" />
android:paddingTop="11dp"
android:paddingBottom="11dp"
osmand:tickMark="@drawable/seekbar_tickmark_announcement_time"
tools:max="3"
tools:progress="1" />
<View <View
android:id="@+id/divider" android:id="@+id/divider"

View file

@ -445,6 +445,9 @@ public class ContextMenuAdapter {
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon); ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
imageView.setImageDrawable(drawable); imageView.setImageDrawable(drawable);
imageView.setVisibility(View.VISIBLE); imageView.setVisibility(View.VISIBLE);
if (secondaryDrawable == R.drawable.ic_action_additional_option) {
UiUtilities.rotateImageByLayoutDirection(imageView);
}
} else { } else {
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon); ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
if (imageView != null) { if (imageView != null) {

View file

@ -275,16 +275,14 @@ public class LiveUpdatesFragment extends BaseOsmAndDialogFragment implements OnL
TextViewEx toolbarTitle = (TextViewEx) toolbar.findViewById(R.id.toolbar_title); TextViewEx toolbarTitle = (TextViewEx) toolbar.findViewById(R.id.toolbar_title);
toolbarTitle.setText(R.string.osm_live); toolbarTitle.setText(R.string.osm_live);
View closeButton = toolbar.findViewById(R.id.close_button); ImageView closeButton = (ImageView) toolbar.findViewById(R.id.close_button);
UiUtilities.rotateImageByLayoutDirection(closeButton);
closeButton.setOnClickListener(new View.OnClickListener() { closeButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
dismiss(); dismiss();
} }
}); });
if (closeButton instanceof ImageView) {
UiUtilities.rotateImageByLayoutDirection((ImageView) closeButton);
}
FrameLayout iconHelpContainer = toolbar.findViewById(R.id.action_button); FrameLayout iconHelpContainer = toolbar.findViewById(R.id.action_button);
int iconColorResId = nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light; int iconColorResId = nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light;
@ -443,6 +441,8 @@ public class LiveUpdatesFragment extends BaseOsmAndDialogFragment implements OnL
boolean isLastChild, View convertView, ViewGroup parent) { boolean isLastChild, View convertView, ViewGroup parent) {
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
convertView = inflater.inflate(R.layout.list_item_triple_row_icon_and_menu, parent, false); convertView = inflater.inflate(R.layout.list_item_triple_row_icon_and_menu, parent, false);
ImageView secondaryIcon = (ImageView) convertView.findViewById(R.id.secondary_icon);
UiUtilities.rotateImageByLayoutDirection(secondaryIcon);
LiveMapsViewHolder viewHolder = new LiveMapsViewHolder(convertView); LiveMapsViewHolder viewHolder = new LiveMapsViewHolder(convertView);
convertView.setTag(viewHolder); convertView.setTag(viewHolder);
viewHolder.bindLocalIndexInfo(getChild(groupPosition, childPosition).getFileName()); viewHolder.bindLocalIndexInfo(getChild(groupPosition, childPosition).getFileName());

View file

@ -1,26 +1,24 @@
package net.osmand.plus.settings.bottomsheets; package net.osmand.plus.settings.bottomsheets;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.SeekBar;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import com.google.android.material.slider.Slider;
import com.google.android.material.slider.Slider.OnChangeListener;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem.Builder;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.routing.data.AnnounceTimeDistances; import net.osmand.plus.routing.data.AnnounceTimeDistances;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
@ -33,8 +31,7 @@ import org.apache.commons.logging.Log;
import static net.osmand.plus.settings.bottomsheets.SingleSelectPreferenceBottomSheet.SELECTED_ENTRY_INDEX_KEY; import static net.osmand.plus.settings.bottomsheets.SingleSelectPreferenceBottomSheet.SELECTED_ENTRY_INDEX_KEY;
public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet {
implements SeekBar.OnSeekBarChangeListener {
public static final String TAG = AnnouncementTimeBottomSheet.class.getSimpleName(); public static final String TAG = AnnouncementTimeBottomSheet.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(AnnouncementTimeBottomSheet.class); private static final Log LOG = PlatformUtil.getLog(AnnouncementTimeBottomSheet.class);
@ -46,7 +43,7 @@ public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet
private int selectedEntryIndex = -1; private int selectedEntryIndex = -1;
private TextViewEx tvSeekBarLabel; private TextViewEx tvSeekBarLabel;
private SeekBar seekBarArrival; private Slider slider;
private ImageView ivArrow; private ImageView ivArrow;
private TextViewEx tvIntervalsDescr; private TextViewEx tvIntervalsDescr;
@ -110,22 +107,6 @@ public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet
dismiss(); dismiss();
} }
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (progress != selectedEntryIndex) {
selectedEntryIndex = progress;
updateViews();
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
private ListPreferenceEx getListPreference() { private ListPreferenceEx getListPreference() {
return (ListPreferenceEx) getPreference(); return (ListPreferenceEx) getPreference();
} }
@ -135,30 +116,40 @@ public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet
.inflate(R.layout.bottom_sheet_announcement_time, null); .inflate(R.layout.bottom_sheet_announcement_time, null);
tvSeekBarLabel = rootView.findViewById(R.id.tv_seek_bar_label); tvSeekBarLabel = rootView.findViewById(R.id.tv_seek_bar_label);
seekBarArrival = rootView.findViewById(R.id.seek_bar_arrival); slider = rootView.findViewById(R.id.arrival_slider);
ivArrow = rootView.findViewById(R.id.iv_arrow); ivArrow = rootView.findViewById(R.id.iv_arrow);
tvIntervalsDescr = rootView.findViewById(R.id.tv_interval_descr); tvIntervalsDescr = rootView.findViewById(R.id.tv_interval_descr);
int appModeColor = getAppMode().getProfileColor(nightMode);
setProfileColorToSeekBar(); slider.setValue(selectedEntryIndex);
seekBarArrival.setOnSeekBarChangeListener(this); slider.setValueFrom(0);
seekBarArrival.setProgress(selectedEntryIndex); slider.setValueTo(listPreference.getEntries().length - 1);
seekBarArrival.setMax(listPreference.getEntries().length - 1); slider.setStepSize(1);
rootView.findViewById(R.id.description_container).setOnClickListener(new View.OnClickListener() { slider.addOnChangeListener(new OnChangeListener() {
@Override
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
int intValue = (int) value;
if (intValue != selectedEntryIndex) {
selectedEntryIndex = intValue;
updateViews();
}
}
});
UiUtilities.setupSlider(slider, nightMode, appModeColor, true);
rootView.findViewById(R.id.description_container).setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
toggleDescriptionVisibility(); toggleDescriptionVisibility();
} }
}); });
return new BaseBottomSheetItem.Builder() return new Builder()
.setCustomView(rootView) .setCustomView(rootView)
.create(); .create();
} }
private void updateViews() { private void updateViews() {
seekBarArrival.setProgress(selectedEntryIndex);
tvSeekBarLabel.setText(listPreference.getEntries()[selectedEntryIndex]); tvSeekBarLabel.setText(listPreference.getEntries()[selectedEntryIndex]);
float value = (float) listPreference.getEntryValues()[selectedEntryIndex]; float value = (float) listPreference.getEntryValues()[selectedEntryIndex];
announceTimeDistances.setArrivalDistances(value); announceTimeDistances.setArrivalDistances(value);
tvIntervalsDescr.setText(announceTimeDistances.getIntervalsDescription(app)); tvIntervalsDescr.setText(announceTimeDistances.getIntervalsDescription(app));
@ -170,31 +161,6 @@ public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet
AndroidUiHelper.updateVisibility(tvIntervalsDescr, !collapsed); AndroidUiHelper.updateVisibility(tvIntervalsDescr, !collapsed);
} }
private void setProfileColorToSeekBar() {
int color = getAppMode().getProfileColor(nightMode);
LayerDrawable seekBarProgressLayer =
(LayerDrawable) ContextCompat.getDrawable(app, R.drawable.seekbar_progress_announcement_time);
GradientDrawable background = (GradientDrawable) seekBarProgressLayer.findDrawableByLayerId(R.id.background);
background.setColor(color);
background.setAlpha(70);
GradientDrawable progress = (GradientDrawable) seekBarProgressLayer.findDrawableByLayerId(R.id.progress);
progress.setColor(color);
Drawable clippedProgress = new ClipDrawable(progress, Gravity.CENTER_VERTICAL | Gravity.START, 1);
seekBarArrival.setProgressDrawable(new LayerDrawable(new Drawable[] {
background, clippedProgress
}));
LayerDrawable seekBarThumpLayer =
(LayerDrawable) ContextCompat.getDrawable(app, R.drawable.seekbar_thumb_announcement_time);
GradientDrawable thump = (GradientDrawable) seekBarThumpLayer.findDrawableByLayerId(R.id.thump);
thump.setColor(color);
seekBarArrival.setThumb(thump);
}
public static void showInstance(@NonNull FragmentManager fm, String prefKey, Fragment target, public static void showInstance(@NonNull FragmentManager fm, String prefKey, Fragment target,
@Nullable ApplicationMode appMode, boolean usedOnMap) { @Nullable ApplicationMode appMode, boolean usedOnMap) {
try { try {

View file

@ -134,6 +134,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
public static void updateCustomButtonView(OsmandApplication app, ApplicationMode mode, View customView, boolean checked, boolean nightMode) { public static void updateCustomButtonView(OsmandApplication app, ApplicationMode mode, View customView, boolean checked, boolean nightMode) {
Context themedCtx = UiUtilities.getThemedContext(app, nightMode); Context themedCtx = UiUtilities.getThemedContext(app, nightMode);
boolean isLayoutRtl = AndroidUtils.isLayoutRtl(themedCtx);
LinearLayout buttonView = customView.findViewById(R.id.button_container); LinearLayout buttonView = customView.findViewById(R.id.button_container);
int bgColor; int bgColor;
@ -149,10 +150,11 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
ContextCompat.getColor(app, getActivePrimaryColorId(nightMode)), checked ? 0.3f : 0.5f); ContextCompat.getColor(app, getActivePrimaryColorId(nightMode)), checked ? 0.3f : 0.5f);
} }
int bgResId = R.drawable.rectangle_rounded_right; int bgResId = isLayoutRtl ? R.drawable.rectangle_rounded_left : R.drawable.rectangle_rounded_right;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
int selectableResId = R.drawable.ripple_rectangle_rounded_right; int selectableResId = isLayoutRtl ?
R.drawable.ripple_rectangle_rounded_left :
R.drawable.ripple_rectangle_rounded_right;
Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor); Drawable bgDrawable = app.getUIUtilities().getPaintedIcon(bgResId, bgColor);
Drawable selectable = app.getUIUtilities().getPaintedIcon(selectableResId, selectedColor); Drawable selectable = app.getUIUtilities().getPaintedIcon(selectableResId, selectedColor);
Drawable[] layers = {bgDrawable, selectable}; Drawable[] layers = {bgDrawable, selectable};