Cleanup source code.

This commit is contained in:
dgis 2019-02-21 21:44:08 +00:00
parent d552bd0301
commit 9709c873e3
9 changed files with 119 additions and 2919 deletions

File diff suppressed because it is too large Load diff

View file

@ -352,10 +352,6 @@ JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_stop(JNIEnv *env,
}
//JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_resize(JNIEnv *env, jobject thisz, jint width, jint height) {
//
//}
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_draw(JNIEnv *env, jobject thisz) {
draw();
}
@ -381,11 +377,6 @@ JNIEXPORT jstring JNICALL Java_org_emulator_forty_eight_NativeLib_getCurrentFile
jstring result = (*env)->NewStringUTF(env, szCurrentFilename);
return result;
}
//JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_setCurrentFilename(JNIEnv *env, jobject thisz, jstring newFilename) {
// const char *newFilenameUTF8 = (*env)->GetStringUTFChars(env, newFilename , NULL) ;
// _tcscpy(szBufferFilename, newFilenameUTF8);
// (*env)->ReleaseStringUTFChars(env, newFilename, newFilenameUTF8);
//}
JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_getCurrentModel(JNIEnv *env, jobject thisz) {
return cCurrentRomType;
@ -419,7 +410,6 @@ JNIEXPORT jboolean JNICALL Java_org_emulator_forty_eight_NativeLib_getSoundEnabl
JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_onFileNew(JNIEnv *env, jobject thisz, jstring kmlFilename) {
//OnFileNew();
if (bDocumentAvail)
{
SwitchToState(SM_INVALID);
@ -433,14 +423,6 @@ JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_onFileNew(JNIEnv
_tcscpy(szChosenCurrentKml, filenameUTF8);
(*env)->ReleaseStringUTFChars(env, kmlFilename, filenameUTF8);
// TCHAR * urlContentSchemeFound = _tcsstr(szChosenCurrentKml, _T("content://"));
// if(urlContentSchemeFound) {
// _tcscpy(szEmuDirectory, szChosenCurrentKml);
// TCHAR * filename = _tcsrchr(szChosenCurrentKml, _T('/'));
// if(filename) {
// *filename = _T('\0');
// }
// _tcscpy(szRomDirectory, szEmuDirectory);
TCHAR * fileScheme = _T("document:");
TCHAR * urlSchemeFound = _tcsstr(szChosenCurrentKml, fileScheme);
if(urlSchemeFound) {
@ -469,7 +451,6 @@ JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_onFileNew(JNIEnv
return result;
}
JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_onFileOpen(JNIEnv *env, jobject thisz, jstring stateFilename) {
//OnFileOpen();
if (bDocumentAvail)
{
SwitchToState(SM_INVALID);
@ -496,7 +477,6 @@ JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_onFileOpen(JNIEnv
}
JNIEXPORT jint JNICALL Java_org_emulator_forty_eight_NativeLib_onFileSave(JNIEnv *env, jobject thisz) {
// szBufferFilename must be set before calling that!!!
//OnFileSave();
BOOL result = FALSE;
if (bDocumentAvail)
{
@ -669,78 +649,6 @@ JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onViewCopy(JNIEnv
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
}
// void * pixelsSource = hBitmap->bitmapBits;
//
// int sourceWidth = hBitmap->bitmapInfoHeader->biWidth;
// int sourceHeight = abs(hBitmap->bitmapInfoHeader->biHeight);
// int destinationWidth = bitmapScreenInfo.width;
// int destinationHeight = bitmapScreenInfo.height;
//
// //https://softwareengineering.stackexchange.com/questions/148123/what-is-the-algorithm-to-copy-a-region-of-one-bitmap-into-a-region-in-another
// float src_dx = (float)wSrc / (float)wDest;
// float src_dy = (float)hSrc / (float)hDest;
// float src_maxx = xSrc + wSrc;
// float src_maxy = ySrc + hSrc;
// float dst_maxx = xDest + wDest;
// float dst_maxy = yDest + hDest;
// float src_cury = ySrc;
//
// int sourceBytes = (hBitmap->bitmapInfoHeader->biBitCount >> 3);
// float sourceStride = sourceWidth * sourceBytes;
// sourceStride = (float)(4 * ((sourceWidth * hBitmap->bitmapInfoHeader->biBitCount + 31) / 32));
// float destinationStride = bitmapScreenInfo.stride; // Destination always 4 bytes RGBA
// //LOGD("StretchBlt(%08x, x:%d, y:%d, w:%d, h:%d, %08x, x:%d, y:%d, w:%d, h:%d) -> sourceBytes: %d", hdcDest->hdcCompatible, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, sourceBytes);
//
// PALETTEENTRY * palPalEntry = hdcSrc->selectedPalette && hdcSrc->selectedPalette->paletteLog && hdcSrc->selectedPalette->paletteLog->palPalEntry ?
// hdcSrc->selectedPalette->paletteLog->palPalEntry : NULL;
//
// for (float y = yDest; y < dst_maxy; y++)
// {
// float src_curx = xSrc;
// for (float x = xDest; x < dst_maxx; x++)
// {
// // Point sampling - you can also impl as bilinear or other
// //dst.bmp[x,y] = src.bmp[src_curx, src_cury];
//
// BYTE * destinationPixel = pixelsDestination + (int)(4.0 * x + destinationStride * y);
// BYTE * sourcePixel = pixelsSource + (int)(sourceBytes * (int)src_curx) + (int)(sourceStride * (int)src_cury);
//
// // -> ARGB_8888
// switch (sourceBytes) {
// case 1:
// if(palPalEntry) {
// BYTE colorIndex = sourcePixel[0];
// destinationPixel[0] = palPalEntry[colorIndex].peBlue;
// destinationPixel[1] = palPalEntry[colorIndex].peGreen;
// destinationPixel[2] = palPalEntry[colorIndex].peRed;
// destinationPixel[3] = 255;
// } else {
// destinationPixel[0] = sourcePixel[0];
// destinationPixel[1] = sourcePixel[0];
// destinationPixel[2] = sourcePixel[0];
// destinationPixel[3] = 255;
// }
// break;
// case 3:
// destinationPixel[0] = sourcePixel[2];
// destinationPixel[1] = sourcePixel[1];
// destinationPixel[2] = sourcePixel[0];
// destinationPixel[3] = 255;
// break;
// case 4:
// memcpy(destinationPixel, sourcePixel, sourceBytes);
// break;
// default:
// break;
// }
//
// src_curx += src_dx;
// }
//
// src_cury += src_dy;
// }
// DIB bitmap
#define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
#define PALVERSION 0x300
@ -821,41 +729,6 @@ JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onViewCopy(JNIEnv
}
// // memory allocation for clipboard data
// if ((hClipObj = GlobalAlloc(GMEM_MOVEABLE, dwLen)) != NULL)
// {
// lpbi = (LPBITMAPINFOHEADER ) GlobalLock(hClipObj);
// // initialize BITMAPINFOHEADER
// lpbi->biSize = sizeof(BITMAPINFOHEADER);
// lpbi->biWidth = bm.bmWidth;
// lpbi->biHeight = bm.bmHeight;
// lpbi->biPlanes = 1;
// lpbi->biBitCount = wBits;
// lpbi->biCompression = BI_RGB;
// lpbi->biSizeImage = dwSizeImage;
// lpbi->biXPelsPerMeter = 0;
// lpbi->biYPelsPerMeter = 0;
// lpbi->biClrUsed = 0;
// lpbi->biClrImportant = 0;
// // get bitmap color table and bitmap data
// GetDIBits(hBmpDC, hBmp, 0, lpbi->biHeight, (LPBYTE)lpbi + dwLen - dwSizeImage,
// (LPBITMAPINFO)lpbi, DIB_RGB_COLORS);
// GlobalUnlock(hClipObj);
// SetClipboardData(CF_DIB, hClipObj);
//
// // get number of entries in the logical palette
// GetObject(hPalette,sizeof(WORD),&wBits);
//
// // memory allocation for temporary palette data
// if ((ppal = (PLOGPALETTE) calloc(sizeof(LOGPALETTE) + wBits * sizeof(PALETTEENTRY),1)) != NULL)
// {
// ppal->palVersion = PALVERSION;
// ppal->palNumEntries = wBits;
// GetPaletteEntries(hPalette, 0, wBits, ppal->palPalEntry);
// SetClipboardData(CF_PALETTE, CreatePalette(ppal));
// free(ppal);
// }
// }
DeleteDC(hBmpDC);
DeleteObject(hBmp);
#undef WIDTHBYTES
@ -875,7 +748,6 @@ JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onStackPaste(JNIE
}
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onViewReset(JNIEnv *env, jobject thisz) {
//OnViewReset();
if (nState != SM_RUN)
return;
SwitchToState(SM_SLEEP);
@ -969,15 +841,21 @@ JNIEXPORT int JNICALL Java_org_emulator_forty_eight_NativeLib_onViewScript(JNIEn
}
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onBackupSave(JNIEnv *env, jobject thisz) {
OnBackupSave();
UINT nOldState;
if (pbyRom == NULL) return;
nOldState = SwitchToState(SM_INVALID);
SaveBackup();
SwitchToState(nOldState);
}
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onBackupRestore(JNIEnv *env, jobject thisz) {
OnBackupRestore();
SwitchToState(SM_INVALID);
RestoreBackup();
if (pbyRom) SwitchToState(SM_RUN);
}
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onBackupDelete(JNIEnv *env, jobject thisz) {
OnBackupDelete();
ResetBackup();
}
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_setConfiguration(JNIEnv *env, jobject thisz, jstring key, jint isDynamic, jint intValue1, jint intValue2, jstring stringValue) {

View file

@ -60,6 +60,13 @@ import androidx.drawerlayout.widget.DrawerLayout;
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "MainActivity";
public static MainActivity mainActivity;
private SharedPreferences sharedPreferences;
private NavigationView navigationView;
private DrawerLayout drawer;
private MainScreenView mainScreenView;
public static final int INTENT_GETOPENFILENAME = 1;
public static final int INTENT_GETSAVEFILENAME = 2;
public static final int INTENT_OBJECT_LOAD = 3;
@ -69,24 +76,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
public static final int INTENT_PICK_KML_FOLDER_FOR_NEW_FILE = 7;
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;
private static final String TAG = "MainActivity";
private SharedPreferences sharedPreferences;
private NavigationView navigationView;
private DrawerLayout drawer;
private MainScreenView mainScreenView;
private final static int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 2;
private String kmlMimeType = "application/vnd.google-earth.kml+xml";
private boolean kmlFolderUseDefault = true;
private String kmlFolderURL = "";
private boolean kmFolderChange = true;
private int MRU_ID_START = 10000;
private int MAX_MRU = 5;
private LinkedHashMap<String, String> mruLinkedHashMap = new LinkedHashMap<String, String>(5, 1.0f, true) {
@ -121,21 +116,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
ViewGroup mainScreenContainer = findViewById(R.id.main_screen_container);
mainScreenView = new MainScreenView(this);
// mainScreenView.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View view, MotionEvent motionEvent) {
// if (motionEvent.getAction() == MotionEvent.ACTION_DOWN){
// if(motionEvent.getY() < 0.3f * mainScreenView.getHeight()) {
// if(toolbar.getVisibility() == View.GONE)
// toolbar.setVisibility(View.VISIBLE);
// else
// toolbar.setVisibility(View.GONE);
// return true;
// }
// }
// return false;
// }
// });
toolbar.setVisibility(View.GONE);
mainScreenContainer.addView(mainScreenView, 0);
mainScreenView.setFillScreen(sharedPreferences.getBoolean("settings_fill_screen", false));
@ -167,7 +148,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
String documentToOpenUrl = sharedPreferences.getString("lastDocument", "");
Uri documentToOpenUri = null;
boolean isFileAndNeedPermission = false;
Intent intent = getIntent();
if(intent != null) {
String action = intent.getAction();
@ -177,10 +157,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if (documentToOpenUri != null) {
String scheme = documentToOpenUri.getScheme();
if(scheme != null && scheme.compareTo("file") == 0) {
// isFileAndNeedPermission = true;
// File file = new File(documentToOpenUri.toString());
// //Uri uri = FileProvider.getUriForFile(this, "androidx.core.content.FileProvider", file /* file whose Uri is required */);
// documentToOpenUrl = uri.getPath();
documentToOpenUrl = null;
} else
documentToOpenUrl = documentToOpenUri.toString();
@ -194,20 +170,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
//https://developer.android.com/guide/topics/providers/document-provider#permissions
if(documentToOpenUrl != null && documentToOpenUrl.length() > 0)
try {
// if(isFileAndNeedPermission
// && ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// ActivityCompat.requestPermissions(this, new String[]{ Manifest.permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
// //return;
// } else {
if(onFileOpen(documentToOpenUrl) != 0) {
saveLastDocument(documentToOpenUrl);
if(intent != null && documentToOpenUri != null && !isFileAndNeedPermission)
if(intent != null && documentToOpenUri != null)
makeUriPersistable(intent, documentToOpenUri);
}
// }
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
@ -226,7 +195,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
if (recentsSubMenu != null) {
Set<String> mruLinkedHashMapKeySet = mruLinkedHashMap.keySet();
String[] mrus = mruLinkedHashMapKeySet.toArray(new String[mruLinkedHashMapKeySet.size()]);
String[] mrus = mruLinkedHashMapKeySet.toArray(new String[0]);
for (int i = mrus.length - 1; i >= 0; i--) {
String displayName = getFilenameFromURL(mrus[i]);
recentsSubMenu.add(Menu.NONE, MRU_ID_START + i, Menu.NONE, displayName);
@ -252,7 +221,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
String currentFilename = NativeLib.getCurrentFilename();
if (currentFilename != null && currentFilename.length() > 0) {
if(NativeLib.onFileSave() == 1)
showAlert("State saved");
showAlert(getString(R.string.message_state_saved));
}
}
@ -276,35 +245,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
updateFromPreferences(key, true);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: {
// If request is cancelled, the result arrays are empty.
// if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//
// } else {
// //Toast.makeText(this, R.string.toast_access_location_denied, Toast.LENGTH_SHORT).show();
// }
String lastDocumentUrl = sharedPreferences.getString("lastDocument", "");
if(lastDocumentUrl.length() > 0) {
if(onFileOpen(lastDocumentUrl) != 0)
try {
makeUriPersistable(getIntent(), Uri.parse(lastDocumentUrl));
} catch (Exception e) {
// Do nothing
}
}
// return;
}
// default:
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
@ -441,6 +384,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
e.printStackTrace();
}
kmlScripts.clear();
if(calculatorsAssetFilenames != null) {
Pattern patternGlobalTitle = Pattern.compile("\\s*Title\\s+\"(.*)\"");
Pattern patternGlobalModel = Pattern.compile("\\s*Model\\s+\"(.*)\"");
Matcher m;
@ -496,25 +440,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
}
}
} else {
Uri kmlFolderUri = Uri.parse(kmlFolderURL);
List<String> calculatorsAssetFilenames = new LinkedList<>();
// Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(kmlFolderUri, DocumentsContract.getTreeDocumentId(kmlFolderUri));
// Cursor cursor = getContentResolver().query(childrenUri, new String[]{DocumentsContract.Document.COLUMN_DOCUMENT_ID, DocumentsContract.Document.COLUMN_DISPLAY_NAME, DocumentsContract.Document.COLUMN_MIME_TYPE}, null, null, null);
// try {
// while (cursor.moveToNext()) {
// final String url = cursor.getString(0);
// final String name = cursor.getString(1);
// final String mime = cursor.getString(2);
// Log.d(TAG, "url: " + url + ", name: " + name + ", mime: " + mime);
// if(kmlMimeType.equals(mime)) {
// calculatorsAssetFilenames.add(url);
// }
// }
// } finally {
// cursor.close();
// }
DocumentFile kmlFolderDocumentFile = DocumentFile.fromTreeUri(this, kmlFolderUri);
for (DocumentFile file : kmlFolderDocumentFile.listFiles()) {
final String url = file.getUri().toString();
@ -608,7 +538,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if (which == DialogInterface.BUTTON_POSITIVE) {
if (hasFilename) {
if(NativeLib.onFileSave() == 1)
showAlert("State saved");
showAlert(getString(R.string.message_state_saved));
if (continueCallback != null)
continueCallback.run();
} else {
@ -627,9 +557,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
onClickListener.onClick(null, DialogInterface.BUTTON_POSITIVE);
} else {
new AlertDialog.Builder(this)
.setMessage("Do you want to save changes?\n(BACK to cancel)")
.setPositiveButton("Yes", onClickListener)
.setNegativeButton("No", onClickListener)
.setMessage(getString(R.string.message_do_you_want_to_save))
.setPositiveButton(getString(R.string.message_yes), onClickListener)
.setNegativeButton(getString(R.string.message_no), onClickListener)
.show();
}
} else if(continueCallback != null)
@ -643,48 +573,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
ensureDocumentSaved(new Runnable() {
@Override
public void run() {
// extractKMLScripts();
//
// final ArrayList<KMLScriptItem> kmlScriptsForCurrentModel = kmlScripts;
//
// final int lastIndex = kmlScriptsForCurrentModel.size();
// final String[] kmlScriptTitles = new String[lastIndex + 2];
// for (int i = 0; i < kmlScriptsForCurrentModel.size(); i++)
// 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)
// .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);
// 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);
}
});
@ -762,13 +650,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
// //Intent.setType("application/*|text/*");
// String[] mimeTypes = {
// "text/plain",
// "application/pdf",
// "application/zip"
// };
// intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
intent.putExtra(Intent.EXTRA_TITLE, "emu48-object.hp");
startActivityForResult(intent, INTENT_OBJECT_LOAD);
}
@ -783,10 +664,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
};
new AlertDialog.Builder(this)
.setMessage("Warning: Trying to load an object while the emulator is busy\n" +
"will certainly result in a memory lost. Before loading an object\n" +
"you should be sure that the calculator is in idle state.\n" +
"Do you want to see this warning next time you try to load an object?")
.setMessage(getString(R.string.message_object_load))
.setPositiveButton(android.R.string.yes, onClickListener)
.setNegativeButton(android.R.string.no, onClickListener)
.show();
@ -819,10 +697,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType(mimeType);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_SUBJECT, "Emu48 screenshot");
intent.putExtra(Intent.EXTRA_SUBJECT, R.string.message_screenshot);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this,this.getPackageName() + ".provider", imageFile));
startActivity(Intent.createChooser(intent, "Share Emu48 screenshot"));
startActivity(Intent.createChooser(intent, getString(R.string.message_share_screenshot)));
} catch (Exception e) {
e.printStackTrace();
}
@ -842,9 +720,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
};
new AlertDialog.Builder(this)
.setMessage("Are you sure you want to press the Reset Button?")
.setPositiveButton("Yes", onClickListener)
.setNegativeButton("No", onClickListener)
.setMessage(getString(R.string.message_press_reset))
.setPositiveButton(getString(R.string.message_yes), onClickListener)
.setNegativeButton(getString(R.string.message_no), onClickListener)
.show();
}
private void OnBackupSave() {
@ -861,8 +739,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
private void OnViewScript() {
if (NativeLib.getState() != 0 /*SM_RUN*/) {
showAlert("You cannot change the KML script when Emu48 is not running.\n"
+ "Use the File,New menu item to create a new calculator.");
showAlert(getString(R.string.message_change_kml));
return;
}
@ -952,7 +829,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
case INTENT_GETSAVEFILENAME: {
Log.d(TAG, "onActivityResult INTENT_GETSAVEFILENAME " + url);
if (NativeLib.onFileSaveAs(url) != 0) {
showAlert("State saved");
showAlert(getString(R.string.message_state_saved));
saveLastDocument(url);
makeUriPersistable(data, uri);
displayFilename(url);
@ -973,14 +850,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
case INTENT_SETTINGS:
break;
// case INTENT_PICK_KML_FILE: {
// Log.d(TAG, "onActivityResult INTENT_PICK_KML_FILE " + url);
//// String filePath = Utils.getFilePath(this, url);
//// newFileFromKML(filePath);
// DocumentFile documentFile = DocumentFile.fromSingleUri(this, uri);
// DocumentFile parentDocumentFile = documentFile.getParentFile();
// break;
// }
case INTENT_PICK_KML_FOLDER_FOR_NEW_FILE:
case INTENT_PICK_KML_FOLDER_FOR_CHANGING:
case INTENT_PICK_KML_FOLDER_FOR_SETTINGS: {
@ -1022,12 +891,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
private void makeUriPersistable(Intent data, Uri uri) {
//grantUriPermission(getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
getContentResolver().takePersistableUriPermission(uri, takeFlags);
}
private void makeUriPersistableReadOnly(Intent data, Uri uri) {
//grantUriPermission(getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
getContentResolver().takePersistableUriPermission(uri, takeFlags);
}
@ -1081,7 +948,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private void showKMLLogForce() {
String kmlLog = NativeLib.getKMLLog();
new AlertDialog.Builder(this)
.setTitle("KML Script Compilation Result")
.setTitle(getString(R.string.message_kml_script_compilation_result))
.setMessage(kmlLog)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@ -1145,7 +1012,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
void showAlert(String text) {
Toast toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
View view = toast.getView();
//View view = toast.getView();
//view.setBackgroundColor(0x80000000);
toast.show();
}

View file

@ -52,16 +52,16 @@ public class MainScreenView extends SurfaceView {
vkmap.put(KeyEvent.KEYCODE_DPAD_UP, 0x26); // VK_UP
vkmap.put(KeyEvent.KEYCODE_DPAD_RIGHT, 0x27); // VK_RIGHT
vkmap.put(KeyEvent.KEYCODE_DPAD_DOWN, 0x28); // VK_DOWN
vkmap.put(KeyEvent.KEYCODE_0, 0x30); // 0
vkmap.put(KeyEvent.KEYCODE_1, 0x31); // 1
vkmap.put(KeyEvent.KEYCODE_2, 0x32); // 2
vkmap.put(KeyEvent.KEYCODE_3, 0x33); // 3
vkmap.put(KeyEvent.KEYCODE_4, 0x34); // 4
vkmap.put(KeyEvent.KEYCODE_5, 0x35); // 5
vkmap.put(KeyEvent.KEYCODE_6, 0x36); // 6
vkmap.put(KeyEvent.KEYCODE_7, 0x37); // 7
vkmap.put(KeyEvent.KEYCODE_8, 0x38); // 8
vkmap.put(KeyEvent.KEYCODE_9, 0x39); // 9
// vkmap.put(KeyEvent.KEYCODE_0, 0x30); // 0
// vkmap.put(KeyEvent.KEYCODE_1, 0x31); // 1
// vkmap.put(KeyEvent.KEYCODE_2, 0x32); // 2
// vkmap.put(KeyEvent.KEYCODE_3, 0x33); // 3
// vkmap.put(KeyEvent.KEYCODE_4, 0x34); // 4
// vkmap.put(KeyEvent.KEYCODE_5, 0x35); // 5
// vkmap.put(KeyEvent.KEYCODE_6, 0x36); // 6
// vkmap.put(KeyEvent.KEYCODE_7, 0x37); // 7
// vkmap.put(KeyEvent.KEYCODE_8, 0x38); // 8
// vkmap.put(KeyEvent.KEYCODE_9, 0x39); // 9
vkmap.put(KeyEvent.KEYCODE_A, 0x41); // A
vkmap.put(KeyEvent.KEYCODE_B, 0x42); // B
vkmap.put(KeyEvent.KEYCODE_C, 0x43); // C
@ -140,46 +140,23 @@ public class MainScreenView extends SurfaceView {
//Log.d(TAG, "ACTION_DOWN/ACTION_POINTER_DOWN count: " + touchCount + ", actionIndex: " + actionIndex);
NativeLib.buttonDown((int)((event.getX(actionIndex) - screenOffsetX) / screenScaleX), (int)((event.getY(actionIndex) - screenOffsetY) / screenScaleY));
break;
// case MotionEvent.ACTION_MOVE:
// break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
//Log.d(TAG, "ACTION_UP/ACTION_POINTER_UP count: " + touchCount + ", actionIndex: " + actionIndex);
NativeLib.buttonUp((int)((event.getX(actionIndex) - screenOffsetX) / screenScaleX), (int)((event.getY(actionIndex) - screenOffsetY) / screenScaleY));
break;
// case MotionEvent.ACTION_CANCEL:
// break;
// case MotionEvent.ACTION_OUTSIDE:
// break;
default:
break;
}
return true;
}
// @Override
// public boolean onGenericMotionEvent(MotionEvent event) {
// if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
// switch (event.getAction()) {
// case MotionEvent.ACTION_SCROLL:
// float wheelDelta = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
// if(wheelDelta > 0f)
// scaleByStep(mScaleStep, event.getX(), event.getY());
// else if(wheelDelta < 0f)
// scaleByStep(1.0f / mScaleStep, event.getX(), event.getY());
//
// return true;
// }
// }
// return super.onGenericMotionEvent(event);
// }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0) {
Integer windowsKeycode = vkmap.get(keyCode);
if (windowsKeycode != null)
NativeLib.keyDown(windowsKeycode.intValue());
NativeLib.keyDown(windowsKeycode);
else
Log.e(TAG, String.format("Unknown keyCode: %d", keyCode));
}
@ -191,7 +168,7 @@ public class MainScreenView extends SurfaceView {
if((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) == 0) {
Integer windowsKeycode = vkmap.get(keyCode);
if (windowsKeycode != null)
NativeLib.keyUp(windowsKeycode.intValue());
NativeLib.keyUp(windowsKeycode);
else
Log.e(TAG, String.format("Unknown keyCode: %d", keyCode));
}

View file

@ -1,167 +0,0 @@
package org.emulator.forty.eight;
import android.content.Context;
import android.content.DialogInterface;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
public class SeekBarPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener
{
private static final String androidns="http://schemas.android.com/apk/res/android";
private static final String appdns="http://schemas.android.com/apk/res-auto";
private SeekBar mSeekBar;
private TextView mSplashText,mValueText;
private Context mContext;
private String mDialogMessage, mSuffix, mSuffixes;
private int mDefault, mMin, mMax, mValue = 0;
private float mDisplayScale = 1.0f;
private String mDisplayFormat;
public SeekBarPreference(Context context, AttributeSet attrs) {
super(context,attrs);
mContext = context;
mDialogMessage = getAttributeValue(attrs, androidns, "dialogMessage");
mValue = mDefault = attrs.getAttributeIntValue(androidns, "defaultValue", 0);
mDisplayScale = attrs.getAttributeFloatValue(appdns, "displayScale", 1.0f);
mSuffix = getAttributeValue(attrs, appdns, "suffix");
mSuffixes = getAttributeValue(attrs, appdns, "suffixes");
mDisplayFormat = attrs.getAttributeValue(appdns, "displayFormat");
mMin = attrs.getAttributeIntValue(appdns, "min", 0);
mMax = attrs.getAttributeIntValue(androidns, "max", 100);
}
private String getAttributeValue(AttributeSet attrs, String namespace, String name) {
String attributeValue = attrs.getAttributeValue(namespace, name);
String result = attributeValue;
if(attributeValue != null && attributeValue.length() > 1 && attributeValue.charAt(0) == '@') {
try {
int id = Integer.parseInt(attributeValue.substring(1));
result = mContext.getString(id);
} catch (NumberFormatException e) {}
}
return result;
}
@Override
protected View onCreateDialogView() {
LinearLayout layout = new LinearLayout(mContext);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setPadding(6, 6, 6, 6);
mSplashText = new TextView(mContext);
if (mDialogMessage != null)
mSplashText.setText(mDialogMessage);
layout.addView(mSplashText);
mValueText = new TextView(mContext);
mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
mValueText.setTextSize(32);
layout.addView(mValueText, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
mSeekBar = new SeekBar(mContext);
mSeekBar.setOnSeekBarChangeListener(this);
layout.addView(mSeekBar, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
if (shouldPersist())
mValue = getPersistedInt(mDefault);
mSeekBar.setMax(mMax - mMin);
mSeekBar.setProgress(mValue - mMin);
return layout;
}
@Override
protected void onBindDialogView(View v) {
super.onBindDialogView(v);
mSeekBar.setMax(mMax - mMin);
mSeekBar.setProgress(mValue - mMin);
}
@Override
protected void onSetInitialValue(boolean restore, Object defaultValue)
{
super.onSetInitialValue(restore, defaultValue);
if (restore)
mValue = shouldPersist() ? getPersistedInt(mDefault) : 0;
else
mValue = (Integer)defaultValue;
}
public void setValueSummary()
{
setSummary(getValueSummary());
}
public String getValueSummary()
{
return getValueSummary(mValue);
}
public String getValueSummary(int value)
{
String textValue;
if(mDisplayFormat != null)
textValue = String.format(mDisplayFormat, value * mDisplayScale);
else if(mDisplayScale != 1.0f)
textValue = String.valueOf(value * mDisplayScale);
else
textValue = String.valueOf(value);
if(value * mDisplayScale > 1.0f) {
if(mSuffixes != null)
textValue += " " + mSuffixes;
else if(mSuffix != null)
textValue += " " + mSuffix;
} else if(mSuffix != null)
textValue += " " + mSuffix;
return textValue;
}
public void onProgressChanged(SeekBar seek, int value, boolean fromTouch)
{
int theValue = mMin + value;
String textValue = getValueSummary(theValue);
mValueText.setText(textValue);
if (shouldPersist())
persistInt(theValue);
//mValue = theValue;
//callChangeListener(Integer.valueOf(mMin + value));
}
public void onStartTrackingTouch(SeekBar seek) {}
public void onStopTrackingTouch(SeekBar seek) {}
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
// save your new password here
mValue = mMin + mSeekBar.getProgress();
callChangeListener(Integer.valueOf(mValue));
break;
default:
// do something else...
break;
}
}
public void setMin(int min) { mMin = min; }
public int getMin() { return mMin; }
public void setMax(int max) { mMax = max; }
public int getMax() { return mMax; }
public void setProgress(int progress) {
mValue = progress;
if (mSeekBar != null)
mSeekBar.setProgress(progress - mMin);
}
public int getProgress() { return mValue; }
}

View file

@ -37,7 +37,7 @@ import androidx.core.app.NavUtils;
*/
public class SettingsActivity extends AppCompatPreferenceActivity {
private static final String TAG = "SettingsActivity";
//private static final String TAG = "SettingsActivity";
private static SharedPreferences sharedPreferences;
@ -69,36 +69,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
return super.onMenuItemSelected(featureId, item);
}
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
};
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
@ -108,49 +78,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
// /**
// * Binds a preference's summary to its value. More specifically, when the
// * preference's value is changed, its summary (line of text below the
// * preference title) is updated to reflect the value. The summary is also
// * immediately updated upon calling this method. The exact display format is
// * dependent on the type of preference.
// *
// * @see #sBindPreferenceSummaryToValueListener
// */
// private static void bindPreferenceSummaryToStringValue(Preference preference) {
// preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
// sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, sharedPreferences.getString(preference.getKey(), ""));
// }
//
// /**
// * Binds a preference's summary to its value. More specifically, when the
// * preference's value is changed, its summary (line of text below the
// * preference title) is updated to reflect the value. The summary is also
// * immediately updated upon calling this method. The exact display format is
// * dependent on the type of preference.
// *
// * @see #sBindPreferenceSummaryToValueListener
// */
// private static void bindPreferenceSummaryToIntValue(Preference preference) {
// preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
// sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, sharedPreferences.getInt(preference.getKey(), 0));
// }
//
// /**
// * Binds a preference's summary to its value. More specifically, when the
// * preference's value is changed, its summary (line of text below the
// * preference title) is updated to reflect the value. The summary is also
// * immediately updated upon calling this method. The exact display format is
// * dependent on the type of preference.
// *
// * @see #sBindPreferenceSummaryToValueListener
// */
// private static void bindPreferenceSummaryToBoolValue(Preference preference) {
// // Set the listener to watch for value changes.
// preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
// sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, sharedPreferences.getBoolean(preference.getKey(), false));
// }
/**
* {@inheritDoc}
*/
@ -159,15 +86,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
return isXLargeTablet(this);
}
// /**
// * {@inheritDoc}
// */
// @Override
// @TargetApi(Build.VERSION_CODES.HONEYCOMB)
// public void onBuildHeaders(List<Header> target) {
// loadHeadersFromResource(R.xml.pref_headers, target);
// }
/**
* This method stops fragment injection in malicious applications.
* Make sure to deny any unknown fragments here.
@ -175,8 +93,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
protected boolean isValidFragment(String fragmentName) {
return PreferenceFragment.class.getName().equals(fragmentName)
|| GeneralPreferenceFragment.class.getName().equals(fragmentName)
// || DataSyncPreferenceFragment.class.getName().equals(fragmentName)
// || NotificationPreferenceFragment.class.getName().equals(fragmentName)
;
}
@ -231,18 +147,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
preferenceAutosave.setOnPreferenceChangeListener(onPreferenceChangeListenerAutosave);
onPreferenceChangeListenerAutosave.onPreferenceChange(preferenceAutosave, sharedPreferences.getBoolean(preferenceAutosave.getKey(), false));
// Preference preferenceAutosaveonexit = findPreference("settings_autosaveonexit");
// Preference.OnPreferenceChangeListener onPreferenceChangeListenerAutosaveonexit = new Preference.OnPreferenceChangeListener() {
// @Override
// public boolean onPreferenceChange(Preference preference, Object value) {
// String stringValue = value.toString();
// preference.setSummary(stringValue);
// return true;
// }
// };
// preferenceAutosaveonexit.setOnPreferenceChangeListener(onPreferenceChangeListenerAutosaveonexit);
// onPreferenceChangeListenerAutosaveonexit.onPreferenceChange(preferenceAutosaveonexit, sharedPreferences.getBoolean(preferenceAutosaveonexit.getKey(), false));
Preference preferenceObjectloadwarning = findPreference("settings_objectloadwarning");
Preference.OnPreferenceChangeListener onPreferenceChangeListenerObjectloadwarning = new Preference.OnPreferenceChangeListener() {
@Override
@ -273,49 +177,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
preferenceAllowSound.setEnabled(false);
}
// 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;
// }
// });
// Ports 1 & 2 settings
final Preference preferencePort1en = findPreference("settings_port1en");
@ -354,12 +215,11 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
Preference.OnPreferenceChangeListener onPreferenceChangeListenerPort2en = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
Boolean booleanValue = (Boolean)value;
String stringValue = value.toString();
preference.setSummary(stringValue);
preferencePort2en.setEnabled(enablePortPreferences);
preferencePort2wr.setEnabled(enablePortPreferences /*&& booleanValue.booleanValue()*/);
preferencePort2load.setEnabled(enablePortPreferences /*&& booleanValue.booleanValue()*/);
preferencePort2wr.setEnabled(enablePortPreferences);
preferencePort2load.setEnabled(enablePortPreferences);
return true;
}
};
@ -397,7 +257,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
//intent.setType("YOUR FILETYPE"); //not needed, but maybe usefull
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_TITLE, "shared.bin");
getActivity().startActivityForResult(intent, MainActivity.INTENT_PORT2LOAD);
@ -431,29 +290,13 @@ 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);
// }
}
}
super.onActivityResult(requestCode, resultCode, data);
}
private void makeUriPersistable(Intent data, Uri uri) {
//grantUriPermission(getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
getContentResolver().takePersistableUriPermission(uri, takeFlags);
}
private void makeUriPersistableReadOnly(Intent data, Uri uri) {
//grantUriPermission(getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
getContentResolver().takePersistableUriPermission(uri, takeFlags);
}
}

View file

@ -3,67 +3,10 @@
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<!--
https://material.io/tools/icons/?icon=insert_drive_file&style=baseline
https://github.com/google/material-design-icons/tree/master/action/drawable-anydpi-v21
NEW
++insert_drive_file *editor
OPEN
++ description *action
open_in_new *action
SAVEs
save *content
CLOSE
close *navigation
LOAD OBJECT
open_in_browser *action
SAVE OBJECT
save_alt *content-
COPY SCREEN
tv *hardware
COPY STACK
filter_none *image
PASTE STACK
file_copy *content-
RESET CALCULATOR
refresh *navigation
SAVE BACKUP
++playlist_add *av
input *action
subdirectory_arrow_right *navigation
RESTORE BACKUP
++playlist_play *av
subdirectory_arrow_left *navigation
restore_page *action
DELETE BACKUP
remove *content
KML
wallpaper *device
art_track *av
HELP
help *action
ABOUT
info *action
-->
<!--
https://material.io/tools/icons/?icon=insert_drive_file&style=baseline
https://github.com/google/material-design-icons/tree/master/action/drawable-anydpi-v21
-->
<group android:checkableBehavior="single">
<item

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- http://stackoverflow.com/questions/3441396/defining-custom-attrs -->
<declare-styleable name="SeekBarPreference">
<attr name="min" format="integer" />
<attr name="displayScale" format="float" />
<attr name="displayFormat" format="string" />
<attr name="suffix" format="string" />
<attr name="suffixes" format="string" />
</declare-styleable>
</resources>

View file

@ -46,6 +46,16 @@
<string name="load_custom_kml">[Custom KML script...]</string>
<string name="load_default_kml">[Default KML script]</string>
<string name="pick_calculator">Pick a calculator</string>
<string name="message_state_saved">State saved</string>
<string name="message_do_you_want_to_save">Do you want to save changes?\n(BACK to cancel)</string>
<string name="message_yes">Yes</string>
<string name="message_no">No</string>
<string name="message_object_load">Warning: Trying to load an object while the emulator is busy will certainly result in a memory lost. Before loading an object you should be sure that the calculator is in idle state. Do you want to see this warning next time you try to load an object?</string>
<string name="message_screenshot">Emu48 screenshot</string>
<string name="message_share_screenshot">Share Emu48 screenshot</string>
<string name="message_press_reset">Are you sure you want to press the Reset Button?</string>
<string name="message_change_kml">You cannot change the KML script when Emu48 is not running. Use the File, New menu item to create a new calculator.</string>
<string name="message_kml_script_compilation_result">KML Script Compilation Result</string>
</resources>