Merge pull request #8459 from osmandapp/FixManageProfile
Fix Manage Profiles bugs
This commit is contained in:
commit
8da102bd0c
12 changed files with 76 additions and 44 deletions
|
@ -11,6 +11,7 @@
|
||||||
android:id="@+id/button_container"
|
android:id="@+id/button_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:duplicateParentState="true"
|
||||||
tools:ignore="UselessParent">
|
tools:ignore="UselessParent">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:duplicateParentState="true"
|
||||||
tools:text="Button" />
|
tools:text="Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
android:id="@+id/button_container"
|
android:id="@+id/button_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:duplicateParentState="true"
|
||||||
tools:ignore="UselessParent">
|
tools:ignore="UselessParent">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
android:gravity="center_vertical|start"
|
android:gravity="center_vertical|start"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:duplicateParentState="true"
|
||||||
tools:text="Button" />
|
tools:text="Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:minHeight="@dimen/context_menu_controller_height"
|
android:minHeight="@dimen/context_menu_controller_height"
|
||||||
|
android:duplicateParentState="true"
|
||||||
tools:ignore="UselessParent">
|
tools:ignore="UselessParent">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:duplicateParentState="true"
|
||||||
tools:text="Button" />
|
tools:text="Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -25,26 +25,40 @@
|
||||||
android:src="@drawable/ic_action_mode_back"
|
android:src="@drawable/ic_action_mode_back"
|
||||||
android:tint="?attr/default_icon_color" />
|
android:tint="?attr/default_icon_color" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<LinearLayout
|
||||||
android:id="@+id/toolbar_title"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
android:paddingTop="@dimen/content_padding_half"
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:paddingBottom="@dimen/content_padding_half"
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:background="?attr/card_and_list_background_basic"
|
||||||
android:maxLines="2"
|
android:orientation="vertical">
|
||||||
android:textColor="?android:textColorPrimary"
|
|
||||||
android:textSize="@dimen/dialog_header_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="@string/routing_settings_2" />
|
|
||||||
|
|
||||||
<include
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
layout="@layout/profile_button_small"
|
android:id="@+id/toolbar_title"
|
||||||
android:layout_width="@dimen/route_info_toolbar_button_size"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="@dimen/route_info_toolbar_button_size"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/content_padding_half"
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
android:layout_marginRight="@dimen/content_padding_half" />
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/dialog_header_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="@string/routing_settings_2" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/toolbar_subtitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||||
|
tools:text="Some description" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:paddingLeft="@dimen/content_padding"
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:paddingRight="@dimen/content_padding"
|
||||||
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||||
android:visibility="gone"
|
|
||||||
tools:text="Some description" />
|
tools:text="Some description" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="please_provide_profile_name_message">Please provide a name for the profile</string>
|
||||||
<string name="open_settings">Open settings</string>
|
<string name="open_settings">Open settings</string>
|
||||||
<string name="plugin_disabled">Plugin disabled</string>
|
<string name="plugin_disabled">Plugin disabled</string>
|
||||||
<string name="plugin_disabled_descr">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.</string>
|
<string name="plugin_disabled_descr">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.</string>
|
||||||
|
|
|
@ -369,7 +369,7 @@ public class UiUtilities {
|
||||||
activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode));
|
activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode));
|
||||||
break;
|
break;
|
||||||
case TOOLBAR:
|
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;
|
inactiveColorPrimary = activeColor;
|
||||||
inactiveColorSecondary = UiUtilities.getColorWithAlpha(Color.BLACK, 0.25f);
|
inactiveColorSecondary = UiUtilities.getColorWithAlpha(Color.BLACK, 0.25f);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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),
|
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),
|
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),
|
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),
|
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),
|
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),
|
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),
|
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),
|
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),
|
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),
|
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_big),
|
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),
|
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);
|
DEVELOPMENT_SETTINGS(DevelopmentSettingsFragment.class.getName(), false, R.xml.development_settings, R.layout.global_preference_toolbar);
|
||||||
|
|
||||||
public final String fragmentName;
|
public final String fragmentName;
|
||||||
|
@ -435,6 +435,11 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
||||||
toolbarTitle.setText(getPreferenceScreen().getTitle());
|
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);
|
View closeButton = view.findViewById(R.id.close_button);
|
||||||
if (closeButton != null) {
|
if (closeButton != null) {
|
||||||
closeButton.setOnClickListener(new View.OnClickListener() {
|
closeButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -461,6 +466,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
switchProfile.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,11 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
|
||||||
updateToolbarSwitch();
|
updateToolbarSwitch();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
View switchProfile = view.findViewById(R.id.profile_button);
|
||||||
|
if (switchProfile != null) {
|
||||||
|
switchProfile.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -50,12 +50,6 @@ public class NavigationFragment extends BaseSettingsFragment {
|
||||||
routingProfileDataObjects = getRoutingProfiles(app);
|
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
|
@Override
|
||||||
protected void setupPreferences() {
|
protected void setupPreferences() {
|
||||||
navigationType = findPreference(NAVIGATION_TYPE);
|
navigationType = findPreference(NAVIGATION_TYPE);
|
||||||
|
|
|
@ -251,13 +251,6 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
||||||
return !profile.equals(changedProfile);
|
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
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
saveState(outState);
|
saveState(outState);
|
||||||
|
@ -327,15 +320,16 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
changedProfile.name = s.toString();
|
changedProfile.name = s.toString();
|
||||||
if (hasNameDuplicate()) {
|
if (nameIsEmpty()) {
|
||||||
saveButton.setEnabled(false);
|
disableSaveButtonWithErrorMessage(app.getString(R.string.please_provide_profile_name_message));
|
||||||
profileNameOtfb.setError(app.getString(R.string.profile_alert_duplicate_name_msg), true);
|
} else if (hasNameDuplicate()) {
|
||||||
|
disableSaveButtonWithErrorMessage(app.getString(R.string.profile_alert_duplicate_name_msg));
|
||||||
} else {
|
} else {
|
||||||
saveButton.setEnabled(true);
|
saveButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (getSelectedAppMode().equals(ApplicationMode.DEFAULT)) {
|
if (getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile) {
|
||||||
profileName.setFocusableInTouchMode(false);
|
profileName.setFocusableInTouchMode(false);
|
||||||
profileName.setFocusable(false);
|
profileName.setFocusable(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -686,13 +680,22 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
private boolean hasNameDuplicate() {
|
private boolean hasNameDuplicate() {
|
||||||
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
|
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
|
||||||
if (m.toHumanString().equals(changedProfile.name) &&
|
if (m.toHumanString().trim().equals(changedProfile.name.trim()) &&
|
||||||
!m.getStringKey().equals(profile.stringKey)) {
|
!m.getStringKey().trim().equals(profile.stringKey.trim())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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) {
|
public boolean isProfileAppearanceChanged(final MapActivity mapActivity) {
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package net.osmand.plus.widgets;
|
package net.osmand.plus.widgets;
|
||||||
|
|
||||||
import android.content.Context;
|
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.support.v4.view.ViewCompat;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -91,6 +88,13 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
|
||||||
return editText;
|
return editText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void makeCursorBlink() {
|
||||||
|
CharSequence hintCache = this.editText.getHint();
|
||||||
|
this.editText.setHint(" ");
|
||||||
|
this.editText.setHint(hintCache);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setError(String errorText, boolean giveFocus) {
|
public void setError(String errorText, boolean giveFocus) {
|
||||||
super.setError(errorText, giveFocus);
|
super.setError(errorText, giveFocus);
|
||||||
|
|
Loading…
Reference in a new issue