-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #308 sdcard problems might be fixable now
If two ExternalFilesDirs are available, the non-removable is going to be used now. Also, if setting a download directory in the preferences screen fails, a fallback directory will be suggested.
- Loading branch information
Showing
16 changed files
with
148 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/github/yeriomin/yalpstore/YalpStorePermissionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.github.yeriomin.yalpstore; | ||
|
||
import android.Manifest; | ||
import android.app.Activity; | ||
import android.content.pm.PackageManager; | ||
import android.os.Build; | ||
import android.util.Log; | ||
|
||
import java.lang.ref.WeakReference; | ||
|
||
public class YalpStorePermissionManager { | ||
|
||
private static final int PERMISSIONS_REQUEST_CODE = 384; | ||
|
||
private WeakReference<Activity> activityRef = new WeakReference<>(null); | ||
|
||
public YalpStorePermissionManager(Activity activity) { | ||
this.activityRef = new WeakReference<>(activity); | ||
} | ||
|
||
static public boolean isGranted(int requestCode, String permissions[], int[] grantResults) { | ||
return requestCode == PERMISSIONS_REQUEST_CODE | ||
&& grantResults.length > 0 | ||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED | ||
; | ||
} | ||
|
||
public boolean checkPermission() { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && null != activityRef.get()) { | ||
Log.i(getClass().getSimpleName(), "Checking if write permission is granted"); | ||
return activityRef.get().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; | ||
} | ||
return true; | ||
} | ||
|
||
public void requestPermission() { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && null != activityRef.get()) { | ||
Log.i(getClass().getSimpleName(), "Requesting the write permission"); | ||
activityRef.get().requestPermissions( | ||
new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, | ||
PERMISSIONS_REQUEST_CODE | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.