pull request fixes
This commit is contained in:
parent
e1e5250470
commit
463a83ba22
11 changed files with 1365 additions and 1482 deletions
|
@ -157,23 +157,6 @@
|
||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpx" />
|
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpx" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<!--<intent-filter-->
|
|
||||||
<!--android:label="@string/app_name"-->
|
|
||||||
<!--android:priority="50">-->
|
|
||||||
<!--<action android:name="android.intent.action.VIEW" />-->
|
|
||||||
|
|
||||||
<!--<category android:name="android.intent.category.DEFAULT" />-->
|
|
||||||
<!--<category android:name="android.intent.category.BROWSABLE" />-->
|
|
||||||
<!--<data android:scheme="file"/>-->
|
|
||||||
<!--<data android:host="*"/>-->
|
|
||||||
<!--<data android:pathPattern="*.kml"/>-->
|
|
||||||
<!--<data android:pathPattern=".*\\.kml" />-->
|
|
||||||
<!--<data android:pathPattern=".*\\..*\\.kml" />-->
|
|
||||||
<!--<data android:pathPattern=".*\\..*\\..*\\.kml" />-->
|
|
||||||
<!--<data android:pathPattern=".*\\..*\\..*\\..*\\.kml" />-->
|
|
||||||
<!--<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.kml" />-->
|
|
||||||
<!--</intent-filter>-->
|
|
||||||
|
|
||||||
<intent-filter
|
<intent-filter
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:priority="50">
|
android:priority="50">
|
||||||
|
|
|
@ -99,8 +99,7 @@
|
||||||
android:id="@+id/drawer_relative_layout"
|
android:id="@+id/drawer_relative_layout"
|
||||||
android:layout_width="280dp"
|
android:layout_width="280dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start">
|
||||||
>
|
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/menuItems"
|
android:id="@+id/menuItems"
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
android:layout_height="@dimen/list_item_height">
|
android:layout_height="@dimen/list_item_height">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layoutDirection="locale"
|
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -14,7 +13,9 @@
|
||||||
android:drawablePadding="24dp"
|
android:drawablePadding="24dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight = "16dp"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
android:textStyle="normal"
|
android:textStyle="normal"
|
||||||
tools:drawableStart="@drawable/ic_action_search_dark"
|
tools:drawableStart="@drawable/ic_action_search_dark"
|
||||||
|
|
|
@ -1668,28 +1668,6 @@ public class OsmandAidlApi {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void registerForOsmandInitialization(final IOsmAndAidlCallback callback) throws RemoteException {
|
|
||||||
// if (app.isApplicationInitializing()) {
|
|
||||||
// app.getAppInitializer().addListener(new AppInitializeListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onProgress(AppInitializer init, InitEvents event) {}
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFinish(AppInitializer init) {
|
|
||||||
// LOG.debug("App init finished callback");
|
|
||||||
// try{
|
|
||||||
// callback.onAppInitialized();
|
|
||||||
// } catch(Exception e){
|
|
||||||
// e.printStackTrace();
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// callback.onAppInitialized();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
boolean setNavDrawerItems(String appPackage, List<net.osmand.aidl.navdrawer.NavDrawerItem> items) {
|
boolean setNavDrawerItems(String appPackage, List<net.osmand.aidl.navdrawer.NavDrawerItem> items) {
|
||||||
if (!TextUtils.isEmpty(appPackage) && items != null) {
|
if (!TextUtils.isEmpty(appPackage) && items != null) {
|
||||||
if (items.isEmpty()) {
|
if (items.isEmpty()) {
|
||||||
|
@ -1911,7 +1889,7 @@ public class OsmandAidlApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean setNavDrawerLogoWithParams(
|
boolean setNavDrawerLogoWithParams(
|
||||||
@Nullable String uri, @Nullable String packageName, @Nullable String intent) {
|
@NonNull String uri, @Nullable String packageName, @Nullable String intent) {
|
||||||
return app.getAppCustomization().setNavDrawerLogoWithParams(uri, packageName, intent);
|
return app.getAppCustomization().setNavDrawerLogoWithParams(uri, packageName, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,62 +7,62 @@ import android.support.annotation.Nullable;
|
||||||
|
|
||||||
public class NavDrawerFooterParams implements Parcelable {
|
public class NavDrawerFooterParams implements Parcelable {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private String packageName;
|
private String packageName;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String intent;
|
private String intent;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String appName;
|
private String appName;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getPackageName() {
|
public String getPackageName() {
|
||||||
return packageName;
|
return packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getIntent() {
|
public String getIntent() {
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getAppName() {
|
public String getAppName() {
|
||||||
return appName;
|
return appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavDrawerFooterParams(@NonNull String packageName, @Nullable String intent,
|
public NavDrawerFooterParams(@NonNull String packageName, @Nullable String intent,
|
||||||
@Nullable String appName) {
|
@Nullable String appName) {
|
||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
this.intent = intent;
|
this.intent = intent;
|
||||||
this.appName = appName;
|
this.appName = appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NavDrawerFooterParams(Parcel in) {
|
protected NavDrawerFooterParams(Parcel in) {
|
||||||
packageName = in.readString();
|
packageName = in.readString();
|
||||||
intent = in.readString();
|
intent = in.readString();
|
||||||
appName = in.readString();
|
appName = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(packageName);
|
dest.writeString(packageName);
|
||||||
dest.writeString(intent);
|
dest.writeString(intent);
|
||||||
dest.writeString(appName);
|
dest.writeString(appName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<NavDrawerFooterParams> CREATOR = new Creator<NavDrawerFooterParams>() {
|
public static final Creator<NavDrawerFooterParams> CREATOR = new Creator<NavDrawerFooterParams>() {
|
||||||
@Override
|
@Override
|
||||||
public NavDrawerFooterParams createFromParcel(Parcel in) {
|
public NavDrawerFooterParams createFromParcel(Parcel in) {
|
||||||
return new NavDrawerFooterParams(in);
|
return new NavDrawerFooterParams(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NavDrawerFooterParams[] newArray(int size) {
|
public NavDrawerFooterParams[] newArray(int size) {
|
||||||
return new NavDrawerFooterParams[size];
|
return new NavDrawerFooterParams[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,62 +7,62 @@ import android.support.annotation.Nullable;
|
||||||
|
|
||||||
public class NavDrawerHeaderParams implements Parcelable {
|
public class NavDrawerHeaderParams implements Parcelable {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private String imageUri;
|
private String imageUri;
|
||||||
@NonNull
|
@NonNull
|
||||||
private String packageName;
|
private String packageName;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String intent;
|
private String intent;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getImageUri() {
|
public String getImageUri() {
|
||||||
return imageUri;
|
return imageUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getPackageName() {
|
public String getPackageName() {
|
||||||
return packageName;
|
return packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getIntent() {
|
public String getIntent() {
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavDrawerHeaderParams(@NonNull String imageUri, @NonNull String packageName,
|
public NavDrawerHeaderParams(@NonNull String imageUri, @NonNull String packageName,
|
||||||
@Nullable String intent) {
|
@Nullable String intent) {
|
||||||
this.imageUri = imageUri;
|
this.imageUri = imageUri;
|
||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
this.intent = intent;
|
this.intent = intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavDrawerHeaderParams(Parcel in) {
|
public NavDrawerHeaderParams(Parcel in) {
|
||||||
imageUri = in.readString();
|
imageUri = in.readString();
|
||||||
packageName = in.readString();
|
packageName = in.readString();
|
||||||
intent = in.readString();
|
intent = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(imageUri);
|
dest.writeString(imageUri);
|
||||||
dest.writeString(packageName);
|
dest.writeString(packageName);
|
||||||
dest.writeString(intent);
|
dest.writeString(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<NavDrawerHeaderParams> CREATOR = new Creator<NavDrawerHeaderParams>() {
|
public static final Creator<NavDrawerHeaderParams> CREATOR = new Creator<NavDrawerHeaderParams>() {
|
||||||
@Override
|
@Override
|
||||||
public NavDrawerHeaderParams createFromParcel(Parcel in) {
|
public NavDrawerHeaderParams createFromParcel(Parcel in) {
|
||||||
return new NavDrawerHeaderParams(in);
|
return new NavDrawerHeaderParams(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NavDrawerHeaderParams[] newArray(int size) {
|
public NavDrawerHeaderParams[] newArray(int size) {
|
||||||
return new NavDrawerHeaderParams[size];
|
return new NavDrawerHeaderParams[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,47 +5,47 @@ import android.os.Parcelable;
|
||||||
|
|
||||||
public class PluginParams implements Parcelable {
|
public class PluginParams implements Parcelable {
|
||||||
|
|
||||||
private String pluginId;
|
private String pluginId;
|
||||||
private int newState; //0- off, 1 - on
|
private int newState; //0- off, 1 - on
|
||||||
|
|
||||||
public PluginParams(String pluginId, int newState) {
|
public PluginParams(String pluginId, int newState) {
|
||||||
this.pluginId = pluginId;
|
this.pluginId = pluginId;
|
||||||
this.newState = newState;
|
this.newState = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPluginId() {
|
public String getPluginId() {
|
||||||
return pluginId;
|
return pluginId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNewState() {
|
public int getNewState() {
|
||||||
return newState;
|
return newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PluginParams(Parcel in) {
|
protected PluginParams(Parcel in) {
|
||||||
pluginId = in.readString();
|
pluginId = in.readString();
|
||||||
newState = in.readInt();
|
newState = in.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(pluginId);
|
dest.writeString(pluginId);
|
||||||
dest.writeInt(newState);
|
dest.writeInt(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<PluginParams> CREATOR = new Creator<PluginParams>() {
|
public static final Creator<PluginParams> CREATOR = new Creator<PluginParams>() {
|
||||||
@Override
|
@Override
|
||||||
public PluginParams createFromParcel(Parcel in) {
|
public PluginParams createFromParcel(Parcel in) {
|
||||||
return new PluginParams(in);
|
return new PluginParams(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginParams[] newArray(int size) {
|
public PluginParams[] newArray(int size) {
|
||||||
return new PluginParams[size];
|
return new PluginParams[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,378 +43,375 @@ import java.util.Set;
|
||||||
|
|
||||||
public class OsmAndAppCustomization {
|
public class OsmAndAppCustomization {
|
||||||
|
|
||||||
protected OsmandApplication app;
|
protected OsmandApplication app;
|
||||||
protected OsmandSettings osmandSettings;
|
protected OsmandSettings osmandSettings;
|
||||||
|
|
||||||
private Bitmap navDrawerLogo;
|
private Bitmap navDrawerLogo;
|
||||||
private ArrayList<String> navDrawerParams;
|
private ArrayList<String> navDrawerParams;
|
||||||
private NavDrawerFooterParams navDrawerFooterParams;
|
private NavDrawerFooterParams navDrawerFooterParams;
|
||||||
|
|
||||||
private Set<String> featuresEnabledIds = new HashSet<>();
|
private Set<String> featuresEnabledIds = new HashSet<>();
|
||||||
private Set<String> featuresDisabledIds = new HashSet<>();
|
private Set<String> featuresDisabledIds = new HashSet<>();
|
||||||
private Set<String> featuresEnabledPatterns = new HashSet<>();
|
private Set<String> featuresEnabledPatterns = new HashSet<>();
|
||||||
private Set<String> featuresDisabledPatterns = new HashSet<>();
|
private Set<String> featuresDisabledPatterns = new HashSet<>();
|
||||||
private Map<String, Set<ApplicationMode>> widgetsVisibilityMap = new LinkedHashMap<>();
|
private Map<String, Set<ApplicationMode>> widgetsVisibilityMap = new LinkedHashMap<>();
|
||||||
private Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
|
private Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
|
||||||
private CustomOsmandSettings customOsmandSettings;
|
private CustomOsmandSettings customOsmandSettings;
|
||||||
|
|
||||||
private boolean featuresCustomized;
|
private boolean featuresCustomized;
|
||||||
private boolean widgetsCustomized;
|
private boolean widgetsCustomized;
|
||||||
|
|
||||||
private List<OsmAndAppCustomizationListener> listeners = new ArrayList<>();
|
private List<OsmAndAppCustomizationListener> listeners = new ArrayList<>();
|
||||||
|
|
||||||
public interface OsmAndAppCustomizationListener {
|
public interface OsmAndAppCustomizationListener {
|
||||||
|
|
||||||
void onOsmAndSettingsCustomized();
|
void onOsmAndSettingsCustomized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CustomOsmandSettings {
|
public static class CustomOsmandSettings {
|
||||||
|
|
||||||
private String sharedPreferencesName;
|
private String sharedPreferencesName;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
|
||||||
CustomOsmandSettings(OsmandApplication app, String sharedPreferencesName, Bundle bundle) {
|
CustomOsmandSettings(OsmandApplication app, String sharedPreferencesName, Bundle bundle) {
|
||||||
this.sharedPreferencesName = sharedPreferencesName;
|
this.sharedPreferencesName = sharedPreferencesName;
|
||||||
this.settings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app),
|
this.settings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app),
|
||||||
sharedPreferencesName);
|
sharedPreferencesName);
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
for (String key : bundle.keySet()) {
|
for (String key : bundle.keySet()) {
|
||||||
Object object = bundle.get(key);
|
Object object = bundle.get(key);
|
||||||
this.settings.setPreference(key, object);
|
this.settings.setPreference(key, object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandSettings getSettings() {
|
public OsmandSettings getSettings() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setup(OsmandApplication app) {
|
public void setup(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app));
|
this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app));
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandSettings getOsmandSettings() {
|
public OsmandSettings getOsmandSettings() {
|
||||||
return customOsmandSettings != null ? customOsmandSettings.getSettings() : osmandSettings;
|
return customOsmandSettings != null ? customOsmandSettings.getSettings() : osmandSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void customizeOsmandSettings(@NonNull String sharedPreferencesName,
|
public void customizeOsmandSettings(@NonNull String sharedPreferencesName,
|
||||||
@Nullable Bundle bundle) {
|
@Nullable Bundle bundle) {
|
||||||
customOsmandSettings = new CustomOsmandSettings(app, sharedPreferencesName, bundle);
|
customOsmandSettings = new CustomOsmandSettings(app, sharedPreferencesName, bundle);
|
||||||
OsmandSettings newSettings = customOsmandSettings.getSettings();
|
OsmandSettings newSettings = customOsmandSettings.getSettings();
|
||||||
if (Build.VERSION.SDK_INT < 19) {
|
if (Build.VERSION.SDK_INT < 19) {
|
||||||
if (osmandSettings.isExternalStorageDirectorySpecifiedPre19()) {
|
if (osmandSettings.isExternalStorageDirectorySpecifiedPre19()) {
|
||||||
File externalStorageDirectory = osmandSettings.getExternalStorageDirectoryPre19();
|
File externalStorageDirectory = osmandSettings.getExternalStorageDirectoryPre19();
|
||||||
newSettings.setExternalStorageDirectoryPre19(externalStorageDirectory.getAbsolutePath());
|
newSettings.setExternalStorageDirectoryPre19(externalStorageDirectory.getAbsolutePath());
|
||||||
}
|
}
|
||||||
} else if (osmandSettings.isExternalStorageDirectoryTypeSpecifiedV19()
|
} else if (osmandSettings.isExternalStorageDirectoryTypeSpecifiedV19()
|
||||||
&& osmandSettings.isExternalStorageDirectorySpecifiedV19()) {
|
&& osmandSettings.isExternalStorageDirectorySpecifiedV19()) {
|
||||||
int type = osmandSettings.getExternalStorageDirectoryTypeV19();
|
int type = osmandSettings.getExternalStorageDirectoryTypeV19();
|
||||||
String directory = osmandSettings.getExternalStorageDirectoryV19();
|
String directory = osmandSettings.getExternalStorageDirectoryV19();
|
||||||
newSettings.setExternalStorageDirectoryV19(type, directory);
|
newSettings.setExternalStorageDirectoryV19(type, directory);
|
||||||
}
|
}
|
||||||
app.setOsmandSettings(newSettings);
|
app.setOsmandSettings(newSettings);
|
||||||
notifySettingsCustomized();
|
notifySettingsCustomized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreOsmandSettings() {
|
public void restoreOsmandSettings() {
|
||||||
app.setOsmandSettings(osmandSettings);
|
app.setOsmandSettings(osmandSettings);
|
||||||
notifySettingsCustomized();
|
notifySettingsCustomized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean restoreOsmand() {
|
public boolean restoreOsmand() {
|
||||||
navDrawerLogo = null;
|
navDrawerLogo = null;
|
||||||
featuresCustomized = false;
|
featuresCustomized = false;
|
||||||
widgetsCustomized = false;
|
widgetsCustomized = false;
|
||||||
customOsmandSettings = null;
|
customOsmandSettings = null;
|
||||||
restoreOsmandSettings();
|
restoreOsmandSettings();
|
||||||
|
|
||||||
featuresEnabledIds.clear();
|
featuresEnabledIds.clear();
|
||||||
featuresDisabledIds.clear();
|
featuresDisabledIds.clear();
|
||||||
featuresEnabledPatterns.clear();
|
featuresEnabledPatterns.clear();
|
||||||
featuresDisabledPatterns.clear();
|
featuresDisabledPatterns.clear();
|
||||||
widgetsVisibilityMap.clear();
|
widgetsVisibilityMap.clear();
|
||||||
widgetsAvailabilityMap.clear();
|
widgetsAvailabilityMap.clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activities
|
// Activities
|
||||||
public Class<? extends Activity> getSettingsActivity() {
|
public Class<? extends Activity> getSettingsActivity() {
|
||||||
return SettingsActivity.class;
|
return SettingsActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<MapActivity> getMapActivity() {
|
public Class<MapActivity> getMapActivity() {
|
||||||
return MapActivity.class;
|
return MapActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<TrackActivity> getTrackActivity() {
|
public Class<TrackActivity> getTrackActivity() {
|
||||||
return TrackActivity.class;
|
return TrackActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<FavoritesActivity> getFavoritesActivity() {
|
public Class<FavoritesActivity> getFavoritesActivity() {
|
||||||
return FavoritesActivity.class;
|
return FavoritesActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends Activity> getDownloadIndexActivity() {
|
public Class<? extends Activity> getDownloadIndexActivity() {
|
||||||
return DownloadActivity.class;
|
return DownloadActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends Activity> getPluginsActivity() {
|
public Class<? extends Activity> getPluginsActivity() {
|
||||||
return PluginsActivity.class;
|
return PluginsActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends Activity> getDownloadActivity() {
|
public Class<? extends Activity> getDownloadActivity() {
|
||||||
return DownloadActivity.class;
|
return DownloadActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> onIndexingFiles(IProgress progress, Map<String, String> indexFileNames) {
|
public List<String> onIndexingFiles(IProgress progress, Map<String, String> indexFileNames) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexesUrl() {
|
public String getIndexesUrl() {
|
||||||
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/get_indexes?gzip&" + Version
|
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/get_indexes?gzip&" + Version
|
||||||
.getVersionAsURLParam(app);
|
.getVersionAsURLParam(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showDownloadExtraActions() {
|
public boolean showDownloadExtraActions() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getTracksDir() {
|
public File getTracksDir() {
|
||||||
return app.getAppPath(IndexConstants.GPX_RECORDED_INDEX_DIR);
|
return app.getAppPath(IndexConstants.GPX_RECORDED_INDEX_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createLayers(OsmandMapTileView mapView, MapActivity activity) {
|
public void createLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<? extends LocationPoint> getWaypoints() {
|
public List<? extends LocationPoint> getWaypoints() {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) {
|
public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) {
|
||||||
if (waypointType == WaypointHelper.ALARMS) {
|
if (waypointType == WaypointHelper.ALARMS) {
|
||||||
return route != null && !route.getAlarmInfo().isEmpty();
|
return route != null && !route.getAlarmInfo().isEmpty();
|
||||||
} else if (waypointType == WaypointHelper.WAYPOINTS) {
|
} else if (waypointType == WaypointHelper.WAYPOINTS) {
|
||||||
return route != null && !route.getLocationPoints().isEmpty();
|
return route != null && !route.getLocationPoints().isEmpty();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onDestinationReached() {
|
public boolean onDestinationReached() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Bitmap getNavDrawerLogo() {
|
public Bitmap getNavDrawerLogo() {
|
||||||
return navDrawerLogo;
|
return navDrawerLogo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ArrayList<String> getNavDrawerLogoParams() {
|
public ArrayList<String> getNavDrawerLogoParams() {
|
||||||
return navDrawerParams;
|
return navDrawerParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setNavDrawerLogo(@Nullable String uri, @Nullable String packageName,
|
public boolean setNavDrawerLogo(@NonNull String uri, @Nullable String packageName,
|
||||||
@Nullable String intent) {
|
@Nullable String intent) {
|
||||||
if (TextUtils.isEmpty(uri)) {
|
if (TextUtils.isEmpty(uri)) {
|
||||||
navDrawerLogo = null;
|
navDrawerLogo = null;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
InputStream is = app.getContentResolver().openInputStream(Uri.parse(uri));
|
InputStream is = app.getContentResolver().openInputStream(Uri.parse(uri));
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
navDrawerLogo = BitmapFactory.decodeStream(is);
|
navDrawerLogo = BitmapFactory.decodeStream(is);
|
||||||
is.close();
|
is.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return false;
|
return false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
if (packageName != null && intent != null) {
|
if (packageName != null && intent != null) {
|
||||||
navDrawerParams = new ArrayList<>();
|
navDrawerParams = new ArrayList<>();
|
||||||
navDrawerParams.add(packageName);
|
navDrawerParams.add(packageName);
|
||||||
navDrawerParams.add(intent);
|
navDrawerParams.add(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setNavDrawerFooterParams(NavDrawerFooterParams params){
|
public boolean setNavDrawerFooterParams(NavDrawerFooterParams params) {
|
||||||
navDrawerFooterParams = params;
|
navDrawerFooterParams = params;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavDrawerFooterParams getNavFooterParams(){
|
public NavDrawerFooterParams getNavFooterParams() {
|
||||||
return navDrawerFooterParams;
|
return navDrawerFooterParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeaturesEnabledIds(@NonNull Collection<String> ids) {
|
public void setFeaturesEnabledIds(@NonNull Collection<String> ids) {
|
||||||
featuresEnabledIds.clear();
|
featuresEnabledIds.clear();
|
||||||
featuresEnabledIds.addAll(ids);
|
featuresEnabledIds.addAll(ids);
|
||||||
setFeaturesCustomized();
|
setFeaturesCustomized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeaturesDisabledIds(@NonNull Collection<String> ids) {
|
public void setFeaturesDisabledIds(@NonNull Collection<String> ids) {
|
||||||
featuresDisabledIds.clear();
|
featuresDisabledIds.clear();
|
||||||
featuresDisabledIds.addAll(ids);
|
featuresDisabledIds.addAll(ids);
|
||||||
setFeaturesCustomized();
|
setFeaturesCustomized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeaturesEnabledPatterns(@NonNull Collection<String> patterns) {
|
public void setFeaturesEnabledPatterns(@NonNull Collection<String> patterns) {
|
||||||
featuresEnabledPatterns.clear();
|
featuresEnabledPatterns.clear();
|
||||||
featuresEnabledPatterns.addAll(patterns);
|
featuresEnabledPatterns.addAll(patterns);
|
||||||
setFeaturesCustomized();
|
setFeaturesCustomized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeaturesDisabledPatterns(@NonNull Collection<String> patterns) {
|
public void setFeaturesDisabledPatterns(@NonNull Collection<String> patterns) {
|
||||||
featuresDisabledPatterns.clear();
|
featuresDisabledPatterns.clear();
|
||||||
featuresDisabledPatterns.addAll(patterns);
|
featuresDisabledPatterns.addAll(patterns);
|
||||||
setFeaturesCustomized();
|
setFeaturesCustomized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<ApplicationMode> regWidgetVisibility(@NonNull String widgetId,
|
public Set<ApplicationMode> regWidgetVisibility(@NonNull String widgetId,
|
||||||
@Nullable List<String> appModeKeys) {
|
@Nullable List<String> appModeKeys) {
|
||||||
HashSet<ApplicationMode> set = getAppModesSet(appModeKeys);
|
HashSet<ApplicationMode> set = getAppModesSet(appModeKeys);
|
||||||
widgetsVisibilityMap.put(widgetId, set);
|
widgetsVisibilityMap.put(widgetId, set);
|
||||||
setWidgetsCustomized();
|
setWidgetsCustomized();
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<ApplicationMode> regWidgetAvailability(@NonNull String widgetId,
|
public Set<ApplicationMode> regWidgetAvailability(@NonNull String widgetId,
|
||||||
@Nullable List<String> appModeKeys) {
|
@Nullable List<String> appModeKeys) {
|
||||||
HashSet<ApplicationMode> set = getAppModesSet(appModeKeys);
|
HashSet<ApplicationMode> set = getAppModesSet(appModeKeys);
|
||||||
widgetsAvailabilityMap.put(widgetId, set);
|
widgetsAvailabilityMap.put(widgetId, set);
|
||||||
setWidgetsCustomized();
|
setWidgetsCustomized();
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWidgetVisible(@NonNull String key, ApplicationMode appMode) {
|
public boolean isWidgetVisible(@NonNull String key, ApplicationMode appMode) {
|
||||||
Set<ApplicationMode> set = widgetsVisibilityMap.get(key);
|
Set<ApplicationMode> set = widgetsVisibilityMap.get(key);
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return set.contains(appMode);
|
return set.contains(appMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWidgetAvailable(@NonNull String key, ApplicationMode appMode) {
|
public boolean isWidgetAvailable(@NonNull String key, ApplicationMode appMode) {
|
||||||
Set<ApplicationMode> set = widgetsAvailabilityMap.get(key);
|
Set<ApplicationMode> set = widgetsAvailabilityMap.get(key);
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return set.contains(appMode);
|
return set.contains(appMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setNavDrawerLogoWithParams(String uri, @Nullable String packageName,
|
public boolean setNavDrawerLogoWithParams(@NonNull String imageUri, @Nullable String packageName,
|
||||||
@Nullable String intent) {
|
@Nullable String intent) {
|
||||||
return setNavDrawerLogo(uri, packageName, intent);
|
return setNavDrawerLogo(imageUri, packageName, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setNavDrawerFooterAction(String packageName, String intent, String appName) {
|
public boolean changePluginStatus(PluginParams params) {
|
||||||
//todo implement custom action to "Powered by Osmand" action in NavDrawer
|
if (params.getNewState() == 0) {
|
||||||
return true;
|
for (OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) {
|
||||||
}
|
if (plugin.getId().equals(params.getPluginId())) {
|
||||||
|
plugin.setActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean changePluginStatus(PluginParams params) {
|
if (params.getNewState() == 1) {
|
||||||
if (params.getNewState() == 0) {
|
for (OsmandPlugin plugin : OsmandPlugin.getAvailablePlugins()) {
|
||||||
for (OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) {
|
if (plugin.getId().equals(params.getPluginId())) {
|
||||||
if(plugin.getId().equals(params.getPluginId())) plugin.setActive(false);
|
plugin.setActive(true);
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (params.getNewState() == 1) {
|
return false;
|
||||||
for (OsmandPlugin plugin : OsmandPlugin.getAvailablePlugins()) {
|
}
|
||||||
if (plugin.getId().equals(params.getPluginId())) {
|
|
||||||
plugin.setActive(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
@NonNull
|
||||||
}
|
private HashSet<ApplicationMode> getAppModesSet(@Nullable List<String> appModeKeys) {
|
||||||
|
HashSet<ApplicationMode> set = new HashSet<>();
|
||||||
|
List<ApplicationMode> values = ApplicationMode.allPossibleValues();
|
||||||
|
if (appModeKeys == null) {
|
||||||
|
set.addAll(values);
|
||||||
|
} else {
|
||||||
|
for (String key : appModeKeys) {
|
||||||
|
ApplicationMode am = ApplicationMode.valueOfStringKey(key, null);
|
||||||
|
if (am != null) {
|
||||||
|
set.add(am);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ApplicationMode m : values) {
|
||||||
|
// add derived modes
|
||||||
|
if (set.contains(m.getParent())) {
|
||||||
|
set.add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
public boolean isFeatureEnabled(@NonNull String id) {
|
||||||
private HashSet<ApplicationMode> getAppModesSet(@Nullable List<String> appModeKeys) {
|
if (!featuresCustomized) {
|
||||||
HashSet<ApplicationMode> set = new HashSet<>();
|
return true;
|
||||||
List<ApplicationMode> values = ApplicationMode.allPossibleValues();
|
}
|
||||||
if (appModeKeys == null) {
|
if (featuresEnabledIds.contains(id)) {
|
||||||
set.addAll(values);
|
return true;
|
||||||
} else {
|
}
|
||||||
for (String key : appModeKeys) {
|
if (featuresDisabledIds.contains(id)) {
|
||||||
ApplicationMode am = ApplicationMode.valueOfStringKey(key, null);
|
return false;
|
||||||
if (am != null) {
|
}
|
||||||
set.add(am);
|
if (isMatchesPattern(id, featuresEnabledPatterns)) {
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
return !isMatchesPattern(id, featuresDisabledPatterns);
|
||||||
for (ApplicationMode m : values) {
|
}
|
||||||
// add derived modes
|
|
||||||
if (set.contains(m.getParent())) {
|
|
||||||
set.add(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFeatureEnabled(@NonNull String id) {
|
public boolean areWidgetsCustomized() {
|
||||||
if (!featuresCustomized) {
|
return widgetsCustomized;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
if (featuresEnabledIds.contains(id)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (featuresDisabledIds.contains(id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (isMatchesPattern(id, featuresEnabledPatterns)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return !isMatchesPattern(id, featuresDisabledPatterns);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areWidgetsCustomized() {
|
private void setFeaturesCustomized() {
|
||||||
return widgetsCustomized;
|
featuresCustomized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFeaturesCustomized() {
|
private void setWidgetsCustomized() {
|
||||||
featuresCustomized = true;
|
widgetsCustomized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWidgetsCustomized() {
|
private boolean isMatchesPattern(@NonNull String id, @NonNull Set<String> patterns) {
|
||||||
widgetsCustomized = true;
|
for (String pattern : patterns) {
|
||||||
}
|
if (id.startsWith(pattern)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isMatchesPattern(@NonNull String id, @NonNull Set<String> patterns) {
|
private void notifySettingsCustomized() {
|
||||||
for (String pattern : patterns) {
|
app.uiHandler.post(new Runnable() {
|
||||||
if (id.startsWith(pattern)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifySettingsCustomized() {
|
@Override
|
||||||
app.uiHandler.post(new Runnable() {
|
public void run() {
|
||||||
|
for (OsmAndAppCustomizationListener l : listeners) {
|
||||||
|
l.onOsmAndSettingsCustomized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public void addListener(OsmAndAppCustomizationListener listener) {
|
||||||
public void run() {
|
this.listeners.add(listener);
|
||||||
for (OsmAndAppCustomizationListener l : listeners) {
|
}
|
||||||
l.onOsmAndSettingsCustomized();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addListener(OsmAndAppCustomizationListener listener) {
|
public void removeListener(OsmAndAppCustomizationListener listener) {
|
||||||
this.listeners.add(listener);
|
this.listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener(OsmAndAppCustomizationListener listener) {
|
|
||||||
this.listeners.remove(listener);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.actions.OsmAndDialogs;
|
import net.osmand.plus.activities.actions.OsmAndDialogs;
|
||||||
import net.osmand.plus.activities.actions.OsmandRestoreOrExitDialog;
|
import net.osmand.plus.activities.actions.OsmandRestoreOrExitDialog;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||||
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
|
|
||||||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
import net.osmand.plus.liveupdates.OsmLiveActivity;
|
import net.osmand.plus.liveupdates.OsmLiveActivity;
|
||||||
|
@ -103,15 +102,15 @@ import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MEAS
|
||||||
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_SEARCH_NEARBY;
|
import static net.osmand.plus.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_SEARCH_NEARBY;
|
||||||
import static net.osmand.plus.helpers.ImportHelper.GPX_SUFFIX;
|
import static net.osmand.plus.helpers.ImportHelper.GPX_SUFFIX;
|
||||||
|
|
||||||
public class MapActivityActions implements DialogProvider {
|
|
||||||
|
|
||||||
|
public class MapActivityActions implements DialogProvider {
|
||||||
private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class);
|
private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class);
|
||||||
public static final String KEY_LONGITUDE = "longitude";
|
public static final String KEY_LONGITUDE = "longitude";
|
||||||
public static final String KEY_LATITUDE = "latitude";
|
public static final String KEY_LATITUDE = "latitude";
|
||||||
public static final String KEY_NAME = "name";
|
public static final String KEY_NAME = "name";
|
||||||
|
|
||||||
public static final String KEY_ZOOM = "zoom";
|
public static final String KEY_ZOOM = "zoom";
|
||||||
|
|
||||||
public static final int REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION = 203;
|
public static final int REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION = 203;
|
||||||
|
|
||||||
// Constants for determining the order of items in the additional actions context menu
|
// Constants for determining the order of items in the additional actions context menu
|
||||||
|
@ -145,24 +144,20 @@ public class MapActivityActions implements DialogProvider {
|
||||||
settings = mapActivity.getMyApplication().getSettings();
|
settings = mapActivity.getMyApplication().getSettings();
|
||||||
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
||||||
drawerLogoHeader = new ImageView(mapActivity);
|
drawerLogoHeader = new ImageView(mapActivity);
|
||||||
drawerLogoHeader
|
drawerLogoHeader.setPadding(-AndroidUtils.dpToPx(mapActivity, 8f), AndroidUtils.dpToPx(mapActivity, 16f), 0,
|
||||||
.setPadding(-AndroidUtils.dpToPx(mapActivity, 8f), AndroidUtils.dpToPx(mapActivity, 16f), 0,
|
|
||||||
0);
|
0);
|
||||||
drawerOsmAndFooter = mapActivity.getLayoutInflater()
|
drawerOsmAndFooter = mapActivity.getLayoutInflater().inflate(R.layout.powered_by_osmand_item, null);
|
||||||
.inflate(R.layout.powered_by_osmand_item, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAsTarget(double latitude, double longitude, PointDescription pd) {
|
public void addAsTarget(double latitude, double longitude, PointDescription pd) {
|
||||||
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
|
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
|
||||||
targets.navigateToPoint(new LatLon(latitude, longitude), true,
|
targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1,
|
||||||
targets.getIntermediatePoints().size() + 1,
|
|
||||||
pd);
|
pd);
|
||||||
openIntermediatePointsDialog();
|
openIntermediatePointsDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addMapMarker(double latitude, double longitude, PointDescription pd,
|
public void addMapMarker(double latitude, double longitude, PointDescription pd, @Nullable String mapObjectName) {
|
||||||
@Nullable String mapObjectName) {
|
|
||||||
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
||||||
markersHelper.addMapMarker(new LatLon(latitude, longitude), pd, mapObjectName);
|
markersHelper.addMapMarker(new LatLon(latitude, longitude), pd, mapObjectName);
|
||||||
}
|
}
|
||||||
|
@ -199,11 +194,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
double longitude = args.getDouble(KEY_LONGITUDE);
|
double longitude = args.getDouble(KEY_LONGITUDE);
|
||||||
String name = editText.getText().toString();
|
String name = editText.getText().toString();
|
||||||
SavingTrackHelper savingTrackHelper = mapActivity.getMyApplication().getSavingTrackHelper();
|
SavingTrackHelper savingTrackHelper = mapActivity.getMyApplication().getSavingTrackHelper();
|
||||||
savingTrackHelper
|
savingTrackHelper.insertPointData(latitude, longitude, System.currentTimeMillis(), null, name, null, 0);
|
||||||
.insertPointData(latitude, longitude, System.currentTimeMillis(), null, name, null, 0);
|
Toast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
|
||||||
Toast.makeText(mapActivity,
|
|
||||||
MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name),
|
|
||||||
Toast.LENGTH_SHORT)
|
|
||||||
.show();
|
.show();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
@ -213,8 +205,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if (hasFocus) {
|
if (hasFocus) {
|
||||||
alertDialog.getWindow()
|
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||||
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -285,8 +276,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
dlg.findViewById(R.id.DuplicateFileName).setVisibility(View.VISIBLE);
|
dlg.findViewById(R.id.DuplicateFileName).setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
dlg.dismiss();
|
dlg.dismiss();
|
||||||
new SaveDirectionsAsyncTask(app)
|
new SaveDirectionsAsyncTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, toSave);
|
||||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, toSave);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -298,6 +288,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return dlg;
|
return dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,8 +305,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
if (params.length > 0) {
|
if (params.length > 0) {
|
||||||
File file = params[0];
|
File file = params[0];
|
||||||
String fileName = file.getName();
|
String fileName = file.getName();
|
||||||
GPXFile gpx = app.getRoutingHelper().generateGPXFileWithRoute(
|
GPXFile gpx = app.getRoutingHelper().generateGPXFileWithRoute(fileName.substring(0,fileName.length()-GPX_SUFFIX.length()));
|
||||||
fileName.substring(0, fileName.length() - GPX_SUFFIX.length()));
|
|
||||||
GPXUtilities.writeGpxFile(file, gpx, app);
|
GPXUtilities.writeGpxFile(file, gpx, app);
|
||||||
return app.getString(R.string.route_successfully_saved_at, file.getName());
|
return app.getString(R.string.route_successfully_saved_at, file.getName());
|
||||||
}
|
}
|
||||||
|
@ -331,8 +321,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void contextMenuPoint(final double latitude, final double longitude,
|
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
|
||||||
final ContextMenuAdapter iadapter, Object selectedObj) {
|
|
||||||
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter() : iadapter;
|
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter() : iadapter;
|
||||||
ItemBuilder itemBuilder = new ItemBuilder();
|
ItemBuilder itemBuilder = new ItemBuilder();
|
||||||
|
|
||||||
|
@ -351,10 +340,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
|
|
||||||
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
|
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
|
||||||
|
|
||||||
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
|
ItemClickListener listener = new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int resId, int pos,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
boolean isChecked, int[] viewCoordinates) {
|
|
||||||
if (resId == R.string.context_menu_item_add_waypoint) {
|
if (resId == R.string.context_menu_item_add_waypoint) {
|
||||||
mapActivity.getContextMenu().addWptPt();
|
mapActivity.getContextMenu().addWptPt();
|
||||||
} else if (resId == R.string.context_menu_item_edit_waypoint) {
|
} else if (resId == R.string.context_menu_item_edit_waypoint) {
|
||||||
|
@ -365,9 +353,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (selectedObj instanceof WptPt
|
if (selectedObj instanceof WptPt
|
||||||
&& getMyApplication().getSelectedGpxHelper().getSelectedGPXFile((WptPt) selectedObj)
|
&& getMyApplication().getSelectedGpxHelper().getSelectedGPXFile((WptPt) selectedObj) != null) {
|
||||||
!= null) {
|
adapter.addItem(new ItemBuilder()
|
||||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
|
||||||
.setTitleId(R.string.context_menu_item_edit_waypoint, mapActivity)
|
.setTitleId(R.string.context_menu_item_edit_waypoint, mapActivity)
|
||||||
.setId(MAP_CONTEXT_MENU_EDIT_GPX_WP)
|
.setId(MAP_CONTEXT_MENU_EDIT_GPX_WP)
|
||||||
.setIcon(R.drawable.ic_action_edit_dark)
|
.setIcon(R.drawable.ic_action_edit_dark)
|
||||||
|
@ -375,7 +362,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
.setListener(listener).createItem());
|
.setListener(listener).createItem());
|
||||||
} else if (!getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles().isEmpty()
|
} else if (!getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles().isEmpty()
|
||||||
|| (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null)) {
|
|| (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null)) {
|
||||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
adapter.addItem(new ItemBuilder()
|
||||||
.setTitleId(R.string.context_menu_item_add_waypoint, mapActivity)
|
.setTitleId(R.string.context_menu_item_add_waypoint, mapActivity)
|
||||||
.setId(MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT)
|
.setId(MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT)
|
||||||
.setIcon(R.drawable.ic_action_gnew_label_dark)
|
.setIcon(R.drawable.ic_action_gnew_label_dark)
|
||||||
|
@ -396,38 +383,31 @@ public class MapActivityActions implements DialogProvider {
|
||||||
adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent());
|
adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent());
|
||||||
|
|
||||||
AdditionalActionsBottomSheetDialogFragment actionsBottomSheetDialogFragment = new AdditionalActionsBottomSheetDialogFragment();
|
AdditionalActionsBottomSheetDialogFragment actionsBottomSheetDialogFragment = new AdditionalActionsBottomSheetDialogFragment();
|
||||||
actionsBottomSheetDialogFragment.setAdapter(adapter,
|
actionsBottomSheetDialogFragment.setAdapter(adapter, new AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener() {
|
||||||
new AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener() {
|
@Override
|
||||||
@Override
|
public void onItemClick(int position) {
|
||||||
public void onItemClick(int position) {
|
ContextMenuItem item = adapter.getItem(position);
|
||||||
ContextMenuItem item = adapter.getItem(position);
|
int standardId = item.getTitleId();
|
||||||
int standardId = item.getTitleId();
|
ItemClickListener click = item.getItemClickListener();
|
||||||
ItemClickListener click = item.getItemClickListener();
|
if (click != null) {
|
||||||
if (click != null) {
|
click.onContextMenuClick(listAdapter, standardId, position, false, null);
|
||||||
click.onContextMenuClick(listAdapter, standardId, position, false, null);
|
} else if (standardId == R.string.context_menu_item_search) {
|
||||||
} else if (standardId == R.string.context_menu_item_search) {
|
mapActivity.showQuickSearch(latitude, longitude);
|
||||||
mapActivity.showQuickSearch(latitude, longitude);
|
} else if (standardId == R.string.context_menu_item_directions_from) {
|
||||||
} else if (standardId == R.string.context_menu_item_directions_from) {
|
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
||||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
enterDirectionsFromPoint(latitude, longitude);
|
||||||
enterDirectionsFromPoint(latitude, longitude);
|
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity, Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||||
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity,
|
mapActivity.getMyApplication().showToastMessage(R.string.ask_for_location_permission);
|
||||||
Manifest.permission.ACCESS_FINE_LOCATION)) {
|
} else {
|
||||||
mapActivity.getMyApplication()
|
ActivityCompat.requestPermissions(mapActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION);
|
||||||
.showToastMessage(R.string.ask_for_location_permission);
|
|
||||||
} else {
|
|
||||||
ActivityCompat.requestPermissions(mapActivity,
|
|
||||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
|
||||||
REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION);
|
|
||||||
}
|
|
||||||
} else if (standardId == R.string.measurement_tool) {
|
|
||||||
mapActivity.getContextMenu().close();
|
|
||||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
|
||||||
new LatLon(latitude, longitude));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
} else if (standardId == R.string.measurement_tool) {
|
||||||
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(),
|
mapActivity.getContextMenu().close();
|
||||||
AdditionalActionsBottomSheetDialogFragment.TAG);
|
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), new LatLon(latitude, longitude));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(), AdditionalActionsBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterDirectionsFromPoint(final double latitude, final double longitude) {
|
public void enterDirectionsFromPoint(final double latitude, final double longitude) {
|
||||||
|
@ -435,8 +415,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() == null) {
|
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() == null) {
|
||||||
setFirstMapMarkerAsTarget();
|
setFirstMapMarkerAsTarget();
|
||||||
}
|
}
|
||||||
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper()
|
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
|
||||||
.isRoutePlanningMode()) {
|
|
||||||
enterRoutePlanningMode(new LatLon(latitude, longitude),
|
enterRoutePlanningMode(new LatLon(latitude, longitude),
|
||||||
mapActivity.getContextMenu().getPointDescription());
|
mapActivity.getContextMenu().getPointDescription());
|
||||||
} else {
|
} else {
|
||||||
|
@ -450,9 +429,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
mapActivity.getRoutingHelper().setGpxParams(null);
|
mapActivity.getRoutingHelper().setGpxParams(null);
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||||
} else {
|
} else {
|
||||||
GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result,
|
GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result, mapActivity.getMyApplication()
|
||||||
mapActivity.getMyApplication()
|
.getSettings());
|
||||||
.getSettings());
|
|
||||||
if (result.hasRtePt() && !result.hasTrkPt()) {
|
if (result.hasRtePt() && !result.hasTrkPt()) {
|
||||||
settings.GPX_CALCULATE_RTEPT.set(true);
|
settings.GPX_CALCULATE_RTEPT.set(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -468,11 +446,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
Location startLoc = ps.get(0);
|
Location startLoc = ps.get(0);
|
||||||
Location finishLoc = ps.get(ps.size() - 1);
|
Location finishLoc = ps.get(ps.size() - 1);
|
||||||
TargetPointsHelper tg = mapActivity.getMyApplication().getTargetPointsHelper();
|
TargetPointsHelper tg = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||||
tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false,
|
tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1);
|
||||||
-1);
|
|
||||||
if (startLoc != finishLoc) {
|
if (startLoc != finishLoc) {
|
||||||
tg.setStartPoint(new LatLon(startLoc.getLatitude(), startLoc.getLongitude()), false,
|
tg.setStartPoint(new LatLon(startLoc.getLatitude(), startLoc.getLongitude()), false, null);
|
||||||
null);
|
|
||||||
} else {
|
} else {
|
||||||
tg.clearStartPoint(false);
|
tg.clearStartPoint(false);
|
||||||
}
|
}
|
||||||
|
@ -500,19 +476,16 @@ public class MapActivityActions implements DialogProvider {
|
||||||
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName,
|
enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName, useIntermediatePointsByDefault, true);
|
||||||
useIntermediatePointsByDefault, true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
bld.setTitle(R.string.navigation_over_track);
|
bld.setTitle(R.string.navigation_over_track);
|
||||||
ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity,
|
ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity, R.layout.drawer_list_item, gpxFiles) {
|
||||||
R.layout.drawer_list_item, gpxFiles) {
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = mapActivity.getLayoutInflater()
|
convertView = mapActivity.getLayoutInflater().inflate(R.layout.drawer_list_item, null);
|
||||||
.inflate(R.layout.drawer_list_item, null);
|
|
||||||
}
|
}
|
||||||
String path = getItem(position).path;
|
String path = getItem(position).path;
|
||||||
String name = path.substring(path.lastIndexOf("/") + 1, path.length());
|
String name = path.substring(path.lastIndexOf("/") + 1, path.length());
|
||||||
|
@ -525,8 +498,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
bld.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
bld.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName,
|
enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName, useIntermediatePointsByDefault, true);
|
||||||
useIntermediatePointsByDefault, true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -534,8 +506,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
|
bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault,
|
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bld.show();
|
bld.show();
|
||||||
|
@ -544,9 +515,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from,
|
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName,
|
||||||
PointDescription fromName,
|
boolean useIntermediatePointsByDefault, boolean showDialog) {
|
||||||
boolean useIntermediatePointsByDefault, boolean showDialog) {
|
|
||||||
settings.USE_INTERMEDIATE_POINTS_NAVIGATION.set(useIntermediatePointsByDefault);
|
settings.USE_INTERMEDIATE_POINTS_NAVIGATION.set(useIntermediatePointsByDefault);
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||||
|
@ -606,10 +576,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationMode getRouteMode(LatLon from) {
|
public ApplicationMode getRouteMode(LatLon from) {
|
||||||
MarkersPlanRouteContext planRouteContext = mapActivity.getMyApplication().getMapMarkersHelper()
|
MarkersPlanRouteContext planRouteContext = mapActivity.getMyApplication().getMapMarkersHelper().getPlanRouteContext();
|
||||||
.getPlanRouteContext();
|
if (planRouteContext.isNavigationFromMarkers() && planRouteContext.getSnappedMode() != ApplicationMode.DEFAULT) {
|
||||||
if (planRouteContext.isNavigationFromMarkers()
|
|
||||||
&& planRouteContext.getSnappedMode() != ApplicationMode.DEFAULT) {
|
|
||||||
planRouteContext.setNavigationFromMarkers(false);
|
planRouteContext.setNavigationFromMarkers(false);
|
||||||
return planRouteContext.getSnappedMode();
|
return planRouteContext.getSnappedMode();
|
||||||
}
|
}
|
||||||
|
@ -636,39 +604,37 @@ public class MapActivityActions implements DialogProvider {
|
||||||
builder.setMessage(R.string.context_menu_item_update_map_confirm);
|
builder.setMessage(R.string.context_menu_item_update_map_confirm);
|
||||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||||
builder.setPositiveButton(R.string.context_menu_item_update_map,
|
builder.setPositiveButton(R.string.context_menu_item_update_map, new DialogInterface.OnClickListener() {
|
||||||
new DialogInterface.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
int zoom = args.getInt(KEY_ZOOM);
|
||||||
int zoom = args.getInt(KEY_ZOOM);
|
BaseMapLayer mainLayer = mapView.getMainLayer();
|
||||||
BaseMapLayer mainLayer = mapView.getMainLayer();
|
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
|
||||||
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
|
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT)
|
return;
|
||||||
.show();
|
}
|
||||||
return;
|
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
||||||
}
|
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
|
||||||
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||||
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
|
return;
|
||||||
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT)
|
}
|
||||||
.show();
|
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
||||||
return;
|
final QuadRect tilesRect = tb.getTileBounds();
|
||||||
}
|
int left = (int) Math.floor(tilesRect.left);
|
||||||
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
int top = (int) Math.floor(tilesRect.top);
|
||||||
final QuadRect tilesRect = tb.getTileBounds();
|
int width = (int) (Math.ceil(tilesRect.right) - left);
|
||||||
int left = (int) Math.floor(tilesRect.left);
|
int height = (int) (Math.ceil(tilesRect.bottom) - top);
|
||||||
int top = (int) Math.floor(tilesRect.top);
|
for (int i = 0; i < width; i++) {
|
||||||
int width = (int) (Math.ceil(tilesRect.right) - left);
|
for (int j = 0; j < height; j++) {
|
||||||
int height = (int) (Math.ceil(tilesRect.bottom) - top);
|
((OsmandApplication) mapActivity.getApplication()).getResourceManager().
|
||||||
for (int i = 0; i < width; i++) {
|
clearTileForMap(null, mapSource, i + left, j + top, zoom);
|
||||||
for (int j = 0; j < height; j++) {
|
|
||||||
((OsmandApplication) mapActivity.getApplication()).getResourceManager().
|
|
||||||
clearTileForMap(null, mapSource, i + left, j + top, zoom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mapView.refreshMap();
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mapView.refreshMap();
|
||||||
|
}
|
||||||
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,15 +688,13 @@ public class MapActivityActions implements DialogProvider {
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.home, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.home, mapActivity)
|
||||||
.setId(DRAWER_DASHBOARD_ID)
|
.setId(DRAWER_DASHBOARD_ID)
|
||||||
.setIcon(R.drawable.map_dashboard)
|
.setIcon(R.drawable.map_dashboard)
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
app.logEvent(mapActivity, "drawer_dashboard_open");
|
app.logEvent(mapActivity, "drawer_dashboard_open");
|
||||||
MapActivity.clearPrevActivityIntent();
|
MapActivity.clearPrevActivityIntent();
|
||||||
mapActivity.closeDrawer();
|
mapActivity.closeDrawer();
|
||||||
mapActivity.getDashboard()
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
|
||||||
.setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).createItem());
|
}).createItem());
|
||||||
|
@ -738,10 +702,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
|
||||||
.setId(DRAWER_MAP_MARKERS_ID)
|
.setId(DRAWER_MAP_MARKERS_ID)
|
||||||
.setIcon(R.drawable.ic_action_flag_dark)
|
.setIcon(R.drawable.ic_action_flag_dark)
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
app.logEvent(mapActivity, "drawer_markers_open");
|
app.logEvent(mapActivity, "drawer_markers_open");
|
||||||
MapActivity.clearPrevActivityIntent();
|
MapActivity.clearPrevActivityIntent();
|
||||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||||
|
@ -749,44 +712,40 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
}).createItem());
|
}).createItem());
|
||||||
|
|
||||||
optionsMenuHelper
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
|
||||||
.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
|
.setId(DRAWER_MY_PLACES_ID)
|
||||||
.setId(DRAWER_MY_PLACES_ID)
|
.setIcon(R.drawable.ic_action_fav_dark)
|
||||||
.setIcon(R.drawable.ic_action_fav_dark)
|
.setListener(new ItemClickListener() {
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
@Override
|
||||||
@Override
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
app.logEvent(mapActivity, "drawer_myplaces_open");
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||||
app.logEvent(mapActivity, "drawer_myplaces_open");
|
.getFavoritesActivity());
|
||||||
Intent newIntent = new Intent(mapActivity,
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
mapActivity.getMyApplication().getAppCustomization()
|
mapActivity.startActivity(newIntent);
|
||||||
.getFavoritesActivity());
|
return true;
|
||||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
}
|
||||||
mapActivity.startActivity(newIntent);
|
}).createItem());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}).createItem());
|
|
||||||
|
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity)
|
||||||
.setId(DRAWER_SEARCH_ID)
|
.setId(DRAWER_SEARCH_ID)
|
||||||
.setIcon(R.drawable.ic_action_search_dark)
|
.setIcon(R.drawable.ic_action_search_dark)
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
app.logEvent(mapActivity, "drawer_search_open");
|
app.logEvent(mapActivity, "drawer_search_open");
|
||||||
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
|
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).createItem());
|
}).createItem());
|
||||||
|
|
||||||
|
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||||
.setId(DRAWER_DIRECTIONS_ID)
|
.setId(DRAWER_DIRECTIONS_ID)
|
||||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
app.logEvent(mapActivity, "drawer_directions_open");
|
app.logEvent(mapActivity, "drawer_directions_open");
|
||||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||||
if (mapControlsLayer != null) {
|
if (mapControlsLayer != null) {
|
||||||
|
@ -809,21 +768,18 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}).createItem());
|
}).createItem());
|
||||||
*/
|
*/
|
||||||
|
|
||||||
optionsMenuHelper
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||||
.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
.setId(DRAWER_CONFIGURE_MAP_ID)
|
||||||
.setId(DRAWER_CONFIGURE_MAP_ID)
|
.setIcon(R.drawable.ic_action_layers_dark)
|
||||||
.setIcon(R.drawable.ic_action_layers_dark)
|
.setListener(new ItemClickListener() {
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
@Override
|
||||||
@Override
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
app.logEvent(mapActivity, "drawer_config_map_open");
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
MapActivity.clearPrevActivityIntent();
|
||||||
app.logEvent(mapActivity, "drawer_config_map_open");
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
|
||||||
MapActivity.clearPrevActivityIntent();
|
return false;
|
||||||
mapActivity.getDashboard()
|
}
|
||||||
.setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
|
}).createItem());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).createItem());
|
|
||||||
|
|
||||||
String d = getString(R.string.welmode_download_maps);
|
String d = getString(R.string.welmode_download_maps);
|
||||||
if (app.getDownloadThread().getIndexes().isDownloadedFromInternet) {
|
if (app.getDownloadThread().getIndexes().isDownloadedFromInternet) {
|
||||||
|
@ -835,14 +791,12 @@ public class MapActivityActions implements DialogProvider {
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.welmode_download_maps, null)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.welmode_download_maps, null)
|
||||||
.setId(DRAWER_DOWNLOAD_MAPS_ID)
|
.setId(DRAWER_DOWNLOAD_MAPS_ID)
|
||||||
.setTitle(d).setIcon(R.drawable.ic_type_archive)
|
.setTitle(d).setIcon(R.drawable.ic_type_archive)
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
app.logEvent(mapActivity, "drawer_download_maps_open");
|
app.logEvent(mapActivity, "drawer_download_maps_open");
|
||||||
Intent newIntent = new Intent(mapActivity,
|
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||||
mapActivity.getMyApplication().getAppCustomization()
|
.getDownloadActivity());
|
||||||
.getDownloadActivity());
|
|
||||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
mapActivity.startActivity(newIntent);
|
mapActivity.startActivity(newIntent);
|
||||||
return true;
|
return true;
|
||||||
|
@ -853,10 +807,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.osm_live, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.osm_live, mapActivity)
|
||||||
.setId(DRAWER_OSMAND_LIVE_ID)
|
.setId(DRAWER_OSMAND_LIVE_ID)
|
||||||
.setIcon(R.drawable.ic_action_osm_live)
|
.setIcon(R.drawable.ic_action_osm_live)
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
app.logEvent(mapActivity, "drawer_osm_live_open");
|
app.logEvent(mapActivity, "drawer_osm_live_open");
|
||||||
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
|
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
@ -866,94 +819,81 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}).createItem());
|
}).createItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
optionsMenuHelper.addItem(
|
optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)")
|
||||||
new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)")
|
.setId(DRAWER_TRAVEL_GUIDES_ID)
|
||||||
.setId(DRAWER_TRAVEL_GUIDES_ID)
|
.setIcon(R.drawable.ic_action_travel)
|
||||||
.setIcon(R.drawable.ic_action_travel)
|
.setListener(new ItemClickListener() {
|
||||||
.setListener(new ItemClickListener() {
|
@Override
|
||||||
@Override
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
MapActivity.clearPrevActivityIntent();
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
TravelDbHelper travelDbHelper = getMyApplication().getTravelDbHelper();
|
||||||
MapActivity.clearPrevActivityIntent();
|
travelDbHelper.initTravelBooks();
|
||||||
TravelDbHelper travelDbHelper = getMyApplication().getTravelDbHelper();
|
if (travelDbHelper.getSelectedTravelBook() == null) {
|
||||||
travelDbHelper.initTravelBooks();
|
WikivoyageWelcomeDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
|
||||||
if (travelDbHelper.getSelectedTravelBook() == null) {
|
} else {
|
||||||
WikivoyageWelcomeDialogFragment
|
Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class);
|
||||||
.showInstance(mapActivity.getSupportFragmentManager());
|
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
} else {
|
mapActivity.startActivity(intent);
|
||||||
Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class);
|
}
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
return true;
|
||||||
mapActivity.startActivity(intent);
|
}
|
||||||
}
|
}).createItem());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}).createItem());
|
|
||||||
|
|
||||||
optionsMenuHelper.addItem(
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||||
new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
.setId(DRAWER_MEASURE_DISTANCE_ID)
|
||||||
.setId(DRAWER_MEASURE_DISTANCE_ID)
|
.setIcon(R.drawable.ic_action_ruler)
|
||||||
.setIcon(R.drawable.ic_action_ruler)
|
.setListener(new ItemClickListener() {
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
@Override
|
||||||
@Override
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager());
|
||||||
int position, boolean isChecked, int[] viewCoordinates) {
|
return true;
|
||||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager());
|
}
|
||||||
return true;
|
}).createItem());
|
||||||
}
|
|
||||||
}).createItem());
|
|
||||||
|
|
||||||
app.getAidlApi().registerNavDrawerItems(mapActivity, optionsMenuHelper);
|
app.getAidlApi().registerNavDrawerItems(mapActivity, optionsMenuHelper);
|
||||||
|
|
||||||
optionsMenuHelper
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
|
||||||
.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
|
.setId(DRAWER_CONFIGURE_SCREEN_ID)
|
||||||
.setId(DRAWER_CONFIGURE_SCREEN_ID)
|
.setIcon(R.drawable.ic_configure_screen_dark)
|
||||||
.setIcon(R.drawable.ic_configure_screen_dark)
|
.setListener(new ItemClickListener() {
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
@Override
|
||||||
@Override
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
app.logEvent(mapActivity, "drawer_config_screen_open");
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
MapActivity.clearPrevActivityIntent();
|
||||||
app.logEvent(mapActivity, "drawer_config_screen_open");
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
|
||||||
MapActivity.clearPrevActivityIntent();
|
return false;
|
||||||
mapActivity.getDashboard()
|
}
|
||||||
.setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
|
}).createItem());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).createItem());
|
|
||||||
|
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
|
||||||
.setId(DRAWER_PLUGINS_ID)
|
.setId(DRAWER_PLUGINS_ID)
|
||||||
.setIcon(R.drawable.ic_extension_dark)
|
.setIcon(R.drawable.ic_extension_dark)
|
||||||
.setListener(new ItemClickListener() {
|
.setListener(new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
app.logEvent(mapActivity, "drawer_plugins_open");
|
app.logEvent(mapActivity, "drawer_plugins_open");
|
||||||
Intent newIntent = new Intent(mapActivity,
|
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||||
mapActivity.getMyApplication().getAppCustomization()
|
.getPluginsActivity());
|
||||||
.getPluginsActivity());
|
|
||||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
mapActivity.startActivity(newIntent);
|
mapActivity.startActivity(newIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).createItem());
|
}).createItem());
|
||||||
|
|
||||||
optionsMenuHelper
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
||||||
.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
.setId(DRAWER_SETTINGS_ID)
|
||||||
.setId(DRAWER_SETTINGS_ID)
|
.setIcon(R.drawable.ic_action_settings)
|
||||||
.setIcon(R.drawable.ic_action_settings)
|
.setListener(new ItemClickListener() {
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
@Override
|
||||||
@Override
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
app.logEvent(mapActivity, "drawer_settings_open");
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization()
|
||||||
app.logEvent(mapActivity, "drawer_settings_open");
|
.getSettingsActivity());
|
||||||
final Intent settings = new Intent(mapActivity,
|
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
getMyApplication().getAppCustomization()
|
mapActivity.startActivity(settings);
|
||||||
.getSettingsActivity());
|
return true;
|
||||||
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
}
|
||||||
mapActivity.startActivity(settings);
|
}).createItem());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}).createItem());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||||
|
@ -971,10 +911,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity)
|
||||||
.setId(DRAWER_HELP_ID)
|
.setId(DRAWER_HELP_ID)
|
||||||
.setIcon(R.drawable.ic_action_help)
|
.setIcon(R.drawable.ic_action_help)
|
||||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
.setListener(new ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
int pos, boolean isChecked, int[] viewCoordinates) {
|
|
||||||
app.logEvent(mapActivity, "drawer_help_open");
|
app.logEvent(mapActivity, "drawer_help_open");
|
||||||
Intent intent = new Intent(mapActivity, HelpActivity.class);
|
Intent intent = new Intent(mapActivity, HelpActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
@ -1019,8 +958,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
for (ApplicationMode mode : modes) {
|
for (ApplicationMode mode : modes) {
|
||||||
if (settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(mode)) {
|
if (settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(mode)) {
|
||||||
settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, false);
|
settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, false);
|
||||||
settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false)
|
settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false).setModeValue(mode, false);
|
||||||
.setModeValue(mode, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1066,40 +1004,37 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreOrReturnDialog(final String packageName) {
|
public void restoreOrReturnDialog(final String packageName) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||||
builder.setTitle("Restore OsmAnd");
|
builder.setTitle("Restore OsmAnd");
|
||||||
builder.setMessage("Do you want to Restore OsmAnd or get back to the Client App?");
|
builder.setMessage("Do you want to Restore OsmAnd or get back to the Client App?");
|
||||||
builder.setPositiveButton("Restore", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("Restore", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
restoreOsmand();
|
restoreOsmand();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNeutralButton("Return", new DialogInterface.OnClickListener() {
|
builder.setNeutralButton("Return", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
executeHeadersIntent(packageName);
|
executeHeadersIntent(packageName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton("Cancel", null);
|
builder.setNegativeButton("Cancel", null);
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateDrawerMenu() {
|
protected void updateDrawerMenu() {
|
||||||
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems);
|
final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems);
|
||||||
if (nightMode) {
|
if (nightMode) {
|
||||||
menuItemsListView
|
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_dark));
|
||||||
.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_dark));
|
|
||||||
} else {
|
} else {
|
||||||
menuItemsListView
|
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
|
||||||
.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
|
|
||||||
}
|
}
|
||||||
menuItemsListView.removeHeaderView(drawerLogoHeader);
|
menuItemsListView.removeHeaderView(drawerLogoHeader);
|
||||||
menuItemsListView.removeFooterView(drawerOsmAndFooter);
|
menuItemsListView.removeFooterView(drawerOsmAndFooter);
|
||||||
Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo();
|
Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo();
|
||||||
final ArrayList<String> navDrawerLogoParams = getMyApplication().getAppCustomization()
|
final ArrayList<String> navDrawerLogoParams = getMyApplication().getAppCustomization().getNavDrawerLogoParams();
|
||||||
.getNavDrawerLogoParams();
|
|
||||||
|
|
||||||
boolean customHeader = false;
|
boolean customHeader = false;
|
||||||
if (navDrawerLogo != null) {
|
if (navDrawerLogo != null) {
|
||||||
|
@ -1110,9 +1045,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
menuItemsListView.setDivider(null);
|
menuItemsListView.setDivider(null);
|
||||||
final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu();
|
final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu();
|
||||||
contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item);
|
contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item);
|
||||||
final ArrayAdapter<ContextMenuItem> simpleListAdapter = contextMenuAdapter
|
final ArrayAdapter<ContextMenuItem> simpleListAdapter = contextMenuAdapter.createListAdapter(mapActivity,
|
||||||
.createListAdapter(mapActivity,
|
!nightMode);
|
||||||
!nightMode);
|
|
||||||
menuItemsListView.setAdapter(simpleListAdapter);
|
menuItemsListView.setAdapter(simpleListAdapter);
|
||||||
menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1120,22 +1054,18 @@ public class MapActivityActions implements DialogProvider {
|
||||||
mapActivity.dismissCardDialog();
|
mapActivity.dismissCardDialog();
|
||||||
boolean hasHeader = menuItemsListView.getHeaderViewsCount() > 0;
|
boolean hasHeader = menuItemsListView.getHeaderViewsCount() > 0;
|
||||||
boolean hasFooter = menuItemsListView.getFooterViewsCount() > 0;
|
boolean hasFooter = menuItemsListView.getFooterViewsCount() > 0;
|
||||||
if (hasHeader && position == 0 || (hasFooter
|
if (hasHeader && position ==0 || (hasFooter && position== menuItemsListView.getCount() - 1)) {
|
||||||
&& position == menuItemsListView.getCount() - 1)) {
|
if(navDrawerLogoParams!=null) executeHeadersIntent(navDrawerLogoParams.get(0));
|
||||||
if (navDrawerLogoParams != null) {
|
else restoreOsmand();
|
||||||
executeHeadersIntent(navDrawerLogoParams.get(0));
|
|
||||||
} else {
|
} else {
|
||||||
restoreOsmand();
|
position -= menuItemsListView.getHeaderViewsCount();
|
||||||
}
|
ContextMenuItem item = contextMenuAdapter.getItem(position);
|
||||||
} else {
|
ItemClickListener click = item.getItemClickListener();
|
||||||
position -= menuItemsListView.getHeaderViewsCount();
|
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
|
||||||
ContextMenuItem item = contextMenuAdapter.getItem(position);
|
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
|
||||||
ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
|
mapActivity.closeDrawer();
|
||||||
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
|
}
|
||||||
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
|
}
|
||||||
mapActivity.closeDrawer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1147,11 +1077,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
if (menuItemsListView.getChildCount() > 0) {
|
if (menuItemsListView.getChildCount() > 0) {
|
||||||
int numItemsVisible = menuItemsListView.getLastVisiblePosition() -
|
int numItemsVisible = menuItemsListView.getLastVisiblePosition() -
|
||||||
menuItemsListView.getFirstVisiblePosition();
|
menuItemsListView.getFirstVisiblePosition();
|
||||||
View lastView = menuItemsListView
|
View lastView = menuItemsListView.getChildAt(menuItemsListView.getLastVisiblePosition());
|
||||||
.getChildAt(menuItemsListView.getLastVisiblePosition());
|
boolean overlapped = lastView != null && lastView.getY() + lastView.getHeight() * 2 > menuItemsListView.getHeight();
|
||||||
boolean overlapped =
|
|
||||||
lastView != null && lastView.getY() + lastView.getHeight() * 2 > menuItemsListView
|
|
||||||
.getHeight();
|
|
||||||
if (simpleListAdapter.getCount() - 1 > numItemsVisible || overlapped) {
|
if (simpleListAdapter.getCount() - 1 > numItemsVisible || overlapped) {
|
||||||
menuItemsListView.addFooterView(drawerOsmAndFooter);
|
menuItemsListView.addFooterView(drawerOsmAndFooter);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1184,18 +1111,16 @@ public class MapActivityActions implements DialogProvider {
|
||||||
|
|
||||||
private void executeHeadersIntent(String packageName) {
|
private void executeHeadersIntent(String packageName) {
|
||||||
Intent launchIntent = mapActivity.getPackageManager().getLaunchIntentForPackage(packageName);
|
Intent launchIntent = mapActivity.getPackageManager().getLaunchIntentForPackage(packageName);
|
||||||
if (launchIntent != null) {
|
if(launchIntent!=null) mapActivity.startActivity(launchIntent);
|
||||||
mapActivity.startActivity(launchIntent);
|
|
||||||
}
|
|
||||||
mapActivity.closeDrawer();
|
mapActivity.closeDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showReturnConfirmationDialog(String packageName) {
|
private void showReturnConfirmationDialog(String packageName) {
|
||||||
restoreOrReturnDialog(packageName);
|
restoreOrReturnDialog(packageName);
|
||||||
mapActivity.closeDrawer();
|
mapActivity.closeDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreOsmand() {
|
private void restoreOsmand(){
|
||||||
getMyApplication().getAppCustomization().restoreOsmand();
|
getMyApplication().getAppCustomization().restoreOsmand();
|
||||||
mapActivity.closeDrawer();
|
mapActivity.closeDrawer();
|
||||||
}
|
}
|
||||||
|
@ -1203,12 +1128,10 @@ public class MapActivityActions implements DialogProvider {
|
||||||
|
|
||||||
public void setFirstMapMarkerAsTarget() {
|
public void setFirstMapMarkerAsTarget() {
|
||||||
if (getMyApplication().getMapMarkersHelper().getMapMarkers().size() > 0) {
|
if (getMyApplication().getMapMarkersHelper().getMapMarkers().size() > 0) {
|
||||||
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkers()
|
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkers().get(0);
|
||||||
.get(0);
|
|
||||||
PointDescription pointDescription = marker.getOriginalPointDescription();
|
PointDescription pointDescription = marker.getOriginalPointDescription();
|
||||||
if (pointDescription.isLocation()
|
if (pointDescription.isLocation()
|
||||||
&& pointDescription.getName()
|
&& pointDescription.getName().equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
|
||||||
.equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
|
|
||||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
|
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
|
||||||
}
|
}
|
||||||
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
|
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
|
||||||
|
|
|
@ -16,47 +16,49 @@ import net.osmand.plus.helpers.FontCache;
|
||||||
|
|
||||||
public class OsmandRestoreOrExitDialog extends BottomSheetDialogFragment {
|
public class OsmandRestoreOrExitDialog extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
private String clientAppTitle = "";
|
private String clientAppTitle = "";
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = getActivity().getLayoutInflater()
|
View view = getActivity().getLayoutInflater()
|
||||||
.inflate(R.layout.dash_restore_osmand_fragment, container, false);
|
.inflate(R.layout.dash_restore_osmand_fragment, container, false);
|
||||||
try {
|
try {
|
||||||
clientAppTitle = getMyApplication().getAppCustomization().getNavFooterParams().getAppName();
|
clientAppTitle = getMyApplication().getAppCustomization().getNavFooterParams().getAppName();
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
String msg = MessageFormat.format(getString(R.string.run_full_osmand_msg), clientAppTitle);
|
String msg = MessageFormat.format(getString(R.string.run_full_osmand_msg), clientAppTitle);
|
||||||
Typeface typeface = FontCache.getRobotoMedium(getActivity());
|
Typeface typeface = FontCache.getRobotoMedium(getActivity());
|
||||||
Typeface typefaceReg = FontCache.getRobotoRegular(getActivity());
|
Typeface typefaceReg = FontCache.getRobotoRegular(getActivity());
|
||||||
TextView header = view.findViewById(R.id.run_full_osmand_header);
|
TextView header = view.findViewById(R.id.run_full_osmand_header);
|
||||||
header.setTypeface(typeface);
|
header.setTypeface(typeface);
|
||||||
|
|
||||||
TextView message = view.findViewById(R.id.run_full_osmand_message);
|
TextView message = view.findViewById(R.id.run_full_osmand_message);
|
||||||
message.setTypeface(typefaceReg);
|
message.setTypeface(typefaceReg);
|
||||||
message.setText(msg);
|
message.setText(msg);
|
||||||
|
|
||||||
Button cancelBtn = view.findViewById(R.id.cancel_full_osmand_btn);
|
Button cancelBtn = view.findViewById(R.id.cancel_full_osmand_btn);
|
||||||
cancelBtn.setTypeface(typeface);
|
cancelBtn.setTypeface(typeface);
|
||||||
cancelBtn.setOnClickListener(new View.OnClickListener() {
|
cancelBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Button launchBtn = view.findViewById(R.id.launch_full_osmand_btn);
|
Button launchBtn = view.findViewById(R.id.launch_full_osmand_btn);
|
||||||
launchBtn.setTypeface(typeface);
|
launchBtn.setTypeface(typeface);
|
||||||
launchBtn.setOnClickListener(new View.OnClickListener() {
|
launchBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
getMyApplication().getAppCustomization().restoreOsmand();
|
getMyApplication().getAppCustomization().restoreOsmand();
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue