diff --git a/OsmAnd/res/layout/global_preferences_toolbar_with_switch.xml b/OsmAnd/res/layout/global_preferences_toolbar_with_switch.xml new file mode 100644 index 0000000000..9052f1b2ca --- /dev/null +++ b/OsmAnd/res/layout/global_preferences_toolbar_with_switch.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/preference_switch.xml b/OsmAnd/res/layout/preference_switch.xml index aee1090b1e..608ee34789 100644 --- a/OsmAnd/res/layout/preference_switch.xml +++ b/OsmAnd/res/layout/preference_switch.xml @@ -22,37 +22,17 @@ android:layout_marginLeft="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding" /> - - - - - - - + android:paddingRight="@dimen/content_padding" + android:textColor="?android:textColorPrimary" + android:textSize="@dimen/default_list_text_size" + osmand:typeface="@string/font_roboto_regular" /> + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/preference_toolbar_switch.xml b/OsmAnd/res/layout/preference_toolbar_switch.xml new file mode 100644 index 0000000000..8b27a58b6e --- /dev/null +++ b/OsmAnd/res/layout/preference_toolbar_switch.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml index ac8862685b..67d866bd89 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml @@ -53,47 +53,7 @@ - - - - - - - - - - - + diff --git a/OsmAnd/res/xml/general_profile_settings.xml b/OsmAnd/res/xml/general_profile_settings.xml index 5a9a3cff83..cee99d833b 100644 --- a/OsmAnd/res/xml/general_profile_settings.xml +++ b/OsmAnd/res/xml/general_profile_settings.xml @@ -84,7 +84,7 @@ diff --git a/OsmAnd/res/xml/global_settings.xml b/OsmAnd/res/xml/global_settings.xml index ef77c52c52..8f5a1dbb4d 100644 --- a/OsmAnd/res/xml/global_settings.xml +++ b/OsmAnd/res/xml/global_settings.xml @@ -34,7 +34,7 @@ - - diff --git a/OsmAnd/src/net/osmand/plus/settings/ProxySettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/ProxySettingsFragment.java index 04aef0099a..fe42fd655d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ProxySettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ProxySettingsFragment.java @@ -1,10 +1,18 @@ package net.osmand.plus.settings; +import android.graphics.drawable.Drawable; +import android.support.v4.content.ContextCompat; import android.support.v7.preference.Preference; +import android.support.v7.widget.SwitchCompat; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; import android.widget.Toast; +import net.osmand.AndroidUtils; import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.settings.preferences.EditTextPreferenceEx; import static net.osmand.plus.activities.SettingsGeneralActivity.IP_ADDRESS_PATTERN; @@ -25,7 +33,7 @@ public class ProxySettingsFragment extends BaseSettingsFragment { @Override protected int getToolbarResId() { - return R.layout.global_preference_toolbar; + return R.layout.global_preferences_toolbar_with_switch; } @Override @@ -47,6 +55,48 @@ public class ProxySettingsFragment extends BaseSettingsFragment { setupProxyPortPref(); } + @Override + protected void createToolbar(LayoutInflater inflater, View view) { + super.createToolbar(inflater, view); + + view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + boolean checked = !settings.ENABLE_PROXY.get(); + settings.ENABLE_PROXY.set(checked); + updateToolbarSwitch(); + enableDisablePreferences(checked); + } + }); + TextView title = (TextView) view.findViewById(R.id.switchButtonText); + title.setTextColor(ContextCompat.getColor(app, isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light)); + } + + @Override + protected void updateToolbar() { + super.updateToolbar(); + updateToolbarSwitch(); + } + + private void updateToolbarSwitch() { + View view = getView(); + if (view == null) { + return; + } + boolean checked = settings.ENABLE_PROXY.get(); + + View selectableView = view.findViewById(R.id.selectable_item); + + SwitchCompat switchView = (SwitchCompat) selectableView.findViewById(R.id.switchWidget); + switchView.setChecked(checked); + + TextView title = (TextView) selectableView.findViewById(R.id.switchButtonText); + title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off); + + Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, getActiveProfileColor(), 0.3f); + AndroidUtils.setBackground(selectableView, drawable); + } + private void setupProxyHostPref() { EditTextPreferenceEx hostPref = (EditTextPreferenceEx) findPreference(settings.PROXY_HOST.getId()); hostPref.setPersistent(false); diff --git a/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java b/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java index 10dd03767c..b797951177 100644 --- a/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/VoiceAnnouncesFragment.java @@ -221,7 +221,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); + Preference interruptMusicPref = createSwitchPreference(settings.INTERRUPT_MUSIC, R.string.interrupt_music, R.string.interrupt_music_descr, R.layout.preference_switch_with_descr); interruptMusicPref.setIconSpaceReserved(true); getPreferenceScreen().addPreference(interruptMusicPref); }