This commit is contained in:
parent
ed46bee627
commit
0250c5cfe2
6 changed files with 164 additions and 81 deletions
|
@ -21,6 +21,7 @@ AndroidBitmapInfo androidBitmapInfo;
|
||||||
enum ChooseKmlMode chooseCurrentKmlMode;
|
enum ChooseKmlMode chooseCurrentKmlMode;
|
||||||
TCHAR szChosenCurrentKml[MAX_PATH];
|
TCHAR szChosenCurrentKml[MAX_PATH];
|
||||||
TCHAR szKmlLog[10240];
|
TCHAR szKmlLog[10240];
|
||||||
|
TCHAR szKmlLogBackup[10240];
|
||||||
TCHAR szKmlTitle[10240];
|
TCHAR szKmlTitle[10240];
|
||||||
BOOL settingsPort2en;
|
BOOL settingsPort2en;
|
||||||
BOOL settingsPort2wr;
|
BOOL settingsPort2wr;
|
||||||
|
@ -826,23 +827,25 @@ JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onViewReset(JNIEn
|
||||||
SwitchToState(SM_RUN);
|
SwitchToState(SM_RUN);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onViewScript(JNIEnv *env, jobject thisz, jstring kmlFilename) {
|
JNIEXPORT int JNICALL Java_org_emulator_forty_eight_NativeLib_onViewScript(JNIEnv *env, jobject thisz, jstring kmlFilename) {
|
||||||
|
|
||||||
TCHAR szKmlFile[MAX_PATH];
|
TCHAR szKmlFile[MAX_PATH];
|
||||||
BOOL bKMLChanged,bSucc;
|
// BOOL bKMLChanged,bSucc;
|
||||||
BYTE cType = cCurrentRomType;
|
BYTE cType = cCurrentRomType;
|
||||||
SwitchToState(SM_INVALID);
|
SwitchToState(SM_INVALID);
|
||||||
|
|
||||||
const char *filenameUTF8 = (*env)->GetStringUTFChars(env, kmlFilename , NULL) ;
|
|
||||||
_tcscpy(szCurrentKml, filenameUTF8);
|
|
||||||
(*env)->ReleaseStringUTFChars(env, kmlFilename, filenameUTF8);
|
|
||||||
|
|
||||||
// make a copy of the current KML script file name
|
// make a copy of the current KML script file name
|
||||||
_ASSERT(sizeof(szKmlFile) == sizeof(szCurrentKml));
|
_ASSERT(sizeof(szKmlFile) == sizeof(szCurrentKml));
|
||||||
lstrcpyn(szKmlFile,szCurrentKml,ARRAYSIZEOF(szKmlFile));
|
lstrcpyn(szKmlFile,szCurrentKml,ARRAYSIZEOF(szKmlFile));
|
||||||
|
|
||||||
bKMLChanged = FALSE; // KML script not changed
|
const char *filenameUTF8 = (*env)->GetStringUTFChars(env, kmlFilename , NULL) ;
|
||||||
bSucc = TRUE; // KML script successful loaded
|
_tcscpy(szCurrentKml, filenameUTF8);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, kmlFilename, filenameUTF8);
|
||||||
|
|
||||||
|
// bKMLChanged = FALSE; // KML script not changed
|
||||||
|
BOOL bSucc = TRUE; // KML script successful loaded
|
||||||
|
|
||||||
|
chooseCurrentKmlMode = ChooseKmlMode_CHANGE_KML;
|
||||||
|
|
||||||
// do
|
// do
|
||||||
// {
|
// {
|
||||||
|
@ -866,12 +869,27 @@ JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onViewScript(JNIE
|
||||||
// }
|
// }
|
||||||
// else // quit with Ok
|
// else // quit with Ok
|
||||||
// {
|
// {
|
||||||
bKMLChanged = TRUE; // KML script changed
|
// bKMLChanged = TRUE; // KML script changed
|
||||||
bSucc = InitKML(szCurrentKml,FALSE);
|
bSucc = InitKML(szCurrentKml,FALSE);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// while (!bSucc); // retry if KML script is invalid
|
// while (!bSucc); // retry if KML script is invalid
|
||||||
|
|
||||||
|
BOOL result = bSucc;
|
||||||
|
|
||||||
|
if(!bSucc) {
|
||||||
|
// restore KML script file name
|
||||||
|
lstrcpyn(szCurrentKml,szKmlFile,ARRAYSIZEOF(szCurrentKml));
|
||||||
|
|
||||||
|
_tcsncpy(szKmlLogBackup, szKmlLog, sizeof(szKmlLog) / sizeof(TCHAR));
|
||||||
|
|
||||||
|
// try to restore old KML script
|
||||||
|
bSucc = InitKML(szCurrentKml,FALSE);
|
||||||
|
|
||||||
|
_tcsncpy(szKmlLog, szKmlLogBackup, sizeof(szKmlLog) / sizeof(TCHAR));
|
||||||
|
}
|
||||||
|
chooseCurrentKmlMode = ChooseKmlMode_UNKNOWN;
|
||||||
|
|
||||||
if (bSucc)
|
if (bSucc)
|
||||||
{
|
{
|
||||||
if (Chipset.wRomCrc != wRomCrc) // ROM changed
|
if (Chipset.wRomCrc != wRomCrc) // ROM changed
|
||||||
|
@ -890,6 +908,8 @@ JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onViewScript(JNIE
|
||||||
}
|
}
|
||||||
mainViewResizeCallback(nBackgroundW, nBackgroundH);
|
mainViewResizeCallback(nBackgroundW, nBackgroundH);
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onBackupSave(JNIEnv *env, jobject thisz) {
|
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onBackupSave(JNIEnv *env, jobject thisz) {
|
||||||
|
|
|
@ -97,7 +97,7 @@ HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||||
|
|
||||||
TCHAR * foundDocumentScheme = _tcsstr(lpFileName, documentScheme);
|
TCHAR * foundDocumentScheme = _tcsstr(lpFileName, documentScheme);
|
||||||
|
|
||||||
if(chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN) {
|
if(chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN || chooseCurrentKmlMode == ChooseKmlMode_CHANGE_KML) {
|
||||||
// When we open a new E48 state document
|
// When we open a new E48 state document
|
||||||
TCHAR * fileExtension = _tcsrchr(lpFileName, _T('.'));
|
TCHAR * fileExtension = _tcsrchr(lpFileName, _T('.'));
|
||||||
if(fileExtension && ((fileExtension[1] == 'K' && fileExtension[2] == 'M' && fileExtension[3] == 'L') ||
|
if(fileExtension && ((fileExtension[1] == 'K' && fileExtension[2] == 'M' && fileExtension[3] == 'L') ||
|
||||||
|
|
|
@ -1128,7 +1128,8 @@ extern TCHAR szChosenCurrentKml[MAX_PATH];
|
||||||
enum ChooseKmlMode {
|
enum ChooseKmlMode {
|
||||||
ChooseKmlMode_UNKNOWN,
|
ChooseKmlMode_UNKNOWN,
|
||||||
ChooseKmlMode_FILE_NEW,
|
ChooseKmlMode_FILE_NEW,
|
||||||
ChooseKmlMode_FILE_OPEN
|
ChooseKmlMode_FILE_OPEN,
|
||||||
|
ChooseKmlMode_CHANGE_KML
|
||||||
};
|
};
|
||||||
extern enum ChooseKmlMode chooseCurrentKmlMode;
|
extern enum ChooseKmlMode chooseCurrentKmlMode;
|
||||||
BOOL getFirstKMLFilenameForType(BYTE chipsetType, TCHAR * firstKMLFilename, size_t firstKMLFilenameSize);
|
BOOL getFirstKMLFilenameForType(BYTE chipsetType, TCHAR * firstKMLFilename, size_t firstKMLFilenameSize);
|
||||||
|
|
|
@ -66,8 +66,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
public static final int INTENT_OBJECT_SAVE = 4;
|
public static final int INTENT_OBJECT_SAVE = 4;
|
||||||
public static final int INTENT_SETTINGS = 5;
|
public static final int INTENT_SETTINGS = 5;
|
||||||
public static final int INTENT_PORT2LOAD = 6;
|
public static final int INTENT_PORT2LOAD = 6;
|
||||||
public static final int INTENT_PICK_KML_FOLDER = 7;
|
public static final int INTENT_PICK_KML_FOLDER_FOR_NEW_FILE = 7;
|
||||||
//public static final int INTENT_PICK_KML_FILE = 8;
|
public static final int INTENT_PICK_KML_FOLDER_FOR_CHANGING = 8;
|
||||||
|
public static final int INTENT_PICK_KML_FOLDER_FOR_SETTINGS = 9;
|
||||||
|
//public static final int INTENT_PICK_KML_FILE = 10;
|
||||||
|
|
||||||
public static MainActivity mainActivity;
|
public static MainActivity mainActivity;
|
||||||
|
|
||||||
|
@ -630,44 +632,52 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
// By default Port1 is set
|
// By default Port1 is set
|
||||||
setPort1Settings(true, true);
|
setPort1Settings(true, true);
|
||||||
|
|
||||||
extractKMLScripts();
|
|
||||||
|
|
||||||
ensureDocumentSaved(new Runnable() {
|
ensureDocumentSaved(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final int lastIndex = kmlScripts.size();
|
|
||||||
final String[] kmlScriptTitles = new String[lastIndex + 2];
|
|
||||||
for (int i = 0; i < kmlScripts.size(); i++)
|
|
||||||
kmlScriptTitles[i] = kmlScripts.get(i).title;
|
|
||||||
kmlScriptTitles[lastIndex] = getResources().getString(R.string.load_custom_kml);
|
|
||||||
kmlScriptTitles[lastIndex + 1] = getResources().getString(R.string.load_default_kml);
|
|
||||||
new AlertDialog.Builder(MainActivity.this)
|
|
||||||
.setTitle(getResources().getString(R.string.pick_calculator))
|
|
||||||
.setItems(kmlScriptTitles, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if(which == lastIndex) {
|
|
||||||
// Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
|
||||||
// intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
||||||
// intent.setType(kmlMimeType);
|
|
||||||
// intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
|
||||||
// startActivityForResult(intent, INTENT_PICK_KML_FILE);
|
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
// extractKMLScripts();
|
||||||
startActivityForResult(intent, INTENT_PICK_KML_FOLDER);
|
//
|
||||||
} else if(which == lastIndex + 1) {
|
// final ArrayList<KMLScriptItem> kmlScriptsForCurrentModel = kmlScripts;
|
||||||
// Reset to default KML folder
|
//
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
// final int lastIndex = kmlScriptsForCurrentModel.size();
|
||||||
editor.putBoolean("settings_kml_default", true);
|
// final String[] kmlScriptTitles = new String[lastIndex + 2];
|
||||||
//editor.putString("settings_kml_folder", url);
|
// for (int i = 0; i < kmlScriptsForCurrentModel.size(); i++)
|
||||||
editor.apply();
|
// kmlScriptTitles[i] = kmlScriptsForCurrentModel.get(i).title;
|
||||||
OnFileNew();
|
// kmlScriptTitles[lastIndex] = getResources().getString(R.string.load_custom_kml);
|
||||||
} else {
|
// kmlScriptTitles[lastIndex + 1] = getResources().getString(R.string.load_default_kml);
|
||||||
String kmlScriptFilename = kmlScripts.get(which).filename;
|
// new AlertDialog.Builder(MainActivity.this)
|
||||||
newFileFromKML(kmlScriptFilename);
|
// .setTitle(getResources().getString(R.string.pick_calculator))
|
||||||
}
|
// .setItems(kmlScriptTitles, new DialogInterface.OnClickListener() {
|
||||||
}
|
// @Override
|
||||||
}).show();
|
// public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// if(which == lastIndex) {
|
||||||
|
//// Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
|
//// intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
//// intent.setType(kmlMimeType);
|
||||||
|
//// intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
||||||
|
//// startActivityForResult(intent, INTENT_PICK_KML_FILE);
|
||||||
|
//
|
||||||
|
// Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
|
// Bundle bundle = new Bundle();
|
||||||
|
// bundle.putString("mode", "new-kml");
|
||||||
|
// intent.putExtras(bundle);
|
||||||
|
// startActivityForResult(intent, INTENT_PICK_KML_FOLDER);
|
||||||
|
// } else if(which == lastIndex + 1) {
|
||||||
|
// // Reset to default KML folder
|
||||||
|
// SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
// editor.putBoolean("settings_kml_default", true);
|
||||||
|
// //editor.putString("settings_kml_folder", url);
|
||||||
|
// editor.apply();
|
||||||
|
// OnFileNew();
|
||||||
|
// //OnViewScript();
|
||||||
|
// } else {
|
||||||
|
// String kmlScriptFilename = kmlScriptsForCurrentModel.get(which).filename;
|
||||||
|
// newFileFromKML(kmlScriptFilename);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }).show();
|
||||||
|
showKMLPicker(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -842,38 +852,71 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
|
|
||||||
}
|
}
|
||||||
private void OnViewScript() {
|
private void OnViewScript() {
|
||||||
extractKMLScripts();
|
if (NativeLib.getState() != 0 /*SM_RUN*/) {
|
||||||
|
|
||||||
if (NativeLib.getState() != 0 /*SM_RUN*/)
|
|
||||||
{
|
|
||||||
showAlert("You cannot change the KML script when Emu48 is not running.\n"
|
showAlert("You cannot change the KML script when Emu48 is not running.\n"
|
||||||
+ "Use the File,New menu item to create a new calculator.");
|
+ "Use the File,New menu item to create a new calculator.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ArrayList<KMLScriptItem> kmlScriptsForCurrentModel = new ArrayList<>();
|
|
||||||
char m = (char)NativeLib.getCurrentModel();
|
|
||||||
for (int i = 0; i < kmlScripts.size(); i++) {
|
|
||||||
KMLScriptItem kmlScriptItem = kmlScripts.get(i);
|
|
||||||
if (kmlScriptItem.model.charAt(0) == m)
|
|
||||||
kmlScriptsForCurrentModel.add(kmlScriptItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String[] kmlScriptTitles = new String[kmlScriptsForCurrentModel.size()];
|
showKMLPicker(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showKMLPicker(final boolean changeKML) {
|
||||||
|
extractKMLScripts();
|
||||||
|
|
||||||
|
final ArrayList<KMLScriptItem> kmlScriptsForCurrentModel;
|
||||||
|
if(changeKML) {
|
||||||
|
kmlScriptsForCurrentModel = new ArrayList<KMLScriptItem>();
|
||||||
|
char m = (char) NativeLib.getCurrentModel();
|
||||||
|
for (int i = 0; i < kmlScripts.size(); i++) {
|
||||||
|
KMLScriptItem kmlScriptItem = kmlScripts.get(i);
|
||||||
|
if (kmlScriptItem.model.charAt(0) == m)
|
||||||
|
kmlScriptsForCurrentModel.add(kmlScriptItem);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
kmlScriptsForCurrentModel = kmlScripts;
|
||||||
|
|
||||||
|
final int lastIndex = kmlScriptsForCurrentModel.size();
|
||||||
|
final String[] kmlScriptTitles = new String[lastIndex + 2];
|
||||||
for (int i = 0; i < kmlScriptsForCurrentModel.size(); i++)
|
for (int i = 0; i < kmlScriptsForCurrentModel.size(); i++)
|
||||||
kmlScriptTitles[i] = kmlScriptsForCurrentModel.get(i).title;
|
kmlScriptTitles[i] = kmlScriptsForCurrentModel.get(i).title;
|
||||||
|
kmlScriptTitles[lastIndex] = getResources().getString(R.string.load_custom_kml);
|
||||||
|
kmlScriptTitles[lastIndex + 1] = getResources().getString(R.string.load_default_kml);
|
||||||
new AlertDialog.Builder(MainActivity.this)
|
new AlertDialog.Builder(MainActivity.this)
|
||||||
.setTitle("Pick a calculator")
|
.setTitle(getResources().getString(R.string.pick_calculator))
|
||||||
.setItems(kmlScriptTitles, new DialogInterface.OnClickListener() {
|
.setItems(kmlScriptTitles, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String kmlScriptFilename = kmlScriptsForCurrentModel.get(which).filename;
|
if(which == lastIndex) {
|
||||||
NativeLib.onViewScript(kmlScriptFilename);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
displayKMLTitle();
|
startActivityForResult(intent, changeKML ? INTENT_PICK_KML_FOLDER_FOR_CHANGING : INTENT_PICK_KML_FOLDER_FOR_NEW_FILE);
|
||||||
showKMLLog();
|
} else if(which == lastIndex + 1) {
|
||||||
updateNavigationDrawerItems();
|
// Reset to default KML folder
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.putBoolean("settings_kml_default", true);
|
||||||
|
//editor.putString("settings_kml_folder", url);
|
||||||
|
editor.apply();
|
||||||
|
if(changeKML)
|
||||||
|
OnViewScript();
|
||||||
|
else
|
||||||
|
OnFileNew();
|
||||||
|
} else {
|
||||||
|
String kmlScriptFilename = kmlScriptsForCurrentModel.get(which).filename;
|
||||||
|
if(changeKML) {
|
||||||
|
int result = NativeLib.onViewScript(kmlScriptFilename);
|
||||||
|
if(result > 0) {
|
||||||
|
displayKMLTitle();
|
||||||
|
showKMLLog();
|
||||||
|
} else
|
||||||
|
showKMLLogForce();
|
||||||
|
updateNavigationDrawerItems();
|
||||||
|
} else
|
||||||
|
newFileFromKML(kmlScriptFilename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).show();
|
}).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTopics() {
|
private void OnTopics() {
|
||||||
startActivity(new Intent(this, InfoWebActivity.class));
|
startActivity(new Intent(this, InfoWebActivity.class));
|
||||||
}
|
}
|
||||||
|
@ -930,14 +973,27 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||||
// DocumentFile parentDocumentFile = documentFile.getParentFile();
|
// DocumentFile parentDocumentFile = documentFile.getParentFile();
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
case INTENT_PICK_KML_FOLDER: {
|
case INTENT_PICK_KML_FOLDER_FOR_NEW_FILE:
|
||||||
|
case INTENT_PICK_KML_FOLDER_FOR_CHANGING:
|
||||||
|
case INTENT_PICK_KML_FOLDER_FOR_SETTINGS: {
|
||||||
Log.d(TAG, "onActivityResult INTENT_PICK_KML_FOLDER " + url);
|
Log.d(TAG, "onActivityResult INTENT_PICK_KML_FOLDER " + url);
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
editor.putBoolean("settings_kml_default", false);
|
editor.putBoolean("settings_kml_default", false);
|
||||||
editor.putString("settings_kml_folder", url);
|
editor.putString("settings_kml_folder", url);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
makeUriPersistableReadOnly(data, uri);
|
makeUriPersistableReadOnly(data, uri);
|
||||||
OnFileNew();
|
|
||||||
|
switch (requestCode) {
|
||||||
|
case INTENT_PICK_KML_FOLDER_FOR_NEW_FILE:
|
||||||
|
OnFileNew();
|
||||||
|
break;
|
||||||
|
case INTENT_PICK_KML_FOLDER_FOR_CHANGING:
|
||||||
|
OnViewScript();
|
||||||
|
break;
|
||||||
|
case INTENT_PICK_KML_FOLDER_FOR_SETTINGS:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class NativeLib {
|
||||||
public static native void onStackCopy();
|
public static native void onStackCopy();
|
||||||
public static native void onStackPaste();
|
public static native void onStackPaste();
|
||||||
public static native void onViewReset();
|
public static native void onViewReset();
|
||||||
public static native void onViewScript(String kmlFilename);
|
public static native int onViewScript(String kmlFilename);
|
||||||
public static native void onBackupSave();
|
public static native void onBackupSave();
|
||||||
public static native void onBackupRestore();
|
public static native void onBackupRestore();
|
||||||
public static native void onBackupDelete();
|
public static native void onBackupDelete();
|
||||||
|
|
|
@ -305,7 +305,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
startActivityForResult(intent, MainActivity.INTENT_PICK_KML_FOLDER);
|
startActivityForResult(intent, MainActivity.INTENT_PICK_KML_FOLDER_FOR_SETTINGS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -413,22 +413,28 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
if(resultCode == Activity.RESULT_OK) {
|
if(resultCode == Activity.RESULT_OK && data != null) {
|
||||||
if(requestCode == MainActivity.INTENT_PORT2LOAD) {
|
if(requestCode == MainActivity.INTENT_PORT2LOAD) {
|
||||||
Uri uri = data.getData();
|
Uri uri = data.getData();
|
||||||
//Log.d(TAG, "onActivityResult INTENT_PORT2LOAD " + uri.toString());
|
//Log.d(TAG, "onActivityResult INTENT_PORT2LOAD " + uri.toString());
|
||||||
String url = uri.toString();
|
String url = null;
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
if (uri != null) {
|
||||||
editor.putString("settings_port2load", url);
|
url = uri.toString();
|
||||||
editor.apply();
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
makeUriPersistable(data, uri);
|
editor.putString("settings_port2load", url);
|
||||||
} else if(requestCode == MainActivity.INTENT_PICK_KML_FOLDER) {
|
editor.apply();
|
||||||
|
makeUriPersistable(data, uri);
|
||||||
|
}
|
||||||
|
} else if(requestCode == MainActivity.INTENT_PICK_KML_FOLDER_FOR_SETTINGS) {
|
||||||
Uri uri = data.getData();
|
Uri uri = data.getData();
|
||||||
String url = uri.toString();
|
String url = null;
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
if (uri != null) {
|
||||||
editor.putString("settings_kml_folder", url);
|
url = uri.toString();
|
||||||
editor.apply();
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
makeUriPersistableReadOnly(data, uri);
|
editor.putString("settings_kml_folder", url);
|
||||||
|
editor.apply();
|
||||||
|
makeUriPersistableReadOnly(data, uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
Loading…
Reference in a new issue