mirror of
https://github.com/dgis/emu48android
synced 2025-01-17 18:11:37 +01:00
This commit is contained in:
parent
0250c5cfe2
commit
79f9977dcb
6 changed files with 209 additions and 95 deletions
|
@ -12,7 +12,7 @@ NOT WORKING YET
|
|||
- Debugger
|
||||
|
||||
TODO
|
||||
- Bug: custom KML/Save/ChangeKML/Close -> state not saved
|
||||
- Add sound switch settings
|
||||
- Improve the access to the menu
|
||||
- Change the logo following the template
|
||||
- Open Emu48 with a state file shared with it (Can not work)
|
||||
|
|
|
@ -22,6 +22,88 @@
|
|||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:scheme="content"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.e38"
|
||||
android:host="*"/>
|
||||
<data android:scheme="content"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.e39"
|
||||
android:host="*"/>
|
||||
<data android:scheme="content"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.e48"
|
||||
android:host="*"/>
|
||||
<data android:scheme="content"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.e49"
|
||||
android:host="*"/>
|
||||
|
||||
<data android:scheme="file"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.e38"
|
||||
android:host="*"/>
|
||||
<data android:scheme="file"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.e39"
|
||||
android:host="*"/>
|
||||
<data android:scheme="file"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.e48"
|
||||
android:host="*"/>
|
||||
<data android:scheme="file"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.e49"
|
||||
android:host="*"/>
|
||||
</intent-filter>
|
||||
<!--<intent-filter>-->
|
||||
<!--<action android:name="android.intent.action.VIEW" />-->
|
||||
<!--<category android:name="android.intent.category.DEFAULT" />-->
|
||||
<!--<category android:name="android.intent.category.BROWSABLE" />-->
|
||||
<!--<!–<data android:scheme="content" />–>-->
|
||||
<!--<!–<data android:mimeType="*/*" />–>-->
|
||||
<!--<!–<data android:pathPattern=".*\\.e48" />–>-->
|
||||
<!--<!–<data android:host="*" />–>-->
|
||||
<!---->
|
||||
<!--<data android:scheme="content"-->
|
||||
<!--android:mimeType="*/*"-->
|
||||
<!--android:pathPattern=".*\\.e38"-->
|
||||
<!--android:host="*"/>-->
|
||||
<!--<data android:scheme="content"-->
|
||||
<!--android:mimeType="*/*"-->
|
||||
<!--android:pathPattern=".*\\.e39"-->
|
||||
<!--android:host="*"/>-->
|
||||
<!--<data android:scheme="content"-->
|
||||
<!--android:mimeType="*/*"-->
|
||||
<!--android:pathPattern=".*\\.e48"-->
|
||||
<!--android:host="*"/>-->
|
||||
<!--<data android:scheme="content"-->
|
||||
<!--android:mimeType="*/*"-->
|
||||
<!--android:pathPattern=".*\\.e49"-->
|
||||
<!--android:host="*"/>-->
|
||||
|
||||
<!--<data android:scheme="file"-->
|
||||
<!--android:mimeType="*/*"-->
|
||||
<!--android:pathPattern=".*\\.e38"-->
|
||||
<!--android:host="*"/>-->
|
||||
<!--<data android:scheme="file"-->
|
||||
<!--android:mimeType="*/*"-->
|
||||
<!--android:pathPattern=".*\\.e39"-->
|
||||
<!--android:host="*"/>-->
|
||||
<!--<data android:scheme="file"-->
|
||||
<!--android:mimeType="*/*"-->
|
||||
<!--android:pathPattern=".*\\.e48"-->
|
||||
<!--android:host="*"/>-->
|
||||
<!--<data android:scheme="file"-->
|
||||
<!--android:mimeType="*/*"-->
|
||||
<!--android:pathPattern=".*\\.e49"-->
|
||||
<!--android:host="*"/>-->
|
||||
<!--</intent-filter>-->
|
||||
<!--<intent-filter>-->
|
||||
<!--<action android:name="android.intent.action.VIEW" />-->
|
||||
<!--<category android:name="android.intent.category.DEFAULT" />-->
|
||||
|
|
|
@ -122,6 +122,10 @@ HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
|||
}
|
||||
_tcscpy(szRomDirectory, szEmuDirectory);
|
||||
SetCurrentDirectory(szEmuDirectory);
|
||||
} else {
|
||||
_tcscpy(szEmuDirectory, "assets/calculators/");
|
||||
_tcscpy(szRomDirectory, "assets/calculators/");
|
||||
SetCurrentDirectory(szEmuDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,18 +3,21 @@ package org.emulator.forty.eight;
|
|||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.AssetManager;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -160,31 +163,41 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
updateNavigationDrawerItems();
|
||||
|
||||
|
||||
|
||||
|
||||
android.os.Debug.waitForDebugger();
|
||||
|
||||
|
||||
String documentToOpenUrl = sharedPreferences.getString("lastDocument", "");
|
||||
// Uri documentToOpenUri = null;
|
||||
// boolean isFileAndNeedPermission = false;
|
||||
// Intent intent = getIntent();
|
||||
// if(intent != null) {
|
||||
// String action = intent.getAction();
|
||||
// if(action != null) {
|
||||
// if (action.equals(Intent.ACTION_VIEW)) {
|
||||
// documentToOpenUri = intent.getData();
|
||||
// if (documentToOpenUri != null) {
|
||||
// String scheme = documentToOpenUri.getScheme();
|
||||
// if(scheme != null && scheme.compareTo("file") == 0) {
|
||||
Uri documentToOpenUri = null;
|
||||
boolean isFileAndNeedPermission = false;
|
||||
Intent intent = getIntent();
|
||||
if(intent != null) {
|
||||
String action = intent.getAction();
|
||||
if(action != null) {
|
||||
if (action.equals(Intent.ACTION_VIEW)) {
|
||||
documentToOpenUri = intent.getData();
|
||||
if (documentToOpenUri != null) {
|
||||
String scheme = documentToOpenUri.getScheme();
|
||||
if(scheme != null && scheme.compareTo("file") == 0) {
|
||||
// documentToOpenUrl = documentToOpenUri.getPath();
|
||||
// isFileAndNeedPermission = true;
|
||||
// } else
|
||||
// documentToOpenUrl = documentToOpenUri.toString();
|
||||
// }
|
||||
// } else if (action.equals(Intent.ACTION_SEND)) {
|
||||
// documentToOpenUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
// if (documentToOpenUri != null) {
|
||||
// documentToOpenUrl = documentToOpenUri.toString();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
File file = new File(documentToOpenUri.toString());
|
||||
//Uri uri = FileProvider.getUriForFile(this, "androidx.core.content.FileProvider", file /* file whose Uri is required */);
|
||||
Uri uri = getImageContentUri(this, file);
|
||||
documentToOpenUrl = uri.getPath();
|
||||
} else
|
||||
documentToOpenUrl = documentToOpenUri.toString();
|
||||
}
|
||||
} else if (action.equals(Intent.ACTION_SEND)) {
|
||||
documentToOpenUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (documentToOpenUri != null) {
|
||||
documentToOpenUrl = documentToOpenUri.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//https://developer.android.com/guide/topics/providers/document-provider#permissions
|
||||
if(documentToOpenUrl != null && documentToOpenUrl.length() > 0)
|
||||
|
@ -196,8 +209,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
// } else {
|
||||
if(onFileOpen(documentToOpenUrl) != 0) {
|
||||
saveLastDocument(documentToOpenUrl);
|
||||
// if(intent != null && documentToOpenUri != null && !isFileAndNeedPermission)
|
||||
// makeUriPersistable(intent, documentToOpenUri);
|
||||
if(intent != null && documentToOpenUri != null && !isFileAndNeedPermission)
|
||||
makeUriPersistable(intent, documentToOpenUri);
|
||||
}
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
|
@ -207,6 +220,31 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
drawer.openDrawer(GravityCompat.START);
|
||||
}
|
||||
|
||||
public static Uri getImageContentUri(Context context, File imageFile) {
|
||||
String filePath = imageFile.getAbsolutePath();
|
||||
String filePath = imageFile.getAbsolutePath();
|
||||
Cursor cursor = context.getContentResolver().query(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
new String[] { MediaStore.Images.Media._ID },
|
||||
MediaStore.Images.Media.DATA + "=? ",
|
||||
new String[] { filePath }, null);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
int id = cursor.getInt(cursor
|
||||
.getColumnIndex(MediaStore.MediaColumns._ID));
|
||||
Uri baseUri = Uri.parse("content://media/external/images/media");
|
||||
return Uri.withAppendedPath(baseUri, "" + id);
|
||||
} else {
|
||||
if (imageFile.exists()) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MediaStore.Images.Media.DATA, filePath);
|
||||
return context.getContentResolver().insert(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}}
|
||||
|
||||
private void updateMRU() {
|
||||
Menu menu = navigationView.getMenu();
|
||||
MenuItem recentsMenuItem = menu.findItem(R.id.nav_item_recents);
|
||||
|
|
|
@ -270,45 +270,45 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
|
||||
// KML settings
|
||||
|
||||
final Preference preferenceKMLDefault = findPreference("settings_kml_default");
|
||||
final Preference preferenceKMLFolder = findPreference("settings_kml_folder");
|
||||
|
||||
Preference.OnPreferenceChangeListener onPreferenceChangeListenerKMLDefault = new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
Boolean booleanValue = (Boolean)value;
|
||||
String stringValue = value.toString();
|
||||
preference.setSummary(stringValue);
|
||||
preferenceKMLFolder.setEnabled(booleanValue);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
preferenceKMLDefault.setOnPreferenceChangeListener(onPreferenceChangeListenerKMLDefault);
|
||||
onPreferenceChangeListenerKMLDefault.onPreferenceChange(preferenceKMLDefault, sharedPreferences.getBoolean(preferenceKMLDefault.getKey(), true));
|
||||
|
||||
Preference.OnPreferenceChangeListener onPreferenceChangeListenerKMLFolder = new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
String stringValue = value.toString();
|
||||
String displayName = stringValue;
|
||||
try {
|
||||
displayName = Utils.getFileName(getActivity(), stringValue);
|
||||
} catch(Exception e) {
|
||||
}
|
||||
preference.setSummary(displayName);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
preferenceKMLFolder.setOnPreferenceChangeListener(onPreferenceChangeListenerKMLFolder);
|
||||
onPreferenceChangeListenerKMLFolder.onPreferenceChange(preferenceKMLFolder, sharedPreferences.getString(preferenceKMLFolder.getKey(), ""));
|
||||
preferenceKMLFolder.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
startActivityForResult(intent, MainActivity.INTENT_PICK_KML_FOLDER_FOR_SETTINGS);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// final Preference preferenceKMLDefault = findPreference("settings_kml_default");
|
||||
// final Preference preferenceKMLFolder = findPreference("settings_kml_folder");
|
||||
//
|
||||
// Preference.OnPreferenceChangeListener onPreferenceChangeListenerKMLDefault = new Preference.OnPreferenceChangeListener() {
|
||||
// @Override
|
||||
// public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
// Boolean booleanValue = (Boolean)value;
|
||||
// String stringValue = value.toString();
|
||||
// preference.setSummary(stringValue);
|
||||
// preferenceKMLFolder.setEnabled(booleanValue);
|
||||
// return true;
|
||||
// }
|
||||
// };
|
||||
// preferenceKMLDefault.setOnPreferenceChangeListener(onPreferenceChangeListenerKMLDefault);
|
||||
// onPreferenceChangeListenerKMLDefault.onPreferenceChange(preferenceKMLDefault, sharedPreferences.getBoolean(preferenceKMLDefault.getKey(), true));
|
||||
//
|
||||
// Preference.OnPreferenceChangeListener onPreferenceChangeListenerKMLFolder = new Preference.OnPreferenceChangeListener() {
|
||||
// @Override
|
||||
// public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
// String stringValue = value.toString();
|
||||
// String displayName = stringValue;
|
||||
// try {
|
||||
// displayName = Utils.getFileName(getActivity(), stringValue);
|
||||
// } catch(Exception e) {
|
||||
// }
|
||||
// preference.setSummary(displayName);
|
||||
// return true;
|
||||
// }
|
||||
// };
|
||||
// preferenceKMLFolder.setOnPreferenceChangeListener(onPreferenceChangeListenerKMLFolder);
|
||||
// onPreferenceChangeListenerKMLFolder.onPreferenceChange(preferenceKMLFolder, sharedPreferences.getString(preferenceKMLFolder.getKey(), ""));
|
||||
// preferenceKMLFolder.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
// @Override
|
||||
// public boolean onPreferenceClick(Preference preference) {
|
||||
// Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
// startActivityForResult(intent, MainActivity.INTENT_PICK_KML_FOLDER_FOR_SETTINGS);
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
|
||||
// Ports 1 & 2 settings
|
||||
|
||||
|
@ -425,16 +425,16 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
editor.apply();
|
||||
makeUriPersistable(data, uri);
|
||||
}
|
||||
} else if(requestCode == MainActivity.INTENT_PICK_KML_FOLDER_FOR_SETTINGS) {
|
||||
Uri uri = data.getData();
|
||||
String url = null;
|
||||
if (uri != null) {
|
||||
url = uri.toString();
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("settings_kml_folder", url);
|
||||
editor.apply();
|
||||
makeUriPersistableReadOnly(data, uri);
|
||||
}
|
||||
// } else if(requestCode == MainActivity.INTENT_PICK_KML_FOLDER_FOR_SETTINGS) {
|
||||
// Uri uri = data.getData();
|
||||
// String url = null;
|
||||
// if (uri != null) {
|
||||
// url = uri.toString();
|
||||
// SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
// editor.putString("settings_kml_folder", url);
|
||||
// editor.apply();
|
||||
// makeUriPersistableReadOnly(data, uri);
|
||||
// }
|
||||
}
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
android:key="settings_autosave"
|
||||
android:title="Automatically Save Files"
|
||||
android:defaultValue="true" />
|
||||
<!--<SwitchPreference-->
|
||||
<!--android:key="settings_autosaveonexit"-->
|
||||
<!--android:title="Automatically Save Files On Exit"-->
|
||||
<!--android:defaultValue="true" />-->
|
||||
<SwitchPreference
|
||||
android:key="settings_objectloadwarning"
|
||||
android:title="Show Load Object Warning"
|
||||
|
@ -36,25 +32,19 @@
|
|||
android:key="settings_fill_screen"
|
||||
android:title="Fill screen"
|
||||
android:defaultValue="false" />
|
||||
<Preference
|
||||
android:key="settings_kml_folder"
|
||||
android:title="Custom KML Folder"
|
||||
android:summary=""
|
||||
/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="General">
|
||||
<SwitchPreference
|
||||
android:key="settings_kml_default"
|
||||
android:title="Default Internal KML Folder"
|
||||
android:defaultValue="true" />
|
||||
<Preference
|
||||
android:key="settings_kml_folder"
|
||||
android:title="Custom KML Folder"
|
||||
android:summary=""
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
<!--<PreferenceCategory android:title="General">-->
|
||||
<!--<SwitchPreference-->
|
||||
<!--android:key="settings_kml_default"-->
|
||||
<!--android:title="Default Internal KML Folder"-->
|
||||
<!--android:defaultValue="true" />-->
|
||||
<!--<Preference-->
|
||||
<!--android:key="settings_kml_folder"-->
|
||||
<!--android:title="Custom KML Folder"-->
|
||||
<!--android:summary=""-->
|
||||
<!--/>-->
|
||||
<!--</PreferenceCategory>-->
|
||||
|
||||
<!--<PreferenceCategory app:title="Style">
|
||||
"Show Title",IDC_SHOWTITLE
|
||||
|
|
Loading…
Reference in a new issue