Skip to content

Commit

Permalink
Merge pull request #8 from bugyun/develop
Browse files Browse the repository at this point in the history
优化图片体积
  • Loading branch information
bugyun authored Mar 16, 2020
2 parents e195159 + d1e9fd1 commit 65046fa
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion MissPermissionPro/jcenter.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish {
userOrg = 'bugyun' //bintray.com用户名
groupId = 'vip.ruoyun.permission' //jcenter group
artifactId = 'miss-pro' //项目名称 name
publishVersion = '1.0.1'//版本号 version
publishVersion = '1.0.2'//版本号 version
desc = 'Android 权限请求库 MissPermission pro版'//描述
website = 'https://github.com/bugyun/MissPermission' // github 网址
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@

public class MissPermission {

private static class SingletonHolder {

private static final MissPermission INSTANCE = new MissPermission();
}

private static MissPermission getInstance() {
return SingletonHolder.INSTANCE;
}

private MissPermission() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public class PermissionGroup {

public final String permissionName;

public final int permissionIconRes;

public PermissionGroup(String permissionName, int permissionIconRes) {
Expand All @@ -30,12 +31,14 @@ public PermissionGroup(String permissionName, int permissionIconRes) {
*/
static {
//CalendarChecker
PermissionGroup calendarGroup = new PermissionGroup(CalendarChecker.PERMISSION_NAME, CalendarChecker.PERMISSION_ICON_RES);
PermissionGroup calendarGroup = new PermissionGroup(CalendarChecker.PERMISSION_NAME,
CalendarChecker.PERMISSION_ICON_RES);
permissionGroupHashMap.put(Manifest.permission.READ_CALENDAR, calendarGroup);
permissionGroupHashMap.put(Manifest.permission.WRITE_CALENDAR, calendarGroup);

//PhoneChecker
PermissionGroup phoneGroup = new PermissionGroup(PhoneChecker.PERMISSION_NAME, PhoneChecker.PERMISSION_ICON_RES);
PermissionGroup phoneGroup = new PermissionGroup(PhoneChecker.PERMISSION_NAME,
PhoneChecker.PERMISSION_ICON_RES);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
permissionGroupHashMap.put(Manifest.permission.READ_CALL_LOG, phoneGroup);
permissionGroupHashMap.put(Manifest.permission.WRITE_CALL_LOG, phoneGroup);
Expand All @@ -50,27 +53,32 @@ public PermissionGroup(String permissionName, int permissionIconRes) {
permissionGroupHashMap.put(Manifest.permission.ADD_VOICEMAIL, phoneGroup);

//CameraChecker
PermissionGroup cameraGroup = new PermissionGroup(CameraChecker.PERMISSION_NAME, CameraChecker.PERMISSION_ICON_RES);
PermissionGroup cameraGroup = new PermissionGroup(CameraChecker.PERMISSION_NAME,
CameraChecker.PERMISSION_ICON_RES);
permissionGroupHashMap.put(Manifest.permission.CAMERA, cameraGroup);

//ContactsChecker
PermissionGroup contactsGroup = new PermissionGroup(ContactsChecker.PERMISSION_NAME, ContactsChecker.PERMISSION_ICON_RES);
PermissionGroup contactsGroup = new PermissionGroup(ContactsChecker.PERMISSION_NAME,
ContactsChecker.PERMISSION_ICON_RES);
permissionGroupHashMap.put(Manifest.permission.READ_CONTACTS, contactsGroup);
permissionGroupHashMap.put(Manifest.permission.WRITE_CONTACTS, contactsGroup);
permissionGroupHashMap.put(Manifest.permission.GET_ACCOUNTS, contactsGroup);

//LocationChecker
PermissionGroup locationGroup = new PermissionGroup(LocationChecker.PERMISSION_NAME, LocationChecker.PERMISSION_ICON_RES);
PermissionGroup locationGroup = new PermissionGroup(LocationChecker.PERMISSION_NAME,
LocationChecker.PERMISSION_ICON_RES);
permissionGroupHashMap.put(Manifest.permission.ACCESS_FINE_LOCATION, locationGroup);
permissionGroupHashMap.put(Manifest.permission.ACCESS_COARSE_LOCATION, locationGroup);
permissionGroupHashMap.put("android.permission.ACCESS_BACKGROUND_LOCATION", locationGroup);

//MicrophoneChecker
PermissionGroup microphoneGroup = new PermissionGroup(MicrophoneChecker.PERMISSION_NAME, MicrophoneChecker.PERMISSION_ICON_RES);
PermissionGroup microphoneGroup = new PermissionGroup(MicrophoneChecker.PERMISSION_NAME,
MicrophoneChecker.PERMISSION_ICON_RES);
permissionGroupHashMap.put(Manifest.permission.RECORD_AUDIO, microphoneGroup);

//SensorsChecker
PermissionGroup sensorsGroup = new PermissionGroup(SensorsChecker.PERMISSION_NAME, SensorsChecker.PERMISSION_ICON_RES);
PermissionGroup sensorsGroup = new PermissionGroup(SensorsChecker.PERMISSION_NAME,
SensorsChecker.PERMISSION_ICON_RES);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
permissionGroupHashMap.put(Manifest.permission.BODY_SENSORS, sensorsGroup);
}
Expand All @@ -84,7 +92,8 @@ public PermissionGroup(String permissionName, int permissionIconRes) {
permissionGroupHashMap.put(Manifest.permission.RECEIVE_MMS, smsGroup);

//StorageChecker
PermissionGroup storageGroup = new PermissionGroup(StorageChecker.PERMISSION_NAME, StorageChecker.PERMISSION_ICON_RES);
PermissionGroup storageGroup = new PermissionGroup(StorageChecker.PERMISSION_NAME,
StorageChecker.PERMISSION_ICON_RES);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
permissionGroupHashMap.put(Manifest.permission.READ_EXTERNAL_STORAGE, storageGroup);
}
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ android 权限库,超级简单好用!!

![](https://github.com/bugyun/MissPermission/blob/master/art/down.png?raw=true)

## 版本变化

- 1.0.0 : 优化代码
- 1.0.1 : 优化流程,增加真实检测权限方法,优化不必要的代码
- 1.0.2 : 优化图片大小,体积减小50%

### 配置
```xml
implementation 'vip.ruoyun.permission:miss-pro:1.0.1'
implementation 'vip.ruoyun.permission:miss-pro:1.0.2'
```

### 准备工作
Expand Down Expand Up @@ -194,11 +200,6 @@ public interface IAction extends AvoidOnResultHelper.ActivityCallback {
}
```


## 版本变化

- 1.0.0 : 优化代码

---

## MissPermission
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:28.0.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Expand All @@ -31,6 +31,6 @@ dependencies {
implementation 'vip.ruoyun.helper:screen-helper:1.0.2'
testImplementation 'junit:junit:4.12'
implementation project(':MissPermission')
// implementation project(':MissPermissionPro')
implementation 'vip.ruoyun.permission:miss-pro:1.0.1'
implementation project(':MissPermissionPro')
// implementation 'vip.ruoyun.permission:miss-pro:1.0.1'
}
25 changes: 12 additions & 13 deletions app/src/main/java/com/ruoyun/permission/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,6 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClick(View v) {
switch (v.getId()) {
case R.id.buttonCamera:
if (MissPermission.check(this, SMSChecker.NEED_PERMISSION)) {
Log.e(TAG, "有权限");
} else {
Log.e(TAG, "没有权限");
}

if (MissPermission.realCheck(this, Manifest.permission.READ_SMS)) {
Log.e(TAG, "有短信权限");

} else {
Log.e(TAG, "没有短信权限");
}

MissPermission.with(this)
// .permission(Manifest.permission.SEND_SMS)//
// .permission(Manifest.permission.RECEIVE_SMS)//
Expand Down Expand Up @@ -93,6 +80,18 @@ public void onFailure(PermissionRequest request) {

break;
case R.id.buttonAll:
if (MissPermission.check(this, SMSChecker.NEED_PERMISSION)) {
Log.e(TAG, "有权限");
} else {
Log.e(TAG, "没有权限");
}

if (MissPermission.realCheck(this, Manifest.permission.READ_SMS)) {
Log.e(TAG, "有短信权限");

} else {
Log.e(TAG, "没有短信权限");
}
break;
}
}
Expand Down

0 comments on commit 65046fa

Please sign in to comment.