commit
8c34f24f54
34 changed files with 770 additions and 567 deletions
|
@ -8,6 +8,7 @@ import net.osmand.aidlapi.AidlParams;
|
|||
import net.osmand.aidlapi.profile.AExportSettingsType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.aidlapi.profile.ExportProfileParams.SETTINGS_TYPE_KEY;
|
||||
|
||||
|
@ -15,17 +16,17 @@ public class ProfileSettingsParams extends AidlParams {
|
|||
|
||||
public static final String VERSION_KEY = "version";
|
||||
public static final String REPLACE_KEY = "replace";
|
||||
public static final String SILENT_IMPORT_KEY = "silent_import";
|
||||
public static final String SILENT_IMPORT_KEY = "silentImport";
|
||||
public static final String LATEST_CHANGES_KEY = "latestChanges";
|
||||
public static final String PROFILE_SETTINGS_URI_KEY = "profileSettingsUri";
|
||||
private Uri profileSettingsUri;
|
||||
private String latestChanges;
|
||||
private int version;
|
||||
private ArrayList<String> settingsTypeKeyList = new ArrayList<>();
|
||||
private List<String> settingsTypeKeyList = new ArrayList<>();
|
||||
private boolean silent;
|
||||
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) {
|
||||
this.profileSettingsUri = profileSettingsUri;
|
||||
for (AExportSettingsType settingsType : settingsTypeList) {
|
||||
|
@ -65,7 +66,7 @@ public class ProfileSettingsParams extends AidlParams {
|
|||
return profileSettingsUri;
|
||||
}
|
||||
|
||||
public ArrayList<String> getSettingsTypeKeys() {
|
||||
public List<String> getSettingsTypeKeys() {
|
||||
return settingsTypeKeyList;
|
||||
}
|
||||
|
||||
|
@ -82,7 +83,7 @@ public class ProfileSettingsParams extends AidlParams {
|
|||
bundle.putInt(VERSION_KEY, version);
|
||||
bundle.putString(LATEST_CHANGES_KEY, latestChanges);
|
||||
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(SILENT_IMPORT_KEY, silent);
|
||||
}
|
||||
|
|
|
@ -156,6 +156,10 @@ public class TurnType {
|
|||
return value == RNLB || value == TRU;
|
||||
}
|
||||
|
||||
public void setExitOut(int exitOut) {
|
||||
this.exitOut = exitOut;
|
||||
}
|
||||
|
||||
public void setTurnAngle(float turnAngle) {
|
||||
this.turnAngle = turnAngle;
|
||||
}
|
||||
|
|
|
@ -668,8 +668,13 @@ public class MapUtils {
|
|||
|
||||
public static boolean areLatLonEqual(Location l1, Location l2) {
|
||||
return l1 == null && l2 == null
|
||||
|| (l1 != null && l2 != null && Math.abs(l1.getLatitude() - l2.getLatitude()) < 0.00001
|
||||
&& Math.abs(l1.getLongitude() - l2.getLongitude()) < 0.00001);
|
||||
|| (l2 != null && areLatLonEqual(l1, l2.getLatitude(), l2.getLongitude()));
|
||||
}
|
||||
|
||||
public static boolean areLatLonEqual(Location l, double lat, double lon) {
|
||||
return l != null
|
||||
&& Math.abs(l.getLatitude() - lat) < 0.00001
|
||||
&& Math.abs(l.getLongitude() - lon) < 0.00001;
|
||||
}
|
||||
|
||||
public static LatLon rhumbDestinationPoint(LatLon latLon, double distance, double bearing){
|
||||
|
|
20
OsmAnd/res/layout/center_button_container.xml
Normal file
20
OsmAnd/res/layout/center_button_container.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/center_button_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/tab_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/altitude" />
|
||||
|
||||
</FrameLayout>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/custom_radio_buttons"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -13,59 +12,22 @@
|
|||
android:orientation="horizontal"
|
||||
tools:showIn="@layout/fragment_route_between_points_bottom_sheet_dialog">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/left_button_container"
|
||||
<include
|
||||
layout="@layout/left_button_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
android:layout_weight="1" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/left_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/shared_string_left"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/center_button_container"
|
||||
<include
|
||||
layout="@layout/center_button_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone">
|
||||
android:layout_weight="1" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/center_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/position_on_map_center"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/right_button_container"
|
||||
<include
|
||||
layout="@layout/right_button_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/right_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/shared_string_right"/>
|
||||
|
||||
</FrameLayout>
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,24 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/list_item_divider"/>
|
||||
<include layout="@layout/list_item_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.views.controls.PagerSlidingTabStrip
|
||||
android:id="@+id/sliding_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/bg_color"/>
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:minHeight="@dimen/dialog_button_height"
|
||||
android:paddingTop="@dimen/content_padding" />
|
||||
|
||||
<net.osmand.plus.views.controls.WrapContentHeightViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:paddingTop="4dp"/>
|
||||
android:paddingTop="4dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -10,43 +10,59 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:gravity="center_vertical"
|
||||
android:maxWidth="@dimen/grid_menu_item_width"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:lines="1"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="700 km" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/content_padding_half"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_weight="1">
|
||||
|
||||
<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"
|
||||
android:layout_marginStart="@dimen/context_menu_first_line_top_margin"
|
||||
android:layout_marginLeft="@dimen/context_menu_first_line_top_margin"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
tools:src="@drawable/ic_action_track_16" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:maxWidth="@dimen/grid_menu_item_width"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="@string/distance" />
|
||||
|
|
20
OsmAnd/res/layout/left_button_container.xml
Normal file
20
OsmAnd/res/layout/left_button_container.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/left_button_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/tab_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/shared_string_overview" />
|
||||
|
||||
</FrameLayout>
|
20
OsmAnd/res/layout/right_button_container.xml
Normal file
20
OsmAnd/res/layout/right_button_container.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/right_button_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/tab_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/map_widget_speed" />
|
||||
|
||||
</FrameLayout>
|
|
@ -2296,11 +2296,11 @@ public class OsmandAidlApi {
|
|||
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) {
|
||||
if (profileUri != null) {
|
||||
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(SILENT_IMPORT_KEY, silent);
|
||||
bundle.putString(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY, latestChanges);
|
||||
|
|
|
@ -87,6 +87,7 @@ public class UiUtilities {
|
|||
|
||||
public enum CustomRadioButtonType {
|
||||
START,
|
||||
CENTER,
|
||||
END,
|
||||
}
|
||||
|
||||
|
@ -454,10 +455,10 @@ public class UiUtilities {
|
|||
int radius = AndroidUtils.dpToPx(app, 4);
|
||||
boolean isLayoutRtl = AndroidUtils.isLayoutRtl(app);
|
||||
|
||||
TextView startButtonText = buttonsView.findViewById(R.id.left_button);
|
||||
View startButtonContainer = buttonsView.findViewById(R.id.left_button_container);
|
||||
TextView endButtonText = buttonsView.findViewById(R.id.right_button);
|
||||
View centerButtonContainer = buttonsView.findViewById(R.id.center_button_container);
|
||||
View endButtonContainer = buttonsView.findViewById(R.id.right_button_container);
|
||||
|
||||
GradientDrawable background = new GradientDrawable();
|
||||
background.setColor(UiUtilities.getColorWithAlpha(activeColor, 0.1f));
|
||||
background.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(activeColor, 0.5f));
|
||||
|
@ -467,20 +468,54 @@ public class UiUtilities {
|
|||
} else {
|
||||
background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius});
|
||||
}
|
||||
TextView startButtonText = startButtonContainer.findViewById(R.id.tab_title);
|
||||
TextView endButtonText = endButtonContainer.findViewById(R.id.tab_title);
|
||||
|
||||
endButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||
endButtonText.setTextColor(activeColor);
|
||||
startButtonContainer.setBackgroundDrawable(background);
|
||||
startButtonText.setTextColor(textColor);
|
||||
|
||||
if (centerButtonContainer != null) {
|
||||
TextView centerButtonText = centerButtonContainer.findViewById(R.id.tab_title);
|
||||
centerButtonText.setTextColor(activeColor);
|
||||
centerButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
} else if (buttonType == CustomRadioButtonType.CENTER) {
|
||||
background.setCornerRadii(new float[] {0, 0, 0, 0, 0, 0, 0, 0});
|
||||
centerButtonContainer.setBackgroundDrawable(background);
|
||||
TextView centerButtonText = centerButtonContainer.findViewById(R.id.tab_title);
|
||||
centerButtonText.setTextColor(textColor);
|
||||
|
||||
if (endButtonContainer != null) {
|
||||
TextView endButtonText = endButtonContainer.findViewById(R.id.tab_title);
|
||||
endButtonText.setTextColor(activeColor);
|
||||
endButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
if (startButtonContainer != null) {
|
||||
TextView startButtonText = startButtonContainer.findViewById(R.id.tab_title);
|
||||
startButtonText.setTextColor(activeColor);
|
||||
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
} else {
|
||||
if (isLayoutRtl) {
|
||||
background.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius});
|
||||
background.setCornerRadii(new float[] {radius, radius, 0, 0, 0, 0, radius, radius});
|
||||
} else {
|
||||
background.setCornerRadii(new float[]{0, 0, radius, radius, radius, radius, 0, 0});
|
||||
}
|
||||
TextView startButtonText = startButtonContainer.findViewById(R.id.tab_title);
|
||||
TextView endButtonText = endButtonContainer.findViewById(R.id.tab_title);
|
||||
|
||||
endButtonContainer.setBackgroundDrawable(background);
|
||||
endButtonText.setTextColor(textColor);
|
||||
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||
startButtonText.setTextColor(activeColor);
|
||||
|
||||
if (centerButtonContainer != null) {
|
||||
TextView centerButtonText = centerButtonContainer.findViewById(R.id.tab_title);
|
||||
centerButtonText.setTextColor(activeColor);
|
||||
centerButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -651,7 +651,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
protected void onNewIntent(final Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
setIntent(intent);
|
||||
intentHelper.parseLaunchIntents();
|
||||
if (!intentHelper.parseLaunchIntents()) {
|
||||
intentHelper.parseContentIntent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,7 +40,7 @@ import java.util.Map;
|
|||
public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||
|
||||
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_COL_DATE = "date"; //$NON-NLS-1$
|
||||
|
@ -59,6 +59,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
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_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;
|
||||
|
||||
|
@ -77,7 +79,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
private int points;
|
||||
private int trkPoints = 0;
|
||||
|
||||
public SavingTrackHelper(OsmandApplication ctx){
|
||||
public SavingTrackHelper(OsmandApplication ctx) {
|
||||
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
this.ctx = ctx;
|
||||
this.currentTrack = new SelectedGpxFile();
|
||||
|
@ -92,7 +94,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
+ TRACK_COL_DATE + ", " + TRACK_COL_HEADING + ")"
|
||||
+ " 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
|
||||
|
@ -101,18 +106,18 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
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$
|
||||
+ TRACK_COL_ALTITUDE + " double, " + TRACK_COL_SPEED + " double, " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ TRACK_COL_HDOP + " double, " + TRACK_COL_DATE + " long, "
|
||||
+ TRACK_COL_HEADING + " float )"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
private void createTableForPoints(SQLiteDatabase db){
|
||||
private void createTableForPoints(SQLiteDatabase db) {
|
||||
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$
|
||||
+ 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) {
|
||||
// ignore if already exists
|
||||
}
|
||||
|
@ -120,22 +125,26 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
if(oldVersion < 2){
|
||||
if (oldVersion < 2) {
|
||||
createTableForPoints(db);
|
||||
}
|
||||
if(oldVersion < 3){
|
||||
if (oldVersion < 3) {
|
||||
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_CATEGORY + " text");
|
||||
}
|
||||
if(oldVersion < 5){
|
||||
if (oldVersion < 5) {
|
||||
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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,7 +155,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
if (db != null) {
|
||||
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$
|
||||
if(query.moveToFirst()) {
|
||||
if (query.moveToFirst()) {
|
||||
res = query.getLong(0);
|
||||
}
|
||||
query.close();
|
||||
|
@ -154,7 +163,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
db.close();
|
||||
}
|
||||
}
|
||||
} catch(RuntimeException e) {
|
||||
} catch (RuntimeException e) {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -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);
|
||||
has = q.moveToFirst();
|
||||
while(has) {
|
||||
if(q.getDouble(0) != 0 || q.getDouble(1) != 0) {
|
||||
while (has) {
|
||||
if (q.getDouble(0) != 0 || q.getDouble(1) != 0) {
|
||||
break;
|
||||
}
|
||||
if(!q.moveToNext()) {
|
||||
if (!q.moveToNext()) {
|
||||
has = false;
|
||||
break;
|
||||
}
|
||||
|
@ -189,7 +198,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
db.close();
|
||||
}
|
||||
}
|
||||
} catch(RuntimeException e) {
|
||||
} catch (RuntimeException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -294,7 +303,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
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$
|
||||
+ 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()) {
|
||||
do {
|
||||
WptPt pt = new WptPt();
|
||||
|
@ -309,9 +319,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
if (color != 0) {
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -332,7 +344,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
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$
|
||||
+ 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 previousInterval = 0;
|
||||
TrkSegment segment = null;
|
||||
|
@ -358,7 +370,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
} else if (track != null && (ctx.getSettings().AUTO_SPLIT_RECORDING.get() && currentInterval < 2 * 60 * 60 * 1000)) {
|
||||
// 2 hour - same track
|
||||
segment = new TrkSegment();
|
||||
if(!newInterval) {
|
||||
if (!newInterval) {
|
||||
segment.points.add(pt);
|
||||
}
|
||||
track.segments.add(segment);
|
||||
|
@ -367,10 +379,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
track = new Track();
|
||||
segment = new TrkSegment();
|
||||
track.segments.add(segment);
|
||||
if(!newInterval) {
|
||||
if (!newInterval) {
|
||||
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)) {
|
||||
GPXFile gpx = dataTracks.get(date);
|
||||
gpx.tracks.add(track);
|
||||
|
@ -415,7 +427,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
public void startNewSegment() {
|
||||
lastTimeUpdated = 0;
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -464,7 +476,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
OsmandSettings settings) {
|
||||
// * 1000 in next line seems to be wrong with new IntervalChooseDialog
|
||||
// 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;
|
||||
if (lastPoint == null || (time - lastTimeUpdated) > 180 * 1000) {
|
||||
lastPoint = new LatLon(lat, lon);
|
||||
|
@ -529,7 +541,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
ctx.getSelectedGpxHelper().addPoint(pt, currentTrack.getModifiableGpxFile());
|
||||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -549,6 +561,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
params.add(name);
|
||||
params.add(category);
|
||||
params.add(color);
|
||||
params.add(iconName);
|
||||
params.add(iconBackground);
|
||||
|
||||
params.add(pt.getLatitude());
|
||||
params.add(pt.getLongitude());
|
||||
|
@ -563,7 +577,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
+ POINT_COL_DESCRIPTION + "=?, "
|
||||
+ POINT_COL_NAME + "=?, "
|
||||
+ POINT_COL_CATEGORY + "=?, "
|
||||
+ POINT_COL_COLOR + "=? "
|
||||
+ POINT_COL_COLOR + "=?, "
|
||||
+ POINT_COL_ICON + "=?, "
|
||||
+ POINT_COL_BACKGROUND + "=? "
|
||||
+ "WHERE "
|
||||
+ POINT_COL_LAT + "=? 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();
|
||||
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());
|
||||
currentTrack.getModifiableGpxFile().tracks.addAll(entry.getValue().tracks);
|
||||
}
|
||||
|
@ -679,10 +695,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
|
||||
private void prepareCurrentTrackForRecording() {
|
||||
if(currentTrack.getModifiableGpxFile().tracks.size() == 0) {
|
||||
if (currentTrack.getModifiableGpxFile().tracks.size() == 0) {
|
||||
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();
|
||||
currentTrack.getModifiablePointsToDisplay().add(trkSegment);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
|
||||
private int progress;
|
||||
private int maxProgress;
|
||||
private boolean uploadingFinished;
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
|
@ -44,17 +45,12 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
uploadedPhotosCounter = view.findViewById(R.id.description);
|
||||
progressBar = view.findViewById(R.id.progress_bar);
|
||||
progressBar.setMax(maxProgress);
|
||||
String titleProgress = getString(progress == maxProgress? R.string.upload_photo_completed: R.string.upload_photo);
|
||||
String descriptionProgress;
|
||||
if (progress == maxProgress) {
|
||||
descriptionProgress = getString(R.string.uploaded_count, progress, maxProgress);
|
||||
} else {
|
||||
descriptionProgress = getString(R.string.uploading_count, progress, maxProgress);
|
||||
}
|
||||
|
||||
int descriptionId = uploadingFinished ? R.string.uploaded_count : R.string.uploading_count;
|
||||
|
||||
BaseBottomSheetItem descriptionItem = new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(descriptionProgress)
|
||||
.setTitle(titleProgress)
|
||||
.setDescription(getString(descriptionId, progress, maxProgress))
|
||||
.setTitle(getString(uploadingFinished ? R.string.upload_photo_completed : R.string.upload_photo))
|
||||
.setCustomView(view)
|
||||
.create();
|
||||
items.add(descriptionItem);
|
||||
|
@ -74,9 +70,10 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
}
|
||||
|
||||
private void updateProgress(int progress) {
|
||||
int descriptionId = uploadingFinished ? R.string.uploaded_count : R.string.uploading_count;
|
||||
progressBar.setProgress(progress);
|
||||
uploadedPhotosCounter.setText((getString(R.string.uploading_count, progress, maxProgress)));
|
||||
uploadedPhotosTitle.setText(progress == maxProgress ? R.string.upload_photo_completed : R.string.upload_photo);
|
||||
uploadedPhotosCounter.setText(getString(descriptionId, progress, maxProgress));
|
||||
uploadedPhotosTitle.setText(uploadingFinished ? R.string.upload_photo_completed : R.string.upload_photo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,13 +84,10 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
|
||||
@Override
|
||||
public void uploadPhotosFinished() {
|
||||
updateProgress(maxProgress);
|
||||
if (progress == maxProgress) {
|
||||
uploadedPhotosCounter.setText((getString(R.string.uploaded_count, progress, maxProgress)));
|
||||
setDismissButtonTextId(R.string.shared_string_close);
|
||||
uploadingFinished = true;
|
||||
updateProgress(progress);
|
||||
UiUtilities.setupDialogButton(nightMode, dismissButton, getDismissButtonType(), getDismissButtonTextId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||
|
@ -104,6 +98,11 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonTextId() {
|
||||
return uploadingFinished ? R.string.shared_string_close : R.string.shared_string_cancel;
|
||||
}
|
||||
|
||||
public static UploadPhotosListener showInstance(@NonNull FragmentManager fragmentManager, int maxProgress, OnDismissListener listener) {
|
||||
UploadPhotoProgressBottomSheet fragment = new UploadPhotoProgressBottomSheet();
|
||||
fragment.setRetainInstance(true);
|
||||
|
|
|
@ -102,7 +102,7 @@ class SettingsImportTask extends BaseLoadAsyncTask<Void, Void, String> {
|
|||
}
|
||||
} else {
|
||||
Map<ExportSettingsType, List<?>> allSettingsMap = getSettingsToOperate(pluginIndependentItems, false);
|
||||
List<SettingsItem> settingsList = settingsHelper.getFilteredSettingsItems(allSettingsMap, settingsTypes, false);
|
||||
List<SettingsItem> settingsList = settingsHelper.getFilteredSettingsItems(allSettingsMap, settingsTypes, pluginIndependentItems, false);
|
||||
settingsHelper.checkDuplicates(file, settingsList, settingsList, getDuplicatesListener(file, replace));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -45,14 +46,13 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
|||
|
||||
private final OsmandApplication app;
|
||||
private final WeakReference<MapActivity> activityRef;
|
||||
private UploadPhotosListener listener;
|
||||
|
||||
private final OpenDBAPI openDBAPI = new OpenDBAPI();
|
||||
private final LatLon latLon;
|
||||
private final List<Uri> data;
|
||||
private final String[] placeId;
|
||||
private final Map<String, String> params;
|
||||
private final GetImageCardsListener imageCardListener;
|
||||
private UploadPhotosListener listener;
|
||||
|
||||
public UploadPhotosAsyncTask(MapActivity activity, List<Uri> data, LatLon latLon, String[] placeId,
|
||||
Map<String, String> params, GetImageCardsListener imageCardListener) {
|
||||
|
@ -87,13 +87,16 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
|||
}
|
||||
|
||||
protected Void doInBackground(Void... uris) {
|
||||
List<Uri> uploadedPhotoUris = new ArrayList<>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (isCancelled()) {
|
||||
break;
|
||||
}
|
||||
Uri uri = data.get(i);
|
||||
handleSelectedImage(uri);
|
||||
publishProgress(i + 1);
|
||||
if (handleSelectedImage(uri)) {
|
||||
uploadedPhotoUris.add(uri);
|
||||
publishProgress(uploadedPhotoUris.size());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -105,12 +108,13 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleSelectedImage(final Uri uri) {
|
||||
private boolean handleSelectedImage(final Uri uri) {
|
||||
boolean success = false;
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = app.getContentResolver().openInputStream(uri);
|
||||
if (inputStream != null) {
|
||||
uploadImageToPlace(inputStream);
|
||||
success = uploadImageToPlace(inputStream);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error(e);
|
||||
|
@ -118,11 +122,13 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
|||
} finally {
|
||||
Algorithms.closeStream(inputStream);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
private void uploadImageToPlace(InputStream image) {
|
||||
private boolean uploadImageToPlace(InputStream image) {
|
||||
boolean success = false;
|
||||
InputStream serverData = new ByteArrayInputStream(compressImageToJpeg(image));
|
||||
final String baseUrl = OPRConstants.getBaseUrl(app);
|
||||
String baseUrl = OPRConstants.getBaseUrl(app);
|
||||
// all these should be constant
|
||||
String url = baseUrl + "api/ipfs/image";
|
||||
String response = NetworkUtils.sendPostDataRequest(url, "file", "compressed.jpeg", serverData);
|
||||
|
@ -140,8 +146,6 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
|||
response, error);
|
||||
if (res != 200) {
|
||||
app.showToastMessage(error.toString());
|
||||
} else {
|
||||
//ok, continue
|
||||
}
|
||||
} catch (FailedVerificationException e) {
|
||||
LOG.error(e);
|
||||
|
@ -151,6 +155,7 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
|||
//image was uploaded but not added to blockchain
|
||||
checkTokenAndShowScreen();
|
||||
} else {
|
||||
success = true;
|
||||
String str = app.getString(R.string.successfully_uploaded_pattern, 1, 1);
|
||||
app.showToastMessage(str);
|
||||
//refresh the image
|
||||
|
@ -163,6 +168,7 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
|||
} else {
|
||||
checkTokenAndShowScreen();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
//This method runs on non main thread
|
||||
|
|
|
@ -43,7 +43,9 @@ public class SelectedGpxMenuController extends MenuController {
|
|||
@Override
|
||||
public void buttonPressed() {
|
||||
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);
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.MarginLayoutParams;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -35,6 +36,7 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.UiUtilities.CustomRadioButtonType;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
||||
|
@ -42,7 +44,6 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
|||
import net.osmand.plus.helpers.GpxUiHelper.LineGraphType;
|
||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||
import net.osmand.plus.track.TrackDisplayHelper;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip.CustomTabProvider;
|
||||
import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -51,6 +52,7 @@ import net.osmand.util.MapUtils;
|
|||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -72,23 +74,23 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
private GpxDisplayItem gpxItem;
|
||||
private GPXTabItemType[] tabTypes;
|
||||
|
||||
private PagerSlidingTabStrip tabs;
|
||||
private SparseArray<View> views = new SparseArray<>();
|
||||
private SegmentActionsListener actionsListener;
|
||||
|
||||
private boolean chartClicked;
|
||||
private boolean nightMode;
|
||||
|
||||
|
||||
public GPXItemPagerAdapter(@NonNull PagerSlidingTabStrip tabs,
|
||||
public GPXItemPagerAdapter(@NonNull OsmandApplication app,
|
||||
@NonNull GpxDisplayItem gpxItem,
|
||||
@NonNull TrackDisplayHelper displayHelper,
|
||||
@NonNull SegmentActionsListener actionsListener) {
|
||||
boolean nightMode, @NonNull SegmentActionsListener actionsListener) {
|
||||
super();
|
||||
this.tabs = tabs;
|
||||
this.app = app;
|
||||
this.gpxItem = gpxItem;
|
||||
this.nightMode = nightMode;
|
||||
this.displayHelper = displayHelper;
|
||||
this.actionsListener = actionsListener;
|
||||
app = (OsmandApplication) tabs.getContext().getApplicationContext();
|
||||
iconsCache = app.getUIUtilities();
|
||||
fetchTabTypes();
|
||||
}
|
||||
|
@ -556,40 +558,60 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
return view == object;
|
||||
}
|
||||
|
||||
int singleTabLayoutId[] = {R.layout.center_button_container};
|
||||
int doubleTabsLayoutIds[] = {R.layout.left_button_container, R.layout.right_button_container};
|
||||
int tripleTabsLayoutIds[] = {R.layout.left_button_container, R.layout.center_button_container, R.layout.right_button_container};
|
||||
|
||||
@Override
|
||||
public View getCustomTabView(@NonNull ViewGroup parent, int position) {
|
||||
View tab = LayoutInflater.from(parent.getContext()).inflate(R.layout.gpx_tab, parent, false);
|
||||
int layoutId;
|
||||
int count = getCount();
|
||||
if (count == 1) {
|
||||
layoutId = singleTabLayoutId[position];
|
||||
} else if (count == 2) {
|
||||
layoutId = doubleTabsLayoutIds[position];
|
||||
} else {
|
||||
layoutId = tripleTabsLayoutIds[position];
|
||||
}
|
||||
View tab = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
|
||||
tab.setTag(tabTypes[position].name());
|
||||
deselect(tab);
|
||||
return tab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(View tab) {
|
||||
GPXTabItemType tabType = GPXTabItemType.valueOf((String) tab.getTag());
|
||||
ImageView img = tab.findViewById(R.id.tab_image);
|
||||
switch (tabs.getTabSelectionType()) {
|
||||
case ALPHA:
|
||||
img.setAlpha(tabs.getTabTextSelectedAlpha());
|
||||
break;
|
||||
case SOLID_COLOR:
|
||||
img.setImageDrawable(iconsCache.getPaintedIcon(tabType.getIconId(), tabs.getTextColor()));
|
||||
break;
|
||||
}
|
||||
int index = Arrays.asList(tabTypes).indexOf(tabType);
|
||||
View parent = (View) tab.getParent();
|
||||
UiUtilities.updateCustomRadioButtons(app, parent, nightMode, getCustomRadioButtonType(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deselect(View tab) {
|
||||
GPXTabItemType tabType = GPXTabItemType.valueOf((String) tab.getTag());
|
||||
ImageView img = tab.findViewById(R.id.tab_image);
|
||||
switch (tabs.getTabSelectionType()) {
|
||||
case ALPHA:
|
||||
img.setAlpha(tabs.getTabTextAlpha());
|
||||
break;
|
||||
case SOLID_COLOR:
|
||||
img.setImageDrawable(iconsCache.getPaintedIcon(tabType.getIconId(), tabs.getTabInactiveTextColor()));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tabStylesUpdated(View tabsContainer, int currentPosition) {
|
||||
ViewGroup.MarginLayoutParams params = (MarginLayoutParams) tabsContainer.getLayoutParams();
|
||||
params.height = app.getResources().getDimensionPixelSize(R.dimen.dialog_button_height);
|
||||
tabsContainer.setLayoutParams(params);
|
||||
UiUtilities.updateCustomRadioButtons(app, tabsContainer, nightMode, getCustomRadioButtonType(currentPosition));
|
||||
}
|
||||
|
||||
private CustomRadioButtonType getCustomRadioButtonType(int index) {
|
||||
int count = getCount();
|
||||
CustomRadioButtonType type = CustomRadioButtonType.CENTER;
|
||||
if (count == 2) {
|
||||
type = index > 0 ? CustomRadioButtonType.END : CustomRadioButtonType.START;
|
||||
} else if (count == 3) {
|
||||
if (index == 0) {
|
||||
type = CustomRadioButtonType.START;
|
||||
} else if (index == 2) {
|
||||
type = CustomRadioButtonType.END;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.ArrayAdapter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
|
@ -56,7 +55,7 @@ public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
|||
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
||||
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
||||
|
||||
pager.setAdapter(new GPXItemPagerAdapter(tabLayout, item, displayHelper, listener));
|
||||
pager.setAdapter(new GPXItemPagerAdapter(app, item, displayHelper, nightMode, listener));
|
||||
if (create) {
|
||||
tabLayout.setViewPager(pager);
|
||||
} else {
|
||||
|
@ -72,15 +71,8 @@ public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
|||
View row = UiUtilities.getInflater(context, nightMode).inflate(R.layout.gpx_list_item_tab_content, root, false);
|
||||
|
||||
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
||||
tabLayout.setTabBackground(R.color.color_transparent);
|
||||
tabLayout.setIndicatorColorResource(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
||||
tabLayout.setIndicatorBgColorResource(nightMode ? R.color.divider_color_dark : R.color.divider_color_light);
|
||||
tabLayout.setIndicatorHeight(AndroidUtils.dpToPx(context, 1f));
|
||||
if (!nightMode) {
|
||||
tabLayout.setTextColor(tabLayout.getIndicatorColor());
|
||||
tabLayout.setTabInactiveTextColor(ContextCompat.getColor(row.getContext(), R.color.text_color_secondary_light));
|
||||
}
|
||||
tabLayout.setTextSize(AndroidUtils.spToPx(context, 12f));
|
||||
tabLayout.setTabBackground(AndroidUtils.resolveAttribute(context, R.attr.btn_bg_border_inactive));
|
||||
tabLayout.setIndicatorHeight(0);
|
||||
tabLayout.setShouldExpand(true);
|
||||
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
||||
pager.setSwipeable(false);
|
||||
|
|
|
@ -82,12 +82,12 @@ public class OnlineRoutingHelper {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public OnlineRoutingResponse calculateRouteOnline(@NonNull OnlineRoutingEngine engine,
|
||||
private OnlineRoutingResponse calculateRouteOnline(@NonNull OnlineRoutingEngine engine,
|
||||
@NonNull List<LatLon> path,
|
||||
boolean leftSideNavigation) throws IOException, JSONException {
|
||||
String url = engine.getFullUrl(path);
|
||||
String content = makeRequest(url);
|
||||
return engine.parseServerResponse(content, leftSideNavigation);
|
||||
return engine.parseServerResponse(content, app, leftSideNavigation);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -5,6 +5,7 @@ import androidx.annotation.Nullable;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.onlinerouting.EngineParameter;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingResponse;
|
||||
|
@ -84,6 +85,7 @@ public class GraphhopperEngine extends OnlineRoutingEngine {
|
|||
@Nullable
|
||||
@Override
|
||||
public OnlineRoutingResponse parseServerResponse(@NonNull String content,
|
||||
@NonNull OsmandApplication app,
|
||||
boolean leftSideNavigation) throws JSONException {
|
||||
JSONObject obj = new JSONObject(content);
|
||||
JSONObject root = obj.getJSONArray("paths").getJSONObject(0);
|
||||
|
@ -96,25 +98,20 @@ public class GraphhopperEngine extends OnlineRoutingEngine {
|
|||
JSONArray instructions = root.getJSONArray("instructions");
|
||||
List<RouteDirectionInfo> directions = new ArrayList<>();
|
||||
for (int i = 0; i < instructions.length(); i++) {
|
||||
JSONObject item = instructions.getJSONObject(i);
|
||||
int sign = Integer.parseInt(item.getString("sign"));
|
||||
int distance = (int) Math.round(Double.parseDouble(item.getString("distance")));
|
||||
String description = item.getString("text");
|
||||
String streetName = item.getString("street_name");
|
||||
int timeInSeconds = (int) Math.round(Integer.parseInt(item.getString("time")) / 1000f);
|
||||
JSONArray interval = item.getJSONArray("interval");
|
||||
JSONObject instruction = instructions.getJSONObject(i);
|
||||
int distance = (int) Math.round(instruction.getDouble("distance"));
|
||||
String description = instruction.getString("text");
|
||||
String streetName = instruction.getString("street_name");
|
||||
int timeInSeconds = Math.round(instruction.getInt("time") / 1000f);
|
||||
JSONArray interval = instruction.getJSONArray("interval");
|
||||
int startPointOffset = interval.getInt(0);
|
||||
int endPointOffset = interval.getInt(1);
|
||||
|
||||
float averageSpeed = (float) distance / timeInSeconds;
|
||||
TurnType turnType = identifyTurnType(sign, leftSideNavigation);
|
||||
// TODO turnType.setTurnAngle()
|
||||
|
||||
TurnType turnType = parseTurnType(instruction, leftSideNavigation);
|
||||
RouteDirectionInfo direction = new RouteDirectionInfo(averageSpeed, turnType);
|
||||
|
||||
direction.routePointOffset = startPointOffset;
|
||||
if (turnType != null && turnType.isRoundAbout()) {
|
||||
direction.routeEndPointOffset = endPointOffset;
|
||||
}
|
||||
direction.setDescriptionRoute(description);
|
||||
direction.setStreetName(streetName);
|
||||
direction.setDistance(distance);
|
||||
|
@ -123,27 +120,33 @@ public class GraphhopperEngine extends OnlineRoutingEngine {
|
|||
return new OnlineRoutingResponse(route, directions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean parseServerMessage(@NonNull StringBuilder sb,
|
||||
@NonNull String content) throws JSONException {
|
||||
JSONObject obj = new JSONObject(content);
|
||||
if (obj.has("message")) {
|
||||
String message = obj.getString("message");
|
||||
sb.append(message);
|
||||
@NonNull
|
||||
private TurnType parseTurnType(@NonNull JSONObject instruction,
|
||||
boolean leftSide) throws JSONException {
|
||||
int sign = instruction.getInt("sign");
|
||||
TurnType turnType = identifyTurnType(sign, leftSide);
|
||||
|
||||
if (turnType == null) {
|
||||
turnType = TurnType.straight();
|
||||
} else if (turnType.isRoundAbout()) {
|
||||
if (instruction.has("exit_number")) {
|
||||
int exit = instruction.getInt("exit_number");
|
||||
turnType.setExitOut(exit);
|
||||
}
|
||||
return obj.has("paths");
|
||||
if (instruction.has("turn_angle")) {
|
||||
float angle = (float) instruction.getDouble("turn_angle");
|
||||
turnType.setTurnAngle(angle);
|
||||
}
|
||||
} else {
|
||||
// TODO turnType.setTurnAngle()
|
||||
}
|
||||
|
||||
return turnType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sign - a number which specifies the turn type to show (Graphhopper API value)
|
||||
* @return a TurnType object defined in OsmAnd which is equivalent to a value from the Graphhopper API
|
||||
*
|
||||
* For future compatibility it is important that all clients
|
||||
* are able to handle also unknown instruction sign numbers
|
||||
*/
|
||||
@Nullable
|
||||
public static TurnType identifyTurnType(int sign, boolean leftSide) {
|
||||
int id = INVALID_ID;
|
||||
Integer id = null;
|
||||
|
||||
if (sign == -98) {
|
||||
// an U-turn without the knowledge
|
||||
|
@ -192,6 +195,7 @@ public class GraphhopperEngine extends OnlineRoutingEngine {
|
|||
|
||||
} else if (sign == 4) {
|
||||
// the finish instruction before the last point
|
||||
id = TurnType.C;
|
||||
|
||||
} else if (sign == 5) {
|
||||
// the instruction before a via point
|
||||
|
@ -209,6 +213,17 @@ public class GraphhopperEngine extends OnlineRoutingEngine {
|
|||
id = TurnType.TRU;
|
||||
}
|
||||
|
||||
return id != INVALID_ID ? TurnType.valueOf(id, leftSide) : null;
|
||||
return id != null ? TurnType.valueOf(id, leftSide) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean parseServerMessage(@NonNull StringBuilder sb,
|
||||
@NonNull String content) throws JSONException {
|
||||
JSONObject obj = new JSONObject(content);
|
||||
if (obj.has("message")) {
|
||||
String message = obj.getString("message");
|
||||
sb.append(message);
|
||||
}
|
||||
return obj.has("paths");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
|
|||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.onlinerouting.EngineParameter;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingFactory;
|
||||
|
@ -33,7 +34,6 @@ public abstract class OnlineRoutingEngine implements Cloneable {
|
|||
|
||||
public final static String ONLINE_ROUTING_ENGINE_PREFIX = "online_routing_engine_";
|
||||
public final static VehicleType CUSTOM_VEHICLE = new VehicleType("", R.string.shared_string_custom);
|
||||
public final static int INVALID_ID = -1;
|
||||
|
||||
private final Map<String, String> params = new HashMap<>();
|
||||
private final List<VehicleType> allowedVehicles = new ArrayList<>();
|
||||
|
@ -100,6 +100,7 @@ public abstract class OnlineRoutingEngine implements Cloneable {
|
|||
|
||||
@Nullable
|
||||
public abstract OnlineRoutingResponse parseServerResponse(@NonNull String content,
|
||||
@NonNull OsmandApplication app,
|
||||
boolean leftSideNavigation) throws JSONException;
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -5,6 +5,7 @@ import androidx.annotation.Nullable;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.onlinerouting.EngineParameter;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingResponse;
|
||||
|
@ -81,6 +82,7 @@ public class OrsEngine extends OnlineRoutingEngine {
|
|||
@Nullable
|
||||
@Override
|
||||
public OnlineRoutingResponse parseServerResponse(@NonNull String content,
|
||||
@NonNull OsmandApplication app,
|
||||
boolean leftSideNavigation) throws JSONException {
|
||||
JSONObject obj = new JSONObject(content);
|
||||
JSONArray array = obj.getJSONArray("features").getJSONObject(0)
|
||||
|
|
|
@ -5,19 +5,27 @@ import androidx.annotation.Nullable;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.onlinerouting.EngineParameter;
|
||||
import net.osmand.plus.onlinerouting.OnlineRoutingResponse;
|
||||
import net.osmand.plus.onlinerouting.VehicleType;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.GeoPolylineParserUtil;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.util.Algorithms.isEmpty;
|
||||
import static net.osmand.util.Algorithms.objectEquals;
|
||||
|
||||
public class OsrmEngine extends OnlineRoutingEngine {
|
||||
|
||||
|
@ -70,17 +78,154 @@ public class OsrmEngine extends OnlineRoutingEngine {
|
|||
@Nullable
|
||||
@Override
|
||||
public OnlineRoutingResponse parseServerResponse(@NonNull String content,
|
||||
@NonNull OsmandApplication app,
|
||||
boolean leftSideNavigation) throws JSONException {
|
||||
JSONObject obj = new JSONObject(content);
|
||||
String encoded = obj.getJSONArray("routes").getJSONObject(0).getString("geometry");
|
||||
List<LatLon> points = GeoPolylineParserUtil.parse(encoded, GeoPolylineParserUtil.PRECISION_5);
|
||||
if (!isEmpty(points)) {
|
||||
JSONObject routeInfo = obj.getJSONArray("routes").getJSONObject(0);
|
||||
String encodedPoints = routeInfo.getString("geometry");
|
||||
List<LatLon> points = GeoPolylineParserUtil.parse(encodedPoints, GeoPolylineParserUtil.PRECISION_5);
|
||||
if (isEmpty(points)) return null;
|
||||
|
||||
List<Location> route = convertRouteToLocationsList(points);
|
||||
return new OnlineRoutingResponse(route, null);
|
||||
List<RouteDirectionInfo> directions = new ArrayList<>();
|
||||
int startSearchingId = 0;
|
||||
JSONArray legs = routeInfo.getJSONArray("legs");
|
||||
for (int i = 0; i < legs.length(); i++) {
|
||||
JSONObject leg = legs.getJSONObject(i);
|
||||
if (!leg.has("steps")) continue;
|
||||
|
||||
JSONArray steps = leg.getJSONArray("steps");
|
||||
for (int j = 0; j < steps.length(); j++) {
|
||||
JSONObject instruction = steps.getJSONObject(j);
|
||||
JSONObject maneuver = instruction.getJSONObject("maneuver");
|
||||
String maneuverType = maneuver.getString("type");
|
||||
|
||||
JSONArray location = maneuver.getJSONArray("location");
|
||||
double lon = location.getDouble(0);
|
||||
double lat = location.getDouble(1);
|
||||
Integer routePointOffset = getLocationIndexInList(route, startSearchingId, lat, lon);
|
||||
if (routePointOffset == null) continue;
|
||||
startSearchingId = routePointOffset;
|
||||
|
||||
// in meters
|
||||
int distance = (int) Math.round(instruction.getDouble("distance"));
|
||||
// in seconds
|
||||
int duration = (int) Math.round(instruction.getDouble("duration"));
|
||||
|
||||
float averageSpeed = (float) distance / duration;
|
||||
TurnType turnType = parseTurnType(maneuver, leftSideNavigation);
|
||||
RouteDirectionInfo direction = new RouteDirectionInfo(averageSpeed, turnType);
|
||||
direction.setDistance(distance);
|
||||
|
||||
String streetName = instruction.getString("name");
|
||||
String description = "";
|
||||
if (!objectEquals(maneuverType, "arrive")) {
|
||||
description = RouteCalculationResult.toString(turnType, app, false) + " " + streetName;
|
||||
}
|
||||
description = description.trim();
|
||||
|
||||
direction.setStreetName(streetName);
|
||||
direction.setDescriptionRoute(description);
|
||||
direction.routePointOffset = routePointOffset;
|
||||
directions.add(direction);
|
||||
}
|
||||
}
|
||||
|
||||
return new OnlineRoutingResponse(route, directions);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Integer getLocationIndexInList(@NonNull List<Location> locations,
|
||||
int startIndex, double lat, double lon) {
|
||||
for (int i = startIndex; i < locations.size(); i++) {
|
||||
Location l = locations.get(i);
|
||||
if (MapUtils.areLatLonEqual(l, lat, lon)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private TurnType parseTurnType(@NonNull JSONObject maneuver,
|
||||
boolean leftSide) throws JSONException {
|
||||
TurnType turnType = null;
|
||||
|
||||
String type = maneuver.getString("type");
|
||||
String modifier = null;
|
||||
if (maneuver.has("modifier")) {
|
||||
modifier = maneuver.getString("modifier");
|
||||
}
|
||||
|
||||
if (objectEquals(type, "roundabout")
|
||||
|| objectEquals(type, "rotary")
|
||||
|| objectEquals(type, "roundabout turn")) {
|
||||
if (maneuver.has("exit")) {
|
||||
int exit = maneuver.getInt("exit");
|
||||
turnType = TurnType.getExitTurn(exit, 0.0f, leftSide);
|
||||
} else if (modifier != null) {
|
||||
// for simple roundabout turn without "exit" parameter
|
||||
turnType = identifyTurnType(modifier, leftSide);
|
||||
}
|
||||
} else {
|
||||
// for other maneuver types find TurnType
|
||||
// like a basic turn into direction of the modifier
|
||||
if (modifier != null) {
|
||||
turnType = identifyTurnType(modifier, leftSide);
|
||||
}
|
||||
}
|
||||
if (turnType == null) {
|
||||
turnType = TurnType.straight();
|
||||
}
|
||||
|
||||
int bearingBefore = maneuver.getInt("bearing_before");
|
||||
int bearingAfter = maneuver.getInt("bearing_after");
|
||||
float angle = (float) MapUtils.degreesDiff(bearingAfter, bearingBefore);
|
||||
turnType.setTurnAngle(angle);
|
||||
|
||||
return turnType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TurnType identifyTurnType(@NonNull String modifier,
|
||||
boolean leftSide) {
|
||||
Integer id = null;
|
||||
switch (modifier) {
|
||||
case "uturn":
|
||||
id = TurnType.TU;
|
||||
break;
|
||||
|
||||
case "sharp right":
|
||||
id = TurnType.TSHR;
|
||||
break;
|
||||
|
||||
case "right":
|
||||
id = TurnType.TR;
|
||||
break;
|
||||
|
||||
case "slight right":
|
||||
id = TurnType.TSLR;
|
||||
break;
|
||||
|
||||
case "straight":
|
||||
id = TurnType.C;
|
||||
break;
|
||||
|
||||
case "slight left":
|
||||
id = TurnType.TSLL;
|
||||
break;
|
||||
|
||||
case "left":
|
||||
id = TurnType.TL;
|
||||
break;
|
||||
|
||||
case "sharp left":
|
||||
id = TurnType.TSHL;
|
||||
break;
|
||||
}
|
||||
return id != null ? TurnType.valueOf(id, leftSide) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean parseServerMessage(@NonNull StringBuilder sb,
|
||||
@NonNull String content) throws JSONException {
|
||||
|
|
|
@ -711,7 +711,7 @@ public class RouteCalculationResult {
|
|||
if (directions != null && directions.size() > 1) {
|
||||
for (int i = 1; i < directions.size();) {
|
||||
RouteDirectionInfo r = directions.get(i);
|
||||
if (r.getTurnType() != null && r.getTurnType().getValue() == TurnType.C) {
|
||||
if (r.getTurnType().getValue() == TurnType.C) {
|
||||
RouteDirectionInfo prev = directions.get(i - 1);
|
||||
prev.setAverageSpeed((prev.distance + r.distance)
|
||||
/ (prev.distance / prev.getAverageSpeed() + r.distance / r.getAverageSpeed()));
|
||||
|
|
|
@ -1206,7 +1206,7 @@ public class RouteProvider {
|
|||
helper.calculateRouteOnline(stringKey, getPathFromParams(params), params.leftSide);
|
||||
if (response != null) {
|
||||
params.intermediates = null;
|
||||
return new RouteCalculationResult(response.getRoute(), response.getDirections(), params, null, true);
|
||||
return new RouteCalculationResult(response.getRoute(), response.getDirections(), params, null, false);
|
||||
} else {
|
||||
return new RouteCalculationResult("Route is empty");
|
||||
}
|
||||
|
|
|
@ -480,19 +480,21 @@ public class SettingsHelper {
|
|||
typesMap.putAll(getMyPlacesItems());
|
||||
typesMap.putAll(getResourcesItems());
|
||||
|
||||
return getFilteredSettingsItems(typesMap, settingsTypes, export);
|
||||
return getFilteredSettingsItems(typesMap, settingsTypes, Collections.<SettingsItem>emptyList(), export);
|
||||
}
|
||||
|
||||
public List<SettingsItem> getFilteredSettingsItems(Map<ExportSettingsType, List<?>> allSettingsMap,
|
||||
List<ExportSettingsType> settingsTypes, boolean export) {
|
||||
List<SettingsItem> settingsItems = new ArrayList<>();
|
||||
public List<SettingsItem> getFilteredSettingsItems(
|
||||
Map<ExportSettingsType, List<?>> allSettingsMap, List<ExportSettingsType> settingsTypes,
|
||||
@NonNull List<SettingsItem> settingsItems, boolean export
|
||||
) {
|
||||
List<SettingsItem> filteredSettingsItems = new ArrayList<>();
|
||||
for (ExportSettingsType settingsType : settingsTypes) {
|
||||
List<?> settingsDataObjects = allSettingsMap.get(settingsType);
|
||||
if (settingsDataObjects != null) {
|
||||
settingsItems.addAll(prepareSettingsItems(settingsDataObjects, export));
|
||||
filteredSettingsItems.addAll(prepareSettingsItems(settingsDataObjects, settingsItems, export));
|
||||
}
|
||||
}
|
||||
return settingsItems;
|
||||
return filteredSettingsItems;
|
||||
}
|
||||
|
||||
public Map<ExportSettingsCategory, SettingsCategoryItems> getSettingsByCategory(boolean addProfiles) {
|
||||
|
@ -693,8 +695,8 @@ public class SettingsHelper {
|
|||
return files;
|
||||
}
|
||||
|
||||
public List<SettingsItem> prepareSettingsItems(List<?> data, boolean export) {
|
||||
List<SettingsItem> settingsItems = new ArrayList<>();
|
||||
public List<SettingsItem> prepareSettingsItems(List<?> data, List<SettingsItem> settingsItems, boolean export) {
|
||||
List<SettingsItem> result = new ArrayList<>();
|
||||
List<QuickAction> quickActions = new ArrayList<>();
|
||||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
||||
|
@ -719,13 +721,15 @@ public class SettingsHelper {
|
|||
try {
|
||||
File file = (File) object;
|
||||
if (file.getName().endsWith(IndexConstants.GPX_FILE_EXT)) {
|
||||
settingsItems.add(new GpxSettingsItem(app, file));
|
||||
result.add(new GpxSettingsItem(app, file));
|
||||
} else {
|
||||
settingsItems.add(new FileSettingsItem(app, file));
|
||||
result.add(new FileSettingsItem(app, file));
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOG.warn("Trying to export unsuported file type", e);
|
||||
}
|
||||
} else if (object instanceof FileSettingsItem) {
|
||||
result.add((FileSettingsItem) object);
|
||||
} else if (object instanceof AvoidRoadInfo) {
|
||||
avoidRoads.add((AvoidRoadInfo) object);
|
||||
} else if (object instanceof ApplicationModeBean) {
|
||||
|
@ -746,65 +750,100 @@ public class SettingsHelper {
|
|||
} else if (object instanceof HistoryEntry) {
|
||||
historyEntries.add((HistoryEntry) object);
|
||||
} else if (object instanceof GlobalSettingsItem) {
|
||||
settingsItems.add((GlobalSettingsItem) object);
|
||||
result.add((GlobalSettingsItem) object);
|
||||
} else if (object instanceof OnlineRoutingEngine) {
|
||||
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||
}
|
||||
}
|
||||
if (!quickActions.isEmpty()) {
|
||||
settingsItems.add(new QuickActionsSettingsItem(app, quickActions));
|
||||
QuickActionsSettingsItem baseItem = getBaseItem(SettingsItemType.QUICK_ACTIONS, QuickActionsSettingsItem.class, settingsItems);
|
||||
result.add(new QuickActionsSettingsItem(app, baseItem, quickActions));
|
||||
}
|
||||
if (!poiUIFilters.isEmpty()) {
|
||||
settingsItems.add(new PoiUiFiltersSettingsItem(app, poiUIFilters));
|
||||
PoiUiFiltersSettingsItem baseItem = getBaseItem(SettingsItemType.POI_UI_FILTERS, PoiUiFiltersSettingsItem.class, settingsItems);
|
||||
result.add(new PoiUiFiltersSettingsItem(app, baseItem, poiUIFilters));
|
||||
}
|
||||
if (!tileSourceTemplates.isEmpty()) {
|
||||
settingsItems.add(new MapSourcesSettingsItem(app, tileSourceTemplates));
|
||||
MapSourcesSettingsItem baseItem = getBaseItem(SettingsItemType.MAP_SOURCES, MapSourcesSettingsItem.class, settingsItems);
|
||||
result.add(new MapSourcesSettingsItem(app, baseItem, tileSourceTemplates));
|
||||
}
|
||||
if (!avoidRoads.isEmpty()) {
|
||||
settingsItems.add(new AvoidRoadsSettingsItem(app, avoidRoads));
|
||||
AvoidRoadsSettingsItem baseItem = getBaseItem(SettingsItemType.AVOID_ROADS, AvoidRoadsSettingsItem.class, settingsItems);
|
||||
result.add(new AvoidRoadsSettingsItem(app, baseItem, avoidRoads));
|
||||
}
|
||||
if (!appModeBeans.isEmpty()) {
|
||||
for (ApplicationModeBean modeBean : appModeBeans) {
|
||||
if (export) {
|
||||
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
|
||||
if (mode != null) {
|
||||
settingsItems.add(new ProfileSettingsItem(app, mode));
|
||||
result.add(new ProfileSettingsItem(app, mode));
|
||||
}
|
||||
} else {
|
||||
settingsItems.add(new ProfileSettingsItem(app, null, modeBean));
|
||||
result.add(new ProfileSettingsItem(app, getBaseProfileSettingsItem(modeBean, settingsItems), modeBean));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!osmNotesPointList.isEmpty()) {
|
||||
settingsItems.add(new OsmNotesSettingsItem(app, osmNotesPointList));
|
||||
OsmNotesSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_NOTES, OsmNotesSettingsItem.class, settingsItems);
|
||||
result.add(new OsmNotesSettingsItem(app, baseItem, osmNotesPointList));
|
||||
}
|
||||
if (!osmEditsPointList.isEmpty()) {
|
||||
settingsItems.add(new OsmEditsSettingsItem(app, osmEditsPointList));
|
||||
OsmEditsSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_EDITS, OsmEditsSettingsItem.class, settingsItems);
|
||||
result.add(new OsmEditsSettingsItem(app, baseItem, osmEditsPointList));
|
||||
}
|
||||
if (!favoriteGroups.isEmpty()) {
|
||||
settingsItems.add(new FavoritesSettingsItem(app, favoriteGroups));
|
||||
FavoritesSettingsItem baseItem = getBaseItem(SettingsItemType.FAVOURITES, FavoritesSettingsItem.class, settingsItems);
|
||||
result.add(new FavoritesSettingsItem(app, baseItem, favoriteGroups));
|
||||
}
|
||||
if (!markersGroups.isEmpty()) {
|
||||
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||
for (MapMarkersGroup group : markersGroups) {
|
||||
mapMarkers.addAll(group.getMarkers());
|
||||
}
|
||||
settingsItems.add(new MarkersSettingsItem(app, mapMarkers));
|
||||
MarkersSettingsItem baseItem = getBaseItem(SettingsItemType.ACTIVE_MARKERS, MarkersSettingsItem.class, settingsItems);
|
||||
result.add(new MarkersSettingsItem(app, baseItem, mapMarkers));
|
||||
}
|
||||
if (!markersHistoryGroups.isEmpty()) {
|
||||
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||
for (MapMarkersGroup group : markersHistoryGroups) {
|
||||
mapMarkers.addAll(group.getMarkers());
|
||||
}
|
||||
settingsItems.add(new HistoryMarkersSettingsItem(app, mapMarkers));
|
||||
HistoryMarkersSettingsItem baseItem = getBaseItem(SettingsItemType.HISTORY_MARKERS, HistoryMarkersSettingsItem.class, settingsItems);
|
||||
result.add(new HistoryMarkersSettingsItem(app, baseItem, mapMarkers));
|
||||
}
|
||||
if (!historyEntries.isEmpty()) {
|
||||
settingsItems.add(new SearchHistorySettingsItem(app, historyEntries));
|
||||
SearchHistorySettingsItem baseItem = getBaseItem(SettingsItemType.SEARCH_HISTORY, SearchHistorySettingsItem.class, settingsItems);
|
||||
result.add(new SearchHistorySettingsItem(app, baseItem, historyEntries));
|
||||
}
|
||||
if (!onlineRoutingEngines.isEmpty()) {
|
||||
settingsItems.add(new OnlineRoutingSettingsItem(app, onlineRoutingEngines));
|
||||
OnlineRoutingSettingsItem baseItem = getBaseItem(SettingsItemType.ONLINE_ROUTING_ENGINES, OnlineRoutingSettingsItem.class, settingsItems);
|
||||
result.add(new OnlineRoutingSettingsItem(app, baseItem, onlineRoutingEngines));
|
||||
}
|
||||
return settingsItems;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ProfileSettingsItem getBaseProfileSettingsItem(ApplicationModeBean modeBean, List<SettingsItem> settingsItems) {
|
||||
for (SettingsItem settingsItem : settingsItems) {
|
||||
if (settingsItem.getType() == SettingsItemType.PROFILE) {
|
||||
ProfileSettingsItem profileItem = (ProfileSettingsItem) settingsItem;
|
||||
ApplicationModeBean bean = profileItem.getModeBean();
|
||||
if (Algorithms.objectEquals(bean.stringKey, modeBean.stringKey) && Algorithms.objectEquals(bean.userProfileName, modeBean.userProfileName)) {
|
||||
return profileItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T> T getBaseItem(SettingsItemType settingsItemType, Class<T> clazz, List<SettingsItem> settingsItems) {
|
||||
for (SettingsItem settingsItem : settingsItems) {
|
||||
if (settingsItem.getType() == settingsItemType && clazz.isInstance(settingsItem)) {
|
||||
return clazz.cast(settingsItem);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Map<ExportSettingsCategory, SettingsCategoryItems> getSettingsToOperateByCategory(List<SettingsItem> items, boolean importComplete) {
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.commons.logging.Log;
|
|||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -150,7 +151,7 @@ public class ExportSettingsFragment extends BaseSettingsListFragment {
|
|||
showExportProgressDialog();
|
||||
File tempDir = FileUtils.getTempDir(app);
|
||||
String fileName = getFileName();
|
||||
List<SettingsItem> items = app.getSettingsHelper().prepareSettingsItems(adapter.getData(), true);
|
||||
List<SettingsItem> items = app.getSettingsHelper().prepareSettingsItems(adapter.getData(), Collections.<SettingsItem>emptyList(), true);
|
||||
progress.setMax(getMaxProgress(items));
|
||||
app.getSettingsHelper().exportSettings(tempDir, fileName, getSettingsExportListener(), items, true);
|
||||
}
|
||||
|
|
|
@ -18,57 +18,24 @@ import androidx.fragment.app.FragmentManager;
|
|||
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.plus.AppInitializer;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.download.ReloadIndexesTask;
|
||||
import net.osmand.plus.download.ReloadIndexesTask.ReloadIndexesListener;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.plus.mapmarkers.MapMarker;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersGroup;
|
||||
import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine;
|
||||
import net.osmand.plus.osmedit.OpenstreetmapPoint;
|
||||
import net.osmand.plus.osmedit.OsmNotesPoint;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
|
||||
import net.osmand.plus.settings.backend.ExportSettingsType;
|
||||
import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.FavoritesSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.FileSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.GlobalSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.GpxSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.HistoryMarkersSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.MapSourcesSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.MarkersSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.OnlineRoutingSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.PoiUiFiltersSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.ProfileSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.QuickActionsSettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.SearchHistorySettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsHelper;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
||||
import net.osmand.plus.settings.backend.backup.SettingsItemType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportSettingsFragment extends BaseSettingsListFragment {
|
||||
|
@ -177,7 +144,7 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
|||
}
|
||||
|
||||
private void importItems() {
|
||||
List<SettingsItem> selectedItems = getSettingsItemsFromData(adapter.getData());
|
||||
List<SettingsItem> selectedItems = settingsHelper.prepareSettingsItems(adapter.getData(), settingsItems, false);
|
||||
if (file != null && settingsItems != null) {
|
||||
duplicateStartTime = System.currentTimeMillis();
|
||||
settingsHelper.checkDuplicates(file, settingsItems, selectedItems, getDuplicatesListener());
|
||||
|
@ -272,181 +239,6 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
|||
this.settingsItems = settingsItems;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ProfileSettingsItem getBaseProfileSettingsItem(ApplicationModeBean modeBean) {
|
||||
for (SettingsItem settingsItem : settingsItems) {
|
||||
if (settingsItem.getType() == SettingsItemType.PROFILE) {
|
||||
ProfileSettingsItem profileItem = (ProfileSettingsItem) settingsItem;
|
||||
ApplicationModeBean bean = profileItem.getModeBean();
|
||||
if (Algorithms.objectEquals(bean.stringKey, modeBean.stringKey) && Algorithms.objectEquals(bean.userProfileName, modeBean.userProfileName)) {
|
||||
return profileItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private QuickActionsSettingsItem getBaseQuickActionsSettingsItem() {
|
||||
for (SettingsItem settingsItem : settingsItems) {
|
||||
if (settingsItem.getType() == SettingsItemType.QUICK_ACTIONS) {
|
||||
return (QuickActionsSettingsItem) settingsItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PoiUiFiltersSettingsItem getBasePoiUiFiltersSettingsItem() {
|
||||
for (SettingsItem settingsItem : settingsItems) {
|
||||
if (settingsItem.getType() == SettingsItemType.POI_UI_FILTERS) {
|
||||
return (PoiUiFiltersSettingsItem) settingsItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MapSourcesSettingsItem getBaseMapSourcesSettingsItem() {
|
||||
for (SettingsItem settingsItem : settingsItems) {
|
||||
if (settingsItem.getType() == SettingsItemType.MAP_SOURCES) {
|
||||
return (MapSourcesSettingsItem) settingsItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private AvoidRoadsSettingsItem getBaseAvoidRoadsSettingsItem() {
|
||||
for (SettingsItem settingsItem : settingsItems) {
|
||||
if (settingsItem.getType() == SettingsItemType.AVOID_ROADS) {
|
||||
return (AvoidRoadsSettingsItem) settingsItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T> T getBaseItem(SettingsItemType settingsItemType, Class<T> clazz) {
|
||||
for (SettingsItem settingsItem : settingsItems) {
|
||||
if (settingsItem.getType() == settingsItemType && clazz.isInstance(settingsItem)) {
|
||||
return clazz.cast(settingsItem);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<SettingsItem> getSettingsItemsFromData(List<?> data) {
|
||||
List<SettingsItem> settingsItems = new ArrayList<>();
|
||||
List<ApplicationModeBean> appModeBeans = new ArrayList<>();
|
||||
List<QuickAction> quickActions = new ArrayList<>();
|
||||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
||||
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
|
||||
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
|
||||
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
|
||||
List<FavoriteGroup> favoriteGroups = new ArrayList<>();
|
||||
List<MapMarkersGroup> markersGroups = new ArrayList<>();
|
||||
List<MapMarkersGroup> markersHistoryGroups = new ArrayList<>();
|
||||
List<HistoryEntry> historyEntries = new ArrayList<>();
|
||||
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
|
||||
for (Object object : data) {
|
||||
if (object instanceof ApplicationModeBean) {
|
||||
appModeBeans.add((ApplicationModeBean) object);
|
||||
} else if (object instanceof QuickAction) {
|
||||
quickActions.add((QuickAction) object);
|
||||
} else if (object instanceof PoiUIFilter) {
|
||||
poiUIFilters.add((PoiUIFilter) object);
|
||||
} else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
|
||||
tileSourceTemplates.add((ITileSource) object);
|
||||
} else if (object instanceof File) {
|
||||
File file = (File) object;
|
||||
if (file.getName().endsWith(IndexConstants.GPX_FILE_EXT)) {
|
||||
settingsItems.add(new GpxSettingsItem(app, file));
|
||||
} else {
|
||||
settingsItems.add(new FileSettingsItem(app, file));
|
||||
}
|
||||
} else if (object instanceof FileSettingsItem) {
|
||||
settingsItems.add((FileSettingsItem) object);
|
||||
} else if (object instanceof AvoidRoadInfo) {
|
||||
avoidRoads.add((AvoidRoadInfo) object);
|
||||
} else if (object instanceof OsmNotesPoint) {
|
||||
osmNotesPointList.add((OsmNotesPoint) object);
|
||||
} else if (object instanceof OpenstreetmapPoint) {
|
||||
osmEditsPointList.add((OpenstreetmapPoint) object);
|
||||
} else if (object instanceof FavoriteGroup) {
|
||||
favoriteGroups.add((FavoriteGroup) object);
|
||||
} else if (object instanceof GlobalSettingsItem) {
|
||||
settingsItems.add((GlobalSettingsItem) object);
|
||||
} else if (object instanceof MapMarkersGroup) {
|
||||
MapMarkersGroup markersGroup = (MapMarkersGroup) object;
|
||||
if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
|
||||
markersGroups.add((MapMarkersGroup) object);
|
||||
} else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
|
||||
markersHistoryGroups.add((MapMarkersGroup) object);
|
||||
}
|
||||
} else if (object instanceof HistoryEntry) {
|
||||
historyEntries.add((HistoryEntry) object);
|
||||
} else if (object instanceof OnlineRoutingEngine) {
|
||||
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||
}
|
||||
}
|
||||
if (!appModeBeans.isEmpty()) {
|
||||
for (ApplicationModeBean modeBean : appModeBeans) {
|
||||
settingsItems.add(new ProfileSettingsItem(app, getBaseProfileSettingsItem(modeBean), modeBean));
|
||||
}
|
||||
}
|
||||
if (!quickActions.isEmpty()) {
|
||||
settingsItems.add(new QuickActionsSettingsItem(app, getBaseQuickActionsSettingsItem(), quickActions));
|
||||
}
|
||||
if (!poiUIFilters.isEmpty()) {
|
||||
settingsItems.add(new PoiUiFiltersSettingsItem(app, getBasePoiUiFiltersSettingsItem(), poiUIFilters));
|
||||
}
|
||||
if (!tileSourceTemplates.isEmpty()) {
|
||||
settingsItems.add(new MapSourcesSettingsItem(app, getBaseMapSourcesSettingsItem(), tileSourceTemplates));
|
||||
}
|
||||
if (!avoidRoads.isEmpty()) {
|
||||
settingsItems.add(new AvoidRoadsSettingsItem(app, getBaseAvoidRoadsSettingsItem(), avoidRoads));
|
||||
}
|
||||
if (!osmNotesPointList.isEmpty()) {
|
||||
OsmNotesSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_NOTES, OsmNotesSettingsItem.class);
|
||||
settingsItems.add(new OsmNotesSettingsItem(app, baseItem, osmNotesPointList));
|
||||
}
|
||||
if (!osmEditsPointList.isEmpty()) {
|
||||
OsmEditsSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_EDITS, OsmEditsSettingsItem.class);
|
||||
settingsItems.add(new OsmEditsSettingsItem(app, baseItem, osmEditsPointList));
|
||||
}
|
||||
if (!favoriteGroups.isEmpty()) {
|
||||
FavoritesSettingsItem baseItem = getBaseItem(SettingsItemType.FAVOURITES, FavoritesSettingsItem.class);
|
||||
settingsItems.add(new FavoritesSettingsItem(app, baseItem, favoriteGroups));
|
||||
}
|
||||
if (!markersGroups.isEmpty()) {
|
||||
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||
for (MapMarkersGroup group : markersGroups) {
|
||||
mapMarkers.addAll(group.getMarkers());
|
||||
}
|
||||
MarkersSettingsItem baseItem = getBaseItem(SettingsItemType.ACTIVE_MARKERS, MarkersSettingsItem.class);
|
||||
settingsItems.add(new MarkersSettingsItem(app, baseItem, mapMarkers));
|
||||
}
|
||||
if (!markersHistoryGroups.isEmpty()) {
|
||||
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||
for (MapMarkersGroup group : markersHistoryGroups) {
|
||||
mapMarkers.addAll(group.getMarkers());
|
||||
}
|
||||
HistoryMarkersSettingsItem baseItem = getBaseItem(SettingsItemType.HISTORY_MARKERS, HistoryMarkersSettingsItem.class);
|
||||
settingsItems.add(new HistoryMarkersSettingsItem(app, baseItem, mapMarkers));
|
||||
}
|
||||
if (!historyEntries.isEmpty()) {
|
||||
SearchHistorySettingsItem baseItem = getBaseItem(SettingsItemType.SEARCH_HISTORY, SearchHistorySettingsItem.class);
|
||||
settingsItems.add(new SearchHistorySettingsItem(app, baseItem, historyEntries));
|
||||
}
|
||||
if (!onlineRoutingEngines.isEmpty()) {
|
||||
OnlineRoutingSettingsItem baseItem = getBaseItem(SettingsItemType.ONLINE_ROUTING_ENGINES, OnlineRoutingSettingsItem.class);
|
||||
settingsItems.add(new OnlineRoutingSettingsItem(app, baseItem, onlineRoutingEngines));
|
||||
}
|
||||
return settingsItems;
|
||||
}
|
||||
|
||||
public void setFile(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SegmentsCard extends BaseCard {
|
|||
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
|
||||
PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs);
|
||||
|
||||
pager.setAdapter(new GPXItemPagerAdapter(tabLayout, displayItem, displayHelper, listener));
|
||||
pager.setAdapter(new GPXItemPagerAdapter(app, displayItem, displayHelper, nightMode, listener));
|
||||
tabLayout.setViewPager(pager);
|
||||
|
||||
container.addView(segmentView);
|
||||
|
|
|
@ -149,6 +149,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
private Location lastLocation;
|
||||
private UpdateLocationViewCache updateLocationViewCache;
|
||||
private boolean locationUpdateStarted;
|
||||
private LatLon latLon;
|
||||
|
||||
private int menuTitleHeight;
|
||||
private int toolbarHeightPx;
|
||||
|
@ -259,6 +260,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
this.selectedGpxFile = selectedGpxFile;
|
||||
}
|
||||
|
||||
public void setLatLon(LatLon latLon) {
|
||||
this.latLon = latLon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
@ -556,10 +561,9 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
MapActivity mapActivity = getMapActivity();
|
||||
View view = overviewCard.getView();
|
||||
if (mapActivity != null && view != null) {
|
||||
MapContextMenu menu = mapActivity.getContextMenu();
|
||||
TextView distanceText = (TextView) view.findViewById(R.id.distance);
|
||||
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);
|
||||
}
|
||||
if (selectedGpxFile != null) {
|
||||
showInstance(mapActivity, selectedGpxFile);
|
||||
showInstance(mapActivity, selectedGpxFile, null);
|
||||
} else if (!Algorithms.isEmpty(path)) {
|
||||
String title = app.getString(R.string.loading_smth, "");
|
||||
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) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false);
|
||||
showInstance(mapActivity, selectedGpxFile);
|
||||
showInstance(mapActivity, selectedGpxFile, null);
|
||||
}
|
||||
if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
||||
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 {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
|
||||
|
@ -1148,6 +1152,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
fragment.setRetainInstance(true);
|
||||
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()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment, TAG)
|
||||
|
|
|
@ -68,6 +68,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
public View getCustomTabView(@NonNull ViewGroup parent, int position);
|
||||
public void select(View tab);
|
||||
public void deselect(View tab);
|
||||
public void tabStylesUpdated(View tabsContainer, int currentPosition);
|
||||
}
|
||||
|
||||
public interface OnTabReselectedListener {
|
||||
|
@ -307,6 +308,10 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
}
|
||||
}
|
||||
|
||||
public int getCurrentPosition() {
|
||||
return currentPosition;
|
||||
}
|
||||
|
||||
private void addTab(final int position, CharSequence title, View tabView) {
|
||||
TextView textView = (TextView) tabView.findViewById(R.id.tab_title);
|
||||
if (textView != null) {
|
||||
|
@ -332,41 +337,31 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
|
||||
private void updateTabStyles() {
|
||||
tabsContainer.setBackgroundResource(tabBackgroundResId);
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
((CustomTabProvider) pager.getAdapter()).tabStylesUpdated(tabsContainer, currentPosition);
|
||||
} else {
|
||||
for (int i = 0; i < tabCount; i++) {
|
||||
View v = tabsContainer.getChildAt(i);
|
||||
v.setBackgroundResource(tabBackgroundResId);
|
||||
v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
|
||||
TextView tab_title = (TextView) v.findViewById(R.id.tab_title);
|
||||
|
||||
if (tab_title != null) {
|
||||
tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
||||
tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
||||
TextView tabTitle = v.findViewById(R.id.tab_title);
|
||||
if (tabTitle != null) {
|
||||
tabTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
||||
tabTitle.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
||||
switch (tabSelectionType) {
|
||||
case ALPHA:
|
||||
float alpha = pager.getCurrentItem() == i ? tabTextSelectedAlpha : tabTextAlpha;
|
||||
tab_title.setAlpha(alpha);
|
||||
tab_title.setTextColor(tabTextColor);
|
||||
tabTitle.setAlpha(alpha);
|
||||
tabTitle.setTextColor(tabTextColor);
|
||||
break;
|
||||
case SOLID_COLOR:
|
||||
tab_title.setAlpha(OPAQUE);
|
||||
tab_title.setTextColor(pager.getCurrentItem() == i ? tabTextColor : tabInactiveTextColor);
|
||||
tabTitle.setAlpha(OPAQUE);
|
||||
tabTitle.setTextColor(pager.getCurrentItem() == i ? tabTextColor : tabInactiveTextColor);
|
||||
break;
|
||||
}
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
if (pager.getCurrentItem() == i) {
|
||||
((CustomTabProvider) pager.getAdapter()).select(v);
|
||||
} else {
|
||||
((CustomTabProvider) pager.getAdapter()).deselect(v);
|
||||
}
|
||||
}
|
||||
|
||||
// setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
|
||||
// pre-ICS-build
|
||||
if (textAllCaps) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
tab_title.setAllCaps(true);
|
||||
} else {
|
||||
tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
|
||||
tabTitle.setAllCaps(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -558,7 +553,10 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
|
||||
private void notSelected(View tab) {
|
||||
if (tab != null) {
|
||||
TextView title = (TextView) tab.findViewById(R.id.tab_title);
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
((CustomTabProvider) pager.getAdapter()).deselect(tab);
|
||||
} else {
|
||||
TextView title = tab.findViewById(R.id.tab_title);
|
||||
if (title != null) {
|
||||
title.setTypeface(tabTypeface, tabTypefaceStyle);
|
||||
switch (tabSelectionType) {
|
||||
|
@ -570,15 +568,16 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
((CustomTabProvider) pager.getAdapter()).deselect(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void selected(View tab) {
|
||||
if (tab != null) {
|
||||
TextView title = (TextView) tab.findViewById(R.id.tab_title);
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
((CustomTabProvider) pager.getAdapter()).select(tab);
|
||||
} else {
|
||||
TextView title = tab.findViewById(R.id.tab_title);
|
||||
if (title != null) {
|
||||
title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
|
||||
switch (tabSelectionType) {
|
||||
|
@ -589,8 +588,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
title.setTextColor(tabTextColor);
|
||||
break;
|
||||
}
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
((CustomTabProvider) pager.getAdapter()).select(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package net.osmand.plus.wikipedia;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
|
@ -12,6 +16,8 @@ import androidx.core.content.ContextCompat;
|
|||
import androidx.core.os.ConfigurationCompat;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
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() {
|
||||
languages = new ArrayList<>();
|
||||
|
||||
|
@ -188,12 +200,44 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
localesForSaving.add(language.getLocale());
|
||||
}
|
||||
}
|
||||
wikiPlugin.setLanguagesToShow(localesForSaving);
|
||||
wikiPlugin.setShowAllLanguages(isGlobalWikiPoiEnabled);
|
||||
wikiPlugin.updateWikipediaState();
|
||||
applyPreferenceWithSnackBar(localesForSaving, isGlobalWikiPoiEnabled);
|
||||
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() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app == null) {
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.osmand.plus.search.QuickSearchDialogFragment;
|
|||
import net.osmand.plus.search.QuickSearchListAdapter;
|
||||
import net.osmand.plus.search.listitems.QuickSearchBannerListItem;
|
||||
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.views.layers.DownloadedRegionsLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -189,26 +190,50 @@ public class WikipediaPlugin extends OsmandPlugin {
|
|||
return !isShowAllLanguages() && getLanguagesToShow() != null;
|
||||
}
|
||||
|
||||
public boolean hasCustomSettings(ApplicationMode profile) {
|
||||
return !isShowAllLanguages(profile) && getLanguagesToShow(profile) != null;
|
||||
}
|
||||
|
||||
public boolean hasLanguagesFilter() {
|
||||
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() {
|
||||
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) {
|
||||
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() {
|
||||
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) {
|
||||
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) {
|
||||
if (enable) {
|
||||
showWikiOnMap();
|
||||
|
|
Loading…
Reference in a new issue