File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
lib/java/com/google/android/material Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 2828import androidx .annotation .RestrictTo .Scope ;
2929import androidx .core .util .Pair ;
3030import androidx .core .util .Preconditions ;
31+ import android .text .InputType ;
3132import android .util .DisplayMetrics ;
3233import android .view .LayoutInflater ;
3334import android .view .View ;
3435import android .view .ViewGroup ;
3536import android .widget .EditText ;
37+ import com .google .android .material .internal .ManufacturerUtils ;
3638import com .google .android .material .internal .ViewUtils ;
3739import com .google .android .material .resources .MaterialAttributes ;
3840import com .google .android .material .textfield .TextInputLayout ;
@@ -178,6 +180,12 @@ public View onCreateTextInputView(
178180 final TextInputLayout endTextInput = root .findViewById (R .id .mtrl_picker_text_input_range_end );
179181 EditText startEditText = startTextInput .getEditText ();
180182 EditText endEditText = endTextInput .getEditText ();
183+ // The date inputType for Samsung does not include any separator characters
184+ if (ManufacturerUtils .isSamsungDevice ()) {
185+ // Using the URI variation places the '/' and '.' in more prominent positions
186+ startEditText .setInputType (InputType .TYPE_CLASS_TEXT | InputType .TYPE_TEXT_VARIATION_URI );
187+ endEditText .setInputType (InputType .TYPE_CLASS_TEXT | InputType .TYPE_TEXT_VARIATION_URI );
188+ }
181189
182190 invalidRangeStartError = root .getResources ().getString (R .string .mtrl_picker_invalid_range );
183191
Original file line number Diff line number Diff line change 2727import androidx .annotation .RestrictTo ;
2828import androidx .annotation .RestrictTo .Scope ;
2929import androidx .core .util .Pair ;
30+ import android .text .InputType ;
3031import android .view .LayoutInflater ;
3132import android .view .View ;
3233import android .view .ViewGroup ;
3334import android .widget .EditText ;
35+ import com .google .android .material .internal .ManufacturerUtils ;
3436import com .google .android .material .internal .ViewUtils ;
3537import com .google .android .material .resources .MaterialAttributes ;
3638import com .google .android .material .textfield .TextInputLayout ;
@@ -100,6 +102,11 @@ public View onCreateTextInputView(
100102
101103 TextInputLayout dateTextInput = root .findViewById (R .id .mtrl_picker_text_input_date );
102104 EditText dateEditText = dateTextInput .getEditText ();
105+ // The date inputType for Samsung does not include any separator characters
106+ if (ManufacturerUtils .isSamsungDevice ()) {
107+ // Using the URI variation places the '/' and '.' in more prominent positions
108+ dateEditText .setInputType (InputType .TYPE_CLASS_TEXT | InputType .TYPE_TEXT_VARIATION_URI );
109+ }
103110 SimpleDateFormat format = UtcDates .getTextInputFormat ();
104111 String formatHint = UtcDates .getTextInputHint (root .getResources (), format );
105112
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2019 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package com .google .android .material .internal ;
17+
18+ import com .google .android .material .R ;
19+
20+ import android .os .Build ;
21+ import androidx .annotation .RestrictTo ;
22+ import androidx .annotation .RestrictTo .Scope ;
23+
24+ /** Utils to determine device manufacturers for special handling. */
25+ @ RestrictTo (Scope .LIBRARY_GROUP )
26+ public class ManufacturerUtils {
27+
28+ private ManufacturerUtils () {}
29+
30+ /** Returns true if the device manufacturer is Samsung. */
31+ public static boolean isSamsungDevice () {
32+ return Build .MANUFACTURER .equalsIgnoreCase ("samsung" );
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments