mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-27 09:16:08 +00:00
Merge pull request #643 from alexbakker/documentsui-error
Simplify the auto lock block logic and show an error if DocumentsUI is missing
This commit is contained in:
commit
40d1e22079
4 changed files with 39 additions and 12 deletions
|
@ -1,11 +1,14 @@
|
||||||
package com.beemdevelopment.aegis.ui;
|
package com.beemdevelopment.aegis.ui;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.CallSuper;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.AegisApplication;
|
import com.beemdevelopment.aegis.AegisApplication;
|
||||||
|
@ -55,12 +58,32 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CallSuper
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onResume() {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onResume();
|
||||||
_app.setBlockAutoLock(false);
|
_app.setBlockAutoLock(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startActivityForResult(Intent intent, int requestCode, Bundle bundle) {
|
||||||
|
if (isAutoLockBypassedForAction(intent.getAction())) {
|
||||||
|
_app.setBlockAutoLock(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
super.startActivityForResult(intent, requestCode, bundle);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
if (isDocsAction(intent.getAction())) {
|
||||||
|
Dialogs.showErrorDialog(this, R.string.documentsui_error, e);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocked(boolean userInitiated) {
|
public void onLocked(boolean userInitiated) {
|
||||||
setResult(RESULT_CANCELED, null);
|
setResult(RESULT_CANCELED, null);
|
||||||
|
@ -135,4 +158,17 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
||||||
protected boolean isOrphan() {
|
protected boolean isOrphan() {
|
||||||
return !(this instanceof MainActivity) && !(this instanceof AuthActivity) && !(this instanceof IntroActivity) && _app.isVaultLocked();
|
return !(this instanceof MainActivity) && !(this instanceof AuthActivity) && !(this instanceof IntroActivity) && _app.isVaultLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isDocsAction(@Nullable String action) {
|
||||||
|
return action != null && (action.equals(Intent.ACTION_GET_CONTENT)
|
||||||
|
|| action.equals(Intent.ACTION_CREATE_DOCUMENT)
|
||||||
|
|| action.equals(Intent.ACTION_OPEN_DOCUMENT)
|
||||||
|
|| action.equals(Intent.ACTION_OPEN_DOCUMENT_TREE));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isAutoLockBypassedForAction(@Nullable String action) {
|
||||||
|
return isDocsAction(action) || (action != null && (action.equals(Intent.ACTION_PICK)
|
||||||
|
|| action.equals(Intent.ACTION_SEND)
|
||||||
|
|| action.equals(Intent.ACTION_CHOOSER)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,8 +407,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startScanImageActivity() {
|
private void startScanImageActivity() {
|
||||||
_app.setBlockAutoLock(true);
|
|
||||||
|
|
||||||
Intent galleryIntent = new Intent(Intent.ACTION_PICK);
|
Intent galleryIntent = new Intent(Intent.ACTION_PICK);
|
||||||
galleryIntent.setDataAndType(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, "image/*");
|
galleryIntent.setDataAndType(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, "image/*");
|
||||||
|
|
||||||
|
|
|
@ -191,8 +191,6 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
intent.setType("*/*");
|
intent.setType("*/*");
|
||||||
|
|
||||||
_app.setBlockAutoLock(true);
|
|
||||||
startActivityForResult(intent, CODE_IMPORT);
|
startActivityForResult(intent, CODE_IMPORT);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@ -737,8 +735,6 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
.setType(getExportMimeType(requestCode))
|
.setType(getExportMimeType(requestCode))
|
||||||
.putExtra(Intent.EXTRA_TITLE, fileInfo.toString());
|
.putExtra(Intent.EXTRA_TITLE, fileInfo.toString());
|
||||||
|
|
||||||
_app.setBlockAutoLock(true);
|
|
||||||
startActivityForResult(intent, requestCode);
|
startActivityForResult(intent, requestCode);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -775,8 +771,6 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
.setType(getExportMimeType(requestCode))
|
.setType(getExportMimeType(requestCode))
|
||||||
.putExtra(Intent.EXTRA_STREAM, uri);
|
.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
Intent chooser = Intent.createChooser(intent, getString(R.string.pref_export_summary));
|
Intent chooser = Intent.createChooser(intent, getString(R.string.pref_export_summary));
|
||||||
|
|
||||||
_app.setBlockAutoLock(true);
|
|
||||||
startActivity(chooser);
|
startActivity(chooser);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1019,8 +1013,6 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
||||||
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||||
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
|
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
|
||||||
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
|
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
|
||||||
|
|
||||||
_app.setBlockAutoLock(true);
|
|
||||||
startActivityForResult(intent, CODE_BACKUPS);
|
startActivityForResult(intent, CODE_BACKUPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,7 @@
|
||||||
<string name="disable_encryption_error">An error occurred while disabling encryption</string>
|
<string name="disable_encryption_error">An error occurred while disabling encryption</string>
|
||||||
<string name="backup_successful">The backup was scheduled successfully</string>
|
<string name="backup_successful">The backup was scheduled successfully</string>
|
||||||
<string name="backup_error">An error occurred while trying to create a backup</string>
|
<string name="backup_error">An error occurred while trying to create a backup</string>
|
||||||
|
<string name="documentsui_error">DocumentsUI appears to be missing from your device. This is an important system component necessary for the selection and creation of documents. If you used a tool to "debloat" your device, you may have accidentally deleted it and will have to reinstall it.</string>
|
||||||
<string name="permission_denied">Permission denied</string>
|
<string name="permission_denied">Permission denied</string>
|
||||||
<string name="andotp_new_format">New format (v0.6.3 or newer) </string>
|
<string name="andotp_new_format">New format (v0.6.3 or newer) </string>
|
||||||
<string name="andotp_old_format">Old format (v0.6.2 or older) </string>
|
<string name="andotp_old_format">Old format (v0.6.2 or older) </string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue