Update sherpafy customization
This commit is contained in:
parent
a1660b1df7
commit
99a75903b7
12 changed files with 213 additions and 107 deletions
|
@ -54,11 +54,11 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:b
|
|||
<TableRow android:layout_height = "wrap_content" android:layout_marginTop="15dp">
|
||||
<LinearLayout android:id="@+id/FavoritesButton" android:background="@drawable/bg_leftr" android:orientation="vertical" android:clickable="true"
|
||||
android:layout_weight="3" android:layout_height="175dp" android:focusable="true">
|
||||
<ImageView
|
||||
<ImageView android:id="@+id/FavoritesButtonImage"
|
||||
android:src="@drawable/button_icon_favorites" android:scaleType="center" android:layout_gravity="center"
|
||||
android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="0dp"/>
|
||||
<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center">
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/FavoritesButtonText"
|
||||
android:layout_gravity="center_horizontal|top" android:textSize="18sp"
|
||||
android:text="@string/favorites_Button" android:typeface="serif" android:textColor="#000000"/>
|
||||
</LinearLayout>
|
||||
|
@ -66,12 +66,12 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:b
|
|||
<LinearLayout android:layout_weight="2" android:layout_height="fill_parent"/>
|
||||
<LinearLayout android:id="@+id/SettingsButton" android:background="@drawable/bg_rightr" android:orientation="vertical" android:clickable="true"
|
||||
android:layout_weight="3" android:layout_height="175dp" android:focusable="true">
|
||||
<ImageView
|
||||
<ImageView android:id="@+id/SettingsButtonImage"
|
||||
android:src="@drawable/button_icon_settings" android:scaleType="center" android:layout_gravity="center"
|
||||
android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="0dp"/>
|
||||
<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center">
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_horizontal|top" android:textSize="18sp"
|
||||
android:layout_gravity="center_horizontal|top" android:textSize="18sp" android:id="@+id/SettingsButtonText"
|
||||
android:text="@string/settings_Button" android:typeface="serif" android:textColor="#000000"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
5
OsmAnd/res/values/sherpafy.xml
Normal file
5
OsmAnd/res/values/sherpafy.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="settings_file_create_error">Couldn\'t create settings file in tour folder.</string>
|
||||
<string name="tour">Tour</string>
|
||||
</resources>
|
32
OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java
Normal file
32
OsmAnd/src/net/osmand/plus/OsmAndAppCustomization.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.view.Window;
|
||||
import net.osmand.plus.api.SettingsAPI;
|
||||
|
||||
public class OsmAndAppCustomization {
|
||||
|
||||
protected OsmandApplication app;
|
||||
|
||||
public void setup(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public OsmandSettings createSettings(SettingsAPI api) {
|
||||
return new OsmandSettings(app, api);
|
||||
}
|
||||
|
||||
public boolean checkExceptionsOnStart() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean showFirstTimeRunAndTips(boolean firstTime, boolean appVersionChanged) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkBasemapDownloadedOnStart() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void customizeMainMenu(Window window) {
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ import net.osmand.plus.activities.SettingsActivity;
|
|||
import net.osmand.plus.api.SQLiteAPI;
|
||||
import net.osmand.plus.api.SQLiteAPIImpl;
|
||||
import net.osmand.plus.api.SettingsAPI;
|
||||
import net.osmand.plus.api.SettingsAPIImpl;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
|
@ -81,6 +82,7 @@ public class OsmandApplication extends Application {
|
|||
public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$
|
||||
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class);
|
||||
|
||||
|
||||
ResourceManager resourceManager = null;
|
||||
PoiFiltersHelper poiFilters = null;
|
||||
RoutingHelper routingHelper = null;
|
||||
|
@ -89,6 +91,7 @@ public class OsmandApplication extends Application {
|
|||
|
||||
OsmandSettings osmandSettings = null;
|
||||
|
||||
OsmAndAppCustomization appCustomization;
|
||||
DayNightHelper daynightHelper;
|
||||
NavigationService navigationService;
|
||||
RendererRegistry rendererRegistry;
|
||||
|
@ -108,7 +111,6 @@ public class OsmandApplication extends Application {
|
|||
private boolean applicationInitializing = false;
|
||||
private Locale prefferedLocale = null;
|
||||
|
||||
SettingsAPI settingsAPI;
|
||||
SQLiteAPI sqliteAPI;
|
||||
BRouterServiceConnection bRouterServiceConnection;
|
||||
|
||||
|
@ -125,10 +127,10 @@ public class OsmandApplication extends Application {
|
|||
}
|
||||
}
|
||||
super.onCreate();
|
||||
appCustomization = new OsmAndAppCustomization();
|
||||
appCustomization.setup(this);
|
||||
|
||||
settingsAPI = new net.osmand.plus.api.SettingsAPIImpl(this);
|
||||
sqliteAPI = new SQLiteAPIImpl(this);
|
||||
|
||||
try {
|
||||
bRouterServiceConnection = BRouterServiceConnection.connect(this);
|
||||
} catch(Exception e) {
|
||||
|
@ -136,7 +138,7 @@ public class OsmandApplication extends Application {
|
|||
}
|
||||
|
||||
// settings used everywhere so they need to be created first
|
||||
osmandSettings = createOsmandSettingsInstance();
|
||||
osmandSettings = appCustomization.createSettings(new net.osmand.plus.api.SettingsAPIImpl(this));
|
||||
// always update application mode to default
|
||||
if(!osmandSettings.FOLLOW_THE_ROUTE.get()){
|
||||
osmandSettings.APPLICATION_MODE.set(osmandSettings.DEFAULT_APPLICATION_MODE.get());
|
||||
|
@ -189,18 +191,19 @@ public class OsmandApplication extends Application {
|
|||
return taskManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates instance of OsmandSettings
|
||||
*
|
||||
* @return Reference to instance of OsmandSettings
|
||||
*/
|
||||
protected OsmandSettings createOsmandSettingsInstance() {
|
||||
return new OsmandSettings(this);
|
||||
}
|
||||
|
||||
public OsmAndLocationProvider getLocationProvider() {
|
||||
return locationProvider;
|
||||
}
|
||||
|
||||
public OsmAndAppCustomization getAppCustomization() {
|
||||
return appCustomization;
|
||||
}
|
||||
|
||||
public void setAppCustomization(OsmAndAppCustomization appCustomization) {
|
||||
this.appCustomization = appCustomization;
|
||||
this.appCustomization.setup(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Application settings
|
||||
|
@ -692,11 +695,6 @@ public class OsmandApplication extends Application {
|
|||
AccessibleToast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public SettingsAPI getSettingsAPI() {
|
||||
return settingsAPI;
|
||||
}
|
||||
|
||||
|
||||
public SQLiteAPI getSQLiteAPI() {
|
||||
return sqliteAPI;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import net.osmand.plus.osmedit.OsmEditingPlugin;
|
|||
import net.osmand.plus.osmodroid.OsMoDroidPlugin;
|
||||
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.sherpafy.SherpafyPlugin;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -35,7 +34,6 @@ public abstract class OsmandPlugin {
|
|||
private static List<OsmandPlugin> activePlugins = new ArrayList<OsmandPlugin>();
|
||||
private static final Log LOG = PlatformUtil.getLog(OsmandPlugin.class);
|
||||
|
||||
private static final String SHERPAFY_PLUGIN_COMPONENT = "net.osmand.sherpafy"; //$NON-NLS-1$
|
||||
private static final String PARKING_PLUGIN_COMPONENT = "net.osmand.parkingPlugin"; //$NON-NLS-1$
|
||||
private static final String SRTM_PLUGIN_COMPONENT_PAID = "net.osmand.srtmPlugin.paid"; //$NON-NLS-1$
|
||||
private static final String SRTM_PLUGIN_COMPONENT = "net.osmand.srtmPlugin"; //$NON-NLS-1$
|
||||
|
@ -64,7 +62,6 @@ public abstract class OsmandPlugin {
|
|||
public static void initPlugins(OsmandApplication app) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
OsmandRasterMapsPlugin rasterMapsPlugin = new OsmandRasterMapsPlugin(app);
|
||||
installPlugin(SHERPAFY_PLUGIN_COMPONENT, SherpafyPlugin.ID, app, new SherpafyPlugin(app));
|
||||
installedPlugins.add(rasterMapsPlugin);
|
||||
installedPlugins.add(new OsmandMonitoringPlugin(app));
|
||||
installedPlugins.add(new AccessibilityPlugin(app));
|
||||
|
|
|
@ -105,9 +105,9 @@ public class OsmandSettings {
|
|||
private boolean internetConnectionAvailable = true;
|
||||
|
||||
|
||||
protected OsmandSettings(OsmandApplication clientContext) {
|
||||
protected OsmandSettings(OsmandApplication clientContext, SettingsAPI settinsAPI) {
|
||||
ctx = clientContext;
|
||||
settingsAPI = ctx.getSettingsAPI();
|
||||
this.settingsAPI = settinsAPI;
|
||||
|
||||
globalPreferences = settingsAPI.getPreferenceObject(SHARED_PREFERENCES_NAME);
|
||||
// start from default settings
|
||||
|
@ -123,6 +123,14 @@ public class OsmandSettings {
|
|||
return ctx;
|
||||
}
|
||||
|
||||
public void setSettingsAPI(SettingsAPI settingsAPI) {
|
||||
this.settingsAPI = settingsAPI;
|
||||
}
|
||||
|
||||
public SettingsAPI getSettingsAPI() {
|
||||
return settingsAPI;
|
||||
}
|
||||
|
||||
public static String getSharedPreferencesName(ApplicationMode mode){
|
||||
if(mode == null){
|
||||
return SHARED_PREFERENCES_NAME;
|
||||
|
@ -557,6 +565,16 @@ public class OsmandSettings {
|
|||
return p;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CommonPreference<String> registerBooleanPreference(String id, String defValue) {
|
||||
if(registeredPreferences.containsKey(id)) {
|
||||
return (CommonPreference<String>) registeredPreferences.get(id);
|
||||
}
|
||||
StringPreference p = new StringPreference(id, defValue);
|
||||
registeredPreferences.put(id, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CommonPreference<Integer> registerIntPreference(String id, int defValue) {
|
||||
if(registeredPreferences.containsKey(id)) {
|
||||
|
|
|
@ -6,11 +6,13 @@ import java.util.Random;
|
|||
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.sherpafy.SherpafyCustomization;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
|
@ -182,6 +184,9 @@ public class MainMenuActivity extends Activity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if(getIntent() != null) {
|
||||
setupCustomization(getIntent());
|
||||
}
|
||||
((OsmandApplication) getApplication()).applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
boolean exit = false;
|
||||
|
@ -195,6 +200,8 @@ public class MainMenuActivity extends Activity {
|
|||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.menu);
|
||||
|
||||
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
||||
|
||||
onCreateMainMenu(getWindow(), this);
|
||||
|
||||
Window window = getWindow();
|
||||
|
@ -242,6 +249,7 @@ public class MainMenuActivity extends Activity {
|
|||
activity.startActivity(search);
|
||||
}
|
||||
});
|
||||
appCustomization.customizeMainMenu(window);
|
||||
if(exit){
|
||||
getMyApplication().closeApplication(activity);
|
||||
return;
|
||||
|
@ -255,43 +263,56 @@ public class MainMenuActivity extends Activity {
|
|||
}
|
||||
startProgressDialog = new ProgressDialog(this);
|
||||
getMyApplication().checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
|
||||
boolean dialogShown = false;
|
||||
boolean firstTime = false;
|
||||
if(!pref.contains(FIRST_TIME_APP_RUN)){
|
||||
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
|
||||
boolean appVersionChanged = false;
|
||||
if (!pref.contains(FIRST_TIME_APP_RUN)) {
|
||||
firstTime = true;
|
||||
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
||||
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||
|
||||
applicationInstalledFirstTime();
|
||||
} else {
|
||||
int i = pref.getInt(TIPS_SHOW, 0);
|
||||
if (i < 7){
|
||||
pref.edit().putInt(TIPS_SHOW, ++i).commit();
|
||||
}
|
||||
boolean appVersionChanged = false;
|
||||
if(!Version.getFullVersion(app).equals(pref.getString(VERSION_INSTALLED, ""))){
|
||||
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||
appVersionChanged = true;
|
||||
}
|
||||
|
||||
if (i == 1 || i == 5 || appVersionChanged) {
|
||||
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
|
||||
Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
|
||||
dlg.show();
|
||||
} else if (!Version.getFullVersion(app).equals(pref.getString(VERSION_INSTALLED, ""))) {
|
||||
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||
appVersionChanged = true;
|
||||
}
|
||||
if (appCustomization.showFirstTimeRunAndTips(firstTime, appVersionChanged)) {
|
||||
if (firstTime) {
|
||||
applicationInstalledFirstTime();
|
||||
dialogShown = true;
|
||||
} else {
|
||||
if (startProgressDialog.isShowing()) {
|
||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
checkVectorIndexesDownloaded();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
checkVectorIndexesDownloaded();
|
||||
int i = pref.getInt(TIPS_SHOW, 0);
|
||||
if (i < 7) {
|
||||
pref.edit().putInt(TIPS_SHOW, ++i).commit();
|
||||
}
|
||||
if (i == 1 || i == 5 || appVersionChanged) {
|
||||
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
|
||||
Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
|
||||
dlg.show();
|
||||
dialogShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
checkPreviousRunsForExceptions(firstTime);
|
||||
if(!dialogShown && appCustomization.checkBasemapDownloadedOnStart()) {
|
||||
if (startProgressDialog.isShowing()) {
|
||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
checkVectorIndexesDownloaded();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
checkVectorIndexesDownloaded();
|
||||
}
|
||||
}
|
||||
if(appCustomization.checkExceptionsOnStart()){
|
||||
checkPreviousRunsForExceptions(firstTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCustomization(Intent intent) {
|
||||
if (intent.hasExtra("SHERPAFY")) {
|
||||
((OsmandApplication) getApplication()).setAppCustomization(new SherpafyCustomization());
|
||||
}
|
||||
}
|
||||
|
||||
private void applicationInstalledFirstTime() {
|
||||
|
|
|
@ -20,12 +20,14 @@ public class FileSettingsAPIImpl implements SettingsAPI {
|
|||
|
||||
public FileSettingsAPIImpl(OsmandApplication app, File file) throws IOException {
|
||||
this.file = file;
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
props.load(fis);
|
||||
for (Object key : props.keySet()) {
|
||||
String k = key.toString();
|
||||
map.put(k, props.get(key));
|
||||
if (file.exists()) {
|
||||
Properties props = new Properties();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
props.load(fis);
|
||||
for (Object key : props.keySet()) {
|
||||
String k = key.toString();
|
||||
map.put(k, props.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +97,10 @@ public class FileSettingsAPIImpl implements SettingsAPI {
|
|||
map.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
return saveFile();
|
||||
}
|
||||
|
||||
public boolean saveFile() {
|
||||
try {
|
||||
Properties ps = new Properties();
|
||||
ps.putAll(map);
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.api.FileSettingsAPIImpl;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SherpafyCustomization extends OsmAndAppCustomization {
|
||||
|
||||
private static final String SELECTED_TOUR = "sherpafy_tour";
|
||||
private OsmandSettings originalSettings;
|
||||
private CommonPreference<String> selectedTourPref;
|
||||
private File selectedTourFolder = null;
|
||||
|
||||
@Override
|
||||
public void setup(OsmandApplication app) {
|
||||
super.setup(app);
|
||||
originalSettings = createSettings(app.getSettings().getSettingsAPI());
|
||||
selectedTourPref = originalSettings.registerBooleanPreference(SELECTED_TOUR, null).makeGlobal();
|
||||
File toursFolder = new File(originalSettings.getExternalStorageDirectory(), "tours");
|
||||
if(selectedTourPref.get() != null) {
|
||||
selectedTourFolder = new File(toursFolder, selectedTourPref.get());
|
||||
selectedTourFolder.mkdirs();
|
||||
}
|
||||
|
||||
if(selectedTourFolder != null) {
|
||||
File settingsFile = new File(selectedTourFolder, "settings.props");
|
||||
FileSettingsAPIImpl fapi;
|
||||
try {
|
||||
fapi = new FileSettingsAPIImpl(app, settingsFile);
|
||||
if (!settingsFile.exists()) {
|
||||
fapi.saveFile();
|
||||
}
|
||||
app.getSettings().setSettingsAPI(fapi);
|
||||
} catch (IOException e) {
|
||||
app.showToastMessage(R.string.settings_file_create_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkExceptionsOnStart() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean showFirstTimeRunAndTips(boolean firstTime, boolean appVersionChanged) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkBasemapDownloadedOnStart() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customizeMainMenu(Window window) {
|
||||
// Update app name
|
||||
TextView v = (TextView) window.findViewById(R.id.AppName);
|
||||
v.setText("Sherpafy " + Version.getAppVersion(app));
|
||||
|
||||
TextView toursButton = (TextView) window.findViewById(R.id.SettingsButtonText);
|
||||
toursButton.setText(R.string.tour);
|
||||
// the image could be updated
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class SherpafyPlugin extends OsmandPlugin {
|
||||
|
||||
public static final String ID = "osmand.shepafy";
|
||||
protected OsmandApplication app;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID ;
|
||||
}
|
||||
|
||||
public SherpafyPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Sherpafy plugin (TODO externalize)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Sherpafy plugin ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(final OsmandApplication app) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(OsmandApplication app) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLayers(MapActivity activity) {
|
||||
}
|
||||
|
||||
}
|
|
@ -14,12 +14,10 @@
|
|||
<activity
|
||||
android:name=".SherpafyPluginActivity"
|
||||
android:label="@string/app_name" >
|
||||
<!--
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
-->
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
|
|
|
@ -28,7 +28,9 @@ public class SherpafyPluginActivity extends Activity {
|
|||
ResolveInfo resolved = getPackageManager().resolveActivity(intentPlus, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if(resolved != null) {
|
||||
stopService(intentPlus);
|
||||
intentPlus.putExtra("SHERPAFY", true);
|
||||
startActivity(intentPlus);
|
||||
finish();
|
||||
} else {
|
||||
Intent intentNormal = new Intent();
|
||||
intentNormal.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
|
@ -36,7 +38,9 @@ public class SherpafyPluginActivity extends Activity {
|
|||
resolved = getPackageManager().resolveActivity(intentNormal, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (resolved != null) {
|
||||
stopService(intentNormal);
|
||||
intentNormal.putExtra("SHERPAFY", true);
|
||||
startActivity(intentNormal);
|
||||
finish();
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(getString(R.string.osmand_app_not_found));
|
||||
|
|
Loading…
Reference in a new issue