Merge "DO NOT MERGE Update scroll up and down behavior" into qt-car-dev
diff --git a/car-assist-client-lib/res/values-iw/strings.xml b/car-assist-client-lib/res/values-iw/strings.xml
index 510432d..dc96640 100644
--- a/car-assist-client-lib/res/values-iw/strings.xml
+++ b/car-assist-client-lib/res/values-iw/strings.xml
@@ -16,6 +16,6 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="assist_action_failed_toast" msgid="3250146468076483714">"לא ניתן לבקש מה-Assistant לבצע פעולה!"</string>
+ <string name="assist_action_failed_toast" msgid="3250146468076483714">"לא ניתן לבקש מ-Assistant לבצע פעולה!"</string>
<string name="says" msgid="8575666015622916107">"רוצה להודיע כי"</string>
</resources>
diff --git a/car-broadcastradio-support/res/values-bs/strings.xml b/car-broadcastradio-support/res/values-bs/strings.xml
index 42ff388..e29e90e 100644
--- a/car-broadcastradio-support/res/values-bs/strings.xml
+++ b/car-broadcastradio-support/res/values-bs/strings.xml
@@ -20,5 +20,5 @@
<string name="radio_fm_text" msgid="1973045042281933494">"FM"</string>
<string name="radio_dab_text" msgid="8456449462266648979">"DAB"</string>
<string name="program_list_text" msgid="4414150317304422313">"Stanice"</string>
- <string name="favorites_list_text" msgid="7829827713977109155">"Omiljeni"</string>
+ <string name="favorites_list_text" msgid="7829827713977109155">"Omiljeno"</string>
</resources>
diff --git a/car-broadcastradio-support/res/values-is/strings.xml b/car-broadcastradio-support/res/values-is/strings.xml
index 1a2074a..b7e9135 100644
--- a/car-broadcastradio-support/res/values-is/strings.xml
+++ b/car-broadcastradio-support/res/values-is/strings.xml
@@ -20,5 +20,5 @@
<string name="radio_fm_text" msgid="1973045042281933494">"FM"</string>
<string name="radio_dab_text" msgid="8456449462266648979">"DAB"</string>
<string name="program_list_text" msgid="4414150317304422313">"Stöðvar"</string>
- <string name="favorites_list_text" msgid="7829827713977109155">"Eftirlæti"</string>
+ <string name="favorites_list_text" msgid="7829827713977109155">"Uppáhald"</string>
</resources>
diff --git a/car-broadcastradio-support/res/values-ky/strings.xml b/car-broadcastradio-support/res/values-ky/strings.xml
index 4640491..ee67f46 100644
--- a/car-broadcastradio-support/res/values-ky/strings.xml
+++ b/car-broadcastradio-support/res/values-ky/strings.xml
@@ -20,5 +20,5 @@
<string name="radio_fm_text" msgid="1973045042281933494">"FM"</string>
<string name="radio_dab_text" msgid="8456449462266648979">"DAB"</string>
<string name="program_list_text" msgid="4414150317304422313">"Станциялар"</string>
- <string name="favorites_list_text" msgid="7829827713977109155">"Сүйүктүүлөр"</string>
+ <string name="favorites_list_text" msgid="7829827713977109155">"Тандалмалар"</string>
</resources>
diff --git a/car-broadcastradio-support/res/values-uz/strings.xml b/car-broadcastradio-support/res/values-uz/strings.xml
index 5ff7a60..bfb89d7 100644
--- a/car-broadcastradio-support/res/values-uz/strings.xml
+++ b/car-broadcastradio-support/res/values-uz/strings.xml
@@ -20,5 +20,5 @@
<string name="radio_fm_text" msgid="1973045042281933494">"FM"</string>
<string name="radio_dab_text" msgid="8456449462266648979">"Raqamli radio"</string>
<string name="program_list_text" msgid="4414150317304422313">"Radiostansiyalar"</string>
- <string name="favorites_list_text" msgid="7829827713977109155">"Saralanganlar"</string>
+ <string name="favorites_list_text" msgid="7829827713977109155">"Saralangan"</string>
</resources>
diff --git a/car-messenger-common/res/values-fr-rCA/strings.xml b/car-messenger-common/res/values-fr-rCA/strings.xml
index 56086e6..9bbe2c7 100644
--- a/car-messenger-common/res/values-fr-rCA/strings.xml
+++ b/car-messenger-common/res/values-fr-rCA/strings.xml
@@ -19,6 +19,7 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<plurals name="notification_new_message" formatted="false" msgid="1631343923556571689">
<item quantity="one">%d nouveau message</item>
+ <item quantity="many">%d new messages</item>
<item quantity="other">%d nouveaux messages</item>
</plurals>
<string name="action_play" msgid="1884580550634079470">"Faire jouer"</string>
diff --git a/car-messenger-common/res/values-fr/strings.xml b/car-messenger-common/res/values-fr/strings.xml
index a96b14f..12cb2f7 100644
--- a/car-messenger-common/res/values-fr/strings.xml
+++ b/car-messenger-common/res/values-fr/strings.xml
@@ -19,6 +19,7 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<plurals name="notification_new_message" formatted="false" msgid="1631343923556571689">
<item quantity="one">%d nouveau message</item>
+ <item quantity="many">%d new messages</item>
<item quantity="other">%d nouveaux messages</item>
</plurals>
<string name="action_play" msgid="1884580550634079470">"Lire"</string>
diff --git a/car-messenger-common/res/values-mn/strings.xml b/car-messenger-common/res/values-mn/strings.xml
index d47453b..0cd0bcc 100644
--- a/car-messenger-common/res/values-mn/strings.xml
+++ b/car-messenger-common/res/values-mn/strings.xml
@@ -18,8 +18,8 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<plurals name="notification_new_message" formatted="false" msgid="1631343923556571689">
- <item quantity="other">%d шинэ зурвас</item>
- <item quantity="one">Шинэ зурвас</item>
+ <item quantity="other">%d шинэ мессеж</item>
+ <item quantity="one">Шинэ мессеж</item>
</plurals>
<string name="action_play" msgid="1884580550634079470">"Тоглуулах"</string>
<string name="action_mark_as_read" msgid="5185216939940407938">"Уншсан гэж тэмдэглэх"</string>
@@ -30,7 +30,7 @@
<string name="auto_reply_failed_message" msgid="6445984971657465627">"Хариу илгээх боломжгүй байна. Дахин оролдоно уу."</string>
<string name="auto_reply_device_disconnected" msgid="5861772755278229950">"Хариу илгээх боломжгүй байна. Төхөөрөмж холбогдоогүй байна."</string>
<string name="tts_sender_says" msgid="5352698006545359668">"%s хэлж байна"</string>
- <string name="tts_failed_toast" msgid="1483313550894086353">"Зурвасыг унших боломжгүй байна."</string>
+ <string name="tts_failed_toast" msgid="1483313550894086353">"Мессежийг унших боломжгүй байна."</string>
<string name="reply_message_display_template" msgid="6348622926232346974">"\"%s\""</string>
<string name="message_sent_notice" msgid="7172592196465284673">"%s-д хариу илгээсэн"</string>
<string name="name_not_available" msgid="3800013092212550915">"Нэр ашиглалтад алга"</string>
diff --git a/car-telephony-common/res/values-bg/strings.xml b/car-telephony-common/res/values-bg/strings.xml
index 1f38d61..ac7dbf6 100644
--- a/car-telephony-common/res/values-bg/strings.xml
+++ b/car-telephony-common/res/values-bg/strings.xml
@@ -20,7 +20,7 @@
<string name="voicemail" msgid="2125552157407909509">"Гласова поща"</string>
<string name="phone_label_with_info" msgid="4652109530699808645">"<xliff:g id="LABEL">%1$s</xliff:g> · <xliff:g id="DURATION">%2$s</xliff:g>"</string>
<string name="call_state_connecting" msgid="5930724746375294866">"Свързва се…"</string>
- <string name="call_state_dialing" msgid="1534599871716648114">"Набира се…"</string>
+ <string name="call_state_dialing" msgid="1534599871716648114">"Набиране…"</string>
<string name="call_state_hold" msgid="6834028102796624100">"Задържано"</string>
<string name="call_state_call_ended" msgid="4159349597599886429">"Обаждането завърши"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"Установена е връзка"</string>
diff --git a/car-telephony-common/res/values-da/strings.xml b/car-telephony-common/res/values-da/strings.xml
index dcd52a0..6995f5c 100644
--- a/car-telephony-common/res/values-da/strings.xml
+++ b/car-telephony-common/res/values-da/strings.xml
@@ -21,7 +21,7 @@
<string name="phone_label_with_info" msgid="4652109530699808645">"<xliff:g id="LABEL">%1$s</xliff:g> · <xliff:g id="DURATION">%2$s</xliff:g>"</string>
<string name="call_state_connecting" msgid="5930724746375294866">"Tilslutter…"</string>
<string name="call_state_dialing" msgid="1534599871716648114">"Ringer op…"</string>
- <string name="call_state_hold" msgid="6834028102796624100">"Afventer"</string>
+ <string name="call_state_hold" msgid="6834028102796624100">"På hold"</string>
<string name="call_state_call_ended" msgid="4159349597599886429">"Opkaldet er slut"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"Der er forbindelse"</string>
<string name="call_state_call_ringing" msgid="4618803402954375017">"Ringer…"</string>
diff --git a/car-telephony-common/res/values-et/strings.xml b/car-telephony-common/res/values-et/strings.xml
index ee65909..e74cb8a 100644
--- a/car-telephony-common/res/values-et/strings.xml
+++ b/car-telephony-common/res/values-et/strings.xml
@@ -25,5 +25,5 @@
<string name="call_state_call_ended" msgid="4159349597599886429">"Kõne lõpetati"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"Ühendatud"</string>
<string name="call_state_call_ringing" msgid="4618803402954375017">"Heliseb …"</string>
- <string name="call_state_call_ending" msgid="5037498349965472247">"Ühenduse katkest. …"</string>
+ <string name="call_state_call_ending" msgid="5037498349965472247">"Ühenduse katkestamine…"</string>
</resources>
diff --git a/car-telephony-common/res/values-in/strings.xml b/car-telephony-common/res/values-in/strings.xml
index 53a7831..9ef213c 100644
--- a/car-telephony-common/res/values-in/strings.xml
+++ b/car-telephony-common/res/values-in/strings.xml
@@ -25,5 +25,5 @@
<string name="call_state_call_ended" msgid="4159349597599886429">"Panggilan Diakhiri"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"Terhubung"</string>
<string name="call_state_call_ringing" msgid="4618803402954375017">"Berdering…"</string>
- <string name="call_state_call_ending" msgid="5037498349965472247">"Memutus hubungan..."</string>
+ <string name="call_state_call_ending" msgid="5037498349965472247">"Memutus sambungan..."</string>
</resources>
diff --git a/car-telephony-common/res/values-iw/strings.xml b/car-telephony-common/res/values-iw/strings.xml
index 0d1cd68..8e0fe49 100644
--- a/car-telephony-common/res/values-iw/strings.xml
+++ b/car-telephony-common/res/values-iw/strings.xml
@@ -20,7 +20,7 @@
<string name="voicemail" msgid="2125552157407909509">"דואר קולי"</string>
<string name="phone_label_with_info" msgid="4652109530699808645">"<xliff:g id="LABEL">%1$s</xliff:g> · <xliff:g id="DURATION">%2$s</xliff:g>"</string>
<string name="call_state_connecting" msgid="5930724746375294866">"מתחבר…"</string>
- <string name="call_state_dialing" msgid="1534599871716648114">"מחייג…"</string>
+ <string name="call_state_dialing" msgid="1534599871716648114">"החיוג מתבצע…"</string>
<string name="call_state_hold" msgid="6834028102796624100">"בהמתנה"</string>
<string name="call_state_call_ended" msgid="4159349597599886429">"השיחה הסתיימה"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"מתבצעת שיחה"</string>
diff --git a/car-telephony-common/res/values-ms/strings.xml b/car-telephony-common/res/values-ms/strings.xml
index 1c1d5de..fcde473 100644
--- a/car-telephony-common/res/values-ms/strings.xml
+++ b/car-telephony-common/res/values-ms/strings.xml
@@ -25,5 +25,5 @@
<string name="call_state_call_ended" msgid="4159349597599886429">"Panggilan Tamat"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"Disambungkan"</string>
<string name="call_state_call_ringing" msgid="4618803402954375017">"Berdering…"</string>
- <string name="call_state_call_ending" msgid="5037498349965472247">"Memutuskan sambungn…"</string>
+ <string name="call_state_call_ending" msgid="5037498349965472247">"Memutuskan sambungan…"</string>
</resources>
diff --git a/car-telephony-common/res/values-ne/strings.xml b/car-telephony-common/res/values-ne/strings.xml
index b021f11..331c544 100644
--- a/car-telephony-common/res/values-ne/strings.xml
+++ b/car-telephony-common/res/values-ne/strings.xml
@@ -23,7 +23,7 @@
<string name="call_state_dialing" msgid="1534599871716648114">"डायल गर्दै…"</string>
<string name="call_state_hold" msgid="6834028102796624100">"होल्डमा छ"</string>
<string name="call_state_call_ended" msgid="4159349597599886429">"कल समाप्त भयो"</string>
- <string name="call_state_call_active" msgid="2769644783657864202">"जडान गरिएको छ"</string>
+ <string name="call_state_call_active" msgid="2769644783657864202">"कनेक्ट गरिएको छ"</string>
<string name="call_state_call_ringing" msgid="4618803402954375017">"घन्टी बज्दै छ…"</string>
<string name="call_state_call_ending" msgid="5037498349965472247">"विच्छेद गर्दै…"</string>
</resources>
diff --git a/car-telephony-common/res/values-nl/strings.xml b/car-telephony-common/res/values-nl/strings.xml
index 7d00163..53543e8 100644
--- a/car-telephony-common/res/values-nl/strings.xml
+++ b/car-telephony-common/res/values-nl/strings.xml
@@ -25,5 +25,5 @@
<string name="call_state_call_ended" msgid="4159349597599886429">"Gesprek beëindigd"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"Verbonden"</string>
<string name="call_state_call_ringing" msgid="4618803402954375017">"Gaat over…"</string>
- <string name="call_state_call_ending" msgid="5037498349965472247">"Verb. verbreken…"</string>
+ <string name="call_state_call_ending" msgid="5037498349965472247">"Verbreken…"</string>
</resources>
diff --git a/car-telephony-common/res/values-pt/strings.xml b/car-telephony-common/res/values-pt/strings.xml
index 7531adb..1bf5282 100644
--- a/car-telephony-common/res/values-pt/strings.xml
+++ b/car-telephony-common/res/values-pt/strings.xml
@@ -20,7 +20,7 @@
<string name="voicemail" msgid="2125552157407909509">"Correio de voz"</string>
<string name="phone_label_with_info" msgid="4652109530699808645">"<xliff:g id="LABEL">%1$s</xliff:g> · <xliff:g id="DURATION">%2$s</xliff:g>"</string>
<string name="call_state_connecting" msgid="5930724746375294866">"Conectando…"</string>
- <string name="call_state_dialing" msgid="1534599871716648114">"Discando…"</string>
+ <string name="call_state_dialing" msgid="1534599871716648114">"Chamando...…"</string>
<string name="call_state_hold" msgid="6834028102796624100">"Em espera"</string>
<string name="call_state_call_ended" msgid="4159349597599886429">"Chamada encerrada"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"Conectado"</string>
diff --git a/car-telephony-common/res/values-sw/strings.xml b/car-telephony-common/res/values-sw/strings.xml
index fc82d68..18a33e0 100644
--- a/car-telephony-common/res/values-sw/strings.xml
+++ b/car-telephony-common/res/values-sw/strings.xml
@@ -20,10 +20,10 @@
<string name="voicemail" msgid="2125552157407909509">"Ujumbe wa sauti"</string>
<string name="phone_label_with_info" msgid="4652109530699808645">"<xliff:g id="LABEL">%1$s</xliff:g> · <xliff:g id="DURATION">%2$s</xliff:g>"</string>
<string name="call_state_connecting" msgid="5930724746375294866">"Inaunganisha…"</string>
- <string name="call_state_dialing" msgid="1534599871716648114">"Inapigia…"</string>
+ <string name="call_state_dialing" msgid="1534599871716648114">"Inapiga…"</string>
<string name="call_state_hold" msgid="6834028102796624100">"Imesitishwa"</string>
<string name="call_state_call_ended" msgid="4159349597599886429">"Simu Imekamilika"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"Imeunganisha"</string>
<string name="call_state_call_ringing" msgid="4618803402954375017">"Inalia…"</string>
- <string name="call_state_call_ending" msgid="5037498349965472247">"Inaondoa…"</string>
+ <string name="call_state_call_ending" msgid="5037498349965472247">"Inakata…"</string>
</resources>
diff --git a/car-telephony-common/res/values-th/strings.xml b/car-telephony-common/res/values-th/strings.xml
index 7af5876..e627b44 100644
--- a/car-telephony-common/res/values-th/strings.xml
+++ b/car-telephony-common/res/values-th/strings.xml
@@ -25,5 +25,5 @@
<string name="call_state_call_ended" msgid="4159349597599886429">"วางสายแล้ว"</string>
<string name="call_state_call_active" msgid="2769644783657864202">"เชื่อมต่อแล้ว"</string>
<string name="call_state_call_ringing" msgid="4618803402954375017">"กำลังส่งเสียง…"</string>
- <string name="call_state_call_ending" msgid="5037498349965472247">"ยกเลิกการเชื่อมต่อ…"</string>
+ <string name="call_state_call_ending" msgid="5037498349965472247">"ยกเลิกการโทรออก…"</string>
</resources>
diff --git a/car-telephony-common/src/com/android/car/telephony/common/TelecomUtils.java b/car-telephony-common/src/com/android/car/telephony/common/TelecomUtils.java
index 6575992..1d934ec 100644
--- a/car-telephony-common/src/com/android/car/telephony/common/TelecomUtils.java
+++ b/car-telephony-common/src/com/android/car/telephony/common/TelecomUtils.java
@@ -129,11 +129,10 @@
}
String countryIso = getCurrentCountryIso(context);
- L.d(TAG, "PhoneNumberUtils.formatNumberToE16, number: "
- + number + ", country: " + countryIso);
+ L.d(TAG, "PhoneNumberUtils.formatNumber, number: " + number
+ + ", country: " + countryIso);
- String e164 = PhoneNumberUtils.formatNumberToE164(number, countryIso);
- String formattedNumber = PhoneNumberUtils.formatNumber(number, e164, countryIso);
+ String formattedNumber = PhoneNumberUtils.formatNumber(number, countryIso);
formattedNumber = TextUtils.isEmpty(formattedNumber) ? number : formattedNumber;
L.d(TAG, "getFormattedNumber, result: " + formattedNumber);
diff --git a/car-ui-lib/referencedesign/AndroidManifest.xml b/car-ui-lib/referencedesign/AndroidManifest.xml
index 6b4c165..7585b3c 100644
--- a/car-ui-lib/referencedesign/AndroidManifest.xml
+++ b/car-ui-lib/referencedesign/AndroidManifest.xml
@@ -11,6 +11,6 @@
android:targetName="car-ui-lib"
android:isStatic="true"
android:category="BypassIdMapV1"
- android:requiredSystemPropertyName="ro.build.characteristics"
- android:requiredSystemPropertyValue="automotive"/>
+ android:requiredSystemPropertyName="ro.build.car_ui_rros_enabled"
+ android:requiredSystemPropertyValue="true"/>
</manifest>
diff --git a/car-ui-lib/referencedesign/product.mk b/car-ui-lib/referencedesign/product.mk
index c5fc9f1..f77e94d 100644
--- a/car-ui-lib/referencedesign/product.mk
+++ b/car-ui-lib/referencedesign/product.mk
@@ -33,3 +33,7 @@
googlecarui-com-google-android-carassistant \
googlecarui-com-google-android-tts \
googlecarui-com-android-vending \
+
+# This system property is used to enable the RROs on startup via
+# the requiredSystemPropertyName/Value attributes in the manifest
+PRODUCT_PRODUCT_PROPERTIES += ro.build.car_ui_rros_enabled=true
diff --git a/car-ui-lib/res/values-ky/strings.xml b/car-ui-lib/res/values-ky/strings.xml
index b5ddc5d..5d55581 100644
--- a/car-ui-lib/res/values-ky/strings.xml
+++ b/car-ui-lib/res/values-ky/strings.xml
@@ -24,7 +24,7 @@
<string name="car_ui_toolbar_menu_item_settings_title" msgid="6694060516340354337">"Жөндөөлөр"</string>
<string name="car_ui_toolbar_menu_item_overflow_title" msgid="771643815366812499">"Кошумча меню"</string>
<string name="car_ui_dialog_preference_positive" msgid="1918267574135176336">"Жарайт"</string>
- <string name="car_ui_dialog_preference_negative" msgid="4156315694902086271">"Жокко чыгаруу"</string>
+ <string name="car_ui_dialog_preference_negative" msgid="4156315694902086271">"Жок"</string>
<string name="car_ui_preference_switch_on" msgid="5512335363135043642">"Күйүк"</string>
<string name="car_ui_preference_switch_off" msgid="4393435896926380920">"Өчүк"</string>
<string name="car_ui_alert_dialog_default_button" msgid="1775326289021319685">"Жабуу"</string>
diff --git a/car-ui-lib/res/values-uk/strings.xml b/car-ui-lib/res/values-uk/strings.xml
index e32c605..4188f47 100644
--- a/car-ui-lib/res/values-uk/strings.xml
+++ b/car-ui-lib/res/values-uk/strings.xml
@@ -16,7 +16,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="car_ui_toolbar_default_search_hint" msgid="7807151740020494659">"Шукайте…"</string>
+ <string name="car_ui_toolbar_default_search_hint" msgid="7807151740020494659">"Пошук…"</string>
<string name="car_ui_scrollbar_page_down_button" msgid="2419547312871553905">"Прокрутити вниз"</string>
<string name="car_ui_scrollbar_page_up_button" msgid="4152120100101092092">"Прокрутити вгору"</string>
<string name="car_ui_toolbar_nav_icon_content_description" msgid="2689756063478650269">"Назад"</string>
diff --git a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiRecyclerView.java b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiRecyclerView.java
index 152ff84..36ed154 100644
--- a/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiRecyclerView.java
+++ b/car-ui-lib/src/com/android/car/ui/recyclerview/CarUiRecyclerView.java
@@ -51,11 +51,12 @@
import com.android.car.ui.utils.CarUxRestrictionsUtil;
import java.lang.annotation.Retention;
+import java.util.Objects;
/**
- * View that extends a {@link RecyclerView} and wraps itself into a {@link LinearLayout} which
- * could potentially include a scrollbar that has page up and down arrows. Interaction with this
- * view is similar to a {@code RecyclerView} as it takes the same adapter and the layout manager.
+ * View that extends a {@link RecyclerView} and wraps itself into a {@link LinearLayout} which could
+ * potentially include a scrollbar that has page up and down arrows. Interaction with this view is
+ * similar to a {@code RecyclerView} as it takes the same adapter and the layout manager.
*/
public final class CarUiRecyclerView extends RecyclerView implements
Toolbar.OnHeightChangedListener {
@@ -79,16 +80,17 @@
@CarUiRecyclerViewLayout
private int mCarUiRecyclerViewLayout;
- @NonNull
+ @Nullable
private GridOffsetItemDecoration mTopOffsetItemDecorationGrid;
- @NonNull
+ @Nullable
private GridOffsetItemDecoration mBottomOffsetItemDecorationGrid;
- @NonNull
+ @Nullable
private RecyclerView.ItemDecoration mTopOffsetItemDecorationLinear;
- @NonNull
+ @Nullable
private RecyclerView.ItemDecoration mBottomOffsetItemDecorationLinear;
- @NonNull
+ @Nullable
private GridDividerItemDecoration mDividerItemDecorationGrid;
+ @Nullable
private RecyclerView.ItemDecoration mDividerItemDecorationLinear;
private int mNumOfColumns;
private boolean mInstallingExtScrollBar = false;
@@ -97,6 +99,8 @@
private Rect mContainerPaddingRelative;
private LinearLayout mContainer;
+ // Set to true when when styled attributes are read and initialized.
+ private boolean mIsInitialized;
private boolean mEnableDividers;
private int mTopOffset;
private int mBottomOffset;
@@ -119,13 +123,15 @@
@Retention(SOURCE)
public @interface CarUiRecyclerViewLayout {
/**
- * Arranges items either horizontally in a single row or vertically in a single column.
- * This is default.
+ * Arranges items either horizontally in a single row or vertically in a single column. This
+ * is default.
*/
int LINEAR = 0;
- /** Arranges items in a Grid. */
- int GRID = 2;
+ /**
+ * Arranges items in a Grid.
+ */
+ int GRID = 1;
}
/**
@@ -152,8 +158,7 @@
/**
* Sets the maximum number of items available in the adapter. A value less than '0' means
- * the
- * list should not be capped.
+ * the list should not be capped.
*/
void setMaxItems(int maxItems);
}
@@ -217,14 +222,20 @@
mBottomOffsetItemDecorationGrid =
new GridOffsetItemDecoration(mBottomOffset, mNumOfColumns,
OffsetPosition.END);
- if (mCarUiRecyclerViewLayout == CarUiRecyclerViewLayout.LINEAR) {
+
+ mIsInitialized = true;
+
+ // Check if a layout manager has already been set via XML
+ boolean isLayoutMangerSet = getLayoutManager() != null;
+ if (!isLayoutMangerSet && mCarUiRecyclerViewLayout == CarUiRecyclerViewLayout.LINEAR) {
setLayoutManager(new LinearLayoutManager(getContext()));
- } else {
+ } else if (!isLayoutMangerSet && mCarUiRecyclerViewLayout == CarUiRecyclerViewLayout.GRID) {
setLayoutManager(new GridLayoutManager(getContext(), mNumOfColumns));
}
+ a.recycle();
+
if (!mScrollBarEnabled) {
- a.recycle();
mFullyInitialized = true;
return;
}
@@ -235,37 +246,41 @@
setHorizontalScrollBarEnabled(false);
mScrollBarClass = context.getResources().getString(R.string.car_ui_scrollbar_component);
- a.recycle();
}
@Override
- public void setLayoutManager(@Nullable LayoutManager layout) {
- addItemDecorations(layout);
- super.setLayoutManager(layout);
+ public void setLayoutManager(@Nullable LayoutManager layoutManager) {
+ // Cannot setup item decorations before stylized attributes have been read.
+ if (mIsInitialized) {
+ addItemDecorations(layoutManager);
+ }
+ super.setLayoutManager(layoutManager);
}
- private void addItemDecorations(LayoutManager layout) {
- // remove existing Item decorations
- removeItemDecoration(mDividerItemDecorationGrid);
- removeItemDecoration(mTopOffsetItemDecorationGrid);
- removeItemDecoration(mBottomOffsetItemDecorationGrid);
- removeItemDecoration(mDividerItemDecorationLinear);
- removeItemDecoration(mTopOffsetItemDecorationLinear);
- removeItemDecoration(mBottomOffsetItemDecorationLinear);
+ // This method should not be invoked before item decorations are initialized by the #init()
+ // method.
+ private void addItemDecorations(LayoutManager layoutManager) {
+ // remove existing Item decorations.
+ removeItemDecoration(Objects.requireNonNull(mDividerItemDecorationGrid));
+ removeItemDecoration(Objects.requireNonNull(mTopOffsetItemDecorationGrid));
+ removeItemDecoration(Objects.requireNonNull(mBottomOffsetItemDecorationGrid));
+ removeItemDecoration(Objects.requireNonNull(mDividerItemDecorationLinear));
+ removeItemDecoration(Objects.requireNonNull(mTopOffsetItemDecorationLinear));
+ removeItemDecoration(Objects.requireNonNull(mBottomOffsetItemDecorationLinear));
- if (layout instanceof GridLayoutManager) {
+ if (layoutManager instanceof GridLayoutManager) {
if (mEnableDividers) {
- addItemDecoration(mDividerItemDecorationGrid);
+ addItemDecoration(Objects.requireNonNull(mDividerItemDecorationGrid));
}
- addItemDecoration(mTopOffsetItemDecorationGrid);
- addItemDecoration(mBottomOffsetItemDecorationGrid);
- setNumOfColumns(((GridLayoutManager) layout).getSpanCount());
+ addItemDecoration(Objects.requireNonNull(mTopOffsetItemDecorationGrid));
+ addItemDecoration(Objects.requireNonNull(mBottomOffsetItemDecorationGrid));
+ setNumOfColumns(((GridLayoutManager) layoutManager).getSpanCount());
} else {
if (mEnableDividers) {
- addItemDecoration(mDividerItemDecorationLinear);
+ addItemDecoration(Objects.requireNonNull(mDividerItemDecorationLinear));
}
- addItemDecoration(mTopOffsetItemDecorationLinear);
- addItemDecoration(mBottomOffsetItemDecorationLinear);
+ addItemDecoration(Objects.requireNonNull(mTopOffsetItemDecorationLinear));
+ addItemDecoration(Objects.requireNonNull(mBottomOffsetItemDecorationLinear));
}
}
@@ -329,8 +344,8 @@
/**
* This method will detach the current recycler view from its parent and attach it to the
- * container which is a LinearLayout. Later the entire container is attached to the
- * parent where the recycler view was set with the same layout params.
+ * container which is a LinearLayout. Later the entire container is attached to the parent where
+ * the recycler view was set with the same layout params.
*/
private void installExternalScrollBar() {
LayoutInflater inflater = LayoutInflater.from(getContext());
@@ -429,8 +444,8 @@
}
/**
- * Sets the scrollbar's padding top and bottom.
- * This padding is applied in addition to the padding of the RecyclerView.
+ * Sets the scrollbar's padding top and bottom. This padding is applied in addition to the
+ * padding of the RecyclerView.
*/
public void setScrollBarPadding(int paddingTop, int paddingBottom) {
if (mScrollBarEnabled) {