Merge pull request #8459 from osmandapp/FixManageProfile

Fix Manage Profiles bugs
This commit is contained in:
vshcherb 2020-02-13 18:55:42 +01:00 committed by GitHub
commit 8da102bd0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 76 additions and 44 deletions

View file

@ -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">
<net.osmand.plus.widgets.TextViewEx
@ -22,6 +23,7 @@
android:gravity="center"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
android:duplicateParentState="true"
tools:text="Button" />
</LinearLayout>

View file

@ -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">
<net.osmand.plus.widgets.TextViewEx
@ -21,6 +22,7 @@
android:gravity="center_vertical|start"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
android:duplicateParentState="true"
tools:text="Button" />
</LinearLayout>

View file

@ -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">
<net.osmand.plus.widgets.TextViewEx
@ -25,6 +26,7 @@
android:textAllCaps="true"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
android:duplicateParentState="true"
tools:text="Button" />
</LinearLayout>

View file

@ -25,26 +25,40 @@
android:src="@drawable/ic_action_mode_back"
android:tint="?attr/default_icon_color" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:letterSpacing="@dimen/text_button_letter_spacing"
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" />
android:paddingTop="@dimen/content_padding_half"
android:paddingBottom="@dimen/content_padding_half"
android:background="?attr/card_and_list_background_basic"
android:orientation="vertical">
<include
layout="@layout/profile_button_small"
android:layout_width="@dimen/route_info_toolbar_button_size"
android:layout_height="@dimen/route_info_toolbar_button_size"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/text_button_letter_spacing"
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>

View file

@ -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" />
</LinearLayout>

View file

@ -11,6 +11,7 @@
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="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>

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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

View file

@ -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);

View file

@ -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();

View file

@ -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);