Revision e3efd628
Added by Leszek Koltunski almost 8 years ago
build.gradle | ||
---|---|---|
20 | 20 |
|
21 | 21 |
dependencies { |
22 | 22 |
compile project(':distorted-library') |
23 |
compile "com.android.support:support-v4:23.4.0" |
|
23 | 24 |
} |
src/main/AndroidManifest.xml | ||
---|---|---|
7 | 7 |
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="23" /> |
8 | 8 |
<uses-feature android:glEsVersion="0x00020000" android:required="true" /> |
9 | 9 |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
10 |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
|
10 | 11 |
|
11 | 12 |
<application android:icon="@drawable/icon" android:label="@string/app_name" android:allowBackup="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> |
12 | 13 |
<activity android:name=".TableOfContents"> |
src/main/java/org/distorted/examples/save/SaveActivity.java | ||
---|---|---|
22 | 22 |
import org.distorted.library.Distorted; |
23 | 23 |
import org.distorted.examples.R; |
24 | 24 |
|
25 |
import android.Manifest; |
|
25 | 26 |
import android.app.Activity; |
27 |
import android.content.pm.PackageManager; |
|
26 | 28 |
import android.opengl.GLSurfaceView; |
27 | 29 |
import android.os.Bundle; |
30 |
import android.support.v4.app.ActivityCompat; |
|
28 | 31 |
import android.view.View; |
29 | 32 |
import android.widget.SeekBar; |
30 | 33 |
|
... | ... | |
32 | 35 |
|
33 | 36 |
public class SaveActivity extends Activity implements SeekBar.OnSeekBarChangeListener |
34 | 37 |
{ |
38 |
private static final int REQUEST_EXTERNAL_STORAGE = 1; |
|
39 |
private static String[] PERMISSIONS_STORAGE = |
|
40 |
{ |
|
41 |
Manifest.permission.READ_EXTERNAL_STORAGE, |
|
42 |
Manifest.permission.WRITE_EXTERNAL_STORAGE |
|
43 |
}; |
|
44 |
|
|
45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
46 |
// Checks if the app has permission to write to device storage |
|
47 |
// If the app does not has permission then the user will be prompted to grant permissions |
|
48 |
|
|
49 |
private void verifyStoragePermissions() |
|
50 |
{ |
|
51 |
int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE); |
|
52 |
|
|
53 |
if (permission != PackageManager.PERMISSION_GRANTED) |
|
54 |
{ |
|
55 |
ActivityCompat.requestPermissions( this, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE ); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
35 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 60 |
|
37 | 61 |
@Override |
... | ... | |
85 | 109 |
|
86 | 110 |
public void Save(View v) |
87 | 111 |
{ |
112 |
verifyStoragePermissions(); |
|
113 |
|
|
88 | 114 |
SaveSurfaceView view = (SaveSurfaceView) this.findViewById(R.id.saveSurfaceView); |
89 | 115 |
view.getRenderer().Save(); |
90 | 116 |
} |
src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
---|---|---|
35 | 35 |
import org.distorted.library.EffectTypes; |
36 | 36 |
import org.distorted.library.type.Dynamic1D; |
37 | 37 |
import org.distorted.library.type.Static1D; |
38 |
import org.distorted.library.type.Static2D; |
|
39 | 38 |
import org.distorted.library.type.Static3D; |
40 | 39 |
import org.distorted.library.type.Static4D; |
41 | 40 |
|
src/main/java/org/distorted/examples/save/SaveWorkerThread.java | ||
---|---|---|
58 | 58 |
|
59 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 60 |
|
61 |
public SaveWorkerThread()
|
|
61 |
private SaveWorkerThread()
|
|
62 | 62 |
{ |
63 | 63 |
} |
64 | 64 |
|
Also available in: Unified diff
Fix the 'Save' app on Android API >=23 (we need to explicitly ask for write permission)