Update sample prebults for 2017-02 release (nyc-mr1-dev) am: 8a66f8cbc0
am: b2c8c7c8d8
Change-Id: Ib89130912b7bee51a2d546c447b0d165bfdd91a2
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 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.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" package="com.example.android.accelerometerplay">
|
||||
<application android:icon="@mipmap/ic_launcher" android:label="@string/app_name">
|
||||
<activity android:name=".AccelerometerPlayActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
|
||||
<uses-sdk android:minSdkVersion="5"></uses-sdk>
|
||||
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
|
||||
|
||||
</manifest>
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
page.tags="AccelerometerPlay"
|
||||
sample.group=Sensors
|
||||
@jd:body
|
||||
|
||||
<p>
|
||||
|
||||
<p>This sample demonstrates how to use an accelerometer sensor as input for
|
||||
a physics-based view. The input from the accelerometer is used to simulate a
|
||||
virtual surface, and a number of free-moving objects placed on top of it.</p>
|
||||
|
||||
<p>Any effects from the device's acceleration vector (including both gravity and
|
||||
temporary movement) will be translated to the on-screen particles.</p>
|
||||
|
||||
</p>
|
||||
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 191 KiB |
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 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.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/wood"
|
||||
>
|
||||
</FrameLayout>
|
||||
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 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="app_name">AccelerometerPlay</string>
|
||||
</resources>
|
||||
@@ -1,429 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.
|
||||
*/
|
||||
|
||||
package com.example.android.accelerometerplay;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.BitmapFactory.Options;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
* This is an example of using the accelerometer to integrate the device's
|
||||
* acceleration to a position using the Verlet method. This is illustrated with
|
||||
* a very simple particle system comprised of a few iron balls freely moving on
|
||||
* an inclined wooden table. The inclination of the virtual table is controlled
|
||||
* by the device's accelerometer.
|
||||
*
|
||||
* @see SensorManager
|
||||
* @see SensorEvent
|
||||
* @see Sensor
|
||||
*/
|
||||
|
||||
public class AccelerometerPlayActivity extends Activity {
|
||||
|
||||
private SimulationView mSimulationView;
|
||||
private SensorManager mSensorManager;
|
||||
private PowerManager mPowerManager;
|
||||
private WindowManager mWindowManager;
|
||||
private Display mDisplay;
|
||||
private WakeLock mWakeLock;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Get an instance of the SensorManager
|
||||
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
||||
|
||||
// Get an instance of the PowerManager
|
||||
mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
|
||||
// Get an instance of the WindowManager
|
||||
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
mDisplay = mWindowManager.getDefaultDisplay();
|
||||
|
||||
// Create a bright wake lock
|
||||
mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass()
|
||||
.getName());
|
||||
|
||||
// instantiate our simulation view and set it as the activity's content
|
||||
mSimulationView = new SimulationView(this);
|
||||
mSimulationView.setBackgroundResource(R.drawable.wood);
|
||||
setContentView(mSimulationView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
/*
|
||||
* when the activity is resumed, we acquire a wake-lock so that the
|
||||
* screen stays on, since the user will likely not be fiddling with the
|
||||
* screen or buttons.
|
||||
*/
|
||||
mWakeLock.acquire();
|
||||
|
||||
// Start the simulation
|
||||
mSimulationView.startSimulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
/*
|
||||
* When the activity is paused, we make sure to stop the simulation,
|
||||
* release our sensor resources and wake locks
|
||||
*/
|
||||
|
||||
// Stop the simulation
|
||||
mSimulationView.stopSimulation();
|
||||
|
||||
// and release our wake-lock
|
||||
mWakeLock.release();
|
||||
}
|
||||
|
||||
class SimulationView extends FrameLayout implements SensorEventListener {
|
||||
// diameter of the balls in meters
|
||||
private static final float sBallDiameter = 0.004f;
|
||||
private static final float sBallDiameter2 = sBallDiameter * sBallDiameter;
|
||||
|
||||
private final int mDstWidth;
|
||||
private final int mDstHeight;
|
||||
|
||||
private Sensor mAccelerometer;
|
||||
private long mLastT;
|
||||
|
||||
private float mXDpi;
|
||||
private float mYDpi;
|
||||
private float mMetersToPixelsX;
|
||||
private float mMetersToPixelsY;
|
||||
private float mXOrigin;
|
||||
private float mYOrigin;
|
||||
private float mSensorX;
|
||||
private float mSensorY;
|
||||
private float mHorizontalBound;
|
||||
private float mVerticalBound;
|
||||
private final ParticleSystem mParticleSystem;
|
||||
/*
|
||||
* Each of our particle holds its previous and current position, its
|
||||
* acceleration. for added realism each particle has its own friction
|
||||
* coefficient.
|
||||
*/
|
||||
class Particle extends View {
|
||||
private float mPosX = (float) Math.random();
|
||||
private float mPosY = (float) Math.random();
|
||||
private float mVelX;
|
||||
private float mVelY;
|
||||
|
||||
public Particle(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public Particle(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public Particle(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public Particle(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void computePhysics(float sx, float sy, float dT) {
|
||||
|
||||
final float ax = -sx/5;
|
||||
final float ay = -sy/5;
|
||||
|
||||
mPosX += mVelX * dT + ax * dT * dT / 2;
|
||||
mPosY += mVelY * dT + ay * dT * dT / 2;
|
||||
|
||||
mVelX += ax * dT;
|
||||
mVelY += ay * dT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Resolving constraints and collisions with the Verlet integrator
|
||||
* can be very simple, we simply need to move a colliding or
|
||||
* constrained particle in such way that the constraint is
|
||||
* satisfied.
|
||||
*/
|
||||
public void resolveCollisionWithBounds() {
|
||||
final float xmax = mHorizontalBound;
|
||||
final float ymax = mVerticalBound;
|
||||
final float x = mPosX;
|
||||
final float y = mPosY;
|
||||
if (x > xmax) {
|
||||
mPosX = xmax;
|
||||
mVelX = 0;
|
||||
} else if (x < -xmax) {
|
||||
mPosX = -xmax;
|
||||
mVelX = 0;
|
||||
}
|
||||
if (y > ymax) {
|
||||
mPosY = ymax;
|
||||
mVelY = 0;
|
||||
} else if (y < -ymax) {
|
||||
mPosY = -ymax;
|
||||
mVelY = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A particle system is just a collection of particles
|
||||
*/
|
||||
class ParticleSystem {
|
||||
static final int NUM_PARTICLES = 5;
|
||||
private Particle mBalls[] = new Particle[NUM_PARTICLES];
|
||||
|
||||
ParticleSystem() {
|
||||
/*
|
||||
* Initially our particles have no speed or acceleration
|
||||
*/
|
||||
for (int i = 0; i < mBalls.length; i++) {
|
||||
mBalls[i] = new Particle(getContext());
|
||||
mBalls[i].setBackgroundResource(R.drawable.ball);
|
||||
mBalls[i].setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
addView(mBalls[i], new ViewGroup.LayoutParams(mDstWidth, mDstHeight));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the position of each particle in the system using the
|
||||
* Verlet integrator.
|
||||
*/
|
||||
private void updatePositions(float sx, float sy, long timestamp) {
|
||||
final long t = timestamp;
|
||||
if (mLastT != 0) {
|
||||
final float dT = (float) (t - mLastT) / 1000.f /** (1.0f / 1000000000.0f)*/;
|
||||
final int count = mBalls.length;
|
||||
for (int i = 0; i < count; i++) {
|
||||
Particle ball = mBalls[i];
|
||||
ball.computePhysics(sx, sy, dT);
|
||||
}
|
||||
}
|
||||
mLastT = t;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs one iteration of the simulation. First updating the
|
||||
* position of all the particles and resolving the constraints and
|
||||
* collisions.
|
||||
*/
|
||||
public void update(float sx, float sy, long now) {
|
||||
// update the system's positions
|
||||
updatePositions(sx, sy, now);
|
||||
|
||||
// We do no more than a limited number of iterations
|
||||
final int NUM_MAX_ITERATIONS = 10;
|
||||
|
||||
/*
|
||||
* Resolve collisions, each particle is tested against every
|
||||
* other particle for collision. If a collision is detected the
|
||||
* particle is moved away using a virtual spring of infinite
|
||||
* stiffness.
|
||||
*/
|
||||
boolean more = true;
|
||||
final int count = mBalls.length;
|
||||
for (int k = 0; k < NUM_MAX_ITERATIONS && more; k++) {
|
||||
more = false;
|
||||
for (int i = 0; i < count; i++) {
|
||||
Particle curr = mBalls[i];
|
||||
for (int j = i + 1; j < count; j++) {
|
||||
Particle ball = mBalls[j];
|
||||
float dx = ball.mPosX - curr.mPosX;
|
||||
float dy = ball.mPosY - curr.mPosY;
|
||||
float dd = dx * dx + dy * dy;
|
||||
// Check for collisions
|
||||
if (dd <= sBallDiameter2) {
|
||||
/*
|
||||
* add a little bit of entropy, after nothing is
|
||||
* perfect in the universe.
|
||||
*/
|
||||
dx += ((float) Math.random() - 0.5f) * 0.0001f;
|
||||
dy += ((float) Math.random() - 0.5f) * 0.0001f;
|
||||
dd = dx * dx + dy * dy;
|
||||
// simulate the spring
|
||||
final float d = (float) Math.sqrt(dd);
|
||||
final float c = (0.5f * (sBallDiameter - d)) / d;
|
||||
final float effectX = dx * c;
|
||||
final float effectY = dy * c;
|
||||
curr.mPosX -= effectX;
|
||||
curr.mPosY -= effectY;
|
||||
ball.mPosX += effectX;
|
||||
ball.mPosY += effectY;
|
||||
more = true;
|
||||
}
|
||||
}
|
||||
curr.resolveCollisionWithBounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getParticleCount() {
|
||||
return mBalls.length;
|
||||
}
|
||||
|
||||
public float getPosX(int i) {
|
||||
return mBalls[i].mPosX;
|
||||
}
|
||||
|
||||
public float getPosY(int i) {
|
||||
return mBalls[i].mPosY;
|
||||
}
|
||||
}
|
||||
|
||||
public void startSimulation() {
|
||||
/*
|
||||
* It is not necessary to get accelerometer events at a very high
|
||||
* rate, by using a slower rate (SENSOR_DELAY_UI), we get an
|
||||
* automatic low-pass filter, which "extracts" the gravity component
|
||||
* of the acceleration. As an added benefit, we use less power and
|
||||
* CPU resources.
|
||||
*/
|
||||
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
|
||||
public void stopSimulation() {
|
||||
mSensorManager.unregisterListener(this);
|
||||
}
|
||||
|
||||
public SimulationView(Context context) {
|
||||
super(context);
|
||||
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
mXDpi = metrics.xdpi;
|
||||
mYDpi = metrics.ydpi;
|
||||
mMetersToPixelsX = mXDpi / 0.0254f;
|
||||
mMetersToPixelsY = mYDpi / 0.0254f;
|
||||
|
||||
// rescale the ball so it's about 0.5 cm on screen
|
||||
mDstWidth = (int) (sBallDiameter * mMetersToPixelsX + 0.5f);
|
||||
mDstHeight = (int) (sBallDiameter * mMetersToPixelsY + 0.5f);
|
||||
mParticleSystem = new ParticleSystem();
|
||||
|
||||
Options opts = new Options();
|
||||
opts.inDither = true;
|
||||
opts.inPreferredConfig = Bitmap.Config.RGB_565;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
// compute the origin of the screen relative to the origin of
|
||||
// the bitmap
|
||||
mXOrigin = (w - mDstWidth) * 0.5f;
|
||||
mYOrigin = (h - mDstHeight) * 0.5f;
|
||||
mHorizontalBound = ((w / mMetersToPixelsX - sBallDiameter) * 0.5f);
|
||||
mVerticalBound = ((h / mMetersToPixelsY - sBallDiameter) * 0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER)
|
||||
return;
|
||||
/*
|
||||
* record the accelerometer data, the event's timestamp as well as
|
||||
* the current time. The latter is needed so we can calculate the
|
||||
* "present" time during rendering. In this application, we need to
|
||||
* take into account how the screen is rotated with respect to the
|
||||
* sensors (which always return data in a coordinate space aligned
|
||||
* to with the screen in its native orientation).
|
||||
*/
|
||||
|
||||
switch (mDisplay.getRotation()) {
|
||||
case Surface.ROTATION_0:
|
||||
mSensorX = event.values[0];
|
||||
mSensorY = event.values[1];
|
||||
break;
|
||||
case Surface.ROTATION_90:
|
||||
mSensorX = -event.values[1];
|
||||
mSensorY = event.values[0];
|
||||
break;
|
||||
case Surface.ROTATION_180:
|
||||
mSensorX = -event.values[0];
|
||||
mSensorY = -event.values[1];
|
||||
break;
|
||||
case Surface.ROTATION_270:
|
||||
mSensorX = event.values[1];
|
||||
mSensorY = -event.values[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
/*
|
||||
* Compute the new position of our object, based on accelerometer
|
||||
* data and present time.
|
||||
*/
|
||||
final ParticleSystem particleSystem = mParticleSystem;
|
||||
final long now = System.currentTimeMillis();
|
||||
final float sx = mSensorX;
|
||||
final float sy = mSensorY;
|
||||
|
||||
particleSystem.update(sx, sy, now);
|
||||
|
||||
final float xc = mXOrigin;
|
||||
final float yc = mYOrigin;
|
||||
final float xs = mMetersToPixelsX;
|
||||
final float ys = mMetersToPixelsY;
|
||||
final int count = particleSystem.getParticleCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
/*
|
||||
* We transform the canvas so that the coordinate system matches
|
||||
* the sensors coordinate system with the origin in the center
|
||||
* of the screen and the unit is the meter.
|
||||
*/
|
||||
final float x = xc + particleSystem.getPosX(i) * xs;
|
||||
final float y = yc - particleSystem.getPosY(i) * ys;
|
||||
particleSystem.mBalls[i].setTranslationX(x);
|
||||
particleSystem.mBalls[i].setTranslationY(y);
|
||||
}
|
||||
|
||||
// and make sure to redraw asap
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
page.tags="ActionBarCompat-ShareActionProvider"
|
||||
sample.group=UI
|
||||
@jd:body
|
||||
|
||||
<p>
|
||||
|
||||
This sample shows you how a provide a context-sensitive ShareActionProvider with
|
||||
ActionBarCompat, backwards compatible to API v7.
|
||||
|
||||
</p>
|
||||
@@ -16,8 +16,8 @@
|
||||
-->
|
||||
<resources>
|
||||
<string name="add_a_notification">Add a notification</string>
|
||||
<string name="active_notifications">Active Notifications: %1$s</string>
|
||||
<string name="active_notifications">Active Notifications: %1$d</string>
|
||||
<string name="update_notification_count">Update count</string>
|
||||
<string name="sample_notification_content">This is a sample notification.</string>
|
||||
<string name="sample_notification_summary_content">There are %s ActiveNotifications.</string>
|
||||
<string name="sample_notification_summary_content">There are %d ActiveNotifications.</string>
|
||||
</resources>
|
||||
|
||||
@@ -129,23 +129,12 @@ public class ActiveNotificationsFragment extends Fragment {
|
||||
* Adds/updates/removes the notification summary as necessary.
|
||||
*/
|
||||
protected void updateNotificationSummary() {
|
||||
final StatusBarNotification[] activeNotifications = mNotificationManager
|
||||
.getActiveNotifications();
|
||||
|
||||
int numberOfNotifications = activeNotifications.length;
|
||||
// Since the notifications might include a summary notification remove it from the count if
|
||||
// it is present.
|
||||
for (StatusBarNotification notification : activeNotifications) {
|
||||
if (notification.getId() == NOTIFICATION_GROUP_SUMMARY_ID) {
|
||||
numberOfNotifications--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int numberOfNotifications = getNumberOfNotifications();
|
||||
|
||||
if (numberOfNotifications > 1) {
|
||||
// Add/update the notification summary.
|
||||
String notificationContent = getString(R.string.sample_notification_summary_content,
|
||||
"" + numberOfNotifications);
|
||||
numberOfNotifications);
|
||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(getActivity())
|
||||
.setSmallIcon(R.mipmap.ic_notification)
|
||||
.setStyle(new NotificationCompat.BigTextStyle()
|
||||
@@ -165,12 +154,7 @@ public class ActiveNotificationsFragment extends Fragment {
|
||||
* display them to the user.
|
||||
*/
|
||||
protected void updateNumberOfNotifications() {
|
||||
// [BEGIN get_active_notifications]
|
||||
// Query the currently displayed notifications.
|
||||
final StatusBarNotification[] activeNotifications = mNotificationManager
|
||||
.getActiveNotifications();
|
||||
// [END get_active_notifications]
|
||||
final int numberOfNotifications = activeNotifications.length;
|
||||
final int numberOfNotifications = getNumberOfNotifications();
|
||||
mNumberOfNotifications.setText(getString(R.string.active_notifications,
|
||||
numberOfNotifications));
|
||||
Log.i(TAG, getString(R.string.active_notifications, numberOfNotifications));
|
||||
@@ -190,4 +174,21 @@ public class ActiveNotificationsFragment extends Fragment {
|
||||
}
|
||||
return notificationId;
|
||||
}
|
||||
|
||||
private int getNumberOfNotifications() {
|
||||
// [BEGIN get_active_notifications]
|
||||
// Query the currently displayed notifications.
|
||||
final StatusBarNotification[] activeNotifications = mNotificationManager
|
||||
.getActiveNotifications();
|
||||
// [END get_active_notifications]
|
||||
|
||||
// Since the notifications might include a summary notification remove it from the count if
|
||||
// it is present.
|
||||
for (StatusBarNotification notification : activeNotifications) {
|
||||
if (notification.getId() == NOTIFICATION_GROUP_SUMMARY_ID) {
|
||||
return activeNotifications.length - 1;
|
||||
}
|
||||
}
|
||||
return activeNotifications.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/flag_enable_lowprof"
|
||||
android:text="Enable Low Profile Mode" />
|
||||
android:text="@string/enable_low_profile_mode" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/flag_hide_navbar"
|
||||
android:text="Hide Navigation bar" />
|
||||
android:text="@string/hide_navigation_bar" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/flag_hide_statbar"
|
||||
android:text="Hide Status Bar" />
|
||||
android:text="@string/hide_status_bar" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/flag_enable_immersive"
|
||||
android:text="Enable Immersive Mode" />
|
||||
android:text="@string/enable_immersive_mode" />
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/flag_enable_immersive_sticky"
|
||||
android:text="Enable Immersive Mode (Sticky)" />
|
||||
android:text="@string/enable_immersive_mode_sticky" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Do things!"
|
||||
android:text="@string/do_things"
|
||||
android:id="@+id/btn_changeFlags" />
|
||||
|
||||
|
||||
@@ -45,25 +46,24 @@
|
||||
android:layout_marginTop="@dimen/margin_large"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Common flag presets"/>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
android:text="@string/common_flag_presets" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Immersive Mode"
|
||||
android:text="@string/immersive_mode"
|
||||
android:id="@+id/btn_immersive" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Leanback Mode"
|
||||
android:text="@string/leanback_mode"
|
||||
android:id="@+id/btn_leanback" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
||||
Copyright 2016 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="enable_low_profile_mode">Enable Low Profile Mode</string>
|
||||
<string name="hide_navigation_bar">Hide Navigation bar</string>
|
||||
<string name="hide_status_bar">Hide Status Bar</string>
|
||||
<string name="enable_immersive_mode">Enable Immersive Mode</string>
|
||||
<string name="enable_immersive_mode_sticky">Enable Immersive Mode (Sticky)</string>
|
||||
<string name="do_things">Do things!</string>
|
||||
<string name="common_flag_presets">Common flag presets</string>
|
||||
<string name="immersive_mode">Immersive Mode</string>
|
||||
<string name="leanback_mode">Leanback Mode</string>
|
||||
</resources>
|
||||
@@ -18,7 +18,7 @@
|
||||
package="com.example.android.wearable.agendadata">
|
||||
|
||||
<uses-sdk android:minSdkVersion="18"
|
||||
android:targetSdkVersion="23" />
|
||||
android:targetSdkVersion="25" />
|
||||
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package="com.example.android.wearable.agendadata" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="20"
|
||||
android:targetSdkVersion="23" />
|
||||
android:targetSdkVersion="25" />
|
||||
|
||||
<uses-feature android:name="android.hardware.type.watch" />
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
android:label="@string/app_name"
|
||||
>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.wearable.standalone"
|
||||
android:value="false" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
|
||||
@@ -25,7 +25,12 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:label="@string/app_name">
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.DeviceDefault">
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.wearable.standalone"
|
||||
android:value="true" />
|
||||
|
||||
<!--If you want your app to run on pre-22, then set required to false -->
|
||||
<uses-library android:name="com.google.android.wearable" android:required="false" />
|
||||
|
||||
@@ -16,15 +16,17 @@
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.example.android.apprestrictionenforcer"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
||||
@@ -6,6 +6,6 @@ sample.group=Admin
|
||||
<p>
|
||||
|
||||
This sample demonstrates how to set restrictions to other apps as a profile owner.
|
||||
Use AppRestrictionSchema sample as a app with available restrictions.
|
||||
Use the AppRestrictionSchema sample to set restrictions.
|
||||
|
||||
</p>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
@@ -18,7 +18,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.example.android.basicmanagedprofile.MainActivity.MainFragment">
|
||||
tools:context="com.example.android.apprestrictionenforcer.MainActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2014 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.
|
||||
-->
|
||||
<View xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/margin_medium"
|
||||
android:layout_marginTop="@dimen/margin_medium"
|
||||
android:background="#9000"/>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
@@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
This sample demonstrates how to set restrictions to other apps as a profile owner.
|
||||
Use AppRestrictionSchema sample as a app with available restrictions.
|
||||
Use the AppRestrictionSchema sample to set restrictions.
|
||||
|
||||
|
||||
]]>
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
<string name="status_need_reinstall">AppRestrictionSchema needs reinstalling.</string>
|
||||
<string name="unhide">Activate AppRestrictionSchema</string>
|
||||
<string name="allow_saying_hello">Allow AppRestrictionSchema to say hello: </string>
|
||||
<string name="allowed">Allowed</string>
|
||||
<string name="disallowed">Disallowed</string>
|
||||
<string name="profile_name">AppRestrictionEnforcer </string>
|
||||
<string name="message">Message: </string>
|
||||
<string name="number">Number: </string>
|
||||
|
||||
@@ -21,7 +21,6 @@ public interface Constants {
|
||||
/**
|
||||
* Package name of the AppRestrictionSchema sample.
|
||||
*/
|
||||
public static final String PACKAGE_NAME_APP_RESTRICTION_SCHEMA
|
||||
= "com.example.android.apprestrictionschema";
|
||||
String PACKAGE_NAME_APP_RESTRICTION_SCHEMA = "com.example.android.apprestrictionschema";
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.example.android.apprestrictionenforcer;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
@@ -38,9 +39,16 @@ public class MainActivity extends FragmentActivity implements StatusFragment.Sta
|
||||
showSetupProfile();
|
||||
} else {
|
||||
try {
|
||||
int packageFlags;
|
||||
if (Build.VERSION.SDK_INT < 24) {
|
||||
//noinspection deprecation
|
||||
packageFlags = PackageManager.GET_UNINSTALLED_PACKAGES;
|
||||
} else {
|
||||
packageFlags = PackageManager.MATCH_UNINSTALLED_PACKAGES;
|
||||
}
|
||||
ApplicationInfo info = packageManager.getApplicationInfo(
|
||||
Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA,
|
||||
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
packageFlags);
|
||||
if (0 == (info.flags & ApplicationInfo.FLAG_INSTALLED)) {
|
||||
// Need to reinstall the sample app
|
||||
showStatusProfile();
|
||||
|
||||
@@ -80,6 +80,7 @@ public class SetupProfileFragment extends Fragment implements View.OnClickListen
|
||||
intent.putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME,
|
||||
EnforcerDeviceAdminReceiver.getComponentName(activity));
|
||||
} else {
|
||||
//noinspection deprecation
|
||||
intent.putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,
|
||||
activity.getApplicationContext().getPackageName());
|
||||
intent.putExtra(EXTRA_DEVICE_ADMIN, EnforcerDeviceAdminReceiver.getComponentName(activity));
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.app.Activity;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
@@ -85,9 +86,16 @@ public class StatusFragment extends Fragment implements View.OnClickListener {
|
||||
private void updateUi(Activity activity) {
|
||||
PackageManager packageManager = activity.getPackageManager();
|
||||
try {
|
||||
int packageFlags;
|
||||
if (Build.VERSION.SDK_INT < 24) {
|
||||
//noinspection deprecation
|
||||
packageFlags = PackageManager.GET_UNINSTALLED_PACKAGES;
|
||||
} else {
|
||||
packageFlags = PackageManager.MATCH_UNINSTALLED_PACKAGES;
|
||||
}
|
||||
ApplicationInfo info = packageManager.getApplicationInfo(
|
||||
Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA,
|
||||
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
packageFlags);
|
||||
DevicePolicyManager devicePolicyManager =
|
||||
(DevicePolicyManager) activity.getSystemService(Activity.DEVICE_POLICY_SERVICE);
|
||||
if ((info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
|
||||
|
||||
@@ -16,17 +16,17 @@
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.example.android.apprestrictionschema"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<!-- uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" /-->
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
|
||||
<meta-data
|
||||
android:name="android.content.APP_RESTRICTIONS"
|
||||
|
||||
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2014 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,9 +16,9 @@ limitations under the License.
|
||||
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -32,50 +31,50 @@ limitations under the License.
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="@string/explanation_can_say_hello_true"/>
|
||||
tools:text="@string/explanation_can_say_hello_true" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/say_hello"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_medium"
|
||||
android:layout_marginStart="@dimen/margin_medium"
|
||||
android:text="@string/action_can_say_hello"/>
|
||||
|
||||
<include layout="@layout/separator"/>
|
||||
android:text="@string/action_can_say_hello" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/your_number"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_medium"
|
||||
android:layout_marginTop="@dimen/margin_medium"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="@string/your_number"/>
|
||||
|
||||
<include layout="@layout/separator"/>
|
||||
tools:text="@string/your_number" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/your_rank"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_medium"
|
||||
android:layout_marginTop="@dimen/margin_medium"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="@string/your_rank"/>
|
||||
|
||||
<include layout="@layout/separator" android:id="@+id/bundle_separator"/>
|
||||
tools:text="@string/your_rank" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/approvals_you_have"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_medium"
|
||||
android:layout_marginTop="@dimen/margin_medium"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="@string/approvals_you_have"/>
|
||||
|
||||
<include layout="@layout/separator" android:id="@+id/bundle_array_separator" />
|
||||
tools:text="@string/approvals_you_have" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/your_items"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_medium"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="@string/your_items"/>
|
||||
tools:text="@string/your_items" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2014 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.
|
||||
-->
|
||||
<View xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/margin_medium"
|
||||
android:layout_marginTop="@dimen/margin_medium"
|
||||
android:background="#9000"/>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
@@ -81,17 +81,11 @@ public class AppRestrictionSchemaFragment extends Fragment implements View.OnCli
|
||||
mTextNumber = (TextView) view.findViewById(R.id.your_number);
|
||||
mTextRank = (TextView) view.findViewById(R.id.your_rank);
|
||||
mTextApprovals = (TextView) view.findViewById(R.id.approvals_you_have);
|
||||
View bundleSeparator = view.findViewById(R.id.bundle_separator);
|
||||
View bundleArraySeparator = view.findViewById(R.id.bundle_array_separator);
|
||||
mTextItems = (TextView) view.findViewById(R.id.your_items);
|
||||
mButtonSayHello.setOnClickListener(this);
|
||||
if (BUNDLE_SUPPORTED) {
|
||||
bundleSeparator.setVisibility(View.VISIBLE);
|
||||
bundleArraySeparator.setVisibility(View.VISIBLE);
|
||||
mTextItems.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
bundleSeparator.setVisibility(View.GONE);
|
||||
bundleArraySeparator.setVisibility(View.GONE);
|
||||
mTextItems.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.example.android.apprestrictions"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
@@ -25,7 +26,9 @@
|
||||
<!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->
|
||||
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@drawable/ic_launcher">
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:allowBackup="true"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
|
||||
<activity android:name="MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
|
||||
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 10 KiB |
@@ -18,7 +18,7 @@ limitations under the License.
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dp">
|
||||
|
||||
<TextView android:layout_width="match_parent"
|
||||
@@ -35,7 +35,7 @@ limitations under the License.
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="onCustomClicked"/>
|
||||
<TextView android:layout_width="wrap_content"
|
||||
<TextView android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/custom_description"
|
||||
@@ -63,7 +63,7 @@ limitations under the License.
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp">
|
||||
android:layout_marginStart="20dp">
|
||||
<TextView android:layout_width="210dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
@@ -80,7 +80,7 @@ limitations under the License.
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp">
|
||||
android:layout_marginStart="20dp">
|
||||
<TextView android:layout_width="210dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
@@ -97,7 +97,7 @@ limitations under the License.
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp">
|
||||
android:layout_marginStart="20dp">
|
||||
<TextView android:layout_width="210dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
@@ -29,6 +29,7 @@ import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -123,16 +124,14 @@ public class CustomRestrictionsFragment extends PreferenceFragment
|
||||
mChoicePref.setValue(entry.getSelectedString());
|
||||
mChoiceEntry = entry;
|
||||
} else if (entry.getKey().equals(GetRestrictionsReceiver.KEY_MULTI_SELECT)) {
|
||||
HashSet<String> set = new HashSet<String>();
|
||||
for (String value : entry.getAllSelectedStrings()) {
|
||||
set.add(value);
|
||||
}
|
||||
HashSet<String> set = new HashSet<>();
|
||||
Collections.addAll(set, entry.getAllSelectedStrings());
|
||||
mMultiPref.setValues(set);
|
||||
mMultiEntry = entry;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mRestrictions = new ArrayList<RestrictionEntry>();
|
||||
mRestrictions = new ArrayList<>();
|
||||
|
||||
// Initializes the boolean restriction entry and updates its corresponding shared
|
||||
// preference value.
|
||||
@@ -155,13 +154,11 @@ public class CustomRestrictionsFragment extends PreferenceFragment
|
||||
GetRestrictionsReceiver.KEY_MULTI_SELECT));
|
||||
mMultiEntry.setType(RestrictionEntry.TYPE_MULTI_SELECT);
|
||||
if (mMultiEntry.getAllSelectedStrings() != null) {
|
||||
HashSet<String> set = new HashSet<String>();
|
||||
HashSet<String> set = new HashSet<>();
|
||||
final String[] values = mRestrictionsBundle.getStringArray(
|
||||
GetRestrictionsReceiver.KEY_MULTI_SELECT);
|
||||
if (values != null) {
|
||||
for (String value : values) {
|
||||
set.add(value);
|
||||
}
|
||||
Collections.addAll(set, values);
|
||||
}
|
||||
mMultiPref.setValues(set);
|
||||
}
|
||||
@@ -173,7 +170,7 @@ public class CustomRestrictionsFragment extends PreferenceFragment
|
||||
// activity finishes.
|
||||
Intent intent = new Intent(getActivity().getIntent());
|
||||
intent.putParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS_LIST,
|
||||
new ArrayList<RestrictionEntry>(mRestrictions));
|
||||
new ArrayList<>(mRestrictions));
|
||||
getActivity().setResult(Activity.RESULT_OK, intent);
|
||||
}
|
||||
|
||||
@@ -183,9 +180,12 @@ public class CustomRestrictionsFragment extends PreferenceFragment
|
||||
mBooleanEntry.setSelectedState((Boolean) newValue);
|
||||
} else if (preference == mChoicePref) {
|
||||
mChoiceEntry.setSelectedString((String) newValue);
|
||||
} else if (preference == mMultiPref) {
|
||||
String[] selectedStrings = new String[((Set<String>)newValue).size()];
|
||||
} else if (preference == mMultiPref && newValue instanceof Set) {
|
||||
// newValue is a Set<String>, skip the lint warning.
|
||||
//noinspection unchecked
|
||||
String[] selectedStrings = new String[((Set<String>) newValue).size()];
|
||||
int i = 0;
|
||||
//noinspection unchecked
|
||||
for (String value : (Set<String>) newValue) {
|
||||
selectedStrings[i++] = value;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ public class CustomRestrictionsFragment extends PreferenceFragment
|
||||
// Saves all the app restriction configuration changes from the custom activity.
|
||||
Intent intent = new Intent(getActivity().getIntent());
|
||||
intent.putParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS_LIST,
|
||||
new ArrayList<RestrictionEntry>(mRestrictions));
|
||||
new ArrayList<>(mRestrictions));
|
||||
getActivity().setResult(Activity.RESULT_OK, intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class GetRestrictionsReceiver extends BroadcastReceiver {
|
||||
// Demonstrates the creation of standard app restriction types: boolean, single choice, and
|
||||
// multi-select.
|
||||
private ArrayList<RestrictionEntry> initRestrictions(Context context) {
|
||||
ArrayList<RestrictionEntry> newRestrictions = new ArrayList<RestrictionEntry>();
|
||||
ArrayList<RestrictionEntry> newRestrictions = new ArrayList<>();
|
||||
Resources res = context.getResources();
|
||||
|
||||
RestrictionEntry reBoolean = new RestrictionEntry(KEY_BOOLEAN, false);
|
||||
|
||||
@@ -120,12 +120,10 @@ public class MainActivity extends Activity {
|
||||
*
|
||||
* This flag is used by {@code GetRestrictionsReceiver} to determine if a custom app
|
||||
* restriction activity should be used.
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public void onCustomClicked(View view) {
|
||||
final SharedPreferences.Editor editor =
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit();
|
||||
editor.putBoolean(CUSTOM_CONFIG_KEY, mCustomConfig.isChecked()).commit();
|
||||
editor.putBoolean(CUSTOM_CONFIG_KEY, mCustomConfig.isChecked()).apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
<application
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/app"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:resizeableActivity="true">
|
||||
|
||||
<activity android:name="com.example.android.appshortcuts.Main">
|
||||
|
||||
|
Before Width: | Height: | Size: 16 KiB |
BIN
samples/browseable/AppShortcuts/res/mipmap-hdpi/ic_launcher.png
Executable file
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
BIN
samples/browseable/AppShortcuts/res/mipmap-mdpi/ic_launcher.png
Executable file
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
BIN
samples/browseable/AppShortcuts/res/mipmap-xhdpi/ic_launcher.png
Executable file
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
BIN
samples/browseable/AppShortcuts/res/mipmap-xxhdpi/ic_launcher.png
Executable file
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 10 KiB |
BIN
samples/browseable/AppShortcuts/res/mipmap-xxxhdpi/ic_launcher.png
Executable file
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 13 KiB |
@@ -14,25 +14,29 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.android.asymmetricfingerprintdialog"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<manifest package="com.example.android.asymmetricfingerprintdialog"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
|
||||
<application
|
||||
android:name=".InjectedApplication"
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:theme="@style/AppTheme">
|
||||
android:name=".InjectedApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
|
||||
<activity android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
android:layout_marginBottom="32dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/android_robot"/>
|
||||
android:src="@drawable/android_robot"
|
||||
android:contentDescription="@string/description_bugdroid_icon" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -77,8 +78,7 @@
|
||||
android:layout_gravity="end"
|
||||
android:textColor="?android:attr/textColorPrimaryInverse"
|
||||
android:text="@string/purchase"
|
||||
android:id="@+id/purchase_button"
|
||||
android:layout_alignParentEnd="true"/>
|
||||
android:id="@+id/purchase_button"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/confirmation_message"
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@+id/fingerprint_description"
|
||||
android:layout_marginTop="20dp"
|
||||
android:src="@drawable/ic_fp_40px" />
|
||||
android:src="@drawable/ic_fp_40px"
|
||||
android:contentDescription="@string/description_fingerprint_icon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fingerprint_status"
|
||||
|
||||
@@ -15,7 +15,12 @@
|
||||
~ limitations under the License
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
|
||||
<item android:id="@+id/action_settings" android:title="@string/action_settings"
|
||||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".MainActivity">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="use_password">Use password</string>
|
||||
<string name="sign_in">Sign in</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="fingerprint_description">Confirm fingerprint to continue</string>
|
||||
<string name="fingerprint_hint">Touch sensor</string>
|
||||
@@ -36,4 +36,6 @@
|
||||
<string name="use_fingerprint_in_future">Use fingerprint in the future</string>
|
||||
<string name="use_fingerprint_to_authenticate_title">Use fingerprint to authenticate</string>
|
||||
<string name="use_fingerprint_to_authenticate_key" >use_fingerprint_to_authenticate_key</string>
|
||||
<string name="description_bugdroid_icon">Android bugdroid image</string>
|
||||
<string name="description_fingerprint_icon">Fingerprint icon</string>
|
||||
</resources>
|
||||
|
||||
@@ -19,8 +19,8 @@ package com.example.android.asymmetricfingerprintdialog;
|
||||
import com.example.android.asymmetricfingerprintdialog.server.StoreBackend;
|
||||
import com.example.android.asymmetricfingerprintdialog.server.Transaction;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
@@ -158,9 +158,9 @@ public class FingerprintAuthenticationDialogFragment extends DialogFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
mActivity = (MainActivity) activity;
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mActivity = (MainActivity) getActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,11 @@ import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Small helper class to manage text/icon around fingerprint authentication UI.
|
||||
* This class assumes that the {@link android.Manifest.permission#USE_FINGERPRINT}
|
||||
* permission has already been granted. (As of API 23 this permission is normal instead of dangerous
|
||||
* and is granted at install time.)
|
||||
*/
|
||||
@SuppressWarnings("MissingPermission")
|
||||
public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallback {
|
||||
|
||||
@VisibleForTesting static final long ERROR_TIMEOUT_MILLIS = 1600;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<application android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity android:name=".MainActivity"
|
||||
|
||||
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
@@ -16,15 +16,18 @@
|
||||
|
||||
package com.example.android.basicandroidkeystore;
|
||||
|
||||
import com.example.android.common.logger.Log;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.security.KeyPairGeneratorSpec;
|
||||
import android.security.keystore.KeyGenParameterSpec;
|
||||
import android.security.keystore.KeyProperties;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Base64;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.example.android.common.logger.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
@@ -39,6 +42,7 @@ import java.security.Signature;
|
||||
import java.security.SignatureException;
|
||||
import java.security.UnrecoverableEntryException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
@@ -46,7 +50,7 @@ import javax.security.auth.x500.X500Principal;
|
||||
|
||||
public class BasicAndroidKeyStoreFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "BasicAndroidKeyStoreFragment";
|
||||
public static final String TAG = "KeyStoreFragment";
|
||||
|
||||
// BEGIN_INCLUDE(values)
|
||||
|
||||
@@ -159,36 +163,54 @@ public class BasicAndroidKeyStoreFragment extends Fragment {
|
||||
end.add(Calendar.YEAR, 1);
|
||||
//END_INCLUDE(create_valid_dates)
|
||||
|
||||
|
||||
// BEGIN_INCLUDE(create_spec)
|
||||
// The KeyPairGeneratorSpec object is how parameters for your key pair are passed
|
||||
// to the KeyPairGenerator. For a fun home game, count how many classes in this sample
|
||||
// start with the phrase "KeyPair".
|
||||
KeyPairGeneratorSpec spec =
|
||||
new KeyPairGeneratorSpec.Builder(context)
|
||||
// You'll use the alias later to retrieve the key. It's a key for the key!
|
||||
.setAlias(mAlias)
|
||||
// The subject used for the self-signed certificate of the generated pair
|
||||
.setSubject(new X500Principal("CN=" + mAlias))
|
||||
// The serial number used for the self-signed certificate of the
|
||||
// generated pair.
|
||||
.setSerialNumber(BigInteger.valueOf(1337))
|
||||
// Date range of validity for the generated pair.
|
||||
.setStartDate(start.getTime())
|
||||
.setEndDate(end.getTime())
|
||||
.build();
|
||||
// END_INCLUDE(create_spec)
|
||||
|
||||
// BEGIN_INCLUDE(create_keypair)
|
||||
// Initialize a KeyPair generator using the the intended algorithm (in this example, RSA
|
||||
// and the KeyStore. This example uses the AndroidKeyStore.
|
||||
KeyPairGenerator kpGenerator = KeyPairGenerator
|
||||
.getInstance(SecurityConstants.TYPE_RSA,
|
||||
SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
|
||||
kpGenerator.initialize(spec);
|
||||
KeyPair kp = kpGenerator.generateKeyPair();
|
||||
Log.d(TAG, "Public Key is: " + kp.getPublic().toString());
|
||||
// END_INCLUDE(create_keypair)
|
||||
|
||||
// BEGIN_INCLUDE(create_spec)
|
||||
// The KeyPairGeneratorSpec object is how parameters for your key pair are passed
|
||||
// to the KeyPairGenerator.
|
||||
AlgorithmParameterSpec spec;
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
// Below Android M, use the KeyPairGeneratorSpec.Builder.
|
||||
|
||||
spec = new KeyPairGeneratorSpec.Builder(context)
|
||||
// You'll use the alias later to retrieve the key. It's a key for the key!
|
||||
.setAlias(mAlias)
|
||||
// The subject used for the self-signed certificate of the generated pair
|
||||
.setSubject(new X500Principal("CN=" + mAlias))
|
||||
// The serial number used for the self-signed certificate of the
|
||||
// generated pair.
|
||||
.setSerialNumber(BigInteger.valueOf(1337))
|
||||
// Date range of validity for the generated pair.
|
||||
.setStartDate(start.getTime())
|
||||
.setEndDate(end.getTime())
|
||||
.build();
|
||||
|
||||
|
||||
} else {
|
||||
// On Android M or above, use the KeyGenparameterSpec.Builder and specify permitted
|
||||
// properties and restrictions of the key.
|
||||
spec = new KeyGenParameterSpec.Builder(mAlias, KeyProperties.PURPOSE_SIGN)
|
||||
.setCertificateSubject(new X500Principal("CN=" + mAlias))
|
||||
.setDigests(KeyProperties.DIGEST_SHA256)
|
||||
.setSignaturePaddings(KeyProperties.SIGNATURE_PADDING_RSA_PKCS1)
|
||||
.setCertificateSerialNumber(BigInteger.valueOf(1337))
|
||||
.setCertificateNotBefore(start.getTime())
|
||||
.setCertificateNotAfter(end.getTime())
|
||||
.build();
|
||||
}
|
||||
|
||||
kpGenerator.initialize(spec);
|
||||
|
||||
KeyPair kp = kpGenerator.generateKeyPair();
|
||||
// END_INCLUDE(create_spec)
|
||||
Log.d(TAG, "Public Key is: " + kp.getPublic().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item android:id="@+id/sample_action"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
app:showAsAction="ifRoom|withText"
|
||||
android:title="@string/sample_action" />
|
||||
</menu>
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item android:id="@+id/sample_action"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
app:showAsAction="ifRoom|withText"
|
||||
android:title="@string/sample_action" />
|
||||
</menu>
|
||||
|
||||
@@ -188,7 +188,7 @@ public class BluetoothChatFragment extends Fragment {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes this device discoverable.
|
||||
* Makes this device discoverable for 300 seconds (5 minutes).
|
||||
*/
|
||||
private void ensureDiscoverable() {
|
||||
if (mBluetoothAdapter.getScanMode() !=
|
||||
@@ -355,7 +355,7 @@ public class BluetoothChatFragment extends Fragment {
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish connection with other divice
|
||||
* Establish connection with other device
|
||||
*
|
||||
* @param data An {@link Intent} with {@link DeviceListActivity#EXTRA_DEVICE_ADDRESS} extra.
|
||||
* @param secure Socket Security type - Secure (true) , Insecure (false)
|
||||
|
||||