Skip to content

Commit 015f262

Browse files
samtsternjoknu1
andauthored
Transition to Material Components (#1904)
Co-authored-by: Jonas Knutsson <jonas.knutsson@thirdbase.se>
1 parent f0e61e6 commit 015f262

File tree

156 files changed

+647
-1051
lines changed

Some content is hidden

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

156 files changed

+647
-1051
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ android {
6767
}
6868

6969
dependencies {
70-
implementation(Config.Libs.Androidx.design)
70+
implementation(Config.Libs.Androidx.materialDesign)
7171
implementation(Config.Libs.Androidx.multidex)
7272

7373
implementation(project(":auth"))

app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import android.content.Context;
1818
import android.content.Intent;
19-
import android.os.Build;
2019
import android.os.Bundle;
2120
import android.util.Log;
2221
import android.view.View;
@@ -27,8 +26,8 @@
2726
import com.firebase.ui.auth.AuthUI;
2827
import com.firebase.ui.auth.AuthUI.IdpConfig;
2928
import com.firebase.ui.auth.ErrorCodes;
30-
import com.firebase.ui.auth.IdpResponse;
3129
import com.firebase.ui.auth.FirebaseAuthUIActivityResultContract;
30+
import com.firebase.ui.auth.IdpResponse;
3231
import com.firebase.ui.auth.data.model.FirebaseAuthUIAuthenticationResult;
3332
import com.firebase.ui.auth.util.ExtraConstants;
3433
import com.firebase.uidemo.R;
@@ -84,6 +83,9 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
8483
mBinding = AuthUiLayoutBinding.inflate(getLayoutInflater());
8584
setContentView(mBinding.getRoot());
8685

86+
// Workaround for vector drawables on API 19
87+
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
88+
8789
if (ConfigurationUtils.isGoogleMisconfigured(this)) {
8890
mBinding.googleProvider.setChecked(false);
8991
mBinding.googleProvider.setEnabled(false);
@@ -146,16 +148,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
146148
showSnackbar(R.string.configuration_required);
147149
}
148150

149-
if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) {
150-
mBinding.darkTheme.setChecked(true);
151-
}
152-
153151
catchEmailLinkSignIn();
154-
155-
mBinding.defaultTheme.setOnClickListener(toggleDarkThemeListener);
156-
mBinding.greenTheme.setOnClickListener(toggleDarkThemeListener);
157-
mBinding.purpleTheme.setOnClickListener(toggleDarkThemeListener);
158-
mBinding.darkTheme.setOnClickListener(toggleDarkThemeListener);
159152
}
160153

161154
public void catchEmailLinkSignIn() {
@@ -295,26 +288,14 @@ private void startSignedInActivity(@Nullable IdpResponse response) {
295288
startActivity(SignedInActivity.createIntent(this, response));
296289
}
297290

298-
private View.OnClickListener toggleDarkThemeListener = new View.OnClickListener() {
299-
@Override
300-
public void onClick(View view) {
301-
int mode = mBinding.darkTheme.isChecked() ?
302-
AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
303-
if (Build.VERSION.SDK_INT >= 17) {
304-
AppCompatDelegate.setDefaultNightMode(mode);
305-
getDelegate().setLocalNightMode(mode);
306-
}
307-
}
308-
};
309-
310291
@StyleRes
311292
private int getSelectedTheme() {
312293
if (mBinding.greenTheme.isChecked()) {
313294
return R.style.GreenTheme;
314295
}
315296

316-
if (mBinding.purpleTheme.isChecked()) {
317-
return R.style.PurpleTheme;
297+
if (mBinding.appTheme.isChecked()) {
298+
return R.style.AppTheme;
318299
}
319300

320301
return AuthUI.getDefaultTheme();

app/src/main/java/com/firebase/uidemo/auth/SignedInActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.firebase.uidemo.storage.GlideApp;
3232
import com.google.android.gms.tasks.OnCompleteListener;
3333
import com.google.android.gms.tasks.Task;
34+
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
3435
import com.google.android.material.snackbar.Snackbar;
3536
import com.google.firebase.auth.EmailAuthProvider;
3637
import com.google.firebase.auth.FacebookAuthProvider;
@@ -48,7 +49,6 @@
4849
import androidx.annotation.NonNull;
4950
import androidx.annotation.Nullable;
5051
import androidx.annotation.StringRes;
51-
import androidx.appcompat.app.AlertDialog;
5252
import androidx.appcompat.app.AppCompatActivity;
5353

5454
import static com.firebase.ui.auth.AuthUI.EMAIL_LINK_PROVIDER;
@@ -102,7 +102,7 @@ public void signOut() {
102102
}
103103

104104
public void deleteAccountClicked() {
105-
new AlertDialog.Builder(this)
105+
new MaterialAlertDialogBuilder(this)
106106
.setMessage("Are you sure you want to delete this account?")
107107
.setPositiveButton("Yes, nuke it!", (dialogInterface, i) -> deleteAccount())
108108
.setNegativeButton("No", null)

app/src/main/res/layout-land/auth_method_picker_custom_layout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
in button. However this button is NOT considered part of the public API and you should not
9696
use it in your own app.
9797
-->
98-
<com.firebase.ui.auth.util.ui.SupportVectorDrawablesButton
98+
<com.google.android.material.button.MaterialButton
9999
android:id="@+id/custom_google_signin_button"
100100
style="@style/FirebaseUI.Button.AccountChooser.GoogleButton"
101101
android:layout_width="wrap_content"

app/src/main/res/layout/activity_anonymous_upgrade.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
android:orientation="vertical"
1313
tools:context=".auth.AuthUiActivity">
1414

15-
<androidx.appcompat.widget.AppCompatTextView
16-
style="@style/Base.TextAppearance.AppCompat.Headline"
15+
<com.google.android.material.textview.MaterialTextView
16+
style="@style/TextAppearance.MaterialComponents.Headline5"
1717
android:layout_width="wrap_content"
1818
android:layout_height="wrap_content"
1919
android:layout_gravity="center_horizontal"
@@ -31,15 +31,15 @@
3131

3232
<Button
3333
android:id="@+id/anon_sign_in"
34-
style="@style/Widget.AppCompat.Button.Colored"
34+
style="@style/Widget.MaterialComponents.Button"
3535
android:layout_width="200dp"
3636
android:layout_height="wrap_content"
3737
android:layout_gravity="center"
3838
android:text="@string/anonymous_sign_in" />
3939

4040
<Button
4141
android:id="@+id/begin_flow"
42-
style="@style/Widget.AppCompat.Button.Colored"
42+
style="@style/Widget.MaterialComponents.Button"
4343
android:layout_width="200dp"
4444
android:layout_height="wrap_content"
4545
android:layout_gravity="center"
@@ -48,7 +48,7 @@
4848

4949
<Button
5050
android:id="@+id/resolve_merge"
51-
style="@style/Widget.AppCompat.Button.Colored"
51+
style="@style/Widget.MaterialComponents.Button"
5252
android:layout_width="200dp"
5353
android:layout_height="wrap_content"
5454
android:layout_gravity="center"
@@ -57,7 +57,7 @@
5757

5858
<Button
5959
android:id="@+id/sign_out"
60-
style="@style/Widget.AppCompat.Button.Colored"
60+
style="@style/Widget.MaterialComponents.Button"
6161
android:layout_width="200dp"
6262
android:layout_height="wrap_content"
6363
android:layout_gravity="center"

app/src/main/res/layout/activity_chat.xml

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

5151
<Button
5252
android:id="@+id/sendButton"
53-
style="@style/Widget.AppCompat.Button.Borderless.Colored"
53+
style="@style/Widget.MaterialComponents.Button.TextButton"
5454
android:layout_width="wrap_content"
5555
android:layout_height="wrap_content"
5656
android:layout_gravity="bottom|end"

app/src/main/res/layout/activity_image.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
tools:context="com.firebase.uidemo.storage.ImageActivity">
1313

1414
<TextView
15-
style="@style/TextAppearance.AppCompat.Medium"
15+
style="@style/TextAppearance.MaterialComponents.Body1"
1616
android:layout_width="wrap_content"
1717
android:layout_height="wrap_content"
1818
android:text="@string/upload" />
@@ -24,7 +24,7 @@
2424
android:text="@string/choose_image" />
2525

2626
<TextView
27-
style="@style/TextAppearance.AppCompat.Medium"
27+
style="@style/TextAppearance.MaterialComponents.Body1"
2828
android:layout_width="wrap_content"
2929
android:layout_height="wrap_content"
3030
android:layout_marginTop="20dp"

app/src/main/res/layout/auth_method_picker_custom_layout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
in button. However this button is NOT considered part of the public API and you should not
7979
use it in your own app.
8080
-->
81-
<com.firebase.ui.auth.util.ui.SupportVectorDrawablesButton
81+
<com.google.android.material.button.MaterialButton
8282
android:id="@+id/custom_google_signin_button"
8383
style="@style/FirebaseUI.Button.AccountChooser.GoogleButton"
8484
android:layout_width="wrap_content"

app/src/main/res/layout/auth_ui_layout.xml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
android:orientation="vertical"
2222
android:paddingBottom="32dp">
2323

24-
<androidx.appcompat.widget.AppCompatTextView
25-
style="@style/Base.TextAppearance.AppCompat.Headline"
24+
<com.google.android.material.textview.MaterialTextView
25+
style="@style/TextAppearance.MaterialComponents.Headline5"
2626
android:layout_width="wrap_content"
2727
android:layout_height="wrap_content"
2828
android:layout_gravity="center_horizontal"
@@ -31,7 +31,7 @@
3131

3232
<Button
3333
android:id="@+id/sign_in"
34-
style="@style/Widget.AppCompat.Button.Colored"
34+
style="@style/Widget.MaterialComponents.Button"
3535
android:layout_width="wrap_content"
3636
android:layout_height="wrap_content"
3737
android:layout_gravity="center"
@@ -40,15 +40,15 @@
4040

4141
<Button
4242
android:id="@+id/sign_in_silent"
43-
style="@style/Widget.AppCompat.Button.Colored"
43+
style="@style/Widget.MaterialComponents.Button"
4444
android:layout_width="wrap_content"
4545
android:layout_height="wrap_content"
4646
android:layout_gravity="center"
4747
android:layout_marginBottom="16dp"
4848
android:text="@string/sign_in_silent" />
4949

5050
<TextView
51-
style="@style/Base.TextAppearance.AppCompat.Subhead"
51+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
5252
android:layout_width="wrap_content"
5353
android:layout_height="wrap_content"
5454
android:layout_marginBottom="8dp"
@@ -132,7 +132,7 @@
132132
android:text="@string/providers_github" />
133133

134134
<TextView
135-
style="@style/Base.TextAppearance.AppCompat.Subhead"
135+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
136136
android:layout_width="wrap_content"
137137
android:layout_height="wrap_content"
138138
android:layout_marginTop="16dp"
@@ -160,7 +160,7 @@
160160
</RadioGroup>
161161

162162
<TextView
163-
style="@style/Base.TextAppearance.AppCompat.Subhead"
163+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
164164
android:layout_width="wrap_content"
165165
android:layout_height="wrap_content"
166166
android:layout_marginTop="16dp"
@@ -173,33 +173,27 @@
173173
android:orientation="vertical">
174174

175175
<RadioButton
176-
android:id="@+id/default_theme"
176+
android:id="@+id/app_theme"
177+
android:checked="true"
177178
android:layout_width="wrap_content"
178179
android:layout_height="wrap_content"
179-
android:checked="true"
180-
android:text="@string/theme_default" />
180+
android:text="@string/theme_app" />
181181

182182
<RadioButton
183-
android:id="@+id/purple_theme"
183+
android:id="@+id/default_theme"
184184
android:layout_width="wrap_content"
185185
android:layout_height="wrap_content"
186-
android:text="@string/theme_purple" />
186+
android:text="@string/theme_default" />
187187

188188
<RadioButton
189189
android:id="@+id/green_theme"
190190
android:layout_width="wrap_content"
191191
android:layout_height="wrap_content"
192192
android:text="@string/theme_green" />
193-
194-
<RadioButton
195-
android:id="@+id/dark_theme"
196-
android:layout_width="wrap_content"
197-
android:layout_height="wrap_content"
198-
android:text="@string/theme_dark" />
199193
</RadioGroup>
200194

201195
<TextView
202-
style="@style/Base.TextAppearance.AppCompat.Subhead"
196+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
203197
android:layout_width="wrap_content"
204198
android:layout_height="wrap_content"
205199
android:layout_marginTop="16dp"
@@ -233,7 +227,7 @@
233227
</RadioGroup>
234228

235229
<TextView
236-
style="@style/Base.TextAppearance.AppCompat.Subhead"
230+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
237231
android:layout_width="wrap_content"
238232
android:layout_height="wrap_content"
239233
android:layout_marginTop="16dp"
@@ -267,7 +261,7 @@
267261

268262
<TextView
269263
android:id="@+id/google_scopes_header"
270-
style="@style/Base.TextAppearance.AppCompat.Subhead"
264+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
271265
android:layout_width="wrap_content"
272266
android:layout_height="wrap_content"
273267
android:layout_marginTop="16dp"
@@ -290,7 +284,7 @@
290284

291285
<TextView
292286
android:id="@+id/facebook_permissions_header"
293-
style="@style/Base.TextAppearance.AppCompat.Subhead"
287+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
294288
android:layout_width="wrap_content"
295289
android:layout_height="wrap_content"
296290
android:layout_marginTop="16dp"
@@ -312,7 +306,7 @@
312306
android:text="@string/facebook_permission_photos" />
313307

314308
<TextView
315-
style="@style/Base.TextAppearance.AppCompat.Subhead"
309+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
316310
android:layout_width="wrap_content"
317311
android:layout_height="wrap_content"
318312
android:layout_marginTop="16dp"

app/src/main/res/layout/message.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<TextView
3232
android:id="@+id/message_text"
33-
style="@style/TextAppearance.AppCompat.Medium"
33+
style="@style/TextAppearance.MaterialComponents.Subtitle2"
3434
android:layout_width="wrap_content"
3535
android:layout_height="wrap_content"
3636
android:textIsSelectable="true"
@@ -39,7 +39,7 @@
3939

4040
<TextView
4141
android:id="@+id/name_text"
42-
style="@style/TextAppearance.AppCompat.Small"
42+
style="@style/TextAppearance.MaterialComponents.Subtitle2"
4343
android:layout_width="wrap_content"
4444
android:layout_height="wrap_content"
4545
android:textIsSelectable="true"

app/src/main/res/layout/signed_in_layout.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
android:layout_marginBottom="16dp"
1919
android:orientation="vertical">
2020

21-
<androidx.appcompat.widget.AppCompatTextView
22-
style="@style/Base.TextAppearance.AppCompat.Headline"
21+
<com.google.android.material.textview.MaterialTextView
22+
style="@style/TextAppearance.MaterialComponents.Headline5"
2323
android:layout_width="wrap_content"
2424
android:layout_height="wrap_content"
2525
android:layout_gravity="center_horizontal"
@@ -34,7 +34,7 @@
3434

3535
<Button
3636
android:id="@+id/sign_out"
37-
style="@style/Widget.AppCompat.Button.Colored"
37+
style="@style/Widget.MaterialComponents.Button"
3838
android:layout_width="wrap_content"
3939
android:layout_height="wrap_content"
4040
android:layout_gravity="center"
@@ -54,7 +54,7 @@
5454
</LinearLayout>
5555

5656
<TextView
57-
style="@style/Base.TextAppearance.AppCompat.Subhead"
57+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
5858
android:layout_width="wrap_content"
5959
android:layout_height="wrap_content"
6060
android:text="@string/user_profile_header" />
@@ -120,7 +120,7 @@
120120
android:orientation="vertical">
121121

122122
<TextView
123-
style="@style/Base.TextAppearance.AppCompat.Subhead"
123+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
124124
android:layout_width="wrap_content"
125125
android:layout_height="wrap_content"
126126
android:text="@string/idp_token" />
@@ -140,7 +140,7 @@
140140
android:orientation="vertical">
141141

142142
<TextView
143-
style="@style/Base.TextAppearance.AppCompat.Subhead"
143+
style="@style/TextAppearance.MaterialComponents.Subtitle1"
144144
android:layout_width="wrap_content"
145145
android:layout_height="wrap_content"
146146
android:text="@string/idp_secret" />

0 commit comments

Comments
 (0)