Merge branch 'r3.9'
This commit is contained in:
commit
3a481a330e
8 changed files with 211 additions and 95 deletions
|
@ -8,6 +8,7 @@ import net.osmand.aidlapi.AidlParams;
|
||||||
import net.osmand.aidlapi.profile.AExportSettingsType;
|
import net.osmand.aidlapi.profile.AExportSettingsType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.aidlapi.profile.ExportProfileParams.SETTINGS_TYPE_KEY;
|
import static net.osmand.aidlapi.profile.ExportProfileParams.SETTINGS_TYPE_KEY;
|
||||||
|
|
||||||
|
@ -21,11 +22,11 @@ public class ProfileSettingsParams extends AidlParams {
|
||||||
private Uri profileSettingsUri;
|
private Uri profileSettingsUri;
|
||||||
private String latestChanges;
|
private String latestChanges;
|
||||||
private int version;
|
private int version;
|
||||||
private ArrayList<String> settingsTypeKeyList = new ArrayList<>();
|
private List<String> settingsTypeKeyList = new ArrayList<>();
|
||||||
private boolean silent;
|
private boolean silent;
|
||||||
private boolean replace;
|
private boolean replace;
|
||||||
|
|
||||||
public ProfileSettingsParams(Uri profileSettingsUri, ArrayList<AExportSettingsType> settingsTypeList, boolean replace,
|
public ProfileSettingsParams(Uri profileSettingsUri, List<AExportSettingsType> settingsTypeList, boolean replace,
|
||||||
boolean silent, String latestChanges, int version) {
|
boolean silent, String latestChanges, int version) {
|
||||||
this.profileSettingsUri = profileSettingsUri;
|
this.profileSettingsUri = profileSettingsUri;
|
||||||
for (AExportSettingsType settingsType : settingsTypeList) {
|
for (AExportSettingsType settingsType : settingsTypeList) {
|
||||||
|
@ -65,7 +66,7 @@ public class ProfileSettingsParams extends AidlParams {
|
||||||
return profileSettingsUri;
|
return profileSettingsUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getSettingsTypeKeys() {
|
public List<String> getSettingsTypeKeys() {
|
||||||
return settingsTypeKeyList;
|
return settingsTypeKeyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ public class ProfileSettingsParams extends AidlParams {
|
||||||
bundle.putInt(VERSION_KEY, version);
|
bundle.putInt(VERSION_KEY, version);
|
||||||
bundle.putString(LATEST_CHANGES_KEY, latestChanges);
|
bundle.putString(LATEST_CHANGES_KEY, latestChanges);
|
||||||
bundle.putParcelable(PROFILE_SETTINGS_URI_KEY, profileSettingsUri);
|
bundle.putParcelable(PROFILE_SETTINGS_URI_KEY, profileSettingsUri);
|
||||||
bundle.putStringArrayList(SETTINGS_TYPE_KEY, settingsTypeKeyList);
|
bundle.putStringArrayList(SETTINGS_TYPE_KEY, new ArrayList<>(settingsTypeKeyList));
|
||||||
bundle.putBoolean(REPLACE_KEY, replace);
|
bundle.putBoolean(REPLACE_KEY, replace);
|
||||||
bundle.putBoolean(SILENT_IMPORT_KEY, silent);
|
bundle.putBoolean(SILENT_IMPORT_KEY, silent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,43 +10,59 @@
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:maxWidth="@dimen/grid_menu_item_width"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:weightSum="2">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/value"
|
android:id="@+id/value"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
|
android:lines="1"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="700 km" />
|
tools:text="700 km" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<FrameLayout
|
||||||
android:id="@+id/image"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="@dimen/context_menu_transport_icon_size"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="@dimen/context_menu_transport_icon_size"
|
android:layout_marginStart="@dimen/content_padding_half"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_marginLeft="@dimen/content_padding_half"
|
||||||
android:layout_marginStart="@dimen/context_menu_first_line_top_margin"
|
android:layout_weight="1">
|
||||||
android:layout_marginLeft="@dimen/context_menu_first_line_top_margin"
|
|
||||||
tools:src="@drawable/ic_action_track_16" />
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/image"
|
||||||
|
android:layout_width="@dimen/context_menu_transport_icon_size"
|
||||||
|
android:layout_height="@dimen/context_menu_transport_icon_size"
|
||||||
|
android:layout_gravity="center_vertical|end"
|
||||||
|
tools:src="@drawable/ic_action_track_16" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxWidth="@dimen/grid_menu_item_width"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
tools:text="@string/distance" />
|
tools:text="@string/distance" />
|
||||||
|
|
|
@ -2296,11 +2296,11 @@ public class OsmandAidlApi {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean importProfileV2(final Uri profileUri, ArrayList<String> settingsTypeKeys, boolean replace,
|
public boolean importProfileV2(final Uri profileUri, List<String> settingsTypeKeys, boolean replace,
|
||||||
boolean silent, String latestChanges, int version) {
|
boolean silent, String latestChanges, int version) {
|
||||||
if (profileUri != null) {
|
if (profileUri != null) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putStringArrayList(SettingsHelper.SETTINGS_TYPE_LIST_KEY, settingsTypeKeys);
|
bundle.putStringArrayList(SettingsHelper.SETTINGS_TYPE_LIST_KEY, new ArrayList<>(settingsTypeKeys));
|
||||||
bundle.putBoolean(REPLACE_KEY, replace);
|
bundle.putBoolean(REPLACE_KEY, replace);
|
||||||
bundle.putBoolean(SILENT_IMPORT_KEY, silent);
|
bundle.putBoolean(SILENT_IMPORT_KEY, silent);
|
||||||
bundle.putString(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY, latestChanges);
|
bundle.putString(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY, latestChanges);
|
||||||
|
|
|
@ -38,10 +38,10 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SavingTrackHelper extends SQLiteOpenHelper {
|
public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public final static String DATABASE_NAME = "tracks"; //$NON-NLS-1$
|
public final static String DATABASE_NAME = "tracks"; //$NON-NLS-1$
|
||||||
public final static int DATABASE_VERSION = 6;
|
public final static int DATABASE_VERSION = 7;
|
||||||
|
|
||||||
public final static String TRACK_NAME = "track"; //$NON-NLS-1$
|
public final static String TRACK_NAME = "track"; //$NON-NLS-1$
|
||||||
public final static String TRACK_COL_DATE = "date"; //$NON-NLS-1$
|
public final static String TRACK_COL_DATE = "date"; //$NON-NLS-1$
|
||||||
public final static String TRACK_COL_LAT = "lat"; //$NON-NLS-1$
|
public final static String TRACK_COL_LAT = "lat"; //$NON-NLS-1$
|
||||||
|
@ -50,7 +50,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
public final static String TRACK_COL_SPEED = "speed"; //$NON-NLS-1$
|
public final static String TRACK_COL_SPEED = "speed"; //$NON-NLS-1$
|
||||||
public final static String TRACK_COL_HDOP = "hdop"; //$NON-NLS-1$
|
public final static String TRACK_COL_HDOP = "hdop"; //$NON-NLS-1$
|
||||||
public final static String TRACK_COL_HEADING = "heading"; //$NON-NLS-1$
|
public final static String TRACK_COL_HEADING = "heading"; //$NON-NLS-1$
|
||||||
|
|
||||||
public final static String POINT_NAME = "point"; //$NON-NLS-1$
|
public final static String POINT_NAME = "point"; //$NON-NLS-1$
|
||||||
public final static String POINT_COL_DATE = "date"; //$NON-NLS-1$
|
public final static String POINT_COL_DATE = "date"; //$NON-NLS-1$
|
||||||
public final static String POINT_COL_LAT = "lat"; //$NON-NLS-1$
|
public final static String POINT_COL_LAT = "lat"; //$NON-NLS-1$
|
||||||
|
@ -59,7 +59,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
public final static String POINT_COL_CATEGORY = "category"; //$NON-NLS-1$
|
public final static String POINT_COL_CATEGORY = "category"; //$NON-NLS-1$
|
||||||
public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$
|
public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$
|
||||||
public final static String POINT_COL_COLOR = "color"; //$NON-NLS-1$
|
public final static String POINT_COL_COLOR = "color"; //$NON-NLS-1$
|
||||||
|
public final static String POINT_COL_ICON = "icon"; //$NON-NLS-1$
|
||||||
|
public final static String POINT_COL_BACKGROUND = "background"; //$NON-NLS-1$
|
||||||
|
|
||||||
public final static float NO_HEADING = -1.0f;
|
public final static float NO_HEADING = -1.0f;
|
||||||
|
|
||||||
public final static Log log = PlatformUtil.getLog(SavingTrackHelper.class);
|
public final static Log log = PlatformUtil.getLog(SavingTrackHelper.class);
|
||||||
|
@ -76,8 +78,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
private SelectedGpxFile currentTrack;
|
private SelectedGpxFile currentTrack;
|
||||||
private int points;
|
private int points;
|
||||||
private int trkPoints = 0;
|
private int trkPoints = 0;
|
||||||
|
|
||||||
public SavingTrackHelper(OsmandApplication ctx){
|
public SavingTrackHelper(OsmandApplication ctx) {
|
||||||
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.currentTrack = new SelectedGpxFile();
|
this.currentTrack = new SelectedGpxFile();
|
||||||
|
@ -88,11 +90,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
prepareCurrentTrackForRecording();
|
prepareCurrentTrackForRecording();
|
||||||
|
|
||||||
updateScript = "INSERT INTO " + TRACK_NAME + " (" + TRACK_COL_LAT + ", " + TRACK_COL_LON + ", "
|
updateScript = "INSERT INTO " + TRACK_NAME + " (" + TRACK_COL_LAT + ", " + TRACK_COL_LON + ", "
|
||||||
+ TRACK_COL_ALTITUDE + ", " + TRACK_COL_SPEED + ", " + TRACK_COL_HDOP + ", "
|
+ TRACK_COL_ALTITUDE + ", " + TRACK_COL_SPEED + ", " + TRACK_COL_HDOP + ", "
|
||||||
+ TRACK_COL_DATE + ", " + TRACK_COL_HEADING + ")"
|
+ TRACK_COL_DATE + ", " + TRACK_COL_HEADING + ")"
|
||||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
+ " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
insertPointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
insertPointsScript = "INSERT INTO " + POINT_NAME + " (" + POINT_COL_LAT + ", " + POINT_COL_LON + ", "
|
||||||
|
+ POINT_COL_DATE + ", " + POINT_COL_DESCRIPTION + ", " + POINT_COL_NAME + ", "
|
||||||
|
+ POINT_COL_CATEGORY + ", " + POINT_COL_COLOR + ", " + POINT_COL_ICON + ", "
|
||||||
|
+ POINT_COL_BACKGROUND + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,19 +105,19 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
createTableForTrack(db);
|
createTableForTrack(db);
|
||||||
createTableForPoints(db);
|
createTableForPoints(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTableForTrack(SQLiteDatabase db){
|
private void createTableForTrack(SQLiteDatabase db) {
|
||||||
db.execSQL("CREATE TABLE " + TRACK_NAME + " (" + TRACK_COL_LAT + " double, " + TRACK_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
db.execSQL("CREATE TABLE " + TRACK_NAME + " (" + TRACK_COL_LAT + " double, " + TRACK_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
+ TRACK_COL_ALTITUDE + " double, " + TRACK_COL_SPEED + " double, " //$NON-NLS-1$ //$NON-NLS-2$
|
+ TRACK_COL_ALTITUDE + " double, " + TRACK_COL_SPEED + " double, " //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ TRACK_COL_HDOP + " double, " + TRACK_COL_DATE + " long, "
|
+ TRACK_COL_HDOP + " double, " + TRACK_COL_DATE + " long, "
|
||||||
+ TRACK_COL_HEADING + " float )"); //$NON-NLS-1$ //$NON-NLS-2$
|
+ TRACK_COL_HEADING + " float )"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTableForPoints(SQLiteDatabase db){
|
private void createTableForPoints(SQLiteDatabase db) {
|
||||||
try {
|
try {
|
||||||
db.execSQL("CREATE TABLE " + POINT_NAME + " (" + POINT_COL_LAT + " double, " + POINT_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
db.execSQL("CREATE TABLE " + POINT_NAME + " (" + POINT_COL_LAT + " double, " + POINT_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
+ POINT_COL_DATE + " long, " + POINT_COL_DESCRIPTION + " text, " + POINT_COL_NAME + " text, "
|
+ POINT_COL_DATE + " long, " + POINT_COL_DESCRIPTION + " text, " + POINT_COL_NAME + " text, "
|
||||||
+ POINT_COL_CATEGORY + " text, " + POINT_COL_COLOR + " long" + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
+ POINT_COL_CATEGORY + " text, " + POINT_COL_COLOR + " long, " + POINT_COL_ICON + " text, " + POINT_COL_BACKGROUND + " text )"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
// ignore if already exists
|
// ignore if already exists
|
||||||
}
|
}
|
||||||
|
@ -120,25 +125,29 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
if(oldVersion < 2){
|
if (oldVersion < 2) {
|
||||||
createTableForPoints(db);
|
createTableForPoints(db);
|
||||||
}
|
}
|
||||||
if(oldVersion < 3){
|
if (oldVersion < 3) {
|
||||||
db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HDOP + " double");
|
db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HDOP + " double");
|
||||||
}
|
}
|
||||||
if(oldVersion < 4){
|
if (oldVersion < 4) {
|
||||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_NAME + " text");
|
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_NAME + " text");
|
||||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_CATEGORY + " text");
|
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_CATEGORY + " text");
|
||||||
}
|
}
|
||||||
if(oldVersion < 5){
|
if (oldVersion < 5) {
|
||||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_COLOR + " long");
|
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_COLOR + " long");
|
||||||
}
|
}
|
||||||
if(oldVersion < 6){
|
if (oldVersion < 6) {
|
||||||
db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HEADING + " float");
|
db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HEADING + " float");
|
||||||
|
}
|
||||||
|
if (oldVersion < 7) {
|
||||||
|
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_ICON + " text");
|
||||||
|
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_BACKGROUND + " text");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long getLastTrackPointTime() {
|
public long getLastTrackPointTime() {
|
||||||
long res = 0;
|
long res = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -146,7 +155,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
try {
|
try {
|
||||||
Cursor query = db.rawQuery("SELECT " + TRACK_COL_DATE + " FROM " + TRACK_NAME + " ORDER BY " + TRACK_COL_DATE + " DESC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
Cursor query = db.rawQuery("SELECT " + TRACK_COL_DATE + " FROM " + TRACK_NAME + " ORDER BY " + TRACK_COL_DATE + " DESC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
if(query.moveToFirst()) {
|
if (query.moveToFirst()) {
|
||||||
res = query.getLong(0);
|
res = query.getLong(0);
|
||||||
}
|
}
|
||||||
query.close();
|
query.close();
|
||||||
|
@ -154,11 +163,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean hasDataToSave() {
|
public synchronized boolean hasDataToSave() {
|
||||||
try {
|
try {
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
@ -172,11 +181,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
q = db.query(false, POINT_NAME, new String[]{POINT_COL_LAT, POINT_COL_LON}, null, null, null, null, null, null);
|
q = db.query(false, POINT_NAME, new String[]{POINT_COL_LAT, POINT_COL_LON}, null, null, null, null, null, null);
|
||||||
has = q.moveToFirst();
|
has = q.moveToFirst();
|
||||||
while(has) {
|
while (has) {
|
||||||
if(q.getDouble(0) != 0 || q.getDouble(1) != 0) {
|
if (q.getDouble(0) != 0 || q.getDouble(1) != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!q.moveToNext()) {
|
if (!q.moveToNext()) {
|
||||||
has = false;
|
has = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +198,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +303,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
private void collectDBPoints(SQLiteDatabase db, Map<String, GPXFile> dataTracks) {
|
private void collectDBPoints(SQLiteDatabase db, Map<String, GPXFile> dataTracks) {
|
||||||
Cursor query = db.rawQuery("SELECT " + POINT_COL_LAT + "," + POINT_COL_LON + "," + POINT_COL_DATE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
Cursor query = db.rawQuery("SELECT " + POINT_COL_LAT + "," + POINT_COL_LON + "," + POINT_COL_DATE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
+ POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + "," + POINT_COL_COLOR + " FROM " + POINT_NAME+" ORDER BY " + POINT_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
+ POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + "," + POINT_COL_COLOR + ","
|
||||||
|
+ POINT_COL_ICON + "," + POINT_COL_BACKGROUND + " FROM " + POINT_NAME + " ORDER BY " + POINT_COL_DATE + " ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
if (query.moveToFirst()) {
|
if (query.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
WptPt pt = new WptPt();
|
WptPt pt = new WptPt();
|
||||||
|
@ -309,18 +319,20 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
if (color != 0) {
|
if (color != 0) {
|
||||||
pt.setColor(color);
|
pt.setColor(color);
|
||||||
}
|
}
|
||||||
|
pt.setIconName(query.getString(7));
|
||||||
|
pt.setBackgroundType(query.getString(8));
|
||||||
|
|
||||||
// check if name is extension (needed for audio/video plugin & josm integration)
|
// check if name is extension (needed for audio/video plugin & josm integration)
|
||||||
if(pt.name != null && pt.name.length() > 4 && pt.name.charAt(pt.name.length() - 4) == '.') {
|
if (pt.name != null && pt.name.length() > 4 && pt.name.charAt(pt.name.length() - 4) == '.') {
|
||||||
pt.link = pt.name;
|
pt.link = pt.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
String date = DateFormat.format("yyyy-MM-dd", time).toString(); //$NON-NLS-1$
|
String date = DateFormat.format("yyyy-MM-dd", time).toString(); //$NON-NLS-1$
|
||||||
GPXFile gpx;
|
GPXFile gpx;
|
||||||
if (dataTracks.containsKey(date)) {
|
if (dataTracks.containsKey(date)) {
|
||||||
gpx = dataTracks.get(date);
|
gpx = dataTracks.get(date);
|
||||||
} else {
|
} else {
|
||||||
gpx = new GPXFile(Version.getFullVersion(ctx));
|
gpx = new GPXFile(Version.getFullVersion(ctx));
|
||||||
dataTracks.put(date, gpx);
|
dataTracks.put(date, gpx);
|
||||||
}
|
}
|
||||||
ctx.getSelectedGpxHelper().addPoint(pt, gpx);
|
ctx.getSelectedGpxHelper().addPoint(pt, gpx);
|
||||||
|
@ -329,10 +341,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
query.close();
|
query.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectDBTracks(SQLiteDatabase db, Map<String, GPXFile> dataTracks) {
|
private void collectDBTracks(SQLiteDatabase db, Map<String, GPXFile> dataTracks) {
|
||||||
Cursor query = db.rawQuery("SELECT " + TRACK_COL_LAT + "," + TRACK_COL_LON + "," + TRACK_COL_ALTITUDE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
Cursor query = db.rawQuery("SELECT " + TRACK_COL_LAT + "," + TRACK_COL_LON + "," + TRACK_COL_ALTITUDE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
+ TRACK_COL_SPEED + "," + TRACK_COL_HDOP + "," + TRACK_COL_DATE + "," + TRACK_COL_HEADING + " FROM " + TRACK_NAME +" ORDER BY " + TRACK_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
+ TRACK_COL_SPEED + "," + TRACK_COL_HDOP + "," + TRACK_COL_DATE + "," + TRACK_COL_HEADING + " FROM " + TRACK_NAME + " ORDER BY " + TRACK_COL_DATE + " ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
long previousTime = 0;
|
long previousTime = 0;
|
||||||
long previousInterval = 0;
|
long previousInterval = 0;
|
||||||
TrkSegment segment = null;
|
TrkSegment segment = null;
|
||||||
|
@ -351,14 +363,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
pt.heading = heading == NO_HEADING ? Float.NaN : heading;
|
pt.heading = heading == NO_HEADING ? Float.NaN : heading;
|
||||||
long currentInterval = Math.abs(time - previousTime);
|
long currentInterval = Math.abs(time - previousTime);
|
||||||
boolean newInterval = pt.lat == 0 && pt.lon == 0;
|
boolean newInterval = pt.lat == 0 && pt.lon == 0;
|
||||||
|
|
||||||
if (track != null && !newInterval && (!ctx.getSettings().AUTO_SPLIT_RECORDING.get() || currentInterval < 6 * 60 * 1000 || currentInterval < 10 * previousInterval)) {
|
if (track != null && !newInterval && (!ctx.getSettings().AUTO_SPLIT_RECORDING.get() || currentInterval < 6 * 60 * 1000 || currentInterval < 10 * previousInterval)) {
|
||||||
// 6 minute - same segment
|
// 6 minute - same segment
|
||||||
segment.points.add(pt);
|
segment.points.add(pt);
|
||||||
} else if (track != null && (ctx.getSettings().AUTO_SPLIT_RECORDING.get() && currentInterval < 2 * 60 * 60 * 1000)) {
|
} else if (track != null && (ctx.getSettings().AUTO_SPLIT_RECORDING.get() && currentInterval < 2 * 60 * 60 * 1000)) {
|
||||||
// 2 hour - same track
|
// 2 hour - same track
|
||||||
segment = new TrkSegment();
|
segment = new TrkSegment();
|
||||||
if(!newInterval) {
|
if (!newInterval) {
|
||||||
segment.points.add(pt);
|
segment.points.add(pt);
|
||||||
}
|
}
|
||||||
track.segments.add(segment);
|
track.segments.add(segment);
|
||||||
|
@ -367,10 +379,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
track = new Track();
|
track = new Track();
|
||||||
segment = new TrkSegment();
|
segment = new TrkSegment();
|
||||||
track.segments.add(segment);
|
track.segments.add(segment);
|
||||||
if(!newInterval) {
|
if (!newInterval) {
|
||||||
segment.points.add(pt);
|
segment.points.add(pt);
|
||||||
}
|
}
|
||||||
String date = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date(time));; //$NON-NLS-1$
|
String date = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date(time)); //$NON-NLS-1$
|
||||||
if (dataTracks.containsKey(date)) {
|
if (dataTracks.containsKey(date)) {
|
||||||
GPXFile gpx = dataTracks.get(date);
|
GPXFile gpx = dataTracks.get(date);
|
||||||
gpx.tracks.add(track);
|
gpx.tracks.add(track);
|
||||||
|
@ -411,14 +423,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
dataTracks.remove(date);
|
dataTracks.remove(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startNewSegment() {
|
public void startNewSegment() {
|
||||||
lastTimeUpdated = 0;
|
lastTimeUpdated = 0;
|
||||||
lastPoint = null;
|
lastPoint = null;
|
||||||
execWithClose(updateScript, new Object[] { 0, 0, 0, 0, 0, System.currentTimeMillis(), NO_HEADING});
|
execWithClose(updateScript, new Object[]{0, 0, 0, 0, 0, System.currentTimeMillis(), NO_HEADING});
|
||||||
addTrackPoint(null, true, System.currentTimeMillis());
|
addTrackPoint(null, true, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLocation(net.osmand.Location location, Float heading) {
|
public void updateLocation(net.osmand.Location location, Float heading) {
|
||||||
// use because there is a bug on some devices with location.getTime()
|
// use because there is a bug on some devices with location.getTime()
|
||||||
long locationTime = System.currentTimeMillis();
|
long locationTime = System.currentTimeMillis();
|
||||||
|
@ -459,12 +471,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
ctx.getNotificationHelper().refreshNotification(NotificationType.GPX);
|
ctx.getNotificationHelper().refreshNotification(NotificationType.GPX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertData(double lat, double lon, double alt, double speed, double hdop, long time, float heading,
|
public void insertData(double lat, double lon, double alt, double speed, double hdop, long time, float heading,
|
||||||
OsmandSettings settings) {
|
OsmandSettings settings) {
|
||||||
// * 1000 in next line seems to be wrong with new IntervalChooseDialog
|
// * 1000 in next line seems to be wrong with new IntervalChooseDialog
|
||||||
// if (time - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() * 1000) {
|
// if (time - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() * 1000) {
|
||||||
execWithClose(updateScript, new Object[] { lat, lon, alt, speed, hdop, time, heading });
|
execWithClose(updateScript, new Object[]{lat, lon, alt, speed, hdop, time, heading});
|
||||||
boolean newSegment = false;
|
boolean newSegment = false;
|
||||||
if (lastPoint == null || (time - lastTimeUpdated) > 180 * 1000) {
|
if (lastPoint == null || (time - lastTimeUpdated) > 180 * 1000) {
|
||||||
lastPoint = new LatLon(lat, lon);
|
lastPoint = new LatLon(lat, lon);
|
||||||
|
@ -485,7 +497,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
addTrackPoint(pt, newSegment, time);
|
addTrackPoint(pt, newSegment, time);
|
||||||
trkPoints++;
|
trkPoints++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTrackPoint(WptPt pt, boolean newSegment, long time) {
|
private void addTrackPoint(WptPt pt, boolean newSegment, long time) {
|
||||||
List<TrkSegment> points = currentTrack.getModifiablePointsToDisplay();
|
List<TrkSegment> points = currentTrack.getModifiablePointsToDisplay();
|
||||||
Track track = currentTrack.getModifiableGpxFile().tracks.get(0);
|
Track track = currentTrack.getModifiableGpxFile().tracks.get(0);
|
||||||
|
@ -511,12 +523,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public WptPt insertPointData(double lat, double lon, long time, String description, String name, String category,
|
public WptPt insertPointData(double lat, double lon, long time, String description, String name, String category,
|
||||||
int color) {
|
int color) {
|
||||||
return insertPointData(lat, lon, time, description, name, category, color, null, null);
|
return insertPointData(lat, lon, time, description, name, category, color, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WptPt insertPointData(double lat, double lon, long time, String description, String name, String category,
|
public WptPt insertPointData(double lat, double lon, long time, String description, String name, String category,
|
||||||
int color, String iconName, String backgroundName) {
|
int color, String iconName, String backgroundName) {
|
||||||
final WptPt pt = new WptPt(lat, lon, time, Double.NaN, 0, Double.NaN);
|
final WptPt pt = new WptPt(lat, lon, time, Double.NaN, 0, Double.NaN);
|
||||||
pt.name = name;
|
pt.name = name;
|
||||||
pt.category = category;
|
pt.category = category;
|
||||||
|
@ -529,7 +541,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
ctx.getSelectedGpxHelper().addPoint(pt, currentTrack.getModifiableGpxFile());
|
ctx.getSelectedGpxHelper().addPoint(pt, currentTrack.getModifiableGpxFile());
|
||||||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||||
points++;
|
points++;
|
||||||
execWithClose(insertPointsScript, new Object[] { lat, lon, time, description, name, category, color });
|
execWithClose(insertPointsScript, new Object[]{lat, lon, time, description, name, category, color, iconName, backgroundName});
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +550,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePointData(WptPt pt, double lat, double lon, long time, String description, String name,
|
public void updatePointData(WptPt pt, double lat, double lon, long time, String description, String name,
|
||||||
String category, int color, String iconName, String iconBackground) {
|
String category, int color, String iconName, String iconBackground) {
|
||||||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||||
|
|
||||||
List<Object> params = new ArrayList<>();
|
List<Object> params = new ArrayList<>();
|
||||||
|
@ -549,6 +561,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
params.add(name);
|
params.add(name);
|
||||||
params.add(category);
|
params.add(category);
|
||||||
params.add(color);
|
params.add(color);
|
||||||
|
params.add(iconName);
|
||||||
|
params.add(iconBackground);
|
||||||
|
|
||||||
params.add(pt.getLatitude());
|
params.add(pt.getLatitude());
|
||||||
params.add(pt.getLongitude());
|
params.add(pt.getLongitude());
|
||||||
|
@ -563,7 +577,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
+ POINT_COL_DESCRIPTION + "=?, "
|
+ POINT_COL_DESCRIPTION + "=?, "
|
||||||
+ POINT_COL_NAME + "=?, "
|
+ POINT_COL_NAME + "=?, "
|
||||||
+ POINT_COL_CATEGORY + "=?, "
|
+ POINT_COL_CATEGORY + "=?, "
|
||||||
+ POINT_COL_COLOR + "=? "
|
+ POINT_COL_COLOR + "=?, "
|
||||||
|
+ POINT_COL_ICON + "=?, "
|
||||||
|
+ POINT_COL_BACKGROUND + "=? "
|
||||||
+ "WHERE "
|
+ "WHERE "
|
||||||
+ POINT_COL_LAT + "=? AND "
|
+ POINT_COL_LAT + "=? AND "
|
||||||
+ POINT_COL_LON + "=? AND "
|
+ POINT_COL_LON + "=? AND "
|
||||||
|
@ -662,10 +678,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadGpxFromDatabase(){
|
public void loadGpxFromDatabase() {
|
||||||
Map<String, GPXFile> files = collectRecordedData();
|
Map<String, GPXFile> files = collectRecordedData();
|
||||||
currentTrack.getModifiableGpxFile().tracks.clear();
|
currentTrack.getModifiableGpxFile().tracks.clear();
|
||||||
for (Map.Entry<String, GPXFile> entry : files.entrySet()){
|
for (Map.Entry<String, GPXFile> entry : files.entrySet()) {
|
||||||
ctx.getSelectedGpxHelper().addPoints(entry.getValue().getPoints(), currentTrack.getModifiableGpxFile());
|
ctx.getSelectedGpxHelper().addPoints(entry.getValue().getPoints(), currentTrack.getModifiableGpxFile());
|
||||||
currentTrack.getModifiableGpxFile().tracks.addAll(entry.getValue().tracks);
|
currentTrack.getModifiableGpxFile().tracks.addAll(entry.getValue().tracks);
|
||||||
}
|
}
|
||||||
|
@ -679,10 +695,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareCurrentTrackForRecording() {
|
private void prepareCurrentTrackForRecording() {
|
||||||
if(currentTrack.getModifiableGpxFile().tracks.size() == 0) {
|
if (currentTrack.getModifiableGpxFile().tracks.size() == 0) {
|
||||||
currentTrack.getModifiableGpxFile().tracks.add(new Track());
|
currentTrack.getModifiableGpxFile().tracks.add(new Track());
|
||||||
}
|
}
|
||||||
while(currentTrack.getPointsToDisplay().size() < currentTrack.getModifiableGpxFile().tracks.size()) {
|
while (currentTrack.getPointsToDisplay().size() < currentTrack.getModifiableGpxFile().tracks.size()) {
|
||||||
TrkSegment trkSegment = new TrkSegment();
|
TrkSegment trkSegment = new TrkSegment();
|
||||||
currentTrack.getModifiablePointsToDisplay().add(trkSegment);
|
currentTrack.getModifiablePointsToDisplay().add(trkSegment);
|
||||||
}
|
}
|
||||||
|
@ -705,7 +721,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
public int getPoints() {
|
public int getPoints() {
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTrkPoints() {
|
public int getTrkPoints() {
|
||||||
return trkPoints;
|
return trkPoints;
|
||||||
}
|
}
|
||||||
|
@ -717,11 +733,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
public GPXFile getCurrentGpx() {
|
public GPXFile getCurrentGpx() {
|
||||||
return currentTrack.getGpxFile();
|
return currentTrack.getGpxFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectedGpxFile getCurrentTrack() {
|
public SelectedGpxFile getCurrentTrack() {
|
||||||
return currentTrack;
|
return currentTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SaveGpxResult {
|
public class SaveGpxResult {
|
||||||
|
|
||||||
public SaveGpxResult(List<String> warnings, List<String> filenames) {
|
public SaveGpxResult(List<String> warnings, List<String> filenames) {
|
||||||
|
|
|
@ -43,7 +43,9 @@ public class SelectedGpxMenuController extends MenuController {
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed() {
|
public void buttonPressed() {
|
||||||
mapContextMenu.hide(false);
|
mapContextMenu.hide(false);
|
||||||
TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile());
|
WptPt wptPt = selectedGpxPoint.selectedPoint;
|
||||||
|
LatLon latLon = new LatLon(wptPt.lat, wptPt.lon);
|
||||||
|
TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile(), latLon);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
|
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
|
||||||
|
|
|
@ -149,6 +149,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
private Location lastLocation;
|
private Location lastLocation;
|
||||||
private UpdateLocationViewCache updateLocationViewCache;
|
private UpdateLocationViewCache updateLocationViewCache;
|
||||||
private boolean locationUpdateStarted;
|
private boolean locationUpdateStarted;
|
||||||
|
private LatLon latLon;
|
||||||
|
|
||||||
private int menuTitleHeight;
|
private int menuTitleHeight;
|
||||||
private int toolbarHeightPx;
|
private int toolbarHeightPx;
|
||||||
|
@ -259,6 +260,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
this.selectedGpxFile = selectedGpxFile;
|
this.selectedGpxFile = selectedGpxFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLatLon(LatLon latLon) {
|
||||||
|
this.latLon = latLon;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
@ -556,10 +561,9 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
View view = overviewCard.getView();
|
View view = overviewCard.getView();
|
||||||
if (mapActivity != null && view != null) {
|
if (mapActivity != null && view != null) {
|
||||||
MapContextMenu menu = mapActivity.getContextMenu();
|
|
||||||
TextView distanceText = (TextView) view.findViewById(R.id.distance);
|
TextView distanceText = (TextView) view.findViewById(R.id.distance);
|
||||||
ImageView direction = (ImageView) view.findViewById(R.id.direction);
|
ImageView direction = (ImageView) view.findViewById(R.id.direction);
|
||||||
app.getUIUtilities().updateLocationView(updateLocationViewCache, direction, distanceText, menu.getLatLon());
|
app.getUIUtilities().updateLocationView(updateLocationViewCache, direction, distanceText, latLon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1113,7 +1117,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path);
|
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path);
|
||||||
}
|
}
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
showInstance(mapActivity, selectedGpxFile);
|
showInstance(mapActivity, selectedGpxFile, null);
|
||||||
} else if (!Algorithms.isEmpty(path)) {
|
} else if (!Algorithms.isEmpty(path)) {
|
||||||
String title = app.getString(R.string.loading_smth, "");
|
String title = app.getString(R.string.loading_smth, "");
|
||||||
final ProgressDialog progress = ProgressDialog.show(mapActivity, title, app.getString(R.string.loading_data));
|
final ProgressDialog progress = ProgressDialog.show(mapActivity, title, app.getString(R.string.loading_data));
|
||||||
|
@ -1126,7 +1130,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false);
|
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false);
|
||||||
showInstance(mapActivity, selectedGpxFile);
|
showInstance(mapActivity, selectedGpxFile, null);
|
||||||
}
|
}
|
||||||
if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
|
@ -1138,7 +1142,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile) {
|
public static boolean showInstance(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile, @Nullable LatLon latLon) {
|
||||||
try {
|
try {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
|
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
|
||||||
|
@ -1148,6 +1152,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
fragment.setRetainInstance(true);
|
fragment.setRetainInstance(true);
|
||||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||||
|
|
||||||
|
if (latLon != null) {
|
||||||
|
fragment.setLatLon(latLon);
|
||||||
|
} else {
|
||||||
|
QuadRect rect = selectedGpxFile.getGpxFile().getRect();
|
||||||
|
LatLon latLonRect = new LatLon(rect.centerY(), rect.centerX());
|
||||||
|
fragment.setLatLon(latLonRect);
|
||||||
|
}
|
||||||
|
|
||||||
mapActivity.getSupportFragmentManager()
|
mapActivity.getSupportFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.replace(R.id.fragmentContainer, fragment, TAG)
|
.replace(R.id.fragmentContainer, fragment, TAG)
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package net.osmand.plus.wikipedia;
|
package net.osmand.plus.wikipedia;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.style.StyleSpan;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
|
|
||||||
|
@ -12,6 +16,8 @@ import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.os.ConfigurationCompat;
|
import androidx.core.os.ConfigurationCompat;
|
||||||
import androidx.core.os.LocaleListCompat;
|
import androidx.core.os.LocaleListCompat;
|
||||||
|
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
@ -124,6 +130,12 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public MapActivity getMapActivity() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
return (MapActivity) activity;
|
||||||
|
}
|
||||||
|
|
||||||
private void initLanguagesData() {
|
private void initLanguagesData() {
|
||||||
languages = new ArrayList<>();
|
languages = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -188,12 +200,44 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
localesForSaving.add(language.getLocale());
|
localesForSaving.add(language.getLocale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wikiPlugin.setLanguagesToShow(localesForSaving);
|
applyPreferenceWithSnackBar(localesForSaving, isGlobalWikiPoiEnabled);
|
||||||
wikiPlugin.setShowAllLanguages(isGlobalWikiPoiEnabled);
|
|
||||||
wikiPlugin.updateWikipediaState();
|
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final void applyPreference(boolean applyToAllProfiles, List<String> localesForSaving, boolean global) {
|
||||||
|
if (applyToAllProfiles) {
|
||||||
|
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
|
||||||
|
wikiPlugin.setLanguagesToShow(mode, localesForSaving);
|
||||||
|
wikiPlugin.setShowAllLanguages(mode, global);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wikiPlugin.setLanguagesToShow(localesForSaving);
|
||||||
|
wikiPlugin.setShowAllLanguages(global);
|
||||||
|
}
|
||||||
|
|
||||||
|
wikiPlugin.updateWikipediaState();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyPreferenceWithSnackBar(final List<String> localesForSaving, final boolean global) {
|
||||||
|
applyPreference(false, localesForSaving, global);
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
String modeName = appMode.toHumanString();
|
||||||
|
String text = app.getString(R.string.changes_applied_to_profile, modeName);
|
||||||
|
SpannableString message = UiUtilities.createSpannableString(text, new StyleSpan(Typeface.BOLD), modeName);
|
||||||
|
Snackbar snackbar = Snackbar.make(mapActivity.getLayout(), message, Snackbar.LENGTH_LONG)
|
||||||
|
.setAction(R.string.apply_to_all_profiles, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
applyPreference(true, localesForSaving, global);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
UiUtilities.setupSnackbarVerticalLayout(snackbar);
|
||||||
|
UiUtilities.setupSnackbar(snackbar, nightMode);
|
||||||
|
snackbar.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private View getCustomButtonView() {
|
private View getCustomButtonView() {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
if (app == null) {
|
if (app == null) {
|
||||||
|
@ -265,7 +309,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull MapActivity mapActivity,
|
public static void showInstance(@NonNull MapActivity mapActivity,
|
||||||
boolean usedOnMap) {
|
boolean usedOnMap) {
|
||||||
SelectWikiLanguagesBottomSheet fragment = new SelectWikiLanguagesBottomSheet();
|
SelectWikiLanguagesBottomSheet fragment = new SelectWikiLanguagesBottomSheet();
|
||||||
fragment.setUsedOnMap(usedOnMap);
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), SelectWikiLanguagesBottomSheet.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), SelectWikiLanguagesBottomSheet.TAG);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||||
import net.osmand.plus.search.QuickSearchListAdapter;
|
import net.osmand.plus.search.QuickSearchListAdapter;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchBannerListItem;
|
import net.osmand.plus.search.listitems.QuickSearchBannerListItem;
|
||||||
import net.osmand.plus.search.listitems.QuickSearchFreeBannerListItem;
|
import net.osmand.plus.search.listitems.QuickSearchFreeBannerListItem;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.views.layers.DownloadedRegionsLayer;
|
import net.osmand.plus.views.layers.DownloadedRegionsLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
@ -97,8 +98,8 @@ public class WikipediaPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerLayerContextMenuActions(OsmandMapTileView mapView,
|
protected void registerLayerContextMenuActions(OsmandMapTileView mapView,
|
||||||
ContextMenuAdapter adapter,
|
ContextMenuAdapter adapter,
|
||||||
final MapActivity mapActivity) {
|
final MapActivity mapActivity) {
|
||||||
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() {
|
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,7 +114,7 @@ public class WikipediaPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId,
|
||||||
final int pos, boolean isChecked, int[] viewCoordinates) {
|
final int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
if (itemId == R.string.shared_string_wikipedia) {
|
if (itemId == R.string.shared_string_wikipedia) {
|
||||||
toggleWikipediaPoi(isChecked, new CallbackWithObject<Boolean>() {
|
toggleWikipediaPoi(isChecked, new CallbackWithObject<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,26 +190,50 @@ public class WikipediaPlugin extends OsmandPlugin {
|
||||||
return !isShowAllLanguages() && getLanguagesToShow() != null;
|
return !isShowAllLanguages() && getLanguagesToShow() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasCustomSettings(ApplicationMode profile) {
|
||||||
|
return !isShowAllLanguages(profile) && getLanguagesToShow(profile) != null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasLanguagesFilter() {
|
public boolean hasLanguagesFilter() {
|
||||||
return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.get() != null;
|
return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.get() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasLanguagesFilter(ApplicationMode profile) {
|
||||||
|
return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.getModeValue(profile) != null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isShowAllLanguages() {
|
public boolean isShowAllLanguages() {
|
||||||
return settings.GLOBAL_WIKIPEDIA_POI_ENABLED.get();
|
return settings.GLOBAL_WIKIPEDIA_POI_ENABLED.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowAllLanguages(ApplicationMode mode) {
|
||||||
|
return settings.GLOBAL_WIKIPEDIA_POI_ENABLED.getModeValue(mode);
|
||||||
|
}
|
||||||
|
|
||||||
public void setShowAllLanguages(boolean showAllLanguages) {
|
public void setShowAllLanguages(boolean showAllLanguages) {
|
||||||
settings.GLOBAL_WIKIPEDIA_POI_ENABLED.set(showAllLanguages);
|
settings.GLOBAL_WIKIPEDIA_POI_ENABLED.set(showAllLanguages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowAllLanguages(ApplicationMode mode, boolean showAllLanguages) {
|
||||||
|
settings.GLOBAL_WIKIPEDIA_POI_ENABLED.setModeValue(mode, showAllLanguages);
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getLanguagesToShow() {
|
public List<String> getLanguagesToShow() {
|
||||||
return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.getStringsList();
|
return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.getStringsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getLanguagesToShow(ApplicationMode mode) {
|
||||||
|
return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.getStringsListForProfile(mode);
|
||||||
|
}
|
||||||
|
|
||||||
public void setLanguagesToShow(List<String> languagesToShow) {
|
public void setLanguagesToShow(List<String> languagesToShow) {
|
||||||
settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.setStringsList(languagesToShow);
|
settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.setStringsList(languagesToShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLanguagesToShow(ApplicationMode mode, List<String> languagesToShow) {
|
||||||
|
settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.setStringsListForProfile(mode, languagesToShow);
|
||||||
|
}
|
||||||
|
|
||||||
public void toggleWikipediaPoi(boolean enable, CallbackWithObject<Boolean> callback) {
|
public void toggleWikipediaPoi(boolean enable, CallbackWithObject<Boolean> callback) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
showWikiOnMap();
|
showWikiOnMap();
|
||||||
|
|
Loading…
Reference in a new issue