Skip to content

Commit

Permalink
add permissionDis
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchaoxu committed Sep 23, 2016
1 parent b8b1959 commit cec70b6
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 54 deletions.
15 changes: 11 additions & 4 deletions bone/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
apply plugin: 'com.android.library'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'me.tatarka.retrolambda'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

compileOptions {
sourceCompatibility rootProject.ext.sourceCompatibility
targetCompatibility rootProject.ext.targetCompatibility
}

dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
Expand All @@ -20,10 +26,7 @@ android {
multiDexEnabled true
}

compileOptions {
sourceCompatibility rootProject.ext.sourceCompatibility
targetCompatibility rootProject.ext.targetCompatibility
}

buildTypes {
release {
minifyEnabled false
Expand Down Expand Up @@ -60,6 +63,10 @@ dependencies {
compile deps.rxpermissions
compile deps.rxpreferences

// permissionsDispatcher
compile deps.permissionsDispatcher
apt deps.permissionsDispatcherProcessor

// db
compile deps.dbflowcore
compile deps.dbflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,16 @@ private ArrayList<String> removeMoreItem() {
return list;
}


@Override
public int getItemCount() {
return mPhotoPaths.size();
}

public static class PhotoViewHolder extends RecyclerView.ViewHolder {
class PhotoViewHolder extends RecyclerView.ViewHolder {
private ImageView ivPhoto;
private View vSelected;

public PhotoViewHolder(View itemView) {
PhotoViewHolder(View itemView) {
super(itemView);
ivPhoto = (ImageView) itemView.findViewById(R.id.iv_photo);
vSelected = itemView.findViewById(R.id.v_selected);
Expand Down
62 changes: 62 additions & 0 deletions bone/src/main/java/com/idogfooding/bone/utils/AppInfoUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.idogfooding.bone.utils;

import android.content.Context;
import android.content.pm.PackageInfo;

/**
* AppInfoUtils
*
* @author Charles
*/
public class AppInfoUtils {

/**
* get package info
* @param context
* @return
*/
public static PackageInfo getPackageInfo(Context context) {
try {
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}

/**
* get package name
*/
public static String getPackageName(Context context) {
try {
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).packageName;
} catch (Exception e) {
e.printStackTrace();
return "";
}
}

/**
* get the current version name
*/
public static String getVersionName(Context context) {
try {
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
} catch (Exception e) {
e.printStackTrace();
return "";
}
}

/**
* get the current versionCode
*/
public static int getVersionCode(Context context) {
try {
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
}
21 changes: 11 additions & 10 deletions bone/src/main/java/com/idogfooding/bone/utils/SettingsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
public class SettingsUtils {

public static Intent openApplicationSettings(String packageName) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + packageName));
return intent;
}
return new Intent();
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + packageName));
return intent;
}

public static void openApplicationSettings(Context context, String packageName) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
Intent intent = openApplicationSettings(packageName);
context.startActivity(intent);
}
Intent intent = openApplicationSettings(packageName);
context.startActivity(intent);
}

public static void openApplicationSettings(Context context) {
String packageName = AppInfoUtils.getPackageName(context);
Intent intent = openApplicationSettings(packageName);
context.startActivity(intent);
}

}
35 changes: 0 additions & 35 deletions bone/src/main/java/com/idogfooding/bone/utils/VersionUtils.java

This file was deleted.

1 change: 1 addition & 0 deletions bone/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<string name="close">关闭</string>
<string name="loading">加载中,请稍等&#8230;</string>
<string name="edit">编辑</string>
<string name="denied">拒绝</string>
<string name="agreement">我已经阅读并同意《用户使用协议》</string>

<!-- account -->
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ext {
targetSdkVersion = 24

// compileOptions
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

ext.deps = [
Expand Down

0 comments on commit cec70b6

Please sign in to comment.