Skip to content

Commit 1008b12

Browse files
authored
Merge branch 'master' into remove_todo_snackbar
2 parents f4f5426 + b84b335 commit 1008b12

File tree

351 files changed

+7683
-5214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+7683
-5214
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ext {
2929
? project.property('mavenRepoUrl') : '/tmp/myRepo/')
3030

3131
// Current version of the library (could be in-development/unreleased).
32-
mdcLibraryVersion = '1.14.0-alpha01'
32+
mdcLibraryVersion = '1.14.0-alpha02'
3333
mdcLibraryPackage = "com.google.android.material"
3434
mdcLibraryDir = "com/google/android/material"
3535
}

catalog/java/io/material/catalog/card/SelectableCardsAdapter.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.material.catalog.R;
2020

2121
import androidx.recyclerview.widget.RecyclerView;
22+
import android.view.KeyEvent;
2223
import android.view.LayoutInflater;
2324
import android.view.MotionEvent;
2425
import android.view.View;
@@ -98,6 +99,25 @@ private void bind(Item item, int position) {
9899
subtitleView.setText(item.subtitle);
99100
if (selectionTracker != null) {
100101
bindSelectedState();
102+
materialCardView.setOnKeyListener(
103+
(v, keyCode, event) -> {
104+
if (event.getAction() == KeyEvent.ACTION_DOWN
105+
&& (keyCode == KeyEvent.KEYCODE_ENTER
106+
|| keyCode == KeyEvent.KEYCODE_DPAD_CENTER)) {
107+
Long selectionKey = details.getSelectionKey();
108+
if (selectionKey != null) {
109+
if (selectionTracker.isSelected(selectionKey)) {
110+
selectionTracker.deselect(selectionKey);
111+
} else {
112+
selectionTracker.select(selectionKey);
113+
}
114+
return true;
115+
}
116+
}
117+
return false;
118+
});
119+
} else {
120+
materialCardView.setOnKeyListener(null);
101121
}
102122
}
103123

@@ -187,8 +207,7 @@ static class Details extends ItemDetailsLookup.ItemDetails<Long> {
187207

188208
long position;
189209

190-
Details() {
191-
}
210+
Details() {}
192211

193212
@Override
194213
public int getPosition() {

catalog/java/io/material/catalog/dockedtoolbar/DockedToolbarMainDemoFragment.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.os.Bundle;
2323
import androidx.appcompat.app.AppCompatActivity;
2424
import androidx.appcompat.widget.Toolbar;
25+
import androidx.appcompat.widget.TooltipCompat;
2526
import android.view.LayoutInflater;
2627
import android.view.View;
2728
import android.view.ViewGroup;
@@ -52,14 +53,14 @@ public View onCreateDemoView(
5253
dockedToolbar = view.findViewById(R.id.docked_toolbar);
5354
((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
5455

55-
setupSnackbarAndButtonParentOnClick(view.findViewById(R.id.docked_toolbar_left_arrow_button));
56-
setupSnackbarAndButtonParentOnClick(view.findViewById(R.id.docked_toolbar_right_arrow_button));
57-
setupSnackbarAndButtonParentOnClick(view.findViewById(R.id.docked_toolbar_add_button));
58-
setupSnackbarAndButtonParentOnClick(view.findViewById(R.id.docked_toolbar_tab_button));
59-
setupSnackbarAndButtonParentOnClick(view.findViewById(R.id.docked_toolbar_star_button));
60-
setupSnackbarAndButtonParentOnClick(view.findViewById(R.id.docked_toolbar_alarm_button));
61-
setupSnackbarAndButtonParentOnClick(view.findViewById(R.id.docked_toolbar_search_button));
62-
setupSnackbarAndButtonParentOnClick(view.findViewById(R.id.docked_toolbar_settings_button));
56+
setupSnackbarAndButtonParentOnClickAndTooltip(view.findViewById(R.id.docked_toolbar_left_arrow_button));
57+
setupSnackbarAndButtonParentOnClickAndTooltip(view.findViewById(R.id.docked_toolbar_right_arrow_button));
58+
setupSnackbarAndButtonParentOnClickAndTooltip(view.findViewById(R.id.docked_toolbar_add_button));
59+
setupSnackbarAndButtonParentOnClickAndTooltip(view.findViewById(R.id.docked_toolbar_tab_button));
60+
setupSnackbarAndButtonParentOnClickAndTooltip(view.findViewById(R.id.docked_toolbar_star_button));
61+
setupSnackbarAndButtonParentOnClickAndTooltip(view.findViewById(R.id.docked_toolbar_alarm_button));
62+
setupSnackbarAndButtonParentOnClickAndTooltip(view.findViewById(R.id.docked_toolbar_search_button));
63+
setupSnackbarAndButtonParentOnClickAndTooltip(view.findViewById(R.id.docked_toolbar_settings_button));
6364

6465
LinearLayout bodyContainer = view.findViewById(R.id.body_container);
6566

@@ -86,7 +87,7 @@ private void updateContentPaddingOnTalkback(View content, boolean talkbackEnable
8687
talkbackEnabled ? dockedToolbar.getMeasuredHeight() : 0));
8788
}
8889

89-
private void setupSnackbarAndButtonParentOnClick(View view) {
90+
private void setupSnackbarAndButtonParentOnClickAndTooltip(View view) {
9091
view.setOnClickListener(
9192
v ->
9293
Snackbar.make(
@@ -95,6 +96,7 @@ private void setupSnackbarAndButtonParentOnClick(View view) {
9596
Snackbar.LENGTH_SHORT)
9697
.setAnchorView(dockedToolbar)
9798
.show());
99+
TooltipCompat.setTooltipText(view, view.getContentDescription());
98100

99101
// Since each button is being wrapped by a FrameLayout, we set a click listener on each button's
100102
// parent so that any item that is in the overflow menu has its click action properly set up.

catalog/java/io/material/catalog/dockedtoolbar/DockedToolbarThreeItemDemoFragment.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import android.os.Bundle;
2121
import androidx.appcompat.app.AppCompatActivity;
2222
import androidx.appcompat.widget.Toolbar;
23+
import androidx.appcompat.widget.TooltipCompat;
2324
import android.view.LayoutInflater;
2425
import android.view.View;
2526
import android.view.ViewGroup;
@@ -53,14 +54,14 @@ public View onCreateDemoView(@NonNull LayoutInflater layoutInflater, @Nullable V
5354
Button leftArrowButton = content.findViewById(R.id.docked_toolbar_left_arrow_button);
5455
Button rightArrowButton = content.findViewById(R.id.docked_toolbar_right_arrow_button);
5556
Button addButton = content.findViewById(R.id.docked_toolbar_add_button);
56-
setupSnackbarOnClick(leftArrowButton);
57-
setupSnackbarOnClick(rightArrowButton);
58-
setupSnackbarOnClick(addButton);
57+
setupSnackbarOnClickAndTooltip(leftArrowButton);
58+
setupSnackbarOnClickAndTooltip(rightArrowButton);
59+
setupSnackbarOnClickAndTooltip(addButton);
5960

6061
return view;
6162
}
6263

63-
private void setupSnackbarOnClick(@NonNull View view) {
64+
private void setupSnackbarOnClickAndTooltip(@NonNull View view) {
6465
view.setOnClickListener(
6566
v ->
6667
Snackbar.make(
@@ -69,6 +70,7 @@ private void setupSnackbarOnClick(@NonNull View view) {
6970
Snackbar.LENGTH_SHORT)
7071
.setAnchorView(dockedToolbar)
7172
.show());
73+
TooltipCompat.setTooltipText(view, view.getContentDescription());
7274
}
7375

7476
@LayoutRes

catalog/java/io/material/catalog/dockedtoolbar/res/layout/cat_docked_toolbar_content.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
android:layout_width="0dp"
2222
android:layout_height="wrap_content"
2323
android:minWidth="48dp"
24+
android:focusable="false"
2425
android:layout_weight="1">
2526
<Button
2627
android:id="@+id/docked_toolbar_left_arrow_button"
@@ -36,6 +37,7 @@
3637
android:layout_width="0dp"
3738
android:layout_height="wrap_content"
3839
android:minWidth="48dp"
40+
android:focusable="false"
3941
android:layout_weight="1">
4042
<Button
4143
android:id="@+id/docked_toolbar_right_arrow_button"
@@ -51,6 +53,7 @@
5153
android:layout_width="0dp"
5254
android:layout_height="wrap_content"
5355
android:minWidth="48dp"
56+
android:focusable="false"
5457
android:layout_weight="1">
5558
<Button
5659
android:id="@+id/docked_toolbar_add_button"
@@ -72,6 +75,7 @@
7275
android:layout_height="wrap_content"
7376
android:minWidth="48dp"
7477
android:layout_weight="1"
78+
android:focusable="false"
7579
app:layout_overflowText="@string/cat_docked_toolbar_tab_button_description">
7680
<Button
7781
android:id="@+id/docked_toolbar_tab_button"
@@ -88,6 +92,7 @@
8892
android:layout_width="0dp"
8993
android:layout_height="wrap_content"
9094
android:minWidth="48dp"
95+
android:focusable="false"
9196
android:layout_weight="1"
9297
app:layout_overflowText="@string/cat_docked_toolbar_star_button_description">
9398
<Button
@@ -106,6 +111,7 @@
106111
android:layout_height="wrap_content"
107112
android:minWidth="48dp"
108113
android:layout_weight="1"
114+
android:focusable="false"
109115
app:layout_overflowText="@string/cat_docked_toolbar_alarm_button_description">
110116
<Button
111117
android:id="@+id/docked_toolbar_alarm_button"
@@ -123,6 +129,7 @@
123129
android:layout_height="wrap_content"
124130
android:minWidth="48dp"
125131
android:layout_weight="1"
132+
android:focusable="false"
126133
app:layout_overflowText="@string/cat_docked_toolbar_search_button_description">
127134
<Button
128135
android:id="@+id/docked_toolbar_search_button"
@@ -140,6 +147,7 @@
140147
android:layout_height="wrap_content"
141148
android:minWidth="48dp"
142149
android:layout_weight="1"
150+
android:focusable="false"
143151
app:layout_overflowText="@string/cat_docked_toolbar_settings_button_description">
144152
<Button
145153
android:id="@+id/docked_toolbar_settings_button"

catalog/java/io/material/catalog/dockedtoolbar/res/layout/cat_docked_toolbar_small_content.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<FrameLayout
2525
android:layout_width="0dp"
2626
android:layout_height="wrap_content"
27+
android:focusable="false"
2728
android:layout_weight="1">
2829
<Button
2930
android:id="@+id/docked_toolbar_left_arrow_button"
@@ -38,6 +39,7 @@
3839
<FrameLayout
3940
android:layout_width="0dp"
4041
android:layout_height="wrap_content"
42+
android:focusable="false"
4143
android:layout_weight="1">
4244
<Button
4345
android:id="@+id/docked_toolbar_add_button"
@@ -53,6 +55,7 @@
5355
<FrameLayout
5456
android:layout_width="0dp"
5557
android:layout_height="wrap_content"
58+
android:focusable="false"
5659
android:layout_weight="1">
5760
<Button
5861
android:id="@+id/docked_toolbar_right_arrow_button"

catalog/java/io/material/catalog/floatingtoolbar/FloatingToolbarMainDemoFragment.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import android.os.Bundle;
2424
import androidx.appcompat.app.AppCompatActivity;
2525
import androidx.appcompat.widget.Toolbar;
26+
import androidx.appcompat.widget.TooltipCompat;
2627
import android.view.Gravity;
2728
import android.view.LayoutInflater;
2829
import android.view.View;
@@ -80,6 +81,7 @@ public View onCreateDemoView(
8081
}
8182
propagateCheckedButtonState(boldButtons, isChecked);
8283
});
84+
TooltipCompat.setTooltipText(boldButton, boldButton.getContentDescription());
8385
}
8486

8587
// Initialize group of italics format buttons.
@@ -100,6 +102,7 @@ public View onCreateDemoView(
100102
}
101103
propagateCheckedButtonState(italicButtons, isChecked);
102104
});
105+
TooltipCompat.setTooltipText(italicButton, italicButton.getContentDescription());
103106
}
104107

105108
// Initialize group of underline format buttons.
@@ -117,6 +120,7 @@ public View onCreateDemoView(
117120
}
118121
propagateCheckedButtonState(underlineButtons, isChecked);
119122
});
123+
TooltipCompat.setTooltipText(underlineButton, underlineButton.getContentDescription());
120124
}
121125

122126
// Initialize color text format buttons.
@@ -125,6 +129,7 @@ public View onCreateDemoView(
125129
colorTextButtons.addAll(initializeFormatButtons(floatingToolbars, R.id.floating_toolbar_vibrant_button_color_text));
126130
for (MaterialButton colorTextButton : colorTextButtons) {
127131
colorTextButton.setOnClickListener(v -> bodyText.setTextColor(getRandomColor()));
132+
TooltipCompat.setTooltipText(colorTextButton, colorTextButton.getContentDescription());
128133
}
129134

130135
// Initialize color fill format buttons.
@@ -133,6 +138,7 @@ public View onCreateDemoView(
133138
colorFillButtons.addAll(initializeFormatButtons(floatingToolbars, R.id.floating_toolbar_vibrant_button_color_fill));
134139
for (MaterialButton colorFillButton : colorFillButtons) {
135140
colorFillButton.setOnClickListener(v -> view.setBackgroundColor(getRandomColor()));
141+
TooltipCompat.setTooltipText(colorFillButton, colorFillButton.getContentDescription());
136142
}
137143

138144
// Initialize strikethrough format buttons.
@@ -150,6 +156,7 @@ public View onCreateDemoView(
150156
}
151157
propagateCheckedButtonState(strikethroughButtons, isChecked);
152158
});
159+
TooltipCompat.setTooltipText(strikethroughButton, strikethroughButton.getContentDescription());
153160
}
154161

155162
// Initialize left align format buttons.
@@ -158,6 +165,7 @@ public View onCreateDemoView(
158165
leftAlignButtons.addAll(initializeFormatButtons(floatingToolbars, R.id.floating_toolbar_vibrant_button_left_align));
159166
for (MaterialButton leftAlignButton : leftAlignButtons) {
160167
leftAlignButton.setOnClickListener(v -> bodyText.setGravity(Gravity.LEFT));
168+
TooltipCompat.setTooltipText(leftAlignButton, leftAlignButton.getContentDescription());
161169
}
162170

163171
// Initialize center align format buttons.
@@ -166,6 +174,7 @@ public View onCreateDemoView(
166174
centerAlignButtons.addAll(initializeFormatButtons(floatingToolbars, R.id.floating_toolbar_vibrant_button_center_align));
167175
for (MaterialButton centerButton : centerAlignButtons) {
168176
centerButton.setOnClickListener(v -> bodyText.setGravity(Gravity.CENTER_HORIZONTAL));
177+
TooltipCompat.setTooltipText(centerButton, centerButton.getContentDescription());
169178
}
170179

171180
// Initialize right align format buttons.
@@ -175,6 +184,7 @@ public View onCreateDemoView(
175184
for (MaterialButton rightAlignButton : rightAlignButtons) {
176185
// Check if is RTL since icon won't change direction.
177186
rightAlignButton.setOnClickListener(v -> bodyText.setGravity(Gravity.RIGHT));
187+
TooltipCompat.setTooltipText(rightAlignButton, rightAlignButton.getContentDescription());
178188
}
179189

180190
// Initialize orientation configuration selection controls.

catalog/java/io/material/catalog/navigationdrawer/res/layout/cat_navigationdrawer.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@
3333
<com.google.android.material.appbar.AppBarLayout
3434
android:layout_width="match_parent"
3535
android:layout_height="wrap_content"
36+
android:touchscreenBlocksFocus="false"
3637
android:fitsSystemWindows="true">
3738

3839
<androidx.appcompat.widget.Toolbar
3940
android:id="@+id/toolbar"
4041
style="?attr/catalogToolbarStyle"
4142
android:layout_width="match_parent"
4243
android:layout_height="wrap_content"
44+
android:touchscreenBlocksFocus="false"
4345
app:navigationIcon="@drawable/ic_drawer_menu_24px"
4446
app:title="@string/cat_navigationdrawer_title"/>
4547
</com.google.android.material.appbar.AppBarLayout>

catalog/test/javatests/io/material/catalog/feature/MemoryViewTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
/** Tests for {@link MemoryView}. */
4242
@RunWith(RobolectricTestRunner.class)
43-
@Config(sdk = 21)
43+
@Config(sdk = Config.OLDEST_SDK)
4444
public class MemoryViewTest {
4545

4646
private static final int BYTES_IN_MB = 1024 * 1024;

0 commit comments

Comments
 (0)