Merge pull request #11298 from osmandapp/text_direction

Text direction
This commit is contained in:
Vitaliy 2021-04-05 09:31:25 +03:00 committed by GitHub
commit 529576d012
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 24 deletions

View file

@ -234,7 +234,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
ivIcon.setImageDrawable(icon); ivIcon.setImageDrawable(icon);
if (currentKey.equals(MANUALLY_SPECIFIED)) { if (currentKey.equals(MANUALLY_SPECIFIED)) {
tvSummary.setText(item.getDirectory()); setFormattedPath(item, tvSummary);
secondPart.setVisibility(View.GONE); secondPart.setVisibility(View.GONE);
tvAdditionalDescription.setVisibility(View.GONE); tvAdditionalDescription.setVisibility(View.GONE);
divider.setVisibility(View.GONE); divider.setVisibility(View.GONE);
@ -252,15 +252,8 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
} }
if (currentKey.equals(INTERNAL_STORAGE)) { if (currentKey.equals(INTERNAL_STORAGE)) {
tvAdditionalDescription.setText(item.getDescription()); tvAdditionalDescription.setText(item.getDescription());
} else if (currentKey.equals(SHARED_STORAGE)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
BidiFormatter rtlFormatter = BidiFormatter.getInstance();
tvAdditionalDescription.setText(rtlFormatter.unicodeWrap(item.getDirectory()));
} else { } else {
tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory())); setFormattedPath(item, tvAdditionalDescription);
}
} else {
tvAdditionalDescription.setText(item.getDirectory());
} }
} }
} }
@ -310,6 +303,15 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
} }
} }
private void setFormattedPath(StorageItem item, TextView tvAdditionalDescription) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
BidiFormatter pathRtlFormatter = BidiFormatter.getInstance();
tvAdditionalDescription.setText(pathRtlFormatter.unicodeWrap(item.getDirectory()));
} else {
tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory()));
}
}
@Override @Override
public void onDestroy() { public void onDestroy() {
if (!activity.isChangingConfigurations()) { if (!activity.isChangingConfigurations()) {

View file

@ -21,7 +21,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
import com.github.ksoichiro.android.observablescrollview.ObservableListView; import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.google.android.material.slider.RangeSlider; import com.google.android.material.slider.RangeSlider;
@ -50,14 +49,16 @@ import org.apache.commons.logging.Log;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
import java.util.Locale;
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.*; import static net.osmand.plus.UiUtilities.CustomRadioButtonType.END;
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.START;
import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE; import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE;
import static net.osmand.plus.download.DownloadActivityType.SLOPE_FILE; import static net.osmand.plus.download.DownloadActivityType.SLOPE_FILE;
import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE;
import static net.osmand.plus.srtmplugin.TerrainMode.SLOPE;
import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MAX_ZOOM; import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MAX_ZOOM;
import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MIN_ZOOM; import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MIN_ZOOM;
import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE;
import static net.osmand.plus.srtmplugin.TerrainMode.SLOPE;
public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener, public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener,
@ -102,7 +103,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
private ArrayAdapter<ContextMenuItem> listAdapter; private ArrayAdapter<ContextMenuItem> listAdapter;
private Slider.OnChangeListener transparencySliderChangeListener = new Slider.OnChangeListener() { private final Slider.OnChangeListener transparencySliderChangeListener = new Slider.OnChangeListener() {
@Override @Override
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
if (fromUser) { if (fromUser) {
@ -114,7 +115,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
} }
}; };
private RangeSlider.OnChangeListener zoomSliderChangeListener = new RangeSlider.OnChangeListener() { private final RangeSlider.OnChangeListener zoomSliderChangeListener = new RangeSlider.OnChangeListener() {
@Override @Override
public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) { public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) {
List<Float> values = slider.getValues(); List<Float> values = slider.getValues();
@ -186,11 +187,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
getString(R.string.slope_read_more), getString(R.string.slope_read_more),
wikiString wikiString
); );
String emptyStateText = String.format( String emptyStateText = getString(R.string.terrain_empty_state_text) + "\n" + PLUGIN_URL;
getString(R.string.ltr_or_rtl_combine_via_space),
getString(R.string.terrain_empty_state_text),
PLUGIN_URL
);
setupClickableText(slopeReadMoreTv, readMoreText, wikiString, SLOPES_WIKI_URL, false); setupClickableText(slopeReadMoreTv, readMoreText, wikiString, SLOPES_WIKI_URL, false);
setupClickableText(emptyStateDescriptionTv, emptyStateText, PLUGIN_URL, PLUGIN_URL, true); setupClickableText(emptyStateDescriptionTv, emptyStateText, PLUGIN_URL, PLUGIN_URL, true);