pull request fixes

This commit is contained in:
madwasp79 2019-01-16 12:35:07 +02:00
parent e1e5250470
commit 463a83ba22
11 changed files with 1365 additions and 1482 deletions

View file

@ -157,23 +157,6 @@
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.gpx" />
</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
android:label="@string/app_name"
android:priority="50">

View file

@ -99,8 +99,7 @@
android:id="@+id/drawer_relative_layout"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
>
android:layout_gravity="start">
<ListView
android:id="@+id/menuItems"

View file

@ -5,7 +5,6 @@
android:layout_height="@dimen/list_item_height">
<TextView
android:layoutDirection="locale"
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -14,7 +13,9 @@
android:drawablePadding="24dp"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingLeft="16dp"
android:paddingRight = "16dp"
android:textAppearance="@style/TextAppearance.ListItemTitle"
android:textStyle="normal"
tools:drawableStart="@drawable/ic_action_search_dark"

View file

@ -1668,28 +1668,6 @@ public class OsmandAidlApi {
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) {
if (!TextUtils.isEmpty(appPackage) && items != null) {
if (items.isEmpty()) {
@ -1911,7 +1889,7 @@ public class OsmandAidlApi {
}
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);
}

File diff suppressed because it is too large Load diff

View file

@ -7,62 +7,62 @@ import android.support.annotation.Nullable;
public class NavDrawerFooterParams implements Parcelable {
@NonNull
private String packageName;
@Nullable
private String intent;
@Nullable
private String appName;
@NonNull
private String packageName;
@Nullable
private String intent;
@Nullable
private String appName;
@NonNull
public String getPackageName() {
return packageName;
}
@NonNull
public String getPackageName() {
return packageName;
}
@Nullable
public String getIntent() {
return intent;
}
@Nullable
public String getIntent() {
return intent;
}
@Nullable
public String getAppName() {
return appName;
}
@Nullable
public String getAppName() {
return appName;
}
public NavDrawerFooterParams(@NonNull String packageName, @Nullable String intent,
@Nullable String appName) {
this.packageName = packageName;
this.intent = intent;
this.appName = appName;
}
public NavDrawerFooterParams(@NonNull String packageName, @Nullable String intent,
@Nullable String appName) {
this.packageName = packageName;
this.intent = intent;
this.appName = appName;
}
protected NavDrawerFooterParams(Parcel in) {
packageName = in.readString();
intent = in.readString();
appName = in.readString();
}
protected NavDrawerFooterParams(Parcel in) {
packageName = in.readString();
intent = in.readString();
appName = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(packageName);
dest.writeString(intent);
dest.writeString(appName);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(packageName);
dest.writeString(intent);
dest.writeString(appName);
}
@Override
public int describeContents() {
return 0;
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<NavDrawerFooterParams> CREATOR = new Creator<NavDrawerFooterParams>() {
@Override
public NavDrawerFooterParams createFromParcel(Parcel in) {
return new NavDrawerFooterParams(in);
}
public static final Creator<NavDrawerFooterParams> CREATOR = new Creator<NavDrawerFooterParams>() {
@Override
public NavDrawerFooterParams createFromParcel(Parcel in) {
return new NavDrawerFooterParams(in);
}
@Override
public NavDrawerFooterParams[] newArray(int size) {
return new NavDrawerFooterParams[size];
}
};
@Override
public NavDrawerFooterParams[] newArray(int size) {
return new NavDrawerFooterParams[size];
}
};
}

View file

@ -7,62 +7,62 @@ import android.support.annotation.Nullable;
public class NavDrawerHeaderParams implements Parcelable {
@NonNull
private String imageUri;
@NonNull
private String packageName;
@Nullable
private String intent;
@NonNull
private String imageUri;
@NonNull
private String packageName;
@Nullable
private String intent;
@NonNull
public String getImageUri() {
return imageUri;
}
@NonNull
public String getImageUri() {
return imageUri;
}
@NonNull
public String getPackageName() {
return packageName;
}
@NonNull
public String getPackageName() {
return packageName;
}
@Nullable
public String getIntent() {
return intent;
}
@Nullable
public String getIntent() {
return intent;
}
public NavDrawerHeaderParams(@NonNull String imageUri, @NonNull String packageName,
@Nullable String intent) {
this.imageUri = imageUri;
this.packageName = packageName;
this.intent = intent;
}
public NavDrawerHeaderParams(@NonNull String imageUri, @NonNull String packageName,
@Nullable String intent) {
this.imageUri = imageUri;
this.packageName = packageName;
this.intent = intent;
}
public NavDrawerHeaderParams(Parcel in) {
imageUri = in.readString();
packageName = in.readString();
intent = in.readString();
}
public NavDrawerHeaderParams(Parcel in) {
imageUri = in.readString();
packageName = in.readString();
intent = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(imageUri);
dest.writeString(packageName);
dest.writeString(intent);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(imageUri);
dest.writeString(packageName);
dest.writeString(intent);
}
@Override
public int describeContents() {
return 0;
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<NavDrawerHeaderParams> CREATOR = new Creator<NavDrawerHeaderParams>() {
@Override
public NavDrawerHeaderParams createFromParcel(Parcel in) {
return new NavDrawerHeaderParams(in);
}
public static final Creator<NavDrawerHeaderParams> CREATOR = new Creator<NavDrawerHeaderParams>() {
@Override
public NavDrawerHeaderParams createFromParcel(Parcel in) {
return new NavDrawerHeaderParams(in);
}
@Override
public NavDrawerHeaderParams[] newArray(int size) {
return new NavDrawerHeaderParams[size];
}
};
@Override
public NavDrawerHeaderParams[] newArray(int size) {
return new NavDrawerHeaderParams[size];
}
};
}

View file

@ -5,47 +5,47 @@ import android.os.Parcelable;
public class PluginParams implements Parcelable {
private String pluginId;
private int newState; //0- off, 1 - on
private String pluginId;
private int newState; //0- off, 1 - on
public PluginParams(String pluginId, int newState) {
this.pluginId = pluginId;
this.newState = newState;
}
public PluginParams(String pluginId, int newState) {
this.pluginId = pluginId;
this.newState = newState;
}
public String getPluginId() {
return pluginId;
}
public String getPluginId() {
return pluginId;
}
public int getNewState() {
return newState;
}
public int getNewState() {
return newState;
}
protected PluginParams(Parcel in) {
pluginId = in.readString();
newState = in.readInt();
}
protected PluginParams(Parcel in) {
pluginId = in.readString();
newState = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(pluginId);
dest.writeInt(newState);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(pluginId);
dest.writeInt(newState);
}
@Override
public int describeContents() {
return 0;
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<PluginParams> CREATOR = new Creator<PluginParams>() {
@Override
public PluginParams createFromParcel(Parcel in) {
return new PluginParams(in);
}
public static final Creator<PluginParams> CREATOR = new Creator<PluginParams>() {
@Override
public PluginParams createFromParcel(Parcel in) {
return new PluginParams(in);
}
@Override
public PluginParams[] newArray(int size) {
return new PluginParams[size];
}
};
@Override
public PluginParams[] newArray(int size) {
return new PluginParams[size];
}
};
}

View file

@ -43,378 +43,375 @@ import java.util.Set;
public class OsmAndAppCustomization {
protected OsmandApplication app;
protected OsmandSettings osmandSettings;
protected OsmandApplication app;
protected OsmandSettings osmandSettings;
private Bitmap navDrawerLogo;
private ArrayList<String> navDrawerParams;
private NavDrawerFooterParams navDrawerFooterParams;
private Bitmap navDrawerLogo;
private ArrayList<String> navDrawerParams;
private NavDrawerFooterParams navDrawerFooterParams;
private Set<String> featuresEnabledIds = new HashSet<>();
private Set<String> featuresDisabledIds = new HashSet<>();
private Set<String> featuresEnabledPatterns = new HashSet<>();
private Set<String> featuresDisabledPatterns = new HashSet<>();
private Map<String, Set<ApplicationMode>> widgetsVisibilityMap = new LinkedHashMap<>();
private Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
private CustomOsmandSettings customOsmandSettings;
private Set<String> featuresEnabledIds = new HashSet<>();
private Set<String> featuresDisabledIds = new HashSet<>();
private Set<String> featuresEnabledPatterns = new HashSet<>();
private Set<String> featuresDisabledPatterns = new HashSet<>();
private Map<String, Set<ApplicationMode>> widgetsVisibilityMap = new LinkedHashMap<>();
private Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
private CustomOsmandSettings customOsmandSettings;
private boolean featuresCustomized;
private boolean widgetsCustomized;
private boolean featuresCustomized;
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 OsmandSettings settings;
private String sharedPreferencesName;
private OsmandSettings settings;
CustomOsmandSettings(OsmandApplication app, String sharedPreferencesName, Bundle bundle) {
this.sharedPreferencesName = sharedPreferencesName;
this.settings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app),
sharedPreferencesName);
if (bundle != null) {
for (String key : bundle.keySet()) {
Object object = bundle.get(key);
this.settings.setPreference(key, object);
}
}
}
CustomOsmandSettings(OsmandApplication app, String sharedPreferencesName, Bundle bundle) {
this.sharedPreferencesName = sharedPreferencesName;
this.settings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app),
sharedPreferencesName);
if (bundle != null) {
for (String key : bundle.keySet()) {
Object object = bundle.get(key);
this.settings.setPreference(key, object);
}
}
}
public OsmandSettings getSettings() {
return settings;
}
}
public OsmandSettings getSettings() {
return settings;
}
}
public void setup(OsmandApplication app) {
this.app = app;
this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app));
}
public void setup(OsmandApplication app) {
this.app = app;
this.osmandSettings = new OsmandSettings(app, new net.osmand.plus.api.SettingsAPIImpl(app));
}
public OsmandSettings getOsmandSettings() {
return customOsmandSettings != null ? customOsmandSettings.getSettings() : osmandSettings;
}
public OsmandSettings getOsmandSettings() {
return customOsmandSettings != null ? customOsmandSettings.getSettings() : osmandSettings;
}
public void customizeOsmandSettings(@NonNull String sharedPreferencesName,
@Nullable Bundle bundle) {
customOsmandSettings = new CustomOsmandSettings(app, sharedPreferencesName, bundle);
OsmandSettings newSettings = customOsmandSettings.getSettings();
if (Build.VERSION.SDK_INT < 19) {
if (osmandSettings.isExternalStorageDirectorySpecifiedPre19()) {
File externalStorageDirectory = osmandSettings.getExternalStorageDirectoryPre19();
newSettings.setExternalStorageDirectoryPre19(externalStorageDirectory.getAbsolutePath());
}
} else if (osmandSettings.isExternalStorageDirectoryTypeSpecifiedV19()
&& osmandSettings.isExternalStorageDirectorySpecifiedV19()) {
int type = osmandSettings.getExternalStorageDirectoryTypeV19();
String directory = osmandSettings.getExternalStorageDirectoryV19();
newSettings.setExternalStorageDirectoryV19(type, directory);
}
app.setOsmandSettings(newSettings);
notifySettingsCustomized();
}
public void customizeOsmandSettings(@NonNull String sharedPreferencesName,
@Nullable Bundle bundle) {
customOsmandSettings = new CustomOsmandSettings(app, sharedPreferencesName, bundle);
OsmandSettings newSettings = customOsmandSettings.getSettings();
if (Build.VERSION.SDK_INT < 19) {
if (osmandSettings.isExternalStorageDirectorySpecifiedPre19()) {
File externalStorageDirectory = osmandSettings.getExternalStorageDirectoryPre19();
newSettings.setExternalStorageDirectoryPre19(externalStorageDirectory.getAbsolutePath());
}
} else if (osmandSettings.isExternalStorageDirectoryTypeSpecifiedV19()
&& osmandSettings.isExternalStorageDirectorySpecifiedV19()) {
int type = osmandSettings.getExternalStorageDirectoryTypeV19();
String directory = osmandSettings.getExternalStorageDirectoryV19();
newSettings.setExternalStorageDirectoryV19(type, directory);
}
app.setOsmandSettings(newSettings);
notifySettingsCustomized();
}
public void restoreOsmandSettings() {
app.setOsmandSettings(osmandSettings);
notifySettingsCustomized();
}
public void restoreOsmandSettings() {
app.setOsmandSettings(osmandSettings);
notifySettingsCustomized();
}
public boolean restoreOsmand() {
navDrawerLogo = null;
featuresCustomized = false;
widgetsCustomized = false;
customOsmandSettings = null;
restoreOsmandSettings();
public boolean restoreOsmand() {
navDrawerLogo = null;
featuresCustomized = false;
widgetsCustomized = false;
customOsmandSettings = null;
restoreOsmandSettings();
featuresEnabledIds.clear();
featuresDisabledIds.clear();
featuresEnabledPatterns.clear();
featuresDisabledPatterns.clear();
widgetsVisibilityMap.clear();
widgetsAvailabilityMap.clear();
featuresEnabledIds.clear();
featuresDisabledIds.clear();
featuresEnabledPatterns.clear();
featuresDisabledPatterns.clear();
widgetsVisibilityMap.clear();
widgetsAvailabilityMap.clear();
return true;
}
return true;
}
// Activities
public Class<? extends Activity> getSettingsActivity() {
return SettingsActivity.class;
}
// Activities
public Class<? extends Activity> getSettingsActivity() {
return SettingsActivity.class;
}
public Class<MapActivity> getMapActivity() {
return MapActivity.class;
}
public Class<MapActivity> getMapActivity() {
return MapActivity.class;
}
public Class<TrackActivity> getTrackActivity() {
return TrackActivity.class;
}
public Class<TrackActivity> getTrackActivity() {
return TrackActivity.class;
}
public Class<FavoritesActivity> getFavoritesActivity() {
return FavoritesActivity.class;
}
public Class<FavoritesActivity> getFavoritesActivity() {
return FavoritesActivity.class;
}
public Class<? extends Activity> getDownloadIndexActivity() {
return DownloadActivity.class;
}
public Class<? extends Activity> getDownloadIndexActivity() {
return DownloadActivity.class;
}
public Class<? extends Activity> getPluginsActivity() {
return PluginsActivity.class;
}
public Class<? extends Activity> getPluginsActivity() {
return PluginsActivity.class;
}
public Class<? extends Activity> getDownloadActivity() {
return DownloadActivity.class;
}
public Class<? extends Activity> getDownloadActivity() {
return DownloadActivity.class;
}
public List<String> onIndexingFiles(IProgress progress, Map<String, String> indexFileNames) {
return Collections.emptyList();
}
public List<String> onIndexingFiles(IProgress progress, Map<String, String> indexFileNames) {
return Collections.emptyList();
}
public String getIndexesUrl() {
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/get_indexes?gzip&" + Version
.getVersionAsURLParam(app);
}
public String getIndexesUrl() {
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/get_indexes?gzip&" + Version
.getVersionAsURLParam(app);
}
public boolean showDownloadExtraActions() {
return true;
}
public boolean showDownloadExtraActions() {
return true;
}
public File getTracksDir() {
return app.getAppPath(IndexConstants.GPX_RECORDED_INDEX_DIR);
}
public File getTracksDir() {
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() {
return Collections.emptyList();
}
public List<? extends LocationPoint> getWaypoints() {
return Collections.emptyList();
}
public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) {
if (waypointType == WaypointHelper.ALARMS) {
return route != null && !route.getAlarmInfo().isEmpty();
} else if (waypointType == WaypointHelper.WAYPOINTS) {
return route != null && !route.getLocationPoints().isEmpty();
}
return true;
}
public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) {
if (waypointType == WaypointHelper.ALARMS) {
return route != null && !route.getAlarmInfo().isEmpty();
} else if (waypointType == WaypointHelper.WAYPOINTS) {
return route != null && !route.getLocationPoints().isEmpty();
}
return true;
}
public boolean onDestinationReached() {
return true;
}
public boolean onDestinationReached() {
return true;
}
@Nullable
public Bitmap getNavDrawerLogo() {
return navDrawerLogo;
}
@Nullable
public Bitmap getNavDrawerLogo() {
return navDrawerLogo;
}
@Nullable
public ArrayList<String> getNavDrawerLogoParams() {
return navDrawerParams;
}
@Nullable
public ArrayList<String> getNavDrawerLogoParams() {
return navDrawerParams;
}
public boolean setNavDrawerLogo(@Nullable String uri, @Nullable String packageName,
@Nullable String intent) {
if (TextUtils.isEmpty(uri)) {
navDrawerLogo = null;
} else {
try {
InputStream is = app.getContentResolver().openInputStream(Uri.parse(uri));
if (is != null) {
navDrawerLogo = BitmapFactory.decodeStream(is);
is.close();
public boolean setNavDrawerLogo(@NonNull String uri, @Nullable String packageName,
@Nullable String intent) {
if (TextUtils.isEmpty(uri)) {
navDrawerLogo = null;
} else {
try {
InputStream is = app.getContentResolver().openInputStream(Uri.parse(uri));
if (is != null) {
navDrawerLogo = BitmapFactory.decodeStream(is);
is.close();
}
} catch (FileNotFoundException e) {
return false;
} catch (IOException e) {
// ignore
}
if (packageName != null && intent != null) {
navDrawerParams = new ArrayList<>();
navDrawerParams.add(packageName);
navDrawerParams.add(intent);
}
}
return true;
}
}
} catch (FileNotFoundException e) {
return false;
} catch (IOException e) {
// ignore
}
if (packageName != null && intent != null) {
navDrawerParams = new ArrayList<>();
navDrawerParams.add(packageName);
navDrawerParams.add(intent);
}
}
return true;
}
public boolean setNavDrawerFooterParams(NavDrawerFooterParams params){
navDrawerFooterParams = params;
return true;
}
public boolean setNavDrawerFooterParams(NavDrawerFooterParams params) {
navDrawerFooterParams = params;
return true;
}
public NavDrawerFooterParams getNavFooterParams(){
return navDrawerFooterParams;
}
public NavDrawerFooterParams getNavFooterParams() {
return navDrawerFooterParams;
}
public void setFeaturesEnabledIds(@NonNull Collection<String> ids) {
featuresEnabledIds.clear();
featuresEnabledIds.addAll(ids);
setFeaturesCustomized();
}
public void setFeaturesEnabledIds(@NonNull Collection<String> ids) {
featuresEnabledIds.clear();
featuresEnabledIds.addAll(ids);
setFeaturesCustomized();
}
public void setFeaturesDisabledIds(@NonNull Collection<String> ids) {
featuresDisabledIds.clear();
featuresDisabledIds.addAll(ids);
setFeaturesCustomized();
}
public void setFeaturesDisabledIds(@NonNull Collection<String> ids) {
featuresDisabledIds.clear();
featuresDisabledIds.addAll(ids);
setFeaturesCustomized();
}
public void setFeaturesEnabledPatterns(@NonNull Collection<String> patterns) {
featuresEnabledPatterns.clear();
featuresEnabledPatterns.addAll(patterns);
setFeaturesCustomized();
}
public void setFeaturesEnabledPatterns(@NonNull Collection<String> patterns) {
featuresEnabledPatterns.clear();
featuresEnabledPatterns.addAll(patterns);
setFeaturesCustomized();
}
public void setFeaturesDisabledPatterns(@NonNull Collection<String> patterns) {
featuresDisabledPatterns.clear();
featuresDisabledPatterns.addAll(patterns);
setFeaturesCustomized();
}
public void setFeaturesDisabledPatterns(@NonNull Collection<String> patterns) {
featuresDisabledPatterns.clear();
featuresDisabledPatterns.addAll(patterns);
setFeaturesCustomized();
}
public Set<ApplicationMode> regWidgetVisibility(@NonNull String widgetId,
@Nullable List<String> appModeKeys) {
HashSet<ApplicationMode> set = getAppModesSet(appModeKeys);
widgetsVisibilityMap.put(widgetId, set);
setWidgetsCustomized();
return set;
}
public Set<ApplicationMode> regWidgetVisibility(@NonNull String widgetId,
@Nullable List<String> appModeKeys) {
HashSet<ApplicationMode> set = getAppModesSet(appModeKeys);
widgetsVisibilityMap.put(widgetId, set);
setWidgetsCustomized();
return set;
}
public Set<ApplicationMode> regWidgetAvailability(@NonNull String widgetId,
@Nullable List<String> appModeKeys) {
HashSet<ApplicationMode> set = getAppModesSet(appModeKeys);
widgetsAvailabilityMap.put(widgetId, set);
setWidgetsCustomized();
return set;
}
public Set<ApplicationMode> regWidgetAvailability(@NonNull String widgetId,
@Nullable List<String> appModeKeys) {
HashSet<ApplicationMode> set = getAppModesSet(appModeKeys);
widgetsAvailabilityMap.put(widgetId, set);
setWidgetsCustomized();
return set;
}
public boolean isWidgetVisible(@NonNull String key, ApplicationMode appMode) {
Set<ApplicationMode> set = widgetsVisibilityMap.get(key);
if (set == null) {
return false;
}
return set.contains(appMode);
}
public boolean isWidgetVisible(@NonNull String key, ApplicationMode appMode) {
Set<ApplicationMode> set = widgetsVisibilityMap.get(key);
if (set == null) {
return false;
}
return set.contains(appMode);
}
public boolean isWidgetAvailable(@NonNull String key, ApplicationMode appMode) {
Set<ApplicationMode> set = widgetsAvailabilityMap.get(key);
if (set == null) {
return true;
}
return set.contains(appMode);
}
public boolean isWidgetAvailable(@NonNull String key, ApplicationMode appMode) {
Set<ApplicationMode> set = widgetsAvailabilityMap.get(key);
if (set == null) {
return true;
}
return set.contains(appMode);
}
public boolean setNavDrawerLogoWithParams(String uri, @Nullable String packageName,
@Nullable String intent) {
return setNavDrawerLogo(uri, packageName, intent);
}
public boolean setNavDrawerLogoWithParams(@NonNull String imageUri, @Nullable String packageName,
@Nullable String intent) {
return setNavDrawerLogo(imageUri, packageName, intent);
}
public boolean setNavDrawerFooterAction(String packageName, String intent, String appName) {
//todo implement custom action to "Powered by Osmand" action in NavDrawer
return true;
}
public boolean changePluginStatus(PluginParams params) {
if (params.getNewState() == 0) {
for (OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) {
if (plugin.getId().equals(params.getPluginId())) {
plugin.setActive(false);
}
}
return true;
}
public boolean changePluginStatus(PluginParams params) {
if (params.getNewState() == 0) {
for (OsmandPlugin plugin : OsmandPlugin.getEnabledPlugins()) {
if(plugin.getId().equals(params.getPluginId())) plugin.setActive(false);
}
return true;
}
if (params.getNewState() == 1) {
for (OsmandPlugin plugin : OsmandPlugin.getAvailablePlugins()) {
if (plugin.getId().equals(params.getPluginId())) {
plugin.setActive(true);
}
}
return true;
}
if (params.getNewState() == 1) {
for (OsmandPlugin plugin : OsmandPlugin.getAvailablePlugins()) {
if (plugin.getId().equals(params.getPluginId())) {
plugin.setActive(true);
}
}
return true;
}
return false;
}
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
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;
}
public boolean isFeatureEnabled(@NonNull String id) {
if (!featuresCustomized) {
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 isFeatureEnabled(@NonNull String id) {
if (!featuresCustomized) {
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() {
return widgetsCustomized;
}
public boolean areWidgetsCustomized() {
return widgetsCustomized;
}
private void setFeaturesCustomized() {
featuresCustomized = true;
}
private void setFeaturesCustomized() {
featuresCustomized = true;
}
private void setWidgetsCustomized() {
widgetsCustomized = true;
}
private void setWidgetsCustomized() {
widgetsCustomized = true;
}
private boolean isMatchesPattern(@NonNull String id, @NonNull Set<String> patterns) {
for (String pattern : patterns) {
if (id.startsWith(pattern)) {
return true;
}
}
return false;
}
private boolean isMatchesPattern(@NonNull String id, @NonNull Set<String> patterns) {
for (String pattern : patterns) {
if (id.startsWith(pattern)) {
return true;
}
}
return false;
}
private void notifySettingsCustomized() {
app.uiHandler.post(new Runnable() {
private void notifySettingsCustomized() {
app.uiHandler.post(new Runnable() {
@Override
public void run() {
for (OsmAndAppCustomizationListener l : listeners) {
l.onOsmAndSettingsCustomized();
}
}
});
}
@Override
public void run() {
for (OsmAndAppCustomizationListener l : listeners) {
l.onOsmAndSettingsCustomized();
}
}
});
}
public void addListener(OsmAndAppCustomizationListener listener) {
this.listeners.add(listener);
}
public void addListener(OsmAndAppCustomizationListener listener) {
this.listeners.add(listener);
}
public void removeListener(OsmAndAppCustomizationListener listener) {
this.listeners.remove(listener);
}
public void removeListener(OsmAndAppCustomizationListener listener) {
this.listeners.remove(listener);
}
}

View file

@ -53,7 +53,6 @@ import net.osmand.plus.Version;
import net.osmand.plus.activities.actions.OsmAndDialogs;
import net.osmand.plus.activities.actions.OsmandRestoreOrExitDialog;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.liveupdates.OsmLiveActivity;
@ -103,8 +102,8 @@ 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.helpers.ImportHelper.GPX_SUFFIX;
public class MapActivityActions implements DialogProvider {
public class MapActivityActions implements DialogProvider {
private static final Log LOG = PlatformUtil.getLog(MapActivityActions.class);
public static final String KEY_LONGITUDE = "longitude";
public static final String KEY_LATITUDE = "latitude";
@ -145,24 +144,20 @@ public class MapActivityActions implements DialogProvider {
settings = mapActivity.getMyApplication().getSettings();
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
drawerLogoHeader = new ImageView(mapActivity);
drawerLogoHeader
.setPadding(-AndroidUtils.dpToPx(mapActivity, 8f), AndroidUtils.dpToPx(mapActivity, 16f), 0,
drawerLogoHeader.setPadding(-AndroidUtils.dpToPx(mapActivity, 8f), AndroidUtils.dpToPx(mapActivity, 16f), 0,
0);
drawerOsmAndFooter = mapActivity.getLayoutInflater()
.inflate(R.layout.powered_by_osmand_item, null);
drawerOsmAndFooter = mapActivity.getLayoutInflater().inflate(R.layout.powered_by_osmand_item, null);
}
public void addAsTarget(double latitude, double longitude, PointDescription pd) {
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
targets.navigateToPoint(new LatLon(latitude, longitude), true,
targets.getIntermediatePoints().size() + 1,
targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1,
pd);
openIntermediatePointsDialog();
}
public void addMapMarker(double latitude, double longitude, PointDescription pd,
@Nullable String mapObjectName) {
public void addMapMarker(double latitude, double longitude, PointDescription pd, @Nullable String mapObjectName) {
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
markersHelper.addMapMarker(new LatLon(latitude, longitude), pd, mapObjectName);
}
@ -199,11 +194,8 @@ public class MapActivityActions implements DialogProvider {
double longitude = args.getDouble(KEY_LONGITUDE);
String name = editText.getText().toString();
SavingTrackHelper savingTrackHelper = mapActivity.getMyApplication().getSavingTrackHelper();
savingTrackHelper
.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)
savingTrackHelper.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)
.show();
dialog.dismiss();
}
@ -213,8 +205,7 @@ public class MapActivityActions implements DialogProvider {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
alertDialog.getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
alertDialog.getWindow().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);
} else {
dlg.dismiss();
new SaveDirectionsAsyncTask(app)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, toSave);
new SaveDirectionsAsyncTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, toSave);
}
}
});
@ -298,6 +288,7 @@ public class MapActivityActions implements DialogProvider {
}
});
return dlg;
}
@ -314,8 +305,7 @@ public class MapActivityActions implements DialogProvider {
if (params.length > 0) {
File file = params[0];
String fileName = file.getName();
GPXFile gpx = app.getRoutingHelper().generateGPXFileWithRoute(
fileName.substring(0, fileName.length() - GPX_SUFFIX.length()));
GPXFile gpx = app.getRoutingHelper().generateGPXFileWithRoute(fileName.substring(0,fileName.length()-GPX_SUFFIX.length()));
GPXUtilities.writeGpxFile(file, gpx, app);
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,
final ContextMenuAdapter iadapter, Object selectedObj) {
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter() : iadapter;
ItemBuilder itemBuilder = new ItemBuilder();
@ -351,10 +340,9 @@ public class MapActivityActions implements DialogProvider {
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
ItemClickListener listener = new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int resId, int pos,
boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int resId, int pos, boolean isChecked, int[] viewCoordinates) {
if (resId == R.string.context_menu_item_add_waypoint) {
mapActivity.getContextMenu().addWptPt();
} else if (resId == R.string.context_menu_item_edit_waypoint) {
@ -365,9 +353,8 @@ public class MapActivityActions implements DialogProvider {
};
if (selectedObj instanceof WptPt
&& getMyApplication().getSelectedGpxHelper().getSelectedGPXFile((WptPt) selectedObj)
!= null) {
adapter.addItem(new ContextMenuItem.ItemBuilder()
&& getMyApplication().getSelectedGpxHelper().getSelectedGPXFile((WptPt) selectedObj) != null) {
adapter.addItem(new ItemBuilder()
.setTitleId(R.string.context_menu_item_edit_waypoint, mapActivity)
.setId(MAP_CONTEXT_MENU_EDIT_GPX_WP)
.setIcon(R.drawable.ic_action_edit_dark)
@ -375,7 +362,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(listener).createItem());
} else if (!getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles().isEmpty()
|| (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null)) {
adapter.addItem(new ContextMenuItem.ItemBuilder()
adapter.addItem(new ItemBuilder()
.setTitleId(R.string.context_menu_item_add_waypoint, mapActivity)
.setId(MAP_CONTEXT_MENU_ADD_GPX_WAYPOINT)
.setIcon(R.drawable.ic_action_gnew_label_dark)
@ -396,38 +383,31 @@ public class MapActivityActions implements DialogProvider {
adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent());
AdditionalActionsBottomSheetDialogFragment actionsBottomSheetDialogFragment = new AdditionalActionsBottomSheetDialogFragment();
actionsBottomSheetDialogFragment.setAdapter(adapter,
new AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener() {
@Override
public void onItemClick(int position) {
ContextMenuItem item = adapter.getItem(position);
int standardId = item.getTitleId();
ItemClickListener click = item.getItemClickListener();
if (click != null) {
click.onContextMenuClick(listAdapter, standardId, position, false, null);
} else if (standardId == R.string.context_menu_item_search) {
mapActivity.showQuickSearch(latitude, longitude);
} else if (standardId == R.string.context_menu_item_directions_from) {
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
enterDirectionsFromPoint(latitude, longitude);
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity,
Manifest.permission.ACCESS_FINE_LOCATION)) {
mapActivity.getMyApplication()
.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));
}
actionsBottomSheetDialogFragment.setAdapter(adapter, new AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener() {
@Override
public void onItemClick(int position) {
ContextMenuItem item = adapter.getItem(position);
int standardId = item.getTitleId();
ItemClickListener click = item.getItemClickListener();
if (click != null) {
click.onContextMenuClick(listAdapter, standardId, position, false, null);
} else if (standardId == R.string.context_menu_item_search) {
mapActivity.showQuickSearch(latitude, longitude);
} else if (standardId == R.string.context_menu_item_directions_from) {
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
enterDirectionsFromPoint(latitude, longitude);
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity, Manifest.permission.ACCESS_FINE_LOCATION)) {
mapActivity.getMyApplication().showToastMessage(R.string.ask_for_location_permission);
} else {
ActivityCompat.requestPermissions(mapActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION);
}
});
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(),
AdditionalActionsBottomSheetDialogFragment.TAG);
} else if (standardId == R.string.measurement_tool) {
mapActivity.getContextMenu().close();
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), new LatLon(latitude, longitude));
}
}
});
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(), AdditionalActionsBottomSheetDialogFragment.TAG);
}
public void enterDirectionsFromPoint(final double latitude, final double longitude) {
@ -435,8 +415,7 @@ public class MapActivityActions implements DialogProvider {
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() == null) {
setFirstMapMarkerAsTarget();
}
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper()
.isRoutePlanningMode()) {
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
enterRoutePlanningMode(new LatLon(latitude, longitude),
mapActivity.getContextMenu().getPointDescription());
} else {
@ -450,9 +429,8 @@ public class MapActivityActions implements DialogProvider {
mapActivity.getRoutingHelper().setGpxParams(null);
settings.FOLLOW_THE_GPX_ROUTE.set(null);
} else {
GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result,
mapActivity.getMyApplication()
.getSettings());
GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result, mapActivity.getMyApplication()
.getSettings());
if (result.hasRtePt() && !result.hasTrkPt()) {
settings.GPX_CALCULATE_RTEPT.set(true);
} else {
@ -468,11 +446,9 @@ public class MapActivityActions implements DialogProvider {
Location startLoc = ps.get(0);
Location finishLoc = ps.get(ps.size() - 1);
TargetPointsHelper tg = mapActivity.getMyApplication().getTargetPointsHelper();
tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false,
-1);
tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1);
if (startLoc != finishLoc) {
tg.setStartPoint(new LatLon(startLoc.getLatitude(), startLoc.getLongitude()), false,
null);
tg.setStartPoint(new LatLon(startLoc.getLatitude(), startLoc.getLongitude()), false, null);
} else {
tg.clearStartPoint(false);
}
@ -500,19 +476,16 @@ public class MapActivityActions implements DialogProvider {
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName,
useIntermediatePointsByDefault, true);
enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName, useIntermediatePointsByDefault, true);
}
});
} else {
bld.setTitle(R.string.navigation_over_track);
ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity,
R.layout.drawer_list_item, gpxFiles) {
ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity, R.layout.drawer_list_item, gpxFiles) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mapActivity.getLayoutInflater()
.inflate(R.layout.drawer_list_item, null);
convertView = mapActivity.getLayoutInflater().inflate(R.layout.drawer_list_item, null);
}
String path = getItem(position).path;
String name = path.substring(path.lastIndexOf("/") + 1, path.length());
@ -525,8 +498,7 @@ public class MapActivityActions implements DialogProvider {
bld.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName,
useIntermediatePointsByDefault, true);
enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName, useIntermediatePointsByDefault, true);
}
});
}
@ -534,8 +506,7 @@ public class MapActivityActions implements DialogProvider {
bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault,
true);
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
}
});
bld.show();
@ -544,9 +515,8 @@ public class MapActivityActions implements DialogProvider {
}
}
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from,
PointDescription fromName,
boolean useIntermediatePointsByDefault, boolean showDialog) {
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName,
boolean useIntermediatePointsByDefault, boolean showDialog) {
settings.USE_INTERMEDIATE_POINTS_NAVIGATION.set(useIntermediatePointsByDefault);
OsmandApplication app = mapActivity.getMyApplication();
TargetPointsHelper targets = app.getTargetPointsHelper();
@ -606,10 +576,8 @@ public class MapActivityActions implements DialogProvider {
}
public ApplicationMode getRouteMode(LatLon from) {
MarkersPlanRouteContext planRouteContext = mapActivity.getMyApplication().getMapMarkersHelper()
.getPlanRouteContext();
if (planRouteContext.isNavigationFromMarkers()
&& planRouteContext.getSnappedMode() != ApplicationMode.DEFAULT) {
MarkersPlanRouteContext planRouteContext = mapActivity.getMyApplication().getMapMarkersHelper().getPlanRouteContext();
if (planRouteContext.isNavigationFromMarkers() && planRouteContext.getSnappedMode() != ApplicationMode.DEFAULT) {
planRouteContext.setNavigationFromMarkers(false);
return planRouteContext.getSnappedMode();
}
@ -636,39 +604,37 @@ public class MapActivityActions implements DialogProvider {
builder.setMessage(R.string.context_menu_item_update_map_confirm);
builder.setNegativeButton(R.string.shared_string_cancel, null);
final OsmandMapTileView mapView = mapActivity.getMapView();
builder.setPositiveButton(R.string.context_menu_item_update_map,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int zoom = args.getInt(KEY_ZOOM);
BaseMapLayer mainLayer = mapView.getMainLayer();
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT)
.show();
return;
}
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT)
.show();
return;
}
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
final QuadRect tilesRect = tb.getTileBounds();
int left = (int) Math.floor(tilesRect.left);
int top = (int) Math.floor(tilesRect.top);
int width = (int) (Math.ceil(tilesRect.right) - left);
int height = (int) (Math.ceil(tilesRect.bottom) - top);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
((OsmandApplication) mapActivity.getApplication()).getResourceManager().
clearTileForMap(null, mapSource, i + left, j + top, zoom);
}
}
mapView.refreshMap();
builder.setPositiveButton(R.string.context_menu_item_update_map, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int zoom = args.getInt(KEY_ZOOM);
BaseMapLayer mainLayer = mapView.getMainLayer();
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
return;
}
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
Toast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
return;
}
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
final QuadRect tilesRect = tb.getTileBounds();
int left = (int) Math.floor(tilesRect.left);
int top = (int) Math.floor(tilesRect.top);
int width = (int) (Math.ceil(tilesRect.right) - left);
int height = (int) (Math.ceil(tilesRect.bottom) - top);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
((OsmandApplication) mapActivity.getApplication()).getResourceManager().
clearTileForMap(null, mapSource, i + left, j + top, zoom);
}
});
}
mapView.refreshMap();
}
});
return builder.create();
}
@ -722,15 +688,13 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.home, mapActivity)
.setId(DRAWER_DASHBOARD_ID)
.setIcon(R.drawable.map_dashboard)
.setListener(new ContextMenuAdapter.ItemClickListener() {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_dashboard_open");
MapActivity.clearPrevActivityIntent();
mapActivity.closeDrawer();
mapActivity.getDashboard()
.setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
return true;
}
}).createItem());
@ -738,10 +702,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
.setId(DRAWER_MAP_MARKERS_ID)
.setIcon(R.drawable.ic_action_flag_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_markers_open");
MapActivity.clearPrevActivityIntent();
MapMarkersDialogFragment.showInstance(mapActivity);
@ -749,44 +712,40 @@ public class MapActivityActions implements DialogProvider {
}
}).createItem());
optionsMenuHelper
.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
.setId(DRAWER_MY_PLACES_ID)
.setIcon(R.drawable.ic_action_fav_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_myplaces_open");
Intent newIntent = new Intent(mapActivity,
mapActivity.getMyApplication().getAppCustomization()
.getFavoritesActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
.setId(DRAWER_MY_PLACES_ID)
.setIcon(R.drawable.ic_action_fav_dark)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_myplaces_open");
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getFavoritesActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity)
.setId(DRAWER_SEARCH_ID)
.setIcon(R.drawable.ic_action_search_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_search_open");
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
.setId(DRAWER_DIRECTIONS_ID)
.setIcon(R.drawable.ic_action_gdirections_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_directions_open");
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
if (mapControlsLayer != null) {
@ -809,21 +768,18 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
*/
optionsMenuHelper
.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
.setId(DRAWER_CONFIGURE_MAP_ID)
.setIcon(R.drawable.ic_action_layers_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_config_map_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard()
.setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
return false;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
.setId(DRAWER_CONFIGURE_MAP_ID)
.setIcon(R.drawable.ic_action_layers_dark)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_config_map_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
return false;
}
}).createItem());
String d = getString(R.string.welmode_download_maps);
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)
.setId(DRAWER_DOWNLOAD_MAPS_ID)
.setTitle(d).setIcon(R.drawable.ic_type_archive)
.setListener(new ContextMenuAdapter.ItemClickListener() {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_download_maps_open");
Intent newIntent = new Intent(mapActivity,
mapActivity.getMyApplication().getAppCustomization()
.getDownloadActivity());
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getDownloadActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
@ -853,10 +807,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.osm_live, mapActivity)
.setId(DRAWER_OSMAND_LIVE_ID)
.setIcon(R.drawable.ic_action_osm_live)
.setListener(new ContextMenuAdapter.ItemClickListener() {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_osm_live_open");
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -866,94 +819,81 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
}
optionsMenuHelper.addItem(
new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)")
.setId(DRAWER_TRAVEL_GUIDES_ID)
.setIcon(R.drawable.ic_action_travel)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
MapActivity.clearPrevActivityIntent();
TravelDbHelper travelDbHelper = getMyApplication().getTravelDbHelper();
travelDbHelper.initTravelBooks();
if (travelDbHelper.getSelectedTravelBook() == null) {
WikivoyageWelcomeDialogFragment
.showInstance(mapActivity.getSupportFragmentManager());
} else {
Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
}
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)")
.setId(DRAWER_TRAVEL_GUIDES_ID)
.setIcon(R.drawable.ic_action_travel)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
MapActivity.clearPrevActivityIntent();
TravelDbHelper travelDbHelper = getMyApplication().getTravelDbHelper();
travelDbHelper.initTravelBooks();
if (travelDbHelper.getSelectedTravelBook() == null) {
WikivoyageWelcomeDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
} else {
Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
}
return true;
}
}).createItem());
optionsMenuHelper.addItem(
new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
.setId(DRAWER_MEASURE_DISTANCE_ID)
.setIcon(R.drawable.ic_action_ruler)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int position, boolean isChecked, int[] viewCoordinates) {
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
.setId(DRAWER_MEASURE_DISTANCE_ID)
.setIcon(R.drawable.ic_action_ruler)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
app.getAidlApi().registerNavDrawerItems(mapActivity, optionsMenuHelper);
optionsMenuHelper
.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
.setId(DRAWER_CONFIGURE_SCREEN_ID)
.setIcon(R.drawable.ic_configure_screen_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_config_screen_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard()
.setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
return false;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
.setId(DRAWER_CONFIGURE_SCREEN_ID)
.setIcon(R.drawable.ic_configure_screen_dark)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_config_screen_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
return false;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
.setId(DRAWER_PLUGINS_ID)
.setIcon(R.drawable.ic_extension_dark)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_plugins_open");
Intent newIntent = new Intent(mapActivity,
mapActivity.getMyApplication().getAppCustomization()
.getPluginsActivity());
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getPluginsActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
optionsMenuHelper
.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
.setId(DRAWER_SETTINGS_ID)
.setIcon(R.drawable.ic_action_settings)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_settings_open");
final Intent settings = new Intent(mapActivity,
getMyApplication().getAppCustomization()
.getSettingsActivity());
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(settings);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
.setId(DRAWER_SETTINGS_ID)
.setIcon(R.drawable.ic_action_settings)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_settings_open");
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization()
.getSettingsActivity());
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(settings);
return true;
}
}).createItem());
/*
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)
.setId(DRAWER_HELP_ID)
.setIcon(R.drawable.ic_action_help)
.setListener(new ContextMenuAdapter.ItemClickListener() {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId,
int pos, boolean isChecked, int[] viewCoordinates) {
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_help_open");
Intent intent = new Intent(mapActivity, HelpActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -1019,8 +958,7 @@ public class MapActivityActions implements DialogProvider {
for (ApplicationMode mode : modes) {
if (settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(mode)) {
settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, false);
settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false)
.setModeValue(mode, false);
settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false).setModeValue(mode, false);
}
}
}
@ -1066,40 +1004,37 @@ public class MapActivityActions implements DialogProvider {
}
public void restoreOrReturnDialog(final String packageName) {
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
builder.setTitle("Restore OsmAnd");
builder.setMessage("Do you want to Restore OsmAnd or get back to the Client App?");
builder.setPositiveButton("Restore", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
restoreOsmand();
}
});
builder.setNeutralButton("Return", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
executeHeadersIntent(packageName);
}
});
builder.setNegativeButton("Cancel", null);
builder.show();
}
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
builder.setTitle("Restore OsmAnd");
builder.setMessage("Do you want to Restore OsmAnd or get back to the Client App?");
builder.setPositiveButton("Restore", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
restoreOsmand();
}
});
builder.setNeutralButton("Return", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
executeHeadersIntent(packageName);
}
});
builder.setNegativeButton("Cancel", null);
builder.show();
}
protected void updateDrawerMenu() {
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems);
if (nightMode) {
menuItemsListView
.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_dark));
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_dark));
} else {
menuItemsListView
.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
}
menuItemsListView.removeHeaderView(drawerLogoHeader);
menuItemsListView.removeFooterView(drawerOsmAndFooter);
Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo();
final ArrayList<String> navDrawerLogoParams = getMyApplication().getAppCustomization()
.getNavDrawerLogoParams();
final ArrayList<String> navDrawerLogoParams = getMyApplication().getAppCustomization().getNavDrawerLogoParams();
boolean customHeader = false;
if (navDrawerLogo != null) {
@ -1110,9 +1045,8 @@ public class MapActivityActions implements DialogProvider {
menuItemsListView.setDivider(null);
final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu();
contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item);
final ArrayAdapter<ContextMenuItem> simpleListAdapter = contextMenuAdapter
.createListAdapter(mapActivity,
!nightMode);
final ArrayAdapter<ContextMenuItem> simpleListAdapter = contextMenuAdapter.createListAdapter(mapActivity,
!nightMode);
menuItemsListView.setAdapter(simpleListAdapter);
menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
@ -1120,22 +1054,18 @@ public class MapActivityActions implements DialogProvider {
mapActivity.dismissCardDialog();
boolean hasHeader = menuItemsListView.getHeaderViewsCount() > 0;
boolean hasFooter = menuItemsListView.getFooterViewsCount() > 0;
if (hasHeader && position == 0 || (hasFooter
&& position == menuItemsListView.getCount() - 1)) {
if (navDrawerLogoParams != null) {
executeHeadersIntent(navDrawerLogoParams.get(0));
if (hasHeader && position ==0 || (hasFooter && position== menuItemsListView.getCount() - 1)) {
if(navDrawerLogoParams!=null) executeHeadersIntent(navDrawerLogoParams.get(0));
else restoreOsmand();
} else {
restoreOsmand();
}
} else {
position -= menuItemsListView.getHeaderViewsCount();
ContextMenuItem item = contextMenuAdapter.getItem(position);
ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
mapActivity.closeDrawer();
}
}
position -= menuItemsListView.getHeaderViewsCount();
ContextMenuItem item = contextMenuAdapter.getItem(position);
ItemClickListener click = item.getItemClickListener();
if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
position, false, AndroidUtils.getCenterViewCoordinates(view))) {
mapActivity.closeDrawer();
}
}
}
});
@ -1147,11 +1077,8 @@ public class MapActivityActions implements DialogProvider {
if (menuItemsListView.getChildCount() > 0) {
int numItemsVisible = menuItemsListView.getLastVisiblePosition() -
menuItemsListView.getFirstVisiblePosition();
View lastView = menuItemsListView
.getChildAt(menuItemsListView.getLastVisiblePosition());
boolean overlapped =
lastView != null && lastView.getY() + lastView.getHeight() * 2 > menuItemsListView
.getHeight();
View lastView = menuItemsListView.getChildAt(menuItemsListView.getLastVisiblePosition());
boolean overlapped = lastView != null && lastView.getY() + lastView.getHeight() * 2 > menuItemsListView.getHeight();
if (simpleListAdapter.getCount() - 1 > numItemsVisible || overlapped) {
menuItemsListView.addFooterView(drawerOsmAndFooter);
} else {
@ -1184,18 +1111,16 @@ public class MapActivityActions implements DialogProvider {
private void executeHeadersIntent(String packageName) {
Intent launchIntent = mapActivity.getPackageManager().getLaunchIntentForPackage(packageName);
if (launchIntent != null) {
mapActivity.startActivity(launchIntent);
}
if(launchIntent!=null) mapActivity.startActivity(launchIntent);
mapActivity.closeDrawer();
}
private void showReturnConfirmationDialog(String packageName) {
restoreOrReturnDialog(packageName);
mapActivity.closeDrawer();
mapActivity.closeDrawer();
}
private void restoreOsmand() {
private void restoreOsmand(){
getMyApplication().getAppCustomization().restoreOsmand();
mapActivity.closeDrawer();
}
@ -1203,12 +1128,10 @@ public class MapActivityActions implements DialogProvider {
public void setFirstMapMarkerAsTarget() {
if (getMyApplication().getMapMarkersHelper().getMapMarkers().size() > 0) {
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkers()
.get(0);
MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkers().get(0);
PointDescription pointDescription = marker.getOriginalPointDescription();
if (pointDescription.isLocation()
&& pointDescription.getName()
.equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
&& pointDescription.getName().equals(PointDescription.getAddressNotFoundStr(mapActivity))) {
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
}
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();

View file

@ -16,47 +16,49 @@ import net.osmand.plus.helpers.FontCache;
public class OsmandRestoreOrExitDialog extends BottomSheetDialogFragment {
private String clientAppTitle = "";
private String clientAppTitle = "";
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater()
.inflate(R.layout.dash_restore_osmand_fragment, container, false);
try {
clientAppTitle = getMyApplication().getAppCustomization().getNavFooterParams().getAppName();
} catch (Exception e) { e.printStackTrace(); }
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater()
.inflate(R.layout.dash_restore_osmand_fragment, container, false);
try {
clientAppTitle = getMyApplication().getAppCustomization().getNavFooterParams().getAppName();
} catch (Exception e) {
e.printStackTrace();
}
String msg = MessageFormat.format(getString(R.string.run_full_osmand_msg), clientAppTitle);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
Typeface typefaceReg = FontCache.getRobotoRegular(getActivity());
TextView header = view.findViewById(R.id.run_full_osmand_header);
header.setTypeface(typeface);
String msg = MessageFormat.format(getString(R.string.run_full_osmand_msg), clientAppTitle);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
Typeface typefaceReg = FontCache.getRobotoRegular(getActivity());
TextView header = view.findViewById(R.id.run_full_osmand_header);
header.setTypeface(typeface);
TextView message = view.findViewById(R.id.run_full_osmand_message);
message.setTypeface(typefaceReg);
message.setText(msg);
TextView message = view.findViewById(R.id.run_full_osmand_message);
message.setTypeface(typefaceReg);
message.setText(msg);
Button cancelBtn = view.findViewById(R.id.cancel_full_osmand_btn);
cancelBtn.setTypeface(typeface);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
Button cancelBtn = view.findViewById(R.id.cancel_full_osmand_btn);
cancelBtn.setTypeface(typeface);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
Button launchBtn = view.findViewById(R.id.launch_full_osmand_btn);
launchBtn.setTypeface(typeface);
launchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getMyApplication().getAppCustomization().restoreOsmand();
dismiss();
}
});
Button launchBtn = view.findViewById(R.id.launch_full_osmand_btn);
launchBtn.setTypeface(typeface);
launchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getMyApplication().getAppCustomization().restoreOsmand();
dismiss();
}
});
return view;
}
return view;
}
}