Fix search screen night mode and improve settings ui

This commit is contained in:
Chumva 2019-09-10 11:23:30 +03:00
parent 19b8c85b5d
commit 5fdde1e250
8 changed files with 119 additions and 68 deletions

View file

@ -9,8 +9,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height">
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
@ -18,38 +17,28 @@
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" />
android:layout_marginTop="@dimen/content_padding_small"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding_small" />
<LinearLayout
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:layout_marginBottom="@dimen/context_menu_padding_margin_tiny"
android:background="?attr/divider_color_basic" />
<Switch
android:id="@android:id/switch_widget"
@ -61,13 +50,6 @@
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
android:background="?attr/divider_color_basic" />
</LinearLayout>
</LinearLayout>

View file

@ -56,8 +56,8 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:clickable="true"
android:focusable="true"
android:clickable="false"
android:focusable="false"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" />

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
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" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="4"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
android:background="?attr/divider_color_basic" />
<Switch
android:id="@android:id/switch_widget"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:clickable="true"
android:focusable="true"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" />
</LinearLayout>
</LinearLayout>

View file

@ -63,21 +63,21 @@
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="use_kalman_filter_compass"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/use_kalman_filter_compass" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="use_magnetic_field_sensor_compass"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/use_magnetic_sensor" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="map_empty_state_allowed"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/tap_on_map_to_hide_interface" />
@ -91,7 +91,7 @@
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="external_input_device"
android:layout="@layout/preference_dialog_and_switch"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:title="@string/external_input_device" />
</PreferenceScreen>

View file

@ -17,7 +17,8 @@
<Preference
android:key="external_storage_dir"
android:layout="@layout/preference_with_descr" android:persistent="false"
android:layout="@layout/preference_with_descr"
android:persistent="false"
android:title="@string/application_dir"
tools:icon="@drawable/ic_action_folder" />

View file

@ -5,6 +5,7 @@ import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.support.v7.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -45,6 +46,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
private OsmandApplication app;
private Activity activity;
private AccessibilityAssistant accessibilityAssistant;
private LayoutInflater inflater;
private boolean useMapCenter;
@ -70,6 +72,11 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
super(app, R.layout.search_list_item);
this.app = app;
this.activity = activity;
int themeRes = !app.getSettings().isLightContent() ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(activity, themeRes);
this.inflater = activity.getLayoutInflater().cloneInContext(themedContext);
dp56 = AndroidUtils.dpToPx(app, 56f);
dp1 = AndroidUtils.dpToPx(app, 1f);
updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache();
@ -192,7 +199,6 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
LinearLayout view;
if (type == QuickSearchListItemType.SEARCH_MORE) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(R.layout.search_more_list_item, null);
} else {
view = (LinearLayout) convertView;
@ -257,10 +263,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
}
} else if (type == QuickSearchListItemType.BUTTON) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.search_custom_list_item, null);
view = (LinearLayout) inflater.inflate(R.layout.search_custom_list_item, null);
} else {
view = (LinearLayout) convertView;
}
@ -272,10 +275,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
}
} else if (type == QuickSearchListItemType.SELECT_ALL) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.select_all_list_item, null);
view = (LinearLayout) inflater.inflate(R.layout.select_all_list_item, null);
} else {
view = (LinearLayout) convertView;
}
@ -291,10 +291,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
});
} else if (type == QuickSearchListItemType.HEADER) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.search_header_list_item, null);
view = (LinearLayout) inflater.inflate(R.layout.search_header_list_item, null);
} else {
view = (LinearLayout) convertView;
}
@ -307,30 +304,21 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
}
} else if (type == QuickSearchListItemType.TOP_SHADOW) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.list_shadow_header, null);
view = (LinearLayout) inflater.inflate(R.layout.list_shadow_header, null);
} else {
view = (LinearLayout) convertView;
}
return view;
} else if (type == QuickSearchListItemType.BOTTOM_SHADOW) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.list_shadow_footer, null);
view = (LinearLayout) inflater.inflate(R.layout.list_shadow_footer, null);
} else {
view = (LinearLayout) convertView;
}
return view;
} else {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) app
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = (LinearLayout) inflater.inflate(
R.layout.search_list_item, null);
view = (LinearLayout) inflater.inflate(R.layout.search_list_item, null);
} else {
view = (LinearLayout) convertView;
}

View file

@ -67,7 +67,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
}
private void setupTimeConditionalRoutingPref() {
SwitchPreference timeConditionalRouting = createSwitchPreferenceEx(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId(), R.string.temporary_conditional_routing, R.layout.preference_dialog_and_switch);
SwitchPreference timeConditionalRouting = createSwitchPreferenceEx(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId(), R.string.temporary_conditional_routing, R.layout.preference_with_descr_dialog_and_switch);
timeConditionalRouting.setIcon(getRoutingPrefIcon(settings.ENABLE_TIME_CONDITIONAL_ROUTING.getId()));
timeConditionalRouting.setSummaryOn(R.string.shared_string_enable);
timeConditionalRouting.setSummaryOff(R.string.shared_string_disable);
@ -81,7 +81,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
}
PreferenceScreen screen = getPreferenceScreen();
SwitchPreferenceEx fastRoute = createSwitchPreferenceEx(app.getSettings().FAST_ROUTE_MODE.getId(), R.string.fast_route_mode, R.layout.preference_dialog_and_switch);
SwitchPreferenceEx fastRoute = createSwitchPreferenceEx(app.getSettings().FAST_ROUTE_MODE.getId(), R.string.fast_route_mode, R.layout.preference_with_descr_dialog_and_switch);
fastRoute.setIcon(getRoutingPrefIcon(app.getSettings().FAST_ROUTE_MODE.getId()));
fastRoute.setDescription(getString(R.string.fast_route_mode_descr));
fastRoute.setSummaryOn(R.string.shared_string_enable);
@ -151,6 +151,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
preferRouting.setTitle(R.string.prefer_in_routing_title);
preferRouting.setSummary(R.string.prefer_in_routing_descr);
preferRouting.setLayoutResource(R.layout.preference_with_descr);
preferRouting.setIconSpaceReserved(true);
screen.addPreference(preferRouting);
}
if (reliefFactorParameters.size() > 0) {
@ -174,6 +175,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
reliefFactorRouting.setPersistent(false);
reliefFactorRouting.setValue(selectedParameterId);
reliefFactorRouting.setDescription(R.string.relief_smoothness_factor_descr);
reliefFactorRouting.setIconSpaceReserved(true);
screen.addPreference(reliefFactorRouting);
}
@ -184,11 +186,12 @@ public class RouteParametersFragment extends BaseSettingsFragment {
if (p.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
OsmandSettings.OsmandPreference pref = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
SwitchPreferenceEx switchPreferenceEx = (SwitchPreferenceEx) createSwitchPreferenceEx(pref.getId(), title, description, R.layout.preference_dialog_and_switch);
SwitchPreferenceEx switchPreferenceEx = (SwitchPreferenceEx) createSwitchPreferenceEx(pref.getId(), title, description, R.layout.preference_with_descr_dialog_and_switch);
switchPreferenceEx.setDescription(description);
switchPreferenceEx.setIcon(getRoutingPrefIcon(p.getId()));
switchPreferenceEx.setSummaryOn(R.string.shared_string_enable);
switchPreferenceEx.setSummaryOff(R.string.shared_string_disable);
switchPreferenceEx.setIconSpaceReserved(true);
screen.addPreference(switchPreferenceEx);
} else {
@ -203,6 +206,7 @@ public class RouteParametersFragment extends BaseSettingsFragment {
ListPreferenceEx listPreferenceEx = (ListPreferenceEx) createListPreferenceEx(pref.getId(), p.getPossibleValueDescriptions(), svlss, title, R.layout.preference_with_descr);
listPreferenceEx.setDescription(description);
listPreferenceEx.setIcon(getRoutingPrefIcon(p.getId()));
listPreferenceEx.setIconSpaceReserved(true);
screen.addPreference(listPreferenceEx);
}

View file

@ -159,6 +159,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
//AudioManager.USE_DEFAULT_STREAM_TYPE};
ListPreferenceEx audioStreamGuidance = createListPreferenceEx(settings.AUDIO_STREAM_GUIDANCE.getId(), streamTypes, streamIntTypes, R.string.choose_audio_stream, R.layout.preference_with_descr);
audioStreamGuidance.setIconSpaceReserved(true);
getPreferenceScreen().addPreference(audioStreamGuidance);
@ -167,6 +168,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
private void setupInterruptMusicPref() {
Preference interruptMusicPref = createSwitchPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music, R.string.interrupt_music_descr, R.layout.preference_switch);
interruptMusicPref.setIconSpaceReserved(true);
getPreferenceScreen().addPreference(interruptMusicPref);
interruptMusicPref.setDependency(settings.SPEAK_ROUTING_ALARMS.getId());