mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Refactor check permission without supportv4 dependency
This commit is contained in:
@@ -104,13 +104,6 @@
|
|||||||
<artifactId>gdx-backend-android</artifactId>
|
<artifactId>gdx-backend-android</artifactId>
|
||||||
<version>1.9.10</version>
|
<version>1.9.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.android.support</groupId>
|
|
||||||
<artifactId>support-v4</artifactId>
|
|
||||||
<version>23.1.1</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${pom.basedir}/libs/android-support-v4.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@@ -145,12 +144,20 @@ public class Main extends AndroidApplication {
|
|||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
private boolean checkPermission() {
|
private boolean checkPermission() {
|
||||||
int result = ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
int pid = android.os.Process.myPid();
|
||||||
|
int uid = android.os.Process.myUid();
|
||||||
|
try {
|
||||||
|
int result = this.getBaseContext().checkPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, pid, uid);
|
||||||
|
//we only need the result above atm, we can free the dependency from android-support-v4 :)
|
||||||
|
//int result = ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
if (result == PackageManager.PERMISSION_GRANTED) {
|
if (result == PackageManager.PERMISSION_GRANTED) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void requestPermission() {
|
private void requestPermission() {
|
||||||
//Show Information about why you need the permission
|
//Show Information about why you need the permission
|
||||||
|
|||||||
Reference in New Issue
Block a user