diff options
11 files changed, 471 insertions, 9 deletions
diff --git a/input/autofill/AutofillFramework/Application/src/main/AndroidManifest.xml b/input/autofill/AutofillFramework/Application/src/main/AndroidManifest.xml index da296dc5..8ea7960a 100644 --- a/input/autofill/AutofillFramework/Application/src/main/AndroidManifest.xml +++ b/input/autofill/AutofillFramework/Application/src/main/AndroidManifest.xml @@ -53,6 +53,9 @@ android:name=".app.CreditCardCompoundViewActivity" android:taskAffinity=".CreditCardCompoundViewActivity" /> <activity + android:name=".app.CreditCardDatePickerActivity" + android:taskAffinity=".CreditCardDatePickerActivity" /> + <activity android:name=".app.MultiplePartitionsActivity" android:taskAffinity=".MultiplePartitionsActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardCompoundViewActivity.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardCompoundViewActivity.java index dc064540..05f57d03 100644 --- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardCompoundViewActivity.java +++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardCompoundViewActivity.java @@ -28,7 +28,7 @@ import com.example.android.autofillframework.R; public class CreditCardCompoundViewActivity extends AppCompatActivity { - private CreditCardExpirationDateView mCcExpDateView; + private CreditCardExpirationDateCompoundView mCcExpDateView; private EditText mCcExpNumber; private EditText mCcSecurityCode; diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardDatePickerActivity.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardDatePickerActivity.java new file mode 100644 index 00000000..0f325e12 --- /dev/null +++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardDatePickerActivity.java @@ -0,0 +1,92 @@ +/* + * 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 static com.example.android.autofillframework.CommonUtil.TAG; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; +import android.view.View; +import android.view.autofill.AutofillManager; +import android.widget.EditText; + +import com.example.android.autofillframework.R; + +public class CreditCardDatePickerActivity extends AppCompatActivity { + + private CreditCardExpirationDatePickerView mCcExpDateView; + private EditText mCcExpNumber; + private EditText mCcSecurityCode; + + public static Intent getStartActivityIntent(Context context) { + Intent intent = new Intent(context, CreditCardDatePickerActivity.class); + return intent; + } + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.credit_card_date_picker_activity); + mCcExpDateView = findViewById(R.id.creditCardExpirationView); + mCcExpNumber = findViewById(R.id.creditCardNumberField); + mCcSecurityCode = findViewById(R.id.creditCardSecurityCode); + findViewById(R.id.submitButton).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + submit(); + } + }); + findViewById(R.id.clearButton).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getSystemService(AutofillManager.class).cancel(); + resetFields(); + } + }); + + // TODO: fix out style to display as an EditText? + mCcExpDateView.reset(); + } + + private void resetFields() { + mCcExpDateView.reset(); + mCcExpNumber.setText(""); + mCcSecurityCode.setText(""); + } + + public void showDatePickerDialog(View v) { + if (v != mCcExpDateView) { + Log.w(TAG, "showDatePickerDialog() called on invalid view: " + v); + return; + } + mCcExpDateView.showDatePickerDialog(getSupportFragmentManager()); + } + + + /** + * Launches new Activity and finishes, triggering an autofill save request if the user entered + * any new data. + */ + private void submit() { + Intent intent = WelcomeActivity.getStartActivityIntent(this); + startActivity(intent); + finish(); + } +} diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardExpirationDateView.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardExpirationDateCompoundView.java index 22a3777f..6d948648 100644 --- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardExpirationDateView.java +++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardExpirationDateCompoundView.java @@ -32,7 +32,11 @@ import com.example.android.autofillframework.R; import java.util.Calendar; -public class CreditCardExpirationDateView extends FrameLayout { +/** + * A custom view that represents a {@link View#AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE} using + * 2 {@link Spinner spinners} to represent the credit card expiration month and year. + */ +public class CreditCardExpirationDateCompoundView extends FrameLayout { private static final int CC_EXP_YEARS_COUNT = 5; @@ -41,20 +45,21 @@ public class CreditCardExpirationDateView extends FrameLayout { private Spinner mCcExpMonthSpinner; private Spinner mCcExpYearSpinner; - public CreditCardExpirationDateView(@NonNull Context context) { + public CreditCardExpirationDateCompoundView(@NonNull Context context) { this(context, null); } - public CreditCardExpirationDateView(@NonNull Context context, @Nullable AttributeSet attrs) { + public CreditCardExpirationDateCompoundView(@NonNull Context context, + @Nullable AttributeSet attrs) { this(context, attrs, 0); } - public CreditCardExpirationDateView(@NonNull Context context, @Nullable AttributeSet attrs, - int defStyleAttr) { + public CreditCardExpirationDateCompoundView(@NonNull Context context, + @Nullable AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } - public CreditCardExpirationDateView(@NonNull final Context context, + public CreditCardExpirationDateCompoundView(@NonNull final Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); View rootView = LayoutInflater.from(context).inflate(R.layout.cc_exp_date, this); @@ -76,7 +81,7 @@ public class CreditCardExpirationDateView extends FrameLayout { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { context.getSystemService(AutofillManager.class) - .notifyValueChanged(CreditCardExpirationDateView.this); + .notifyValueChanged(CreditCardExpirationDateCompoundView.this); } @Override diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardExpirationDatePickerView.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardExpirationDatePickerView.java new file mode 100644 index 00000000..e0ea5d00 --- /dev/null +++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/CreditCardExpirationDatePickerView.java @@ -0,0 +1,169 @@ +/* + * 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 static com.example.android.autofillframework.CommonUtil.DEBUG; +import static com.example.android.autofillframework.CommonUtil.TAG; + +import android.app.DatePickerDialog; +import android.app.Dialog; +import android.content.Context; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.DialogFragment; +import android.support.v4.app.FragmentManager; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; +import android.view.autofill.AutofillValue; +import android.widget.DatePicker; +import android.widget.EditText; + +import com.example.android.autofillframework.R; + +import java.lang.reflect.Field; +import java.util.Calendar; + +/** + * A custom view that represents a {@link View#AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE} using + * a non-editable {@link EditText} that triggers a {@link DatePickerDialog} to represent the + * credit card expiration month and year. + */ +public class CreditCardExpirationDatePickerView extends EditText { + + private static final int CC_EXP_YEARS_COUNT = 5; + + /** Calendar instance used for month / year calculations. Should be reset before each use. */ + private final Calendar mTempCalendar; + + private int mMonth; + private int mYear; + + public CreditCardExpirationDatePickerView(@NonNull Context context) { + this(context, null); + } + + public CreditCardExpirationDatePickerView(@NonNull Context context, + @Nullable AttributeSet attrs) { + this(context, attrs, 0); + } + + public CreditCardExpirationDatePickerView(@NonNull Context context, + @Nullable AttributeSet attrs, int defStyleAttr) { + this(context, attrs, defStyleAttr, 0); + } + + public CreditCardExpirationDatePickerView(@NonNull final Context context, + @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + + // Use the current date as the initial date in the picker. + mTempCalendar = Calendar.getInstance(); + mYear = mTempCalendar.get(Calendar.YEAR); + mMonth = mTempCalendar.get(Calendar.MONTH); + } + + /** + * Gets a temporary calendar set with the View's year and month. + */ + private Calendar getCalendar() { + mTempCalendar.clear(); + mTempCalendar.set(Calendar.YEAR, mYear); + mTempCalendar.set(Calendar.MONTH, mMonth); + return mTempCalendar; + } + + @Override + public AutofillValue getAutofillValue() { + Calendar c = getCalendar(); + AutofillValue value = AutofillValue.forDate(c.getTimeInMillis()); + if (DEBUG) Log.d(TAG, "getAutofillValue(): " + value); + return value; + } + + @Override + public void autofill(AutofillValue value) { + if (value == null || !value.isDate()) { + Log.w(TAG, "autofill(): invalid value " + value); + return; + } + long time = value.getDateValue(); + mTempCalendar.setTimeInMillis(time); + int year = mTempCalendar.get(Calendar.YEAR); + int month = mTempCalendar.get(Calendar.MONTH); + if (DEBUG) Log.d(TAG, "autofill(" + value + "): " + month + "/" + year); + setDate(year, month); + } + + private void setDate(int year, int month) { + mYear = year; + mMonth = month; + // TODO: use i18n / DateFormatter + String text = String.format("%2d/%d", mMonth + 1, mYear); + if (DEBUG) Log.d(TAG, "Formatted date: " + text); + setText(text); + } + + @Override + public int getAutofillType() { + return AUTOFILL_TYPE_DATE; + } + + public void reset() { + mTempCalendar.setTimeInMillis(System.currentTimeMillis()); + mYear = mTempCalendar.get(Calendar.YEAR); + mMonth = mTempCalendar.get(Calendar.MONTH); + // TODO: use i18n / DateFormatter + setText("MM/YYYY"); + } + + public void showDatePickerDialog(FragmentManager fragmentManager) { + DatePickerFragment newFragment = new DatePickerFragment(); + newFragment.mParent = this; + newFragment.show(fragmentManager, "datePicker"); + } + + public static class DatePickerFragment extends DialogFragment + implements DatePickerDialog.OnDateSetListener { + + private CreditCardExpirationDatePickerView mParent; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + DatePickerDialog dialog = new DatePickerDialog(getActivity(), + R.style.CustomDatePickerDialogTheme, this, mParent.mYear, mParent.mMonth, 0); + + DatePicker datePicker = dialog.getDatePicker(); + + // Limit range. + Calendar c = mParent.getCalendar(); + datePicker.setMinDate(c.getTimeInMillis()); + c.set(Calendar.YEAR, mParent.mYear + CC_EXP_YEARS_COUNT - 1); + datePicker.setMaxDate(c.getTimeInMillis()); + + // Remove day. + datePicker.findViewById(getResources().getIdentifier("day", "id", "android")) + .setVisibility(View.GONE); + return dialog; + } + + @Override + public void onDateSet(DatePicker view, int year, int month, int day) { + mParent.setDate(year, month); + } + } +}
\ No newline at end of file diff --git a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.java b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.java index 5cd9671c..9ad2e5c4 100644 --- a/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.java +++ b/input/autofill/AutofillFramework/Application/src/main/java/com/example/android/autofillframework/app/MainActivity.java @@ -47,6 +47,7 @@ public class MainActivity extends AppCompatActivity { NavigationItem loginAutoComplete = findViewById(R.id.standardLoginWithAutoCompleteButton); NavigationItem emailCompose = findViewById(R.id.emailComposeButton); NavigationItem creditCardCompoundView = findViewById(R.id.creditCardCompoundViewButton); + NavigationItem creditCardDatePicker = findViewById(R.id.creditCardDatePickerButton); NavigationItem mulitplePartitions = findViewById(R.id.multiplePartitionsButton); loginEditTexts.setNavigationButtonClickListener(new View.OnClickListener() { @Override @@ -84,6 +85,12 @@ public class MainActivity extends AppCompatActivity { startActivity(CreditCardCompoundViewActivity.getStartActivityIntent(MainActivity.this)); } }); + creditCardDatePicker.setNavigationButtonClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(CreditCardDatePickerActivity.getStartActivityIntent(MainActivity.this)); + } + }); mulitplePartitions.setNavigationButtonClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/activity_main.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/activity_main.xml index cbe708ab..34ca9b2b 100644 --- a/input/autofill/AutofillFramework/Application/src/main/res/layout/activity_main.xml +++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/activity_main.xml @@ -73,6 +73,15 @@ app:itemLogo="@drawable/ic_view_module_black_24dp" /> <com.example.android.autofillframework.app.NavigationItem + android:id="@+id/creditCardDatePickerButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:infoText="@string/date_picker_credit_card_info" + app:labelText="@string/navigation_button_date_picker_credit_card_label" + app:imageColor="@android:color/holo_blue_light" + app:itemLogo="@drawable/ic_view_module_black_24dp" /> + + <com.example.android.autofillframework.app.NavigationItem android:id="@+id/emailComposeButton" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/credit_card_compound_view_activity.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/credit_card_compound_view_activity.xml index 7fae6b6a..14db0386 100644 --- a/input/autofill/AutofillFramework/Application/src/main/res/layout/credit_card_compound_view_activity.xml +++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/credit_card_compound_view_activity.xml @@ -90,7 +90,7 @@ app:layout_constraintStart_toStartOf="@id/creditCardNumberLabel" app:layout_constraintTop_toBottomOf="@+id/creditCardNumberLabel" /> - <com.example.android.autofillframework.app.CreditCardExpirationDateView + <com.example.android.autofillframework.app.CreditCardExpirationDateCompoundView android:id="@+id/creditCardExpirationView" android:layout_width="250dp" android:layout_height="wrap_content" diff --git a/input/autofill/AutofillFramework/Application/src/main/res/layout/credit_card_date_picker_activity.xml b/input/autofill/AutofillFramework/Application/src/main/res/layout/credit_card_date_picker_activity.xml new file mode 100644 index 00000000..de5f7f59 --- /dev/null +++ b/input/autofill/AutofillFramework/Application/src/main/res/layout/credit_card_date_picker_activity.xml @@ -0,0 +1,162 @@ +<?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:id="@+id/authLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + 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/standard_login_header" + style="@style/TextAppearance.AppCompat.Large" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:gravity="center" + android:text="@string/navigation_button_compound_view_credit_card_label" + app:layout_constraintEnd_toEndOf="parent" + 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:layout_marginStart="@dimen/spacing_normal" + android:background="@drawable/ic_info_black_24dp" + app:dialogText="@string/compound_view_credit_card_info" + app:layout_constraintBottom_toBottomOf="@+id/standard_login_header" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toEndOf="@+id/standard_login_header" + app:layout_constraintTop_toTopOf="@+id/standard_login_header" /> + + <TextView + android:id="@+id/creditCardNumberLabel" + style="@style/TextAppearance.AppCompat.Body1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="@dimen/spacing_normal" + android:layout_marginStart="@dimen/spacing_normal" + android:layout_marginTop="@dimen/spacing_large" + android:labelFor="@+id/creditCardNumberField" + android:text="@string/credit_card_number_label" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/standard_login_header" /> + + <EditText + android:id="@+id/creditCardNumberField" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/spacing_normal" + android:layout_marginTop="@dimen/spacing_normal" + android:autofillHints="creditCardNumber" + android:ems="12" + android:inputType="number" + android:paddingHorizontal="@dimen/spacing_micro" + app:layout_constraintBottom_toBottomOf="@+id/creditCardNumberLabel" + app:layout_constraintStart_toEndOf="@+id/creditCardNumberLabel" + app:layout_constraintTop_toTopOf="@+id/creditCardNumberLabel" /> + + <TextView + android:id="@+id/creditCardExpirationLabel" + style="@style/TextAppearance.AppCompat.Body1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacing_large" + android:labelFor="@+id/creditCardExpirationView" + android:text="@string/credit_card_expiration_label" + app:layout_constraintStart_toStartOf="@id/creditCardNumberLabel" + app:layout_constraintTop_toBottomOf="@+id/creditCardNumberLabel" /> + + <com.example.android.autofillframework.app.CreditCardExpirationDatePickerView + android:id="@+id/creditCardExpirationView" + android:layout_width="250dp" + android:layout_height="wrap_content" + android:layout_marginEnd="8dp" + android:layout_marginStart="@dimen/spacing_normal" + android:layout_marginTop="@dimen/spacing_normal" + android:autofillHints="creditCardExpirationDate" + android:onClick="showDatePickerDialog" + app:layout_constraintBottom_toBottomOf="@+id/creditCardExpirationLabel" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@+id/creditCardExpirationLabel" + app:layout_constraintTop_toTopOf="@+id/creditCardExpirationLabel" /> + + <TextView + android:id="@+id/creditCardSecurityCodeLabel" + style="@style/TextAppearance.AppCompat.Body1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacing_large" + android:importantForAutofill="no" + android:text="@string/credit_card_security_code_label" + app:layout_constraintEnd_toStartOf="@+id/expirationDate" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/creditCardExpirationView" /> + + <!-- TODO: it's overlapping with @+id/creditCardExpirationView --> + <EditText + android:id="@+id/creditCardSecurityCode" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/creditCardSecurityCodeLabel" + android:layout_marginEnd="8dp" + android:inputType="number" + android:autofillHints="creditCardSecurityCode" + app:layout_constraintBottom_toBottomOf="@+id/creditCardSecurityCodeLabel" + app:layout_constraintEnd_toEndOf="@+id/creditCardExpirationView" + app:layout_constraintStart_toStartOf="@+id/creditCardExpirationView" + app:layout_constraintTop_toTopOf="@+id/creditCardSecurityCodeLabel" /> + + <TextView + android:id="@+id/clearButton" + style="@style/Widget.AppCompat.Button.Borderless" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/spacing_normal" + android:layout_marginTop="@dimen/spacing_normal" + android:text="@string/clear_label" + android:textColor="@android:color/holo_blue_dark" + app:layout_constraintEnd_toStartOf="@+id/submitButton" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintHorizontal_chainStyle="packed" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/creditCardSecurityCodeLabel" /> + + <TextView + android:id="@+id/submitButton" + style="@style/Widget.AppCompat.Button.Borderless" + 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/submit_label" + android:textColor="@android:color/holo_blue_dark" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toEndOf="@+id/clearButton" + app:layout_constraintTop_toTopOf="@+id/clearButton" /> + +</android.support.constraint.ConstraintLayout>
\ No newline at end of file diff --git a/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml b/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml index 177c5e6d..89ec9d4b 100644 --- a/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml +++ b/input/autofill/AutofillFramework/Application/src/main/res/values/strings.xml @@ -24,6 +24,7 @@ <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="navigation_button_compound_view_credit_card_label">Sample Credit Card Check Out Using Compound Views</string> + <string name="navigation_button_date_picker_credit_card_label">Sample Credit Card Check Out Using Date Picker</string> <string name="navigation_button_multiple_partitions_label">Sample Page with Multiple Data Partitions</string> <string name="username_label">Username</string> <string name="password_label">Password</string> @@ -99,6 +100,12 @@ optimized out of the box for autofill, this example shows how to implement certain Autofill- specific methods and XML properties for the custom compound view. </string> + <string name="date_picker_credit_card_info"> + This is a sample credit card checkout page that uses a custom EditText and a DatePicker + to input the credit card\'s expiration date and an EditText to input the credit card number. + While the EditText is optimized out of the box for autofill, this example shows how to + use it to autofill a date field. + </string> <string name="multiple_partitions"> This is a sample page that contains multiple partitions (login credentials, address, credit card info) and can be used to make sure that only one partition can be autofilled diff --git a/input/autofill/AutofillFramework/Application/src/main/res/values/styles.xml b/input/autofill/AutofillFramework/Application/src/main/res/values/styles.xml index 8fe4718f..c44f9991 100644 --- a/input/autofill/AutofillFramework/Application/src/main/res/values/styles.xml +++ b/input/autofill/AutofillFramework/Application/src/main/res/values/styles.xml @@ -41,4 +41,12 @@ <item name="android:paddingStart">?android:listPreferredItemPaddingStart</item> <item name="android:paddingBottom">@dimen/spacing_normal</item> </style> + + <style name="CustomDatePickerDialogTheme" parent="android:Theme.Material.Light.Dialog"> + <item name="android:datePickerStyle">@style/MyDatePickerStyle</item> + </style> + + <style name="MyDatePickerStyle" parent="@android:style/Widget.Material.DatePicker"> + <item name="android:datePickerMode">spinner</item> + </style> </resources>
\ No newline at end of file |