aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-09-04 23:12:01 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-09-04 23:12:01 +0000
commit20ce36d44de28c1215e27166eff488d10287b444 (patch)
tree329b05418a0f59137848de93f54c0c25df959831
parent14a47d457e30fb9e8c6b12c2e607311bb72261d9 (diff)
parent62f7efaaf88420486373f48001726ae1344465f5 (diff)
downloadtests-20ce36d44de28c1215e27166eff488d10287b444.tar.gz
Snap for 6814464 from 62f7efaaf88420486373f48001726ae1344465f5 to rvc-qpr1-release
Change-Id: I333f5811f94949c7206e2a824881349ed5ed5a08
-rw-r--r--RotaryPlayground/res/layout/rotary_cards.xml5
-rw-r--r--RotaryPlayground/res/layout/rotary_menu.xml7
-rw-r--r--RotaryPlayground/res/layout/rotary_web_view.xml67
-rw-r--r--RotaryPlayground/res/raw/web_view_html.xml130
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java32
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/WebViewFragment.java69
6 files changed, 299 insertions, 11 deletions
diff --git a/RotaryPlayground/res/layout/rotary_cards.xml b/RotaryPlayground/res/layout/rotary_cards.xml
index e3d9e87..b197058 100644
--- a/RotaryPlayground/res/layout/rotary_cards.xml
+++ b/RotaryPlayground/res/layout/rotary_cards.xml
@@ -52,12 +52,15 @@
android:layout_width="@dimen/card_width"
android:layout_height="match_parent"
android:padding="@dimen/card_padding"
- android:orientation="vertical">
+ android:orientation="vertical"
+ app:nudgeShortcut="@+id/button1"
+ app:nudgeShortcutDirection="up">
<TextView
android:layout_height="@dimen/description_height"
android:layout_width="match_parent"
android:text="@string/card_normal_text" />
<Button
+ android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:onClick="onRotaryButtonClick"
diff --git a/RotaryPlayground/res/layout/rotary_menu.xml b/RotaryPlayground/res/layout/rotary_menu.xml
index 38a0b8d..452fdc1 100644
--- a/RotaryPlayground/res/layout/rotary_menu.xml
+++ b/RotaryPlayground/res/layout/rotary_menu.xml
@@ -62,4 +62,11 @@
android:layout_weight="1"
android:text="Scroll"
style="@style/tab" />
+ <Button
+ android:id="@+id/web_view"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:text="WebView"
+ style="@style/tab" />
</com.android.car.ui.FocusArea>
diff --git a/RotaryPlayground/res/layout/rotary_web_view.xml b/RotaryPlayground/res/layout/rotary_web_view.xml
new file mode 100644
index 0000000..7995dc6
--- /dev/null
+++ b/RotaryPlayground/res/layout/rotary_web_view.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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.
+ -->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <com.android.car.ui.FocusArea
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <Button
+ android:id="@+id/toggle_buttons"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:text="Toggle Buttons"/>
+
+ </com.android.car.ui.FocusArea>
+
+ <com.android.car.ui.FocusArea
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <Button
+ android:id="@+id/top_button"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:onClick="onRotaryButtonClick"
+ android:tag="test_button"
+ android:text="Top Button"
+ android:visibility="gone" />
+
+ <WebView
+ android:id="@+id/web_view"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1" />
+
+ <Button
+ android:id="@+id/bottom_button"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:onClick="onRotaryButtonClick"
+ android:tag="test_button"
+ android:text="Bottom Button"
+ android:visibility="gone" />
+
+ </com.android.car.ui.FocusArea>
+
+</LinearLayout> \ No newline at end of file
diff --git a/RotaryPlayground/res/raw/web_view_html.xml b/RotaryPlayground/res/raw/web_view_html.xml
new file mode 100644
index 0000000..d6e128a
--- /dev/null
+++ b/RotaryPlayground/res/raw/web_view_html.xml
@@ -0,0 +1,130 @@
+<!--
+ ~ Copyright (C) 2020 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.
+ -->
+
+<html>
+ <head>
+ <title>Sample Web Page</title>
+ </head>
+
+ <body>
+
+ <h1>1. Lists</h1>
+ <ol>
+ <li><b>First</b></li>
+ <li><i>Second</i></li>
+ <li>Third</li>
+ <li>Fourth</li>
+ <li>Fifth</li>
+ </ol>
+ <ul>
+ <li><b>1st</b></li>
+ <li><i>2nd</i></li>
+ <li>3rd</li>
+ <li>4th</li>
+ <li>5th</li>
+ </ul>
+
+ <h1>2. Text</h1>
+ <p>Paragraph</p>
+ <p>Another paragraph</p>
+
+ <h1>3. Links</h1>
+ <a href="https://en.wikipedia.org/wiki/Breakout_(video_game)">Breakout</a>
+ <br/>
+ <a href="https://en.wikipedia.org/wiki/Pong">Pong</a>
+ <br/>
+ <a href="https://en.wikipedia.org/wiki/Space_Invaders">Space Invaders</a>
+ <br/>
+ <a href="https://en.wikipedia.org/wiki/Lunar_Lander_(1979_video_game)">Lunar Lander</a>
+ <a href="https://en.wikipedia.org/wiki/Asteroids_(video_game)">Asteroids</a>
+ <br/>
+ <a href="https://en.wikipedia.org/wiki/Battlezone_(1980_video_game)">Battlezone</a>
+ <a href="https://en.wikipedia.org/wiki/Centipede_(video_game)">Centipede</a>
+ <a href="https://en.wikipedia.org/wiki/Missile_Command">Missile Command</a>
+
+ <h1>4. Lists</h1>
+ <ol>
+ <li><b>Sixth</b></li>
+ <li><i>Seventh</i></li>
+ <li>Eighth</li>
+ <li>Ninth</li>
+ <li>Tenth</li>
+ </ol>
+ <ul>
+ <li><b>6th</b></li>
+ <li><i>7th</i></li>
+ <li>8th</li>
+ <li>9th</li>
+ <li>10th</li>
+ </ul>
+
+ <h1>5. More Lists</h1>
+ <ol>
+ <li><b>Eleventh</b></li>
+ <li><i>Twelfth</i></li>
+ <li>Thirteenth</li>
+ <li>Fourteenth</li>
+ <li>Fifteenth</li>
+ </ol>
+ <ul>
+ <li><b>11th</b></li>
+ <li><i>12th</i></li>
+ <li>13th</li>
+ <li>14th</li>
+ <li>15th</li>
+ </ul>
+
+ <h1>6. More Links</h1>
+ <a href="https://en.wikipedia.org/wiki/Defender_(1981_video_game)">Defender</a>
+ <a href="https://en.wikipedia.org/wiki/Donkey_Kong_(video_game)">Donkey Kong</a>
+ <a href="https://en.wikipedia.org/wiki/Tempest_(video_game)">Tempest</a>
+ <a href="https://en.wikipedia.org/wiki/Frogger">Frogger</a>
+ <a href="https://en.wikipedia.org/wiki/Qix">Qix</a>
+
+ <h1>7. Lists</h1>
+ <ol>
+ <li><b>Sixteenth</b></li>
+ <li><i>Seventeenth</i></li>
+ <li>Eighteenth</li>
+ <li>Nineteenth</li>
+ <li>Twentieth</li>
+ </ol>
+ <ul>
+ <li><b>16th</b></li>
+ <li><i>17th</i></li>
+ <li>18th</li>
+ <li>19th</li>
+ <li>20th</li>
+ </ul>
+
+ <h1>8. More Lists</h1>
+ <ol>
+ <li><b>Twenty-first</b></li>
+ <li><i>Twenty-second</i></li>
+ <li>Twenty-third</li>
+ <li>Twenty-fourth</li>
+ <li>Twenty-fifth</li>
+ </ol>
+ <ul>
+ <li><b>21st</b></li>
+ <li><i>22nd</i></li>
+ <li>23rd</li>
+ <li>24th</li>
+ <li>25th</li>
+ </ul>
+
+ </body>
+</html>
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
index fd3baa8..048686e 100644
--- a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
@@ -37,6 +37,7 @@ public class RotaryMenu extends Fragment {
private Fragment mSysUiDirectManipulation = null;
private Fragment mNotificationFragment = null;
private Fragment mScrollFragment = null;
+ private Fragment mWebViewFragment = null;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@@ -56,18 +57,16 @@ public class RotaryMenu extends Fragment {
});
Button directManipulationButton = view.findViewById(R.id.direct_manipulation);
- directManipulationButton.setOnClickListener(
- (v -> {
- selectTab(v);
- showDirectManipulationExamples();
- }));
+ directManipulationButton.setOnClickListener(v -> {
+ selectTab(v);
+ showDirectManipulationExamples();
+ });
Button sysUiDirectManipulationButton = view.findViewById(R.id.sys_ui_direct_manipulation);
- sysUiDirectManipulationButton.setOnClickListener(
- (v -> {
- selectTab(v);
- showSysUiDirectManipulationExamples();
- }));
+ sysUiDirectManipulationButton.setOnClickListener(v -> {
+ selectTab(v);
+ showSysUiDirectManipulationExamples();
+ });
Button notificationButton = view.findViewById(R.id.notification);
notificationButton.setOnClickListener(v -> {
@@ -81,6 +80,12 @@ public class RotaryMenu extends Fragment {
showScrollFragment();
});
+ Button webViewButton = view.findViewById(R.id.web_view);
+ webViewButton.setOnClickListener(v -> {
+ selectTab(v);
+ showWebViewFragment();
+ });
+
return view;
}
@@ -136,6 +141,13 @@ public class RotaryMenu extends Fragment {
showFragment(mScrollFragment);
}
+ private void showWebViewFragment() {
+ if (mWebViewFragment == null) {
+ mWebViewFragment = new WebViewFragment();
+ }
+ showFragment(mWebViewFragment);
+ }
+
private void showFragment(Fragment fragment) {
getFragmentManager().beginTransaction()
.replace(R.id.rotary_content, fragment)
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/WebViewFragment.java b/RotaryPlayground/src/com/android/car/rotaryplayground/WebViewFragment.java
new file mode 100644
index 0000000..033b6a8
--- /dev/null
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/WebViewFragment.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 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.android.car.rotaryplayground;
+
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.util.Base64;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+import android.widget.Button;
+import android.widget.CheckBox;
+
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/** Fragment to demo a layout with a {@link WebView}. */
+public class WebViewFragment extends Fragment {
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.rotary_web_view, container, false);
+ Button toggleButtonsButton = view.findViewById(R.id.toggle_buttons);
+ Button topButton = view.findViewById(R.id.top_button);
+ WebView webView = view.findViewById(R.id.web_view);
+ Button bottomButton = view.findViewById(R.id.bottom_button);
+
+ toggleButtonsButton.setOnClickListener(v -> {
+ int buttonVisibility =
+ topButton.getVisibility() == View.GONE ? View.VISIBLE : View.GONE;
+ topButton.setVisibility(buttonVisibility);
+ bottomButton.setVisibility(buttonVisibility);
+ });
+
+ Resources res = getResources();
+ InputStream inputStream = res.openRawResource(R.raw.web_view_html);
+ byte[] byteArray = new byte[0];
+ try {
+ byteArray = new byte[inputStream.available()];
+ inputStream.read(byteArray);
+ } catch (IOException e) {
+ Log.w("WebViewFragment", "Can't read HTML");
+ }
+ String webViewHtml = new String(byteArray);
+ String encodedHtml = Base64.encodeToString(webViewHtml.getBytes(), Base64.NO_PADDING);
+ webView.loadData(encodedHtml, "text/html", "base64");
+ return view;
+ }
+}