Merge "Added a demo for CircularProgressLayout" into oc-support-26.0-dev am: 1f2a269186
am: 9c0150f666
Change-Id: I8b97e83681f282b6fa01d47899bf8347dcd7c644
diff --git a/samples/SupportWearDemos/AndroidManifest.xml b/samples/SupportWearDemos/AndroidManifest.xml
index eb10f0a..4e4fb60 100644
--- a/samples/SupportWearDemos/AndroidManifest.xml
+++ b/samples/SupportWearDemos/AndroidManifest.xml
@@ -24,6 +24,8 @@
</activity>
<activity android:name="com.example.android.support.wear.app.WearableSwitchDemo">
</activity>
+ <activity android:name="com.example.android.support.wear.app.CircularProgressLayoutDemo">
+ </activity>
<activity android:name="com.example.android.support.wear.app.MainDemoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/samples/SupportWearDemos/res/layout/cpl_demo.xml b/samples/SupportWearDemos/res/layout/cpl_demo.xml
new file mode 100644
index 0000000..cf29663
--- /dev/null
+++ b/samples/SupportWearDemos/res/layout/cpl_demo.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 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.
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <android.support.wear.widget.CircularProgressLayout
+ android:id="@+id/circularProgressLayout_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:padding="10dp"
+ app:backgroundColor="@color/cpl_light_yellow"
+ app:colorSchemeColors="@color/cpl_light_blue"
+ app:strokeWidth="10dp">
+ <TextView
+ android:id="@+id/circularProgressLayout_child"
+ android:layout_width="60dp"
+ android:layout_height="60dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:textColor="@color/cpl_black"
+ android:text="@string/cpl_click_me"/>
+ </android.support.wear.widget.CircularProgressLayout>
+</FrameLayout>
\ No newline at end of file
diff --git a/samples/SupportWearDemos/res/values/colors.xml b/samples/SupportWearDemos/res/values/colors.xml
new file mode 100644
index 0000000..95c0119
--- /dev/null
+++ b/samples/SupportWearDemos/res/values/colors.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 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>
+ <color name="cpl_light_yellow">#fff176</color>
+ <color name="cpl_light_red">#ef5350</color>
+ <color name="cpl_light_green">#66bb6a</color>
+ <color name="cpl_light_blue">#4fc3f7</color>
+ <color name="cpl_black">#000000</color>
+</resources>
\ No newline at end of file
diff --git a/samples/SupportWearDemos/res/values/strings.xml b/samples/SupportWearDemos/res/values/strings.xml
new file mode 100644
index 0000000..7f92211
--- /dev/null
+++ b/samples/SupportWearDemos/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 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="cpl_click_me">Click me!</string>
+ <string name="cpl_clicked">Clicked!</string>
+ <string name="cpl_finished">Finished!</string>
+</resources>
\ No newline at end of file
diff --git a/samples/SupportWearDemos/src/com/example/android/support/wear/app/CircularProgressLayoutDemo.java b/samples/SupportWearDemos/src/com/example/android/support/wear/app/CircularProgressLayoutDemo.java
new file mode 100644
index 0000000..6bd4438
--- /dev/null
+++ b/samples/SupportWearDemos/src/com/example/android/support/wear/app/CircularProgressLayoutDemo.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 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.
+ */
+
+package com.example.android.support.wear.app;
+
+import android.app.Activity;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.RequiresApi;
+import android.support.v4.content.ContextCompat;
+import android.support.wear.widget.CircularProgressLayout;
+import android.view.View;
+import android.widget.TextView;
+
+import com.example.android.support.wear.R;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Main activity for the CircularProgressLayout demo.
+ */
+@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+public class CircularProgressLayoutDemo extends Activity implements
+ CircularProgressLayout.OnTimerFinishedListener, View.OnClickListener {
+
+ private static final long TOTAL_TIME = TimeUnit.SECONDS.toMillis(10);
+
+ CircularProgressLayout mCircularProgressLayout;
+ TextView mChildView;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.cpl_demo);
+ mCircularProgressLayout = findViewById(R.id.circularProgressLayout_layout);
+ mChildView = findViewById(R.id.circularProgressLayout_child);
+
+ mCircularProgressLayout.setOnClickListener(this);
+ mCircularProgressLayout.setOnTimerFinishedListener(this);
+
+ mCircularProgressLayout.setTotalTime(TOTAL_TIME);
+ mCircularProgressLayout.startTimer();
+ }
+
+ @Override
+ public void onTimerFinished(CircularProgressLayout layout) {
+ if (layout == mCircularProgressLayout) {
+ mChildView.setText(getString(R.string.cpl_finished));
+ mCircularProgressLayout.setBackgroundColor(
+ ContextCompat.getColor(this, R.color.cpl_light_green));
+ }
+ }
+
+ @Override
+ public void onClick(View view) {
+ if (view == mCircularProgressLayout && mCircularProgressLayout.isTimerRunning()) {
+ mCircularProgressLayout.stopTimer();
+ mChildView.setText(getString(R.string.cpl_clicked));
+ mCircularProgressLayout.setBackgroundColor(
+ ContextCompat.getColor(this, R.color.cpl_light_red));
+ }
+ }
+}
diff --git a/samples/SupportWearDemos/src/com/example/android/support/wear/app/MainDemoActivity.java b/samples/SupportWearDemos/src/com/example/android/support/wear/app/MainDemoActivity.java
index c9512a2..313457b 100644
--- a/samples/SupportWearDemos/src/com/example/android/support/wear/app/MainDemoActivity.java
+++ b/samples/SupportWearDemos/src/com/example/android/support/wear/app/MainDemoActivity.java
@@ -54,12 +54,15 @@
this, SimpleWearableRecyclerViewDemo.class));
contentMap.put("Wearable Switch", new Intent(
this, WearableSwitchDemo.class));
+ contentMap.put("Circular Progress Layout", new Intent(
+ this, CircularProgressLayoutDemo.class));
return contentMap;
}
private class ViewHolder extends RecyclerView.ViewHolder {
Button mView;
+
ViewHolder(Button itemView) {
super(itemView);
mView = itemView;