diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-12-11 22:42:47 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-12-11 22:42:47 +0000 |
commit | a07e753ad5557e594147d6666ccbfa767312e663 (patch) | |
tree | e820db0126014efb926364c2e1599c0a90f368ae | |
parent | 52cc64417d7e1bca301553134f04a19770fb5b20 (diff) | |
parent | 30c7a4fe8521b48608486874ee5ccda1ad5a0041 (diff) | |
download | android-a07e753ad5557e594147d6666ccbfa767312e663.tar.gz |
Merge "Update RuntimePermissionsBasic Java sample." into oc-dev
19 files changed, 347 insertions, 124 deletions
diff --git a/system/RuntimePermissionsBasic/Application/.gitignore b/system/RuntimePermissionsBasic/Application/.gitignore deleted file mode 100644 index 6eb878d4..00000000 --- a/system/RuntimePermissionsBasic/Application/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2013 The Android Open Source Project -# -# 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. -src/template/ -src/common/ -build.gradle diff --git a/system/RuntimePermissionsBasic/Application/build.gradle b/system/RuntimePermissionsBasic/Application/build.gradle new file mode 100644 index 00000000..2a235317 --- /dev/null +++ b/system/RuntimePermissionsBasic/Application/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'com.android.application' + +repositories { + jcenter() + google() +} + +dependencies { + compile "com.android.support:support-v4:27.0.2" + compile "com.android.support:support-v13:27.0.2" + compile "com.android.support:cardview-v7:27.0.2" + compile "com.android.support:appcompat-v7:27.0.2" + compile 'com.android.support:design:27.0.2' +} + +List<String> dirs = ['main'] + +android { + compileSdkVersion 27 + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 27 + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + sourceSets { + main { + dirs.each { dir -> + java.srcDirs "src/${dir}/java" + res.srcDirs "src/${dir}/res" + } + } + androidTest.setRoot('tests') + androidTest.java.srcDirs = ['tests/src'] + + } +} diff --git a/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/MainActivity.java b/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/MainActivity.java index f534d407..ebc44840 100644 --- a/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/MainActivity.java +++ b/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/MainActivity.java @@ -16,20 +16,21 @@ package com.example.android.basicpermissions; -import com.example.android.basicpermissions.camera.CameraPreviewActivity; - import android.Manifest; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; +import com.example.android.basicpermissions.camera.CameraPreviewActivity; + /** * Launcher Activity that demonstrates the use of runtime permissions for Android M. * This Activity requests permissions to access the camera @@ -66,8 +67,7 @@ public class MainActivity extends AppCompatActivity mLayout = findViewById(R.id.main_layout); // Register a listener for the 'Show Camera Preview' button. - Button b = (Button) findViewById(R.id.button_open_camera); - b.setOnClickListener(new View.OnClickListener() { + findViewById(R.id.button_open_camera).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showCameraPreview(); @@ -76,20 +76,20 @@ public class MainActivity extends AppCompatActivity } @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, - int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, + @NonNull int[] grantResults) { // BEGIN_INCLUDE(onRequestPermissionsResult) if (requestCode == PERMISSION_REQUEST_CAMERA) { // Request for camera permission. if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Permission has been granted. Start camera preview Activity. - Snackbar.make(mLayout, "Camera permission was granted. Starting preview.", + Snackbar.make(mLayout, R.string.camera_permission_granted, Snackbar.LENGTH_SHORT) .show(); startCamera(); } else { // Permission request was denied. - Snackbar.make(mLayout, "Camera permission request was denied.", + Snackbar.make(mLayout, R.string.camera_permission_denied, Snackbar.LENGTH_SHORT) .show(); } @@ -104,7 +104,7 @@ public class MainActivity extends AppCompatActivity == PackageManager.PERMISSION_GRANTED) { // Permission is already available, start camera preview Snackbar.make(mLayout, - "Camera permission is available. Starting preview.", + R.string.camera_permission_available, Snackbar.LENGTH_SHORT).show(); startCamera(); } else { @@ -125,9 +125,9 @@ public class MainActivity extends AppCompatActivity Manifest.permission.CAMERA)) { // Provide an additional rationale to the user if the permission was not granted // and the user would benefit from additional context for the use of the permission. - // Display a SnackBar with a button to request the missing permission. - Snackbar.make(mLayout, "Camera access is required to display the camera preview.", - Snackbar.LENGTH_INDEFINITE).setAction("OK", new View.OnClickListener() { + // Display a SnackBar with cda button to request the missing permission. + Snackbar.make(mLayout, R.string.camera_access_required, + Snackbar.LENGTH_INDEFINITE).setAction(R.string.ok, new View.OnClickListener() { @Override public void onClick(View view) { // Request the permission @@ -138,12 +138,10 @@ public class MainActivity extends AppCompatActivity }).show(); } else { - Snackbar.make(mLayout, - "Permission is not available. Requesting camera permission.", - Snackbar.LENGTH_SHORT).show(); + Snackbar.make(mLayout, R.string.camera_unavailable, Snackbar.LENGTH_SHORT).show(); // Request the permission. The result will be received in onRequestPermissionResult(). - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, - PERMISSION_REQUEST_CAMERA); + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.CAMERA}, PERMISSION_REQUEST_CAMERA); } } diff --git a/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/camera/CameraPreview.java b/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/camera/CameraPreview.java index 7abf2d8d..db8eacf6 100644 --- a/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/camera/CameraPreview.java +++ b/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/camera/CameraPreview.java @@ -18,6 +18,7 @@ package com.example.android.basicpermissions.camera; import android.content.Context; import android.hardware.Camera; +import android.util.AttributeSet; import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; @@ -27,7 +28,7 @@ import java.io.IOException; /** * Camera preview that displays a {@link Camera}. - * + * <p> * Handles basic lifecycle methods to display and stop the preview. * <p> * Implementation is based directly on the documentation at @@ -36,14 +37,19 @@ import java.io.IOException; public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback { private static final String TAG = "CameraPreview"; + private SurfaceHolder mHolder; private Camera mCamera; private Camera.CameraInfo mCameraInfo; private int mDisplayOrientation; - public CameraPreview(Context context, Camera camera, Camera.CameraInfo cameraInfo, - int displayOrientation) { - super(context); + public CameraPreview(Context context, AttributeSet attrs, int defStyleAttr) { + this(context, attrs, defStyleAttr, null, null, 0); + } + + public CameraPreview(Context context, AttributeSet attrs, int defStyleAttr, + Camera camera, Camera.CameraInfo cameraInfo, int displayOrientation) { + super(context, attrs, defStyleAttr); // Do not initialise if no camera has been set if (camera == null || cameraInfo == null) { @@ -59,6 +65,41 @@ public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback mHolder.addCallback(this); } + /** + * Calculate the correct orientation for a {@link Camera} preview that is displayed on screen. + * <p> + * Implementation is based on the sample code provided in + * {@link Camera#setDisplayOrientation(int)}. + */ + public static int calculatePreviewOrientation(Camera.CameraInfo info, int rotation) { + int degrees = 0; + + switch (rotation) { + case Surface.ROTATION_0: + degrees = 0; + break; + case Surface.ROTATION_90: + degrees = 90; + break; + case Surface.ROTATION_180: + degrees = 180; + break; + case Surface.ROTATION_270: + degrees = 270; + break; + } + + int result; + if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { + result = (info.orientation + degrees) % 360; + result = (360 - result) % 360; // compensate the mirror + } else { // back-facing + result = (info.orientation - degrees + 360) % 360; + } + + return result; + } + public void surfaceCreated(SurfaceHolder holder) { // The Surface has been created, now tell the camera where to draw the preview. try { @@ -104,39 +145,4 @@ public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback Log.d(TAG, "Error starting camera preview: " + e.getMessage()); } } - - /** - * Calculate the correct orientation for a {@link Camera} preview that is displayed on screen. - * - * Implementation is based on the sample code provided in - * {@link Camera#setDisplayOrientation(int)}. - */ - public static int calculatePreviewOrientation(Camera.CameraInfo info, int rotation) { - int degrees = 0; - - switch (rotation) { - case Surface.ROTATION_0: - degrees = 0; - break; - case Surface.ROTATION_90: - degrees = 90; - break; - case Surface.ROTATION_180: - degrees = 180; - break; - case Surface.ROTATION_270: - degrees = 270; - break; - } - - int result; - if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { - result = (info.orientation + degrees) % 360; - result = (360 - result) % 360; // compensate the mirror - } else { // back-facing - result = (info.orientation - degrees + 360) % 360; - } - - return result; - } } diff --git a/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/camera/CameraPreviewActivity.java b/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/camera/CameraPreviewActivity.java index ee589d99..d7981d84 100644 --- a/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/camera/CameraPreviewActivity.java +++ b/system/RuntimePermissionsBasic/Application/src/main/java/com/example/android/basicpermissions/camera/CameraPreviewActivity.java @@ -16,14 +16,15 @@ package com.example.android.basicpermissions.camera; -import com.example.android.basicpermissions.R; - import android.app.Activity; import android.hardware.Camera; import android.os.Bundle; +import android.util.Log; import android.widget.FrameLayout; import android.widget.Toast; +import com.example.android.basicpermissions.R; + /** * Displays a {@link CameraPreview} of the first {@link Camera}. * An error message is displayed if the Camera is not available. @@ -36,15 +37,12 @@ import android.widget.Toast; * http://developer.android.com/guide/topics/media/camera.html */ public class CameraPreviewActivity extends Activity { - - private static final String TAG = "CameraPreview"; - + private static final String TAG = "CameraPreviewActivity"; /** * Id of the camera to access. 0 is the first camera. */ private static final int CAMERA_ID = 0; - private CameraPreview mPreview; private Camera mCamera; @Override @@ -56,22 +54,21 @@ public class CameraPreviewActivity extends Activity { Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); Camera.getCameraInfo(CAMERA_ID, cameraInfo); - if (mCamera == null || cameraInfo == null) { + if (mCamera == null) { // Camera is not available, display error message - Toast.makeText(this, "Camera is not available.", Toast.LENGTH_SHORT).show(); setContentView(R.layout.activity_camera_unavailable); } else { setContentView(R.layout.activity_camera); // Get the rotation of the screen to adjust the preview image accordingly. - final int displayRotation = getWindowManager().getDefaultDisplay() - .getRotation(); + int displayRotation = getWindowManager().getDefaultDisplay().getRotation(); // Create the Preview view and set it as the content of this Activity. - mPreview = new CameraPreview(this, mCamera, cameraInfo, displayRotation); - FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview); - preview.addView(mPreview); + CameraPreview cameraPreview = new CameraPreview(this, null, + 0, mCamera, cameraInfo, displayRotation); + FrameLayout preview = findViewById(R.id.camera_preview); + preview.addView(cameraPreview); } } @@ -82,22 +79,26 @@ public class CameraPreviewActivity extends Activity { releaseCamera(); } - /** A safe way to get an instance of the Camera object. */ + /** + * A safe way to get an instance of the Camera object. + */ private Camera getCameraInstance(int cameraId) { Camera c = null; try { c = Camera.open(cameraId); // attempt to get a Camera instance } catch (Exception e) { // Camera is not available (in use or does not exist) - Toast.makeText(this, "Camera " + cameraId + " is not available: " + e.getMessage(), - Toast.LENGTH_SHORT).show(); + Log.e(TAG, "Camera " + cameraId + " is not available: " + e.getMessage()); } return c; // returns null if camera is unavailable } + /** + * Release the camera for other applications. + */ private void releaseCamera() { if (mCamera != null) { - mCamera.release(); // release the camera for other applications + mCamera.release(); mCamera = null; } } diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/drawable-hdpi/tile.9.png b/system/RuntimePermissionsBasic/Application/src/main/res/drawable-hdpi/tile.9.png Binary files differnew file mode 100644 index 00000000..13586288 --- /dev/null +++ b/system/RuntimePermissionsBasic/Application/src/main/res/drawable-hdpi/tile.9.png diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_camera.xml b/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_camera.xml index b12eee19..1329717b 100644 --- a/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_camera.xml +++ b/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_camera.xml @@ -1,5 +1,5 @@ <!-- - Copyright 2015 The Android Open Source Project + Copyright 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,8 +15,7 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/camera_preview" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:layout_weight="1" - /> + android:id="@+id/camera_preview" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_weight="1" /> diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_camera_unavailable.xml b/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_camera_unavailable.xml index af0efe5d..0f9ecb9d 100644 --- a/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_camera_unavailable.xml +++ b/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_camera_unavailable.xml @@ -1,5 +1,5 @@ <!-- - Copyright 2015 The Android Open Source Project + Copyright 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,23 +15,16 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="@dimen/horizontal_page_margin" - android:paddingRight="@dimen/horizontal_page_margin" - android:paddingTop="@dimen/vertical_page_margin" - android:paddingBottom="@dimen/vertical_page_margin"> - - <ScrollView - android:layout_width="match_parent" - android:layout_height="fill_parent"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/camera_unavailable"/> - - </ScrollView> - + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:paddingBottom="@dimen/vertical_page_margin" + android:paddingLeft="@dimen/horizontal_page_margin" + android:paddingRight="@dimen/horizontal_page_margin" + android:paddingTop="@dimen/vertical_page_margin"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/camera_unavailable" /> </LinearLayout>
\ No newline at end of file diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_main.xml b/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_main.xml index 146b8b1e..838bbea4 100644 --- a/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_main.xml +++ b/system/RuntimePermissionsBasic/Application/src/main/res/layout/activity_main.xml @@ -14,9 +14,9 @@ limitations under the License. --> -<LinearLayout android:id="@+id/main_layout" - xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/main_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" @@ -32,10 +32,9 @@ android:layout_marginBottom="@dimen/horizontal_page_margin" android:text="@string/intro" /> - <Button android:id="@+id/button_open_camera" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Open Camera Preview" /> + android:text="@string/open_camera_preview" /> </LinearLayout> diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/values-sw600dp/dimens.xml b/system/RuntimePermissionsBasic/Application/src/main/res/values-sw600dp/dimens.xml new file mode 100644 index 00000000..9a0875e5 --- /dev/null +++ b/system/RuntimePermissionsBasic/Application/src/main/res/values-sw600dp/dimens.xml @@ -0,0 +1,24 @@ +<!-- + Copyright 2017 The Android Open Source Project + + 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. + --> + +<resources> + + <!-- Semantic definitions --> + + <dimen name="horizontal_page_margin">@dimen/margin_huge</dimen> + <dimen name="vertical_page_margin">@dimen/margin_medium</dimen> + +</resources> diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/values-sw600dp/styles.xml b/system/RuntimePermissionsBasic/Application/src/main/res/values-sw600dp/styles.xml new file mode 100644 index 00000000..04fbedfd --- /dev/null +++ b/system/RuntimePermissionsBasic/Application/src/main/res/values-sw600dp/styles.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright 2017 The Android Open Source Project + + 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. + --> + +<resources> + <style name="Widget.SampleMessage"> + <item name="android:textAppearance">?android:textAppearanceLarge</item> + <item name="android:lineSpacingMultiplier">1.2</item> + <item name="android:shadowDy">-6.5</item> + </style> +</resources>
\ No newline at end of file diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/values-v11/styles.xml b/system/RuntimePermissionsBasic/Application/src/main/res/values-v11/styles.xml new file mode 100644 index 00000000..447ef8b5 --- /dev/null +++ b/system/RuntimePermissionsBasic/Application/src/main/res/values-v11/styles.xml @@ -0,0 +1,22 @@ +<!-- + Copyright 2017 The Android Open Source Project + + 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. + --> + +<resources> + + <!-- Activity themes --> + <style name="Theme.Base" parent="android:Theme.Holo.Light" /> + +</resources> diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/values-v21/styles.xml b/system/RuntimePermissionsBasic/Application/src/main/res/values-v21/styles.xml new file mode 100644 index 00000000..f9074f71 --- /dev/null +++ b/system/RuntimePermissionsBasic/Application/src/main/res/values-v21/styles.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright 2017 The Android Open Source Project + + 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. + --> + +<resources> + <style name="Theme.Base" parent="android:Theme.Material.Light" /> +</resources>
\ No newline at end of file diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/values/dimens.xml b/system/RuntimePermissionsBasic/Application/src/main/res/values/dimens.xml new file mode 100644 index 00000000..ffa67a6b --- /dev/null +++ b/system/RuntimePermissionsBasic/Application/src/main/res/values/dimens.xml @@ -0,0 +1,32 @@ +<!-- + Copyright 2017 The Android Open Source Project + + 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. + --> + +<resources> + + <!-- Define standard dimensions to comply with Holo-style grids and rhythm. --> + + <dimen name="margin_tiny">4dp</dimen> + <dimen name="margin_small">8dp</dimen> + <dimen name="margin_medium">16dp</dimen> + <dimen name="margin_large">32dp</dimen> + <dimen name="margin_huge">64dp</dimen> + + <!-- Semantic definitions --> + + <dimen name="horizontal_page_margin">@dimen/margin_medium</dimen> + <dimen name="vertical_page_margin">@dimen/margin_medium</dimen> + +</resources> diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/values/strings.xml b/system/RuntimePermissionsBasic/Application/src/main/res/values/strings.xml index eb0b7c46..bc6b3867 100644 --- a/system/RuntimePermissionsBasic/Application/src/main/res/values/strings.xml +++ b/system/RuntimePermissionsBasic/Application/src/main/res/values/strings.xml @@ -1,6 +1,36 @@ +<!-- + Copyright 2017 The Android Open Source Project + + 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. + --> + <resources> <string name="show_camera">Show camera preview</string> <string name="camera_unavailable"><b>Camera could not be opened.</b>\nThis occurs when the camera is not available (for example it is already in use) or if the system has denied access (for example when camera access has been disabled).</string> <string name="intro">This sample shows a basic implementation for requesting permissions at runtime.\nClick the button below to request the Camera permission and open a full-screen camera preview.</string> + <string name="open_camera_preview">Open Camera Preview</string> + <string name="app_name">RuntimePermissionsBasic</string> + <string name="intro_message"><![CDATA[ +This sample shows a basic implementation for requesting permissions at runtime. Click the button to +request the Camera permission and open a full-screen camera preview. +Note: The "RuntimePermissions" sample provides a more complete overview over the runtime permission +features available.]]> + </string> + <string name="camera_access_required">Camera access is required to display the camera preview.</string> + <string name="ok">OK</string> + <string name="camera_permission_not_available">Permission is not available. Requesting camera permission.</string> + <string name="camera_permission_available">Camera permission is available. Starting preview.</string> + <string name="camera_permission_granted">Camera permission was granted. Starting preview.</string> + <string name="camera_permission_denied">Camera permission request was denied.</string> </resources> diff --git a/system/RuntimePermissionsBasic/Application/src/main/res/values/styles.xml b/system/RuntimePermissionsBasic/Application/src/main/res/values/styles.xml new file mode 100644 index 00000000..d88caa56 --- /dev/null +++ b/system/RuntimePermissionsBasic/Application/src/main/res/values/styles.xml @@ -0,0 +1,42 @@ +<!-- + Copyright 2017 The Android Open Source Project + + 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. + --> + +<resources> + + <!-- Activity themes --> + + <style name="Theme.Base" parent="android:Theme.Light" /> + + <style name="Theme.Sample" parent="Theme.Base" /> + + <style name="AppTheme" parent="Theme.Sample" /> + <!-- Widget styling --> + + <style name="Widget" /> + + <style name="Widget.SampleMessage"> + <item name="android:textAppearance">?android:textAppearanceMedium</item> + <item name="android:lineSpacingMultiplier">1.1</item> + </style> + + <style name="Widget.SampleMessageTile"> + <item name="android:background">@drawable/tile</item> + <item name="android:shadowColor">#7F000000</item> + <item name="android:shadowDy">-3.5</item> + <item name="android:shadowRadius">2</item> + </style> + +</resources> diff --git a/system/RuntimePermissionsBasic/build.gradle b/system/RuntimePermissionsBasic/build.gradle index 2b8d1ef1..b0634833 100644 --- a/system/RuntimePermissionsBasic/build.gradle +++ b/system/RuntimePermissionsBasic/build.gradle @@ -1,3 +1,13 @@ +buildscript { + repositories { + jcenter() + google() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.0.1' + } +} // BEGIN_EXCLUDE import com.example.android.samples.build.SampleGenPlugin diff --git a/system/RuntimePermissionsBasic/gradle/wrapper/gradle-wrapper.properties b/system/RuntimePermissionsBasic/gradle/wrapper/gradle-wrapper.properties index 4a39e6d5..fcae5ca1 100644 --- a/system/RuntimePermissionsBasic/gradle/wrapper/gradle-wrapper.properties +++ b/system/RuntimePermissionsBasic/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
\ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
\ No newline at end of file diff --git a/system/RuntimePermissionsBasic/template-params.xml b/system/RuntimePermissionsBasic/template-params.xml index aba6ac8e..0dae4dfb 100644 --- a/system/RuntimePermissionsBasic/template-params.xml +++ b/system/RuntimePermissionsBasic/template-params.xml @@ -21,9 +21,6 @@ <minSdk>15</minSdk> - <dependency>com.android.support:support-v4:24.0.0</dependency> - <dependency>com.android.support:design:24.0.0</dependency> - <strings> <intro> <![CDATA[ @@ -33,7 +30,7 @@ Note: The "RuntimePermissions" sample provides a more complete overview over the </intro> </strings> - <template src="base"/> + <template src="base-build"/> <metadata> <status>PUBLISHED</status> |