aboutsummaryrefslogtreecommitdiff
path: root/input/autofill/AutofillFramework/kotlinApp/Application/src/main
diff options
context:
space:
mode:
authorDouglas Sigelbaum <sigelbaum@google.com>2017-06-16 13:04:26 -0700
committerDouglas Sigelbaum <sigelbaum@google.com>2017-07-10 14:49:22 +0000
commitfff04fe1616be519fc2a4af77761eac64ef911dc (patch)
treeb943702974c27a29281e511dab1f6e5a0c1ea8f7 /input/autofill/AutofillFramework/kotlinApp/Application/src/main
parentabc564e17e6c244a5841bd740162fd75dbf5d6ae (diff)
downloadandroid-fff04fe1616be519fc2a4af77761eac64ef911dc.tar.gz
Autofill sample: adding email compose activity.
To show how to set the importantForAutofill attribute. Bug: 38182790 Test: manual Change-Id: I7f05f367b8b3add8694276a9e063bc53b761df51
Diffstat (limited to 'input/autofill/AutofillFramework/kotlinApp/Application/src/main')
-rw-r--r--input/autofill/AutofillFramework/kotlinApp/Application/src/main/AndroidManifest.xml16
-rw-r--r--input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/EmailComposeActivity.kt43
-rw-r--r--input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.kt7
-rw-r--r--input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_email_black_24dp.xml24
-rw-r--r--input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_send_white_24dp.xml24
-rw-r--r--input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/activity_main.xml9
-rw-r--r--input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/email_compose_activity.xml123
-rw-r--r--input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml13
8 files changed, 250 insertions, 9 deletions
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/AndroidManifest.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/AndroidManifest.xml
index 21d33639..4d796e4f 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/AndroidManifest.xml
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/AndroidManifest.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
+<?xml version="1.0" encoding="UTF-8"?><!--
Copyright 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,8 +35,7 @@
</activity>
<activity
android:name=".app.StandardSignInActivity"
- android:taskAffinity=".StandardSignInActivity">
- </activity>
+ android:taskAffinity=".StandardSignInActivity" />
<activity
android:name=".app.StandardAutoCompleteSignInActivity"
android:taskAffinity=".StandardAutoCompleteSignInActivity" />
@@ -49,8 +47,10 @@
<activity android:name=".app.WelcomeActivity" />
<activity
android:name=".app.CreditCardActivity"
- android:taskAffinity=".CreditCardActivity">
- </activity>
+ android:taskAffinity=".CreditCardActivity" />
+ <activity
+ android:name=".app.EmailComposeActivity"
+ android:taskAffinity=".EmailComposeActivity" />
<!--
Including launcher icon for Autofill Settings to convenience.
Not necessary for a real service.
@@ -73,8 +73,8 @@
-->
<service
android:name=".multidatasetservice.MyAutofillService"
- android:permission="android.permission.BIND_AUTOFILL"
- android:label="Multi-Dataset Autofill Service">
+ android:label="Multi-Dataset Autofill Service"
+ android:permission="android.permission.BIND_AUTOFILL">
<meta-data
android:name="android.autofill"
android:resource="@xml/multidataset_service" />
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/EmailComposeActivity.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/EmailComposeActivity.kt
new file mode 100644
index 00000000..7b23b611
--- /dev/null
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/EmailComposeActivity.kt
@@ -0,0 +1,43 @@
+/*
+ * 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.autofillframework.app
+
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import com.example.android.autofillframework.R
+import kotlinx.android.synthetic.main.email_compose_activity.sendButton
+
+class EmailComposeActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.email_compose_activity)
+ sendButton.setOnClickListener {
+ startActivity(WelcomeActivity.getStartActivityIntent(this@EmailComposeActivity))
+ finish()
+ }
+ }
+
+ companion object {
+
+ fun getStartActivityIntent(context: Context): Intent {
+ val intent = Intent(context, EmailComposeActivity::class.java)
+ return intent
+ }
+ }
+}
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.kt b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.kt
index 3ab4f389..d251369d 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.kt
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.kt
@@ -20,6 +20,7 @@ import android.support.v7.app.AppCompatActivity
import android.view.View
import com.example.android.autofillframework.R
import kotlinx.android.synthetic.main.activity_main.creditCardCheckoutButton
+import kotlinx.android.synthetic.main.activity_main.emailComposeButton
import kotlinx.android.synthetic.main.activity_main.standardLoginWithAutoCompleteButton
import kotlinx.android.synthetic.main.activity_main.standardViewSignInButton
import kotlinx.android.synthetic.main.activity_main.virtualViewSignInButton
@@ -36,6 +37,7 @@ class MainActivity : AppCompatActivity() {
virtualViewSignInButton.setNavigationButtonClickListener(View.OnClickListener { virtualViewSignIn() })
creditCardCheckoutButton.setNavigationButtonClickListener(View.OnClickListener { creditCardCheckout() })
standardLoginWithAutoCompleteButton.setNavigationButtonClickListener(View.OnClickListener { standardAutoCompleteSignIn() })
+ emailComposeButton.setNavigationButtonClickListener(View.OnClickListener { emailCompose() })
}
private fun creditCardCheckout() {
@@ -57,4 +59,9 @@ class MainActivity : AppCompatActivity() {
val intent = VirtualSignInActivity.getStartActivityIntent(this)
startActivity(intent)
}
+
+ private fun emailCompose() {
+ val intent = EmailComposeActivity.getStartActivityIntent(this)
+ startActivity(intent)
+ }
} \ No newline at end of file
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_email_black_24dp.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_email_black_24dp.xml
new file mode 100644
index 00000000..174c1272
--- /dev/null
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_email_black_24dp.xml
@@ -0,0 +1,24 @@
+<!--
+ * 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
+</vector>
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_send_white_24dp.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_send_white_24dp.xml
new file mode 100644
index 00000000..f614267a
--- /dev/null
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/drawable/ic_send_white_24dp.xml
@@ -0,0 +1,24 @@
+<!--
+ * 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
+</vector>
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/activity_main.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/activity_main.xml
index 2043dd1d..b85f6c58 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/activity_main.xml
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/activity_main.xml
@@ -63,5 +63,14 @@
app:itemLogo="@drawable/ic_spinners_logo_24dp"
app:imageColor="@android:color/holo_orange_dark"/>
+ <com.example.android.autofillframework.app.NavigationItem
+ android:id="@+id/emailComposeButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:infoText="@string/email_compose_info"
+ app:labelText="@string/navigation_button_email_compose_label"
+ app:itemLogo="@drawable/ic_email_black_24dp"
+ app:imageColor="@android:color/holo_purple"/>
+
</LinearLayout>
</ScrollView> \ No newline at end of file
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/email_compose_activity.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/email_compose_activity.xml
new file mode 100644
index 00000000..0b7519f6
--- /dev/null
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/layout/email_compose_activity.xml
@@ -0,0 +1,123 @@
+<?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.
+-->
+<android.support.constraint.ConstraintLayout 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:importantForAutofill="noExcludeDescendants"
+ android:orientation="vertical"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin">
+
+
+ <TextView
+ android:id="@+id/email_compose_header"
+ style="@style/TextAppearance.AppCompat.Large"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/spacing_normal"
+ android:gravity="center"
+ android:text="@string/navigation_button_email_compose_label"
+ app:layout_constraintEnd_toStartOf="@+id/imageButton"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintHorizontal_chainStyle="spread"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <com.example.android.autofillframework.app.InfoButton
+ android:id="@+id/imageButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_info_black_24dp"
+ app:dialogText="@string/email_compose_info"
+ app:layout_constraintBottom_toBottomOf="@+id/email_compose_header"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toEndOf="@+id/email_compose_header"
+ app:layout_constraintTop_toTopOf="@+id/email_compose_header" />
+
+ <TextView
+ android:id="@+id/toLabel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/spacing_normal"
+ android:layout_marginEnd="@dimen/spacing_normal"
+ android:layout_marginStart="@dimen/spacing_normal"
+ android:layout_marginTop="@dimen/spacing_normal"
+ android:text="@string/to_label"
+ app:layout_constraintBottom_toBottomOf="@+id/toText"
+ app:layout_constraintEnd_toStartOf="@+id/toText"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/toText" />
+
+ <EditText
+ android:id="@+id/toText"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="@dimen/spacing_normal"
+ android:layout_marginTop="@dimen/spacing_normal"
+ android:inputType="textEmailAddress"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="@+id/bodyText"
+ app:layout_constraintTop_toBottomOf="@+id/email_compose_header" />
+
+ <TextView
+ android:id="@+id/bodyLabel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="@dimen/spacing_normal"
+ android:layout_marginStart="@dimen/spacing_normal"
+ android:text="@string/body_label"
+ app:layout_constraintEnd_toStartOf="@+id/bodyText"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/placeholder"
+ app:layout_constraintBottom_toBottomOf="@+id/placeholder"/>
+
+ <EditText
+ android:id="@+id/bodyText"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="@dimen/spacing_normal"
+ android:layout_marginStart="@dimen/spacing_normal"
+ android:layout_marginTop="@dimen/spacing_normal"
+ android:inputType="textMultiLine"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/bodyLabel"
+ app:layout_constraintTop_toBottomOf="@+id/toText" />
+
+ <View
+ android:id="@+id/placeholder"
+ android:layout_width="match_parent"
+ android:layout_height="36sp"
+ app:layout_constraintTop_toTopOf="@+id/bodyText"
+ app:layout_constraintStart_toStartOf="parent"
+ android:layout_marginStart="8dp" />
+
+ <android.support.design.widget.FloatingActionButton
+ android:id="@+id/sendButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:layout_marginEnd="8dp"
+ android:backgroundTint="@android:color/holo_purple"
+ android:src="@drawable/ic_send_white_24dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+</android.support.constraint.ConstraintLayout> \ No newline at end of file
diff --git a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml
index 55d96c4c..86ecdb05 100644
--- a/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml
+++ b/input/autofill/AutofillFramework/kotlinApp/Application/src/main/res/values/strings.xml
@@ -22,9 +22,10 @@
<string name="navigation_button_spinners_credit_card_label">Sample Credit Card Check Out Using Spinners</string>
<string name="navigation_button_edittext_login_label">Sample Login Using EditTexts</string>
<string name="navigation_button_autocomplete_login_label">Sample Login Using AutoCompleteTextViews</string>
+ <string name="navigation_button_email_compose_label">Sample Email Compose Using EditTexts</string>
<string name="username_label">Username</string>
<string name="password_label">Password</string>
- <string name="welcome_text">You have successfully signed in!</string>
+ <string name="welcome_text">Success!</string>
<string name="standard_view_sign_in">Sign in using standard views</string>
<string name="standard_view_autocomplete_sign_in">Sign in using standard views that
trigger AutoComplete dialogs when focused</string>
@@ -51,6 +52,8 @@
<string name="settings_auth_change_credentials_title">Change credentials</string>
<string name="clear_label">Clear</string>
<string name="login_label">Login</string>
+ <string name="to_label">To</string>
+ <string name="body_label">Body</string>
<string name="autofill_master_login_label">Autofill Master Login</string>
<string name="submit_label">Submit</string>
<string name="edittext_login_info">This is a sample login page that uses standard EditTexts
@@ -73,6 +76,14 @@
In that case, you need to tell the Autofill framework which values in the adapter map to
which indices.
</string>
+ <string name="email_compose_info">
+ This is a sample email compose page that uses EditTexts to compose the email. Since none of
+ the fields on the page are important to autofill, it is necessary to set the
+ android:importantForAutofill XML property appropriately for each View. You can either set it
+ to &quot;no&quot; on all non-autofillable Views, or set &quot;noExcludeDescendants&quot;
+ on the root View if all Views in the hierarchy should not be autofilled. In this case, we
+ did the latter.
+ </string>
<plurals name="welcome_page_countdown">
<item quantity="one">Automatically return to main page in %d second.</item>
<item quantity="other">Automatically return to main page in %d seconds.</item>