diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-11-08 04:11:05 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-11-08 04:11:05 +0000 |
commit | ed0f1ed2a42cd5f86e3d8cf199b0aa47dc7fc17b (patch) | |
tree | ce2ad8469bde85b9fda6f343628c1cf3c6d981fc /wearable | |
parent | 7b46d3fab450ac7d4514860f3553d847b83bcc6e (diff) | |
parent | 9cea92564bf75a89383fdd3e1346d6b7049a0481 (diff) | |
download | android-ed0f1ed2a42cd5f86e3d8cf199b0aa47dc7fc17b.tar.gz |
Merge "Replaces all tap code with new simple onTap()." into oc-mr1-dev
Diffstat (limited to 'wearable')
3 files changed, 12 insertions, 84 deletions
diff --git a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/watchface/AnalogComplicationWatchFaceService.java b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/watchface/AnalogComplicationWatchFaceService.java index 2fc0b2d5..5ef4c315 100644 --- a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/watchface/AnalogComplicationWatchFaceService.java +++ b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/watchface/AnalogComplicationWatchFaceService.java @@ -413,91 +413,19 @@ public class AnalogComplicationWatchFaceService extends CanvasWatchFaceService { Log.d(TAG, "OnTapCommand()"); switch (tapType) { case TAP_TYPE_TAP: - int tappedComplicationId = getTappedComplicationId(x, y); - if (tappedComplicationId != -1) { - onComplicationTap(tappedComplicationId); - } - break; - } - } - /* - * Determines if tap inside a complication area or returns -1. - */ - private int getTappedComplicationId(int x, int y) { - int complicationId; - ComplicationData complicationData; - ComplicationDrawable complicationDrawable; + for (int i = 0; i < COMPLICATION_IDS.length; i++) { + int complicationId = COMPLICATION_IDS[i]; + ComplicationDrawable complicationDrawable = + mComplicationDrawableSparseArray.get(complicationId); - long currentTimeMillis = System.currentTimeMillis(); + boolean successfulTap = complicationDrawable.onTap(x, y, eventTime); - for (int i = 0; i < COMPLICATION_IDS.length; i++) { - complicationId = COMPLICATION_IDS[i]; - complicationData = mActiveComplicationDataSparseArray.get(complicationId); - - if ((complicationData != null) - && (complicationData.isActive(currentTimeMillis)) - // The line below this comment block disables taps for background - // complications (usually not wanted by the user). - // If you do want to enable this, remove the line below and reverse order - // of the loop so it checks the last elements (non-background complications) - // first. Otherwise, the background complication (since it is the size of - // the whole watch face) will capture all taps. - && (complicationData.getType() != ComplicationData.TYPE_LARGE_IMAGE) - && (complicationData.getType() != ComplicationData.TYPE_NOT_CONFIGURED) - && (complicationData.getType() != ComplicationData.TYPE_EMPTY)) { - - complicationDrawable = mComplicationDrawableSparseArray.get(complicationId); - Rect complicationBoundingRect = complicationDrawable.getBounds(); - - if (complicationBoundingRect.width() > 0) { - if (complicationBoundingRect.contains(x, y)) { - return complicationId; + if (successfulTap) { + return; } - } else { - Log.e(TAG, "Not a recognized complication id."); - } - } - } - return -1; - } - - /* - * Fires PendingIntent associated with complication (if it has one). - */ - private void onComplicationTap(int complicationId) { - Log.d(TAG, "onComplicationTap()"); - - ComplicationData complicationData = - mActiveComplicationDataSparseArray.get(complicationId); - - if (complicationData != null) { - - if (complicationData.getTapAction() != null) { - try { - complicationData.getTapAction().send(); - } catch (PendingIntent.CanceledException e) { - Log.e(TAG, "On complication tap action error " + e); } - - } else if (complicationData.getType() == ComplicationData.TYPE_NO_PERMISSION) { - - // Watch face does not have permission to receive complication data, so launch - // permission request. - ComponentName componentName = - new ComponentName( - getApplicationContext(), - AnalogComplicationWatchFaceService.class); - - Intent permissionRequestIntent = - ComplicationHelperActivity.createPermissionRequestHelperIntent( - getApplicationContext(), componentName); - - startActivity(permissionRequestIntent); - } - - } else { - Log.d(TAG, "No PendingIntent for complication " + complicationId + "."); + break; } } diff --git a/wearable/wear/WatchFace/gradle/wrapper/gradle-wrapper.properties b/wearable/wear/WatchFace/gradle/wrapper/gradle-wrapper.properties index fe37e6e8..d345e372 100644 --- a/wearable/wear/WatchFace/gradle/wrapper/gradle-wrapper.properties +++ b/wearable/wear/WatchFace/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Mar 27 10:56:30 PDT 2017 +#Fri Nov 03 10:03:20 PDT 2017 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 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/wearable/wear/WatchFace/template-params.xml b/wearable/wear/WatchFace/template-params.xml index 5069fd3f..45e0d3e1 100644 --- a/wearable/wear/WatchFace/template-params.xml +++ b/wearable/wear/WatchFace/template-params.xml @@ -26,8 +26,8 @@ <targetSdkVersion>25</targetSdkVersion> <minSdkVersionWear>24</minSdkVersionWear> - <compileSdkVersionWear>26</compileSdkVersionWear> - <targetSdkVersionWear>26</targetSdkVersionWear> + <compileSdkVersionWear>27</compileSdkVersionWear> + <targetSdkVersionWear>27</targetSdkVersionWear> <dependency>com.google.android.support:wearable:2.0.3</dependency> <dependency_wearable>com.android.support:palette-v7:26.0.0</dependency_wearable> |