-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from bugyun/develop
正式包 MissPermission
- Loading branch information
Showing
52 changed files
with
1,767 additions
and
1,239 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//上传 jcenter 的插件 | ||
apply plugin: 'com.novoda.bintray-release' // 新增 | ||
|
||
/** | ||
* 参考 | ||
* 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
* group: 'com.android.support.test.espresso', name: 'espresso-core', version: '3.0.2' | ||
*/ | ||
|
||
// 新增 | ||
publish { | ||
userOrg = 'bugyun' //bintray.com用户名 | ||
groupId = 'vip.ruoyun.permission' //jcenter group | ||
artifactId = 'miss-helper' //项目名称 name | ||
publishVersion = '1.0.0'//版本号 version | ||
desc = 'Android 权限请求库 MissPermissionHelper'//描述 | ||
website = 'https://github.com/bugyun/MissPermission' // github 网址 | ||
} | ||
|
||
// ./gradlew clean build bintrayUpload -PbintrayUser=bintray.user -PbintrayKey=bintray.apikey -PdryRun=false |
97 changes: 97 additions & 0 deletions
97
MissPermissionHelper/src/main/java/vip/ruoyun/permission/helper/DefaultAction.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,97 @@ | ||
package vip.ruoyun.permission.helper; | ||
|
||
|
||
import android.app.Dialog; | ||
import android.content.DialogInterface; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.ColorDrawable; | ||
import android.os.Build; | ||
import android.support.annotation.RequiresApi; | ||
import android.support.v7.app.AlertDialog; | ||
import android.view.View; | ||
import android.view.Window; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import vip.ruoyun.permission.helper.ui.DialogUtil; | ||
import vip.ruoyun.permission.helper.ui.MissPermissionView; | ||
import vip.ruoyun.permission.helper.ui.PermissionAdapter; | ||
|
||
public class DefaultAction implements IAction { | ||
|
||
private Dialog mDialog; | ||
|
||
@Override | ||
public void checkedAction(final PermissionRequest request, Set<PermissionGroup> permissionGroups) { | ||
if (request.getDeniedPermissionList().size() == 0) { | ||
request.next(); | ||
return; | ||
} | ||
mDialog = new Dialog(request.getContext()); | ||
MissPermissionView contentView = new MissPermissionView(request.getContext()); | ||
contentView.setGridViewColum(permissionGroups.size() < 3 ? permissionGroups.size() : 3); | ||
contentView.setGridViewAdapter(new PermissionAdapter(new ArrayList<>(permissionGroups))); | ||
// if (request.getFilterColor() != 0) { | ||
// int mFilterColor = request.getContext().getResources().getColor(request.getFilterColor()); | ||
// contentView.setFilterColor(mFilterColor); | ||
// } | ||
contentView.setTitle(request.getTitle()); | ||
contentView.setMsg(request.getMsg()); | ||
contentView.setStyleId(request.getStyleResId()); | ||
contentView.setBtnOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (mDialog != null && mDialog.isShowing()) { | ||
mDialog.dismiss(); | ||
} | ||
request.next(); | ||
} | ||
}); | ||
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
mDialog.setContentView(contentView); | ||
|
||
mDialog.setCanceledOnTouchOutside(false); | ||
mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); | ||
mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { | ||
@Override | ||
public void onCancel(DialogInterface dialog) { | ||
dialog.dismiss(); | ||
} | ||
}); | ||
mDialog.show(); | ||
} | ||
|
||
@Override | ||
public void deniedAction(final PermissionRequest request) { | ||
StringBuilder sBuilder = new StringBuilder(); | ||
Set<PermissionGroup> permissionGroups = new HashSet<>(); | ||
for (String deniedPermission : request.getDeniedPermissionList()) { | ||
PermissionGroup permissionGroup = PermissionGroup.permissionGroupHashMap.get(deniedPermission); | ||
if (permissionGroup != null) { | ||
permissionGroups.add(permissionGroup); | ||
} | ||
} | ||
for (PermissionGroup permissionGroup : permissionGroups) { | ||
sBuilder.append(permissionGroup.permissionName); | ||
sBuilder.append(","); | ||
} | ||
if (sBuilder.length() > 0) { | ||
sBuilder.deleteCharAt(sBuilder.length() - 1); | ||
} | ||
if (request.isAlwaysDenied()) { | ||
DialogUtil.showPermissionManagerDialog(request.getContext(), sBuilder.toString()); | ||
} else { | ||
new AlertDialog.Builder(request.getContext()).setTitle("温馨提示").setMessage("我们需要这些权限才能正常使用该功能").setNegativeButton("取消", null).setPositiveButton("验证权限", new DialogInterface.OnClickListener() { | ||
@RequiresApi(api = Build.VERSION_CODES.M) | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
request.requestPermissionsAgain(); | ||
} | ||
}).setCancelable(false).show(); | ||
} | ||
} | ||
|
||
|
||
} |
11 changes: 11 additions & 0 deletions
11
MissPermissionHelper/src/main/java/vip/ruoyun/permission/helper/IAction.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,11 @@ | ||
package vip.ruoyun.permission.helper; | ||
|
||
import java.util.Set; | ||
|
||
|
||
public interface IAction { | ||
|
||
void checkedAction(PermissionRequest request, Set<PermissionGroup> permissionGroups); | ||
|
||
void deniedAction(PermissionRequest request); | ||
} |
Oops, something went wrong.