Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

Commit

Permalink
update some res file
Browse files Browse the repository at this point in the history
  • Loading branch information
jokermonn committed Aug 29, 2017
1 parent 5c287fa commit 08583de
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 51 deletions.
Binary file modified app-debug.apk
Binary file not shown.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
// umeng
annotationProcessor 'com.github.jokermonn:permissions4m:1.1.2-processor'
compile 'com.github.jokermonn:permissions4m:1.1.2-lib'
// compile project(':permissions4m-api')
// annotationProcessor project(':permissions4m-processor')
// annotationProcessor 'com.github.jokermonn:permissions4m:1.1.2-processor'
// compile 'com.github.jokermonn:permissions4m:1.1.2-lib'
compile project(':permissions4m-api')
annotationProcessor project(':permissions4m-processor')
compile 'com.umeng.analytics:analytics:6.1.2'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/joker/permissions4m/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

Expand Down Expand Up @@ -165,12 +166,15 @@ public void syncGranted(int code) {
switch (code) {
case LOCATION_CODE:
ToastUtil.show("地理位置权限授权成功 in activity with annotation");
Log.d("TAG", "syncGranted: 地理位置权限授权成功 in activity with annotation");
break;
case SENSORS_CODE:
ToastUtil.show("传感器权限授权成功 in activity with annotation");
Log.d("TAG", "syncGranted: 传感器权限授权成功 in activity with annotation");
break;
case CALENDAR_CODE:
ToastUtil.show("读取日历权限授权成功 in activity with annotation");
Log.d("TAG", "syncGranted: 读取日历权限授权成功 in activity with annotation");
break;
default:
break;
Expand All @@ -182,12 +186,15 @@ public void syncDenied(int code) {
switch (code) {
case LOCATION_CODE:
ToastUtil.show("地理位置权限授权失败 in activity with annotation");
Log.d("TAG", "syncDenied: 地理位置权限授权失败 in activity with annotation");
break;
case SENSORS_CODE:
ToastUtil.show("传感器权限授权失败 in activity with annotation");
Log.d("TAG", "syncDenied: 传感器权限授权失败 in activity with annotation");
break;
case CALENDAR_CODE:
ToastUtil.show("读取日历权限授权失败 in activity with annotation");
Log.d("TAG", "syncDenied: 读取日历权限授权失败 in activity with annotation");
break;
default:
break;
Expand All @@ -199,12 +206,15 @@ public void syncRationale(int code) {
switch (code) {
case LOCATION_CODE:
ToastUtil.show("请开启地理位置权限 in activity with annotation");
Log.d("TAG", "syncRationale: 请开启地理位置权限 in activity with annotation");
break;
case SENSORS_CODE:
ToastUtil.show("请开启传感器权限 in activity with annotation");
Log.d("TAG", "syncRationale: 请开启传感器权限 in activity with annotation");
break;
case CALENDAR_CODE:
ToastUtil.show("请开启读取日历权限 in activity with annotation");
Log.d("TAG", "syncRationale: 请开启读取日历权限 in activity with annotation");
break;
default:
break;
Expand Down
53 changes: 6 additions & 47 deletions app/src/main/java/com/joker/permissions4m/NormalFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ public class NormalFragment extends Fragment {
public static final int CALENDAR_CODE = 700;
public static final int SENSORS_CODE = 800;
public static final int LOCATION_CODE = 900;
private static final int READ_CALENDAR_CODE = 200;
private static final int SMS_CODE = 500;
private static final int AUDIO_CODE = 600;
private static final int PHONE_STATE_CODE = 1000;
private Button mCalendar;
private Button mSmsButton;
private Button mOneButton;
private Button mStateButton;
Expand All @@ -58,20 +56,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
mSmsButton = (Button) view.findViewById(R.id.btn_sms);
mOneButton = (Button) view.findViewById(R.id.btn_one);
mStateButton = (Button) view.findViewById(R.id.btn_state);
mCalendar = (Button) view.findViewById(R.id.btn_calendar);

// 读取日历申请
mCalendar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Permissions4M.get(NormalFragment.this)
.requestPermission(Manifest.permission.READ_CALENDAR)
.requestForce(true)
.requestPageType(Permissions4M.PageType.MANAGER_PAGE)
.requestCode(READ_CALENDAR_CODE)
.request();
}
});

// 短信申请
mSmsButton.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -123,7 +107,8 @@ public void permissionRationale() {
@Override
public void pageIntent(final Intent intent) {
new AlertDialog.Builder(getActivity())
.setMessage("读取手机状态权限申请:\n我们需要您开启读取手机状态权限(in activity with listener)")
.setMessage("读取手机状态权限申请:\n我们需要您开启读取手机状态权限(in activity with " +
"listener)")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Expand Down Expand Up @@ -154,12 +139,9 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
}

//====================================================================
@PermissionsGranted({READ_CALENDAR_CODE, LOCATION_CODE, SENSORS_CODE, CALENDAR_CODE})
@PermissionsGranted({LOCATION_CODE, SENSORS_CODE, CALENDAR_CODE})
public void storageAndCallGranted(int code) {
switch (code) {
case READ_CALENDAR_CODE:
ToastUtil.show("读取日历权限授权成功 in fragment with annotation");
break;
case LOCATION_CODE:
ToastUtil.show("地理位置权限授权成功 in fragment with annotation");
break;
Expand All @@ -174,12 +156,9 @@ public void storageAndCallGranted(int code) {
}
}

@PermissionsDenied({READ_CALENDAR_CODE, LOCATION_CODE, SENSORS_CODE, CALENDAR_CODE})
@PermissionsDenied({LOCATION_CODE, SENSORS_CODE, CALENDAR_CODE})
public void storageAndCallDenied(int code) {
switch (code) {
case READ_CALENDAR_CODE:
ToastUtil.show("读取日历权限授权失败 in fragment with annotation");
break;
case LOCATION_CODE:
ToastUtil.show("地理位置权限授权失败 in fragment with annotation");
break;
Expand All @@ -194,12 +173,9 @@ public void storageAndCallDenied(int code) {
}
}

@PermissionsRationale({READ_CALENDAR_CODE, LOCATION_CODE, SENSORS_CODE, CALENDAR_CODE})
@PermissionsRationale({LOCATION_CODE, SENSORS_CODE, CALENDAR_CODE})
public void storageAndCallRationale(int code) {
switch (code) {
case READ_CALENDAR_CODE:
ToastUtil.show("请开启读取日历权限授权 in fragment with annotation");
break;
case LOCATION_CODE:
ToastUtil.show("请开启地理位置权限 in fragment with annotation");
break;
Expand Down Expand Up @@ -283,7 +259,7 @@ public void onClick(DialogInterface dialog, int which) {
}
}

@PermissionsNonRationale({SMS_CODE, READ_CALENDAR_CODE})
@PermissionsNonRationale({SMS_CODE})
public void nonRationale(int code, final Intent intent) {
switch (code) {
case SMS_CODE:
Expand All @@ -303,23 +279,6 @@ public void onClick(DialogInterface dialog, int which) {
})
.show();
break;
case READ_CALENDAR_CODE:
new AlertDialog.Builder(getActivity())
.setMessage("读取日历权限申请:\n我们需要您开启读取日历权限(in fragment with annotation)")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(intent);
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.show();
break;
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_normal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="读取日历(多参数注解回调)"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_fragment"/>
Expand Down

0 comments on commit 08583de

Please sign in to comment.