Preferences ui fixes
This commit is contained in:
parent
88fd3881a4
commit
6f569e9565
9 changed files with 123 additions and 49 deletions
|
@ -14,15 +14,25 @@
|
|||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
tools:background="?android:attr/selectableItemBackground">
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
<FrameLayout
|
||||
android:id="@+id/icon_container"
|
||||
android:layout_width="@dimen/route_info_toolbar_button_size"
|
||||
android:layout_height="@dimen/route_info_toolbar_button_size"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_icon_margin" />
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginTop="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:layout_marginBottom="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center"
|
||||
tools:src="@drawable/ic_action_car_dark"
|
||||
tools:tint="@color/active_color_primary_light" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -77,18 +77,20 @@
|
|||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
android:paddingTop="@dimen/content_padding_half"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/content_padding_half">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/profile_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:letterSpacing="@dimen/title_letter_spacing"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
tools:text="@string/profile_type_base_string" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
|
@ -98,8 +100,10 @@
|
|||
android:ellipsize="end"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="@dimen/text_margin_small"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:visibility="gone"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
tools:text="Item additional description" />
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
|
@ -426,6 +425,12 @@ public class AndroidUtils {
|
|||
return outValue.resourceId;
|
||||
}
|
||||
|
||||
public static float getFloatValueFromRes(Context ctx, int resId) {
|
||||
TypedValue outValue = new TypedValue();
|
||||
ctx.getResources().getValue(resId, outValue, true);
|
||||
return outValue.getFloat();
|
||||
}
|
||||
|
||||
public static int getStatusBarHeight(Context ctx) {
|
||||
int result = 0;
|
||||
int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
|
|
|
@ -60,11 +60,11 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
|||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.profiles.AppModesBottomSheetDialogFragment;
|
||||
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment;
|
||||
import net.osmand.plus.profiles.SettingsProfileActivity;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
|
||||
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||
import net.osmand.plus.settings.ConfigureProfileFragment;
|
||||
import net.osmand.plus.views.BaseMapLayer;
|
||||
import net.osmand.plus.views.MapControlsLayer;
|
||||
|
@ -74,7 +74,6 @@ import net.osmand.plus.wikivoyage.WikivoyageWelcomeDialogFragment;
|
|||
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
||||
import net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -639,13 +638,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
//switch profile button
|
||||
ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get();
|
||||
String modeDescription;
|
||||
if (currentMode.isCustomProfile()) {
|
||||
modeDescription = String.format(app.getString(R.string.profile_type_descr_string),
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(currentMode.getParent().toHumanString(app)));
|
||||
} else {
|
||||
modeDescription = getString(R.string.profile_type_base_string);
|
||||
}
|
||||
String modeDescription = BaseSettingsFragment.getAppModeDescription(app, currentMode);
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.main_menu_drawer_btn_switch_profile)
|
||||
.setIcon(currentMode.getIconRes())
|
||||
.setColor(currentMode.getIconColorInfo().getColor(nightMode))
|
||||
|
|
|
@ -11,16 +11,19 @@ import android.view.ViewGroup;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<ConfigureProfileMenuAdapter.ConfigureProfileViewHolder> {
|
||||
|
||||
|
@ -101,12 +104,7 @@ public class ConfigureProfileMenuAdapter extends AbstractProfileMenuAdapter<Conf
|
|||
holder.menuIcon.setVisibility(View.VISIBLE);
|
||||
final ApplicationMode item = (ApplicationMode) obj;
|
||||
holder.title.setText(item.toHumanString(app));
|
||||
if (item.isCustomProfile()) {
|
||||
holder.descr.setText(String.format(app.getString(R.string.profile_type_descr_string),
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(item.getParent().toHumanString(app))));
|
||||
} else {
|
||||
holder.descr.setText(R.string.profile_type_base_string);
|
||||
}
|
||||
holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item));
|
||||
|
||||
holder.initSwitcher = true;
|
||||
holder.switcher.setChecked(selectedItems.contains(item));
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.osmand.plus.ApplicationMode;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -95,12 +96,7 @@ public class SelectProfileMenuAdapter extends AbstractProfileMenuAdapter<SelectP
|
|||
holder.menuIcon.setVisibility(View.GONE);
|
||||
final ApplicationMode item = (ApplicationMode) obj;
|
||||
holder.title.setText(item.toHumanString(app));
|
||||
if (item.isCustomProfile()) {
|
||||
holder.descr.setText(String.format(app.getString(R.string.profile_type_descr_string),
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(item.getParent().toHumanString(app))));
|
||||
} else {
|
||||
holder.descr.setText(R.string.profile_type_base_string);
|
||||
}
|
||||
holder.descr.setText(BaseSettingsFragment.getAppModeDescription(app, item));
|
||||
|
||||
int profileColorResId = item.getIconColorInfo().getColor(nightMode);
|
||||
holder.icon.setImageDrawable(app.getUIUtilities().getIcon(profileColorResId, selectedIconColorRes));
|
||||
|
|
|
@ -56,6 +56,7 @@ import net.osmand.plus.settings.bottomsheets.SingleSelectPreferenceBottomSheet;
|
|||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
import net.osmand.plus.settings.preferences.MultiSelectBooleanPreference;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener,
|
||||
OnPreferenceClickListener, AppModeChangedListener {
|
||||
|
@ -306,10 +307,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
String appName = selectedAppMode.toHumanString(app);
|
||||
profileTitle.setText(appName);
|
||||
}
|
||||
TextView profileType = (TextView) view.findViewById(R.id.profile_type);
|
||||
if (profileType != null) {
|
||||
profileType.setVisibility(View.GONE);
|
||||
}
|
||||
View toolbarDivider = view.findViewById(R.id.toolbar_divider);
|
||||
if (toolbarDivider != null) {
|
||||
toolbarDivider.setBackgroundColor(iconColor);
|
||||
|
@ -588,4 +585,16 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
|
||||
return listPreference;
|
||||
}
|
||||
|
||||
public static String getAppModeDescription(Context ctx, ApplicationMode mode) {
|
||||
String description;
|
||||
if (mode.isCustomProfile()) {
|
||||
description = String.format(ctx.getString(R.string.profile_type_descr_string),
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(mode.getParent().toHumanString(ctx)));
|
||||
} else {
|
||||
description = ctx.getString(R.string.profile_type_base_string);
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -33,6 +34,7 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.PluginActivity;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -96,6 +98,35 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createToolbar(LayoutInflater inflater, View view) {
|
||||
super.createToolbar(inflater, view);
|
||||
|
||||
TextView toolbarTitle = (TextView) view.findViewById(R.id.profile_title);
|
||||
toolbarTitle.setTypeface(FontCache.getRobotoMedium(view.getContext()));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
float letterSpacing = AndroidUtils.getFloatValueFromRes(view.getContext(), R.dimen.title_letter_spacing);
|
||||
toolbarTitle.setLetterSpacing(letterSpacing);
|
||||
}
|
||||
TextView profileType = (TextView) view.findViewById(R.id.profile_type);
|
||||
profileType.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateToolbar() {
|
||||
super.updateToolbar();
|
||||
|
||||
View view = getView();
|
||||
if (view != null) {
|
||||
ApplicationMode selectedMode = getSelectedAppMode();
|
||||
String appModeType = getAppModeDescription(view.getContext(), selectedMode);
|
||||
|
||||
TextView profileType = (TextView) view.findViewById(R.id.profile_type);
|
||||
profileType.setText(appModeType);
|
||||
}
|
||||
}
|
||||
|
||||
private RecyclerView.ItemDecoration createDividerItemDecoration() {
|
||||
final Drawable dividerLight = new ColorDrawable(ContextCompat.getColor(app, R.color.list_background_color_light));
|
||||
final Drawable dividerDark = new ColorDrawable(ContextCompat.getColor(app, R.color.list_background_color_dark));
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.profiles.SettingsProfileActivity;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class MainSettingsFragment extends BaseSettingsFragment {
|
||||
|
||||
public static final String TAG = MainSettingsFragment.class.getSimpleName();
|
||||
|
||||
private static final String CONFIGURE_PROFILE = "configure_profile";
|
||||
|
||||
@Override
|
||||
protected String getFragmentTag() {
|
||||
return TAG;
|
||||
|
@ -53,6 +61,31 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
setupManageProfilesPref();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
|
||||
String key = preference.getKey();
|
||||
if (CONFIGURE_PROFILE.equals(key)) {
|
||||
View iconContainer = holder.itemView.findViewById(R.id.icon_container);
|
||||
if (iconContainer != null) {
|
||||
int profileColor = getActiveProfileColor();
|
||||
int bgColor = UiUtilities.getColorWithAlpha(profileColor, 0.1f);
|
||||
Drawable backgroundDrawable;
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
int selectedColor = UiUtilities.getColorWithAlpha(profileColor, 0.3f);
|
||||
Drawable background = getPaintedIcon(R.drawable.circle_background_light, bgColor);
|
||||
Drawable ripple = getPaintedIcon(R.drawable.ripple_circle, selectedColor);
|
||||
backgroundDrawable = new LayerDrawable(new Drawable[] {background, ripple});
|
||||
} else {
|
||||
backgroundDrawable = getPaintedIcon(R.drawable.circle_background_light, bgColor);
|
||||
}
|
||||
AndroidUtils.setBackground(iconContainer, backgroundDrawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupManageProfilesPref() {
|
||||
Preference manageProfiles = findPreference("manage_profiles");
|
||||
manageProfiles.setIcon(getIcon(R.drawable.ic_action_manage_profiles));
|
||||
|
@ -63,16 +96,10 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
ApplicationMode selectedMode = getSelectedAppMode();
|
||||
|
||||
String title = selectedMode.toHumanString(getContext());
|
||||
String profileType;
|
||||
if (selectedMode.isCustomProfile()) {
|
||||
profileType = String.format(getString(R.string.profile_type_descr_string), Algorithms.capitalizeFirstLetterAndLowercase(selectedMode.getParent().toHumanString(getContext())));
|
||||
} else {
|
||||
profileType = getString(R.string.profile_type_base_string);
|
||||
}
|
||||
|
||||
String profileType = getAppModeDescription(getContext(), selectedMode);
|
||||
int iconRes = selectedMode.getIconRes();
|
||||
|
||||
Preference configureProfile = findPreference("configure_profile");
|
||||
Preference configureProfile = findPreference(CONFIGURE_PROFILE);
|
||||
configureProfile.setIcon(getPaintedIcon(iconRes, getActiveProfileColor()));
|
||||
configureProfile.setTitle(title);
|
||||
configureProfile.setSummary(profileType);
|
||||
|
|
Loading…
Reference in a new issue