Fix Port2 settings
This commit is contained in:
parent
b61ec6d7f5
commit
32e41ccbee
5 changed files with 121 additions and 102 deletions
|
@ -4,8 +4,8 @@
|
||||||
package="com.regis.cosnier.emu48">
|
package="com.regis.cosnier.emu48">
|
||||||
|
|
||||||
<!--<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>-->
|
<!--<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>-->
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<!--<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />-->
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:required="false" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
@ -25,17 +25,41 @@
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<!--<action android:name="android.intent.action.VIEW" />-->
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<!--<action android:name="android.intent.action.SEND" />-->
|
||||||
<action android:name="android.intent.action.SEND" />
|
<!--<category android:name="android.intent.category.DEFAULT" />-->
|
||||||
|
<!--<data android:scheme="content"-->
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<!--android:mimeType="*/*"-->
|
||||||
|
<!--android:pathPattern=".*\\.e38"-->
|
||||||
<!--<data android:mimeType="*/*" />-->
|
<!--android:host="*"/>-->
|
||||||
<data android:scheme="file"
|
<!--<data android:scheme="content"-->
|
||||||
android:mimeType="*/*"
|
<!--android:mimeType="*/*"-->
|
||||||
android:pathPattern=".*\\.e48"
|
<!--android:pathPattern=".*\\.e39"-->
|
||||||
android:host="*"/>
|
<!--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>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
|
|
|
@ -22,6 +22,8 @@ AndroidBitmapInfo androidBitmapInfo;
|
||||||
TCHAR szChosenCurrentKml[MAX_PATH];
|
TCHAR szChosenCurrentKml[MAX_PATH];
|
||||||
TCHAR szKmlLog[10240];
|
TCHAR szKmlLog[10240];
|
||||||
TCHAR szKmlTitle[10240];
|
TCHAR szKmlTitle[10240];
|
||||||
|
BOOL settingsPort2en;
|
||||||
|
BOOL settingsPort2wr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -846,8 +848,8 @@ JNIEXPORT void JNICALL Java_com_regis_cosnier_emu48_NativeLib_setConfiguration(J
|
||||||
SwitchToState(nOldState);
|
SwitchToState(nOldState);
|
||||||
}
|
}
|
||||||
} else if(_tcscmp(_T("settings_port2"), configKey) == 0) {
|
} else if(_tcscmp(_T("settings_port2"), configKey) == 0) {
|
||||||
BOOL settingsPort2en = (BOOL)intValue1;
|
settingsPort2en = (BOOL)intValue1;
|
||||||
BOOL settingsPort2wr = (BOOL)intValue2;
|
settingsPort2wr = (BOOL)intValue2;
|
||||||
const char * settingsPort2load = settingsPort2en ? configStringValue : NULL;
|
const char * settingsPort2load = settingsPort2en ? configStringValue : NULL;
|
||||||
|
|
||||||
LPCTSTR szActPort2Filename = _T("");
|
LPCTSTR szActPort2Filename = _T("");
|
||||||
|
@ -857,24 +859,22 @@ JNIEXPORT void JNICALL Java_com_regis_cosnier_emu48_NativeLib_setConfiguration(J
|
||||||
// HP48SX/GX port2 change settings detection
|
// HP48SX/GX port2 change settings detection
|
||||||
if (cCurrentRomType=='S' || cCurrentRomType=='G' || cCurrentRomType==0)
|
if (cCurrentRomType=='S' || cCurrentRomType=='G' || cCurrentRomType==0)
|
||||||
{
|
{
|
||||||
//bPort2IsShared = settingsPort2isshared;
|
if(settingsPort2en && settingsPort2load) {
|
||||||
const char * szNewPort2Filename = NULL;
|
if(_tcscmp(szPort2Filename, settingsPort2load) != 0) {
|
||||||
if(settingsPort2load) {
|
_tcscpy(szPort2Filename, settingsPort2load);
|
||||||
szNewPort2Filename = settingsPort2load;
|
bPort2CfgChange = TRUE; // slot2 configuration changed
|
||||||
}
|
}
|
||||||
// else
|
|
||||||
// szNewPort2Filename = _T("SHARED.BIN");
|
|
||||||
|
|
||||||
if(szNewPort2Filename && _tcscmp(szPort2Filename, szNewPort2Filename) != 0) {
|
|
||||||
_tcscpy(szPort2Filename, szNewPort2Filename);
|
|
||||||
szActPort2Filename = szPort2Filename;
|
szActPort2Filename = szPort2Filename;
|
||||||
bPort2CfgChange = TRUE; // slot2 configuration changed
|
|
||||||
|
|
||||||
// R/W port
|
// R/W port
|
||||||
if (*szActPort2Filename != 0 && (BOOL)settingsPort2wr != bPort2Writeable)
|
if (*szActPort2Filename != 0 && (BOOL) settingsPort2wr != bPort2Writeable) {
|
||||||
{
|
bPort2AttChange = TRUE; // slot2 file R/W attribute changed
|
||||||
bPort2AttChange = TRUE; // slot2 file R/W attribute changed
|
bPort2CfgChange = TRUE; // slot2 configuration changed
|
||||||
bPort2CfgChange = TRUE; // slot2 configuration changed
|
}
|
||||||
|
} else {
|
||||||
|
if(szPort2Filename[0] != '\0') {
|
||||||
|
bPort2CfgChange = TRUE; // slot2 configuration changed
|
||||||
|
szPort2Filename[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -885,24 +885,6 @@ JNIEXPORT void JNICALL Java_com_regis_cosnier_emu48_NativeLib_setConfiguration(J
|
||||||
|
|
||||||
UnmapPort2(); // unmap port2
|
UnmapPort2(); // unmap port2
|
||||||
|
|
||||||
// if (bPort2AttChange) // slot2 R/W mode changed
|
|
||||||
// {
|
|
||||||
// DWORD dwFileAtt;
|
|
||||||
//
|
|
||||||
// SetCurrentDirectory(szEmuDirectory);
|
|
||||||
// dwFileAtt = GetFileAttributes(szActPort2Filename);
|
|
||||||
// if (dwFileAtt != 0xFFFFFFFF)
|
|
||||||
// {
|
|
||||||
// if (IsDlgButtonChecked(hDlg,IDC_PORT2WR))
|
|
||||||
// dwFileAtt &= ~FILE_ATTRIBUTE_READONLY;
|
|
||||||
// else
|
|
||||||
// dwFileAtt |= FILE_ATTRIBUTE_READONLY;
|
|
||||||
//
|
|
||||||
// SetFileAttributes(szActPort2Filename,dwFileAtt);
|
|
||||||
// }
|
|
||||||
// SetCurrentDirectory(szCurrentDirectory);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (cCurrentRomType) // ROM defined
|
if (cCurrentRomType) // ROM defined
|
||||||
{
|
{
|
||||||
MapPort2(szActPort2Filename);
|
MapPort2(szActPort2Filename);
|
||||||
|
|
|
@ -63,12 +63,17 @@ BOOL SetCurrentDirectory(LPCTSTR path)
|
||||||
return chdir(path);
|
return chdir(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern BOOL settingsPort2en;
|
||||||
|
extern BOOL settingsPort2wr;
|
||||||
|
|
||||||
HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile)
|
HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile)
|
||||||
{
|
{
|
||||||
BOOL forceNormalFile = FALSE;
|
BOOL forceNormalFile = FALSE;
|
||||||
if(_tcscmp(lpFileName, szPort2Filename) == 0) {
|
if(_tcscmp(lpFileName, szPort2Filename) == 0) {
|
||||||
// Special case for Port2 filename
|
// Special case for Port2 filename
|
||||||
forceNormalFile = TRUE;
|
forceNormalFile = TRUE;
|
||||||
|
if(!settingsPort2wr && (dwDesiredAccess & GENERIC_WRITE))
|
||||||
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!forceNormalFile && (szCurrentDirectorySet || _tcsncmp(lpFileName, assetsPrefix, assetsPrefixLength / sizeof(TCHAR)) == 0)) {
|
if(!forceNormalFile && (szCurrentDirectorySet || _tcsncmp(lpFileName, assetsPrefix, assetsPrefixLength / sizeof(TCHAR)) == 0)) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.regis.cosnier.emu48;
|
package com.regis.cosnier.emu48;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
@ -8,6 +9,7 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
@ -54,6 +56,7 @@ import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
|
@ -77,7 +80,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
private NavigationView navigationView;
|
private NavigationView navigationView;
|
||||||
private DrawerLayout drawer;
|
private DrawerLayout drawer;
|
||||||
|
|
||||||
//private final static int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 2;
|
private final static int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 2;
|
||||||
|
|
||||||
enum FileType {
|
enum FileType {
|
||||||
PDF,
|
PDF,
|
||||||
|
@ -122,6 +125,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
mainActivity = this;
|
mainActivity = this;
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,7 +149,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
toolbar.setVisibility(View.GONE);
|
toolbar.setVisibility(View.GONE);
|
||||||
mainScreenContainer.addView(mainScreenView, 0);
|
mainScreenContainer.addView(mainScreenView, 0);
|
||||||
|
|
||||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
AssetManager assetManager = getResources().getAssets();
|
||||||
|
NativeLib.start(assetManager, mainScreenView.getBitmapMainScreen(), this, mainScreenView);
|
||||||
|
|
||||||
updateFromPreferences(null, false);
|
updateFromPreferences(null, false);
|
||||||
sharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
sharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -155,15 +161,12 @@ public class MainActivity extends AppCompatActivity
|
||||||
};
|
};
|
||||||
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
||||||
|
|
||||||
|
|
||||||
AssetManager assetManager = getResources().getAssets();
|
|
||||||
NativeLib.start(assetManager, mainScreenView.getBitmapMainScreen(), this, mainScreenView);
|
|
||||||
|
|
||||||
updateNavigationDrawerItems();
|
updateNavigationDrawerItems();
|
||||||
|
|
||||||
|
|
||||||
String documentToOpenUrl = sharedPreferences.getString("lastDocument", "");
|
String documentToOpenUrl = sharedPreferences.getString("lastDocument", "");
|
||||||
Uri documentToOpenUri = null;
|
Uri documentToOpenUri = null;
|
||||||
|
boolean isFileAndNeedPermission = false;
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if(intent != null) {
|
if(intent != null) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
@ -171,9 +174,10 @@ public class MainActivity extends AppCompatActivity
|
||||||
if (action.equals(Intent.ACTION_VIEW)) {
|
if (action.equals(Intent.ACTION_VIEW)) {
|
||||||
documentToOpenUri = intent.getData();
|
documentToOpenUri = intent.getData();
|
||||||
if (documentToOpenUri != null) {
|
if (documentToOpenUri != null) {
|
||||||
if(documentToOpenUri.getScheme().compareTo("file") == 0)
|
if(documentToOpenUri.getScheme().compareTo("file") == 0) {
|
||||||
documentToOpenUrl = documentToOpenUri.getPath();
|
documentToOpenUrl = documentToOpenUri.getPath();
|
||||||
else
|
isFileAndNeedPermission = true;
|
||||||
|
} else
|
||||||
documentToOpenUrl = documentToOpenUri.toString();
|
documentToOpenUrl = documentToOpenUri.toString();
|
||||||
}
|
}
|
||||||
} else if (action.equals(Intent.ACTION_SEND)) {
|
} else if (action.equals(Intent.ACTION_SEND)) {
|
||||||
|
@ -187,22 +191,22 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
//https://developer.android.com/guide/topics/providers/document-provider#permissions
|
//https://developer.android.com/guide/topics/providers/document-provider#permissions
|
||||||
if(documentToOpenUrl.length() > 0)
|
if(documentToOpenUrl.length() > 0)
|
||||||
// try {
|
try {
|
||||||
// if(ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
if(isFileAndNeedPermission
|
||||||
// ActivityCompat.requestPermissions(this, new String[]{ Manifest.permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
|
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||||
// //return;
|
ActivityCompat.requestPermissions(this, new String[]{ Manifest.permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
|
||||||
// } else {
|
//return;
|
||||||
if(onFileOpen(documentToOpenUrl) != 0 && documentToOpenUri != null) {
|
} else {
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
if(onFileOpen(documentToOpenUrl) != 0) {
|
||||||
editor.putString("lastDocument", documentToOpenUrl);
|
saveLastDocument(documentToOpenUrl);
|
||||||
editor.commit();
|
if(intent != null && documentToOpenUri != null && !isFileAndNeedPermission)
|
||||||
makeUriPersistable(intent, documentToOpenUri);
|
makeUriPersistable(intent, documentToOpenUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// }
|
}
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Log.e(TAG, e.getMessage());
|
Log.e(TAG, e.getMessage());
|
||||||
// }
|
}
|
||||||
else if(drawer != null)
|
else if(drawer != null)
|
||||||
drawer.openDrawer(GravityCompat.START);
|
drawer.openDrawer(GravityCompat.START);
|
||||||
}
|
}
|
||||||
|
@ -238,25 +242,30 @@ public class MainActivity extends AppCompatActivity
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
// public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||||
// switch (requestCode) {
|
switch (requestCode) {
|
||||||
// case PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: {
|
case PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: {
|
||||||
// // If request is cancelled, the result arrays are empty.
|
// If request is cancelled, the result arrays are empty.
|
||||||
//// if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
// if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
////
|
//
|
||||||
//// } else {
|
// } else {
|
||||||
//// //Toast.makeText(this, R.string.toast_access_location_denied, Toast.LENGTH_SHORT).show();
|
// //Toast.makeText(this, R.string.toast_access_location_denied, Toast.LENGTH_SHORT).show();
|
||||||
//// }
|
// }
|
||||||
// String lastDocumentUrl = sharedPreferences.getString("lastDocument", "");
|
String lastDocumentUrl = sharedPreferences.getString("lastDocument", "");
|
||||||
// if(lastDocumentUrl.length() > 0)
|
if(lastDocumentUrl.length() > 0) {
|
||||||
// onFileOpen(lastDocumentUrl);
|
if(onFileOpen(lastDocumentUrl) != 0)
|
||||||
//// return;
|
try {
|
||||||
// }
|
makeUriPersistable(getIntent(), Uri.parse(lastDocumentUrl));
|
||||||
//// default:
|
} catch (Exception e) {
|
||||||
//// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
}
|
||||||
// }
|
}
|
||||||
// }
|
// return;
|
||||||
|
}
|
||||||
|
// default:
|
||||||
|
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
|
@ -549,9 +558,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
NativeLib.onFileClose();
|
NativeLib.onFileClose();
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
saveLastDocument("");
|
||||||
editor.putString("lastDocument", "");
|
|
||||||
editor.commit();
|
|
||||||
updateNavigationDrawerItems();
|
updateNavigationDrawerItems();
|
||||||
displayFilename("");
|
displayFilename("");
|
||||||
if(drawer != null) {
|
if(drawer != null) {
|
||||||
|
@ -720,9 +727,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
String url = uri.toString();
|
String url = uri.toString();
|
||||||
if(onFileOpen(url) != 0) {
|
if(onFileOpen(url) != 0) {
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
saveLastDocument(url);
|
||||||
editor.putString("lastDocument", url);
|
|
||||||
editor.commit();
|
|
||||||
makeUriPersistable(data, uri);
|
makeUriPersistable(data, uri);
|
||||||
}
|
}
|
||||||
} else if(requestCode == INTENT_GETSAVEFILENAME) {
|
} else if(requestCode == INTENT_GETSAVEFILENAME) {
|
||||||
|
@ -733,10 +738,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
String url = uri.toString();
|
String url = uri.toString();
|
||||||
if(NativeLib.onFileSaveAs(url) != 0) {
|
if(NativeLib.onFileSaveAs(url) != 0) {
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
saveLastDocument(url);
|
||||||
editor.putString("lastDocument", url);
|
|
||||||
editor.commit();
|
|
||||||
|
|
||||||
makeUriPersistable(data, uri);
|
makeUriPersistable(data, uri);
|
||||||
displayFilename(url);
|
displayFilename(url);
|
||||||
if(fileSaveAsCallback != null)
|
if(fileSaveAsCallback != null)
|
||||||
|
@ -765,6 +767,12 @@ public class MainActivity extends AppCompatActivity
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveLastDocument(String url) {
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
editor.putString("lastDocument", url);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
private void makeUriPersistable(Intent data, Uri uri) {
|
private void makeUriPersistable(Intent data, Uri uri) {
|
||||||
//grantUriPermission(getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
//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);
|
final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
|
|
|
@ -283,7 +283,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
String stringValue = value.toString();
|
String stringValue = value.toString();
|
||||||
preference.setSummary(stringValue);
|
preference.setSummary(stringValue);
|
||||||
preferencePort1en.setEnabled(enablePortPreferences);
|
preferencePort1en.setEnabled(enablePortPreferences);
|
||||||
preferencePort1wr.setEnabled(enablePortPreferences && booleanValue.booleanValue());
|
preferencePort1wr.setEnabled(enablePortPreferences /*&& booleanValue.booleanValue()*/);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -308,8 +308,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
String stringValue = value.toString();
|
String stringValue = value.toString();
|
||||||
preference.setSummary(stringValue);
|
preference.setSummary(stringValue);
|
||||||
preferencePort2en.setEnabled(enablePortPreferences);
|
preferencePort2en.setEnabled(enablePortPreferences);
|
||||||
preferencePort2wr.setEnabled(enablePortPreferences && booleanValue.booleanValue());
|
preferencePort2wr.setEnabled(enablePortPreferences /*&& booleanValue.booleanValue()*/);
|
||||||
preferencePort2load.setEnabled(enablePortPreferences && booleanValue.booleanValue());
|
preferencePort2load.setEnabled(enablePortPreferences /*&& booleanValue.booleanValue()*/);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue