diff --git a/OsmAnd/res/layout/bottom_sheet_dialog_button.xml b/OsmAnd/res/layout/bottom_sheet_dialog_button.xml index 34dfd832f4..f87dee1855 100644 --- a/OsmAnd/res/layout/bottom_sheet_dialog_button.xml +++ b/OsmAnd/res/layout/bottom_sheet_dialog_button.xml @@ -11,6 +11,7 @@ android:id="@+id/button_container" android:layout_width="match_parent" android:layout_height="match_parent" + android:duplicateParentState="true" tools:ignore="UselessParent"> diff --git a/OsmAnd/res/layout/bottom_sheet_dialog_button_big.xml b/OsmAnd/res/layout/bottom_sheet_dialog_button_big.xml index 7a8d1ee9a9..2dff6a2668 100644 --- a/OsmAnd/res/layout/bottom_sheet_dialog_button_big.xml +++ b/OsmAnd/res/layout/bottom_sheet_dialog_button_big.xml @@ -10,6 +10,7 @@ android:id="@+id/button_container" android:layout_width="match_parent" android:layout_height="match_parent" + android:duplicateParentState="true" tools:ignore="UselessParent"> diff --git a/OsmAnd/res/layout/map_context_menu_button.xml b/OsmAnd/res/layout/map_context_menu_button.xml index 131ecabac8..038c8378b9 100644 --- a/OsmAnd/res/layout/map_context_menu_button.xml +++ b/OsmAnd/res/layout/map_context_menu_button.xml @@ -12,6 +12,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:minHeight="@dimen/context_menu_controller_height" + android:duplicateParentState="true" tools:ignore="UselessParent"> diff --git a/OsmAnd/res/layout/profile_preference_toolbar.xml b/OsmAnd/res/layout/profile_preference_toolbar.xml index c21dcd0edb..41596108c1 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar.xml @@ -25,26 +25,40 @@ android:src="@drawable/ic_action_mode_back" android:tint="?attr/default_icon_color" /> - + android:paddingTop="@dimen/content_padding_half" + android:paddingBottom="@dimen/content_padding_half" + android:background="?attr/card_and_list_background_basic" + android:orientation="vertical"> - + + + + diff --git a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml index 7b7f3dc52a..ee03b0d8f9 100644 --- a/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml +++ b/OsmAnd/res/layout/profile_preference_toolbar_with_switch.xml @@ -62,7 +62,6 @@ android:paddingLeft="@dimen/content_padding" android:paddingRight="@dimen/content_padding" android:textAppearance="@style/TextAppearance.ContextMenuSubtitle" - android:visibility="gone" tools:text="Some description" /> diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index ddf2c73dee..0251cf49e1 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Please provide a name for the profile Open settings Plugin disabled This plugin is a separate application, you will need to remove it separately if you no longer plan to use it.\n\nThe plugin will remain on the device after removing OsmAnd. diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java index 6144decd69..21fecfb2b4 100644 --- a/OsmAnd/src/net/osmand/plus/UiUtilities.java +++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java @@ -369,7 +369,7 @@ public class UiUtilities { activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode)); break; case TOOLBAR: - activeColor = ContextCompat.getColor(app, nightMode ? R.color.text_color_tab_active_dark : R.color.text_color_tab_active_light); + activeColor = Color.WHITE; inactiveColorPrimary = activeColor; inactiveColorSecondary = UiUtilities.getColorWithAlpha(Color.BLACK, 0.25f); break; diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java index bd3bc0ce85..ec9863482e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java @@ -104,7 +104,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl GLOBAL_SETTINGS(GlobalSettingsFragment.class.getName(), false, R.xml.global_settings, R.layout.global_preference_toolbar), CONFIGURE_PROFILE(ConfigureProfileFragment.class.getName(), true, R.xml.configure_profile, R.layout.profile_preference_toolbar_with_switch), PROXY_SETTINGS(ProxySettingsFragment.class.getName(), false, R.xml.proxy_preferences, R.layout.global_preferences_toolbar_with_switch), - GENERAL_PROFILE(GeneralProfileSettingsFragment.class.getName(), true, R.xml.general_profile_settings, R.layout.profile_preference_toolbar_big), + GENERAL_PROFILE(GeneralProfileSettingsFragment.class.getName(), true, R.xml.general_profile_settings, R.layout.profile_preference_toolbar), NAVIGATION(NavigationFragment.class.getName(), true, R.xml.navigation_settings_new, R.layout.profile_preference_toolbar), COORDINATES_FORMAT(CoordinatesFormatFragment.class.getName(), true, R.xml.coordinates_format, R.layout.profile_preference_toolbar), ROUTE_PARAMETERS(RouteParametersFragment.class.getName(), true, R.xml.route_parameters, R.layout.profile_preference_toolbar), @@ -117,10 +117,10 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl DIALOGS_AND_NOTIFICATIONS_SETTINGS(DialogsAndNotificationsSettingsFragment.class.getName(), false, R.xml.dialogs_and_notifications_preferences, R.layout.global_preferences_toolbar_with_switch), PROFILE_APPEARANCE(ProfileAppearanceFragment.TAG, true, R.xml.profile_appearance, R.layout.profile_preference_toolbar), OPEN_STREET_MAP_EDITING(OsmEditingFragment.class.getName(), false, R.xml.osm_editing, R.layout.global_preference_toolbar), - MULTIMEDIA_NOTES(MultimediaNotesFragment.class.getName(), true, R.xml.multimedia_notes, R.layout.profile_preference_toolbar_big), - MONITORING_SETTINGS(MonitoringSettingsFragment.class.getName(), true, R.xml.monitoring_settings, R.layout.profile_preference_toolbar_big), + MULTIMEDIA_NOTES(MultimediaNotesFragment.class.getName(), true, R.xml.multimedia_notes, R.layout.profile_preference_toolbar), + MONITORING_SETTINGS(MonitoringSettingsFragment.class.getName(), true, R.xml.monitoring_settings, R.layout.profile_preference_toolbar), LIVE_MONITORING(LiveMonitoringFragment.class.getName(), false, R.xml.live_monitoring, R.layout.global_preferences_toolbar_with_switch), - ACCESSIBILITY_SETTINGS(AccessibilitySettingsFragment.class.getName(), true, R.xml.accessibility_settings, R.layout.profile_preference_toolbar_big), + ACCESSIBILITY_SETTINGS(AccessibilitySettingsFragment.class.getName(), true, R.xml.accessibility_settings, R.layout.profile_preference_toolbar), DEVELOPMENT_SETTINGS(DevelopmentSettingsFragment.class.getName(), false, R.xml.development_settings, R.layout.global_preference_toolbar); public final String fragmentName; @@ -435,6 +435,11 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl toolbarTitle.setText(getPreferenceScreen().getTitle()); } + TextView toolbarSubtitle = (TextView) view.findViewById(R.id.toolbar_subtitle); + if (toolbarSubtitle != null) { + toolbarSubtitle.setText(getSelectedAppMode().toHumanString()); + } + View closeButton = view.findViewById(R.id.close_button); if (closeButton != null) { closeButton.setOnClickListener(new View.OnClickListener() { @@ -461,6 +466,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } } }); + switchProfile.setVisibility(View.GONE); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java b/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java index 50b5f82f7e..15cd26df7b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ConfigureProfileFragment.java @@ -112,6 +112,11 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co updateToolbarSwitch(); } }); + + View switchProfile = view.findViewById(R.id.profile_button); + if (switchProfile != null) { + switchProfile.setVisibility(View.VISIBLE); + } } @Override diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index 82f80519eb..38a6dbccf9 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -50,12 +50,6 @@ public class NavigationFragment extends BaseSettingsFragment { routingProfileDataObjects = getRoutingProfiles(app); } - @Override - protected void createToolbar(LayoutInflater inflater, View view) { - super.createToolbar(inflater, view); - view.findViewById(R.id.profile_button).setVisibility(View.GONE); - } - @Override protected void setupPreferences() { navigationType = findPreference(NAVIGATION_TYPE); diff --git a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java index 7f35a744bd..7db17b5c5e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ProfileAppearanceFragment.java @@ -251,13 +251,6 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { return !profile.equals(changedProfile); } - @Override - protected void createToolbar(LayoutInflater inflater, View view) { - super.createToolbar(inflater, view); - View profileIcon = view.findViewById(R.id.profile_button); - profileIcon.setVisibility(View.VISIBLE); - } - @Override public void onSaveInstanceState(Bundle outState) { saveState(outState); @@ -327,15 +320,16 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { @Override public void afterTextChanged(Editable s) { changedProfile.name = s.toString(); - if (hasNameDuplicate()) { - saveButton.setEnabled(false); - profileNameOtfb.setError(app.getString(R.string.profile_alert_duplicate_name_msg), true); + if (nameIsEmpty()) { + disableSaveButtonWithErrorMessage(app.getString(R.string.please_provide_profile_name_message)); + } else if (hasNameDuplicate()) { + disableSaveButtonWithErrorMessage(app.getString(R.string.profile_alert_duplicate_name_msg)); } else { saveButton.setEnabled(true); } } }); - if (getSelectedAppMode().equals(ApplicationMode.DEFAULT)) { + if (getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile) { profileName.setFocusableInTouchMode(false); profileName.setFocusable(false); } else { @@ -686,13 +680,22 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { private boolean hasNameDuplicate() { for (ApplicationMode m : ApplicationMode.allPossibleValues()) { - if (m.toHumanString().equals(changedProfile.name) && - !m.getStringKey().equals(profile.stringKey)) { + if (m.toHumanString().trim().equals(changedProfile.name.trim()) && + !m.getStringKey().trim().equals(profile.stringKey.trim())) { return true; } } return false; } + + private boolean nameIsEmpty() { + return changedProfile.name.trim().equals(""); + } + + private void disableSaveButtonWithErrorMessage(String errorMessage) { + saveButton.setEnabled(false); + profileNameOtfb.setError(errorMessage, true); + } public boolean isProfileAppearanceChanged(final MapActivity mapActivity) { hideKeyboard(); diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index 9eb0df286d..7449a29a0c 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -1,9 +1,6 @@ package net.osmand.plus.widgets; import android.content.Context; -import android.os.Parcel; -import android.os.Parcelable; -import android.support.annotation.Nullable; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.view.View; @@ -91,6 +88,13 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { return editText; } + @Override + protected void makeCursorBlink() { + CharSequence hintCache = this.editText.getHint(); + this.editText.setHint(" "); + this.editText.setHint(hintCache); + } + @Override public void setError(String errorText, boolean giveFocus) { super.setError(errorText, giveFocus);