Skip to content

Commit e49b3f0

Browse files
authored
Fix small issues left in version 4.2.1 (#1495)
1 parent 6a66612 commit e49b3f0

File tree

12 files changed

+108
-19
lines changed

12 files changed

+108
-19
lines changed

auth-github/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
android {
2+
lintOptions {
3+
disable("UnknownNullness") // TODO fix in future PR
4+
}
5+
}
6+
17
dependencies {
28
compileOnly(project(":auth")) { isTransitive = false }
39
compileOnly(Config.Libs.Firebase.auth) { isTransitive = false }

auth/src/main/java/com/firebase/ui/auth/ui/phone/CountryListAdapter.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@
3434
* Array adapter used to display a list of countries with section indices.
3535
*/
3636
final class CountryListAdapter extends ArrayAdapter<CountryInfo> implements SectionIndexer {
37+
38+
// Map from first letter --> position in the list
3739
private final HashMap<String, Integer> alphaIndex = new LinkedHashMap<>();
40+
41+
// Map from display name --> position in the list
3842
private final HashMap<String, Integer> countryPosition = new LinkedHashMap<>();
43+
3944
private String[] sections;
4045

4146
public CountryListAdapter(Context context) {
@@ -67,6 +72,11 @@ public void setData(List<CountryInfo> countries) {
6772
notifyDataSetChanged();
6873
}
6974

75+
@Override
76+
public int getCount() {
77+
return countryPosition.size();
78+
}
79+
7080
@Override
7181
public Object[] getSections() {
7282
return sections;
@@ -92,6 +102,16 @@ public int getPositionForSection(int index) {
92102

93103
@Override
94104
public int getSectionForPosition(int position) {
105+
if (sections == null) {
106+
return 0;
107+
}
108+
109+
for (int i = 0; i < sections.length; i++) {
110+
if (getPositionForSection(i) > position) {
111+
return i - 1;
112+
}
113+
}
114+
95115
return 0;
96116
}
97117

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item>
4+
<shape android:shape="rectangle">
5+
<corners android:radius="3dp" />
6+
<solid android:color="@color/fui_bgAnonymous" />
7+
</shape>
8+
</item>
9+
</layer-list>
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<vector
22
xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
43
android:width="24dp"
54
android:height="24dp"
65
android:viewportHeight="24.0"
7-
android:viewportWidth="24.0"
8-
tools:ignore="InvalidVectorPath">
6+
android:viewportWidth="24.0">
97
<path
108
android:fillColor="#FFFFFF"
11-
android:pathData="M12 5.9c1.16 0 2.1.94 2.1 2.1s-0.94 2.1-2.1 2.1S9.9 9.16 9.9 8s0.94-2.1 2.1-2.1m0 9c2.97 0 6.1 1.46 6.1 2.1v1.1H5.9V17c0-0.64 3.13-2.1 6.1-2.1M12 4C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 9c-2.67 0-8 1.34-8 4v3h16v-3c0-2.66-5.33-4-8-4z" />
9+
android:pathData="M12,5.9c1.16,0 2.1,0.94 2.1,2.1s-0.94,2.1 -2.1,2.1S9.9,9.16 9.9,8s0.94,-2.1 2.1,-2.1m0,9c2.97,0 6.1,1.46 6.1,2.1v1.1L5.9,18.1L5.9,17c0,-0.64 3.13,-2.1 6.1,-2.1M12,4C9.79,4 8,5.79 8,8s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,13c-2.67,0 -8,1.34 -8,4v3h16v-3c0,-2.66 -5.33,-4 -8,-4z" />
1210
</vector>

auth/src/main/res/layout/fui_welcome_back_password_prompt_layout.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
android:layout_height="wrap_content"
6060
android:layout_marginTop="@dimen/fui_field_padding_vert"
6161
android:text="@string/fui_trouble_signing_in"
62-
app:layout_constraintStart_toStartOf="parent"
6362
app:layout_constraintEnd_toStartOf="@+id/button_done"
63+
app:layout_constraintStart_toStartOf="parent"
6464
app:layout_constraintTop_toBottomOf="@+id/password_layout" />
6565

6666
<Button
@@ -75,7 +75,8 @@
7575
android:id="@+id/email_footer_tos_and_pp_text"
7676
style="@style/FirebaseUI.PrivacyFooter"
7777
app:layout_constraintTop_toBottomOf="@+id/button_done"
78-
app:layout_constraintBottom_toBottomOf="parent" />
78+
app:layout_constraintBottom_toBottomOf="parent"
79+
tools:text="Terms of Service and Privacy Policy" />
7980

8081
</android.support.constraint.ConstraintLayout>
8182

auth/src/main/res/values/dimens.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313
<dimen name="fui_button_inset_bottom">3dp</dimen>
1414
<dimen name="fui_button_inset_left">1dp</dimen>
1515
<dimen name="fui_button_inset_right">2dp</dimen>
16+
17+
<dimen name="fui_min_height_target">48dp</dimen>
1618
</resources>

auth/src/main/res/values/styles.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@
146146
</style>
147147

148148
<style name="FirebaseUI.Text.Link">
149+
<item name="android:minHeight">@dimen/fui_min_height_target</item>
150+
<item name="android:gravity">center_vertical</item>
149151
<item name="android:textColor">@color/fui_linkColor</item>
150152
</style>
151153

@@ -256,7 +258,8 @@
256258
<item name="android:layout_height">wrap_content</item>
257259
<item name="android:layout_marginTop">@dimen/fui_field_padding_vert</item>
258260
<item name="android:layout_marginBottom">@dimen/fui_field_padding_vert</item>
259-
<item name="android:gravity">end</item>
261+
<item name="android:minHeight">@dimen/fui_min_height_target</item>
262+
<item name="android:gravity">end|center_vertical</item>
260263
<item name="android:textIsSelectable">false</item>
261264
</style>
262265

auth/src/test/java/com/firebase/ui/auth/testhelpers/TestHelper.java

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

1717
import android.content.Context;
1818
import android.content.res.Resources;
19+
import android.util.Log;
1920

2021
import com.firebase.ui.auth.AuthUI;
2122
import com.firebase.ui.auth.AuthUI.IdpConfig;
@@ -34,6 +35,7 @@
3435

3536
import org.robolectric.RuntimeEnvironment;
3637

38+
import java.lang.reflect.Field;
3739
import java.util.ArrayList;
3840
import java.util.Collection;
3941
import java.util.List;
@@ -44,13 +46,17 @@
4446
import static org.mockito.Mockito.when;
4547

4648
public final class TestHelper {
49+
50+
private static final String TAG = "TestHelper";
51+
private static final String DEFAULT_APP_NAME = "[DEFAULT]";
52+
4753
public static final FirebaseApp MOCK_APP;
4854

4955
static {
5056
FirebaseApp app = mock(FirebaseApp.class);
5157
when(app.get(eq(FirebaseAuth.class))).thenReturn(mock(FirebaseAuth.class));
5258
when(app.getApplicationContext()).thenReturn(RuntimeEnvironment.application);
53-
when(app.getName()).thenReturn(FirebaseApp.DEFAULT_APP_NAME);
59+
when(app.getName()).thenReturn(DEFAULT_APP_NAME);
5460
MOCK_APP = app;
5561
}
5662

@@ -134,7 +140,7 @@ public static FlowParameters getFlowParameters(Collection<String> providerIds,
134140
}
135141
}
136142
return new FlowParameters(
137-
FirebaseApp.DEFAULT_APP_NAME,
143+
DEFAULT_APP_NAME,
138144
idpConfigs,
139145
AuthUI.getDefaultTheme(),
140146
AuthUI.NO_LOGO,
@@ -146,5 +152,40 @@ public static FlowParameters getFlowParameters(Collection<String> providerIds,
146152
false);
147153
}
148154

155+
/**
156+
* Set a private, obfuscated field of an object.
157+
* @param obj the object to modify.
158+
* @param objClass the object's class.
159+
* @param fieldClass the class of the target field.
160+
* @param fieldValue the value to use for the field.
161+
*/
162+
public static <T, F> void setPrivateField(
163+
T obj,
164+
Class<T> objClass,
165+
Class<F> fieldClass,
166+
F fieldValue) {
167+
168+
Field targetField = null;
169+
Field[] classFields = objClass.getDeclaredFields();
170+
for (Field field : classFields) {
171+
if (field.getType().equals(fieldClass)) {
172+
if (targetField != null) {
173+
throw new IllegalStateException("Class " + objClass + " has multiple fields of type " + fieldClass);
174+
}
175+
176+
targetField = field;
177+
}
178+
}
179+
180+
if (targetField == null) {
181+
throw new IllegalStateException("Class " + objClass + " has no fields of type " + fieldClass);
182+
}
149183

184+
targetField.setAccessible(true);
185+
try {
186+
targetField.set(obj, fieldValue);
187+
} catch (IllegalAccessException e) {
188+
Log.w(TAG, "Error setting field", e);
189+
}
190+
}
150191
}

auth/src/test/java/com/firebase/ui/auth/viewmodel/PhoneProviderResponseHandlerTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.firebase.ui.auth.testhelpers.TestConstants;
1515
import com.firebase.ui.auth.testhelpers.TestHelper;
1616
import com.firebase.ui.auth.viewmodel.phone.PhoneProviderResponseHandler;
17+
import com.google.firebase.auth.AuthCredential;
1718
import com.google.firebase.auth.AuthResult;
1819
import com.google.firebase.auth.FirebaseAuth;
1920
import com.google.firebase.auth.FirebaseAuthUserCollisionException;
@@ -104,9 +105,13 @@ public void testSignIn_autoUpgradeAnonymousEnabledWithExistingUser_expectMergeFa
104105
mHandler.getOperation().observeForever(mResponseObserver);
105106
setupAnonymousUpgrade();
106107

108+
FirebaseAuthUserCollisionException ex =
109+
new FirebaseAuthUserCollisionException("foo", "bar");
110+
TestHelper.setPrivateField(ex, FirebaseAuthUserCollisionException.class,
111+
AuthCredential.class, mCredential);
112+
107113
when(mMockAuth.getCurrentUser().linkWithCredential(mCredential))
108-
.thenReturn(AutoCompleteTask.<AuthResult>forFailure(
109-
new FirebaseAuthUserCollisionException("foo", "bar", mCredential)));
114+
.thenReturn(AutoCompleteTask.<AuthResult>forFailure(ex));
110115

111116
IdpResponse response = new IdpResponse.Builder(new User.Builder(
112117
PhoneAuthProvider.PROVIDER_ID, TestConstants.EMAIL).build())

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This empty file along with settings.gradle help Android Studio recognize the project
2+
// as a gradle project, despite the use of .gradle.kts scripts.

buildSrc/src/main/kotlin/Config.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object Config {
1111
}
1212

1313
object Plugins {
14-
const val android = "com.android.tools.build:gradle:3.2.0"
14+
const val android = "com.android.tools.build:gradle:3.2.1"
1515
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1616
const val google = "com.google.gms:google-services:4.0.2"
1717

@@ -36,7 +36,7 @@ object Config {
3636
const val cardView = "com.android.support:cardview-v7:$version"
3737
const val customTabs = "com.android.support:customtabs:$version"
3838

39-
const val constraint = "com.android.support.constraint:constraint-layout:1.1.2"
39+
const val constraint = "com.android.support.constraint:constraint-layout:1.1.3"
4040
}
4141

4242
object Arch {
@@ -51,15 +51,15 @@ object Config {
5151
}
5252

5353
object Firebase {
54-
const val core = "com.google.firebase:firebase-core:16.0.3"
55-
const val auth = "com.google.firebase:firebase-auth:16.0.3"
56-
const val firestore = "com.google.firebase:firebase-firestore:17.1.0"
54+
const val core = "com.google.firebase:firebase-core:16.0.4"
55+
const val auth = "com.google.firebase:firebase-auth:16.0.5"
56+
const val firestore = "com.google.firebase:firebase-firestore:17.1.1"
5757
const val database = "com.google.firebase:firebase-database:16.0.3"
58-
const val storage = "com.google.firebase:firebase-storage:16.0.2"
58+
const val storage = "com.google.firebase:firebase-storage:16.0.3"
5959
}
6060

6161
object PlayServices {
62-
const val auth = "com.google.android.gms:play-services-auth:16.0.0"
62+
const val auth = "com.google.android.gms:play-services-auth:16.0.1"
6363
}
6464

6565

@@ -106,7 +106,7 @@ object Config {
106106
}
107107

108108
object Lint {
109-
private const val version = "26.2.0-alpha17"
109+
private const val version = "26.2.1"
110110

111111
const val api = "com.android.tools.lint:lint-api:$version"
112112
const val tests = "com.android.tools.lint:lint-tests:$version"

settings.gradle.kts renamed to settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
rootProject.buildFileName = 'build.gradle.kts'
2+
13
include(
24
":app", ":library",
35

0 commit comments

Comments
 (0)