diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 8d97f73933..a5cd8d6eb3 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -119,34 +119,166 @@ - + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index c459b9b745..25cc483b1c 100644 --- a/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -160,4 +160,12 @@ interface IOsmAndAidlInterface { boolean getActiveSqliteDbFiles(out List files); boolean showSqliteDbFile(String fileName); boolean hideSqliteDbFile(String fileName); + + + boolean setNavDrawerLogoWithIntent(in String imageUri, String packageName, String intent); + boolean setNavDrawerFooterAction(in String packageName, String intent, String appName); + boolean setPointMenuEnabledIds(in List ids); + boolean setPointMenuDisabledIds(in List ids); + boolean setPointMenuEnabledPatterns(in List patterns); + boolean setPointMenuDisabledPatterns(in List patterns); } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index e905395eb9..51567c1908 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -1822,7 +1822,7 @@ public class OsmandAidlApi { } boolean setNavDrawerLogo(@Nullable String uri) { - return app.getAppCustomization().setNavDrawerLogo(uri); + return app.getAppCustomization().setNavDrawerLogo(uri,null, null); } boolean setEnabledIds(Collection ids) { @@ -1860,6 +1860,34 @@ public class OsmandAidlApi { return true; } + boolean setNavDrawerLogoWithIntent( + @Nullable String uri, @Nullable String packageName, @Nullable String intent) { + + return app.getAppCustomization().setNavDrawerLogoWithIntent(uri, packageName, intent); + } + + boolean setNavDrawerFooterAction(@Nullable String packageName, @Nullable String intent, @Nullable String appName) { + + return app.getAppCustomization().setNavDrawerFooterAction(packageName, intent, appName); + } + + boolean setPointMenuEnabledIds(List ids){ + return true; + } + + boolean setPointMenuDisabledIds(List ids){ + return true; + } + + boolean setPointMenuEnabledPatterns(List patterns){ + return true; + } + + boolean setPointMenuDisabledPatterns(List patterns){ + return true; + } + + private static AGpxFileDetails createGpxFileDetails(@NonNull GPXTrackAnalysis a) { return new AGpxFileDetails(a.totalDistance, a.totalTracks, a.startTime, a.endTime, a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown, diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index 0211db795b..8a61ac84de 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -771,5 +771,37 @@ public class OsmandAidlService extends Service { OsmandAidlApi api = getApi("hideSqliteDbFile"); return api != null && api.hideSqliteDbFile(fileName); } + + @Override + public boolean setNavDrawerLogoWithIntent(String imageUri, String packageName, String intent) throws RemoteException { + OsmandAidlApi api = getApi("setNavDrawerLogoWithIntent"); + return api != null && api.setNavDrawerLogoWithIntent(imageUri, packageName, intent); + } + + @Override + public boolean setNavDrawerFooterAction(String packageName, String intent, String appName) throws RemoteException { + OsmandAidlApi api = getApi ("setNavDrawerFooterAction"); + return api != null && api.setNavDrawerFooterAction(packageName, intent, appName); + } + + @Override + public boolean setPointMenuEnabledIds(List ids) throws RemoteException { + return true; + } + + @Override + public boolean setPointMenuDisabledIds(List ids) throws RemoteException { + return true; + } + + @Override + public boolean setPointMenuEnabledPatterns(List patterns) throws RemoteException { + return true; + } + + @Override + public boolean setPointMenuDisabledPatterns(List patterns) throws RemoteException { + return true; + } }; } diff --git a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java index 7d1d397231..f3cbdc6d83 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java @@ -9,6 +9,7 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; +import android.util.Log; import net.osmand.IProgress; import net.osmand.IndexConstants; @@ -42,6 +43,7 @@ public class OsmAndAppCustomization { protected OsmandSettings osmandSettings; private Bitmap navDrawerLogo; + private ArrayList navDrawerParams; private Set featuresEnabledIds = new HashSet<>(); private Set featuresDisabledIds = new HashSet<>(); @@ -199,7 +201,10 @@ public class OsmAndAppCustomization { return navDrawerLogo; } - public boolean setNavDrawerLogo(@Nullable String uri) { + @Nullable + public ArrayList getNavDrawerLogoParams() {return navDrawerParams; } + + public boolean setNavDrawerLogo(@Nullable String uri, @Nullable String packageName, @Nullable String intent) { if (TextUtils.isEmpty(uri)) { navDrawerLogo = null; } else { @@ -208,16 +213,25 @@ public class OsmAndAppCustomization { if (is != null) { navDrawerLogo = BitmapFactory.decodeStream(is); is.close(); + } } catch (FileNotFoundException e) { return false; } catch (IOException e) { // ignore } + if(packageName!=null && intent!=null) { + Log.d("setNavDrawerLogo", packageName + ", " + intent); + navDrawerParams = new ArrayList<>(); + navDrawerParams.add(packageName); + navDrawerParams.add(intent); + } } return true; } + + public void setFeaturesEnabledIds(@NonNull Collection ids) { featuresEnabledIds.clear(); featuresEnabledIds.addAll(ids); @@ -272,6 +286,15 @@ public class OsmAndAppCustomization { return set.contains(appMode); } + public boolean setNavDrawerLogoWithIntent(String uri, @Nullable String packageName, @Nullable String intent) { + return setNavDrawerLogo(uri, packageName, intent); + } + + public boolean setNavDrawerFooterAction(String packageName, String intent, String appName) { + //todo implement custom action to "Powered by Osmand" action in NavDrawer + return true; + } + @NonNull private HashSet getAppModesSet(@Nullable List appModeKeys) { HashSet set = new HashSet<>(); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index c3d989275c..513f5f36a7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -51,6 +51,7 @@ import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.Version; import net.osmand.plus.activities.actions.OsmAndDialogs; +import net.osmand.plus.audionotes.SortByMenuBottomSheetDialogFragment; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.dialogs.FavoriteDialogs; import net.osmand.plus.download.IndexItem; @@ -990,6 +991,26 @@ public class MapActivityActions implements DialogProvider { menu.show(); } + 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(); + } + protected void updateDrawerMenu() { boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems); @@ -1001,6 +1022,8 @@ public class MapActivityActions implements DialogProvider { menuItemsListView.removeHeaderView(drawerLogoHeader); menuItemsListView.removeFooterView(drawerOsmAndFooter); Bitmap navDrawerLogo = getMyApplication().getAppCustomization().getNavDrawerLogo(); + final ArrayList navDrawerLogoParams = getMyApplication().getAppCustomization().getNavDrawerLogoParams(); + boolean customHeader = false; if (navDrawerLogo != null) { customHeader = true; @@ -1019,19 +1042,20 @@ 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)) { - getMyApplication().getAppCustomization().restoreOsmand(); - mapActivity.closeDrawer(); - } 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(); - } - } + if (hasHeader && position ==0 || (hasFooter && position== menuItemsListView.getCount() - 1)) { + if(navDrawerLogoParams!=null) executeHeadersIntent(navDrawerLogoParams.get(0)); + else restoreOsmand(); + } else { + position -= menuItemsListView.getHeaderViewsCount(); + ContextMenuItem item = contextMenuAdapter.getItem(position); + ContextMenuAdapter.ItemClickListener click = item.getItemClickListener(); + if (click != null && click.onContextMenuClick(simpleListAdapter, item.getTitleId(), + position, false, AndroidUtils.getCenterViewCoordinates(view))) { + mapActivity.closeDrawer(); + } + } } + }); if (customHeader) { menuItemsListView.post(new Runnable() { @@ -1056,9 +1080,8 @@ public class MapActivityActions implements DialogProvider { footerLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - getMyApplication().getAppCustomization().restoreOsmand(); - mapActivity.closeDrawer(); - + if(navDrawerLogoParams!=null) showReturnConfirmationDialog(navDrawerLogoParams.get(0)); + else restoreOsmand(); } }); } else { @@ -1069,6 +1092,23 @@ public class MapActivityActions implements DialogProvider { } } + private void executeHeadersIntent(String packageName) { + Intent launchIntent = mapActivity.getPackageManager().getLaunchIntentForPackage(packageName); + if(launchIntent!=null) mapActivity.startActivity(launchIntent); + mapActivity.closeDrawer(); + } + + private void showReturnConfirmationDialog(String packageName) { + restoreOrReturnDialog(packageName); + mapActivity.closeDrawer(); + } + + private void restoreOsmand(){ + getMyApplication().getAppCustomization().restoreOsmand(); + mapActivity.closeDrawer(); + } + + public void setFirstMapMarkerAsTarget() { if (getMyApplication().getMapMarkersHelper().getMapMarkers().size() > 0) { MapMarkersHelper.MapMarker marker = getMyApplication().getMapMarkersHelper().getMapMarkers().get(0); diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index afa1d1aea6..205cd14a1a 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -237,6 +237,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { .setOrder(MARK_AS_PARKING_POS_ITEM_ORDER) .setListener(addListener) .createItem()); + } /** diff --git a/gradle.properties b/gradle.properties index 1a75c657f4..8cabefc3f8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,8 +5,8 @@ # # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +Default value: -Xmx10248m -XX:MaxPermSize=256m +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit