Skip to content

Commit

Permalink
For now, "solve" the Android 11 storage permission problem with a wor…
Browse files Browse the repository at this point in the history
…karound of target SDK 29
  • Loading branch information
Mikhail Barashkov committed Jul 23, 2021
1 parent 59ac984 commit 42e70d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
17 changes: 16 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

def financierPropertiesFile = rootProject.file("./Keys/financier.properties")
def financierProperties = new Properties()

financierProperties.load(new FileInputStream(financierPropertiesFile))

android {
buildFeatures {
dataBinding true
Expand All @@ -28,10 +33,19 @@ android {
}
}

signingConfigs {
release {
storeFile file(financierProperties['storeFile'])
storePassword financierProperties['storePassword']
keyAlias financierProperties['keyAlias']
keyPassword financierProperties['keyPassword']
}
}

defaultConfig {
applicationId "com.handydev.financier"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 29
versionCode 216
versionName "2.0.16"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -48,6 +62,7 @@ android {
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public static boolean isRequestingPermission(Context context, String permission)
}

public static boolean checkPermission(Context ctx, String permission) {
if(SDK_INT >= 30) {
/*if(SDK_INT >= 30) {
if(permission.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
return Environment.isExternalStorageManager();
}
}
}*/
return ContextCompat.checkSelfPermission(ctx, permission) == PackageManager.PERMISSION_GRANTED;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected void attachBaseContext(Context base) {
super.attachBaseContext(MyPreferences.switchLocale(base));
}

@Override
/* @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(SDK_INT >= 30) {
Expand All @@ -86,7 +86,7 @@ public void onActivityResult(ActivityResult result) {
}
});
}
}
}*/

@AfterViews
public void initViews() {
Expand All @@ -101,11 +101,11 @@ private void checkAllFilesPermission() {
}

private void checkPermissions() {
if(SDK_INT >= 30) {
checkAllFilesPermission();
} else {
//if(SDK_INT >= 30) {
// checkAllFilesPermission();
//} else {
disableToggleIfGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE, toggleWriteStorage, toggleWriteStorageWrap);
}
//}
disableToggleIfGranted(Manifest.permission.GET_ACCOUNTS, toggleGetAccounts, toggleGetAccountsWrap);
disableToggleIfGranted(Manifest.permission.CAMERA, toggleCamera, toggleCameraWrap);
if(!BuildConfig.FLAVOR.equals("googleplay")) {
Expand All @@ -129,12 +129,12 @@ private void enableToggle(Boolean enable, CompoundButton toggleButton, ViewGroup

@Click(R.id.toggleWriteStorage)
public void onGrantWriteStorage() {
if(SDK_INT >= 30){
/*if(SDK_INT >= 30){
Intent intent = new Intent(ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package:" + BuildConfig.APPLICATION_ID));
activityResultLauncher.launch(intent);
} else {
} else {*/
requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, toggleWriteStorage);
}
//}
}

@Click(R.id.toggleGetAccounts)
Expand Down

0 comments on commit 42e70d9

Please sign in to comment.