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