Remove old app modes settings screens

This commit is contained in:
Vitaliy 2020-01-23 19:02:02 +02:00
parent 0703dd9636
commit 41c9b3e7a3
16 changed files with 38 additions and 2210 deletions

View file

@ -391,7 +391,6 @@
<activity android:name="net.osmand.plus.activities.SettingsGeneralActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.activities.SettingsNavigationActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.monitoring.SettingsMonitoringActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.rastermaps.SettingsRasterMapsActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.osmedit.SettingsOsmEditingActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="net.osmand.plus.development.SettingsDevelopmentActivity" android:configChanges="keyboardHidden|orientation" />
@ -986,15 +985,6 @@
<receiver android:name="net.osmand.plus.liveupdates.LiveUpdatesAlarmReceiver"/>
<activity
android:configChanges="keyboardHidden|orientation"
android:label="Application profiles"
android:name=".profiles.SettingsProfileActivity"/>
<activity
android:name=".profiles.EditProfileActivity"
android:label="Application profiles"/>
<activity android:name=".activities.PrivacyAndSecurityActivity"
android:configChanges="keyboardHidden|orientation" />

View file

@ -1,576 +0,0 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="?attr/actionModeBackground"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/close_button"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/toolbar_height"
android:layout_height="@dimen/toolbar_height"
android:contentDescription="@string/access_shared_string_navigate_up"
android:src="@drawable/ic_action_mode_back" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size"
app:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
<ImageButton
android:id="@+id/delete_button"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/toolbar_height"
android:layout_height="@dimen/toolbar_height"
android:contentDescription="@string/shared_string_delete"
android:src="@drawable/ic_action_delete_dark" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color">
<ScrollView
android:id="@+id/scroll_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/setting_profile_item_height"
android:layout_gravity="top"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/type_selection_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:paddingStart="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding_small"
android:orientation="horizontal">
<ImageView
android:id="@+id/mode_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
android:layout_gravity="center_vertical"
android:tint="?attr/default_icon_color"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/profile_type_base_string"/>
<TextView
android:id="@+id/mode_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="18sp"
tools:text="Item additional description"/>
</LinearLayout>
<ImageView
android:id="@+id/type_down_arrow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_action_arrow_drop_down"
android:tint="@color/settings_divider"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
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">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/profile_name_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
tools:text="@string/lorem_ipsum"/>
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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">
<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"/>
<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/nav_type_hint">
<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>
<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>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/context_menu_action_buttons_h"
android:layout_marginTop="8dp"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/divider_color"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
<LinearLayout
android:id="@+id/select_icon_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_weight="1"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_icon"
android:textColor="?android:textColorPrimary"/>
<ImageView
android:id="@+id/profile_icon_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/list_content_padding"
tools:src="@drawable/ic_action_horse"
tools:tint="@color/A400red"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="36dp"
android:layout_gravity="center_vertical"
android:background="?attr/divider_color"/>
<LinearLayout
android:id="@+id/select_icon_color_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:paddingLeft="@dimen/list_content_padding"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_color"
android:textColor="?android:textColorPrimary"/>
<ImageView
android:id="@+id/color_sample_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/list_content_padding"
tools:src = "@drawable/ic_action_circle"
tools:tint="@color/A400red"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/divider_color"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
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"
android:text="@string/osmand_routing_promo"/>
<FrameLayout
android:id="@+id/click_block_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@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_marginRight="@dimen/list_content_padding"
android:text="@string/edit_profile_setup_title"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@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_marginRight="@dimen/list_content_padding"
android:text="@string/edit_profile_setup_subtitle"
android:textColor="@color/description_font_and_bottom_sheet_icons"/>
<LinearLayout
android:id="@+id/profile_config_btn"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/profile_config_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginLeft="@dimen/list_content_padding"
android:src="@drawable/ic_action_settings"
android:tint="?attr/default_icon_color"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/configure_profile"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/description_font_and_bottom_sheet_icons"
android:visibility="gone"
tools:text="@string/configure_profile_info"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<include layout="@layout/list_shadow_footer"/>
<LinearLayout
android:id="@+id/buttons_layout_sv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bg_color"
android:orientation="horizontal"
android:visibility="gone">
<Button
android:id="@+id/cancel_button_sv"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginEnd="8dp"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="8dp"
android:background="?attr/profile_cancel_btn"
android:text="@string/shared_string_cancel"
android:textAllCaps="false"
android:textColor="@color/map_widget_blue"/>
<Button
android:id="@+id/save_profile_btn_sv"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="8dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="8dp"
android:layout_marginRight="@dimen/list_content_padding"
android:background="?attr/profile_save_btn"
android:text="@string/shared_string_save"
android:textAllCaps="false"
android:textColor="@color/color_white"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
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"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="@dimen/list_content_padding"
android:layout_marginEnd="8dp"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="8dp"
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"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/list_content_padding"
android:layout_marginBottom="@dimen/list_content_padding"
android:layout_marginStart="8dp"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginLeft="8dp"
android:layout_marginRight="@dimen/list_content_padding"
android:background="?attr/profile_save_btn"
android:text="@string/shared_string_save"
android:textAllCaps="false"
android:textColor="@color/color_white"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>

View file

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/global_preference_toolbar" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/list_background_color"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/profiles_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingBottom="72dp"/>
<LinearLayout
android:id="@+id/add_profile_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:clickable="true"
android:focusable="true"
android:layout_gravity="bottom|center_horizontal"
android:background="@drawable/fab_extended_drawable"
android:orientation="horizontal"
android:gravity="center_vertical">
<android.support.v7.widget.AppCompatImageView
android:layout_gravity="center_vertical"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="14dp"
android:layout_marginStart="14dp"
android:src="@drawable/ic_action_plus"/>
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shared_string_add"
android:textColor="@color/color_white"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference android:key="general_settings" android:title="@string/general_settings_2" android:summary="@string/general_settings_descr"/>
<Preference android:key="application_profiles" android:title="@string/application_profiles" android:summary="@string/application_profiles_descr"/>
<Preference android:key="routing_settings" android:title="@string/routing_settings_2" android:summary="@string/routing_settings_descr"/>
<Preference android:key="subscription_settings" android:title="@string/osm_live_subscription" android:summary="@string/osm_live_subscription_desc"/>
<Preference android:key="privacy_and_security" android:title="@string/settings_privacy_and_security" android:summary="@string/settings_privacy_and_security_desc"/>

View file

@ -116,7 +116,6 @@ import net.osmand.plus.mapmarkers.PlanRouteFragment;
import net.osmand.plus.measurementtool.MeasurementEditingContext;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.measurementtool.NewGpxData;
import net.osmand.plus.profiles.EditProfileFragment;
import net.osmand.plus.quickaction.QuickActionListFragment;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager;
@ -675,13 +674,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
chooseRouteFragment.dismiss(true);
return;
}
EditProfileFragment editProfileFragment = getEditProfileFragment();
if (editProfileFragment != null) {
if (!editProfileFragment.onBackPressedAllowed()) {
editProfileFragment.confirmCancelDialog(this);
return;
}
}
ProfileAppearanceFragment profileAppearanceFragment = getProfileAppearanceFragment();
if (profileAppearanceFragment != null) {
if (profileAppearanceFragment.isProfileAppearanceChanged(this)) {
@ -859,21 +851,21 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
setIntent(null);
}
if (intent.hasExtra(EditProfileFragment.OPEN_SETTINGS)) {
String settingsType = intent.getStringExtra(EditProfileFragment.OPEN_SETTINGS);
String appMode = intent.getStringExtra(EditProfileFragment.SELECTED_ITEM);
if (EditProfileFragment.OPEN_CONFIG_PROFILE.equals(settingsType)) {
if (intent.hasExtra(BaseSettingsFragment.OPEN_SETTINGS)) {
String settingsType = intent.getStringExtra(BaseSettingsFragment.OPEN_SETTINGS);
String appMode = intent.getStringExtra(BaseSettingsFragment.APP_MODE_KEY);
if (BaseSettingsFragment.OPEN_CONFIG_PROFILE.equals(settingsType)) {
BaseSettingsFragment.showInstance(this, SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(appMode, null));
}
setIntent(null);
}
if (intent.hasExtra(EditProfileFragment.OPEN_CONFIG_ON_MAP)) {
switch (intent.getStringExtra(EditProfileFragment.OPEN_CONFIG_ON_MAP)) {
case EditProfileFragment.MAP_CONFIG:
if (intent.hasExtra(BaseSettingsFragment.OPEN_CONFIG_ON_MAP)) {
switch (intent.getStringExtra(BaseSettingsFragment.OPEN_CONFIG_ON_MAP)) {
case BaseSettingsFragment.MAP_CONFIG:
this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, null);
break;
case EditProfileFragment.SCREEN_CONFIG:
case BaseSettingsFragment.SCREEN_CONFIG:
this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, null);
break;
}
@ -1655,7 +1647,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
return super.onKeyUp(keyCode, event);
}
private void scrollMap(int dx, int dy) {
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
final QuadPoint cp = tb.getCenterPixelPoint();
@ -2409,10 +2401,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return getFragment(ChooseRouteFragment.TAG);
}
public EditProfileFragment getEditProfileFragment() {
return getFragment(EditProfileFragment.TAG);
}
public ProfileAppearanceFragment getProfileAppearanceFragment() {
return getFragment(ProfileAppearanceFragment.TAG);
}

View file

@ -14,7 +14,6 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.liveupdates.OsmLiveActivity;
import net.osmand.plus.profiles.SettingsProfileActivity;
public class SettingsActivity extends SettingsBaseActivity {
@ -29,7 +28,6 @@ public class SettingsActivity extends SettingsBaseActivity {
private Preference general;
private Preference routing;
private Preference subscription;
private Preference profiles;
private Preference privacy;
@ -43,8 +41,6 @@ public class SettingsActivity extends SettingsBaseActivity {
general.setOnPreferenceClickListener(this);
routing = (Preference) screen.findPreference("routing_settings");
routing.setOnPreferenceClickListener(this);
profiles = (Preference) screen.findPreference("application_profiles");
profiles.setOnPreferenceClickListener(this);
subscription = (Preference) screen.findPreference("subscription_settings");
subscription.setOnPreferenceClickListener(this);
privacy = (Preference) screen.findPreference("privacy_and_security");
@ -95,9 +91,6 @@ public class SettingsActivity extends SettingsBaseActivity {
if (preference == general) {
startActivity(new Intent(this, SettingsGeneralActivity.class));
return true;
} else if (preference == profiles){
startActivity(new Intent(this, SettingsProfileActivity.class));
return true;
} else if (preference == routing) {
startActivity(new Intent(this, SettingsNavigationActivity.class));
return true;

View file

@ -40,10 +40,11 @@ import java.util.Map;
import static net.osmand.plus.OsmandSettings.DAILY_DIRECTORY;
import static net.osmand.plus.OsmandSettings.MONTHLY_DIRECTORY;
import static net.osmand.plus.OsmandSettings.REC_DIRECTORY;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public class SettingsMonitoringActivity extends SettingsBaseActivity {
public static final String PROFILE_STRING_KEY = "string_key";
private CheckBoxPreference routeServiceEnabled;
private BroadcastReceiver broadcastReceiver;

View file

@ -1,72 +0,0 @@
package net.osmand.plus.profiles;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.MenuItemCompat;
import android.view.Menu;
import android.view.MenuItem;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
public class EditProfileActivity extends OsmandActionBarActivity {
public static final int DELETE_ID = 1010;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.single_fragment_layout);
if (savedInstanceState == null) {
EditProfileFragment editProfileFragment = new EditProfileFragment();
editProfileFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(android.R.id.content,
editProfileFragment, EditProfileFragment.TAG).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
int activeButtonsAndLinksTextResId = getMyApplication().getSettings().isLightContent() ?
R.color.active_buttons_and_links_text_light : R.color.active_buttons_and_links_text_dark;
Drawable icDelete = getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_delete_dark, activeButtonsAndLinksTextResId);
MenuItem m = menu.add(0, DELETE_ID, 0, R.string.action_delete)
.setIcon(icDelete);
MenuItemCompat.setShowAsAction(m, MenuItem.SHOW_AS_ACTION_ALWAYS);
super.onCreateOptionsMenu(menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (itemId) {
case android.R.id.home:
onBackPressed();
return true;
case DELETE_ID:
((EditProfileFragment) getSupportFragmentManager().findFragmentByTag(
EditProfileFragment.TAG)).onDeleteProfileClick();
return true;
}
return false;
}
@Override
public void onBackPressed() {
final EditProfileFragment epf = (EditProfileFragment) getSupportFragmentManager()
.findFragmentByTag(EditProfileFragment.TAG);
if (epf.onBackPressedAllowed()) {
super.onBackPressed();
} else {
epf.confirmCancelDialog(this);
}
}
}

View file

@ -1,968 +0,0 @@
package net.osmand.plus.profiles;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListPopupWindow;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ApplicationMode.ProfileIconColors;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
import net.osmand.router.GeneralRouter;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.PROFILE_KEY_ARG;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_BASE_APP_PROFILE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_NEW_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_USER_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public class EditProfileFragment extends BaseOsmAndFragment {
private static final Log LOG = PlatformUtil.getLog(EditProfileFragment.class);
public static final String TAG = EditProfileFragment.class.getSimpleName();
public static final String OPEN_CONFIG_PROFILE = "openConfigProfile";
public static final String OPEN_SETTINGS = "openSettings";
public static final String OPEN_CONFIG_ON_MAP = "openConfigOnMap";
public static final String MAP_CONFIG = "openMapConfigMenu";
public static final String NAV_CONFIG = "openNavConfigMenu";
public static final String SCREEN_CONFIG = "openScreenConfigMenu";
public static final String SELECTED_ITEM = "editedProfile";
public static final String SELECTED_ICON = "selectedIcon";
OsmandApplication app;
ApplicationMode mode = null;
ApplicationProfileObject profile = null;
List<RoutingProfileDataObject> routingProfileDataObjects;
RoutingProfileDataObject selectedRoutingProfileDataObject = null;
private boolean isNew = false;
private boolean isUserProfile = false;
private boolean dataChanged = false;
private boolean nightMode;
private SelectProfileListener navTypeListener = null;
private SelectProfileListener iconIdListener = null;
private SelectProfileListener baseTypeListener = null;
private TextView toolbarTitle;
private ImageView profileIcon;
private LinearLayout profileIconBtn;
private ImageView colorSample;
private LinearLayout selectColorBtn;
private ExtendedEditText profileNameEt;
private OsmandTextFieldBoxes profileNameTextBox;
private ExtendedEditText navTypeEt;
private OsmandTextFieldBoxes navTypeTextBox;
private FrameLayout selectNavTypeBtn;
private Button cancelBtn;
private Button saveButton;
private View profileConfigBtn;
private LinearLayout buttonsLayout;
private FrameLayout clickBlockLayout;
private LinearLayout typeSelectionBtn;
private ImageView baseModeIcon;
private TextView baseModeTitle;
private ScrollView scrollContainer;
private LinearLayout buttonsLayoutSV;
private Button cancelBtnSV;
private Button saveButtonSV;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
if (getArguments() != null) {
String modeName = getArguments().getString(PROFILE_STRING_KEY, "car");
isNew = getArguments().getBoolean(IS_NEW_PROFILE, false);
isUserProfile = getArguments().getBoolean(IS_USER_PROFILE, false);
mode = ApplicationMode.valueOfStringKey(modeName, ApplicationMode.DEFAULT);
profile = new ApplicationProfileObject(mode, isNew, isUserProfile);
}
nightMode = !app.getSettings().isLightContent();
routingProfileDataObjects = getRoutingProfiles(app);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final FragmentActivity activity = getActivity();
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(getContext(), themeRes);
final View view = inflater.cloneInContext(themedContext).inflate(R.layout.fragment_selected_profile, container, false);
setupToolbar(view);
toolbarTitle = view.findViewById(R.id.toolbar_title);
profileIcon = view.findViewById(R.id.profile_icon_img);
profileIconBtn = view.findViewById(R.id.select_icon_button);
colorSample = view.findViewById(R.id.color_sample_img);
selectColorBtn = view.findViewById(R.id.select_icon_color_button);
profileNameEt = view.findViewById(R.id.profile_name_et);
profileNameTextBox = view.findViewById(R.id.profile_name_otfb);
navTypeEt = view.findViewById(R.id.master_profile_et);
navTypeTextBox = view.findViewById(R.id.master_profile_otfb);
selectNavTypeBtn = view.findViewById(R.id.select_nav_type_btn);
cancelBtn = view.findViewById(R.id.cancel_button);
saveButton = view.findViewById(R.id.save_profile_btn);
profileConfigBtn = view.findViewById(R.id.profile_config_btn);
buttonsLayout = view.findViewById(R.id.buttons_layout);
clickBlockLayout = view.findViewById(R.id.click_block_layout);
typeSelectionBtn = view.findViewById(R.id.type_selection_button);
baseModeIcon = view.findViewById(R.id.mode_icon);
baseModeTitle = view.findViewById(R.id.mode_title);
scrollContainer = view.findViewById(R.id.scroll_view_container);
buttonsLayoutSV = view.findViewById(R.id.buttons_layout_sv);
cancelBtnSV = view.findViewById(R.id.cancel_button_sv);
saveButtonSV = view.findViewById(R.id.save_profile_btn_sv);
profileNameEt.setFocusable(true);
profileNameTextBox.getEditText().setSelection(profileNameEt.getText().length());
String title = getResources().getString(R.string.new_profile);
int startIconId = profile.iconId;
if (isNew) {
dataChanged = true;
startIconId = profile.parent.getIconRes();
profile.iconId = startIconId;
profile.iconStringName = profile.parent.getIconName();
} else if (isUserProfile) {
title = profile.userProfileTitle;
profileNameEt.setText(title);
dataChanged = false;
} else if (profile.stringKeyName != -1) {
title = getResources().getString(profile.stringKeyName);
profileNameEt.setText(title);
clickBlockLayout.setClickable(true);
}
profile.userProfileTitle = title;
if (profile.parent != null) {
setupBaseProfileView(profile.parent.getStringKey());
} else if (profile.stringKeyName != -1) {
baseModeTitle.setText(profile.stringKeyName);
baseModeIcon.setImageDrawable(
app.getUIUtilities().getIcon(profile.iconId, R.color.icon_color_default_light));
}
if (isUserProfile || isNew) {
typeSelectionBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment();
Bundle bundle = new Bundle();
if (profile.parent != null) {
bundle.putString(SELECTED_KEY, profile.parent.getStringKey());
}
bundle.putString(DIALOG_TYPE, TYPE_BASE_APP_PROFILE);
dialog.setArguments(bundle);
if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction()
.add(dialog, "select_base_type").commitAllowingStateLoss();
}
}
});
} else {
typeSelectionBtn.setClickable(false);
}
if (!Algorithms.isEmpty(mode.getRoutingProfile()) || mode.getRouteService() != RouteService.OSMAND) {
for (RoutingProfileDataObject r : routingProfileDataObjects) {
if (mode.getRoutingProfile() != null && mode.getRoutingProfile().equals(r.getStringKey())
|| (mode.getRouteService() == RouteService.BROUTER
&& r.getStringKey().equals(RoutingProfilesResources.BROUTER_MODE.name()))
|| (mode.getRouteService() == RouteService.STRAIGHT
&& r.getStringKey().equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name()))) {
profile.routingProfileDataObject = r;
r.setSelected(true);
navTypeEt.setText(r.getName());
navTypeEt.clearFocus();
}
}
} else {
for (RoutingProfileDataObject rp : routingProfileDataObjects) {
if (profile.stringKey.equals(rp.getStringKey())) {
navTypeEt.setText(
RoutingProfilesResources.valueOf(rp.getStringKey().toUpperCase())
.getStringRes());
}
}
navTypeEt.clearFocus();
}
profileNameEt.clearFocus();
updateToolbar(title);
int iconColor = profile.iconColor.getColor(nightMode);
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(startIconId, iconColor));
colorSample.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_circle, iconColor));
profileNameEt.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
profile.userProfileTitle = s.toString();
dataChanged = true;
updateToolbar(s.toString());
}
});
selectNavTypeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isNew || isUserProfile) {
hideKeyboard();
final SelectProfileBottomSheetDialogFragment fragment = new SelectProfileBottomSheetDialogFragment();
Bundle bundle = new Bundle();
if (profile.routingProfileDataObject != null) {
bundle.putString(SELECTED_KEY,
profile.routingProfileDataObject.getStringKey());
}
bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE);
fragment.setArguments(bundle);
if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction()
.add(fragment, "select_nav_type").commitAllowingStateLoss();
}
navTypeEt.setCursorVisible(false);
navTypeEt.setTextIsSelectable(false);
navTypeEt.clearFocus();
navTypeEt.requestFocus(ExtendedEditText.FOCUS_UP);
}
}
});
if (isUserProfile || isNew) {
profileIconBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final SelectProfileBottomSheetDialogFragment iconSelectDialog = new SelectProfileBottomSheetDialogFragment();
Bundle bundle = new Bundle();
// bundle.putString(DIALOG_TYPE, TYPE_ICON);
bundle.putString(SELECTED_ICON, profile.iconStringName);
iconSelectDialog.setArguments(bundle);
hideKeyboard();
if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction()
.add(iconSelectDialog, "select_icon")
.commitAllowingStateLoss();
}
}
});
selectColorBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popupWindow = new ListPopupWindow(activity);
popupWindow.setAnchorView(selectColorBtn);
popupWindow.setContentWidth(AndroidUtils.dpToPx(activity, 200f));
popupWindow.setModal(true);
if (Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
popupWindow.setDropDownGravity(Gravity.TOP | Gravity.RIGHT);
}
popupWindow.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f));
popupWindow.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
final ProfileColorAdapter profileColorAdapter = new ProfileColorAdapter(activity, mode.getIconColorInfo());
popupWindow.setAdapter(profileColorAdapter);
popupWindow.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
dataChanged = true;
profile.iconColor = ProfileIconColors.values()[position];
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(profile.iconId, profile.iconColor.getColor(nightMode)));
colorSample.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_circle, profile.iconColor.getColor(nightMode)));
popupWindow.dismiss();
}
});
popupWindow.show();
}
});
} else {
if (VERSION.SDK_INT > VERSION_CODES.LOLLIPOP) {
selectColorBtn.setBackground(null);
profileIconBtn.setBackground(null);
} else {
selectColorBtn.setBackgroundDrawable(null);
profileIconBtn.setBackgroundDrawable(null);
}
}
profileConfigBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (dataChanged) {
needSaveDialog();
} else if (getSettings() != null) {
if (activity instanceof EditProfileActivity) {
Intent i = new Intent(getActivity(), MapActivity.class);
i.putExtra(OPEN_SETTINGS, OPEN_CONFIG_PROFILE);
i.putExtra(SELECTED_ITEM, profile.stringKey);
startActivity(i);
} else {
BaseSettingsFragment.showInstance(activity, SettingsScreenType.CONFIGURE_PROFILE, ApplicationMode.valueOfStringKey(profile.stringKey, null));
}
}
}
});
cancelBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (getActivity() != null) {
getActivity().onBackPressed();
}
}
});
cancelBtnSV.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (getActivity() != null) {
getActivity().onBackPressed();
}
}
});
if (!isNew && !isUserProfile) {
saveButtonSV.setEnabled(false);
saveButton.setEnabled(false);
} else {
saveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (saveNewProfile()) {
activateMode(mode);
getActivity().onBackPressed();
}
}
});
saveButtonSV.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (saveNewProfile()) {
activateMode(mode);
getActivity().onBackPressed();
}
}
});
}
final float d = getResources().getDisplayMetrics().density;
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int marginShow = 66;
int marginHide = 0;
Rect r = new Rect();
view.getWindowVisibleDisplayFrame(r);
int screenHeight = view.getRootView().getHeight();
int keypadHeight = screenHeight - r.bottom;
if (keypadHeight > screenHeight * 0.15) {
buttonsLayout.setVisibility(View.GONE);
buttonsLayoutSV.setVisibility(View.VISIBLE);
setMargins(scrollContainer, 0, 0, 0, (int) (marginHide * d));
} else {
buttonsLayoutSV.setVisibility(View.GONE);
buttonsLayout.setVisibility(View.VISIBLE);
setMargins(scrollContainer, 0, 0, 0, (int) (marginShow * d));
}
}
});
return view;
}
@Override
public void onResume() {
getBaseProfileListener();
getNavProfileListener();
getIconListener();
super.onResume();
}
@Override
public int getStatusBarColorId() {
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
public boolean onBackPressedAllowed() {
return !dataChanged;
}
SelectProfileListener getIconListener() {
if (iconIdListener == null) {
iconIdListener = new SelectProfileListener() {
@Override
public void onSelectedType(Bundle bundle) {
int pos = -1;
dataChanged = true;
profile.iconId = pos;
profile.iconStringName = null;
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(pos,
profile.iconColor.getColor(nightMode)));
}
};
}
return iconIdListener;
}
SelectProfileListener getBaseProfileListener() {
if (baseTypeListener == null) {
baseTypeListener = new SelectProfileListener() {
@Override
public void onSelectedType(Bundle args) {
String profileKey = args.getString(PROFILE_KEY_ARG);
setupBaseProfileView(profileKey);
profile.parent = ApplicationMode.valueOfStringKey(profileKey, ApplicationMode.DEFAULT);
dataChanged = true;
}
};
}
return baseTypeListener;
}
SelectProfileListener getNavProfileListener() {
if (navTypeListener == null) {
navTypeListener = new SelectProfileListener() {
@Override
public void onSelectedType(Bundle args) {
int pos = -1;
updateRoutingProfile(pos);
}
};
}
return navTypeListener;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (!isUserProfile && !isNew) {
profileNameEt.setFocusable(false);
navTypeEt.setFocusable(false);
}
if (isNew) {
profileNameEt.requestFocus();
} else {
scrollContainer.requestFocus();
}
}
void updateRoutingProfile(int pos) {
dataChanged = true;
for (int i = 0; i < routingProfileDataObjects.size(); i++) {
if (i == pos) {
routingProfileDataObjects.get(i).setSelected(true);
} else {
routingProfileDataObjects.get(i).setSelected(false);
}
}
selectedRoutingProfileDataObject = routingProfileDataObjects.get(pos);
navTypeEt.setText(selectedRoutingProfileDataObject.getName());
profile.routingProfileDataObject = selectedRoutingProfileDataObject;
}
void activateMode(ApplicationMode mode) {
if (!ApplicationMode.values(app).contains(mode)) {
ApplicationMode.changeProfileAvailability(mode, true, getMyApplication());
}
}
private void setupToolbar(View view) {
FragmentActivity activity = getActivity();
AppBarLayout appBar = (AppBarLayout) view.findViewById(R.id.appbar);
if ((activity instanceof EditProfileActivity)) {
EditProfileActivity editProfileActivity = (EditProfileActivity) activity;
if (editProfileActivity.getSupportActionBar() != null) {
editProfileActivity.getSupportActionBar().setElevation(5.0f);
}
AndroidUiHelper.updateVisibility(appBar, false);
} else {
AndroidUtils.addStatusBarPadding21v(activity, view);
ViewCompat.setElevation(appBar, 5.0f);
View closeButton = view.findViewById(R.id.close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity fragmentActivity = getActivity();
if (fragmentActivity != null) {
fragmentActivity.onBackPressed();
}
}
});
View deleteBtn = view.findViewById(R.id.delete_button);
deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onDeleteProfileClick();
}
});
}
}
private void updateToolbar(String title) {
FragmentActivity activity = getActivity();
if (activity instanceof EditProfileActivity) {
EditProfileActivity editProfileActivity = (EditProfileActivity) activity;
if (editProfileActivity.getSupportActionBar() != null) {
editProfileActivity.getSupportActionBar().setTitle(title);
}
} else {
toolbarTitle.setText(title);
}
}
private void setupBaseProfileView(String stringKey) {
for (ApplicationMode am : ApplicationMode.getDefaultValues()) {
if (am.getStringKey().equals(stringKey)) {
baseModeIcon.setImageDrawable(
app.getUIUtilities().getIcon(am.getIconRes(), R.color.icon_color_default_light));
baseModeTitle.setText(Algorithms.capitalizeFirstLetter(am.toHumanString(app)));
dataChanged = false;
}
}
}
private void setMargins(View v, int l, int t, int r, int b) {
if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
p.setMargins(l, t, r, b);
v.requestLayout();
}
}
private boolean saveNewProfile() {
if (profile.routingProfileDataObject == null) {
showSaveWarningDialog(
getString(R.string.profile_alert_need_routing_type_title),
getString(R.string.profile_alert_need_routing_type_msg),
getActivity());
return false;
}
if (profile.userProfileTitle.isEmpty()
|| profile.userProfileTitle.replace(" ", "").length() < 1
|| profileNameEt.getText().toString().replace(" ", "").length() < 1) {
showSaveWarningDialog(
getString(R.string.profile_alert_need_profile_name_title),
getString(R.string.profile_alert_need_profile_name_msg),
getActivity()
);
return false;
}
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (m.getCustomProfileName() != null && getActivity() != null &&
m.getCustomProfileName().equals(profile.userProfileTitle) && isNew) {
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
bld.setTitle(R.string.profile_alert_duplicate_name_title);
bld.setMessage(R.string.profile_alert_duplicate_name_msg);
bld.setNegativeButton(R.string.shared_string_dismiss, null);
bld.show();
bld.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
profileNameEt.requestFocus();
}
});
return false;
}
}
String customStringKey = profile.stringKey;
if (isNew) {
customStringKey =
profile.parent.getStringKey() + "_" + System.currentTimeMillis();
}
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
.createCustomMode(profile.parent, profile.userProfileTitle.trim(), customStringKey)
.icon(app, profile.iconStringName);
if(profile.routingProfileDataObject.getStringKey().equals(
RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
builder.setRouteService(RouteService.STRAIGHT);
} else if(profile.routingProfileDataObject.getStringKey().equals(
RoutingProfilesResources.BROUTER_MODE.name())) {
builder.setRouteService(RouteService.BROUTER);
} else if (profile.routingProfileDataObject != null) {
builder.setRoutingProfile(profile.routingProfileDataObject.getStringKey());
}
builder.setColor(profile.iconColor);
mode = ApplicationMode.saveProfile(builder, getMyApplication());
if (!ApplicationMode.values(app).contains(mode)) {
ApplicationMode.changeProfileAvailability(mode, true, getMyApplication());
}
dataChanged = false;
return true;
}
private void needSaveDialog() {
if (getActivity() != null) {
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
bld.setTitle(R.string.profile_alert_need_save_title);
bld.setMessage(R.string.profile_alert_need_save_msg);
bld.setNegativeButton(R.string.shared_string_ok, null);
bld.show();
}
}
private void showSaveWarningDialog(String title, String message, Activity activity) {
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
bld.setTitle(title);
bld.setMessage(message);
bld.setNegativeButton(R.string.shared_string_dismiss, null);
bld.show();
}
public void confirmCancelDialog(final Activity activity) {
AlertDialog.Builder bld = new Builder(activity);
bld.setTitle(R.string.shared_string_dismiss);
bld.setMessage(R.string.exit_without_saving);
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dataChanged = false;
activity.onBackPressed();
}
});
bld.setNegativeButton(R.string.shared_string_cancel, null);
bld.show();
}
void onDeleteProfileClick() {
if (getActivity() != null) {
if (isUserProfile) {
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
bld.setTitle(R.string.profile_alert_delete_title);
bld.setMessage(String
.format(getString(R.string.profile_alert_delete_msg),
profile.userProfileTitle));
bld.setPositiveButton(R.string.shared_string_delete,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
OsmandApplication app = getMyApplication();
if (app != null) {
ApplicationMode.deleteCustomMode(mode, app);
app.getSettings().APPLICATION_MODE.set(ApplicationMode.DEFAULT);
}
if (getActivity() != null) {
getActivity().onBackPressed();
}
}
});
bld.setNegativeButton(R.string.shared_string_dismiss, null);
bld.show();
} else {
Toast.makeText(getActivity(), R.string.profile_alert_cant_delete_base,
Toast.LENGTH_SHORT).show();
}
}
}
private void hideKeyboard() {
View cf = getActivity().getCurrentFocus();
if (cf != null) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(cf.getWindowToken(), 0);
}
}
}
public static boolean showInstance(FragmentManager fragmentManager, boolean newProfile, boolean userProfile, String profileKey) {
try {
Bundle args = new Bundle();
args.putBoolean(IS_NEW_PROFILE, newProfile);
args.putBoolean(IS_USER_PROFILE, userProfile);
args.putString(PROFILE_STRING_KEY, profileKey);
EditProfileFragment editProfileFragment = new EditProfileFragment();
editProfileFragment.setArguments(args);
fragmentManager.beginTransaction()
.replace(R.id.fragmentContainer, editProfileFragment, TAG)
.addToBackStack(DRAWER_SETTINGS_ID + ".new")
.commit();
return true;
} catch (Exception e) {
return false;
}
}
private static List<RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
List<RoutingProfileDataObject> profilesObjects = new ArrayList<>();
profilesObjects.add(new RoutingProfileDataObject(
RoutingProfilesResources.STRAIGHT_LINE_MODE.name(),
context.getString(RoutingProfilesResources.STRAIGHT_LINE_MODE.getStringRes()),
context.getString(R.string.special_routing_type),
RoutingProfilesResources.STRAIGHT_LINE_MODE.getIconRes(),
false, null));
if (context.getBRouterService() != null) {
profilesObjects.add(new RoutingProfileDataObject(
RoutingProfilesResources.BROUTER_MODE.name(),
context.getString(RoutingProfilesResources.BROUTER_MODE.getStringRes()),
context.getString(R.string.third_party_routing_type),
RoutingProfilesResources.BROUTER_MODE.getIconRes(),
false, null));
}
Map<String, GeneralRouter> inputProfiles = context.getRoutingConfig().getAllRouters();
for (Entry<String, GeneralRouter> e : inputProfiles.entrySet()) {
if (!e.getKey().equals("geocoding")) {
int iconRes = R.drawable.ic_action_gdirections_dark;
String name = e.getValue().getProfileName();
String description = context.getString(R.string.osmand_default_routing);
if (!Algorithms.isEmpty(e.getValue().getFilename())) {
description = e.getValue().getFilename();
} else if (RoutingProfilesResources.isRpValue(name.toUpperCase())){
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
name = context
.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
}
profilesObjects.add(new RoutingProfileDataObject(e.getKey(), name, description,
iconRes, false, e.getValue().getFilename()));
}
}
return profilesObjects;
}
private enum RoutingProfilesResources {
STRAIGHT_LINE_MODE(R.string.routing_profile_straightline, R.drawable.ic_action_split_interval),
BROUTER_MODE(R.string.routing_profile_broutrer, R.drawable.ic_action_split_interval),
CAR(R.string.rendering_value_car_name, R.drawable.ic_action_car_dark),
PEDESTRIAN(R.string.rendering_value_pedestrian_name, R.drawable.ic_action_pedestrian_dark),
BICYCLE(R.string.rendering_value_bicycle_name, R.drawable.ic_action_bicycle_dark),
SKI(R.string.routing_profile_ski, R.drawable.ic_action_skiing),
PUBLIC_TRANSPORT(R.string.app_mode_public_transport, R.drawable.ic_action_bus_dark),
BOAT(R.string.app_mode_boat, R.drawable.ic_action_sail_boat_dark),
GEOCODING(R.string.routing_profile_geocoding, R.drawable.ic_action_world_globe);
int stringRes;
int iconRes;
RoutingProfilesResources(int stringRes, int iconRes) {
this.stringRes = stringRes;
this.iconRes = iconRes;
}
public int getStringRes() {
return stringRes;
}
public int getIconRes() {
return iconRes;
}
private static final List<String> rpValues = new ArrayList<>();
static {
for (RoutingProfilesResources rpr : RoutingProfilesResources.values()) {
rpValues.add(rpr.name());
}
}
public static boolean isRpValue(String value) {
return rpValues.contains(value);
}
}
class ApplicationProfileObject {
int stringKeyName = -1;
String stringKey;
String userProfileTitle = "";
ApplicationMode parent = null;
int iconId = R.drawable.ic_world_globe_dark;
String iconStringName = "ic_world_globe_dark";
ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
RoutingProfileDataObject routingProfileDataObject = null;
ApplicationProfileObject(ApplicationMode mode, boolean isNew, boolean isUserProfile) {
if (isNew) {
stringKey = mode.getStringKey() + System.currentTimeMillis();
parent = mode;
iconStringName = parent.getIconName();
} else if (isUserProfile) {
stringKey = mode.getStringKey();
parent = mode.getParent();
iconId = mode.getIconRes();
iconStringName = mode.getIconName();
iconColor = mode.getIconColorInfo() == null ? ProfileIconColors.DEFAULT : mode.getIconColorInfo();
userProfileTitle = mode.getCustomProfileName();
} else {
stringKeyName = mode.getNameKeyResource();
stringKey = mode.getStringKey();
iconId = mode.getIconRes();
iconStringName = mode.getIconName();
}
}
}
public static class ProfileColorAdapter extends ArrayAdapter<ColorListItem> {
private OsmandApplication app;
private ProfileIconColors currentColorData;
public ProfileColorAdapter(Context context, ProfileIconColors iconColorData) {
super(context, R.layout.rendering_prop_menu_item);
this.app = (OsmandApplication) getContext().getApplicationContext();
this.currentColorData = iconColorData;
init();
}
public void init() {
boolean nightMode = !app.getSettings().isLightContent();
String currentColorName = app.getString(ProfileIconColors.DEFAULT.getName());
ColorListItem item = new ColorListItem(currentColorName, currentColorName, ProfileIconColors.DEFAULT.getColor(nightMode));
add(item);
for (ProfileIconColors pic : ProfileIconColors.values()) {
if (pic != ProfileIconColors.DEFAULT) {
item = new ColorListItem(currentColorName, app.getString(pic.getName()), pic.getColor(nightMode));
add(item);
}
}
item.setLastItem(true);
}
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
ColorListItem item = getItem(position);
View v = convertView;
if (v == null) {
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
}
if (item != null) {
TextView textView = (TextView) v.findViewById(R.id.text1);
textView.setText(item.valueName);
if (item.color == -1) {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getUIUtilities().getThemedIcon(R.drawable.ic_action_circle), null);
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getUIUtilities().getIcon(R.drawable.ic_action_circle, item.color), null);
}
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));
v.findViewById(R.id.divider).setVisibility(item.lastItem
&& position < getCount() - 1 ? View.VISIBLE : View.GONE);
}
return v;
}
}
public static class ColorListItem {
private String currentValueName;
private String valueName;
private int color;
private boolean lastItem;
public ColorListItem(String currentValueName, String valueName, int color) {
this.currentValueName = currentValueName;
this.valueName = valueName;
this.color = color;
}
public int getColor() {
return color;
}
public boolean isLastItem() {
return lastItem;
}
public void setLastItem(boolean lastItem) {
this.lastItem = lastItem;
}
}
}

View file

@ -71,7 +71,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
if (type.equals(TYPE_NAV_PROFILE)) {
profiles.addAll(NavigationFragment.getRoutingProfiles(app).values());
} else if (type.equals(TYPE_BASE_APP_PROFILE)) {
profiles.addAll(SettingsProfileFragment.getBaseProfiles(app));
profiles.addAll(NavigationFragment.getBaseProfiles(app));
} else {
LOG.error("Check intent data!");
dismiss();
@ -267,14 +267,11 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
FragmentActivity activity = getActivity();
if (activity != null) {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
SettingsProfileFragment settingsProfileFragment = (SettingsProfileFragment) fragmentManager.findFragmentByTag(SettingsProfileFragment.class.getName());
NavigationFragment navigationFragment = (NavigationFragment) fragmentManager.findFragmentByTag(NavigationFragment.class.getName());
ProfileAppearanceFragment profileAppearanceFragment = (ProfileAppearanceFragment) fragmentManager.findFragmentByTag(ProfileAppearanceFragment.TAG);
MainSettingsFragment mainSettingsFragment = (MainSettingsFragment) fragmentManager.findFragmentByTag(MainSettingsFragment.TAG);
if (settingsProfileFragment != null) {
listener = settingsProfileFragment.getBaseProfileListener();
} else if (navigationFragment != null) {
if (navigationFragment != null) {
listener = navigationFragment.getNavProfileListener();
} else if (profileAppearanceFragment != null) {
listener = profileAppearanceFragment.getParentProfileListener();

View file

@ -1,43 +0,0 @@
package net.osmand.plus.profiles;
import android.os.Bundle;
import android.view.MenuItem;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
public class SettingsProfileActivity extends OsmandActionBarActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.single_fragment_layout);
getSupportActionBar().setElevation(5.0f);
getSupportActionBar().setTitle(R.string.application_profiles);
if (savedInstanceState == null) {
SettingsProfileFragment profileFragment = new SettingsProfileFragment();
profileFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, profileFragment, SettingsProfileFragment.class.getName()).commit();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (itemId) {
case android.R.id.home:
finish();
return true;
}
return false;
}
@Override
protected void onResume() {
super.onResume();
}
}

View file

@ -1,213 +0,0 @@
package net.osmand.plus.profiles;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.PROFILE_KEY_ARG;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_BASE_APP_PROFILE;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
import org.apache.commons.logging.Log;
public class SettingsProfileFragment extends BaseOsmAndFragment
implements ConfigureProfileMenuAdapter.ProfileSelectedListener, AbstractProfileMenuAdapter.ProfilePressedListener{
private static final Log LOG = PlatformUtil.getLog(SettingsProfileFragment.class);
public static final String PROFILE_STRING_KEY = "string_key";
public static final String IS_NEW_PROFILE = "new_profile";
public static final String IS_USER_PROFILE = "user_profile";
private ConfigureProfileMenuAdapter adapter;
private SelectProfileListener typeListener = null;
private List<ApplicationMode> allAppModes;
private Set<ApplicationMode> availableAppModes;
private List<ProfileDataObject> baseProfiles;
private boolean nightMode;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allAppModes.remove(ApplicationMode.DEFAULT);
availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication()));
availableAppModes.remove(ApplicationMode.DEFAULT);
baseProfiles = getBaseProfiles(getMyActivity());
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
nightMode = !requireSettings().isLightContent();
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
Context themedContext = new ContextThemeWrapper(getContext(), themeRes);
View view = inflater.cloneInContext(themedContext).inflate(R.layout.profiles_list_fragment, container, false);
AppBarLayout appBar = (AppBarLayout) view.findViewById(R.id.appbar);
if (!(getActivity() instanceof SettingsProfileActivity)) {
AndroidUtils.addStatusBarPadding21v(getContext(), view);
ViewCompat.setElevation(appBar, 5.0f);
TextView toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
toolbarTitle.setText(R.string.application_profiles);
View closeButton = view.findViewById(R.id.close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
mapActivity.onBackPressed();
}
}
});
} else {
AndroidUiHelper.updateVisibility(appBar, false);
}
RecyclerView recyclerView = view.findViewById(R.id.profiles_list);
LinearLayout addNewProfileBtn = view.findViewById(R.id.add_profile_btn);
addNewProfileBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(DIALOG_TYPE, TYPE_BASE_APP_PROFILE);
dialog.setArguments(bundle);
if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction()
.add(dialog, "select_base_type").commitAllowingStateLoss();
}
}
});
adapter = new ConfigureProfileMenuAdapter(allAppModes, availableAppModes, getMyApplication(), null, !getMyApplication().getSettings().isLightContent());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
return view;
}
@Override
public void onResume() {
super.onResume();
adapter.setProfilePressedListener(this);
adapter.setProfileSelectedListener(this);
getBaseProfileListener();
allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allAppModes.remove(ApplicationMode.DEFAULT);
adapter.updateItemsList(allAppModes, new LinkedHashSet<>(ApplicationMode.values(getMyApplication())));
}
@Override
public int getStatusBarColorId() {
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
SelectProfileListener getBaseProfileListener() {
if (typeListener == null) {
typeListener = new SelectProfileListener() {
@Override
public void onSelectedType(Bundle args) {
FragmentActivity activity = getActivity();
String profileKey = args.getString(PROFILE_KEY_ARG);
if (activity != null) {
if (activity instanceof SettingsProfileActivity) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(IS_NEW_PROFILE, true);
intent.putExtra(IS_USER_PROFILE, true);
intent.putExtra(PROFILE_STRING_KEY, profileKey);
activity.startActivity(intent);
} else {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) {
EditProfileFragment.showInstance(fragmentManager, true, true, profileKey);
}
}
}
}
};
}
return typeListener;
}
public static List<ProfileDataObject> getBaseProfiles(Context ctx) {
List<ProfileDataObject> profiles = new ArrayList<>();
for (ApplicationMode mode : ApplicationMode.getDefaultValues()) {
if (mode != ApplicationMode.DEFAULT) {
profiles.add(new ProfileDataObject(mode.toHumanString(ctx), mode.getDescription(ctx),
mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
}
}
return profiles;
}
@Override
public void onProfilePressed(ApplicationMode item) {
FragmentActivity activity = getActivity();
if (activity != null) {
if (activity instanceof SettingsProfileActivity) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
intent.putExtra(IS_USER_PROFILE, item.isCustomProfile());
activity.startActivity(intent);
} else {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) {
String profileKey = item.getStringKey();
EditProfileFragment.showInstance(fragmentManager, false, item.isCustomProfile(), profileKey);
}
}
}
}
@Override
public void onProfileSelected(ApplicationMode item, boolean isChecked) {
if (isChecked) {
availableAppModes.add(item);
} else {
availableAppModes.remove(item);
}
ApplicationMode.changeProfileAvailability(item, isChecked, getMyApplication());
}
}

View file

@ -1,219 +0,0 @@
package net.osmand.plus.rastermaps;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import net.osmand.ResultMatcher;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.views.SeekBarPreference;
import java.util.Map;
public class SettingsRasterMapsActivity extends SettingsBaseActivity {
private ListPreference tileSourcePreference;
private ListPreference overlayPreference;
private ListPreference underlayPreference;
public static final String MORE_VALUE = "MORE_VALUE";
public static final String DEFINE_EDIT = "DEFINE_EDIT";
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.shared_string_online_maps);
PreferenceScreen grp = getPreferenceScreen();
OnPreferenceChangeListener listener = createPreferenceListener();
PreferenceCategory cat = new PreferenceCategory(this);
cat.setTitle(R.string.pref_raster_map);
grp.addPreference(cat);
// present on configure map
// addTileSourcePrefs(listener, cat);
// int startZoom = 1;
// int endZoom = 18;
// String[] entries = new String[endZoom - startZoom + 1];
// Integer[] intValues = new Integer[endZoom - startZoom + 1];
// for (int i = startZoom; i <= endZoom; i++) {
// entries[i - startZoom] = i + ""; //$NON-NLS-1$
// intValues[i - startZoom] = i ;
// }
// ListPreference lp = createListPreference(settings.LEVEL_TO_SWITCH_VECTOR_RASTER,
// entries, intValues, R.string.level_to_switch_vector_raster, R.string.level_to_switch_vector_raster_descr);
// cat.addPreference(lp);
// present on configure map
// addOverlayPrefs(grp, listener);
}
@SuppressWarnings("unused")
private void addOverlayPrefs(PreferenceScreen grp, OnPreferenceChangeListener listener) {
PreferenceCategory cat;
cat = new PreferenceCategory(this);
cat.setTitle(R.string.pref_overlay);
grp.addPreference(cat);
overlayPreference = new ListPreference(this);
overlayPreference.setSummary(R.string.map_overlay_descr);
overlayPreference.setTitle(R.string.map_overlay);
overlayPreference.setOnPreferenceChangeListener(listener);
cat.addPreference(overlayPreference);
underlayPreference = new ListPreference(this);
underlayPreference.setSummary(R.string.map_underlay_descr);
underlayPreference.setTitle(R.string.map_underlay);
underlayPreference.setOnPreferenceChangeListener(listener);
cat.addPreference(underlayPreference);
SeekBarPreference sp = createSeekBarPreference(settings.MAP_OVERLAY_TRANSPARENCY, R.string.overlay_transparency, R.string.overlay_transparency_descr,
R.string.modify_transparency, 0, 255);
cat.addPreference(sp);
sp = createSeekBarPreference(settings.MAP_TRANSPARENCY, R.string.map_transparency, R.string.map_transparency_descr,
R.string.modify_transparency, 0, 255);
cat.addPreference(sp);
}
@SuppressWarnings("unused")
private void addTileSourcePrefs(OnPreferenceChangeListener listener, PreferenceCategory cat) {
CheckBoxPreference mapVectorData = createCheckBoxPreference(settings.MAP_ONLINE_DATA,
R.string.map_online_data, R.string.map_online_data_descr);
cat.addPreference(mapVectorData);
tileSourcePreference = new ListPreference(this);
tileSourcePreference.setSummary(R.string.map_tile_source_descr);
tileSourcePreference.setTitle(R.string.map_tile_source);
tileSourcePreference.setOnPreferenceChangeListener(listener);
cat.addPreference(tileSourcePreference);
}
public void updateAllSettings() {
super.updateAllSettings();
updateTileSourceSummary();
}
private void updateTileSourceSummary() {
if (tileSourcePreference != null) {
fillTileSourcesToPreference(tileSourcePreference, settings.MAP_TILE_SOURCES.get(), false);
fillTileSourcesToPreference(overlayPreference, settings.MAP_OVERLAY.get(), true);
fillTileSourcesToPreference(underlayPreference, settings.MAP_UNDERLAY.get(), true);
// String mapName = " " + osmandSettings.MAP_TILE_SOURCES.get(); //$NON-NLS-1$
// String summary = tileSourcePreference.getSummary().toString();
// if (summary.lastIndexOf(':') != -1) {
// summary = summary.substring(0, summary.lastIndexOf(':') + 1);
// }
// tileSourcePreference.setSummary(summary + mapName);
;
tileSourcePreference.setSummary(format(R.string.map_tile_source_descr, settings.MAP_TILE_SOURCES.get()));
overlayPreference.setSummary(format(R.string.map_overlay_descr, settings.MAP_OVERLAY.get()) );
underlayPreference.setSummary(format(R.string.map_underlay_descr, settings.MAP_UNDERLAY.get()) );
}
}
private String format(int r, String string) {
return getString(r) + " [" + (string == null ? "" : string) + "]";
}
private void fillTileSourcesToPreference(ListPreference tileSourcePreference, String value, boolean addNone) {
Map<String, String> entriesMap = settings.getTileSourceEntries();
int add = addNone ? 1 : 0;
String[] entries = new String[entriesMap.size() + 2 + add];
String[] values = new String[entriesMap.size() + 2 + add];
int ki = 0;
if (addNone) {
entries[ki] = getString(R.string.shared_string_none);
values[ki] = "";
ki++;
}
if (value == null) {
value = "";
}
for (Map.Entry<String, String> es : entriesMap.entrySet()) {
entries[ki] = es.getValue();
values[ki] = es.getKey();
ki++;
}
entries[ki] = getMyApplication().getString(R.string.install_more);
values[ki] = MORE_VALUE;
ki++;
entries[ki] = getMyApplication().getString(R.string.maps_define_edit);
values[ki] = DEFINE_EDIT;
fill(tileSourcePreference, entries, values, value);
}
private void fill(ListPreference component, String[] list, String[] values, String selected) {
component.setEntries(list);
component.setEntryValues(values);
component.setValue(selected);
}
private OnPreferenceChangeListener createPreferenceListener() {
return new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == tileSourcePreference || preference == overlayPreference
|| preference == underlayPreference) {
if(MORE_VALUE.equals(newValue)){
OsmandRasterMapsPlugin.installMapLayers(SettingsRasterMapsActivity.this, new ResultMatcher<TileSourceTemplate>() {
@Override
public boolean isCancelled() { return false;}
@Override
public boolean publish(TileSourceTemplate object) {
if(object == null){
updateTileSourceSummary();
}
return true;
}
});
} else if(DEFINE_EDIT.equals(newValue)){
OsmandRasterMapsPlugin.defineNewEditLayer(SettingsRasterMapsActivity.this, new ResultMatcher<TileSourceTemplate>() {
@Override
public boolean isCancelled() { return false;}
@Override
public boolean publish(TileSourceTemplate object) {
updateTileSourceSummary();
return true;
}
});
} else if(preference == tileSourcePreference){
settings.MAP_TILE_SOURCES.set((String) newValue);
updateTileSourceSummary();
} else {
if(((String) newValue).length() == 0){
newValue = null;
}
if(preference == underlayPreference){
settings.MAP_UNDERLAY.set(((String) newValue));
underlayPreference.setSummary(getString(R.string.map_underlay_descr) + " [" + settings.MAP_UNDERLAY.get() + "]");
} else if(preference == overlayPreference){
settings.MAP_OVERLAY.set(((String) newValue));
overlayPreference.setSummary(getString(R.string.map_overlay_descr) + " [" + settings.MAP_OVERLAY.get() + "]");
}
}
}
return true;
}
};
}
}

View file

@ -72,7 +72,13 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
OnPreferenceClickListener, AppModeChangedListener {
private static final Log LOG = PlatformUtil.getLog(BaseSettingsFragment.class);
private static final String APP_MODE_KEY = "app_mode_key";
public static final String APP_MODE_KEY = "app_mode_key";
public static final String OPEN_CONFIG_PROFILE = "openConfigProfile";
public static final String OPEN_SETTINGS = "openSettings";
public static final String OPEN_CONFIG_ON_MAP = "openConfigOnMap";
public static final String MAP_CONFIG = "openMapConfigMenu";
public static final String SCREEN_CONFIG = "screenConfig";
protected OsmandApplication app;
protected OsmandSettings settings;

View file

@ -52,10 +52,6 @@ import java.io.File;
import java.util.List;
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
import static net.osmand.plus.profiles.EditProfileFragment.MAP_CONFIG;
import static net.osmand.plus.profiles.EditProfileFragment.OPEN_CONFIG_ON_MAP;
import static net.osmand.plus.profiles.EditProfileFragment.SCREEN_CONFIG;
import static net.osmand.plus.profiles.EditProfileFragment.SELECTED_ITEM;
public class ConfigureProfileFragment extends BaseSettingsFragment implements CopyAppModePrefsListener, ResetAppModePrefsListener {
@ -248,7 +244,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
Intent intent = new Intent(ctx, MapActivity.class);
intent.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
intent.putExtra(APP_MODE_KEY, getSelectedAppMode().getStringKey());
configureMap.setIntent(intent);
}
@ -262,7 +258,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
Intent intent = new Intent(ctx, MapActivity.class);
intent.putExtra(OPEN_CONFIG_ON_MAP, SCREEN_CONFIG);
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
intent.putExtra(APP_MODE_KEY, getSelectedAppMode().getStringKey());
configureMap.setIntent(intent);
}

View file

@ -1,5 +1,6 @@
package net.osmand.plus.settings;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.SwitchPreferenceCompat;
@ -10,6 +11,7 @@ import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.profiles.ProfileDataObject;
import net.osmand.plus.profiles.RoutingProfileDataObject;
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
@ -18,7 +20,9 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import net.osmand.router.GeneralRouter;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
@ -186,6 +190,17 @@ public class NavigationFragment extends BaseSettingsFragment {
return profilesObjects;
}
public static List<ProfileDataObject> getBaseProfiles(Context ctx) {
List<ProfileDataObject> profiles = new ArrayList<>();
for (ApplicationMode mode : ApplicationMode.getDefaultValues()) {
if (mode != ApplicationMode.DEFAULT) {
profiles.add(new ProfileDataObject(mode.toHumanString(ctx), mode.getDescription(ctx),
mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
}
}
return profiles;
}
private void setupVehicleParametersPref() {
Preference vehicleParameters = findPreference("vehicle_parameters");
int iconRes = getSelectedAppMode().getIconRes();