Fix #8819
This commit is contained in:
parent
66060f78b2
commit
9a01fc9277
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,6 +134,7 @@ public class PluginDisabledBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
|
||||
public static void showInstance(@NonNull FragmentManager fm, String pluginId, Boolean usedOnMap) {
|
||||
try {
|
||||
if (!fm.isStateSaved()) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PLUGIN_ID_KEY, pluginId);
|
||||
|
||||
|
@ -141,6 +142,7 @@ public class PluginDisabledBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
dialog.setArguments(args);
|
||||
dialog.setUsedOnMap(usedOnMap);
|
||||
dialog.show(fm, PluginDisabledBottomSheet.TAG);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("showInstance", e);
|
||||
}
|
||||
|
|
|
@ -322,6 +322,7 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
|||
|
||||
public static void showInstance(@NonNull FragmentManager fm, String pluginId, Boolean usedOnMap) {
|
||||
try {
|
||||
if (!fm.isStateSaved()) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PLUGIN_ID_KEY, pluginId);
|
||||
|
||||
|
@ -329,6 +330,7 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
|||
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