Skip to content

Commit

Permalink
1、完善示例
Browse files Browse the repository at this point in the history
  • Loading branch information
zincPower committed Apr 19, 2018
1 parent c010cc2 commit 8ab8f2b
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".manu.MyTestMenu" />

<service android:name=".MyService" />
</application>

Expand Down
30 changes: 25 additions & 5 deletions app/src/main/java/com/zinc/jpermission/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import android.Manifest;
import android.content.Intent;
import android.os.Environment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.zinc.jpermission.manu.MyTestGenymotionMenu;
import com.zinc.libpermission.annotation.Permission;
import com.zinc.libpermission.annotation.PermissionCanceled;
import com.zinc.libpermission.annotation.PermissionDenied;
Expand All @@ -19,8 +19,6 @@
import com.zinc.libpermission.utils.JPermissionHelper;
import com.zinc.libpermission.utils.JPermissionUtil;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -37,6 +35,9 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.btn_request_200).setOnClickListener(this);
findViewById(R.id.btn_service).setOnClickListener(this);

//设置各自品牌的系统权限页
// JPermissionUtil.setManuFacturer("genymotion", MyTestGenymotionMenu.class);

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.frame_layout, new MyFragment());
transaction.commit();
Expand Down Expand Up @@ -90,8 +91,22 @@ private void requestOnePermission() {
private void requestAllExclue() {
List<String> excluePermission = new ArrayList<>();
excluePermission.add(Manifest.permission.CAMERA);
excluePermission.add(Manifest.permission.ACCESS_FINE_LOCATION);
JPermissionUtil.requestAllPermission(this, excluePermission);
JPermissionUtil.requestAllPermission(this, excluePermission, new IPermission() {
@Override
public void ganted() {

}

@Override
public void denied(int requestCode, List<String> denyList) {

}

@Override
public void canceled(int requestCode) {

}
});
}

private void requestAll() {
Expand Down Expand Up @@ -123,6 +138,11 @@ private void cancelCode200(CancelInfo cancelInfo){
Toast.makeText(this, "cancel__200", Toast.LENGTH_SHORT).show();
}

@PermissionDenied(requestCode = 200)
private void denyCode200(DenyInfo denyInfo){
Toast.makeText(this, "deny__200", Toast.LENGTH_SHORT).show();
}

@PermissionCanceled()
private void cancel(CancelInfo cancelInfo) {
Log.i(JPermissionHelper.TAG, "writeCancel: " + cancelInfo.getRequestCode());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.zinc.jpermission.manu;

import android.content.Context;
import android.content.Intent;

import com.zinc.libpermission.menu.base.IMenu;

/**
* @author Jiang zinc
* @date 创建时间:2018/4/18
* @description
*/

public class MyTestGenymotionMenu implements IMenu {

@Override
public Intent getMenuIntent(Context context) {
Intent intent = new Intent(context, MyTestMenu.class);

return intent;
}

}
22 changes: 22 additions & 0 deletions app/src/main/java/com/zinc/jpermission/manu/MyTestMenu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.zinc.jpermission.manu;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.zinc.jpermission.R;

/**
* @author Jiang zinc
* @date 创建时间:2018/4/18
* @description
*/

public class MyTestMenu extends Activity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_manu);
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_test_manu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="测试系统权限页——genymotion"
android:gravity="center"
/>

</android.support.constraint.ConstraintLayout>

0 comments on commit 8ab8f2b

Please sign in to comment.