Skip to content

Commit

Permalink
added runtime permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
commonsguy committed Jan 7, 2017
1 parent df7977d commit c3ef152
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Files/FilesEditor/app/build.gradle
Expand Up @@ -2,15 +2,15 @@ apply plugin: 'com.android.application'


dependencies { dependencies {
compile 'io.karim:materialtabs:2.0.2' compile 'io.karim:materialtabs:2.0.2'
compile 'com.android.support:support-v13:22.2.1' compile 'com.android.support:support-v13:25.1.0'
} }


android { android {
compileSdkVersion 22 compileSdkVersion 25
buildToolsVersion "22.0.1" buildToolsVersion "25.0.2"


defaultConfig { defaultConfig {
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 18 targetSdkVersion 25
} }
} }
20 changes: 9 additions & 11 deletions Files/FilesEditor/app/src/main/AndroidManifest.xml
@@ -1,30 +1,28 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<manifest package="com.commonsware.android.fileseditor" <manifest package="com.commonsware.android.fileseditor"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0"> android:versionName="1.0">


<uses-permission <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18"/>


<supports-screens <supports-screens
android:anyDensity="true" android:anyDensity="true"
android:largeScreens="true" android:largeScreens="true"
android:normalScreens="true" android:normalScreens="true"
android:smallScreens="true"/> android:smallScreens="true" />


<application <application
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:theme="@style/Theme.Apptheme" android:label="@string/app_name"
android:label="@string/app_name"> android:theme="@style/Theme.Apptheme">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />


<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
Expand Down
@@ -1,5 +1,5 @@
/*** /***
Copyright (c) 2012-2015 CommonsWare, LLC Copyright (c) 2012-2017 CommonsWare, LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not 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 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 of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
Expand All @@ -14,15 +14,28 @@


package com.commonsware.android.fileseditor; package com.commonsware.android.fileseditor;


import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.widget.Toast;
import io.karim.MaterialTabs; import io.karim.MaterialTabs;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;


public class MainActivity extends Activity { public class MainActivity extends AbstractPermissionActivity {
@Override @Override
public void onCreate(Bundle savedInstanceState) { protected String[] getDesiredPermissions() {
super.onCreate(savedInstanceState); return(new String[]{WRITE_EXTERNAL_STORAGE});
}

@Override
protected void onPermissionDenied() {
Toast
.makeText(this, R.string.msg_sorry, Toast.LENGTH_LONG)
.show();
finish();
}

@Override
protected void onReady(Bundle savedInstanceState) {
setContentView(R.layout.main); setContentView(R.layout.main);


ViewPager pager=(ViewPager)findViewById(R.id.pager); ViewPager pager=(ViewPager)findViewById(R.id.pager);
Expand Down
Expand Up @@ -38,10 +38,6 @@ public SampleAdapter(Context ctxt, FragmentManager mgr) {


@Override @Override
public int getCount() { public int getCount() {
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT) {
return(2);
}

return(3); return(3);
} }


Expand Down
1 change: 1 addition & 0 deletions Files/FilesEditor/app/src/main/res/values/strings.xml
Expand Up @@ -4,5 +4,6 @@
<string name="internal">Internal</string> <string name="internal">Internal</string>
<string name="external">External</string> <string name="external">External</string>
<string name="pub">Public</string> <string name="pub">Public</string>
<string name="msg_sorry">Sorry, but we need permission to continue!</string>


</resources> </resources>
2 changes: 1 addition & 1 deletion Files/FilesEditor/build.gradle
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.android.tools.build:gradle:2.2.3'


// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
Expand Down

0 comments on commit c3ef152

Please sign in to comment.