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:orientation="vertical"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<include layout="@layout/bottom_buttons" />
|
||||||
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>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -36,32 +36,17 @@
|
||||||
android:id="@+id/buttons_shadow"
|
android:id="@+id/buttons_shadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="10dp"
|
android:layout_height="10dp"
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:background="?attr/list_background_color">
|
||||||
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">
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/cancel_button"
|
layout="@layout/bottom_buttons"
|
||||||
layout="@layout/bottom_sheet_dialog_button" />
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/dialog_button_ex_height" />
|
||||||
<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" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</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>
|
|
|
@ -2,18 +2,19 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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_marginStart="@dimen/list_content_padding"
|
||||||
android:layout_marginEnd="@dimen/list_content_padding"
|
|
||||||
android:layout_marginLeft="@dimen/list_content_padding"
|
android:layout_marginLeft="@dimen/list_content_padding"
|
||||||
android:layout_marginRight="@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">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/type_down_arrow"
|
android:id="@+id/type_down_arrow"
|
||||||
|
@ -28,9 +29,9 @@
|
||||||
android:id="@+id/master_profile_otfb"
|
android:id="@+id/master_profile_otfb"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
|
app:labelText="@string/master_profile"
|
||||||
app:primaryColor="@color/active_color_primary_dark"
|
app:primaryColor="@color/active_color_primary_dark"
|
||||||
app:secondaryColor="?android:textColorSecondary"
|
app:secondaryColor="?android:textColorSecondary">
|
||||||
app:labelText="@string/master_profile">
|
|
||||||
|
|
||||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||||
android:id="@+id/master_profile_et"
|
android:id="@+id/master_profile_et"
|
||||||
|
@ -38,7 +39,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
|
|
||||||
tools:text="Car" />
|
tools:text="Car" />
|
||||||
|
|
||||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||||
|
@ -51,4 +51,5 @@
|
||||||
android:focusable="true" />
|
android:focusable="true" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
@ -11,20 +11,21 @@
|
||||||
android:id="@+id/profile_name_otfb"
|
android:id="@+id/profile_name_otfb"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_margin="@dimen/list_content_padding"
|
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:primaryColor="@color/active_color_primary_dark"
|
||||||
app:secondaryColor="?android:textColorSecondary"
|
app:secondaryColor="?android:textColorSecondary">
|
||||||
app:labelText="@string/profile_name_hint">
|
|
||||||
|
|
||||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||||
android:id="@+id/profile_name_et"
|
android:id="@+id/profile_name_et"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="1"
|
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
tools:text="@string/lorem_ipsum" />
|
tools:text="@string/lorem_ipsum" />
|
||||||
|
|
||||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -52,7 +52,6 @@ public class ApplicationMode {
|
||||||
private static Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
|
private static Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
private static List<ApplicationMode> defaultValues = new ArrayList<>();
|
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> values = new ArrayList<>();
|
||||||
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<>();
|
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -194,6 +193,9 @@ public class ApplicationMode {
|
||||||
private ApplicationMode reg() {
|
private ApplicationMode reg() {
|
||||||
values.add(applicationMode);
|
values.add(applicationMode);
|
||||||
defaultValues.add(applicationMode);
|
defaultValues.add(applicationMode);
|
||||||
|
if (applicationMode.getOrder() == 0 && !values.isEmpty()) {
|
||||||
|
applicationMode.setOrder(values.size());
|
||||||
|
}
|
||||||
return applicationMode;
|
return applicationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +215,9 @@ public class ApplicationMode {
|
||||||
m.locationIconDayLost = m.parentAppMode.locationIconDayLost;
|
m.locationIconDayLost = m.parentAppMode.locationIconDayLost;
|
||||||
m.locationIconNightLost = m.parentAppMode.locationIconNightLost;
|
m.locationIconNightLost = m.parentAppMode.locationIconNightLost;
|
||||||
values.add(applicationMode);
|
values.add(applicationMode);
|
||||||
customValues.add(applicationMode);
|
if (applicationMode.getOrder() == 0 && !values.isEmpty()) {
|
||||||
|
applicationMode.setOrder(values.size());
|
||||||
|
}
|
||||||
return applicationMode;
|
return applicationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +416,13 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ApplicationMode> getCustomValues() {
|
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
|
// returns modifiable ! Set<ApplicationMode> to exclude non-wanted derived
|
||||||
|
@ -656,12 +666,11 @@ public class ApplicationMode {
|
||||||
public static void reorderAppModes() {
|
public static void reorderAppModes() {
|
||||||
Comparator<ApplicationMode> comparator = new Comparator<ApplicationMode>() {
|
Comparator<ApplicationMode> comparator = new Comparator<ApplicationMode>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(ApplicationMode o1, ApplicationMode o2) {
|
public int compare(ApplicationMode mode1, ApplicationMode mode2) {
|
||||||
return (o1.order < o2.order) ? -1 : ((o1.order == o2.order) ? 0 : 1);
|
return (mode1.order < mode2.order) ? -1 : ((mode1.order == mode2.order) ? 0 : 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Collections.sort(values, comparator);
|
Collections.sort(values, comparator);
|
||||||
Collections.sort(customValues, comparator);
|
|
||||||
Collections.sort(defaultValues, comparator);
|
Collections.sort(defaultValues, comparator);
|
||||||
Collections.sort(cachedFilteredValues, comparator);
|
Collections.sort(cachedFilteredValues, comparator);
|
||||||
}
|
}
|
||||||
|
@ -672,9 +681,11 @@ public class ApplicationMode {
|
||||||
|
|
||||||
ApplicationModeBuilder b = createCustomMode(valueOfStringKey(mb.parent, null),
|
ApplicationModeBuilder b = createCustomMode(valueOfStringKey(mb.parent, null),
|
||||||
mb.userProfileName, mb.stringKey);
|
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.icon(app, mb.iconName);
|
||||||
b.setColor(mb.iconColor);
|
b.setColor(mb.iconColor);
|
||||||
|
b.setOrder(mb.order);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,6 +698,7 @@ public class ApplicationMode {
|
||||||
mb.stringKey = stringKey;
|
mb.stringKey = stringKey;
|
||||||
mb.routeService = routeService;
|
mb.routeService = routeService;
|
||||||
mb.routingProfile = routingProfile;
|
mb.routingProfile = routingProfile;
|
||||||
|
mb.order = order;
|
||||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
return gson.toJson(mb);
|
return gson.toJson(mb);
|
||||||
}
|
}
|
||||||
|
@ -734,7 +746,7 @@ public class ApplicationMode {
|
||||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
|
|
||||||
List<ApplicationModeBean> defaultModeBeans = createApplicationModeBeans(defaultValues);
|
List<ApplicationModeBean> defaultModeBeans = createApplicationModeBeans(defaultValues);
|
||||||
List<ApplicationModeBean> customModeBeans = createApplicationModeBeans(customValues);
|
List<ApplicationModeBean> customModeBeans = createApplicationModeBeans(getCustomValues());
|
||||||
|
|
||||||
String defaultProfiles = gson.toJson(defaultModeBeans);
|
String defaultProfiles = gson.toJson(defaultModeBeans);
|
||||||
String customProfiles = gson.toJson(customModeBeans);
|
String customProfiles = gson.toJson(customModeBeans);
|
||||||
|
@ -744,7 +756,7 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void saveAppModesToSettings(OsmandSettings settings, boolean saveCustomModes) {
|
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);
|
List<ApplicationModeBean> modeBeans = createApplicationModeBeans(appModes);
|
||||||
|
|
||||||
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
|
@ -802,14 +814,18 @@ public class ApplicationMode {
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customValues.remove(md);
|
|
||||||
cachedFilteredValues.remove(md);
|
cachedFilteredValues.remove(md);
|
||||||
saveAppModesToSettings(app.getSettings(), md.isCustomProfile());
|
saveAppModesToSettings(app.getSettings(), md.isCustomProfile());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteCustomModes(List<ApplicationMode> modes, OsmandApplication app) {
|
public static void deleteCustomModes(List<ApplicationMode> modes, OsmandApplication app) {
|
||||||
values.removeAll(modes);
|
Iterator<ApplicationMode> it = values.iterator();
|
||||||
customValues.removeAll(modes);
|
while (it.hasNext()) {
|
||||||
|
ApplicationMode m = it.next();
|
||||||
|
if (modes.contains(m)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
cachedFilteredValues.removeAll(modes);
|
cachedFilteredValues.removeAll(modes);
|
||||||
saveAppModesToSettings(app.getSettings(), true);
|
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.MovePointCommand;
|
||||||
import net.osmand.plus.measurementtool.command.RemovePointCommand;
|
import net.osmand.plus.measurementtool.command.RemovePointCommand;
|
||||||
import net.osmand.plus.measurementtool.command.ReorderPointCommand;
|
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;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
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.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
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.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.settings.BaseSettingsFragment;
|
import net.osmand.plus.settings.BaseSettingsFragment;
|
||||||
|
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -47,20 +48,23 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
private EditProfilesAdapter adapter;
|
private EditProfilesAdapter adapter;
|
||||||
|
|
||||||
|
private boolean nightMode;
|
||||||
|
private boolean wasDrawerDisabled;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
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)) {
|
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);
|
appModesOrders = (HashMap<String, Integer>) savedInstanceState.getSerializable(APP_MODES_ORDER_KEY);
|
||||||
deletedModesKeys = savedInstanceState.getStringArrayList(DELETED_APP_MODES_KEY);
|
deletedModesKeys = savedInstanceState.getStringArrayList(DELETED_APP_MODES_KEY);
|
||||||
} else {
|
} else {
|
||||||
List<ApplicationMode> appModes = ApplicationMode.allPossibleValues();
|
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||||
for (int i = 0; i < appModes.size(); i++) {
|
appModesOrders.put(mode.getStringKey(), mode.getOrder());
|
||||||
ApplicationMode mode = appModes.get(i);
|
|
||||||
appModesOrders.put(mode.getStringKey(), i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nightMode = !app.getSettings().isLightContent();
|
||||||
|
|
||||||
View mainView = inflater.inflate(R.layout.edit_profiles_list_fragment, container, false);
|
View mainView = inflater.inflate(R.layout.edit_profiles_list_fragment, container, false);
|
||||||
AndroidUtils.addStatusBarPadding21v(getContext(), mainView);
|
AndroidUtils.addStatusBarPadding21v(getContext(), mainView);
|
||||||
|
|
||||||
|
@ -82,7 +86,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
||||||
RecyclerView recyclerView = mainView.findViewById(R.id.profiles_list);
|
RecyclerView recyclerView = mainView.findViewById(R.id.profiles_list);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
adapter = new EditProfilesAdapter(mapActivity);
|
adapter = new EditProfilesAdapter(app);
|
||||||
updateItems();
|
updateItems();
|
||||||
|
|
||||||
final ItemTouchHelper touchHelper = new ItemTouchHelper(new ReorderItemTouchHelperCallback(adapter));
|
final ItemTouchHelper touchHelper = new ItemTouchHelper(new ReorderItemTouchHelperCallback(adapter));
|
||||||
|
@ -125,7 +129,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
recyclerView.setAdapter(adapter);
|
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);
|
UiUtilities.setupDialogButton(false, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel);
|
||||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@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);
|
UiUtilities.setupDialogButton(false, applyButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_apply);
|
||||||
|
applyButton.setVisibility(View.VISIBLE);
|
||||||
applyButton.setOnClickListener(new View.OnClickListener() {
|
applyButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -185,6 +192,41 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
||||||
outState.putStringArrayList(DELETED_APP_MODES_KEY, deletedModesKeys);
|
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) {
|
public List<EditProfileDataObject> getProfiles(boolean deleted) {
|
||||||
List<EditProfileDataObject> profiles = new ArrayList<>();
|
List<EditProfileDataObject> profiles = new ArrayList<>();
|
||||||
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||||
|
@ -271,9 +313,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
|
||||||
EditProfilesAdapter(MapActivity mapActivity) {
|
EditProfilesAdapter(OsmandApplication app) {
|
||||||
setHasStableIds(true);
|
setHasStableIds(true);
|
||||||
app = mapActivity.getMyApplication();
|
this.app = app;
|
||||||
uiUtilities = app.getUIUtilities();
|
uiUtilities = app.getUIUtilities();
|
||||||
nightMode = !app.getSettings().isLightContent();
|
nightMode = !app.getSettings().isLightContent();
|
||||||
}
|
}
|
||||||
|
@ -390,11 +432,16 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
|
||||||
Object itemFrom = getItem(from);
|
Object itemFrom = getItem(from);
|
||||||
Object itemTo = getItem(to);
|
Object itemTo = getItem(to);
|
||||||
if (itemFrom instanceof EditProfileDataObject && itemTo instanceof EditProfileDataObject) {
|
if (itemFrom instanceof EditProfileDataObject && itemTo instanceof EditProfileDataObject) {
|
||||||
EditProfileDataObject profileDataObjectFrom = (EditProfileDataObject) itemFrom;
|
EditProfileDataObject profileFrom = (EditProfileDataObject) itemFrom;
|
||||||
EditProfileDataObject profileDataObjectTo = (EditProfileDataObject) itemTo;
|
EditProfileDataObject profileTo = (EditProfileDataObject) itemTo;
|
||||||
int tmp = profileDataObjectFrom.getOrder();
|
|
||||||
appModesOrders.put(profileDataObjectFrom.getStringKey(), profileDataObjectTo.getOrder());
|
int orderFrom = profileFrom.getOrder();
|
||||||
appModesOrders.put(profileDataObjectTo.getStringKey(), tmp);
|
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);
|
Collections.swap(items, from, to);
|
||||||
notifyItemMoved(from, to);
|
notifyItemMoved(from, to);
|
||||||
|
|
|
@ -28,9 +28,9 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
|
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback.UnmovableItem;
|
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback.UnmovableItem;
|
||||||
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback.OnItemMoveCallback;
|
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback.OnItemMoveCallback;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.widget.TextView;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dialogs.SelectMapViewQuickActionsBottomSheet;
|
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.ArrayList;
|
||||||
import java.util.Collections;
|
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 CREATE_PROFILE = "create_profile";
|
||||||
private static final String IMPORT_PROFILE = "import_profile";
|
private static final String IMPORT_PROFILE = "import_profile";
|
||||||
private static final String REORDER_PROFILES = "reorder_profiles";
|
private static final String REORDER_PROFILES = "reorder_profiles";
|
||||||
|
|
||||||
private List<ApplicationMode> allAppModes;
|
private List<ApplicationMode> allAppModes;
|
||||||
private Set<ApplicationMode> availableAppModes;
|
private Set<ApplicationMode> availableAppModes;
|
||||||
private SelectProfileListener selectProfileListener = null;
|
private SelectProfileListener selectProfileListener = null;
|
||||||
|
|
|
@ -27,8 +27,9 @@ public class NavigationFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
public static final String TAG = NavigationFragment.class.getSimpleName();
|
public static final String TAG = NavigationFragment.class.getSimpleName();
|
||||||
public static final String NAVIGATION_TYPE = "navigation_type";
|
public static final String NAVIGATION_TYPE = "navigation_type";
|
||||||
|
|
||||||
private SelectProfileBottomSheetDialogFragment.SelectProfileListener navTypeListener;
|
private SelectProfileBottomSheetDialogFragment.SelectProfileListener navTypeListener;
|
||||||
List<RoutingProfileDataObject> routingProfileDataObjects;
|
private List<RoutingProfileDataObject> routingProfileDataObjects;
|
||||||
private Preference navigationType;
|
private Preference navigationType;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,7 +20,6 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -30,6 +29,7 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
|
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.profiles.SettingsProfileFragment;
|
import net.osmand.plus.profiles.SettingsProfileFragment;
|
||||||
|
@ -134,12 +134,22 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
FrameLayout frameLayout = view.findViewById(android.R.id.list_container);
|
FrameLayout preferencesContainer = view.findViewById(android.R.id.list_container);
|
||||||
View inflatedLayout = UiUtilities.getInflater(getContext(), isNightMode())
|
LayoutInflater themedInflater = UiUtilities.getInflater(getContext(), isNightMode());
|
||||||
.inflate(R.layout.preference_cancel_save_button, frameLayout, false);
|
View buttonsContainer = themedInflater.inflate(R.layout.bottom_buttons, preferencesContainer, false);
|
||||||
frameLayout.addView(inflatedLayout);
|
|
||||||
Button cancelButton = inflatedLayout.findViewById(R.id.cancel_button);
|
preferencesContainer.addView(buttonsContainer);
|
||||||
Button saveButton = inflatedLayout.findViewById(R.id.save_profile_btn);
|
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() {
|
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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.RecyclerView;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
Loading…
Reference in a new issue