Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/main/java/agency/tango/materialintro/CustomSlide.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,14 @@ public boolean canMoveFurther() {
public String cantMoveFurtherErrorMessage() {
return getString(R.string.error_message);
}

@Override
public String[] possiblePermissions() {
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this after merging #75?

}

@Override
public String[] neededPermissions() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package agency.tango.materialintroscreen.fragments;

import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
Expand Down Expand Up @@ -43,6 +44,10 @@ public String[] neededPermissions() {
}

public boolean hasAnyPermissionsToGrant() {
if (!isAndroidVersionSupportingPermissions()) {
return false;
}

boolean hasPermissionToGrant = hasPermissionsToGrant(neededPermissions());
if (!hasPermissionToGrant) {
hasPermissionToGrant = hasPermissionsToGrant(possiblePermissions());
Expand Down Expand Up @@ -86,6 +91,10 @@ public void askForPermissions() {

@SuppressWarnings({"PMD.CollapsibleIfStatements"})
private boolean hasPermissionsToGrant(String[] permissions) {
if (!isAndroidVersionSupportingPermissions()) {
return false;
}

if (permissions != null) {
for (String permission : permissions) {
if (isNotNullOrEmpty(permission)) {
Expand All @@ -106,6 +115,10 @@ private String[] removeEmptyAndNullStrings(final ArrayList<String> permissions)
return list.toArray(new String[list.size()]);
}

private boolean isAndroidVersionSupportingPermissions() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
}

public static boolean isNotNullOrEmpty(String string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use TextUtils.isEmpty from Android SDK?

return string != null && !string.isEmpty();
}
Expand Down