-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- updated gradle files with latest updated deps
- removed jack - added runtime permission handling in sample app - updated gradle wrapper to 4.1
- Loading branch information
Showing
6 changed files
with
150 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/github/nisrulz/projectqreader/RPResultListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (C) 2016 Nishant Srivastava | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package github.nisrulz.projectqreader; | ||
|
||
interface RPResultListener { | ||
void onPermissionGranted(); | ||
|
||
void onPermissionDenied(); | ||
} |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/github/nisrulz/projectqreader/RuntimePermissionUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2016 Nishant Srivastava | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package github.nisrulz.projectqreader; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.pm.PackageManager; | ||
import android.support.v4.app.ActivityCompat; | ||
|
||
class RuntimePermissionUtil { | ||
|
||
private RuntimePermissionUtil() { | ||
|
||
} | ||
|
||
public static void onRequestPermissionsResult(int[] grantResults, | ||
RPResultListener rpResultListener) { | ||
if (grantResults.length > 0) { | ||
for (int grantResult : grantResults) { | ||
if (grantResult == PackageManager.PERMISSION_GRANTED) { | ||
rpResultListener.onPermissionGranted(); | ||
} else { | ||
rpResultListener.onPermissionDenied(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static void requestPermission(final Activity activity, final String[] permissions, | ||
final int REQUEST_CODE) { | ||
// No explanation needed, we can request the permission. | ||
ActivityCompat.requestPermissions(activity, permissions, REQUEST_CODE); | ||
} | ||
|
||
public static void requestPermission(final Activity activity, final String permission, | ||
final int REQUEST_CODE) { | ||
// No explanation needed, we can request the permission. | ||
ActivityCompat.requestPermissions(activity, new String[] { permission }, REQUEST_CODE); | ||
} | ||
|
||
public static boolean checkPermissonGranted(Context context, String permission) { | ||
return (ActivityCompat.checkSelfPermission(context, permission) | ||
== PackageManager.PERMISSION_GRANTED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,6 @@ | ||
# | ||
# Copyright (C) 2016 Nishant Srivastava | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
#Thu Sep 15 18:01:55 IST 2016 | ||
#Mon Aug 21 23:15:11 PDT 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip |