Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
|
4d52d027e0 | ||
|
f64b174b27 | ||
|
5146c8283c | ||
|
efe669f5bc | ||
|
a9d2040e7e | ||
|
3849be68d9 | ||
|
76223ff8a7 | ||
|
4623eede17 | ||
|
884caf3739 | ||
|
c23d4b7c5b |
11 changed files with 350 additions and 178 deletions
|
@ -19,6 +19,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.router.BinaryRoutePlanner.FinalRouteSegment;
|
||||
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
|
||||
import net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -438,6 +439,10 @@ public class RouteResultPreparation {
|
|||
if (result.get(i).getObject().getOneway() == 0 || result.get(i + 1).getObject().getOneway() == 0) {
|
||||
ut = false;
|
||||
}
|
||||
if (!Algorithms.objectEquals(result.get(i).getObject().getName(),
|
||||
result.get(i + 1).getObject().getName())) {
|
||||
ut = false;
|
||||
}
|
||||
if (ut) {
|
||||
tnext.setSkipToSpeak(true);
|
||||
if (tl && TurnType.isLeftTurnNoUTurn(tnext.getValue())) {
|
||||
|
|
|
@ -326,8 +326,12 @@ public class RoutingContext {
|
|||
if(excludeNotAllowed != null && !excludeNotAllowed.contains(ro.getId())) {
|
||||
ts.add(ro);
|
||||
}
|
||||
} else if(excludeNotAllowed != null){
|
||||
} else if(excludeNotAllowed != null && ro.getId() > 0){
|
||||
excludeNotAllowed.add(ro.getId());
|
||||
if(ts.excludedIds == null ){
|
||||
ts.excludedIds = new TLongHashSet();
|
||||
}
|
||||
ts.excludedIds.add(ro.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -506,10 +510,22 @@ public class RoutingContext {
|
|||
}
|
||||
List<RoutingSubregionTile> subregions = indexedSubregions.get(tileId);
|
||||
if (subregions != null) {
|
||||
TLongHashSet duplicates = new TLongHashSet();
|
||||
boolean load = false;
|
||||
for (RoutingSubregionTile ts : subregions) {
|
||||
if (!ts.isLoaded()) {
|
||||
loadSubregionTile(ts, loadOptions == OPTION_IN_MEMORY_LOAD, null, duplicates);
|
||||
load = true;
|
||||
}
|
||||
}
|
||||
if (load) {
|
||||
TLongHashSet excludeIds = new TLongHashSet();
|
||||
for (RoutingSubregionTile ts : subregions) {
|
||||
if (!ts.isLoaded()) {
|
||||
loadSubregionTile(ts, loadOptions == OPTION_IN_MEMORY_LOAD, null, excludeIds);
|
||||
} else {
|
||||
if(ts.excludedIds != null) {
|
||||
excludeIds.addAll(ts.excludedIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -628,6 +644,7 @@ public class RoutingContext {
|
|||
private NativeRouteSearchResult searchResult = null;
|
||||
private int isLoaded = 0;
|
||||
private TLongObjectMap<RouteSegment> routes = null;
|
||||
private TLongHashSet excludedIds = null;
|
||||
|
||||
public RoutingSubregionTile(RouteSubregion subregion) {
|
||||
this.subregion = subregion;
|
||||
|
@ -738,6 +755,7 @@ public class RoutingContext {
|
|||
}
|
||||
searchResult = null;
|
||||
routes = null;
|
||||
excludedIds = null;
|
||||
}
|
||||
|
||||
public void setLoadedNonNative(){
|
||||
|
|
|
@ -52,135 +52,147 @@
|
|||
tools:text="@string/last_update"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="24dp">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/live_update"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_item"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true"/>
|
||||
</LinearLayout>
|
||||
android:layout_marginBottom="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="24dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="24dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/only_download_over_wifi"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
tools:text="Only download over WiFi long text like really long"/>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/live_update"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/downloadOverWiFiSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:checked="true"
|
||||
android:textSize="16sp"/>
|
||||
</LinearLayout>
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="16dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="24dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/update"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/only_download_over_wifi"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
tools:text="Only download over WiFi long text like really long"/>
|
||||
|
||||
<!--style="@style/OsmandLightTheme.Spinner"-->
|
||||
<Spinner
|
||||
android:id="@+id/updateFrequencySpinner"
|
||||
style="@style/OsmandLightTheme.Spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="0dp"/>
|
||||
</LinearLayout>
|
||||
<CheckBox
|
||||
android:id="@+id/downloadOverWiFiSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:checked="true"
|
||||
android:textSize="16sp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/updateTimesOfDayLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="16dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/update_time"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/update"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/updateTimesOfDaySpinner"
|
||||
style="@style/OsmandLightTheme.Spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="0dp"/>
|
||||
</LinearLayout>
|
||||
<!--style="@style/OsmandLightTheme.Spinner"-->
|
||||
<Spinner
|
||||
android:id="@+id/updateFrequencySpinner"
|
||||
style="@style/OsmandLightTheme.Spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="0dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="24dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/updateTimesOfDayLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/updates_size"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/update_time"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sizeTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
tools:text="64NB"/>
|
||||
<Spinner
|
||||
android:id="@+id/updateTimesOfDaySpinner"
|
||||
style="@style/OsmandLightTheme.Spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="0dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="24dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/updates_size"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sizeTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
tools:text="64MB"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
</LinearLayout>
|
|
@ -1135,8 +1135,8 @@ public class OsmandSettings {
|
|||
public final CommonPreference<String> MAP_TILE_SOURCES = new StringPreference("map_tile_sources",
|
||||
TileSourceManager.getMapnikSource().getName()).makeGlobal();
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_LAYER_TRANSPARENCY_SEEKBAR =
|
||||
new BooleanPreference("show_layer_transparency_seekbar", false).makeGlobal();
|
||||
public final CommonPreference<LayerTransparencySeekbarMode> LAYER_TRANSPARENCY_SEEKBAR_MODE =
|
||||
new EnumIntPreference<>("layer_transparency_seekbar_mode", LayerTransparencySeekbarMode.UNDEFINED, LayerTransparencySeekbarMode.values());
|
||||
|
||||
public final CommonPreference<String> MAP_OVERLAY_PREVIOUS = new StringPreference("map_overlay_previous", null).makeGlobal().cache();
|
||||
|
||||
|
@ -2579,6 +2579,24 @@ public class OsmandSettings {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public enum LayerTransparencySeekbarMode {
|
||||
OVERLAY(R.string.overlay_transparency),
|
||||
UNDERLAY(R.string.map_transparency),
|
||||
OFF(R.string.shared_string_off),
|
||||
UNDEFINED(R.string.shared_string_none);
|
||||
|
||||
private final int key;
|
||||
|
||||
LayerTransparencySeekbarMode(int key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String toHumanString(Context ctx) {
|
||||
return ctx.getString(key);
|
||||
}
|
||||
}
|
||||
|
||||
public enum MapMarkersMode {
|
||||
TOOLBAR(R.string.shared_string_topbar),
|
||||
WIDGETS(R.string.shared_string_widgets),
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.DialogInterface;
|
|||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.media.AudioManager;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -19,6 +20,7 @@ import android.preference.Preference.OnPreferenceChangeListener;
|
|||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -52,13 +54,15 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
|
||||
public class SettingsGeneralActivity extends SettingsBaseActivity {
|
||||
public class SettingsGeneralActivity extends SettingsBaseActivity implements OnRequestPermissionsResultCallback {
|
||||
|
||||
public static final String MORE_VALUE = "MORE_VALUE";
|
||||
private Preference applicationDir;
|
||||
private ListPreference applicationModePreference;
|
||||
private ListPreference drivingRegionPreference;
|
||||
|
||||
private ChooseAppDirFragment chooseAppDirFragment;
|
||||
private boolean permissionRequested;
|
||||
private boolean permissionGranted;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -335,15 +339,18 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
|||
|
||||
private void showAppDirDialogV19() {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||
ChooseAppDirFragment frg = new DashChooseAppDirFragment.ChooseAppDirFragment(this, (Dialog) null) {
|
||||
chooseAppDirFragment = new DashChooseAppDirFragment.ChooseAppDirFragment(this, (Dialog) null) {
|
||||
@Override
|
||||
protected void successCallback() {
|
||||
updateApplicationDirTextAndSummary();
|
||||
}
|
||||
};
|
||||
bld.setView(frg.initView(getLayoutInflater(), null, null));
|
||||
if (permissionRequested && !permissionGranted) {
|
||||
chooseAppDirFragment.setPermissionDenied();
|
||||
}
|
||||
bld.setView(chooseAppDirFragment.initView(getLayoutInflater(), null, null));
|
||||
AlertDialog dlg = bld.show();
|
||||
frg.setDialog(dlg);
|
||||
chooseAppDirFragment.setDialog(dlg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -620,5 +627,28 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
|||
return setFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(this,
|
||||
R.string.missing_write_external_storage_permission,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
|
@ -11,6 +12,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.StatFs;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -30,6 +32,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ProgressImplementation;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -65,7 +68,10 @@ public class DashChooseAppDirFragment {
|
|||
private Activity activity;
|
||||
private Fragment fragment;
|
||||
private Dialog dlg;
|
||||
|
||||
|
||||
private static int typeTemp = -1;
|
||||
private static String selectePathTemp;
|
||||
|
||||
public ChooseAppDirFragment(Activity activity, Fragment f) {
|
||||
this.activity = activity;
|
||||
this.fragment = f;
|
||||
|
@ -76,6 +82,11 @@ public class DashChooseAppDirFragment {
|
|||
this.dlg = dlg;
|
||||
}
|
||||
|
||||
public void setPermissionDenied() {
|
||||
typeTemp = -1;
|
||||
selectePathTemp = null;
|
||||
}
|
||||
|
||||
private String getFreeSpace(File dir) {
|
||||
if (dir.canRead()) {
|
||||
StatFs fs = new StatFs(dir.getAbsolutePath());
|
||||
|
@ -150,6 +161,7 @@ public class DashChooseAppDirFragment {
|
|||
copyMapsBtn = view.findViewById(R.id.copy_maps);
|
||||
confirmBtn = view.findViewById(R.id.confirm);
|
||||
addListeners();
|
||||
processPermissionGranted();
|
||||
updateView();
|
||||
return view;
|
||||
}
|
||||
|
@ -172,14 +184,12 @@ public class DashChooseAppDirFragment {
|
|||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_SPECIFIED);
|
||||
}
|
||||
File df = settings.getDefaultInternalStorage();
|
||||
if (type == OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT || OsmandSettings.isWritable(df)) {
|
||||
if (type == OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT) {
|
||||
selected = items.size();
|
||||
}
|
||||
items.add(getString(R.string.storage_directory_shared));
|
||||
paths.add(df.getAbsolutePath());
|
||||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT);
|
||||
if (type == OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT) {
|
||||
selected = items.size();
|
||||
}
|
||||
items.add(getString(R.string.storage_directory_shared));
|
||||
paths.add(df.getAbsolutePath());
|
||||
types.add(OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT);
|
||||
|
||||
File[] externals = getMyApplication().getExternalFilesDirs(null);
|
||||
if (externals != null) {
|
||||
|
@ -232,12 +242,28 @@ public class DashChooseAppDirFragment {
|
|||
dialog.dismiss();
|
||||
showOtherDialog();
|
||||
} else {
|
||||
mapsCopied = false;
|
||||
type = types.get(which);
|
||||
selectedFile = new File(paths.get(which));
|
||||
dialog.dismiss();
|
||||
updateView();
|
||||
|
||||
if (types.get(which) == OsmandSettings.EXTERNAL_STORAGE_TYPE_DEFAULT
|
||||
&& !DownloadActivity.hasPermissionToWriteExternalStorage(activity)) {
|
||||
|
||||
typeTemp = types.get(which);
|
||||
selectePathTemp = paths.get(which);
|
||||
dialog.dismiss();
|
||||
if (dlg != null) {
|
||||
dlg.dismiss();
|
||||
}
|
||||
|
||||
ActivityCompat.requestPermissions(activity,
|
||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
} else {
|
||||
mapsCopied = false;
|
||||
type = types.get(which);
|
||||
selectedFile = new File(paths.get(which));
|
||||
dialog.dismiss();
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -245,6 +271,17 @@ public class DashChooseAppDirFragment {
|
|||
editalert.show();
|
||||
}
|
||||
|
||||
private void processPermissionGranted() {
|
||||
if (typeTemp != -1 && selectePathTemp != null) {
|
||||
mapsCopied = false;
|
||||
type = typeTemp;
|
||||
selectedFile = new File(selectePathTemp);
|
||||
|
||||
typeTemp = -1;
|
||||
selectePathTemp = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void showOtherDialog() {
|
||||
AlertDialog.Builder editalert = new AlertDialog.Builder(activity);
|
||||
editalert.setTitle(R.string.application_dir);
|
||||
|
|
|
@ -220,7 +220,7 @@ public class ConfigureMapMenu {
|
|||
selected = settings.SELECTED_POI_FILTER_FOR_MAP.get() != null;
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.layer_poi, activity)
|
||||
.setSelected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null)
|
||||
.setSelected(selected)
|
||||
.setDescription(POIMapLayer.getSelectedPoiName(app))
|
||||
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
|
||||
.setIcon(R.drawable.ic_action_info_dark)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.dialogs;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
@ -9,10 +10,12 @@ import net.osmand.plus.ContextMenuItem;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.RasterMapType;
|
||||
import net.osmand.plus.views.GPXLayer;
|
||||
import net.osmand.plus.views.RouteLayer;
|
||||
|
||||
|
@ -20,7 +23,7 @@ public class RasterMapMenu {
|
|||
private static final String TAG = "RasterMapMenu";
|
||||
|
||||
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity,
|
||||
final OsmandRasterMapsPlugin.RasterMapType type) {
|
||||
final RasterMapType type) {
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||
createLayersItems(adapter, mapActivity, type);
|
||||
|
@ -29,23 +32,25 @@ public class RasterMapMenu {
|
|||
|
||||
private static void createLayersItems(final ContextMenuAdapter contextMenuAdapter,
|
||||
final MapActivity mapActivity,
|
||||
final OsmandRasterMapsPlugin.RasterMapType type) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
final RasterMapType type) {
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
|
||||
assert plugin != null;
|
||||
final OsmandSettings.CommonPreference<Integer> mapTransparencyPreference;
|
||||
final OsmandSettings.CommonPreference<String> mapTypePreference;
|
||||
final OsmandSettings.CommonPreference<String> exMapTypePreference;
|
||||
final LayerTransparencySeekbarMode currentMapTypeSeekbarMode =
|
||||
type == RasterMapType.OVERLAY ? LayerTransparencySeekbarMode.OVERLAY : LayerTransparencySeekbarMode.UNDERLAY;
|
||||
@StringRes final int mapTypeString;
|
||||
@StringRes final int mapTypeStringTransparency;
|
||||
if (type == OsmandRasterMapsPlugin.RasterMapType.OVERLAY) {
|
||||
if (type == RasterMapType.OVERLAY) {
|
||||
mapTransparencyPreference = settings.MAP_OVERLAY_TRANSPARENCY;
|
||||
mapTypePreference = settings.MAP_OVERLAY;
|
||||
exMapTypePreference = settings.MAP_OVERLAY_PREVIOUS;
|
||||
mapTypeString = R.string.map_overlay;
|
||||
mapTypeStringTransparency = R.string.overlay_transparency;
|
||||
} else if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY) {
|
||||
} else if (type == RasterMapType.UNDERLAY) {
|
||||
mapTransparencyPreference = settings.MAP_TRANSPARENCY;
|
||||
mapTypePreference = settings.MAP_UNDERLAY;
|
||||
exMapTypePreference = settings.MAP_UNDERLAY_PREVIOUS;
|
||||
|
@ -86,29 +91,31 @@ public class RasterMapMenu {
|
|||
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter,
|
||||
int itemId, int pos, boolean isChecked) {
|
||||
final int itemId, final int pos, final boolean isChecked) {
|
||||
if (itemId == toggleActionStringId) {
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.toggleUnderlayState(mapActivity, type, onMapSelectedCallback);
|
||||
if (type == RasterMapType.UNDERLAY) {
|
||||
hidePolygonsPref.set(isChecked);
|
||||
mapActivity.getDashboard().refreshContent(true);
|
||||
}
|
||||
refreshMapComplete(mapActivity);
|
||||
}
|
||||
});
|
||||
} else if (itemId == R.string.show_polygons) {
|
||||
hidePolygonsPref.set(!isChecked);
|
||||
refreshMapComplete(mapActivity);
|
||||
} else if (itemId == R.string.show_transparency_seekbar) {
|
||||
settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(
|
||||
isChecked ? currentMapTypeSeekbarMode : LayerTransparencySeekbarMode.OFF);
|
||||
if (isChecked) {
|
||||
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
|
||||
} else {
|
||||
mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference);
|
||||
}
|
||||
mapLayers.getMapControlsLayer().setTransparencyBarEnabled(isChecked);
|
||||
plugin.toggleUnderlayState(mapActivity, type, onMapSelectedCallback);
|
||||
if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY && !isChecked) {
|
||||
hidePolygonsPref.set(false);
|
||||
mapActivity.getDashboard().refreshContent(true);
|
||||
}
|
||||
refreshMapComplete(mapActivity);
|
||||
} else if (itemId == R.string.show_polygons) {
|
||||
hidePolygonsPref.set(!isChecked);
|
||||
refreshMapComplete(mapActivity);
|
||||
} else if (itemId == R.string.show_transparency_seekbar) {
|
||||
settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.set(isChecked);
|
||||
mapLayers.getMapControlsLayer().setTransparencyBarEnabled(isChecked);
|
||||
if (isChecked) {
|
||||
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -144,15 +151,14 @@ public class RasterMapMenu {
|
|||
.setProgress(mapTransparencyPreference.get())
|
||||
.setListener(l)
|
||||
.setIntegerListener(integerListener).createItem());
|
||||
if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY) {
|
||||
if (type == RasterMapType.UNDERLAY) {
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.show_polygons, mapActivity)
|
||||
.hideDivider(true)
|
||||
.setListener(l)
|
||||
.setSelected(hidePolygonsPref.get()).createItem());
|
||||
.setSelected(!hidePolygonsPref.get()).createItem());
|
||||
}
|
||||
Boolean transparencySwitchState = settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.get()
|
||||
&& mapLayers.getMapControlsLayer().isTransparencyBarInitialized();
|
||||
Boolean transparencySwitchState = isSeekbarVisible(app, type);
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.show_transparency_seekbar, mapActivity)
|
||||
.hideDivider(true)
|
||||
|
@ -161,7 +167,15 @@ public class RasterMapMenu {
|
|||
}
|
||||
}
|
||||
|
||||
private static void refreshMapComplete(final MapActivity activity) {
|
||||
@NonNull
|
||||
public static Boolean isSeekbarVisible(OsmandApplication app, RasterMapType type) {
|
||||
final OsmandSettings.LayerTransparencySeekbarMode currentMapTypeSeekbarMode =
|
||||
type == RasterMapType.OVERLAY ? OsmandSettings.LayerTransparencySeekbarMode.OVERLAY : OsmandSettings.LayerTransparencySeekbarMode.UNDERLAY;
|
||||
LayerTransparencySeekbarMode seekbarMode = app.getSettings().LAYER_TRANSPARENCY_SEEKBAR_MODE.get();
|
||||
return seekbarMode == LayerTransparencySeekbarMode.UNDEFINED || seekbarMode == currentMapTypeSeekbarMode;
|
||||
}
|
||||
|
||||
public static void refreshMapComplete(final MapActivity activity) {
|
||||
activity.getMyApplication().getResourceManager().getRenderer().clearCache();
|
||||
activity.updateMapSettings();
|
||||
GPXLayer gpx = activity.getMapView().getLayerByClass(GPXLayer.class);
|
||||
|
|
|
@ -28,12 +28,14 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.DownloadTilesDialog;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||
import net.osmand.plus.dialogs.RasterMapMenu;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -104,6 +106,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
};
|
||||
// mapView.addLayer(overlayLayer, 0.7f);
|
||||
settings.MAP_OVERLAY_TRANSPARENCY.addListener(overlayLayerListener);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -234,7 +238,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
public void registerLayerContextMenuActions(final OsmandMapTileView mapView,
|
||||
ContextMenuAdapter adapter,
|
||||
final MapActivity mapActivity) {
|
||||
final MapActivityLayers layers = mapActivity.getMapLayers();
|
||||
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() {
|
||||
@Override
|
||||
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) {
|
||||
|
@ -288,6 +291,11 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
final OsmandSettings.CommonPreference<Boolean> hidePolygonsPref =
|
||||
mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
|
||||
hidePolygonsPref.set(hasUnderlayDescription);
|
||||
RasterMapMenu.refreshMapComplete(mapActivity);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
|
@ -526,24 +534,44 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
CommonPreference<String> mapTypePreference;
|
||||
CommonPreference<String> exMapTypePreference;
|
||||
OsmandSettings.CommonPreference<Integer> mapTransparencyPreference;
|
||||
ITileSource map;
|
||||
if (type == RasterMapType.OVERLAY) {
|
||||
mapTransparencyPreference = settings.MAP_OVERLAY_TRANSPARENCY;
|
||||
mapTypePreference = settings.MAP_OVERLAY;
|
||||
exMapTypePreference = settings.MAP_OVERLAY_PREVIOUS;
|
||||
map = overlayLayer.getMap();
|
||||
} else {
|
||||
// Underlay expected
|
||||
mapTransparencyPreference = settings.MAP_TRANSPARENCY;
|
||||
mapTypePreference = settings.MAP_UNDERLAY;
|
||||
exMapTypePreference = settings.MAP_UNDERLAY_PREVIOUS;
|
||||
map = underlayLayer.getMap();
|
||||
}
|
||||
|
||||
boolean isChecked = map == null;
|
||||
boolean showSeekbar = isChecked && RasterMapMenu.isSeekbarVisible(app, type);
|
||||
boolean hideSeekbar = !isChecked && RasterMapMenu.isSeekbarVisible(app, type);
|
||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
CommonPreference<LayerTransparencySeekbarMode> seekbarModePref = settings.LAYER_TRANSPARENCY_SEEKBAR_MODE;
|
||||
if (showSeekbar) {
|
||||
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
|
||||
mapLayers.getMapControlsLayer().setTransparencyBarEnabled(true);
|
||||
if (seekbarModePref.get() == LayerTransparencySeekbarMode.UNDEFINED) {
|
||||
final OsmandSettings.LayerTransparencySeekbarMode currentMapTypeSeekbarMode =
|
||||
type == OsmandRasterMapsPlugin.RasterMapType.OVERLAY ? OsmandSettings.LayerTransparencySeekbarMode.OVERLAY : OsmandSettings.LayerTransparencySeekbarMode.UNDERLAY;
|
||||
seekbarModePref.set(currentMapTypeSeekbarMode);
|
||||
}
|
||||
} else if (hideSeekbar) {
|
||||
mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference);
|
||||
mapLayers.getMapControlsLayer().setTransparencyBarEnabled(false);
|
||||
}
|
||||
|
||||
if (map != null) {
|
||||
mapTypePreference.set(null);
|
||||
if (callback != null) {
|
||||
callback.onMapSelected();
|
||||
}
|
||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
updateMapLayers(mapView, null, mapLayers);
|
||||
} else {
|
||||
selectMapOverlayLayer(mapView, mapTypePreference, exMapTypePreference, false, mapActivity, callback);
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
|
@ -68,7 +69,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
private SeekBar transparencyBar;
|
||||
private LinearLayout transparencyBarLayout;
|
||||
private static CommonPreference<Integer> settingsToTransparency;
|
||||
private static CommonPreference<Integer> transparencySetting;
|
||||
private boolean isTransparencyBarEnabled = true;
|
||||
private OsmandSettings settings;
|
||||
|
||||
|
@ -611,8 +612,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
transparencyBarLayout = (LinearLayout) mapActivity.findViewById(R.id.map_transparency_layout);
|
||||
transparencyBar = (SeekBar) mapActivity.findViewById(R.id.map_transparency_seekbar);
|
||||
transparencyBar.setMax(255);
|
||||
if (settingsToTransparency != null) {
|
||||
transparencyBar.setProgress(settingsToTransparency.get());
|
||||
if (transparencySetting != null) {
|
||||
transparencyBar.setProgress(transparencySetting.get());
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
|
@ -629,8 +630,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (settingsToTransparency != null) {
|
||||
settingsToTransparency.set(progress);
|
||||
if (transparencySetting != null) {
|
||||
transparencySetting.set(progress);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
}
|
||||
}
|
||||
|
@ -640,15 +641,24 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.set(false);
|
||||
hideTransparencyBar(settingsToTransparency);
|
||||
settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(LayerTransparencySeekbarMode.OFF);
|
||||
hideTransparencyBar(transparencySetting);
|
||||
}
|
||||
});
|
||||
|
||||
LayerTransparencySeekbarMode seekbarMode = settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get();
|
||||
if (seekbarMode == LayerTransparencySeekbarMode.OVERLAY && settings.MAP_OVERLAY.get() != null) {
|
||||
showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY);
|
||||
setTransparencyBarEnabled(true);
|
||||
} else if (seekbarMode == LayerTransparencySeekbarMode.UNDERLAY && settings.MAP_UNDERLAY.get() != null) {
|
||||
showTransparencyBar(settings.MAP_TRANSPARENCY);
|
||||
setTransparencyBarEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void showTransparencyBar(CommonPreference<Integer> transparenPreference) {
|
||||
if (MapControlsLayer.settingsToTransparency != transparenPreference) {
|
||||
MapControlsLayer.settingsToTransparency = transparenPreference;
|
||||
if (MapControlsLayer.transparencySetting != transparenPreference) {
|
||||
MapControlsLayer.transparencySetting = transparenPreference;
|
||||
if (isTransparencyBarEnabled) {
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -657,15 +667,15 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public void hideTransparencyBar(CommonPreference<Integer> transparentPreference) {
|
||||
if (settingsToTransparency == transparentPreference) {
|
||||
if (transparencySetting == transparentPreference) {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
settingsToTransparency = null;
|
||||
transparencySetting = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTransparencyBarEnabled(boolean isTransparencyBarEnabled) {
|
||||
this.isTransparencyBarEnabled = isTransparencyBarEnabled;
|
||||
if (settingsToTransparency != null) {
|
||||
if (transparencySetting != null) {
|
||||
if (isTransparencyBarEnabled) {
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -674,10 +684,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isTransparencyBarInitialized() {
|
||||
return settingsToTransparency != null;
|
||||
}
|
||||
|
||||
private class MapHudButton {
|
||||
View iv;
|
||||
int bgDark;
|
||||
|
|
|
@ -322,7 +322,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
return app.getResources().getString(R.string.shared_string_none);
|
||||
}
|
||||
PoiUIFilter filter = pfh.getFilterById(filterId);
|
||||
return filter.getName();
|
||||
if (filter == null) {
|
||||
return app.getResources().getString(R.string.shared_string_none);
|
||||
} else {
|
||||
return filter.getName();
|
||||
}
|
||||
}
|
||||
|
||||
static int getResIdFromAttribute(final Context ctx, final int attr) {
|
||||
|
|
Loading…
Reference in a new issue