Profile settings fifth part
This commit is contained in:
parent
3f12808b76
commit
efeaa0f63a
20 changed files with 490 additions and 517 deletions
|
@ -4,7 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="72dp">
|
||||
android:minHeight="52dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
|
|
17
OsmAnd/res/layout/preference_info_descr.xml
Normal file
17
OsmAnd/res/layout/preference_info_descr.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular" />
|
||||
|
||||
</LinearLayout>
|
|
@ -6,22 +6,47 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="36dp">
|
||||
android:minHeight="72dp">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/empty_state_text_button_padding_left"
|
||||
android:layout_marginLeft="@dimen/empty_state_text_button_padding_left"
|
||||
android:ellipsize="marquee"
|
||||
android:gravity="center_vertical"
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="@dimen/standard_icon_size"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/preference_category_title"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/shared_string_other" />
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:ellipsize="marquee"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/preference_category_title"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/shared_string_other" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="4"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<Preference
|
||||
android:key="configure_profile_info"
|
||||
android:layout="@layout/preference_info"
|
||||
android:layout="@layout/preference_info_descr"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:title="@string/configure_profile_info" />
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
<PreferenceCategory
|
||||
android:key="plugin_settings"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:layout="@layout/simple_preference_category"
|
||||
android:summary="@string/list_of_installed_plugins"
|
||||
android:title="@string/plugin_settings" />
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
android:icon="@drawable/ic_action_privacy_and_security"
|
||||
android:key="send_anonymous_data"
|
||||
android:layout="@layout/preference_dialog_and_switch"
|
||||
android:persistent="false"
|
||||
android:summaryOff="@string/shared_string_off"
|
||||
android:summaryOn="@string/shared_string_on"
|
||||
android:title="@string/analytics_pref_title" />
|
||||
|
|
|
@ -924,7 +924,12 @@ public class OsmandSettings {
|
|||
|
||||
@Override
|
||||
protected boolean setValue(Object prefs, ApplicationMode val) {
|
||||
return settingsAPI.edit(prefs).putString(getId(), val.getStringKey()).commit();
|
||||
boolean valueSaved = settingsAPI.edit(prefs).putString(getId(), val.getStringKey()).commit();
|
||||
if (valueSaved) {
|
||||
APPLICATION_MODE.set(val);
|
||||
}
|
||||
|
||||
return valueSaved;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1102,7 +1107,6 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference("do_not_show_startup_messages", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> DO_NOT_USE_ANIMATIONS = new BooleanPreference("do_not_use_animations", false).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_DATA = new BooleanPreference("send_anonymous_data", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference("send_anonymous_map_downloads_data", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_APP_USAGE_DATA = new BooleanPreference("send_anonymous_app_usage_data", false).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> SEND_ANONYMOUS_DATA_REQUEST_PROCESSED = new BooleanPreference("send_anonymous_data_request_processed", false).makeGlobal().cache();
|
||||
|
|
|
@ -879,7 +879,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
} else if (!isFirstScreenShowing() && OsmLiveCancelledDialog.shouldShowDialog(app)) {
|
||||
OsmLiveCancelledDialog.showInstance(getSupportFragmentManager());
|
||||
} else if (SendAnalyticsBottomSheetDialogFragment.shouldShowDialog(app)) {
|
||||
SendAnalyticsBottomSheetDialogFragment.showInstance(app, getSupportFragmentManager());
|
||||
SendAnalyticsBottomSheetDialogFragment.showInstance(app, getSupportFragmentManager(), null);
|
||||
}
|
||||
FirstUsageWelcomeFragment.SHOW = false;
|
||||
if (isFirstScreenShowing() && (!settings.SHOW_OSMAND_WELCOME_SCREEN.get() || !showOsmAndWelcomeScreen)) {
|
||||
|
|
|
@ -457,12 +457,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName,
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu) {
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu) {
|
||||
enterRoutePlanningModeGivenGpx(gpxFile, from, fromName, useIntermediatePointsByDefault, showMenu, MapRouteInfoMenu.DEFAULT_MENU_STATE);
|
||||
}
|
||||
|
||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName,
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu, int menuState) {
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu, int menuState) {
|
||||
settings.USE_INTERMEDIATE_POINTS_NAVIGATION.set(useIntermediatePointsByDefault);
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||
|
@ -479,7 +479,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
targets.setStartPoint(from, false, fromName);
|
||||
// then set gpx
|
||||
setGPXRouteParams(gpxFile);
|
||||
// then update start and destination point
|
||||
// then update start and destination point
|
||||
targets.updateRouteAndRefresh(true);
|
||||
|
||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
|
@ -685,7 +685,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setId(DRAWER_DIRECTIONS_ID)
|
||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||
|
@ -841,13 +841,13 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
||||
.setId(DRAWER_SETTINGS_ID)
|
||||
.setIcon(R.drawable.ic_action_compass)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_settings) + " (Alpha)")
|
||||
.setId(DRAWER_SETTINGS_ID + ".new")
|
||||
.setIcon(R.drawable.ic_action_settings)
|
||||
.setListener(new ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
app.logEvent("drawer_settings_open");
|
||||
app.logEvent("drawer_settings_new_open");
|
||||
mapActivity.showSettings();
|
||||
return true;
|
||||
}
|
||||
|
@ -963,24 +963,24 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
public void restoreOrReturnDialog(final String packageName) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setTitle("Restore OsmAnd");
|
||||
builder.setMessage("Do you want to Restore OsmAnd or get back to the Client App?");
|
||||
builder.setPositiveButton("Restore", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
restoreOsmand();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton("Return", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
executeHeadersIntent(packageName);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.show();
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setTitle("Restore OsmAnd");
|
||||
builder.setMessage("Do you want to Restore OsmAnd or get back to the Client App?");
|
||||
builder.setPositiveButton("Restore", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
restoreOsmand();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton("Return", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
executeHeadersIntent(packageName);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
protected void updateDrawerMenu() {
|
||||
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
|
@ -1014,17 +1014,17 @@ public class MapActivityActions implements DialogProvider {
|
|||
boolean hasHeader = menuItemsListView.getHeaderViewsCount() > 0;
|
||||
boolean hasFooter = menuItemsListView.getFooterViewsCount() > 0;
|
||||
if (hasHeader && position ==0 || (hasFooter && position== menuItemsListView.getCount() - 1)) {
|
||||
if(navDrawerLogoParams!=null) executeHeadersIntent(navDrawerLogoParams.get(0));
|
||||
else restoreOsmand();
|
||||
} else {
|
||||
position -= menuItemsListView.getHeaderViewsCount();
|
||||
ContextMenuItem item = contextMenuAdapter.getItem(position);
|
||||
ItemClickListener click = item.getItemClickListener();
|
||||
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
|
||||
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
|
||||
mapActivity.closeDrawer();
|
||||
}
|
||||
}
|
||||
if(navDrawerLogoParams!=null) executeHeadersIntent(navDrawerLogoParams.get(0));
|
||||
else restoreOsmand();
|
||||
} else {
|
||||
position -= menuItemsListView.getHeaderViewsCount();
|
||||
ContextMenuItem item = contextMenuAdapter.getItem(position);
|
||||
ItemClickListener click = item.getItemClickListener();
|
||||
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
|
||||
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
|
||||
mapActivity.closeDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1076,7 +1076,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
private void showReturnConfirmationDialog(String packageName) {
|
||||
restoreOrReturnDialog(packageName);
|
||||
mapActivity.closeDrawer();
|
||||
mapActivity.closeDrawer();
|
||||
}
|
||||
|
||||
private void restoreOsmand(){
|
||||
|
|
|
@ -590,7 +590,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
return (OsmandApplication) getApplication();
|
||||
}
|
||||
|
||||
protected void showWarnings(List<String> warnings) {
|
||||
public static void showWarnings(final OsmandApplication app, List<String> warnings) {
|
||||
if (!warnings.isEmpty()) {
|
||||
final StringBuilder b = new StringBuilder();
|
||||
boolean f = true;
|
||||
|
@ -602,11 +602,10 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
}
|
||||
b.append(w);
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(SettingsBaseActivity.this, b.toString(), Toast.LENGTH_LONG).show();
|
||||
|
||||
Toast.makeText(app, b.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
@ -22,6 +24,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.AppCompatCheckedTextView;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -69,7 +72,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
private Preference applicationDir;
|
||||
private ListPreference applicationModePreference;
|
||||
private Preference drivingRegionPreference;
|
||||
private ChooseAppDirFragment chooseAppDirFragment;
|
||||
private boolean permissionRequested;
|
||||
private boolean permissionGranted;
|
||||
|
||||
|
@ -223,17 +225,35 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
}
|
||||
registerListPreference(settings.ANGULAR_UNITS, screen, entries, ac);
|
||||
|
||||
Pair<String[], String[]> preferredLocaleInfo = getPreferredLocaleIdsAndValues(this);
|
||||
if (preferredLocaleInfo != null) {
|
||||
registerListPreference(settings.PREFERRED_LOCALE, screen, preferredLocaleInfo.first, preferredLocaleInfo.second);
|
||||
}
|
||||
|
||||
// Add " (Display language)" to menu title in Latin letters for all non-en languages
|
||||
if (!getResources().getString(R.string.preferred_locale).equals(getResources().getString(R.string.preferred_locale_no_translate))) {
|
||||
((ListPreference) screen.findPreference(settings.PREFERRED_LOCALE.getId())).setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")");
|
||||
}
|
||||
|
||||
// This setting now only in "Confgure map" menu
|
||||
//String[] values = ConfigureMapMenu.getMapNamesValues(this, ConfigureMapMenu.mapNamesIds);
|
||||
//String[] ids = ConfigureMapMenu.getSortedMapNamesIds(this, ConfigureMapMenu.mapNamesIds, values);
|
||||
//registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.getMapNamesValues(this, ids), ids);
|
||||
}
|
||||
|
||||
public static Pair<String[], String[]> getPreferredLocaleIdsAndValues(Context ctx) {
|
||||
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
|
||||
// Hardy maintenance 2016-05-29:
|
||||
// - Include languages if their translation is >= ~10% (but any language will be visible if it is the device's system locale)
|
||||
// - Mark as "incomplete" if < ~80%
|
||||
String incompleteSuffix = " (" + getString(R.string.incomplete_locale) + ")";
|
||||
String incompleteSuffix = " (" + ctx.getString(R.string.incomplete_locale) + ")";
|
||||
|
||||
// Add " (Device language)" to system default entry in Latin letters, so it can be more easily identified if a foreign language has been selected by mistake
|
||||
String latinSystemDefaultSuffix = " (" + getString(R.string.system_locale_no_translate) + ")";
|
||||
String latinSystemDefaultSuffix = " (" + ctx.getString(R.string.system_locale_no_translate) + ")";
|
||||
|
||||
//getResources().getAssets().getLocales();
|
||||
entrieValues = new String[]{"",
|
||||
String[] entryValues = new String[] {
|
||||
"",
|
||||
"en",
|
||||
"af",
|
||||
"ar",
|
||||
|
@ -294,83 +314,76 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
"vi",
|
||||
"zh_CN",
|
||||
"zh_TW"};
|
||||
entries = new String[]{getString(R.string.system_locale) + latinSystemDefaultSuffix,
|
||||
getString(R.string.lang_en),
|
||||
getString(R.string.lang_af) + incompleteSuffix,
|
||||
getString(R.string.lang_ar),
|
||||
getString(R.string.lang_ast) + incompleteSuffix,
|
||||
getString(R.string.lang_az),
|
||||
getString(R.string.lang_be),
|
||||
|
||||
String[] entries = new String[] {
|
||||
ctx.getString(R.string.system_locale) + latinSystemDefaultSuffix,
|
||||
ctx.getString(R.string.lang_en),
|
||||
ctx.getString(R.string.lang_af) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ar),
|
||||
ctx.getString(R.string.lang_ast) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_az),
|
||||
ctx.getString(R.string.lang_be),
|
||||
// getString(R.string.lang_be_by),
|
||||
getString(R.string.lang_bg),
|
||||
getString(R.string.lang_ca),
|
||||
getString(R.string.lang_cs),
|
||||
getString(R.string.lang_cy) + incompleteSuffix,
|
||||
getString(R.string.lang_da),
|
||||
getString(R.string.lang_de),
|
||||
getString(R.string.lang_el) + incompleteSuffix,
|
||||
getString(R.string.lang_en_gb),
|
||||
getString(R.string.lang_eo),
|
||||
getString(R.string.lang_es),
|
||||
getString(R.string.lang_es_ar),
|
||||
getString(R.string.lang_es_us),
|
||||
getString(R.string.lang_eu),
|
||||
getString(R.string.lang_fa),
|
||||
getString(R.string.lang_fi) + incompleteSuffix,
|
||||
getString(R.string.lang_fr),
|
||||
getString(R.string.lang_gl),
|
||||
getString(R.string.lang_he) + incompleteSuffix,
|
||||
getString(R.string.lang_hr) + incompleteSuffix,
|
||||
getString(R.string.lang_hsb) + incompleteSuffix,
|
||||
getString(R.string.lang_hu),
|
||||
getString(R.string.lang_hy),
|
||||
getString(R.string.lang_is),
|
||||
getString(R.string.lang_it),
|
||||
getString(R.string.lang_ja),
|
||||
getString(R.string.lang_ka) + incompleteSuffix,
|
||||
getString(R.string.lang_kab) + incompleteSuffix,
|
||||
getString(R.string.lang_kn) + incompleteSuffix,
|
||||
getString(R.string.lang_ko),
|
||||
getString(R.string.lang_lt),
|
||||
getString(R.string.lang_lv),
|
||||
getString(R.string.lang_ml) + incompleteSuffix,
|
||||
getString(R.string.lang_mr) + incompleteSuffix,
|
||||
getString(R.string.lang_nb),
|
||||
getString(R.string.lang_nl),
|
||||
getString(R.string.lang_nn) + incompleteSuffix,
|
||||
getString(R.string.lang_oc) + incompleteSuffix,
|
||||
getString(R.string.lang_pl),
|
||||
getString(R.string.lang_pt),
|
||||
getString(R.string.lang_pt_br),
|
||||
getString(R.string.lang_ro) + incompleteSuffix,
|
||||
getString(R.string.lang_ru),
|
||||
getString(R.string.lang_sc),
|
||||
getString(R.string.lang_sk),
|
||||
getString(R.string.lang_sl),
|
||||
getString(R.string.lang_sr) + incompleteSuffix,
|
||||
getString(R.string.lang_sr_latn) + incompleteSuffix,
|
||||
getString(R.string.lang_sv),
|
||||
getString(R.string.lang_tr),
|
||||
getString(R.string.lang_uk),
|
||||
getString(R.string.lang_vi) + incompleteSuffix,
|
||||
getString(R.string.lang_zh_cn) + incompleteSuffix,
|
||||
getString(R.string.lang_zh_tw)};
|
||||
String[] valuesPl = ConfigureMapMenu.getSortedMapNamesIds(this, entries, entries);
|
||||
String[] idsPl = ConfigureMapMenu.getSortedMapNamesIds(this, entrieValues, entries);
|
||||
registerListPreference(settings.PREFERRED_LOCALE, screen, valuesPl, idsPl);
|
||||
ctx.getString(R.string.lang_bg),
|
||||
ctx.getString(R.string.lang_ca),
|
||||
ctx.getString(R.string.lang_cs),
|
||||
ctx.getString(R.string.lang_cy) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_da),
|
||||
ctx.getString(R.string.lang_de),
|
||||
ctx.getString(R.string.lang_el) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_en_gb),
|
||||
ctx.getString(R.string.lang_eo),
|
||||
ctx.getString(R.string.lang_es),
|
||||
ctx.getString(R.string.lang_es_ar),
|
||||
ctx.getString(R.string.lang_es_us),
|
||||
ctx.getString(R.string.lang_eu),
|
||||
ctx.getString(R.string.lang_fa),
|
||||
ctx.getString(R.string.lang_fi) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_fr),
|
||||
ctx.getString(R.string.lang_gl),
|
||||
ctx.getString(R.string.lang_he) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_hr) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_hsb) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_hu),
|
||||
ctx.getString(R.string.lang_hy),
|
||||
ctx.getString(R.string.lang_is),
|
||||
ctx.getString(R.string.lang_it),
|
||||
ctx.getString(R.string.lang_ja),
|
||||
ctx.getString(R.string.lang_ka) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_kab) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_kn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ko),
|
||||
ctx.getString(R.string.lang_lt),
|
||||
ctx.getString(R.string.lang_lv),
|
||||
ctx.getString(R.string.lang_ml) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_mr) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_nb),
|
||||
ctx.getString(R.string.lang_nl),
|
||||
ctx.getString(R.string.lang_nn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_oc) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_pl),
|
||||
ctx.getString(R.string.lang_pt),
|
||||
ctx.getString(R.string.lang_pt_br),
|
||||
ctx.getString(R.string.lang_ro) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_ru),
|
||||
ctx.getString(R.string.lang_sc),
|
||||
ctx.getString(R.string.lang_sk),
|
||||
ctx.getString(R.string.lang_sl),
|
||||
ctx.getString(R.string.lang_sr) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_sr_latn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_sv),
|
||||
ctx.getString(R.string.lang_tr),
|
||||
ctx.getString(R.string.lang_uk),
|
||||
ctx.getString(R.string.lang_vi) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_zh_cn) + incompleteSuffix,
|
||||
ctx.getString(R.string.lang_zh_tw)};
|
||||
|
||||
// Add " (Display language)" to menu title in Latin letters for all non-en languages
|
||||
if (!getResources().getString(R.string.preferred_locale).equals(getResources().getString(R.string.preferred_locale_no_translate))) {
|
||||
((ListPreference) screen.findPreference(settings.PREFERRED_LOCALE.getId())).setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")");
|
||||
}
|
||||
String[] valuesPl = ConfigureMapMenu.getSortedMapNamesIds(ctx, entries, entries);
|
||||
String[] idsPl = ConfigureMapMenu.getSortedMapNamesIds(ctx, entryValues, entries);
|
||||
|
||||
// This setting now only in "Confgure map" menu
|
||||
//String[] values = ConfigureMapMenu.getMapNamesValues(this, ConfigureMapMenu.mapNamesIds);
|
||||
//String[] ids = ConfigureMapMenu.getSortedMapNamesIds(this, ConfigureMapMenu.mapNamesIds, values);
|
||||
//registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.getMapNamesValues(this, ids), ids);
|
||||
return Pair.create(valuesPl, idsPl);
|
||||
}
|
||||
|
||||
|
||||
protected void enableProxy(boolean enable) {
|
||||
settings.ENABLE_PROXY.set(enable);
|
||||
if (enable) {
|
||||
|
@ -425,14 +438,14 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
}
|
||||
|
||||
|
||||
public void showAppDirDialog() {
|
||||
public static void showAppDirDialog(final OsmandSettings settings, final ActionBarPreferenceActivity ctx, boolean permissionRequested, boolean permissionGranted) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
showAppDirDialogV19();
|
||||
showAppDirDialogV19(ctx,permissionRequested,permissionGranted);
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder editalert = new AlertDialog.Builder(SettingsGeneralActivity.this);
|
||||
AlertDialog.Builder editalert = new AlertDialog.Builder(ctx);
|
||||
editalert.setTitle(R.string.application_dir);
|
||||
final EditText input = new EditText(SettingsGeneralActivity.this);
|
||||
final EditText input = new EditText(ctx);
|
||||
input.setText(settings.getExternalStorageDirectory().getAbsolutePath());
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
|
@ -445,25 +458,27 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
editalert.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
editalert.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
warnAboutChangingStorage(input.getText().toString());
|
||||
warnAboutChangingStorage(settings,ctx,input.getText().toString());
|
||||
}
|
||||
});
|
||||
editalert.show();
|
||||
|
||||
}
|
||||
|
||||
private void showAppDirDialogV19() {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||
chooseAppDirFragment = new DashChooseAppDirFragment.ChooseAppDirFragment(this, (Dialog) null) {
|
||||
private static void showAppDirDialogV19(final Activity activity, boolean permissionRequested, boolean permissionGranted) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
|
||||
ChooseAppDirFragment chooseAppDirFragment = new DashChooseAppDirFragment.ChooseAppDirFragment(activity, (Dialog) null) {
|
||||
@Override
|
||||
protected void successCallback() {
|
||||
updateApplicationDirTextAndSummary();
|
||||
if (activity instanceof SettingsGeneralActivity) {
|
||||
((SettingsGeneralActivity) activity).updateApplicationDirTextAndSummary();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (permissionRequested && !permissionGranted) {
|
||||
chooseAppDirFragment.setPermissionDenied();
|
||||
}
|
||||
bld.setView(chooseAppDirFragment.initView(getLayoutInflater(), null, null));
|
||||
bld.setView(chooseAppDirFragment.initView(activity.getLayoutInflater(), null, null));
|
||||
AlertDialog dlg = bld.show();
|
||||
chooseAppDirFragment.setDialog(dlg);
|
||||
}
|
||||
|
@ -473,12 +488,12 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
if (!Version.isBlackberry(getMyApplication())) {
|
||||
applicationDir = new Preference(this);
|
||||
applicationDir.setTitle(R.string.application_dir);
|
||||
applicationDir.setKey("external_storage_dir");
|
||||
applicationDir.setKey(OsmandSettings.EXTERNAL_STORAGE_DIR);
|
||||
applicationDir.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
showAppDirDialog();
|
||||
showAppDirDialog(settings, SettingsGeneralActivity.this, permissionRequested, permissionGranted);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -569,7 +584,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
|
||||
|
||||
|
||||
private void warnAboutChangingStorage(final String newValue) {
|
||||
private static void warnAboutChangingStorage(final OsmandSettings settings, final ActionBarPreferenceActivity activity, String newValue) {
|
||||
String newDir = newValue != null ? newValue.trim() : newValue;
|
||||
if (!newDir.replace('/', ' ').trim().
|
||||
toLowerCase().endsWith(IndexConstants.APP_DIR.replace('/', ' ').trim())) {
|
||||
|
@ -578,21 +593,21 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
final File path = new File(newDir);
|
||||
path.mkdirs();
|
||||
if (!path.canRead() || !path.exists()) {
|
||||
Toast.makeText(this, R.string.specified_dir_doesnt_exist, Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(activity, R.string.specified_dir_doesnt_exist, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(getString(R.string.application_dir_change_warning3));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setMessage(activity.getString(R.string.application_dir_change_warning3));
|
||||
builder.setPositiveButton(R.string.shared_string_yes, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
MoveFilesToDifferentDirectory task =
|
||||
new MoveFilesToDifferentDirectory(SettingsGeneralActivity.this,
|
||||
new MoveFilesToDifferentDirectory(activity,
|
||||
settings.getExternalStorageDirectory(), path);
|
||||
task.setRunOnSuccess(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateSettingsToNewDir(path.getParentFile().getAbsolutePath());
|
||||
updateSettingsToNewDir(settings,activity,path.getParentFile().getAbsolutePath());
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -602,39 +617,41 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
updateSettingsToNewDir(path.getParentFile().getAbsolutePath());
|
||||
updateSettingsToNewDir(settings,activity,path.getParentFile().getAbsolutePath());
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void updateSettingsToNewDir(final String newDir) {
|
||||
private static void updateSettingsToNewDir(OsmandSettings settings, ActionBarPreferenceActivity activity, String newDir) {
|
||||
// edit the preference
|
||||
settings.setExternalStorageDirectoryPre19(newDir);
|
||||
getMyApplication().getResourceManager().resetStoreDirectory();
|
||||
reloadIndexes();
|
||||
updateApplicationDirTextAndSummary();
|
||||
((OsmandApplication) activity.getApplication()).getResourceManager().resetStoreDirectory();
|
||||
reloadIndexes(activity);
|
||||
if (activity instanceof SettingsGeneralActivity) {
|
||||
((SettingsGeneralActivity) activity).updateApplicationDirTextAndSummary();
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadIndexes() {
|
||||
setProgressVisibility(true);
|
||||
final CharSequence oldTitle = getToolbar().getTitle();
|
||||
getToolbar().setTitle(getString(R.string.loading_data));
|
||||
getToolbar().setSubtitle(getString(R.string.reading_indexes));
|
||||
public static void reloadIndexes(final ActionBarPreferenceActivity activity) {
|
||||
activity.setProgressVisibility(true);
|
||||
final CharSequence oldTitle = activity.getToolbar().getTitle();
|
||||
activity.getToolbar().setTitle(activity.getString(R.string.loading_data));
|
||||
activity.getToolbar().setSubtitle(activity.getString(R.string.reading_indexes));
|
||||
new AsyncTask<Void, Void, List<String>>() {
|
||||
|
||||
@Override
|
||||
protected List<String> doInBackground(Void... params) {
|
||||
return getMyApplication().getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS,
|
||||
return ((OsmandApplication) activity.getApplication()).getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS,
|
||||
new ArrayList<String>());
|
||||
}
|
||||
|
||||
protected void onPostExecute(List<String> result) {
|
||||
showWarnings(result);
|
||||
getToolbar().setTitle(oldTitle);
|
||||
getToolbar().setSubtitle("");
|
||||
setProgressVisibility(false);
|
||||
showWarnings(((OsmandApplication)activity.getApplication()),result);
|
||||
activity.getToolbar().setTitle(oldTitle);
|
||||
activity.getToolbar().setSubtitle("");
|
||||
activity.setProgressVisibility(false);
|
||||
}
|
||||
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -667,34 +684,11 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected void showWarnings(List<String> warnings) {
|
||||
if (!warnings.isEmpty()) {
|
||||
final StringBuilder b = new StringBuilder();
|
||||
boolean f = true;
|
||||
for (String w : warnings) {
|
||||
if (f) {
|
||||
f = false;
|
||||
} else {
|
||||
b.append('\n');
|
||||
}
|
||||
b.append(w);
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(SettingsGeneralActivity.this, b.toString(), Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (permissionRequested) {
|
||||
showAppDirDialogV19();
|
||||
showAppDirDialogV19(this, permissionRequested, permissionGranted);
|
||||
permissionRequested = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package net.osmand.plus.dialogs;
|
|||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Spannable;
|
||||
|
@ -25,7 +27,6 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
|
|||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitmeListDividerItem;
|
||||
import net.osmand.plus.chooseplan.OsmLiveCancelledDialog;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
@ -142,6 +143,7 @@ public class SendAnalyticsBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
settings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.set(false);
|
||||
settings.SEND_ANONYMOUS_APP_USAGE_DATA.set(false);
|
||||
settings.SEND_ANONYMOUS_DATA_REQUEST_PROCESSED.set(true);
|
||||
informAnalyticsPrefsUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,9 +153,17 @@ public class SendAnalyticsBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
settings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.set(sendAnonymousMapDownloadsData);
|
||||
settings.SEND_ANONYMOUS_APP_USAGE_DATA.set(sendAnonymousAppUsageData);
|
||||
settings.SEND_ANONYMOUS_DATA_REQUEST_PROCESSED.set(true);
|
||||
informAnalyticsPrefsUpdate();
|
||||
dismiss();
|
||||
}
|
||||
|
||||
private void informAnalyticsPrefsUpdate() {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof OnSendAnalyticsPrefsUpdate) {
|
||||
((OnSendAnalyticsPrefsUpdate) target).onAnalyticsPrefsUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldShowDialog(@NonNull OsmandApplication app) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
int requestsCount = settings.SEND_ANONYMOUS_DATA_REQUESTS_COUNT.get();
|
||||
|
@ -171,10 +181,11 @@ public class SendAnalyticsBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull OsmandApplication app, @NonNull FragmentManager fm) {
|
||||
public static void showInstance(@NonNull OsmandApplication app, @NonNull FragmentManager fm, @Nullable Fragment target) {
|
||||
try {
|
||||
if (fm.findFragmentByTag(SendAnalyticsBottomSheetDialogFragment.TAG) == null) {
|
||||
SendAnalyticsBottomSheetDialogFragment fragment = new SendAnalyticsBottomSheetDialogFragment();
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fm, SendAnalyticsBottomSheetDialogFragment.TAG);
|
||||
|
||||
OsmandSettings settings = app.getSettings();
|
||||
|
@ -190,4 +201,10 @@ public class SendAnalyticsBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
LOG.error("showInstance", e);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnSendAnalyticsPrefsUpdate {
|
||||
|
||||
void onAnalyticsPrefsUpdate();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
if (view != null) {
|
||||
AndroidUtils.addStatusBarPadding21v(getContext(), view);
|
||||
createToolbar(inflater, view);
|
||||
setDivider(null);
|
||||
}
|
||||
|
||||
return view;
|
||||
|
@ -110,7 +111,10 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
view.findViewById(R.id.close_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getActivity().getSupportFragmentManager().popBackStack();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
View switchProfile = view.findViewById(R.id.switch_profile_button);
|
||||
|
@ -244,11 +248,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
}
|
||||
|
||||
public void updateAllSettings() {
|
||||
String sharedPreferencesName = OsmandSettings.getSharedPreferencesName(getSelectedAppMode());
|
||||
getPreferenceManager().setSharedPreferencesName(sharedPreferencesName);
|
||||
updateToolbar(getView());
|
||||
getPreferenceScreen().removeAll();
|
||||
updatePreferencesScreen();
|
||||
updateToolbar(getView());
|
||||
}
|
||||
|
||||
@XmlRes
|
||||
|
@ -277,6 +279,11 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
return -1;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
protected int getActiveProfileColor() {
|
||||
return getSelectedAppMode().getIconColorInfo().getColor(isNightMode());
|
||||
}
|
||||
|
||||
protected void registerPreference(Preference preference) {
|
||||
if (preference != null) {
|
||||
preference.setOnPreferenceChangeListener(this);
|
||||
|
@ -352,16 +359,21 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
return iconsCache;
|
||||
}
|
||||
|
||||
protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getIcon(id, colorId) : null;
|
||||
}
|
||||
|
||||
protected Drawable getIcon(@DrawableRes int id) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getIcon(id) : null;
|
||||
}
|
||||
|
||||
protected Drawable getActiveIcon(@DrawableRes int id) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getIcon(id, getActiveProfileColor()) : null;
|
||||
}
|
||||
|
||||
protected Drawable getIcon(@DrawableRes int id, @ColorRes int colorId) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getIcon(id, colorId) : null;
|
||||
}
|
||||
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
UiUtilities cache = getIconsCache();
|
||||
return cache != null ? cache.getThemedIcon(id) : null;
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.aidl.OsmandAidlApi;
|
||||
import net.osmand.aidl.OsmandAidlApi.ConnectedApp;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -32,6 +36,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
|
|||
return R.layout.profile_preference_toolbar_big;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getToolbarTitle() {
|
||||
return getString(R.string.configure_profile);
|
||||
}
|
||||
|
@ -50,69 +55,99 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
|
|||
setupOsmandPluginsPref();
|
||||
}
|
||||
|
||||
private void setupConfigureMapPref() {
|
||||
Context ctx = getContext();
|
||||
if (ctx == null) {
|
||||
return;
|
||||
}
|
||||
Preference configureMap = findPreference("configure_map");
|
||||
configureMap.setIcon(getContentIcon(R.drawable.ic_action_layers_dark));
|
||||
|
||||
Intent intent = new Intent(ctx, MapActivity.class);
|
||||
intent.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
|
||||
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
|
||||
configureMap.setIntent(intent);
|
||||
}
|
||||
|
||||
private void setupConnectedAppsPref() {
|
||||
List<ConnectedApp> connectedApps = getMyApplication().getAidlApi().getConnectedApps();
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app == null) {
|
||||
return;
|
||||
}
|
||||
List<ConnectedApp> connectedApps = app.getAidlApi().getConnectedApps();
|
||||
for (ConnectedApp connectedApp : connectedApps) {
|
||||
SwitchPreference preference = new SwitchPreference(getContext());
|
||||
SwitchPreference preference = new SwitchPreference(app);
|
||||
preference.setPersistent(false);
|
||||
preference.setKey(connectedApp.getPack());
|
||||
preference.setTitle(connectedApp.getName());
|
||||
preference.setIcon(connectedApp.getIcon());
|
||||
preference.setChecked(connectedApp.isEnabled());
|
||||
preference.setLayoutResource(R.layout.preference_dialog_and_switch);
|
||||
preference.setLayoutResource(R.layout.preference_switch);
|
||||
|
||||
getPreferenceScreen().addPreference(preference);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupOsmandPluginsPref() {
|
||||
Context ctx = getContext();
|
||||
if (ctx == null) {
|
||||
return;
|
||||
}
|
||||
List<OsmandPlugin> plugins = OsmandPlugin.getVisiblePlugins();
|
||||
for (OsmandPlugin plugin : plugins) {
|
||||
SwitchPreferenceEx preference = new SwitchPreferenceEx(getContext());
|
||||
SwitchPreferenceEx preference = new SwitchPreferenceEx(ctx);
|
||||
preference.setPersistent(false);
|
||||
preference.setKey(plugin.getId());
|
||||
preference.setTitle(plugin.getName());
|
||||
preference.setIcon(getContentIcon(plugin.getLogoResourceId()));
|
||||
preference.setIcon(getPluginIcon(plugin));
|
||||
preference.setChecked(plugin.isActive());
|
||||
preference.setLayoutResource(R.layout.preference_dialog_and_switch);
|
||||
|
||||
Intent intent = new Intent(getContext(), PluginActivity.class);
|
||||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
|
||||
preference.setIntent(intent);
|
||||
preference.setIntent(getPluginIntent(plugin));
|
||||
|
||||
getPreferenceScreen().addPreference(preference);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupConfigureMapPref() {
|
||||
Preference configureMap = findPreference("configure_map");
|
||||
configureMap.setIcon(getContentIcon(R.drawable.ic_action_layers_dark));
|
||||
|
||||
Intent intent = new Intent(getActivity(), MapActivity.class);
|
||||
intent.putExtra(OPEN_CONFIG_ON_MAP, MAP_CONFIG);
|
||||
intent.putExtra(SELECTED_ITEM, getSelectedAppMode().getStringKey());
|
||||
configureMap.setIntent(intent);
|
||||
private Drawable getPluginIcon(OsmandPlugin plugin) {
|
||||
int iconResId = plugin.getLogoResourceId();
|
||||
return plugin.isActive() ? getActiveIcon(iconResId) : getContentIcon(iconResId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference.getKey().equals("configure_map")) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
|
||||
return false;
|
||||
private Intent getPluginIntent(OsmandPlugin plugin) {
|
||||
Intent intent;
|
||||
final Class<? extends Activity> settingsActivity = plugin.getSettingsActivity();
|
||||
if (settingsActivity != null && !plugin.needsInstallation()) {
|
||||
intent = new Intent(getContext(), settingsActivity);
|
||||
} else {
|
||||
intent = new Intent(getContext(), PluginActivity.class);
|
||||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
|
||||
}
|
||||
|
||||
return super.onPreferenceClick(preference);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
|
||||
OsmandPlugin plugin = OsmandPlugin.getPlugin(key);
|
||||
if (plugin != null) {
|
||||
Toast.makeText(getActivity(), "Change " + plugin.getId(), Toast.LENGTH_LONG).show();
|
||||
return OsmandPlugin.enablePlugin(getActivity(), app, plugin, (Boolean) newValue);
|
||||
if (newValue instanceof Boolean) {
|
||||
if ((plugin.isActive() || !plugin.needsInstallation())) {
|
||||
if (OsmandPlugin.enablePlugin(getActivity(), app, plugin, (Boolean) newValue)) {
|
||||
updateAllSettings();
|
||||
return true;
|
||||
}
|
||||
} else if (plugin.needsInstallation() && preference.getIntent() != null) {
|
||||
startActivity(preference.getIntent());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ConnectedApp connectedApp = getMyApplication().getAidlApi().getConnectedApp(key);
|
||||
|
||||
OsmandAidlApi aidlApi = app.getAidlApi();
|
||||
ConnectedApp connectedApp = aidlApi.getConnectedApp(key);
|
||||
if (connectedApp != null) {
|
||||
return getMyApplication().getAidlApi().switchEnabled(connectedApp);
|
||||
return aidlApi.switchEnabled(connectedApp);
|
||||
}
|
||||
|
||||
return super.onPreferenceChange(preference, newValue);
|
||||
|
|
|
@ -2,38 +2,36 @@ package net.osmand.plus.settings;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.StatFs;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.SettingsGeneralActivity;
|
||||
import net.osmand.plus.dashboard.DashChooseAppDirFragment;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
|
@ -41,13 +39,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GlobalSettingsFragment extends BaseSettingsFragment {
|
||||
public class GlobalSettingsFragment extends BaseSettingsFragment implements SendAnalyticsBottomSheetDialogFragment.OnSendAnalyticsPrefsUpdate, OnPreferenceChanged {
|
||||
|
||||
public static final String TAG = "GlobalSettingsFragment";
|
||||
|
||||
private Preference applicationDir;
|
||||
private boolean permissionRequested;
|
||||
private boolean permissionGranted;
|
||||
private static final String SEND_ANONYMOUS_DATA_PREF_ID = "send_anonymous_data";
|
||||
|
||||
@Override
|
||||
protected int getPreferencesResId() {
|
||||
|
@ -71,204 +67,163 @@ public class GlobalSettingsFragment extends BaseSettingsFragment {
|
|||
setupExternalStorageDirPref();
|
||||
|
||||
setupSendAnonymousDataPref();
|
||||
setupDoNotShowStartupMessagesPref();
|
||||
setupEnableProxyPref();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String prefId = preference.getKey();
|
||||
|
||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.ProgressBar), false);
|
||||
if (prefId.equals(SEND_ANONYMOUS_DATA_PREF_ID)) {
|
||||
if (newValue instanceof Boolean) {
|
||||
boolean enabled = (Boolean) newValue;
|
||||
if (enabled) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
SendAnalyticsBottomSheetDialogFragment.showInstance(app, fragmentManager, this);
|
||||
}
|
||||
} else {
|
||||
settings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.set(false);
|
||||
settings.SEND_ANONYMOUS_APP_USAGE_DATA.set(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return view;
|
||||
return super.onPreferenceChange(preference, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String prefId = preference.getKey();
|
||||
|
||||
if (prefId.equals(OsmandSettings.EXTERNAL_STORAGE_DIR)) {
|
||||
showAppDirDialog();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayPreferenceDialog(Preference preference) {
|
||||
String prefId = preference.getKey();
|
||||
|
||||
if (prefId.equals(SEND_ANONYMOUS_DATA_PREF_ID)) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
SendAnalyticsBottomSheetDialogFragment.showInstance(app, fragmentManager, this);
|
||||
}
|
||||
} else {
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreferenceChanged(String prefId) {
|
||||
if (prefId.equals(settings.DEFAULT_APPLICATION_MODE.getId())) {
|
||||
setupDefaultAppModePref();
|
||||
} else if (prefId.equals(settings.PREFERRED_LOCALE.getId())) {
|
||||
// recreate activity to update locale
|
||||
Activity activity = getActivity();
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null && activity != null) {
|
||||
app.checkPreferredLocale();
|
||||
activity.recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnalyticsPrefsUpdate() {
|
||||
setupSendAnonymousDataPref();
|
||||
}
|
||||
|
||||
private void setupDefaultAppModePref() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app == null) {
|
||||
return;
|
||||
}
|
||||
ApplicationMode selectedMode = settings.DEFAULT_APPLICATION_MODE.get();
|
||||
|
||||
int iconRes = selectedMode.getIconRes();
|
||||
String title = selectedMode.toHumanString(getContext());
|
||||
|
||||
ApplicationMode[] appModes = ApplicationMode.values(app).toArray(new ApplicationMode[0]);
|
||||
String[] entries = new String[appModes.length];
|
||||
String[] entryValues = new String[appModes.length];
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
entries[i] = appModes[i].toHumanString(app);
|
||||
entryValues[i] = appModes[i].getStringKey();
|
||||
}
|
||||
|
||||
final ListPreferenceEx defaultApplicationMode = (ListPreferenceEx) findPreference(settings.DEFAULT_APPLICATION_MODE.getId());
|
||||
defaultApplicationMode.setIcon(getContentIcon(iconRes));
|
||||
defaultApplicationMode.setSummary(title);
|
||||
ListPreferenceEx defaultApplicationMode = (ListPreferenceEx) findPreference(settings.DEFAULT_APPLICATION_MODE.getId());
|
||||
defaultApplicationMode.setIcon(getContentIcon(selectedMode.getIconRes()));
|
||||
defaultApplicationMode.setEntries(entries);
|
||||
defaultApplicationMode.setEntryValues(appModes);
|
||||
defaultApplicationMode.setEntryValues(entryValues);
|
||||
}
|
||||
|
||||
private void setupPreferredLocalePref() {
|
||||
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
|
||||
// Hardy maintenance 2016-05-29:
|
||||
// - Include languages if their translation is >= ~10% (but any language will be visible if it is the device's system locale)
|
||||
// - Mark as "incomplete" if < ~80%
|
||||
String incompleteSuffix = " (" + getString(R.string.incomplete_locale) + ")";
|
||||
|
||||
// Add " (Device language)" to system default entry in Latin letters, so it can be more easily identified if a foreign language has been selected by mistake
|
||||
String latinSystemDefaultSuffix = " (" + getString(R.string.system_locale_no_translate) + ")";
|
||||
|
||||
//getResources().getAssets().getLocales();
|
||||
String[] entrieValues = new String[] {"",
|
||||
"en",
|
||||
"af",
|
||||
"ar",
|
||||
"ast",
|
||||
"az",
|
||||
"be",
|
||||
//"be_BY",
|
||||
"bg",
|
||||
"ca",
|
||||
"cs",
|
||||
"cy",
|
||||
"da",
|
||||
"de",
|
||||
"el",
|
||||
"en_GB",
|
||||
"eo",
|
||||
"es",
|
||||
"es_AR",
|
||||
"es_US",
|
||||
"eu",
|
||||
"fa",
|
||||
"fi",
|
||||
"fr",
|
||||
"gl",
|
||||
"he",
|
||||
"hr",
|
||||
"hsb",
|
||||
"hu",
|
||||
"hy",
|
||||
"is",
|
||||
"it",
|
||||
"ja",
|
||||
"ka",
|
||||
"kab",
|
||||
"kn",
|
||||
"ko",
|
||||
"lt",
|
||||
"lv",
|
||||
"ml",
|
||||
"mr",
|
||||
"nb",
|
||||
"nl",
|
||||
"nn",
|
||||
"oc",
|
||||
"pl",
|
||||
"pt",
|
||||
"pt_BR",
|
||||
"ro",
|
||||
"ru",
|
||||
"sc",
|
||||
"sk",
|
||||
"sl",
|
||||
"sr",
|
||||
"sr+Latn",
|
||||
"sv",
|
||||
"tr",
|
||||
"uk",
|
||||
"vi",
|
||||
"zh_CN",
|
||||
"zh_TW"};
|
||||
|
||||
String[] entries = new String[] {getString(R.string.system_locale) + latinSystemDefaultSuffix,
|
||||
getString(R.string.lang_en),
|
||||
getString(R.string.lang_af) + incompleteSuffix,
|
||||
getString(R.string.lang_ar),
|
||||
getString(R.string.lang_ast) + incompleteSuffix,
|
||||
getString(R.string.lang_az),
|
||||
getString(R.string.lang_be),
|
||||
// getString(R.string.lang_be_by),
|
||||
getString(R.string.lang_bg),
|
||||
getString(R.string.lang_ca),
|
||||
getString(R.string.lang_cs),
|
||||
getString(R.string.lang_cy) + incompleteSuffix,
|
||||
getString(R.string.lang_da),
|
||||
getString(R.string.lang_de),
|
||||
getString(R.string.lang_el) + incompleteSuffix,
|
||||
getString(R.string.lang_en_gb),
|
||||
getString(R.string.lang_eo),
|
||||
getString(R.string.lang_es),
|
||||
getString(R.string.lang_es_ar),
|
||||
getString(R.string.lang_es_us),
|
||||
getString(R.string.lang_eu),
|
||||
getString(R.string.lang_fa),
|
||||
getString(R.string.lang_fi) + incompleteSuffix,
|
||||
getString(R.string.lang_fr),
|
||||
getString(R.string.lang_gl),
|
||||
getString(R.string.lang_he) + incompleteSuffix,
|
||||
getString(R.string.lang_hr) + incompleteSuffix,
|
||||
getString(R.string.lang_hsb) + incompleteSuffix,
|
||||
getString(R.string.lang_hu),
|
||||
getString(R.string.lang_hy),
|
||||
getString(R.string.lang_is),
|
||||
getString(R.string.lang_it),
|
||||
getString(R.string.lang_ja),
|
||||
getString(R.string.lang_ka) + incompleteSuffix,
|
||||
getString(R.string.lang_kab) + incompleteSuffix,
|
||||
getString(R.string.lang_kn) + incompleteSuffix,
|
||||
getString(R.string.lang_ko),
|
||||
getString(R.string.lang_lt),
|
||||
getString(R.string.lang_lv),
|
||||
getString(R.string.lang_ml) + incompleteSuffix,
|
||||
getString(R.string.lang_mr) + incompleteSuffix,
|
||||
getString(R.string.lang_nb),
|
||||
getString(R.string.lang_nl),
|
||||
getString(R.string.lang_nn) + incompleteSuffix,
|
||||
getString(R.string.lang_oc) + incompleteSuffix,
|
||||
getString(R.string.lang_pl),
|
||||
getString(R.string.lang_pt),
|
||||
getString(R.string.lang_pt_br),
|
||||
getString(R.string.lang_ro) + incompleteSuffix,
|
||||
getString(R.string.lang_ru),
|
||||
getString(R.string.lang_sc),
|
||||
getString(R.string.lang_sk),
|
||||
getString(R.string.lang_sl),
|
||||
getString(R.string.lang_sr) + incompleteSuffix,
|
||||
getString(R.string.lang_sr_latn) + incompleteSuffix,
|
||||
getString(R.string.lang_sv),
|
||||
getString(R.string.lang_tr),
|
||||
getString(R.string.lang_uk),
|
||||
getString(R.string.lang_vi) + incompleteSuffix,
|
||||
getString(R.string.lang_zh_cn) + incompleteSuffix,
|
||||
getString(R.string.lang_zh_tw)};
|
||||
|
||||
String[] valuesPl = ConfigureMapMenu.getSortedMapNamesIds(getContext(), entries, entries);
|
||||
String[] idsPl = ConfigureMapMenu.getSortedMapNamesIds(getContext(), entrieValues, entries);
|
||||
|
||||
Context ctx = getContext();
|
||||
if (ctx == null) {
|
||||
return;
|
||||
}
|
||||
ListPreferenceEx preferredLocale = (ListPreferenceEx) findPreference(settings.PREFERRED_LOCALE.getId());
|
||||
preferredLocale.setIcon(getContentIcon(R.drawable.ic_action_map_language));
|
||||
preferredLocale.setSummary(settings.PREFERRED_LOCALE.get());
|
||||
preferredLocale.setEntries(valuesPl);
|
||||
preferredLocale.setEntryValues(idsPl);
|
||||
|
||||
Pair<String[], String[]> preferredLocaleInfo = SettingsGeneralActivity.getPreferredLocaleIdsAndValues(ctx);
|
||||
if (preferredLocaleInfo != null) {
|
||||
preferredLocale.setEntries(preferredLocaleInfo.first);
|
||||
preferredLocale.setEntryValues(preferredLocaleInfo.second);
|
||||
}
|
||||
|
||||
// Add " (Display language)" to menu title in Latin letters for all non-en languages
|
||||
if (!getResources().getString(R.string.preferred_locale).equals(getResources().getString(R.string.preferred_locale_no_translate))) {
|
||||
preferredLocale.setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
// This setting now only in "Confgure map" menu
|
||||
//String[] values = ConfigureMapMenu.getMapNamesValues(this, ConfigureMapMenu.mapNamesIds);
|
||||
//String[] ids = ConfigureMapMenu.getSortedMapNamesIds(this, ConfigureMapMenu.mapNamesIds, values);
|
||||
//registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.getMapNamesValues(this, ids), ids);
|
||||
private void setupSendAnonymousDataPref() {
|
||||
boolean enabled = settings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get() || settings.SEND_ANONYMOUS_APP_USAGE_DATA.get();
|
||||
|
||||
settings.PREFERRED_LOCALE.addListener(new StateChangedListener<String>() {
|
||||
@Override
|
||||
public void stateChanged(String change) {
|
||||
// recreate activity to update locale
|
||||
Activity activity = getActivity();
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null && activity != null) {
|
||||
app.checkPreferredLocale();
|
||||
activity.recreate();
|
||||
}
|
||||
}
|
||||
});
|
||||
SwitchPreference sendAnonymousData = (SwitchPreference) findPreference(SEND_ANONYMOUS_DATA_PREF_ID);
|
||||
sendAnonymousData.setChecked(enabled);
|
||||
}
|
||||
|
||||
private void setupEnableProxyPref() {
|
||||
SwitchPreferenceEx enableProxy = (SwitchPreferenceEx) findPreference(settings.ENABLE_PROXY.getId());
|
||||
enableProxy.setIcon(getContentIcon(R.drawable.ic_action_proxy));
|
||||
}
|
||||
|
||||
|
||||
// -------------------------- APP DIR PREF --------------------------------------------------------
|
||||
|
||||
private Preference applicationDir;
|
||||
private boolean permissionRequested;
|
||||
private boolean permissionGranted;
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (permissionRequested) {
|
||||
showAppDirDialogV19();
|
||||
permissionRequested = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
String permissions[], int[] grantResults) {
|
||||
permissionRequested = requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE;
|
||||
if (permissionRequested
|
||||
&& grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
permissionGranted = true;
|
||||
} else {
|
||||
permissionGranted = false;
|
||||
Toast.makeText(getContext(),
|
||||
R.string.missing_write_external_storage_permission,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupExternalStorageDirPref() {
|
||||
|
@ -317,55 +272,6 @@ public class GlobalSettingsFragment extends BaseSettingsFragment {
|
|||
return "";
|
||||
}
|
||||
|
||||
private void setupSendAnonymousDataPref() {
|
||||
SwitchPreferenceEx sendAnonymousData = (SwitchPreferenceEx) findPreference(settings.SEND_ANONYMOUS_DATA.getId());
|
||||
}
|
||||
|
||||
private void setupDoNotShowStartupMessagesPref() {
|
||||
SwitchPreference doNotShowStartupMessages = (SwitchPreference) findPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES.getId());
|
||||
}
|
||||
|
||||
private void setupEnableProxyPref() {
|
||||
SwitchPreferenceEx enableProxy = (SwitchPreferenceEx) findPreference(settings.ENABLE_PROXY.getId());
|
||||
enableProxy.setIcon(getContentIcon(R.drawable.ic_action_proxy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayPreferenceDialog(Preference preference) {
|
||||
if (preference.getKey().equals(settings.SEND_ANONYMOUS_DATA.getId())) {
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
if (fragmentManager != null) {
|
||||
SendAnalyticsBottomSheetDialogFragment.showInstance(app, fragmentManager);
|
||||
}
|
||||
} else {
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String prefId = preference.getKey();
|
||||
|
||||
if (prefId.equals(OsmandSettings.EXTERNAL_STORAGE_DIR)) {
|
||||
showAppDirDialog();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String prefId = preference.getKey();
|
||||
|
||||
if (prefId.equals(settings.DEFAULT_APPLICATION_MODE.getId()) && newValue instanceof ApplicationMode) {
|
||||
preference.setIcon(getContentIcon(((ApplicationMode) newValue).getIconRes()));
|
||||
settings.APPLICATION_MODE.set((ApplicationMode) newValue);
|
||||
}
|
||||
|
||||
return super.onPreferenceChange(preference, newValue);
|
||||
}
|
||||
|
||||
public void showAppDirDialog() {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
showAppDirDialogV19();
|
||||
|
@ -478,7 +384,7 @@ public class GlobalSettingsFragment extends BaseSettingsFragment {
|
|||
}
|
||||
|
||||
protected void onPostExecute(List<String> result) {
|
||||
showWarnings(result);
|
||||
SettingsBaseActivity.showWarnings(getMyApplication(), result);
|
||||
toolbar.setTitle(oldTitle);
|
||||
toolbar.setSubtitle("");
|
||||
setProgressVisibility(false);
|
||||
|
@ -494,50 +400,4 @@ public class GlobalSettingsFragment extends BaseSettingsFragment {
|
|||
getView().findViewById(R.id.ProgressBar).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void showWarnings(List<String> warnings) {
|
||||
if (!warnings.isEmpty()) {
|
||||
final StringBuilder b = new StringBuilder();
|
||||
boolean f = true;
|
||||
for (String w : warnings) {
|
||||
if (f) {
|
||||
f = false;
|
||||
} else {
|
||||
b.append('\n');
|
||||
}
|
||||
b.append(w);
|
||||
}
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(getContext(), b.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (permissionRequested) {
|
||||
showAppDirDialogV19();
|
||||
permissionRequested = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
String permissions[], int[] grantResults) {
|
||||
permissionRequested = requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE;
|
||||
if (permissionRequested
|
||||
&& grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
permissionGranted = true;
|
||||
} else {
|
||||
permissionGranted = false;
|
||||
Toast.makeText(getContext(),
|
||||
R.string.missing_write_external_storage_permission,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,7 +53,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
ApplicationMode selectedMode = getSelectedAppMode();
|
||||
|
||||
int iconRes = selectedMode.getIconRes();
|
||||
int iconColor = selectedMode.getIconColorInfo().getColor(isNightMode());
|
||||
int iconColor = getActiveProfileColor();
|
||||
String title = selectedMode.toHumanString(getContext());
|
||||
|
||||
String profileType;
|
||||
|
@ -73,7 +73,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
|
|||
ApplicationMode selectedMode = getSelectedAppMode();
|
||||
|
||||
int iconRes = selectedMode.getIconRes();
|
||||
int iconColor = selectedMode.getIconColorInfo().getColor(isNightMode());
|
||||
int iconColor = getActiveProfileColor();
|
||||
String title = selectedMode.toHumanString(getContext());
|
||||
|
||||
String profileType;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
public interface OnPreferenceChanged {
|
||||
|
||||
void onPreferenceChanged(String prefId);
|
||||
|
||||
}
|
|
@ -34,15 +34,10 @@ public class ProxySettingsFragment extends BaseSettingsFragment {
|
|||
Preference mapDuringNavigationInfo = findPreference("proxy_preferences_info");
|
||||
mapDuringNavigationInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
||||
|
||||
setupEnableProxyPref();
|
||||
setupProxyHostPref();
|
||||
setupProxyPortPref();
|
||||
}
|
||||
|
||||
private void setupEnableProxyPref() {
|
||||
SwitchPreference enableProxyPref = (SwitchPreference) findPreference(settings.ENABLE_PROXY.getId());
|
||||
}
|
||||
|
||||
private void setupProxyHostPref() {
|
||||
EditTextPreferenceEx hostPref = (EditTextPreferenceEx) findPreference(settings.PROXY_HOST.getId());
|
||||
hostPref.setPersistent(false);
|
||||
|
|
|
@ -135,6 +135,10 @@ public class SingleSelectPreferenceBottomSheet extends MenuBottomSheetDialogFrag
|
|||
listPreference.setValue(value);
|
||||
}
|
||||
}
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof OnPreferenceChanged) {
|
||||
((OnPreferenceChanged) target).onPreferenceChanged(listPreference.getKey());
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.support.v7.preference.DialogPreference;
|
|||
import android.support.v7.preference.PreferenceDataStore;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandSettings.PreferencesDataStore;
|
||||
|
||||
public class ListPreferenceEx extends DialogPreference {
|
||||
|
@ -128,6 +129,8 @@ public class ListPreferenceEx extends DialogPreference {
|
|||
Object value = ((PreferencesDataStore) dataStore).getValue(getKey(), defaultValue);
|
||||
if (value instanceof Enum) {
|
||||
return ((Enum) value).ordinal();
|
||||
} else if (value instanceof ApplicationMode) {
|
||||
return ((ApplicationMode) value).getStringKey();
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class SwitchPreferenceEx extends SwitchPreference {
|
|||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
if (getFragment() == null) {
|
||||
if (getFragment() == null && getIntent() == null) {
|
||||
getPreferenceManager().showDialog(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue