Skip to content

Commit

Permalink
remove unnecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Elmas authored and Can Elmas committed Nov 1, 2015
1 parent 9834121 commit beeb5ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
10 changes: 0 additions & 10 deletions let-runtime/src/main/java/com/canelmas/let/Let.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,13 @@ public static void handle(int requestCode, String[] permissions, int[] grantResu

if (grantResults[k] == PackageManager.PERMISSION_DENIED) {

/**
* TODO: 23/10/15
* come up with a way to distinguish 'Never Ask Again' state here,
* without second advice and without iterating permissions again
*
* only reason for second advice is that we can't access context here
* and the listener
*/

DelayedTasks.remove(delayedTask);

return;
}

}

// required permissions are granted so proceed
try {
Logger.log("<<< Required permissions granted");
delayedTask.execute();
Expand Down
2 changes: 0 additions & 2 deletions let-runtime/src/main/java/com/canelmas/let/LetAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public Object adviceForAskPermissionAnnotatedMethods(final ProceedingJoinPoint j
@Around("execution(* *.onRequestPermissionsResult(..)) && target(tar) && this(source)")
public void adviceForOnRequestPermissionsResult(final ProceedingJoinPoint joinPoint, Object tar, Object source) throws Throwable {

// TODO: 27/10/15 avoid unnecessary calls to this aspect

// make sure onRequestPermissionsResult() is executed
joinPoint.proceed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ protected Object proceed() {
return proceed(false);
}

private Object proceed(final boolean skipRationale) {
private Object proceed(final boolean retry) {

MethodSignature signature = (MethodSignature) joinPoint.getSignature();

final String[] permissionList = signature.getMethod().getAnnotation(AskPermission.class).value();

Logger.log(">>> " + signature.getName() + "() requires " + permissionList.length + " permission");
/**
* Permissions to ask and to show rationales
*/

// Permissions to ask and to show rationales
final List<String> permissionsToAsk = new ArrayList<>();
final List<String> permissionsToExplain = new ArrayList<>();

Expand All @@ -70,7 +69,6 @@ private Object proceed(final boolean skipRationale) {

Logger.log("\t" + permission);

// check if permission name is valid
if (!isPermissionValid(permission)) {
throw new LetException("Permission not valid!");
} else {
Expand All @@ -79,12 +77,12 @@ private Object proceed(final boolean skipRationale) {

Logger.log("\t\talreadyGranted=" + String.valueOf(permissionResult != -1));

if (permissionResult == PackageManager.PERMISSION_DENIED) {
if (permissionResult != PackageManager.PERMISSION_GRANTED) {

final boolean shouldShowRationale = ActivityCompat.shouldShowRequestPermissionRationale(letContext.getActivity(), permission);
Logger.log("\t\tshowRationale=" + shouldShowRationale);
final boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(letContext.getActivity(), permission);
Logger.log("\t\tshowRationale=" + showRationale);

if (shouldShowRationale && !skipRationale) {
if (showRationale && !retry) {

permissionsToExplain.add(permission);

Expand Down Expand Up @@ -117,20 +115,23 @@ private Object proceed(final boolean skipRationale) {
} else {
throw new LetException(source + " should implement RuntimePermissionListener");
}

return null;

} else if (!permissionsToAsk.isEmpty()) {

final int requestCode = PERMISSIONS_REQUEST_CODE.getAndIncrement();
Logger.log("<<< Making permission request");

final int requestCode = PERMISSIONS_REQUEST_CODE.getAndIncrement();

DelayedTasks.add(new DelayedTasks.Task(permissionsToAsk, requestCode, joinPoint));

letContext.requestPermissions(permissionsToAsk.toArray(new String[]{}), requestCode);

} else {

Logger.log("<<< Permissions granted");

try {
return joinPoint.proceed();
} catch (Throwable t) {
Expand All @@ -139,7 +140,6 @@ private Object proceed(final boolean skipRationale) {

}

// actual method not called
return null;
}

Expand Down

0 comments on commit beeb5ac

Please sign in to comment.