Merge branch 'r3.9'
This commit is contained in:
commit
93a8055a41
18 changed files with 328 additions and 425 deletions
|
@ -16,7 +16,7 @@ public class ProfileSettingsParams extends AidlParams {
|
||||||
|
|
||||||
public static final String VERSION_KEY = "version";
|
public static final String VERSION_KEY = "version";
|
||||||
public static final String REPLACE_KEY = "replace";
|
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 LATEST_CHANGES_KEY = "latestChanges";
|
||||||
public static final String PROFILE_SETTINGS_URI_KEY = "profileSettingsUri";
|
public static final String PROFILE_SETTINGS_URI_KEY = "profileSettingsUri";
|
||||||
private Uri profileSettingsUri;
|
private Uri profileSettingsUri;
|
||||||
|
|
19
OsmAnd/res/layout/center_button_container.xml
Normal file
19
OsmAnd/res/layout/center_button_container.xml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?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"
|
||||||
|
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/center_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/altitude"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/custom_radio_buttons"
|
android:id="@+id/custom_radio_buttons"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -13,59 +12,22 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
tools:showIn="@layout/fragment_route_between_points_bottom_sheet_dialog">
|
tools:showIn="@layout/fragment_route_between_points_bottom_sheet_dialog">
|
||||||
|
|
||||||
<FrameLayout
|
<include
|
||||||
android:id="@+id/left_button_container"
|
layout="@layout/left_button_container"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<include
|
||||||
android:id="@+id/left_button"
|
layout="@layout/center_button_container"
|
||||||
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"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1" />
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<include
|
||||||
android:id="@+id/center_button"
|
layout="@layout/right_button_container"
|
||||||
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"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1">
|
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>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,24 +1,32 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<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_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
|
<net.osmand.plus.views.controls.PagerSlidingTabStrip
|
||||||
android:id="@+id/sliding_tabs"
|
android:id="@+id/sliding_tabs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/bg_color"/>
|
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
|
<net.osmand.plus.views.controls.WrapContentHeightViewPager
|
||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/bg_color"
|
android:paddingTop="4dp" />
|
||||||
android:paddingTop="4dp"/>
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
19
OsmAnd/res/layout/left_button_container.xml
Normal file
19
OsmAnd/res/layout/left_button_container.xml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?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"
|
||||||
|
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/left_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/shared_string_overview"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
19
OsmAnd/res/layout/right_button_container.xml
Normal file
19
OsmAnd/res/layout/right_button_container.xml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?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"
|
||||||
|
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/right_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/map_widget_speed"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -87,6 +87,7 @@ public class UiUtilities {
|
||||||
|
|
||||||
public enum CustomRadioButtonType {
|
public enum CustomRadioButtonType {
|
||||||
START,
|
START,
|
||||||
|
CENTER,
|
||||||
END,
|
END,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,6 +457,8 @@ public class UiUtilities {
|
||||||
|
|
||||||
TextView startButtonText = buttonsView.findViewById(R.id.left_button);
|
TextView startButtonText = buttonsView.findViewById(R.id.left_button);
|
||||||
View startButtonContainer = buttonsView.findViewById(R.id.left_button_container);
|
View startButtonContainer = buttonsView.findViewById(R.id.left_button_container);
|
||||||
|
TextView centerButtonText = buttonsView.findViewById(R.id.center_button);
|
||||||
|
View centerButtonContainer = buttonsView.findViewById(R.id.center_button_container);
|
||||||
TextView endButtonText = buttonsView.findViewById(R.id.right_button);
|
TextView endButtonText = buttonsView.findViewById(R.id.right_button);
|
||||||
View endButtonContainer = buttonsView.findViewById(R.id.right_button_container);
|
View endButtonContainer = buttonsView.findViewById(R.id.right_button_container);
|
||||||
GradientDrawable background = new GradientDrawable();
|
GradientDrawable background = new GradientDrawable();
|
||||||
|
@ -471,9 +474,27 @@ public class UiUtilities {
|
||||||
endButtonText.setTextColor(activeColor);
|
endButtonText.setTextColor(activeColor);
|
||||||
startButtonContainer.setBackgroundDrawable(background);
|
startButtonContainer.setBackgroundDrawable(background);
|
||||||
startButtonText.setTextColor(textColor);
|
startButtonText.setTextColor(textColor);
|
||||||
|
|
||||||
|
if (centerButtonContainer != null) {
|
||||||
|
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);
|
||||||
|
centerButtonText.setTextColor(textColor);
|
||||||
|
|
||||||
|
if (endButtonContainer != null) {
|
||||||
|
endButtonText.setTextColor(activeColor);
|
||||||
|
endButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
if (startButtonContainer != null) {
|
||||||
|
startButtonText.setTextColor(activeColor);
|
||||||
|
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isLayoutRtl) {
|
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 {
|
} else {
|
||||||
background.setCornerRadii(new float[]{0, 0, radius, radius, radius, radius, 0, 0});
|
background.setCornerRadii(new float[]{0, 0, radius, radius, radius, radius, 0, 0});
|
||||||
}
|
}
|
||||||
|
@ -481,6 +502,11 @@ public class UiUtilities {
|
||||||
endButtonText.setTextColor(textColor);
|
endButtonText.setTextColor(textColor);
|
||||||
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
startButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
startButtonText.setTextColor(activeColor);
|
startButtonText.setTextColor(activeColor);
|
||||||
|
|
||||||
|
if (centerButtonContainer != null) {
|
||||||
|
centerButtonText.setTextColor(activeColor);
|
||||||
|
centerButtonContainer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -651,7 +651,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
protected void onNewIntent(final Intent intent) {
|
protected void onNewIntent(final Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
setIntent(intent);
|
setIntent(intent);
|
||||||
intentHelper.parseLaunchIntents();
|
if (!intentHelper.parseLaunchIntents()) {
|
||||||
|
intentHelper.parseContentIntent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
|
|
||||||
private int progress;
|
private int progress;
|
||||||
private int maxProgress;
|
private int maxProgress;
|
||||||
|
private boolean uploadingFinished;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
@ -44,17 +45,12 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
uploadedPhotosCounter = view.findViewById(R.id.description);
|
uploadedPhotosCounter = view.findViewById(R.id.description);
|
||||||
progressBar = view.findViewById(R.id.progress_bar);
|
progressBar = view.findViewById(R.id.progress_bar);
|
||||||
progressBar.setMax(maxProgress);
|
progressBar.setMax(maxProgress);
|
||||||
String titleProgress = getString(progress == maxProgress? R.string.upload_photo_completed: R.string.upload_photo);
|
|
||||||
String descriptionProgress;
|
int descriptionId = uploadingFinished ? R.string.uploaded_count : R.string.uploading_count;
|
||||||
if (progress == maxProgress) {
|
|
||||||
descriptionProgress = getString(R.string.uploaded_count, progress, maxProgress);
|
|
||||||
} else {
|
|
||||||
descriptionProgress = getString(R.string.uploading_count, progress, maxProgress);
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseBottomSheetItem descriptionItem = new BottomSheetItemWithDescription.Builder()
|
BaseBottomSheetItem descriptionItem = new BottomSheetItemWithDescription.Builder()
|
||||||
.setDescription(descriptionProgress)
|
.setDescription(getString(descriptionId, progress, maxProgress))
|
||||||
.setTitle(titleProgress)
|
.setTitle(getString(uploadingFinished ? R.string.upload_photo_completed : R.string.upload_photo))
|
||||||
.setCustomView(view)
|
.setCustomView(view)
|
||||||
.create();
|
.create();
|
||||||
items.add(descriptionItem);
|
items.add(descriptionItem);
|
||||||
|
@ -74,9 +70,10 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProgress(int progress) {
|
private void updateProgress(int progress) {
|
||||||
|
int descriptionId = uploadingFinished ? R.string.uploaded_count : R.string.uploading_count;
|
||||||
progressBar.setProgress(progress);
|
progressBar.setProgress(progress);
|
||||||
uploadedPhotosCounter.setText((getString(R.string.uploading_count, progress, maxProgress)));
|
uploadedPhotosCounter.setText(getString(descriptionId, progress, maxProgress));
|
||||||
uploadedPhotosTitle.setText(progress == maxProgress ? R.string.upload_photo_completed : R.string.upload_photo);
|
uploadedPhotosTitle.setText(uploadingFinished ? R.string.upload_photo_completed : R.string.upload_photo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,13 +84,10 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uploadPhotosFinished() {
|
public void uploadPhotosFinished() {
|
||||||
updateProgress(maxProgress);
|
uploadingFinished = true;
|
||||||
if (progress == maxProgress) {
|
updateProgress(progress);
|
||||||
uploadedPhotosCounter.setText((getString(R.string.uploaded_count, progress, maxProgress)));
|
|
||||||
setDismissButtonTextId(R.string.shared_string_close);
|
|
||||||
UiUtilities.setupDialogButton(nightMode, dismissButton, getDismissButtonType(), getDismissButtonTextId());
|
UiUtilities.setupDialogButton(nightMode, dismissButton, getDismissButtonType(), getDismissButtonTextId());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
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) {
|
public static UploadPhotosListener showInstance(@NonNull FragmentManager fragmentManager, int maxProgress, OnDismissListener listener) {
|
||||||
UploadPhotoProgressBottomSheet fragment = new UploadPhotoProgressBottomSheet();
|
UploadPhotoProgressBottomSheet fragment = new UploadPhotoProgressBottomSheet();
|
||||||
fragment.setRetainInstance(true);
|
fragment.setRetainInstance(true);
|
||||||
|
|
|
@ -102,7 +102,7 @@ class SettingsImportTask extends BaseLoadAsyncTask<Void, Void, String> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Map<ExportSettingsType, List<?>> allSettingsMap = getSettingsToOperate(pluginIndependentItems, false);
|
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));
|
settingsHelper.checkDuplicates(file, settingsList, settingsList, getDuplicatesListener(file, replace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -45,14 +46,13 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
||||||
|
|
||||||
private final OsmandApplication app;
|
private final OsmandApplication app;
|
||||||
private final WeakReference<MapActivity> activityRef;
|
private final WeakReference<MapActivity> activityRef;
|
||||||
private UploadPhotosListener listener;
|
|
||||||
|
|
||||||
private final OpenDBAPI openDBAPI = new OpenDBAPI();
|
private final OpenDBAPI openDBAPI = new OpenDBAPI();
|
||||||
private final LatLon latLon;
|
private final LatLon latLon;
|
||||||
private final List<Uri> data;
|
private final List<Uri> data;
|
||||||
private final String[] placeId;
|
private final String[] placeId;
|
||||||
private final Map<String, String> params;
|
private final Map<String, String> params;
|
||||||
private final GetImageCardsListener imageCardListener;
|
private final GetImageCardsListener imageCardListener;
|
||||||
|
private UploadPhotosListener listener;
|
||||||
|
|
||||||
public UploadPhotosAsyncTask(MapActivity activity, List<Uri> data, LatLon latLon, String[] placeId,
|
public UploadPhotosAsyncTask(MapActivity activity, List<Uri> data, LatLon latLon, String[] placeId,
|
||||||
Map<String, String> params, GetImageCardsListener imageCardListener) {
|
Map<String, String> params, GetImageCardsListener imageCardListener) {
|
||||||
|
@ -87,13 +87,16 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Void doInBackground(Void... uris) {
|
protected Void doInBackground(Void... uris) {
|
||||||
|
List<Uri> uploadedPhotoUris = new ArrayList<>();
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Uri uri = data.get(i);
|
Uri uri = data.get(i);
|
||||||
handleSelectedImage(uri);
|
if (handleSelectedImage(uri)) {
|
||||||
publishProgress(i + 1);
|
uploadedPhotoUris.add(uri);
|
||||||
|
publishProgress(uploadedPhotoUris.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
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;
|
InputStream inputStream = null;
|
||||||
try {
|
try {
|
||||||
inputStream = app.getContentResolver().openInputStream(uri);
|
inputStream = app.getContentResolver().openInputStream(uri);
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
uploadImageToPlace(inputStream);
|
success = uploadImageToPlace(inputStream);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error(e);
|
LOG.error(e);
|
||||||
|
@ -118,11 +122,13 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
||||||
} finally {
|
} finally {
|
||||||
Algorithms.closeStream(inputStream);
|
Algorithms.closeStream(inputStream);
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadImageToPlace(InputStream image) {
|
private boolean uploadImageToPlace(InputStream image) {
|
||||||
|
boolean success = false;
|
||||||
InputStream serverData = new ByteArrayInputStream(compressImageToJpeg(image));
|
InputStream serverData = new ByteArrayInputStream(compressImageToJpeg(image));
|
||||||
final String baseUrl = OPRConstants.getBaseUrl(app);
|
String baseUrl = OPRConstants.getBaseUrl(app);
|
||||||
// all these should be constant
|
// all these should be constant
|
||||||
String url = baseUrl + "api/ipfs/image";
|
String url = baseUrl + "api/ipfs/image";
|
||||||
String response = NetworkUtils.sendPostDataRequest(url, "file", "compressed.jpeg", serverData);
|
String response = NetworkUtils.sendPostDataRequest(url, "file", "compressed.jpeg", serverData);
|
||||||
|
@ -140,8 +146,6 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
||||||
response, error);
|
response, error);
|
||||||
if (res != 200) {
|
if (res != 200) {
|
||||||
app.showToastMessage(error.toString());
|
app.showToastMessage(error.toString());
|
||||||
} else {
|
|
||||||
//ok, continue
|
|
||||||
}
|
}
|
||||||
} catch (FailedVerificationException e) {
|
} catch (FailedVerificationException e) {
|
||||||
LOG.error(e);
|
LOG.error(e);
|
||||||
|
@ -151,6 +155,7 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
||||||
//image was uploaded but not added to blockchain
|
//image was uploaded but not added to blockchain
|
||||||
checkTokenAndShowScreen();
|
checkTokenAndShowScreen();
|
||||||
} else {
|
} else {
|
||||||
|
success = true;
|
||||||
String str = app.getString(R.string.successfully_uploaded_pattern, 1, 1);
|
String str = app.getString(R.string.successfully_uploaded_pattern, 1, 1);
|
||||||
app.showToastMessage(str);
|
app.showToastMessage(str);
|
||||||
//refresh the image
|
//refresh the image
|
||||||
|
@ -163,6 +168,7 @@ public class UploadPhotosAsyncTask extends AsyncTask<Void, Integer, Void> {
|
||||||
} else {
|
} else {
|
||||||
checkTokenAndShowScreen();
|
checkTokenAndShowScreen();
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
//This method runs on non main thread
|
//This method runs on non main thread
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewGroup.MarginLayoutParams;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.UiUtilities.CustomRadioButtonType;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
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.LineGraphType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||||
import net.osmand.plus.track.TrackDisplayHelper;
|
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.PagerSlidingTabStrip.CustomTabProvider;
|
||||||
import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface;
|
import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -51,6 +52,7 @@ import net.osmand.util.MapUtils;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -72,23 +74,23 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
private GpxDisplayItem gpxItem;
|
private GpxDisplayItem gpxItem;
|
||||||
private GPXTabItemType[] tabTypes;
|
private GPXTabItemType[] tabTypes;
|
||||||
|
|
||||||
private PagerSlidingTabStrip tabs;
|
|
||||||
private SparseArray<View> views = new SparseArray<>();
|
private SparseArray<View> views = new SparseArray<>();
|
||||||
private SegmentActionsListener actionsListener;
|
private SegmentActionsListener actionsListener;
|
||||||
|
|
||||||
private boolean chartClicked;
|
private boolean chartClicked;
|
||||||
|
private boolean nightMode;
|
||||||
|
|
||||||
|
|
||||||
public GPXItemPagerAdapter(@NonNull PagerSlidingTabStrip tabs,
|
public GPXItemPagerAdapter(@NonNull OsmandApplication app,
|
||||||
@NonNull GpxDisplayItem gpxItem,
|
@NonNull GpxDisplayItem gpxItem,
|
||||||
@NonNull TrackDisplayHelper displayHelper,
|
@NonNull TrackDisplayHelper displayHelper,
|
||||||
@NonNull SegmentActionsListener actionsListener) {
|
boolean nightMode, @NonNull SegmentActionsListener actionsListener) {
|
||||||
super();
|
super();
|
||||||
this.tabs = tabs;
|
this.app = app;
|
||||||
this.gpxItem = gpxItem;
|
this.gpxItem = gpxItem;
|
||||||
|
this.nightMode = nightMode;
|
||||||
this.displayHelper = displayHelper;
|
this.displayHelper = displayHelper;
|
||||||
this.actionsListener = actionsListener;
|
this.actionsListener = actionsListener;
|
||||||
app = (OsmandApplication) tabs.getContext().getApplicationContext();
|
|
||||||
iconsCache = app.getUIUtilities();
|
iconsCache = app.getUIUtilities();
|
||||||
fetchTabTypes();
|
fetchTabTypes();
|
||||||
}
|
}
|
||||||
|
@ -556,40 +558,60 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
return view == object;
|
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
|
@Override
|
||||||
public View getCustomTabView(@NonNull ViewGroup parent, int position) {
|
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());
|
tab.setTag(tabTypes[position].name());
|
||||||
deselect(tab);
|
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void select(View tab) {
|
public void select(View tab) {
|
||||||
GPXTabItemType tabType = GPXTabItemType.valueOf((String) tab.getTag());
|
GPXTabItemType tabType = GPXTabItemType.valueOf((String) tab.getTag());
|
||||||
ImageView img = tab.findViewById(R.id.tab_image);
|
int index = Arrays.asList(tabTypes).indexOf(tabType);
|
||||||
switch (tabs.getTabSelectionType()) {
|
View parent = (View) tab.getParent();
|
||||||
case ALPHA:
|
UiUtilities.updateCustomRadioButtons(app, parent, nightMode, getCustomRadioButtonType(index));
|
||||||
img.setAlpha(tabs.getTabTextSelectedAlpha());
|
|
||||||
break;
|
|
||||||
case SOLID_COLOR:
|
|
||||||
img.setImageDrawable(iconsCache.getPaintedIcon(tabType.getIconId(), tabs.getTextColor()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deselect(View tab) {
|
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
|
@Override
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
|
@ -56,7 +55,7 @@ public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||||
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
||||||
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
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) {
|
if (create) {
|
||||||
tabLayout.setViewPager(pager);
|
tabLayout.setViewPager(pager);
|
||||||
} else {
|
} 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);
|
View row = UiUtilities.getInflater(context, nightMode).inflate(R.layout.gpx_list_item_tab_content, root, false);
|
||||||
|
|
||||||
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
|
||||||
tabLayout.setTabBackground(R.color.color_transparent);
|
tabLayout.setTabBackground(AndroidUtils.resolveAttribute(context, R.attr.btn_bg_border_inactive));
|
||||||
tabLayout.setIndicatorColorResource(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
tabLayout.setIndicatorHeight(0);
|
||||||
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.setShouldExpand(true);
|
tabLayout.setShouldExpand(true);
|
||||||
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);
|
||||||
pager.setSwipeable(false);
|
pager.setSwipeable(false);
|
||||||
|
|
|
@ -480,19 +480,21 @@ public class SettingsHelper {
|
||||||
typesMap.putAll(getMyPlacesItems());
|
typesMap.putAll(getMyPlacesItems());
|
||||||
typesMap.putAll(getResourcesItems());
|
typesMap.putAll(getResourcesItems());
|
||||||
|
|
||||||
return getFilteredSettingsItems(typesMap, settingsTypes, export);
|
return getFilteredSettingsItems(typesMap, settingsTypes, Collections.<SettingsItem>emptyList(), export);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SettingsItem> getFilteredSettingsItems(Map<ExportSettingsType, List<?>> allSettingsMap,
|
public List<SettingsItem> getFilteredSettingsItems(
|
||||||
List<ExportSettingsType> settingsTypes, boolean export) {
|
Map<ExportSettingsType, List<?>> allSettingsMap, List<ExportSettingsType> settingsTypes,
|
||||||
List<SettingsItem> settingsItems = new ArrayList<>();
|
@NonNull List<SettingsItem> settingsItems, boolean export
|
||||||
|
) {
|
||||||
|
List<SettingsItem> filteredSettingsItems = new ArrayList<>();
|
||||||
for (ExportSettingsType settingsType : settingsTypes) {
|
for (ExportSettingsType settingsType : settingsTypes) {
|
||||||
List<?> settingsDataObjects = allSettingsMap.get(settingsType);
|
List<?> settingsDataObjects = allSettingsMap.get(settingsType);
|
||||||
if (settingsDataObjects != null) {
|
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) {
|
public Map<ExportSettingsCategory, SettingsCategoryItems> getSettingsByCategory(boolean addProfiles) {
|
||||||
|
@ -693,8 +695,8 @@ public class SettingsHelper {
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SettingsItem> prepareSettingsItems(List<?> data, boolean export) {
|
public List<SettingsItem> prepareSettingsItems(List<?> data, List<SettingsItem> settingsItems, boolean export) {
|
||||||
List<SettingsItem> settingsItems = new ArrayList<>();
|
List<SettingsItem> result = new ArrayList<>();
|
||||||
List<QuickAction> quickActions = new ArrayList<>();
|
List<QuickAction> quickActions = new ArrayList<>();
|
||||||
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
List<PoiUIFilter> poiUIFilters = new ArrayList<>();
|
||||||
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
List<ITileSource> tileSourceTemplates = new ArrayList<>();
|
||||||
|
@ -719,13 +721,15 @@ public class SettingsHelper {
|
||||||
try {
|
try {
|
||||||
File file = (File) object;
|
File file = (File) object;
|
||||||
if (file.getName().endsWith(IndexConstants.GPX_FILE_EXT)) {
|
if (file.getName().endsWith(IndexConstants.GPX_FILE_EXT)) {
|
||||||
settingsItems.add(new GpxSettingsItem(app, file));
|
result.add(new GpxSettingsItem(app, file));
|
||||||
} else {
|
} else {
|
||||||
settingsItems.add(new FileSettingsItem(app, file));
|
result.add(new FileSettingsItem(app, file));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
LOG.warn("Trying to export unsuported file type", e);
|
LOG.warn("Trying to export unsuported file type", e);
|
||||||
}
|
}
|
||||||
|
} else if (object instanceof FileSettingsItem) {
|
||||||
|
result.add((FileSettingsItem) object);
|
||||||
} else if (object instanceof AvoidRoadInfo) {
|
} else if (object instanceof AvoidRoadInfo) {
|
||||||
avoidRoads.add((AvoidRoadInfo) object);
|
avoidRoads.add((AvoidRoadInfo) object);
|
||||||
} else if (object instanceof ApplicationModeBean) {
|
} else if (object instanceof ApplicationModeBean) {
|
||||||
|
@ -746,65 +750,100 @@ public class SettingsHelper {
|
||||||
} else if (object instanceof HistoryEntry) {
|
} else if (object instanceof HistoryEntry) {
|
||||||
historyEntries.add((HistoryEntry) object);
|
historyEntries.add((HistoryEntry) object);
|
||||||
} else if (object instanceof GlobalSettingsItem) {
|
} else if (object instanceof GlobalSettingsItem) {
|
||||||
settingsItems.add((GlobalSettingsItem) object);
|
result.add((GlobalSettingsItem) object);
|
||||||
} else if (object instanceof OnlineRoutingEngine) {
|
} else if (object instanceof OnlineRoutingEngine) {
|
||||||
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
onlineRoutingEngines.add((OnlineRoutingEngine) object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!quickActions.isEmpty()) {
|
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()) {
|
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()) {
|
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()) {
|
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()) {
|
if (!appModeBeans.isEmpty()) {
|
||||||
for (ApplicationModeBean modeBean : appModeBeans) {
|
for (ApplicationModeBean modeBean : appModeBeans) {
|
||||||
if (export) {
|
if (export) {
|
||||||
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
|
ApplicationMode mode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
|
||||||
if (mode != null) {
|
if (mode != null) {
|
||||||
settingsItems.add(new ProfileSettingsItem(app, mode));
|
result.add(new ProfileSettingsItem(app, mode));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settingsItems.add(new ProfileSettingsItem(app, null, modeBean));
|
result.add(new ProfileSettingsItem(app, getBaseProfileSettingsItem(modeBean, settingsItems), modeBean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!osmNotesPointList.isEmpty()) {
|
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()) {
|
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()) {
|
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()) {
|
if (!markersGroups.isEmpty()) {
|
||||||
List<MapMarker> mapMarkers = new ArrayList<>();
|
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||||
for (MapMarkersGroup group : markersGroups) {
|
for (MapMarkersGroup group : markersGroups) {
|
||||||
mapMarkers.addAll(group.getMarkers());
|
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()) {
|
if (!markersHistoryGroups.isEmpty()) {
|
||||||
List<MapMarker> mapMarkers = new ArrayList<>();
|
List<MapMarker> mapMarkers = new ArrayList<>();
|
||||||
for (MapMarkersGroup group : markersHistoryGroups) {
|
for (MapMarkersGroup group : markersHistoryGroups) {
|
||||||
mapMarkers.addAll(group.getMarkers());
|
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()) {
|
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()) {
|
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) {
|
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.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -150,7 +151,7 @@ public class ExportSettingsFragment extends BaseSettingsListFragment {
|
||||||
showExportProgressDialog();
|
showExportProgressDialog();
|
||||||
File tempDir = FileUtils.getTempDir(app);
|
File tempDir = FileUtils.getTempDir(app);
|
||||||
String fileName = getFileName();
|
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));
|
progress.setMax(getMaxProgress(items));
|
||||||
app.getSettingsHelper().exportSettings(tempDir, fileName, getSettingsExportListener(), items, true);
|
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 com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.map.ITileSource;
|
|
||||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
|
||||||
import net.osmand.plus.AppInitializer;
|
import net.osmand.plus.AppInitializer;
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.SQLiteTileSource;
|
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.download.ReloadIndexesTask;
|
import net.osmand.plus.download.ReloadIndexesTask;
|
||||||
import net.osmand.plus.download.ReloadIndexesTask.ReloadIndexesListener;
|
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.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;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
|
import net.osmand.plus.settings.backend.backup.SettingsHelper.ImportAsyncTask;
|
||||||
import net.osmand.plus.settings.backend.backup.SettingsItem;
|
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 org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ImportSettingsFragment extends BaseSettingsListFragment {
|
public class ImportSettingsFragment extends BaseSettingsListFragment {
|
||||||
|
@ -177,7 +144,7 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importItems() {
|
private void importItems() {
|
||||||
List<SettingsItem> selectedItems = getSettingsItemsFromData(adapter.getData());
|
List<SettingsItem> selectedItems = settingsHelper.prepareSettingsItems(adapter.getData(), settingsItems, false);
|
||||||
if (file != null && settingsItems != null) {
|
if (file != null && settingsItems != null) {
|
||||||
duplicateStartTime = System.currentTimeMillis();
|
duplicateStartTime = System.currentTimeMillis();
|
||||||
settingsHelper.checkDuplicates(file, settingsItems, selectedItems, getDuplicatesListener());
|
settingsHelper.checkDuplicates(file, settingsItems, selectedItems, getDuplicatesListener());
|
||||||
|
@ -272,181 +239,6 @@ public class ImportSettingsFragment extends BaseSettingsListFragment {
|
||||||
this.settingsItems = settingsItems;
|
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) {
|
public void setFile(File file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class SegmentsCard extends BaseCard {
|
||||||
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
|
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
|
||||||
PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs);
|
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);
|
tabLayout.setViewPager(pager);
|
||||||
|
|
||||||
container.addView(segmentView);
|
container.addView(segmentView);
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
public View getCustomTabView(@NonNull ViewGroup parent, int position);
|
public View getCustomTabView(@NonNull ViewGroup parent, int position);
|
||||||
public void select(View tab);
|
public void select(View tab);
|
||||||
public void deselect(View tab);
|
public void deselect(View tab);
|
||||||
|
public void tabStylesUpdated(View tabsContainer, int currentPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnTabReselectedListener {
|
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) {
|
private void addTab(final int position, CharSequence title, View tabView) {
|
||||||
TextView textView = (TextView) tabView.findViewById(R.id.tab_title);
|
TextView textView = (TextView) tabView.findViewById(R.id.tab_title);
|
||||||
if (textView != null) {
|
if (textView != null) {
|
||||||
|
@ -332,41 +337,31 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
|
|
||||||
private void updateTabStyles() {
|
private void updateTabStyles() {
|
||||||
tabsContainer.setBackgroundResource(tabBackgroundResId);
|
tabsContainer.setBackgroundResource(tabBackgroundResId);
|
||||||
|
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||||
|
((CustomTabProvider) pager.getAdapter()).tabStylesUpdated(tabsContainer, currentPosition);
|
||||||
|
} else {
|
||||||
for (int i = 0; i < tabCount; i++) {
|
for (int i = 0; i < tabCount; i++) {
|
||||||
View v = tabsContainer.getChildAt(i);
|
View v = tabsContainer.getChildAt(i);
|
||||||
v.setBackgroundResource(tabBackgroundResId);
|
v.setBackgroundResource(tabBackgroundResId);
|
||||||
v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
|
v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
|
||||||
TextView tab_title = (TextView) v.findViewById(R.id.tab_title);
|
|
||||||
|
|
||||||
if (tab_title != null) {
|
TextView tabTitle = v.findViewById(R.id.tab_title);
|
||||||
tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
if (tabTitle != null) {
|
||||||
tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
tabTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
||||||
|
tabTitle.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
||||||
switch (tabSelectionType) {
|
switch (tabSelectionType) {
|
||||||
case ALPHA:
|
case ALPHA:
|
||||||
float alpha = pager.getCurrentItem() == i ? tabTextSelectedAlpha : tabTextAlpha;
|
float alpha = pager.getCurrentItem() == i ? tabTextSelectedAlpha : tabTextAlpha;
|
||||||
tab_title.setAlpha(alpha);
|
tabTitle.setAlpha(alpha);
|
||||||
tab_title.setTextColor(tabTextColor);
|
tabTitle.setTextColor(tabTextColor);
|
||||||
break;
|
break;
|
||||||
case SOLID_COLOR:
|
case SOLID_COLOR:
|
||||||
tab_title.setAlpha(OPAQUE);
|
tabTitle.setAlpha(OPAQUE);
|
||||||
tab_title.setTextColor(pager.getCurrentItem() == i ? tabTextColor : tabInactiveTextColor);
|
tabTitle.setTextColor(pager.getCurrentItem() == i ? tabTextColor : tabInactiveTextColor);
|
||||||
break;
|
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 (textAllCaps) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
tabTitle.setAllCaps(true);
|
||||||
tab_title.setAllCaps(true);
|
|
||||||
} else {
|
|
||||||
tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,7 +553,10 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
|
|
||||||
private void notSelected(View tab) {
|
private void notSelected(View tab) {
|
||||||
if (tab != null) {
|
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) {
|
if (title != null) {
|
||||||
title.setTypeface(tabTypeface, tabTypefaceStyle);
|
title.setTypeface(tabTypeface, tabTypefaceStyle);
|
||||||
switch (tabSelectionType) {
|
switch (tabSelectionType) {
|
||||||
|
@ -570,15 +568,16 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
|
||||||
((CustomTabProvider) pager.getAdapter()).deselect(tab);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selected(View tab) {
|
private void selected(View tab) {
|
||||||
if (tab != null) {
|
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) {
|
if (title != null) {
|
||||||
title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
|
title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
|
||||||
switch (tabSelectionType) {
|
switch (tabSelectionType) {
|
||||||
|
@ -589,8 +588,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
title.setTextColor(tabTextColor);
|
title.setTextColor(tabTextColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
|
||||||
((CustomTabProvider) pager.getAdapter()).select(tab);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue