├── .gitignore ├── README.md ├── app ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── pl │ │ └── tajchert │ │ └── runpermissionswork │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── pl │ │ │ └── tajchert │ │ │ └── runpermissionswork │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── pl │ └── tajchert │ └── runpermissionswork │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── image └── task_structure.jpg └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | .idea/ 3 | build/ 4 | *.iml 5 | /local.properties 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android Workshop for Runtime Permissions 2 | 3 | Workshop will show you (by hand) how to migrage your app from API 22 to 23 and survive permission deny armageddon coming with Android Marshmallow release. 4 | 5 | There are two examples - one using Location, and one with phone call feature. I recommend going with second one as it is more interesting (Lint doesn't underline it and help you handle SecurityException). 6 | 7 | #How to start 8 | 9 | Prepare phone or emulator with API >= 23 (Android M). 10 | Connection to Internate in case you forgot to download SDK API = 22 and 23, emulator image, and for dependecies. 11 | 12 | Location example start with [9664218](https://github.com/tajchert/RuntimePermissionWorkshop/commit/9664218ddb5e5d1005502d53d988682db454f5c6) commit. 13 | 14 | Phone call (recommended) example start with [4ff6466](https://github.com/tajchert/RuntimePermissionWorkshop/commit/4ff64661d157491aa6ddddb7e9811cb1e75ac923) commit. 15 | 16 | And proceed to next commits, read comments and look for DIY TODO marks with tasks what to try yourself (they are solved with next commit). 17 | 18 | ![alt tag](https://raw.githubusercontent.com/tajchert/RuntimePermissionWorkshop/master/image/task_structure.jpg) 19 | 20 | Green - suggested scope where you should focus on. 21 | 22 | Green arrow - targetSdkVersion bump. 23 | 24 | Red arrow - task (more in code comment). 25 | 26 | Good luck! 27 | 28 | #Read at home 29 | 30 | Links I found useful on Runtime Permission topic. Can be a good read after a workshop. 31 | 32 | 33 | [Guide - Runtime Permission by Google](https://developer.android.com/preview/features/runtime-permissions.html) 34 | 35 | [Sample - Google Runtime Permission](https://github.com/googlesamples/android-RuntimePermissions?linkId=16169284) 36 | 37 | [Library - Monitoring permissions](https://github.com/tajchert/Nammu) 38 | 39 | [Library - Permission annotation for Fragment or Activity](https://github.com/webpartners/WPAndroidPermissions) 40 | 41 | [Library - Permission annotation for method](https://github.com/hotchemi/PermissionsDispatcher) 42 | 43 | [Article - Everything every Android Developer must know about new Android's Runtime Permission](http://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en) 44 | 45 | [Article - Understanding Permissions in Android M](http://code.tutsplus.com/articles/understanding-permissions-in-android-m--cms-24443) 46 | 47 | [Article - Exploring the new Android Permissions Model](https://medium.com/ribot-labs/exploring-the-new-android-permissions-model-ba1d5d6c0610#8de8) 48 | 49 | #TODO 50 | 51 | Add [PermissionsDispatcher](https://github.com/hotchemi/PermissionsDispatcher) library for easy asking using annotations. 52 | 53 | Add [RxPermissions](https://github.com/tbruyelle/RxPermissions)name says it all. 54 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "pl.tajchert.runpermissionswork" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.0' 26 | compile 'com.jakewharton:butterknife:7.0.1' 27 | compile 'com.android.support:design:23.1.0' 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Tajchert-Laptop\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/pl/tajchert/runpermissionswork/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package pl.tajchert.runpermissionswork; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/pl/tajchert/runpermissionswork/MainActivity.java: -------------------------------------------------------------------------------- 1 | package pl.tajchert.runpermissionswork; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | 9 | import butterknife.Bind; 10 | import butterknife.ButterKnife; 11 | import butterknife.OnClick; 12 | 13 | public class MainActivity extends AppCompatActivity { 14 | private static final String TAG = MainActivity.class.getSimpleName(); 15 | 16 | @Bind(R.id.main_layout) 17 | View mLayout;//We will use it later 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_main); 23 | ButterKnife.bind(this); 24 | } 25 | 26 | @Override 27 | protected void onResume() { 28 | super.onResume(); 29 | } 30 | 31 | @OnClick(R.id.buttonCall) 32 | public void clickButtCall() { 33 | callTest(); 34 | } 35 | 36 | 37 | private void callTest() { 38 | Intent intent = new Intent(Intent.ACTION_CALL); 39 | intent.setData(Uri.parse("tel:" + "11122233")); 40 | startActivity(intent); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 13 | 14 |