Skip to content

Commit

Permalink
Merge pull request #1 from erikeelde/feature/fix_rotation_multiple_ra…
Browse files Browse the repository at this point in the history
…tionale_dialogs

Feature/fix rotation multiple rationale dialogs
  • Loading branch information
erikeelde authored Nov 15, 2017
2 parents 9069a9f + 810cc77 commit 50a8de0
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 85 deletions.
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: android
jdk: oraclejdk8

android:
components:
- tools
- platform-tools

before_install:
# Install SDK license so Android Gradle plugin can install deps.
- mkdir "$ANDROID_HOME/licenses" || true
- echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- yes | sdkmanager tools


script:
- ./gradlew check test

sudo: false

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
11 changes: 5 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
compileSdkVersion 27

dataBinding {
enabled = true
}
defaultConfig {
applicationId "se.eelde.granter.app"
minSdkVersion 17
targetSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -27,9 +27,8 @@ android {
}

dependencies {
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support:support-v4:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation project(path: ':granter')

compile 'com.greysonparrelli.permiso:permiso:0.3.0'
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ protected void onCreate(Bundle savedInstanceState) {

binding.regularPermission.setOnClickListener(view -> RegularPermissionActivity.start(this));

binding.buttonPermisoPermission.setOnClickListener(view -> PermisoPermissionActivity.start(this));

binding.permission1Button.setOnClickListener(view -> new Granter.Builder(this)
.requestCode(RC_CAMERA)
.addPermission(Manifest.permission.CAMERA)
Expand Down
16 changes: 1 addition & 15 deletions app/src/main/res/layout/activity_permission_requesting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
android:text="@string/permission_1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_permiso_permission" />

app:layout_constraintTop_toBottomOf="@+id/regular_permission" />

<Button
android:id="@+id/permission_2_button"
Expand Down Expand Up @@ -67,18 +66,5 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/permission_multiple_button" />

<Button
android:id="@+id/button_permiso_permission"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Permiso permission"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/regular_permission" />


</android.support.constraint.ConstraintLayout>
</layout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta5'
classpath 'com.android.tools.build:gradle:3.0.0'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
12 changes: 5 additions & 7 deletions granter/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"


compileSdkVersion 27

defaultConfig {
minSdkVersion 15
targetSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"

Expand All @@ -23,7 +21,7 @@ android {
}

dependencies {
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:appcompat-v7:27.0.1'

api 'pub.devrel:easypermissions:1.0.0'
api 'pub.devrel:easypermissions:1.0.1'
}
2 changes: 1 addition & 1 deletion granter/src/main/java/se/eelde/granter/Granter.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static class Builder {
private final FragmentManager fragmentManager;
private final ArrayList<String> permissions = new ArrayList<>();
private final Resources resources;
private int requestCode;
private int requestCode = 7896;
private String rationale = null;
private String systemSettingRationale = null;

Expand Down
10 changes: 6 additions & 4 deletions granter/src/main/java/se/eelde/granter/GranterFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
shouldHaveShownRationale = Stolen.shouldShowRationale(this, requestedPermissions);

if (!EasyPermissions.hasPermissions(getContext(), requestedPermissions)) {
EasyPermissions.requestPermissions(this,
rationale,
RC_PERMISSIONS,
requestedPermissions);
if (savedInstanceState == null) {
EasyPermissions.requestPermissions(this,
rationale,
RC_PERMISSIONS,
requestedPermissions);
}
} else {
int[] ints = new int[requestedPermissions.length];
Arrays.fill(ints, PackageManager.PERMISSION_GRANTED);
Expand Down

0 comments on commit 50a8de0

Please sign in to comment.