Merge branch 'master' of ssh://github.com/osmandapp/Osmand into HEAD
This commit is contained in:
commit
9500ceb91f
15 changed files with 225 additions and 3 deletions
|
@ -53,6 +53,8 @@ import net.osmand.aidl.gpx.RemoveGpxParams;
|
|||
|
||||
import net.osmand.aidl.maplayer.point.ShowMapPointParams;
|
||||
|
||||
import net.osmand.aidl.navdrawer.AddOpenAppNavDrawerItemParams;
|
||||
|
||||
// NOTE: Add new methods at the end of file!!!
|
||||
|
||||
interface IOsmAndAidlInterface {
|
||||
|
@ -105,4 +107,6 @@ interface IOsmAndAidlInterface {
|
|||
boolean removeGpx(in RemoveGpxParams params);
|
||||
|
||||
boolean showMapPoint(in ShowMapPointParams params);
|
||||
|
||||
boolean addOpenAppNavDrawerItem(in AddOpenAppNavDrawerItemParams params);
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navdrawer;
|
||||
|
||||
parcelable AddOpenAppNavDrawerItemParams;
|
|
@ -0,0 +1,63 @@
|
|||
package net.osmand.aidl.navdrawer;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class AddOpenAppNavDrawerItemParams implements Parcelable {
|
||||
|
||||
private String itemName;
|
||||
private String appPackage;
|
||||
private int flags;
|
||||
|
||||
public AddOpenAppNavDrawerItemParams(String itemName, String appPackage) {
|
||||
this(itemName, appPackage, -1);
|
||||
}
|
||||
|
||||
public AddOpenAppNavDrawerItemParams(String itemName, String appPackage, int flags) {
|
||||
this.itemName = itemName;
|
||||
this.appPackage = appPackage;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
protected AddOpenAppNavDrawerItemParams(Parcel in) {
|
||||
itemName = in.readString();
|
||||
appPackage = in.readString();
|
||||
flags = in.readInt();
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public String getAppPackage() {
|
||||
return appPackage;
|
||||
}
|
||||
|
||||
public int getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(itemName);
|
||||
dest.writeString(appPackage);
|
||||
dest.writeInt(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<AddOpenAppNavDrawerItemParams> CREATOR = new Creator<AddOpenAppNavDrawerItemParams>() {
|
||||
@Override
|
||||
public AddOpenAppNavDrawerItemParams createFromParcel(Parcel in) {
|
||||
return new AddOpenAppNavDrawerItemParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddOpenAppNavDrawerItemParams[] newArray(int size) {
|
||||
return new AddOpenAppNavDrawerItemParams[size];
|
||||
}
|
||||
};
|
||||
}
|
|
@ -41,6 +41,15 @@ class TelegramApplication : Application(), OsmandHelperListener {
|
|||
settings = TelegramSettings(this)
|
||||
uiUtils = UiUtils(this)
|
||||
osmandAidlHelper = OsmandAidlHelper(this)
|
||||
osmandAidlHelper.listener = object : OsmandAidlHelper.OsmandHelperListener {
|
||||
override fun onOsmandConnectionStateChanged(connected: Boolean) {
|
||||
if (connected) {
|
||||
val basePackage = "net.osmand.telegram"
|
||||
val appPackage = if (BuildConfig.DEBUG) "$basePackage.debug" else basePackage
|
||||
osmandAidlHelper.addOpenAppNavDrawerItem(getString(R.string.app_name), appPackage, -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
shareLocationHelper = ShareLocationHelper(this)
|
||||
showLocationHelper = ShowLocationHelper(this)
|
||||
notificationHelper = NotificationHelper(this)
|
||||
|
|
|
@ -33,6 +33,7 @@ import net.osmand.aidl.mapwidget.AMapWidget
|
|||
import net.osmand.aidl.mapwidget.AddMapWidgetParams
|
||||
import net.osmand.aidl.mapwidget.RemoveMapWidgetParams
|
||||
import net.osmand.aidl.mapwidget.UpdateMapWidgetParams
|
||||
import net.osmand.aidl.navdrawer.AddOpenAppNavDrawerItemParams
|
||||
import net.osmand.aidl.navigation.NavigateGpxParams
|
||||
import net.osmand.aidl.navigation.NavigateParams
|
||||
import net.osmand.aidl.note.StartAudioRecordingParams
|
||||
|
@ -866,4 +867,15 @@ class OsmandAidlHelper(private val app: Application) {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun addOpenAppNavDrawerItem(itemName: String, appPackage: String, flags: Int): Boolean {
|
||||
if (mIOsmAndAidlInterface != null) {
|
||||
try {
|
||||
return mIOsmAndAidlInterface!!.addOpenAppNavDrawerItem(AddOpenAppNavDrawerItemParams(itemName, appPackage, flags))
|
||||
} catch (e: RemoteException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3592,7 +3592,7 @@
|
|||
<string name="poi_checkpoint_type">Typ kontrolního stanoviště</string>
|
||||
|
||||
<string name="poi_wetland_palsa_bog">Rašeliniště</string>
|
||||
<string name="poi_cuisine_sub">Sendvič ( plněná bageta)</string>
|
||||
<string name="poi_cuisine_sub">Housky</string>
|
||||
<string name="poi_couloir">Horský průsmyk</string>
|
||||
<string name="poi_water_place_durability_durable">Zdroj vody: Odolný</string>
|
||||
<string name="poi_water_place_durability_emergency">Zdroj vody: Nouzový</string>
|
||||
|
|
|
@ -3135,7 +3135,7 @@
|
|||
\n
|
||||
\n • 改善 Wikipedia 和維基導遊分析,更新檔案已經能用
|
||||
\n
|
||||
\n • 內容選單 :在夜間模式下修復交通保護顏色,修復附加選單大小
|
||||
\n • 內容選單:在夜間模式下修復交通保護顏色,修復附加選單大小
|
||||
\n
|
||||
\n • 其他錯誤修復
|
||||
\n</string>
|
||||
|
|
|
@ -53,6 +53,8 @@ import net.osmand.aidl.gpx.RemoveGpxParams;
|
|||
|
||||
import net.osmand.aidl.maplayer.point.ShowMapPointParams;
|
||||
|
||||
import net.osmand.aidl.navdrawer.AddOpenAppNavDrawerItemParams;
|
||||
|
||||
// NOTE: Add new methods at the end of file!!!
|
||||
|
||||
interface IOsmAndAidlInterface {
|
||||
|
@ -105,4 +107,6 @@ interface IOsmAndAidlInterface {
|
|||
boolean removeGpx(in RemoveGpxParams params);
|
||||
|
||||
boolean showMapPoint(in ShowMapPointParams params);
|
||||
|
||||
boolean addOpenAppNavDrawerItem(in AddOpenAppNavDrawerItemParams params);
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.aidl;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -12,6 +13,7 @@ import android.os.ParcelFileDescriptor;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -28,6 +30,8 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
|
@ -38,6 +42,7 @@ import net.osmand.plus.MapMarkersHelper;
|
|||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
|
@ -1186,4 +1191,41 @@ public class OsmandAidlApi {
|
|||
app.sendBroadcast(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean addOpenAppNavDrawerItem(String itemName, String appPackage, int flags) {
|
||||
if (!TextUtils.isEmpty(itemName) && !TextUtils.isEmpty(appPackage)) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
settings.API_NAV_DRAWER_ITEM_NAME.set(itemName);
|
||||
settings.API_NAV_DRAWER_ITEM_APP_PACKAGE.set(appPackage);
|
||||
settings.API_NAV_DRAWER_ITEM_FLAGS.set(flags);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void registerNavDrawerItem(final Activity activity, ContextMenuAdapter adapter) {
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final String itemName = settings.API_NAV_DRAWER_ITEM_NAME.get();
|
||||
final String appPackage = settings.API_NAV_DRAWER_ITEM_APP_PACKAGE.get();
|
||||
if (!TextUtils.isEmpty(itemName) && !TextUtils.isEmpty(appPackage)) {
|
||||
final Intent intent = activity.getPackageManager().getLaunchIntentForPackage(appPackage);
|
||||
if (intent != null) {
|
||||
int flags = settings.API_NAV_DRAWER_ITEM_FLAGS.get();
|
||||
if (flags != -1) {
|
||||
intent.addFlags(flags);
|
||||
}
|
||||
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitle(itemName)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
.createItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.aidl.mapmarker.UpdateMapMarkerParams;
|
|||
import net.osmand.aidl.mapwidget.AddMapWidgetParams;
|
||||
import net.osmand.aidl.mapwidget.RemoveMapWidgetParams;
|
||||
import net.osmand.aidl.mapwidget.UpdateMapWidgetParams;
|
||||
import net.osmand.aidl.navdrawer.AddOpenAppNavDrawerItemParams;
|
||||
import net.osmand.aidl.navigation.NavigateGpxParams;
|
||||
import net.osmand.aidl.navigation.NavigateParams;
|
||||
import net.osmand.aidl.note.StartAudioRecordingParams;
|
||||
|
@ -457,5 +458,15 @@ public class OsmandAidlService extends Service {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addOpenAppNavDrawerItem(AddOpenAppNavDrawerItemParams params) throws RemoteException {
|
||||
try {
|
||||
return params != null && getApi("addOpenAppNavDrawerItem").addOpenAppNavDrawerItem(params.getItemName(), params.getAppPackage(), params.getFlags());
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navdrawer;
|
||||
|
||||
parcelable AddOpenAppNavDrawerItemParams;
|
|
@ -0,0 +1,63 @@
|
|||
package net.osmand.aidl.navdrawer;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class AddOpenAppNavDrawerItemParams implements Parcelable {
|
||||
|
||||
private String itemName;
|
||||
private String appPackage;
|
||||
private int flags;
|
||||
|
||||
public AddOpenAppNavDrawerItemParams(String itemName, String appPackage) {
|
||||
this(itemName, appPackage, -1);
|
||||
}
|
||||
|
||||
public AddOpenAppNavDrawerItemParams(String itemName, String appPackage, int flags) {
|
||||
this.itemName = itemName;
|
||||
this.appPackage = appPackage;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
protected AddOpenAppNavDrawerItemParams(Parcel in) {
|
||||
itemName = in.readString();
|
||||
appPackage = in.readString();
|
||||
flags = in.readInt();
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public String getAppPackage() {
|
||||
return appPackage;
|
||||
}
|
||||
|
||||
public int getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(itemName);
|
||||
dest.writeString(appPackage);
|
||||
dest.writeInt(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<AddOpenAppNavDrawerItemParams> CREATOR = new Creator<AddOpenAppNavDrawerItemParams>() {
|
||||
@Override
|
||||
public AddOpenAppNavDrawerItemParams createFromParcel(Parcel in) {
|
||||
return new AddOpenAppNavDrawerItemParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddOpenAppNavDrawerItemParams[] newArray(int size) {
|
||||
return new AddOpenAppNavDrawerItemParams[size];
|
||||
}
|
||||
};
|
||||
}
|
|
@ -8,6 +8,7 @@ import android.content.Context;
|
|||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
import net.osmand.plus.osmedit.OsmBugsDbHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -31,7 +32,8 @@ public class OsmandBackupAgent extends BackupAgentHelper {
|
|||
SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, prefs);
|
||||
addHelper("osmand.settings", helper);
|
||||
|
||||
FileBackupHelper fileBackupHelper = new FileBackupHelper(this, FavouritesDbHelper.FILE_TO_BACKUP, "../databases/" + MapMarkersDbHelper.DB_NAME);
|
||||
FileBackupHelper fileBackupHelper = new FileBackupHelper(this, FavouritesDbHelper.FILE_TO_BACKUP,
|
||||
"../databases/" + MapMarkersDbHelper.DB_NAME, "../databases/" + OsmBugsDbHelper.OSMBUGS_DB_NAME);
|
||||
addHelper("osmand.files", fileBackupHelper);
|
||||
}
|
||||
|
||||
|
|
|
@ -742,6 +742,10 @@ public class OsmandSettings {
|
|||
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_START = new BooleanPreference("should_show_dashboard_on_start", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_DASHBOARD_ON_MAP_SCREEN = new BooleanPreference("show_dashboard_on_map_screen", false).makeGlobal();
|
||||
|
||||
public final CommonPreference<String> API_NAV_DRAWER_ITEM_NAME = new StringPreference("api_nav_drawer_item_name", "").makeGlobal();
|
||||
public final CommonPreference<String> API_NAV_DRAWER_ITEM_APP_PACKAGE = new StringPreference("api_nav_drawer_item_app_package", "").makeGlobal();
|
||||
public final CommonPreference<Integer> API_NAV_DRAWER_ITEM_FLAGS = new IntPreference("api_nav_drawer_item_flags", -1).makeGlobal();
|
||||
|
||||
public final CommonPreference<Integer> NUMBER_OF_STARTS_FIRST_XMAS_SHOWN = new IntPreference("number_of_starts_first_xmas_shown", 0).makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
|
|
|
@ -795,6 +795,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
app.getAidlApi().registerNavDrawerItem(mapActivity, optionsMenuHelper);
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
|
||||
.setIcon(R.drawable.ic_configure_screen_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
|
|
Loading…
Reference in a new issue