commit
f1a2a17c93
5 changed files with 54 additions and 16 deletions
|
@ -3540,7 +3540,7 @@
|
||||||
<string name="shared_string_routing">ניתוב</string>
|
<string name="shared_string_routing">ניתוב</string>
|
||||||
<string name="listed_exist">%1$s מוצג, כבר קיים ב־OsmAnd.</string>
|
<string name="listed_exist">%1$s מוצג, כבר קיים ב־OsmAnd.</string>
|
||||||
<string name="clear_recorded_data_warning">למחוק את הנתונים שהוקלטו\?</string>
|
<string name="clear_recorded_data_warning">למחוק את הנתונים שהוקלטו\?</string>
|
||||||
<string name="importing_from">מיובאים נתונים מתוך %1</string>
|
<string name="importing_from">מיובאים נתונים מתוך %1$s</string>
|
||||||
<string name="shared_string_importing">מתבצע ייבוא</string>
|
<string name="shared_string_importing">מתבצע ייבוא</string>
|
||||||
<string name="checking_for_duplicate_description">OsmAnd יחפש כפילויות של %1$s עם פריטים קיימים ביישומון.
|
<string name="checking_for_duplicate_description">OsmAnd יחפש כפילויות של %1$s עם פריטים קיימים ביישומון.
|
||||||
\n
|
\n
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -9,6 +10,7 @@ import android.text.Html;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.JsonUtils;
|
import net.osmand.JsonUtils;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -104,7 +106,7 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
||||||
// called from UI
|
// called from UI
|
||||||
File pluginItemsFile = getPluginItemsFile();
|
File pluginItemsFile = getPluginItemsFile();
|
||||||
if (pluginItemsFile.exists()) {
|
if (pluginItemsFile.exists()) {
|
||||||
addPluginItemsFromFile(pluginItemsFile);
|
addPluginItemsFromFile(pluginItemsFile, activity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -212,7 +214,26 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
||||||
this.resourceDirName = resourceDirName;
|
this.resourceDirName = resourceDirName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPluginItemsFromFile(final File file) {
|
private void addPluginItemsFromFile(final File file, final Activity activity) {
|
||||||
|
final ProgressDialog progress = new ProgressDialog(activity);
|
||||||
|
progress.setTitle(app.getString(R.string.loading_smth, ""));
|
||||||
|
progress.setMessage(app.getString(R.string.loading_data));
|
||||||
|
progress.setIndeterminate(true);
|
||||||
|
progress.setCancelable(false);
|
||||||
|
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
|
progress.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
final SettingsHelper.SettingsImportListener importListener = new SettingsHelper.SettingsImportListener() {
|
||||||
|
@Override
|
||||||
|
public void onSettingsImportFinished(boolean succeed, @NonNull List<SettingsItem> items) {
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
|
progress.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
app.getSettingsHelper().collectSettings(file, "", 1, new SettingsCollectListener() {
|
app.getSettingsHelper().collectSettings(file, "", 1, new SettingsCollectListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsCollectFinished(boolean succeed, boolean empty, @NonNull List<SettingsItem> items) {
|
public void onSettingsCollectFinished(boolean succeed, boolean empty, @NonNull List<SettingsItem> items) {
|
||||||
|
@ -231,7 +252,7 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
||||||
item.setShouldReplace(true);
|
item.setShouldReplace(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.getSettingsHelper().importSettings(file, items, "", 1, null);
|
app.getSettingsHelper().importSettings(file, items, "", 1, importListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -134,13 +134,15 @@ public class PluginDisabledBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fm, String pluginId, Boolean usedOnMap) {
|
public static void showInstance(@NonNull FragmentManager fm, String pluginId, Boolean usedOnMap) {
|
||||||
try {
|
try {
|
||||||
Bundle args = new Bundle();
|
if (!fm.isStateSaved()) {
|
||||||
args.putString(PLUGIN_ID_KEY, pluginId);
|
Bundle args = new Bundle();
|
||||||
|
args.putString(PLUGIN_ID_KEY, pluginId);
|
||||||
|
|
||||||
PluginDisabledBottomSheet dialog = new PluginDisabledBottomSheet();
|
PluginDisabledBottomSheet dialog = new PluginDisabledBottomSheet();
|
||||||
dialog.setArguments(args);
|
dialog.setArguments(args);
|
||||||
dialog.setUsedOnMap(usedOnMap);
|
dialog.setUsedOnMap(usedOnMap);
|
||||||
dialog.show(fm, PluginDisabledBottomSheet.TAG);
|
dialog.show(fm, PluginDisabledBottomSheet.TAG);
|
||||||
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
LOG.error("showInstance", e);
|
LOG.error("showInstance", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,13 +322,15 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fm, String pluginId, Boolean usedOnMap) {
|
public static void showInstance(@NonNull FragmentManager fm, String pluginId, Boolean usedOnMap) {
|
||||||
try {
|
try {
|
||||||
Bundle args = new Bundle();
|
if (!fm.isStateSaved()) {
|
||||||
args.putString(PLUGIN_ID_KEY, pluginId);
|
Bundle args = new Bundle();
|
||||||
|
args.putString(PLUGIN_ID_KEY, pluginId);
|
||||||
|
|
||||||
PluginInstalledBottomSheetDialog dialog = new PluginInstalledBottomSheetDialog();
|
PluginInstalledBottomSheetDialog dialog = new PluginInstalledBottomSheetDialog();
|
||||||
dialog.setArguments(args);
|
dialog.setArguments(args);
|
||||||
dialog.setUsedOnMap(usedOnMap);
|
dialog.setUsedOnMap(usedOnMap);
|
||||||
dialog.show(fm, PluginInstalledBottomSheetDialog.TAG);
|
dialog.show(fm, PluginInstalledBottomSheetDialog.TAG);
|
||||||
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
LOG.error("showInstance", e);
|
LOG.error("showInstance", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -840,9 +840,22 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePluginImport(final PluginSettingsItem pluginItem, final File file) {
|
private void handlePluginImport(final PluginSettingsItem pluginItem, final File file) {
|
||||||
|
final ProgressDialog progress = new ProgressDialog(activity);
|
||||||
|
progress.setTitle(app.getString(R.string.loading_smth, ""));
|
||||||
|
progress.setMessage(app.getString(R.string.importing_from, pluginItem.getPublicName(app)));
|
||||||
|
progress.setIndeterminate(true);
|
||||||
|
progress.setCancelable(false);
|
||||||
|
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
|
progress.show();
|
||||||
|
}
|
||||||
|
|
||||||
final SettingsImportListener importListener = new SettingsImportListener() {
|
final SettingsImportListener importListener = new SettingsImportListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsImportFinished(boolean succeed, @NonNull List<SettingsItem> items) {
|
public void onSettingsImportFinished(boolean succeed, @NonNull List<SettingsItem> items) {
|
||||||
|
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
|
progress.dismiss();
|
||||||
|
}
|
||||||
CustomOsmandPlugin plugin = pluginItem.getPlugin();
|
CustomOsmandPlugin plugin = pluginItem.getPlugin();
|
||||||
plugin.loadResources();
|
plugin.loadResources();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue