refactor/wip

This commit is contained in:
veliymolfar 2020-02-04 19:04:25 +02:00
parent feca38ac4b
commit ccd638f2ed
3 changed files with 133 additions and 201 deletions

View file

@ -139,9 +139,9 @@ public class SettingsHelper {
PLUGIN, PLUGIN,
DATA, DATA,
FILE, FILE,
QUICK_ACTION_LIST, QUICK_ACTION,
POI_UI_FILTERS_LIST, POI_UI_FILTERS,
MAP_SOURCES_LIST, MAP_SOURCES,
} }
public abstract static class SettingsItem { public abstract static class SettingsItem {
@ -171,6 +171,10 @@ public class SettingsHelper {
@NonNull @NonNull
public abstract String getFileName(); public abstract String getFileName();
public Boolean shouldReadInCollecting() {
return false;
}
static SettingsItemType parseItemType(@NonNull JSONObject json) throws IllegalArgumentException, JSONException { static SettingsItemType parseItemType(@NonNull JSONObject json) throws IllegalArgumentException, JSONException {
return SettingsItemType.valueOf(json.getString("type")); return SettingsItemType.valueOf(json.getString("type"));
} }
@ -271,8 +275,6 @@ public class SettingsHelper {
private OsmandSettings settings; private OsmandSettings settings;
JSONObject json;
public OsmandSettingsItemReader(@NonNull OsmandSettingsItem item, @NonNull OsmandSettings settings) { public OsmandSettingsItemReader(@NonNull OsmandSettingsItem item, @NonNull OsmandSettings settings) {
super(item); super(item);
this.settings = settings; this.settings = settings;
@ -297,33 +299,32 @@ public class SettingsHelper {
if (Algorithms.isEmpty(jsonStr)) { if (Algorithms.isEmpty(jsonStr)) {
throw new IllegalArgumentException("Cannot find json body"); throw new IllegalArgumentException("Cannot find json body");
} }
// final JSONObject json; final JSONObject json;
try { try {
json = new JSONObject(jsonStr); json = new JSONObject(jsonStr);
} catch (JSONException e) { } catch (JSONException e) {
throw new IllegalArgumentException("Json parse error", e); throw new IllegalArgumentException("Json parse error", e);
} }
// settings.getContext().runInUIThread(new Runnable() { settings.getContext().runInUIThread(new Runnable() {
// @Override @Override
// public void run() { public void run() {
// Map<String, OsmandPreference<?>> prefs = settings.getRegisteredPreferences(); Map<String, OsmandPreference<?>> prefs = settings.getRegisteredPreferences();
// Iterator<String> iter = json.keys(); Iterator<String> iter = json.keys();
// while (iter.hasNext()) { while (iter.hasNext()) {
// String key = iter.next(); String key = iter.next();
// OsmandPreference<?> p = prefs.get(key); OsmandPreference<?> p = prefs.get(key);
// if (p != null) { if (p != null) {
// try { try {
// readPreferenceFromJson(p, json); readPreferenceFromJson(p, json);
// } catch (Exception e) { } catch (Exception e) {
// LOG.error("Failed to read preference: " + key, e); LOG.error("Failed to read preference: " + key, e);
// } }
// } else { } else {
// LOG.warn("No preference while importing settings: " + key); LOG.warn("No preference while importing settings: " + key);
// } }
// } }
// } }
// }); });
} }
} }
@ -484,27 +485,6 @@ public class SettingsHelper {
if (appMode.isCustomProfile()) { if (appMode.isCustomProfile()) {
appMode = ApplicationMode.saveProfile(builder, getSettings().getContext()); appMode = ApplicationMode.saveProfile(builder, getSettings().getContext());
} }
getSettings().getContext().runInUIThread(new Runnable() {
@Override
public void run() {
Map<String, OsmandPreference<?>> prefs = getSettings().getRegisteredPreferences();
Iterator<String> iter = reader.json.keys();
while (iter.hasNext()) {
String key = iter.next();
OsmandPreference<?> p = prefs.get(key);
if (p != null) {
try {
reader.readPreferenceFromJson(p, reader.json);
} catch (Exception e) {
LOG.error("Failed to read preference: " + key, e);
}
} else {
LOG.warn("No preference while importing settings: " + key);
}
}
}
});
} }
@Override @Override
@ -513,20 +493,17 @@ public class SettingsHelper {
json.put("appMode", new JSONObject(appMode.toJson())); json.put("appMode", new JSONObject(appMode.toJson()));
} }
OsmandSettingsItemReader reader = new OsmandSettingsItemReader(this, getSettings()) {
@Override
protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
if (!appModeBeanPrefsIds.contains(preference.getId())) {
preference.readFromJson(json, appMode);
}
}
};
@NonNull @NonNull
@Override @Override
SettingsItemReader getReader() { SettingsItemReader getReader() {
return reader; return new OsmandSettingsItemReader(this, getSettings()) {
@Override
protected void readPreferenceFromJson(@NonNull OsmandPreference<?> preference, @NonNull JSONObject json) throws JSONException {
if (!appModeBeanPrefsIds.contains(preference.getId())) {
preference.readFromJson(json, appMode);
}
}
};
} }
@NonNull @NonNull
@ -757,14 +734,14 @@ public class SettingsHelper {
public QuickActionSettingsItem(@NonNull OsmandApplication app, public QuickActionSettingsItem(@NonNull OsmandApplication app,
@NonNull List<QuickAction> quickActions) { @NonNull List<QuickAction> quickActions) {
super(SettingsItemType.QUICK_ACTION_LIST, app.getSettings()); super(SettingsItemType.QUICK_ACTION, app.getSettings());
this.app = app; this.app = app;
this.quickActions = quickActions; this.quickActions = quickActions;
} }
public QuickActionSettingsItem(@NonNull OsmandSettings settings, public QuickActionSettingsItem(@NonNull OsmandSettings settings,
@NonNull JSONObject jsonObject) throws JSONException { @NonNull JSONObject jsonObject) throws JSONException {
super(SettingsItemType.QUICK_ACTION_LIST, settings, jsonObject); super(SettingsItemType.QUICK_ACTION, settings, jsonObject);
} }
public List<QuickAction> getQuickActions() { public List<QuickAction> getQuickActions() {
@ -781,6 +758,11 @@ public class SettingsHelper {
} }
} }
@Override
public Boolean shouldReadInCollecting() {
return true;
}
@NonNull @NonNull
@Override @Override
public String getName() { public String getName() {
@ -874,13 +856,13 @@ public class SettingsHelper {
private OsmandApplication app; private OsmandApplication app;
public PoiUiFilterSettingsItem(OsmandApplication app, List<PoiUIFilter> poiUIFilters) { public PoiUiFilterSettingsItem(OsmandApplication app, List<PoiUIFilter> poiUIFilters) {
super(SettingsItemType.POI_UI_FILTERS_LIST, app.getSettings()); super(SettingsItemType.POI_UI_FILTERS, app.getSettings());
this.app = app; this.app = app;
this.poiUIFilters = poiUIFilters; this.poiUIFilters = poiUIFilters;
} }
public PoiUiFilterSettingsItem(OsmandApplication app, JSONObject jsonObject) throws JSONException { public PoiUiFilterSettingsItem(OsmandApplication app, JSONObject jsonObject) throws JSONException {
super(SettingsItemType.POI_UI_FILTERS_LIST, app.getSettings(), jsonObject); super(SettingsItemType.POI_UI_FILTERS, app.getSettings(), jsonObject);
this.app = app; this.app = app;
readFromJson(jsonObject); readFromJson(jsonObject);
} }
@ -897,6 +879,11 @@ public class SettingsHelper {
return null; return null;
} }
@Override
public Boolean shouldReadInCollecting() {
return true;
}
@NonNull @NonNull
@Override @Override
public String getFileName() { public String getFileName() {
@ -982,12 +969,12 @@ public class SettingsHelper {
private List<ExportImportProfileBottomSheet.MapSourceWrapper> mapSources; private List<ExportImportProfileBottomSheet.MapSourceWrapper> mapSources;
public MapSourcesSettingsItem(OsmandSettings settings, List<ExportImportProfileBottomSheet.MapSourceWrapper> mapSources) { public MapSourcesSettingsItem(OsmandSettings settings, List<ExportImportProfileBottomSheet.MapSourceWrapper> mapSources) {
super(SettingsItemType.MAP_SOURCES_LIST, settings); super(SettingsItemType.MAP_SOURCES, settings);
this.mapSources = mapSources; this.mapSources = mapSources;
} }
public MapSourcesSettingsItem(OsmandSettings settings, JSONObject jsonObject) throws JSONException { public MapSourcesSettingsItem(OsmandSettings settings, JSONObject jsonObject) throws JSONException {
super(SettingsItemType.MAP_SOURCES_LIST, settings, jsonObject); super(SettingsItemType.MAP_SOURCES, settings, jsonObject);
} }
@NonNull @NonNull
@ -1002,6 +989,11 @@ public class SettingsHelper {
return null; return null;
} }
@Override
public Boolean shouldReadInCollecting() {
return true;
}
@NonNull @NonNull
@Override @Override
public String getFileName() { public String getFileName() {
@ -1096,13 +1088,13 @@ public class SettingsHelper {
case FILE: case FILE:
item = new FileSettingsItem(app, json); item = new FileSettingsItem(app, json);
break; break;
case QUICK_ACTION_LIST: case QUICK_ACTION:
item = new QuickActionSettingsItem(settings, json); item = new QuickActionSettingsItem(settings, json);
break; break;
case POI_UI_FILTERS_LIST: case POI_UI_FILTERS:
item = new PoiUiFilterSettingsItem(app, json); item = new PoiUiFilterSettingsItem(app, json);
break; break;
case MAP_SOURCES_LIST: case MAP_SOURCES:
item = new MapSourcesSettingsItem(settings, json); item = new MapSourcesSettingsItem(settings, json);
break; break;
} }
@ -1181,15 +1173,14 @@ public class SettingsHelper {
} }
private List<SettingsItem> processItems(@NonNull File file, @Nullable List<SettingsItem> items) throws IllegalArgumentException, IOException { private List<SettingsItem> processItems(@NonNull File file, @Nullable List<SettingsItem> items) throws IllegalArgumentException, IOException {
// boolean collecting = items == null; boolean collecting = items == null;
// if (collecting) { if (collecting) {
// items = new ArrayList<>(); items = new ArrayList<>();
// } else { } else {
// if (items.size() == 0) { if (items.size() == 0) {
// throw new IllegalArgumentException("No items"); throw new IllegalArgumentException("No items");
// } }
// } }
items = new ArrayList<>();
ZipInputStream zis = new ZipInputStream(new FileInputStream(file)); ZipInputStream zis = new ZipInputStream(new FileInputStream(file));
InputStream ois = new BufferedInputStream(zis); InputStream ois = new BufferedInputStream(zis);
try { try {
@ -1207,9 +1198,9 @@ public class SettingsHelper {
SettingsItemsFactory itemsFactory; SettingsItemsFactory itemsFactory;
try { try {
itemsFactory = new SettingsItemsFactory(app, itemsJson); itemsFactory = new SettingsItemsFactory(app, itemsJson);
// if (collecting) { if (collecting) {
items.addAll(itemsFactory.getItems()); items.addAll(itemsFactory.getItems());
// } }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
LOG.error("Error parsing items: " + itemsJson, e); LOG.error("Error parsing items: " + itemsJson, e);
throw new IllegalArgumentException("No items"); throw new IllegalArgumentException("No items");
@ -1220,7 +1211,8 @@ public class SettingsHelper {
while ((entry = zis.getNextEntry()) != null) { while ((entry = zis.getNextEntry()) != null) {
String fileName = entry.getName(); String fileName = entry.getName();
SettingsItem item = itemsFactory.getItemByFileName(fileName); SettingsItem item = itemsFactory.getItemByFileName(fileName);
if (item != null) { if (item != null && collecting && item.shouldReadInCollecting()
|| item != null && !collecting && !item.shouldReadInCollecting()) {
try { try {
item.getReader().readFromStream(ois); item.getReader().readFromStream(ois);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -1251,6 +1243,7 @@ public class SettingsHelper {
private File file; private File file;
private String latestChanges; private String latestChanges;
private int version; private int version;
private Boolean isCollecting;
private SettingsImportListener listener; private SettingsImportListener listener;
private SettingsImporter importer; private SettingsImporter importer;
@ -1265,6 +1258,17 @@ public class SettingsHelper {
this.latestChanges = latestChanges; this.latestChanges = latestChanges;
this.version = version; this.version = version;
importer = new SettingsImporter(app); importer = new SettingsImporter(app);
isCollecting = true;
}
ImportAsyncTask(@NonNull File settingsFile, @NonNull List<SettingsItem> items, String latestChanges, int version, @Nullable SettingsImportListener listener) {
this.file = settingsFile;
this.listener = listener;
this.items = items;
this.latestChanges = latestChanges;
this.version = version;
importer = new SettingsImporter(app);
isCollecting = false;
} }
@Override @Override
@ -1279,21 +1283,29 @@ public class SettingsHelper {
@Override @Override
protected List<SettingsItem> doInBackground(Void... voids) { protected List<SettingsItem> doInBackground(Void... voids) {
try { if (isCollecting) {
return importer.collectItems(file); try {
} catch (IllegalArgumentException e) { return importer.collectItems(file);
LOG.error("Failed to collect items from: " + file.getName(), e); } catch (IllegalArgumentException e) {
} catch (IOException e) { LOG.error("Failed to collect items from: " + file.getName(), e);
LOG.error("Failed to collect items from: " + file.getName(), e); } catch (IOException e) {
LOG.error("Failed to collect items from: " + file.getName(), e);
}
} else {
return this.items;
} }
return null; return null;
} }
@Override @Override
protected void onPostExecute(List<SettingsItem> items) { protected void onPostExecute(List<SettingsItem> items) {
this.items = items; if (isCollecting) {
if (items != null && items.size() > 0) { listener.onSettingsImportFinished(true, false, items);
processNextItem(); } else {
this.items = items;
if (items != null && items.size() > 0) {
processNextItem();
}
} }
} }
@ -1433,46 +1445,6 @@ public class SettingsHelper {
} }
} }
@SuppressLint("StaticFieldLeak")
public class PreImportAsyncTask extends AsyncTask<Void, Void, List<SettingsItem>> {
private String latestChanges;
private int version;
private File file;
private SettingsPreImportListener listener;
private SettingsImporter importer;
PreImportAsyncTask(@NonNull File file, String latestChanges, int version, SettingsPreImportListener listener) {
this.file = file;
this.listener = listener;
this.latestChanges = latestChanges;
this.version = version;
importer = new SettingsImporter(app);
}
@Override
protected List<SettingsItem> doInBackground(Void... voids) {
try {
return importer.collectItems(file);
} catch (IllegalArgumentException e) {
LOG.error("Failed to collect items from: " + file.getName(), e);
} catch (IOException e) {
LOG.error("Failed to collect items from: " + file.getName(), e);
}
return null;
}
@Override
protected void onPostExecute(List<SettingsItem> settingsItems) {
super.onPostExecute(settingsItems);
if (settingsItems != null && settingsItems.size() > 0) {
listener.onSettingsPreImported(true, settingsItems);
} else {
listener.onSettingsPreImported(false, settingsItems);
}
}
}
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
private class ExportAsyncTask extends AsyncTask<Void, Void, Boolean> { private class ExportAsyncTask extends AsyncTask<Void, Void, Boolean> {
@ -1516,6 +1488,10 @@ public class SettingsHelper {
new ImportAsyncTask(settingsFile, latestChanges, version, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new ImportAsyncTask(settingsFile, latestChanges, version, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
public void importSettings(@NonNull File settingsFile, @NonNull List<SettingsItem> items, String latestChanges, int version, @Nullable SettingsImportListener listener) {
new ImportAsyncTask(settingsFile, items, latestChanges, version, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public void exportSettings(@NonNull File fileDir, @NonNull String fileName, public void exportSettings(@NonNull File fileDir, @NonNull String fileName,
@Nullable SettingsExportListener listener, @Nullable SettingsExportListener listener,
@NonNull List<SettingsItem> items) { @NonNull List<SettingsItem> items) {
@ -1527,59 +1503,4 @@ public class SettingsHelper {
@NonNull SettingsItem... items) { @NonNull SettingsItem... items) {
exportSettings(fileDir, fileName, listener, new ArrayList<>(Arrays.asList(items))); exportSettings(fileDir, fileName, listener, new ArrayList<>(Arrays.asList(items)));
} }
public void preImportSettings(File file, String latestChanges, int version, SettingsPreImportListener listener) {
new PreImportAsyncTask(file, latestChanges, version, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public void importSettingsItems(List<SettingsItem> list) {
for (SettingsItem item : list) {
if (item.exists()) {
switch (item.getType()) {
case PROFILE: {
String title = activity.getString(R.string.overwrite_profile_q, item.getPublicName(app));
showConfirmDialog(item, title, "");
break;
}
default:
item.apply();
break;
}
} else {
if (item.getType() == SettingsItemType.PROFILE) {
String title = activity.getString(R.string.add_new_profile_q, item.getPublicName(app));
showConfirmDialog(item, title, "");
} else {
item.apply();
// acceptItem(item);
}
}
}
}
private AlertDialog showConfirmDialog(final SettingsItem item, String title, String message) {
AlertDialog.Builder b = new AlertDialog.Builder(activity);
b.setTitle(title);
b.setMessage(message);
b.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
item.apply();
}
});
b.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
b.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
}
});
b.setCancelable(false);
return b.show();
}
} }

View file

@ -776,18 +776,19 @@ public class ImportHelper {
File tempDir = app.getAppPath(IndexConstants.TEMP_DIR); File tempDir = app.getAppPath(IndexConstants.TEMP_DIR);
final File file = new File(tempDir, name); final File file = new File(tempDir, name);
if (error == null && file.exists()) { if (error == null && file.exists()) {
app.getSettingsHelper().preImportSettings(file, latestChanges, version, new SettingsHelper.SettingsPreImportListener() { app.getSettingsHelper().importSettings(file, latestChanges, version, new SettingsImportListener() {
@Override @Override
public void onSettingsPreImported(boolean isSuccessful, List<SettingsHelper.SettingsItem> items) { public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
if (isActivityNotDestroyed(activity)) { if (isActivityNotDestroyed(activity)) {
progress.dismiss(); progress.dismiss();
} }
if (isSuccessful) { if (succeed) {
FragmentManager fragmentManager = activity.getSupportFragmentManager(); FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager != null) { if (fragmentManager != null) {
ExportImportProfileBottomSheet.showInstance( ExportImportProfileBottomSheet.showInstance(
fragmentManager, fragmentManager,
ExportImportProfileBottomSheet.State.IMPORT, ExportImportProfileBottomSheet.State.IMPORT,
file,
items); items);
} }
} else { } else {

View file

@ -87,6 +87,8 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
private SettingsHelper.ProfileSettingsItem profileSettingsItem; private SettingsHelper.ProfileSettingsItem profileSettingsItem;
private File file;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -191,11 +193,11 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
List<PoiUIFilter> poiUIFilters = new ArrayList<>(); List<PoiUIFilter> poiUIFilters = new ArrayList<>();
List<MapSourceWrapper> mapSourceWrappers = new ArrayList<>(); List<MapSourceWrapper> mapSourceWrappers = new ArrayList<>();
for (SettingsHelper.SettingsItem item : settingsItems) { for (SettingsHelper.SettingsItem item : settingsItems) {
if (item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION_LIST)) { if (item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION)) {
quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getQuickActions()); quickActions.addAll(((SettingsHelper.QuickActionSettingsItem) item).getQuickActions());
} else if (item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS_LIST)) { } else if (item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS)) {
// poiUIFilters.addAll(((SettingsHelper.PoiUiFilterSettingsItem) item).) // poiUIFilters.addAll(((SettingsHelper.PoiUiFilterSettingsItem) item).)
} else if (item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES_LIST)) { } else if (item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES)) {
// mapSourceWrappers.addAll(((SettingsHelper.MapSourcesSettingsItem) item).) // mapSourceWrappers.addAll(((SettingsHelper.MapSourcesSettingsItem) item).)
} }
} }
@ -219,21 +221,14 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
dataToOperate.addAll(dataWrapper.getItems()); dataToOperate.addAll(dataWrapper.getItems());
} }
adapter.updateList(dataList); adapter.updateList(dataList);
// app.getSettingsHelper().importSettings(settingsItems, file, new SettingsHelper.SettingsImportListener() {
// @Override
// public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
//
// }
// });
} }
private Boolean checkAdditionalDataContains() { private Boolean checkAdditionalDataContains() {
boolean containsData = false; boolean containsData = false;
for (SettingsHelper.SettingsItem item : settingsItems) { for (SettingsHelper.SettingsItem item : settingsItems) {
containsData = item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION_LIST) containsData = item.getType().equals(SettingsHelper.SettingsItemType.QUICK_ACTION)
|| item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS_LIST) || item.getType().equals(SettingsHelper.SettingsItemType.POI_UI_FILTERS)
|| item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES_LIST); || item.getType().equals(SettingsHelper.SettingsItemType.MAP_SOURCES);
if (containsData) { if (containsData) {
break; break;
} }
@ -299,7 +294,12 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
if (includeAdditionalData) { if (includeAdditionalData) {
list.addAll(prepareAdditionalSettingsItems()); list.addAll(prepareAdditionalSettingsItems());
} }
app.getSettingsHelper().importSettingsItems(list); app.getSettingsHelper().importSettings(file, list, "", 1, new SettingsHelper.SettingsImportListener() {
@Override
public void onSettingsImportFinished(boolean succeed, boolean empty, @NonNull List<SettingsHelper.SettingsItem> items) {
}
});
dismiss(); dismiss();
} }
@ -410,6 +410,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
public static boolean showInstance(@NonNull FragmentManager fragmentManager, public static boolean showInstance(@NonNull FragmentManager fragmentManager,
State state, State state,
File file,
List<SettingsHelper.SettingsItem> items) { List<SettingsHelper.SettingsItem> items) {
try { try {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -417,6 +418,7 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
ExportImportProfileBottomSheet fragment = new ExportImportProfileBottomSheet(); ExportImportProfileBottomSheet fragment = new ExportImportProfileBottomSheet();
fragment.setArguments(bundle); fragment.setArguments(bundle);
fragment.setSettingsItems(items); fragment.setSettingsItems(items);
fragment.setFile(file);
fragment.show(fragmentManager, TAG); fragment.show(fragmentManager, TAG);
return true; return true;
} catch (RuntimeException e) { } catch (RuntimeException e) {
@ -424,6 +426,14 @@ public class ExportImportProfileBottomSheet extends BasePreferenceBottomSheet {
} }
} }
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public enum State { public enum State {
EXPORT, EXPORT,
IMPORT IMPORT