-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dangerous permission):添加串行申请危险权限
- Loading branch information
junhua
committed
Jun 12, 2019
1 parent
19b27f0
commit 0d4b6f0
Showing
6 changed files
with
109 additions
and
30 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
56 changes: 56 additions & 0 deletions
56
agent/src/main/java/cn/junhua/android/permission/dangerous/EachDangerousPermissionAgent.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,56 @@ | ||
package cn.junhua.android.permission.dangerous; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import cn.junhua.android.permission.agent.PermissionHandler; | ||
import cn.junhua.android.permission.dangerous.checker.Permission; | ||
import cn.junhua.android.permission.utils.Executor; | ||
|
||
/** | ||
* 串行申请危险权限 | ||
* | ||
* @author [email protected]<br/> | ||
* CREATED 2018/12/19 13:39 | ||
*/ | ||
public class EachDangerousPermissionAgent extends DangerousPermissionAgent { | ||
|
||
private List<String> mPermissionListTemp = new ArrayList<>(1); | ||
|
||
public EachDangerousPermissionAgent(Executor executor, PermissionHandler permissionHandler, String[] permissions) { | ||
super(executor, permissionHandler, permissions); | ||
} | ||
|
||
@Override | ||
public List<String> onInitPermissions(String[] permissions) { | ||
return new ArrayList<>(Arrays.asList(permissions)); | ||
} | ||
|
||
@Override | ||
public List<String> getPermissions() { | ||
return mPermissionListTemp; | ||
} | ||
|
||
@Override | ||
public void apply() { | ||
List<String> permissions = super.getPermissions(); | ||
if (permissions.isEmpty()) return; | ||
|
||
mPermissionListTemp.clear(); | ||
mPermissionListTemp.addAll(Permission.handleGroup(permissions.remove(0))); | ||
super.apply(); | ||
} | ||
|
||
@Override | ||
protected void dispatchGranted(List<String> permissions) { | ||
super.dispatchGranted(permissions); | ||
apply(); | ||
} | ||
|
||
@Override | ||
protected void dispatchDenied(List<String> permissions) { | ||
super.dispatchDenied(permissions); | ||
apply(); | ||
} | ||
} |
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