commit
f1a2a17c93
5 changed files with 54 additions and 16 deletions
|
@ -3540,7 +3540,7 @@
|
|||
<string name="shared_string_routing">ניתוב</string>
|
||||
<string name="listed_exist">%1$s מוצג, כבר קיים ב־OsmAnd.</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="checking_for_duplicate_description">OsmAnd יחפש כפילויות של %1$s עם פריטים קיימים ביישומון.
|
||||
\n
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -9,6 +10,7 @@ import android.text.Html;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.JsonUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -104,7 +106,7 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
|||
// called from UI
|
||||
File pluginItemsFile = getPluginItemsFile();
|
||||
if (pluginItemsFile.exists()) {
|
||||
addPluginItemsFromFile(pluginItemsFile);
|
||||
addPluginItemsFromFile(pluginItemsFile, activity);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -212,7 +214,26 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
|||
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() {
|
||||
@Override
|
||||
public void onSettingsCollectFinished(boolean succeed, boolean empty, @NonNull List<SettingsItem> items) {
|
||||
|
@ -231,7 +252,7 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
|||
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) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PLUGIN_ID_KEY, pluginId);
|
||||
if (!fm.isStateSaved()) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PLUGIN_ID_KEY, pluginId);
|
||||
|
||||
PluginDisabledBottomSheet dialog = new PluginDisabledBottomSheet();
|
||||
dialog.setArguments(args);
|
||||
dialog.setUsedOnMap(usedOnMap);
|
||||
dialog.show(fm, PluginDisabledBottomSheet.TAG);
|
||||
PluginDisabledBottomSheet dialog = new PluginDisabledBottomSheet();
|
||||
dialog.setArguments(args);
|
||||
dialog.setUsedOnMap(usedOnMap);
|
||||
dialog.show(fm, PluginDisabledBottomSheet.TAG);
|
||||
}
|
||||
} catch (RuntimeException 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) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PLUGIN_ID_KEY, pluginId);
|
||||
if (!fm.isStateSaved()) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PLUGIN_ID_KEY, pluginId);
|
||||
|
||||
PluginInstalledBottomSheetDialog dialog = new PluginInstalledBottomSheetDialog();
|
||||
dialog.setArguments(args);
|
||||
dialog.setUsedOnMap(usedOnMap);
|
||||
dialog.show(fm, PluginInstalledBottomSheetDialog.TAG);
|
||||
PluginInstalledBottomSheetDialog dialog = new PluginInstalledBottomSheetDialog();
|
||||
dialog.setArguments(args);
|
||||
dialog.setUsedOnMap(usedOnMap);
|
||||
dialog.show(fm, PluginInstalledBottomSheetDialog.TAG);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("showInstance", e);
|
||||
}
|
||||
|
|
|
@ -840,9 +840,22 @@ public class ImportHelper {
|
|||
}
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void onSettingsImportFinished(boolean succeed, @NonNull List<SettingsItem> items) {
|
||||
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||
progress.dismiss();
|
||||
}
|
||||
CustomOsmandPlugin plugin = pluginItem.getPlugin();
|
||||
plugin.loadResources();
|
||||
|
||||
|
|
Loading…
Reference in a new issue