RTL - Step 3 (Fixes)
This commit is contained in:
parent
cb105deda0
commit
7ba03d94e4
7 changed files with 49 additions and 37 deletions
|
@ -425,6 +425,17 @@ public class AndroidUtils {
|
||||||
: ctx.getResources().getColor(R.color.text_color_secondary_light));
|
: ctx.getResources().getColor(R.color.text_color_secondary_light));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getPopupMenuWidth(Context ctx, float textSize, List<String> titles) {
|
||||||
|
int width = 0;
|
||||||
|
for (String title : titles) {
|
||||||
|
int titleWidth = getTextWidth(textSize, title);
|
||||||
|
if (titleWidth > width) {
|
||||||
|
width = titleWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return width + dpToPx(ctx, 34);
|
||||||
|
}
|
||||||
|
|
||||||
public static int getTextWidth(float textSize, String text) {
|
public static int getTextWidth(float textSize, String text) {
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
paint.setTextSize(textSize);
|
paint.setTextSize(textSize);
|
||||||
|
|
|
@ -12,10 +12,12 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import static net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SimplePopUpMenuItemAdapter
|
public class SimplePopUpMenuItemAdapter
|
||||||
extends ArrayAdapter<SimplePopUpMenuItemAdapter.SimplePopUpMenuItem> {
|
extends ArrayAdapter<SimplePopUpMenuItem> {
|
||||||
|
|
||||||
private List<SimplePopUpMenuItem> items;
|
private List<SimplePopUpMenuItem> items;
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ public class SimplePopUpMenuItemAdapter
|
||||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||||
LayoutInflater inflater = LayoutInflater.from(getContext());
|
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = inflater.inflate(R.layout.popup_menu_item, null);
|
convertView = inflater.inflate(R.layout.popup_menu_item, parent, false);
|
||||||
}
|
}
|
||||||
SimplePopUpMenuItem item = getItem(position);
|
SimplePopUpMenuItem item = getItem(position);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
|
|
@ -55,10 +55,13 @@ import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||||
|
|
||||||
|
import static net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem;
|
||||||
|
|
||||||
public class UiUtilities {
|
public class UiUtilities {
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(UiUtilities.class);
|
private static final Log LOG = PlatformUtil.getLog(UiUtilities.class);
|
||||||
|
@ -651,23 +654,18 @@ public class UiUtilities {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ListPopupWindow createListPopupWindow(Context themedCtx, View v,
|
public static ListPopupWindow createListPopupWindow(Context themedCtx,
|
||||||
List<SimplePopUpMenuItemAdapter.SimplePopUpMenuItem> items,
|
View v, int minWidth,
|
||||||
|
List<SimplePopUpMenuItem> items,
|
||||||
final AdapterView.OnItemClickListener listener) {
|
final AdapterView.OnItemClickListener listener) {
|
||||||
int contentPadding = themedCtx.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
|
||||||
int contentPaddingHalf = themedCtx.getResources().getDimensionPixelSize(R.dimen.content_padding_half);
|
int contentPaddingHalf = themedCtx.getResources().getDimensionPixelSize(R.dimen.content_padding_half);
|
||||||
|
int defaultListTextSize = themedCtx.getResources().getDimensionPixelSize(R.dimen.default_list_text_size);
|
||||||
|
|
||||||
Paint paint = new Paint();
|
List<String> titles = new ArrayList<>();
|
||||||
paint.setTextSize(themedCtx.getResources().getDimensionPixelSize(R.dimen.default_list_text_size));
|
for (SimplePopUpMenuItem item : items) {
|
||||||
CharSequence longestTitle = "";
|
titles.add(String.valueOf(item.getTitle()));
|
||||||
for (SimplePopUpMenuItemAdapter.SimplePopUpMenuItem item : items) {
|
|
||||||
if (item.getTitle().length() > longestTitle.length()) {
|
|
||||||
longestTitle = item.getTitle();
|
|
||||||
}
|
}
|
||||||
}
|
float itemWidth = AndroidUtils.getPopupMenuWidth(themedCtx, defaultListTextSize, titles);
|
||||||
float titleTextWidth = paint.measureText(longestTitle.toString());
|
|
||||||
float itemWidth = titleTextWidth + contentPadding;
|
|
||||||
float minWidth = v.getWidth();
|
|
||||||
|
|
||||||
SimplePopUpMenuItemAdapter adapter =
|
SimplePopUpMenuItemAdapter adapter =
|
||||||
new SimplePopUpMenuItemAdapter(themedCtx, R.layout.popup_menu_item, items);
|
new SimplePopUpMenuItemAdapter(themedCtx, R.layout.popup_menu_item, items);
|
||||||
|
|
|
@ -32,7 +32,6 @@ import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.SimplePopUpMenuItemAdapter;
|
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
@ -48,6 +47,8 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem;
|
||||||
|
|
||||||
public class TrackDetailsMenu {
|
public class TrackDetailsMenu {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -490,6 +491,9 @@ public class TrackDetailsMenu {
|
||||||
if (mapActivity == null || gpxItem == null) {
|
if (mapActivity == null || gpxItem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
|
final UiUtilities ic = app.getUIUtilities();
|
||||||
|
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||||
GPXTrackAnalysis analysis = gpxItem.analysis;
|
GPXTrackAnalysis analysis = gpxItem.analysis;
|
||||||
if (analysis == null || gpxItem.chartTypes == null) {
|
if (analysis == null || gpxItem.chartTypes == null) {
|
||||||
parentView.setVisibility(View.GONE);
|
parentView.setVisibility(View.GONE);
|
||||||
|
@ -576,9 +580,6 @@ public class TrackDetailsMenu {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final OsmandApplication app = mapActivity.getMyApplication();
|
|
||||||
final UiUtilities ic = app.getUIUtilities();
|
|
||||||
|
|
||||||
GpxUiHelper.setupGPXChart(app, chart, 4);
|
GpxUiHelper.setupGPXChart(app, chart, 4);
|
||||||
|
|
||||||
List<ILineDataSet> dataSets = new ArrayList<>();
|
List<ILineDataSet> dataSets = new ArrayList<>();
|
||||||
|
@ -652,15 +653,15 @@ public class TrackDetailsMenu {
|
||||||
yAxis.setOnClickListener(new View.OnClickListener() {
|
yAxis.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Context themedContext = UiUtilities.getThemedContext(v.getContext(), true);
|
Context themedContext = UiUtilities.getThemedContext(v.getContext(), nightMode);
|
||||||
List<SimplePopUpMenuItemAdapter.SimplePopUpMenuItem> items = new ArrayList<>();
|
List<SimplePopUpMenuItem> items = new ArrayList<>();
|
||||||
for (GPXDataSetType[] types : availableTypes) {
|
for (GPXDataSetType[] types : availableTypes) {
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
GPXDataSetType.getName(app, types),
|
GPXDataSetType.getName(app, types),
|
||||||
GPXDataSetType.getImageDrawable(app, types)));
|
GPXDataSetType.getImageDrawable(app, types)));
|
||||||
}
|
}
|
||||||
UiUtilities.createListPopupWindow(
|
UiUtilities.createListPopupWindow(
|
||||||
themedContext, v, items, new AdapterView.OnItemClickListener() {
|
themedContext, v, v.getWidth(), items, new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
GpxDisplayItem gpxItem = getGpxItem();
|
GpxDisplayItem gpxItem = getGpxItem();
|
||||||
|
@ -695,14 +696,14 @@ public class TrackDetailsMenu {
|
||||||
xAxis.setOnClickListener(new View.OnClickListener() {
|
xAxis.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Context themedContext = UiUtilities.getThemedContext(v.getContext(), true);
|
Context themedContext = UiUtilities.getThemedContext(v.getContext(), nightMode);
|
||||||
List<SimplePopUpMenuItemAdapter.SimplePopUpMenuItem> items = new ArrayList<>();
|
List<SimplePopUpMenuItem> items = new ArrayList<>();
|
||||||
for (GPXDataSetAxisType type : GPXDataSetAxisType.values()) {
|
for (GPXDataSetAxisType type : GPXDataSetAxisType.values()) {
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
app.getString(type.getStringId()), type.getImageDrawable(app)));
|
app.getString(type.getStringId()), type.getImageDrawable(app)));
|
||||||
}
|
}
|
||||||
UiUtilities.createListPopupWindow(themedContext,
|
UiUtilities.createListPopupWindow(themedContext,
|
||||||
v, items, new AdapterView.OnItemClickListener() {
|
v, v.getWidth(), items, new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
GpxDisplayItem gpxItem = getGpxItem();
|
GpxDisplayItem gpxItem = getGpxItem();
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
||||||
private TrackDetailsMenu menu;
|
private TrackDetailsMenu menu;
|
||||||
private View mainView;
|
private View mainView;
|
||||||
private boolean paused = true;
|
private boolean paused = true;
|
||||||
|
private boolean nightMode;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private MapActivity getMapActivity() {
|
private MapActivity getMapActivity() {
|
||||||
|
@ -46,7 +47,7 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
MapActivity mapActivity = requireMapActivity();
|
MapActivity mapActivity = requireMapActivity();
|
||||||
menu = mapActivity.getTrackDetailsMenu();
|
menu = mapActivity.getTrackDetailsMenu();
|
||||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
ContextThemeWrapper context =
|
ContextThemeWrapper context =
|
||||||
new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.track_details, container, false);
|
View view = LayoutInflater.from(context).inflate(R.layout.track_details, container, false);
|
||||||
|
@ -192,7 +193,6 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
boolean portraitMode = AndroidUiHelper.isOrientationPortrait(ctx);
|
boolean portraitMode = AndroidUiHelper.isOrientationPortrait(ctx);
|
||||||
boolean landscapeLayout = !portraitMode;
|
boolean landscapeLayout = !portraitMode;
|
||||||
boolean nightMode = ctx.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
|
||||||
if (!landscapeLayout) {
|
if (!landscapeLayout) {
|
||||||
AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -81,9 +81,8 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
|
||||||
}
|
}
|
||||||
int expandType = args.getInt(EXPAND_TYPE_KEY, -1);
|
int expandType = args.getInt(EXPAND_TYPE_KEY, -1);
|
||||||
|
|
||||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
final View titleView = UiUtilities.getInflater(ctx, nightMode)
|
||||||
final View titleView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
|
.inflate(R.layout.bottom_sheet_item_toolbar_title, null);
|
||||||
R.layout.bottom_sheet_item_toolbar_title, null);
|
|
||||||
TextView textView = (TextView) titleView.findViewById(R.id.title);
|
TextView textView = (TextView) titleView.findViewById(R.id.title);
|
||||||
textView.setText(R.string.show_along_the_route);
|
textView.setText(R.string.show_along_the_route);
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
private SearchUICore searchUICore;
|
private SearchUICore searchUICore;
|
||||||
private SearchResultListener defaultResultListener;
|
private SearchResultListener defaultResultListener;
|
||||||
private String searchQuery;
|
private String searchQuery;
|
||||||
|
private boolean nightMode;
|
||||||
|
|
||||||
private LatLon centerLatLon;
|
private LatLon centerLatLon;
|
||||||
private net.osmand.Location location = null;
|
private net.osmand.Location location = null;
|
||||||
|
@ -229,6 +230,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
app = getMyApplication();
|
app = getMyApplication();
|
||||||
|
nightMode = !app.getSettings().isLightContent();
|
||||||
navigationInfo = new NavigationInfo(app);
|
navigationInfo = new NavigationInfo(app);
|
||||||
accessibilityAssistant = new AccessibilityAssistant(getActivity());
|
accessibilityAssistant = new AccessibilityAssistant(getActivity());
|
||||||
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||||
|
@ -242,7 +244,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
final MapActivity mapActivity = getMapActivity();
|
final MapActivity mapActivity = getMapActivity();
|
||||||
final View view = inflater.inflate(R.layout.search_dialog_fragment, container, false);
|
final View view = inflater.inflate(R.layout.search_dialog_fragment, container, false);
|
||||||
final boolean nightMode = !app.getSettings().isLightContent();
|
|
||||||
|
|
||||||
toolbarController = new QuickSearchToolbarController();
|
toolbarController = new QuickSearchToolbarController();
|
||||||
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
|
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
|
||||||
|
|
Loading…
Reference in a new issue