Merge remote-tracking branch 'origin/Manage_profile_settings' into Manage_profile_settings
This commit is contained in:
commit
0431e16a5c
17 changed files with 231 additions and 209 deletions
30
OsmAnd/res/layout/bottom_buttons.xml
Normal file
30
OsmAnd/res/layout/bottom_buttons.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/buttons_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dialog_button_ex_height"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<include
|
||||
android:id="@+id/dismiss_button"
|
||||
layout="@layout/bottom_sheet_dialog_button" />
|
||||
|
||||
<View
|
||||
android:id="@+id/buttons_divider"
|
||||
android:layout_width="@dimen/content_padding"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<include
|
||||
android:id="@+id/right_bottom_button"
|
||||
layout="@layout/bottom_sheet_dialog_button"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
|
@ -26,32 +26,6 @@
|
|||
android:orientation="vertical"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dialog_button_ex_height"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<include
|
||||
android:id="@+id/dismiss_button"
|
||||
layout="@layout/bottom_sheet_dialog_button" />
|
||||
|
||||
<View
|
||||
android:id="@+id/buttons_divider"
|
||||
android:layout_width="@dimen/content_padding"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<include
|
||||
android:id="@+id/right_bottom_button"
|
||||
layout="@layout/bottom_sheet_dialog_button"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/bottom_buttons" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -36,32 +36,17 @@
|
|||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/list_background_color"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding_small"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/content_padding_small">
|
||||
android:background="?attr/list_background_color">
|
||||
|
||||
<include
|
||||
android:id="@+id/cancel_button"
|
||||
layout="@layout/bottom_sheet_dialog_button" />
|
||||
|
||||
<View
|
||||
android:id="@+id/buttons_divider"
|
||||
android:layout_width="@dimen/content_padding"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<include
|
||||
android:id="@+id/apply_button"
|
||||
layout="@layout/bottom_sheet_dialog_button" />
|
||||
layout="@layout/bottom_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dialog_button_ex_height" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/buttons_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginTop="@dimen/card_padding"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="@dimen/card_padding"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/profile_cancel_btn"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="?attr/active_color_basic" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_profile_btn"
|
||||
style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="@dimen/card_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="@dimen/card_padding"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/profile_save_btn"
|
||||
android:text="@string/shared_string_save"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/color_white" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,54 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/list_header_top_margin"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/type_down_arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|right"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:src="@drawable/ic_action_arrow_drop_down"
|
||||
android:tint="@color/settings_divider"/>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginTop="@dimen/list_header_top_margin"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||
android:id="@+id/master_profile_otfb"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
app:primaryColor="@color/active_color_primary_dark"
|
||||
app:secondaryColor="?android:textColorSecondary"
|
||||
app:labelText="@string/master_profile">
|
||||
<ImageView
|
||||
android:id="@+id/type_down_arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|right"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:src="@drawable/ic_action_arrow_drop_down"
|
||||
android:tint="@color/settings_divider" />
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
android:id="@+id/master_profile_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:maxLines="1"
|
||||
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||
android:id="@+id/master_profile_otfb"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
app:labelText="@string/master_profile"
|
||||
app:primaryColor="@color/active_color_primary_dark"
|
||||
app:secondaryColor="?android:textColorSecondary">
|
||||
|
||||
tools:text="Car"/>
|
||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
android:id="@+id/master_profile_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:maxLines="1"
|
||||
tools:text="Car" />
|
||||
|
||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/select_nav_type_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:focusable="true"/>
|
||||
<FrameLayout
|
||||
android:id="@+id/select_nav_type_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:focusable="true" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
|
@ -1,30 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||
android:id="@+id/profile_name_otfb"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="@dimen/list_content_padding"
|
||||
app:primaryColor="@color/active_color_primary_dark"
|
||||
app:secondaryColor="?android:textColorSecondary"
|
||||
app:labelText="@string/profile_name_hint">
|
||||
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||
android:id="@+id/profile_name_otfb"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="@dimen/list_content_padding"
|
||||
android:layout_weight="1"
|
||||
app:labelText="@string/profile_name_hint"
|
||||
app:primaryColor="@color/active_color_primary_dark"
|
||||
app:secondaryColor="?android:textColorSecondary">
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
android:id="@+id/profile_name_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
tools:text="@string/lorem_ipsum"/>
|
||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
android:id="@+id/profile_name_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
tools:text="@string/lorem_ipsum" />
|
||||
|
||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||
|
||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||
</LinearLayout>
|
|
@ -11,13 +11,13 @@
|
|||
android:title="@string/nav_type_hint"
|
||||
tools:icon="@drawable/ic_action_car_dark" />
|
||||
|
||||
<Preference
|
||||
android:key="route_parameters"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/route_parameters_descr"
|
||||
android:title="@string/route_parameters"
|
||||
app:fragment="net.osmand.plus.settings.RouteParametersFragment"
|
||||
tools:icon="@drawable/ic_action_route_distance" />
|
||||
<Preference
|
||||
android:key="route_parameters"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:summary="@string/route_parameters_descr"
|
||||
android:title="@string/route_parameters"
|
||||
app:fragment="net.osmand.plus.settings.RouteParametersFragment"
|
||||
tools:icon="@drawable/ic_action_route_distance" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="show_routing_alarms"
|
||||
|
|
|
@ -52,7 +52,6 @@ public class ApplicationMode {
|
|||
private static Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
|
||||
|
||||
private static List<ApplicationMode> defaultValues = new ArrayList<>();
|
||||
private static List<ApplicationMode> customValues = new ArrayList<>();
|
||||
private static List<ApplicationMode> values = new ArrayList<>();
|
||||
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<>();
|
||||
|
||||
|
@ -194,6 +193,9 @@ public class ApplicationMode {
|
|||
private ApplicationMode reg() {
|
||||
values.add(applicationMode);
|
||||
defaultValues.add(applicationMode);
|
||||
if (applicationMode.getOrder() == 0 && !values.isEmpty()) {
|
||||
applicationMode.setOrder(values.size());
|
||||
}
|
||||
return applicationMode;
|
||||
}
|
||||
|
||||
|
@ -213,7 +215,9 @@ public class ApplicationMode {
|
|||
m.locationIconDayLost = m.parentAppMode.locationIconDayLost;
|
||||
m.locationIconNightLost = m.parentAppMode.locationIconNightLost;
|
||||
values.add(applicationMode);
|
||||
customValues.add(applicationMode);
|
||||
if (applicationMode.getOrder() == 0 && !values.isEmpty()) {
|
||||
applicationMode.setOrder(values.size());
|
||||
}
|
||||
return applicationMode;
|
||||
}
|
||||
|
||||
|
@ -412,7 +416,13 @@ public class ApplicationMode {
|
|||
}
|
||||
|
||||
public static List<ApplicationMode> getCustomValues() {
|
||||
return customValues;
|
||||
List<ApplicationMode> customModes = new ArrayList<>();
|
||||
for (ApplicationMode mode : values) {
|
||||
if (mode.isCustomProfile()) {
|
||||
customModes.add(mode);
|
||||
}
|
||||
}
|
||||
return customModes;
|
||||
}
|
||||
|
||||
// returns modifiable ! Set<ApplicationMode> to exclude non-wanted derived
|
||||
|
@ -656,12 +666,11 @@ public class ApplicationMode {
|
|||
public static void reorderAppModes() {
|
||||
Comparator<ApplicationMode> comparator = new Comparator<ApplicationMode>() {
|
||||
@Override
|
||||
public int compare(ApplicationMode o1, ApplicationMode o2) {
|
||||
return (o1.order < o2.order) ? -1 : ((o1.order == o2.order) ? 0 : 1);
|
||||
public int compare(ApplicationMode mode1, ApplicationMode mode2) {
|
||||
return (mode1.order < mode2.order) ? -1 : ((mode1.order == mode2.order) ? 0 : 1);
|
||||
}
|
||||
};
|
||||
Collections.sort(values, comparator);
|
||||
Collections.sort(customValues, comparator);
|
||||
Collections.sort(defaultValues, comparator);
|
||||
Collections.sort(cachedFilteredValues, comparator);
|
||||
}
|
||||
|
@ -672,9 +681,11 @@ public class ApplicationMode {
|
|||
|
||||
ApplicationModeBuilder b = createCustomMode(valueOfStringKey(mb.parent, null),
|
||||
mb.userProfileName, mb.stringKey);
|
||||
b.setRouteService(mb.routeService).setRoutingProfile(mb.routingProfile);
|
||||
b.setRouteService(mb.routeService);
|
||||
b.setRoutingProfile(mb.routingProfile);
|
||||
b.icon(app, mb.iconName);
|
||||
b.setColor(mb.iconColor);
|
||||
b.setOrder(mb.order);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -687,6 +698,7 @@ public class ApplicationMode {
|
|||
mb.stringKey = stringKey;
|
||||
mb.routeService = routeService;
|
||||
mb.routingProfile = routingProfile;
|
||||
mb.order = order;
|
||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||
return gson.toJson(mb);
|
||||
}
|
||||
|
@ -734,7 +746,7 @@ public class ApplicationMode {
|
|||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||
|
||||
List<ApplicationModeBean> defaultModeBeans = createApplicationModeBeans(defaultValues);
|
||||
List<ApplicationModeBean> customModeBeans = createApplicationModeBeans(customValues);
|
||||
List<ApplicationModeBean> customModeBeans = createApplicationModeBeans(getCustomValues());
|
||||
|
||||
String defaultProfiles = gson.toJson(defaultModeBeans);
|
||||
String customProfiles = gson.toJson(customModeBeans);
|
||||
|
@ -744,7 +756,7 @@ public class ApplicationMode {
|
|||
}
|
||||
|
||||
private static void saveAppModesToSettings(OsmandSettings settings, boolean saveCustomModes) {
|
||||
List<ApplicationMode> appModes = saveCustomModes ? customValues : defaultValues;
|
||||
List<ApplicationMode> appModes = saveCustomModes ? getCustomValues() : defaultValues;
|
||||
List<ApplicationModeBean> modeBeans = createApplicationModeBeans(appModes);
|
||||
|
||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||
|
@ -802,14 +814,18 @@ public class ApplicationMode {
|
|||
it.remove();
|
||||
}
|
||||
}
|
||||
customValues.remove(md);
|
||||
cachedFilteredValues.remove(md);
|
||||
saveAppModesToSettings(app.getSettings(), md.isCustomProfile());
|
||||
}
|
||||
|
||||
public static void deleteCustomModes(List<ApplicationMode> modes, OsmandApplication app) {
|
||||
values.removeAll(modes);
|
||||
customValues.removeAll(modes);
|
||||
Iterator<ApplicationMode> it = values.iterator();
|
||||
while (it.hasNext()) {
|
||||
ApplicationMode m = it.next();
|
||||
if (modes.contains(m)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
cachedFilteredValues.removeAll(modes);
|
||||
saveAppModesToSettings(app.getSettings(), true);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ import net.osmand.plus.measurementtool.command.ClearPointsCommand;
|
|||
import net.osmand.plus.measurementtool.command.MovePointCommand;
|
||||
import net.osmand.plus.measurementtool.command.RemovePointCommand;
|
||||
import net.osmand.plus.measurementtool.command.ReorderPointCommand;
|
||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.osmand.plus.UiUtilities;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -47,20 +48,23 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
|
||||
private EditProfilesAdapter adapter;
|
||||
|
||||
private boolean nightMode;
|
||||
private boolean wasDrawerDisabled;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final MapActivity mapActivity = (MapActivity) requireActivity();
|
||||
OsmandApplication app = requireMyApplication();
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey(APP_MODES_ORDER_KEY) && savedInstanceState.containsKey(DELETED_APP_MODES_KEY)) {
|
||||
appModesOrders = (HashMap<String, Integer>) savedInstanceState.getSerializable(APP_MODES_ORDER_KEY);
|
||||
deletedModesKeys = savedInstanceState.getStringArrayList(DELETED_APP_MODES_KEY);
|
||||
} else {
|
||||
List<ApplicationMode> appModes = ApplicationMode.allPossibleValues();
|
||||
for (int i = 0; i < appModes.size(); i++) {
|
||||
ApplicationMode mode = appModes.get(i);
|
||||
appModesOrders.put(mode.getStringKey(), i);
|
||||
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||
appModesOrders.put(mode.getStringKey(), mode.getOrder());
|
||||
}
|
||||
}
|
||||
nightMode = !app.getSettings().isLightContent();
|
||||
|
||||
View mainView = inflater.inflate(R.layout.edit_profiles_list_fragment, container, false);
|
||||
AndroidUtils.addStatusBarPadding21v(getContext(), mainView);
|
||||
|
||||
|
@ -82,7 +86,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
RecyclerView recyclerView = mainView.findViewById(R.id.profiles_list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
adapter = new EditProfilesAdapter(mapActivity);
|
||||
adapter = new EditProfilesAdapter(app);
|
||||
updateItems();
|
||||
|
||||
final ItemTouchHelper touchHelper = new ItemTouchHelper(new ReorderItemTouchHelperCallback(adapter));
|
||||
|
@ -125,7 +129,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
View cancelButton = mainView.findViewById(R.id.cancel_button);
|
||||
View cancelButton = mainView.findViewById(R.id.dismiss_button);
|
||||
UiUtilities.setupDialogButton(false, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -137,8 +141,11 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
});
|
||||
|
||||
View applyButton = mainView.findViewById(R.id.apply_button);
|
||||
mainView.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE);
|
||||
|
||||
View applyButton = mainView.findViewById(R.id.right_bottom_button);
|
||||
UiUtilities.setupDialogButton(false, applyButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_apply);
|
||||
applyButton.setVisibility(View.VISIBLE);
|
||||
applyButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -185,6 +192,41 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
outState.putStringArrayList(DELETED_APP_MODES_KEY, deletedModesKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
wasDrawerDisabled = mapActivity.isDrawerDisabled();
|
||||
if (!wasDrawerDisabled) {
|
||||
mapActivity.disableDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null && !wasDrawerDisabled) {
|
||||
mapActivity.enableDrawer();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusBarColorId() {
|
||||
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MapActivity getMapActivity() {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof MapActivity) {
|
||||
return (MapActivity) activity;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<EditProfileDataObject> getProfiles(boolean deleted) {
|
||||
List<EditProfileDataObject> profiles = new ArrayList<>();
|
||||
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||
|
@ -271,9 +313,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
|
||||
private boolean nightMode;
|
||||
|
||||
EditProfilesAdapter(MapActivity mapActivity) {
|
||||
EditProfilesAdapter(OsmandApplication app) {
|
||||
setHasStableIds(true);
|
||||
app = mapActivity.getMyApplication();
|
||||
this.app = app;
|
||||
uiUtilities = app.getUIUtilities();
|
||||
nightMode = !app.getSettings().isLightContent();
|
||||
}
|
||||
|
@ -390,11 +432,16 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
|||
Object itemFrom = getItem(from);
|
||||
Object itemTo = getItem(to);
|
||||
if (itemFrom instanceof EditProfileDataObject && itemTo instanceof EditProfileDataObject) {
|
||||
EditProfileDataObject profileDataObjectFrom = (EditProfileDataObject) itemFrom;
|
||||
EditProfileDataObject profileDataObjectTo = (EditProfileDataObject) itemTo;
|
||||
int tmp = profileDataObjectFrom.getOrder();
|
||||
appModesOrders.put(profileDataObjectFrom.getStringKey(), profileDataObjectTo.getOrder());
|
||||
appModesOrders.put(profileDataObjectTo.getStringKey(), tmp);
|
||||
EditProfileDataObject profileFrom = (EditProfileDataObject) itemFrom;
|
||||
EditProfileDataObject profileTo = (EditProfileDataObject) itemTo;
|
||||
|
||||
int orderFrom = profileFrom.getOrder();
|
||||
int orderTo = profileTo.getOrder();
|
||||
|
||||
profileFrom.setOrder(orderTo);
|
||||
profileTo.setOrder(orderFrom);
|
||||
appModesOrders.put(profileFrom.getStringKey(), orderTo);
|
||||
appModesOrders.put(profileTo.getStringKey(), orderFrom);
|
||||
|
||||
Collections.swap(items, from, to);
|
||||
notifyItemMoved(from, to);
|
||||
|
|
|
@ -28,9 +28,9 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
|
||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback.UnmovableItem;
|
||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback.OnItemMoveCallback;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback.UnmovableItem;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback.OnItemMoveCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -20,7 +20,7 @@ import android.widget.TextView;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.SelectMapViewQuickActionsBottomSheet;
|
||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -40,6 +40,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
private static final String CREATE_PROFILE = "create_profile";
|
||||
private static final String IMPORT_PROFILE = "import_profile";
|
||||
private static final String REORDER_PROFILES = "reorder_profiles";
|
||||
|
||||
private List<ApplicationMode> allAppModes;
|
||||
private Set<ApplicationMode> availableAppModes;
|
||||
private SelectProfileListener selectProfileListener = null;
|
||||
|
@ -89,7 +90,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
ApplicationMode applicationMode = ApplicationMode.valueOfStringKey(preference.getKey(), null);
|
||||
ApplicationMode applicationMode = ApplicationMode.valueOfStringKey(preference.getKey(), null);
|
||||
if (applicationMode != null) {
|
||||
if (newValue instanceof Boolean) {
|
||||
boolean isChecked = (Boolean) newValue;
|
||||
|
@ -121,7 +122,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
}
|
||||
|
||||
private void setupConfigureProfilePref() {
|
||||
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
|
||||
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
|
||||
String title = selectedMode.toHumanString(getContext());
|
||||
String profileType = getAppModeDescription(getContext(), selectedMode);
|
||||
int iconRes = selectedMode.getIconRes();
|
||||
|
|
|
@ -27,8 +27,9 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
|
||||
public static final String TAG = NavigationFragment.class.getSimpleName();
|
||||
public static final String NAVIGATION_TYPE = "navigation_type";
|
||||
|
||||
private SelectProfileBottomSheetDialogFragment.SelectProfileListener navTypeListener;
|
||||
List<RoutingProfileDataObject> routingProfileDataObjects;
|
||||
private List<RoutingProfileDataObject> routingProfileDataObjects;
|
||||
private Preference navigationType;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
@ -30,6 +29,7 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
|
||||
import net.osmand.plus.profiles.SettingsProfileFragment;
|
||||
|
@ -134,12 +134,22 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view != null) {
|
||||
FrameLayout frameLayout = view.findViewById(android.R.id.list_container);
|
||||
View inflatedLayout = UiUtilities.getInflater(getContext(), isNightMode())
|
||||
.inflate(R.layout.preference_cancel_save_button, frameLayout, false);
|
||||
frameLayout.addView(inflatedLayout);
|
||||
Button cancelButton = inflatedLayout.findViewById(R.id.cancel_button);
|
||||
Button saveButton = inflatedLayout.findViewById(R.id.save_profile_btn);
|
||||
FrameLayout preferencesContainer = view.findViewById(android.R.id.list_container);
|
||||
LayoutInflater themedInflater = UiUtilities.getInflater(getContext(), isNightMode());
|
||||
View buttonsContainer = themedInflater.inflate(R.layout.bottom_buttons, preferencesContainer, false);
|
||||
|
||||
preferencesContainer.addView(buttonsContainer);
|
||||
View cancelButton = buttonsContainer.findViewById(R.id.dismiss_button);
|
||||
View saveButton = buttonsContainer.findViewById(R.id.right_bottom_button);
|
||||
|
||||
saveButton.setVisibility(View.VISIBLE);
|
||||
buttonsContainer.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE);
|
||||
|
||||
AndroidUtils.setBackground(getContext(), buttonsContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
|
||||
|
||||
UiUtilities.setupDialogButton(false, cancelButton, DialogButtonType.SECONDARY, R.string.shared_string_cancel);
|
||||
UiUtilities.setupDialogButton(false, saveButton, DialogButtonType.PRIMARY, R.string.shared_string_save);
|
||||
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.profiles;
|
||||
package net.osmand.plus.views.controls;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
Loading…
Reference in a new issue