Skip to content

Commit

Permalink
Merge pull request #135 from ParkSangGwon/split-tedpermission-util
Browse files Browse the repository at this point in the history
Split tedpermission util
  • Loading branch information
ParkSangGwon authored Oct 27, 2021
2 parents c0fac70 + 393f046 commit b97ba2e
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import androidx.appcompat.app.AppCompatActivity;

import com.gun0912.tedpermission.TedPermissionUtil;
import com.gun0912.tedpermission.normal.TedPermission;

import java.util.List;
Expand All @@ -27,9 +28,9 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.btn_coroutine).setOnClickListener(this);
findViewById(R.id.btn_windowPermission).setOnClickListener(this);

boolean isGranted = TedPermission.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION);
boolean isGranted = TedPermissionUtil.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION);
Log.d("ted", "isGranted: " + isGranted);
List<String> deniedPermissions = TedPermission.getDeniedPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION);
List<String> deniedPermissions = TedPermissionUtil.getDeniedPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION);
Log.d("ted", "deniedPermissions: " + deniedPermissions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import androidx.appcompat.app.AppCompatActivity;

import com.gun0912.tedpermission.PermissionListener;
import com.gun0912.tedpermission.TedPermissionUtil;
import com.gun0912.tedpermission.normal.TedPermission;

import java.util.List;
Expand All @@ -22,7 +23,7 @@ public class WindowPermissionActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

boolean isAlertWindowPermissionGranted = TedPermission.isGranted(Manifest.permission.SYSTEM_ALERT_WINDOW);
boolean isAlertWindowPermissionGranted = TedPermissionUtil.isGranted(Manifest.permission.SYSTEM_ALERT_WINDOW);
Log.d("ted", "isAlertWindowPermissionGranted: " + isAlertWindowPermissionGranted);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package com.gun0912.tedpermission.coroutine
import android.annotation.SuppressLint
import com.gun0912.tedpermission.PermissionBuilder
import com.gun0912.tedpermission.PermissionListener
import com.gun0912.tedpermission.TedPermissionBase
import com.gun0912.tedpermission.TedPermissionResult
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

@SuppressLint("StaticFieldLeak")
object TedPermission : TedPermissionBase() {
object TedPermission {

fun create(): Builder = Builder()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.gun0912.tedpermission.normal;

import com.gun0912.tedpermission.PermissionBuilder;
import com.gun0912.tedpermission.TedPermissionBase;

public class TedPermission extends TedPermissionBase {
public class TedPermission {
public static final String TAG = TedPermission.class.getSimpleName();

public static Builder create() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gun0912.tedpermission.PermissionBuilder;
import com.gun0912.tedpermission.PermissionListener;
import com.gun0912.tedpermission.TedPermissionBase;
import com.gun0912.tedpermission.TedPermissionResult;

import java.util.List;
Expand All @@ -11,7 +10,7 @@
import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;

public class TedPermission extends TedPermissionBase {
public class TedPermission {

public static Builder create() {
return new Builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gun0912.tedpermission.PermissionBuilder;
import com.gun0912.tedpermission.PermissionListener;
import com.gun0912.tedpermission.TedPermissionBase;
import com.gun0912.tedpermission.TedPermissionResult;

import java.util.List;
Expand All @@ -13,7 +12,7 @@
import io.reactivex.rxjava3.core.SingleOnSubscribe;


public class TedPermission extends TedPermissionBase {
public class TedPermission {

public static Builder create() {
return new Builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected void checkPermissions() {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
TedPermissionActivity.startActivity(context, intent, listener);
TedPermissionBase.setFirstRequest(permissions);
TedPermissionUtil.setFirstRequest(permissions);
}

public T setPermissionListener(PermissionListener listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -168,7 +167,7 @@ private void checkPermissions(boolean fromOnActivityResult) {
needPermissions.add(permission);
}
} else {
if (TedPermissionBase.isDenied(permission)) {
if (TedPermissionUtil.isDenied(permission)) {
needPermissions.add(permission);
}
}
Expand Down Expand Up @@ -259,7 +258,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
@NonNull int[] grantResults) {

super.onRequestPermissionsResult(requestCode, permissions, grantResults);
List<String> deniedPermissions = TedPermissionBase.getDeniedPermissions(permissions);
List<String> deniedPermissions = TedPermissionUtil.getDeniedPermissions(permissions);

if (deniedPermissions.isEmpty()) {
permissionResult(null);
Expand Down Expand Up @@ -297,7 +296,7 @@ public void onClick(DialogInterface dialogInterface, int i) {
builder.setPositiveButton(settingButtonText, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TedPermissionBase.startSettingActivityForResult(TedPermissionActivity.this);
TedPermissionUtil.startSettingActivityForResult(TedPermissionActivity.this);

}
});
Expand Down Expand Up @@ -356,7 +355,7 @@ public void onClick(DialogInterface dialog, int which) {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case TedPermissionBase.REQ_CODE_REQUEST_SETTING:
case TedPermissionUtil.REQ_CODE_REQUEST_SETTING:
checkPermissions(true);
break;
case REQ_CODE_SYSTEM_ALERT_WINDOW_PERMISSION_REQUEST: // 최초 ALERT WINDOW 요청에 대한 결과
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Created by TedPark on 2017. 9. 26..
*/

public abstract class TedPermissionBase {
public class TedPermissionUtil {
public static final int REQ_CODE_REQUEST_SETTING = 2000;
private static final String PREFS_NAME_PERMISSION = "PREFS_NAME_PERMISSION";
private static final String PREFS_IS_FIRST_REQUEST = "IS_FIRST_REQUEST";
Expand Down

0 comments on commit b97ba2e

Please sign in to comment.