Merge pull request #7141 from osmandapp/prof_ui_fixes

Profiles ui fixes
This commit is contained in:
Alexey 2019-07-03 14:41:54 +03:00 committed by GitHub
commit 0713ada1df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 19 deletions

View file

@ -404,7 +404,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/edit_profile_configure_map" android:text="@string/configure_map"
android:textColor="?attr/main_font_color_basic" android:textColor="?attr/main_font_color_basic"
android:textSize="@dimen/default_list_text_size"/> android:textSize="@dimen/default_list_text_size"/>
@ -452,7 +452,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/edit_profile_configure_screen_title" android:text="@string/map_widget_config"
android:textColor="?attr/main_font_color_basic" android:textColor="?attr/main_font_color_basic"
android:textSize="@dimen/default_list_text_size"/> android:textSize="@dimen/default_list_text_size"/>
@ -502,7 +502,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/edit_profile_nav_settings_title" android:text="@string/routing_settings_2"
android:textColor="?attr/main_font_color_basic" android:textColor="?attr/main_font_color_basic"
android:textSize="@dimen/default_list_text_size"/> android:textSize="@dimen/default_list_text_size"/>

View file

@ -102,16 +102,18 @@
</LinearLayout> </LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent" >
<ImageView
android:id="@+id/selector_shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/abp__shadow_height"
android:src="@drawable/preference_activity_action_bar_shadow"
android:visibility="invisible"/>
<ListView <ListView
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -1465,8 +1465,7 @@
<string name="waypoint_visit_before">Відвідати, перш ніж</string> <string name="waypoint_visit_before">Відвідати, перш ніж</string>
<string name="simulate_your_location">Моделювання вашого місця розташування</string> <string name="simulate_your_location">Моделювання вашого місця розташування</string>
<string name="drawer">Суцільним списком</string> <string name="drawer">Суцільним списком</string>
<string name="short_location_on_map">Шир %1$s↵ <string name="short_location_on_map">Шир %1$s\nДов %2$s</string>
Дов %2$s</string>
<string name="tips_and_tricks_descr">Запитання та відповіді, останні зміни та інше.</string> <string name="tips_and_tricks_descr">Запитання та відповіді, останні зміни та інше.</string>
<string name="routing_settings_2">Налаштування навігації</string> <string name="routing_settings_2">Налаштування навігації</string>
<string name="general_settings_2">Загальні параметри</string> <string name="general_settings_2">Загальні параметри</string>

View file

@ -14,11 +14,8 @@
<string name="app_mode_offroad">Offroad</string> <string name="app_mode_offroad">Offroad</string>
<string name="edit_profile_setup_title">Setup Profile</string> <string name="edit_profile_setup_title">Setup Profile</string>
<string name="edit_profile_setup_subtitle">Profile keeps its own settings</string> <string name="edit_profile_setup_subtitle">Profile keeps its own settings</string>
<string name="edit_profile_configure_map">Configure map</string>
<string name="edit_profile_setup_map_subtitle">Select default map options for profile</string> <string name="edit_profile_setup_map_subtitle">Select default map options for profile</string>
<string name="edit_profile_configure_screen_title">Configure screen</string>
<string name="edit_profile_screen_options_subtitle">Select default screen options for profile</string> <string name="edit_profile_screen_options_subtitle">Select default screen options for profile</string>
<string name="edit_profile_nav_settings_title">Navigation settings</string>
<string name="edit_profile_nav_settings_subtitle">Select default navigation settings for profile</string> <string name="edit_profile_nav_settings_subtitle">Select default navigation settings for profile</string>
<string name="routing_attr_max_num_changes_description">Specify max number of changes</string> <string name="routing_attr_max_num_changes_description">Specify max number of changes</string>
<string name="routing_attr_max_num_changes_name">Number of changes</string> <string name="routing_attr_max_num_changes_name">Number of changes</string>

View file

@ -333,6 +333,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
if (profileSettings) { if (profileSettings) {
modes.clear(); modes.clear();
findViewById(R.id.selector_shadow).setVisibility(View.VISIBLE);
for (ApplicationMode a : ApplicationMode.values(app)) { for (ApplicationMode a : ApplicationMode.values(app)) {
if (a != ApplicationMode.DEFAULT) { if (a != ApplicationMode.DEFAULT) {
modes.add(a); modes.add(a);

View file

@ -1,6 +1,7 @@
package net.osmand.plus.activities.actions; package net.osmand.plus.activities.actions;
import android.app.Activity; import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
@ -8,11 +9,14 @@ import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.HorizontalScrollView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams; import android.widget.LinearLayout.LayoutParams;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -21,9 +25,12 @@ import net.osmand.plus.R;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.logging.Log;
public class AppModeDialog { public class AppModeDialog {
private static final Log LOG = PlatformUtil.getLog(AppModeDialog.class);
public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault, public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault,
ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener) { ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener) {
OsmandApplication app = (OsmandApplication) a.getApplication(); OsmandApplication app = (OsmandApplication) a.getApplication();
@ -58,7 +65,7 @@ public class AppModeDialog {
public static View prepareAppModeView(Activity a, final List<ApplicationMode> values, final Set<ApplicationMode> selected, public static View prepareAppModeView(Activity a, final List<ApplicationMode> values, final Set<ApplicationMode> selected,
ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener, boolean nightMode) { ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener, boolean nightMode) {
View ll = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent); final View ll = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
if (useListBg) { if (useListBg) {
AndroidUtils.setListItemBackground(a, ll, nightMode); AndroidUtils.setListItemBackground(a, ll, nightMode);
} else { } else {
@ -73,6 +80,23 @@ public class AppModeDialog {
updateButtonState((OsmandApplication) a.getApplication(), values, selected, onClickListener, buttons, i, updateButtonState((OsmandApplication) a.getApplication(), values, selected, onClickListener, buttons, i,
singleSelection, useMapTheme, nightMode); singleSelection, useMapTheme, nightMode);
} }
ApplicationMode activeMode = ((OsmandApplication) a.getApplication()).getSettings().getApplicationMode();
final int idx = values.indexOf(activeMode);
OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
HorizontalScrollView scrollView = ll.findViewById(R.id.app_modes_scroll_container);
LinearLayout container = ll.findViewById(R.id.app_modes_content);
int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() : 0;
scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
};
ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener);
return ll; return ll;
} }
@ -84,11 +108,13 @@ public class AppModeDialog {
View tb = buttons[i]; View tb = buttons[i];
final ApplicationMode mode = visible.get(i); final ApplicationMode mode = visible.get(i);
final boolean checked = selected.contains(mode); final boolean checked = selected.contains(mode);
final View selection = tb.findViewById(R.id.selection);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon); ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
if (checked) { if (checked) {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode))); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
tb.findViewById(R.id.selection).setVisibility(View.VISIBLE); selection.setBackgroundResource(mode.getIconColorInfo().getColor(nightMode));
selection.setVisibility(View.VISIBLE);
} else { } else {
if (useMapTheme) { if (useMapTheme) {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode))); iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
@ -97,7 +123,7 @@ public class AppModeDialog {
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes())); iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes()));
} }
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked))); iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
tb.findViewById(R.id.selection).setVisibility(View.INVISIBLE); selection.setVisibility(View.INVISIBLE);
} }
iv.setOnClickListener(new View.OnClickListener() { iv.setOnClickListener(new View.OnClickListener() {

View file

@ -3,6 +3,7 @@ package net.osmand.plus.routepreparationmenu;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.res.Configuration;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
@ -21,6 +22,7 @@ import android.support.v7.widget.AppCompatImageView;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.HorizontalScrollView; import android.widget.HorizontalScrollView;
import android.widget.ImageView; import android.widget.ImageView;
@ -30,6 +32,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.StateChangedListener; import net.osmand.StateChangedListener;
import net.osmand.ValueHolder; import net.osmand.ValueHolder;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
@ -103,9 +106,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import org.apache.commons.logging.Log;
public class MapRouteInfoMenu implements IRouteInformationListener, CardListener { public class MapRouteInfoMenu implements IRouteInformationListener, CardListener {
private static final Log LOG = PlatformUtil.getLog(MapRouteInfoMenu.class);
private static final int BUTTON_ANIMATION_DELAY = 2000; private static final int BUTTON_ANIMATION_DELAY = 2000;
public static final int DEFAULT_MENU_STATE = 0; public static final int DEFAULT_MENU_STATE = 0;
private static final int MAX_PEDESTRIAN_ROUTE_DURATION = 30 * 60; private static final int MAX_PEDESTRIAN_ROUTE_DURATION = 30 * 60;
@ -804,15 +810,15 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
updateApplicationMode(am, next); updateApplicationMode(am, next);
} }
View ll = mapActivity.getLayoutInflater().inflate(R.layout.mode_toggles, vg); final View ll = mapActivity.getLayoutInflater().inflate(R.layout.mode_toggles, vg);
ll.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.card_and_list_background_dark : R.color.card_and_list_background_light)); ll.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.card_and_list_background_dark : R.color.card_and_list_background_light));
HorizontalScrollView scrollView = ll.findViewById(R.id.app_modes_scroll_container); final HorizontalScrollView scrollView = ll.findViewById(R.id.app_modes_scroll_container);
scrollView.setVerticalScrollBarEnabled(false); scrollView.setVerticalScrollBarEnabled(false);
scrollView.setHorizontalScrollBarEnabled(false); scrollView.setHorizontalScrollBarEnabled(false);
int leftTogglePadding = AndroidUtils.dpToPx(mapActivity, 8f); int leftTogglePadding = AndroidUtils.dpToPx(mapActivity, 8f);
int rightTogglePadding = mapActivity.getResources().getDimensionPixelSize(R.dimen.content_padding); final int rightTogglePadding = mapActivity.getResources().getDimensionPixelSize(R.dimen.content_padding);
final View[] buttons = new View[values.size()]; final View[] buttons = new View[values.size()];
int k = 0; int k = 0;
Iterator<ApplicationMode> iterator = values.iterator(); Iterator<ApplicationMode> iterator = values.iterator();
@ -837,6 +843,21 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
for (int i = 0; i < buttons.length; i++) { for (int i = 0; i < buttons.length; i++) {
AppModeDialog.updateButtonStateForRoute((OsmandApplication) mapActivity.getApplication(), values, selected, listener, buttons, i, true, true, nightMode); AppModeDialog.updateButtonStateForRoute((OsmandApplication) mapActivity.getApplication(), values, selected, listener, buttons, i, true, true, nightMode);
} }
final ApplicationMode activeMode = app.getSettings().getApplicationMode();
final int idx = values.indexOf(activeMode);
OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
LinearLayout container = ll.findViewById(R.id.app_modes_content);
int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() + rightTogglePadding : 0;
scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
};
ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener);
} }
private void updateOptionsButtons() { private void updateOptionsButtons() {