-
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 #5 from bugyun/develop
Develop
- Loading branch information
Showing
62 changed files
with
2,843 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,34 @@ | ||
apply plugin: 'com.android.library' | ||
apply from: 'jcenter.gradle'//上传 jcenter 的插件 | ||
|
||
android { | ||
compileSdkVersion 28 | ||
buildToolsVersion "28.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles 'consumer-rules.pro' | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:support-fragment:28.0.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
api 'vip.ruoyun.helper:avoid-onresult-helper:1.0.3' | ||
} |
Empty file.
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-pro' //项目名称 name | ||
publishVersion = '1.0.0'//版本号 version | ||
desc = 'Android 权限请求库 MissPermission pro版'//描述 | ||
website = 'https://github.com/bugyun/MissPermission' // github 网址 | ||
} | ||
|
||
// ./gradlew clean build bintrayUpload -PbintrayUser=bintray.user -PbintrayKey=bintray.apikey -PdryRun=false |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
27 changes: 27 additions & 0 deletions
27
...PermissionPro/src/androidTest/java/vip/ruoyun/permission/pro/ExampleInstrumentedTest.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,27 @@ | ||
package vip.ruoyun.permission.pro; | ||
|
||
import android.content.Context; | ||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
|
||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
|
||
assertEquals("vip.ruoyun.permission.pro.test", appContext.getPackageName()); | ||
} | ||
} |
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,2 @@ | ||
<manifest package="vip.ruoyun.permission.pro" | ||
xmlns:android="http://schemas.android.com/apk/res/android" /> |
104 changes: 104 additions & 0 deletions
104
MissPermissionPro/src/main/java/vip/ruoyun/permission/pro/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,104 @@ | ||
package vip.ruoyun.permission.pro; | ||
|
||
|
||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.provider.Settings; | ||
import android.view.View; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import vip.ruoyun.helper.avoid.AvoidOnResultHelper; | ||
import vip.ruoyun.permission.pro.ui.AgainRequestDialog; | ||
import vip.ruoyun.permission.pro.ui.AlwaysDeniedDialog; | ||
import vip.ruoyun.permission.pro.ui.RequestPromptDialog; | ||
|
||
|
||
public class DefaultAction implements IAction { | ||
|
||
private RequestPromptDialog requestPromptDialog; | ||
private AlwaysDeniedDialog alwaysDeniedDialog; | ||
private AgainRequestDialog againRequestDialog; | ||
|
||
@Override | ||
public void checkedAction(final PermissionRequest request, Set<PermissionGroup> permissionGroups) { | ||
if (request.getDeniedPermissionList().size() == 0) { | ||
request.next(); | ||
return; | ||
} | ||
if (requestPromptDialog == null) { | ||
requestPromptDialog = RequestPromptDialog.getRequestPromptDialog(request.getContext()); | ||
requestPromptDialog.setTitleAndMsg(request.getTitle(), request.getMsg()); | ||
requestPromptDialog.setBtnOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (requestPromptDialog != null && requestPromptDialog.isShowing()) { | ||
requestPromptDialog.dismiss(); | ||
} | ||
request.next(); | ||
} | ||
}); | ||
} | ||
requestPromptDialog.setPermissionGroups(permissionGroups); | ||
requestPromptDialog.setStyleId(request.getStyleResId()); | ||
requestPromptDialog.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()) { | ||
if (alwaysDeniedDialog == null) { | ||
alwaysDeniedDialog = AlwaysDeniedDialog.getAlwaysDeniedDialog(request.getContext()); | ||
alwaysDeniedDialog.setStyleId(request.getStyleResId()); | ||
alwaysDeniedDialog.setSettingClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (alwaysDeniedDialog != null && alwaysDeniedDialog.isShowing()) { | ||
alwaysDeniedDialog.dismiss(); | ||
} | ||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | ||
intent.setData(Uri.parse("package:" + v.getContext().getPackageName())); | ||
AvoidOnResultHelper.startActivityForResult(request.getContext(), intent, DefaultAction.this); | ||
} | ||
}); | ||
} | ||
alwaysDeniedDialog.setTitleAndMsg("温馨提示", "获取" + sBuilder.toString() + "权限被禁用" + "\n请在 设置-应用管理-权限管理 (将权限打开)"); | ||
alwaysDeniedDialog.show(); | ||
} else { | ||
if (againRequestDialog == null) { | ||
againRequestDialog = AgainRequestDialog.getAlwaysDeniedDialog(request.getContext()); | ||
againRequestDialog.setStyleId(request.getStyleResId()); | ||
againRequestDialog.setSettingClickListener("验证权限", new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
request.requestPermissionsAgain(); | ||
if (againRequestDialog != null && againRequestDialog.isShowing()) { | ||
againRequestDialog.dismiss(); | ||
} | ||
} | ||
}); | ||
againRequestDialog.setTitleAndMsg("温馨提示", "我们需要这些权限才能正常使用该功能"); | ||
} | ||
againRequestDialog.show(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onActivityResult(int resultCode, Intent data) { | ||
|
||
} | ||
} |
Oops, something went wrong.