Merge "Drop support for non ub-supportlib-* builds of support library." into oc-mr1-jetpack-dev
diff --git a/car/OWNERS b/car/OWNERS
index d226975..eac51b8 100644
--- a/car/OWNERS
+++ b/car/OWNERS
@@ -1 +1,3 @@
-ajchen@google.com
\ No newline at end of file
+ajchen@google.com
+deanh@google.com
+yaoyx@google.com
diff --git a/car/res/layout/car_paged_list_item_content.xml b/car/res/layout/car_paged_list_item_content.xml
index fd6a8a4..d9c865d 100644
--- a/car/res/layout/car_paged_list_item_content.xml
+++ b/car/res/layout/car_paged_list_item_content.xml
@@ -24,8 +24,7 @@
<ImageView
android:id="@+id/primary_icon"
android:layout_width="@dimen/car_single_line_list_item_height"
- android:layout_height="@dimen/car_single_line_list_item_height"
- android:layout_centerVertical="true"/>
+ android:layout_height="@dimen/car_single_line_list_item_height"/>
<!-- Text. -->
<TextView
diff --git a/car/src/main/java/androidx/car/widget/ListItem.java b/car/src/main/java/androidx/car/widget/ListItem.java
index d292d6b..a04a413 100644
--- a/car/src/main/java/androidx/car/widget/ListItem.java
+++ b/car/src/main/java/androidx/car/widget/ListItem.java
@@ -282,12 +282,15 @@
R.dimen.car_keyline_1));
if (!TextUtils.isEmpty(mBody)) {
- // Set top margin.
+ // Set icon top margin so that the icon remains in the same position it
+ // would've been in for non-long-text item, namely so that the center
+ // line of icon matches that of line item.
layoutParams.removeRule(RelativeLayout.CENTER_VERTICAL);
- layoutParams.topMargin = mContext.getResources().getDimensionPixelSize(
- R.dimen.car_padding_4);
+ int itemHeight = mContext.getResources().getDimensionPixelSize(
+ R.dimen.car_double_line_list_item_height);
+ layoutParams.topMargin = (itemHeight - iconSize) / 2;
} else {
- // Centered vertically.
+ // If the icon can be centered vertically, leave the work for framework.
layoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
layoutParams.topMargin = 0;
}
diff --git a/car/tests/src/androidx/car/widget/ListItemTest.java b/car/tests/src/androidx/car/widget/ListItemTest.java
index 8d2096a..1cbbc9d 100644
--- a/car/tests/src/androidx/car/widget/ListItemTest.java
+++ b/car/tests/src/androidx/car/widget/ListItemTest.java
@@ -366,6 +366,49 @@
}
@Test
+ public void testSmallPrimaryIconTopMarginRemainsTheSameRegardlessOfTextLength() {
+ final String longText = InstrumentationRegistry.getContext().getResources().getString(
+ R.string.over_120_chars);
+ List<ListItem> items = Arrays.asList(
+ // Single line item.
+ new ListItem.Builder(mActivity)
+ .withPrimaryActionIcon(android.R.drawable.sym_def_app_icon, false)
+ .withTitle("one line text")
+ .build(),
+ // Double line item with one line text.
+ new ListItem.Builder(mActivity)
+ .withPrimaryActionIcon(android.R.drawable.sym_def_app_icon, false)
+ .withTitle("one line text")
+ .withBody("one line text")
+ .build(),
+ // Double line item with long text.
+ new ListItem.Builder(mActivity)
+ .withPrimaryActionIcon(android.R.drawable.sym_def_app_icon, false)
+ .withTitle("one line text")
+ .withBody(longText)
+ .build(),
+ // Body text only - long text.
+ new ListItem.Builder(mActivity)
+ .withPrimaryActionIcon(android.R.drawable.sym_def_app_icon, false)
+ .withBody(longText)
+ .build(),
+ // Body text only - one line text.
+ new ListItem.Builder(mActivity)
+ .withPrimaryActionIcon(android.R.drawable.sym_def_app_icon, false)
+ .withBody("one line text")
+ .build());
+ setupPagedListView(items);
+
+ for (int i = 1; i < items.size(); i++) {
+ onView(withId(R.id.recycler_view)).perform(scrollToPosition(i));
+ // Implementation uses integer division so it may be off by 1 vs centered vertically.
+ assertThat((double) getViewHolderAtPosition(i - 1).getPrimaryIcon().getTop(),
+ is(closeTo(
+ (double) getViewHolderAtPosition(i).getPrimaryIcon().getTop(), 1.0d)));
+ }
+ }
+
+ @Test
public void testClickingPrimaryActionIsSeparateFromSupplementalAction() {
final boolean[] clicked = {false, false};
List<ListItem> items = Arrays.asList(
diff --git a/compat/api/current.txt b/compat/api/current.txt
index dc27c1b..145286b 100644
--- a/compat/api/current.txt
+++ b/compat/api/current.txt
@@ -1223,6 +1223,8 @@
public class ObjectsCompat {
method public static boolean equals(java.lang.Object, java.lang.Object);
+ method public static int hash(java.lang.Object...);
+ method public static int hashCode(java.lang.Object);
}
public class Pair<F, S> {
@@ -1786,7 +1788,7 @@
field public static final int TYPE_TOUCH = 0; // 0x0
}
- public final deprecated class ViewConfigurationCompat {
+ public final class ViewConfigurationCompat {
method public static float getScaledHorizontalScrollFactor(android.view.ViewConfiguration, android.content.Context);
method public static deprecated int getScaledPagingTouchSlop(android.view.ViewConfiguration);
method public static float getScaledVerticalScrollFactor(android.view.ViewConfiguration, android.content.Context);
diff --git a/compat/src/main/java/android/support/v4/graphics/TypefaceCompatUtil.java b/compat/src/main/java/android/support/v4/graphics/TypefaceCompatUtil.java
index b5d206c..c524f82 100644
--- a/compat/src/main/java/android/support/v4/graphics/TypefaceCompatUtil.java
+++ b/compat/src/main/java/android/support/v4/graphics/TypefaceCompatUtil.java
@@ -94,11 +94,15 @@
@RequiresApi(19)
public static ByteBuffer mmap(Context context, CancellationSignal cancellationSignal, Uri uri) {
final ContentResolver resolver = context.getContentResolver();
- try (ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r", cancellationSignal);
- FileInputStream fis = new FileInputStream(pfd.getFileDescriptor())) {
- FileChannel channel = fis.getChannel();
- final long size = channel.size();
- return channel.map(FileChannel.MapMode.READ_ONLY, 0, size);
+ try (ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r", cancellationSignal)) {
+ if (pfd == null) {
+ return null;
+ }
+ try (FileInputStream fis = new FileInputStream(pfd.getFileDescriptor())) {
+ FileChannel channel = fis.getChannel();
+ final long size = channel.size();
+ return channel.map(FileChannel.MapMode.READ_ONLY, 0, size);
+ }
} catch (IOException e) {
return null;
}
diff --git a/compat/src/main/java/android/support/v4/util/ObjectsCompat.java b/compat/src/main/java/android/support/v4/util/ObjectsCompat.java
index b6c740e..747cfb4 100644
--- a/compat/src/main/java/android/support/v4/util/ObjectsCompat.java
+++ b/compat/src/main/java/android/support/v4/util/ObjectsCompat.java
@@ -18,6 +18,7 @@
import android.os.Build;
import android.support.annotation.Nullable;
+import java.util.Arrays;
import java.util.Objects;
/**
@@ -51,4 +52,46 @@
return (a == b) || (a != null && a.equals(b));
}
}
+
+ /**
+ * Returns the hash code of a non-{@code null} argument and 0 for a {@code null} argument.
+ *
+ * @param o an object
+ * @return the hash code of a non-{@code null} argument and 0 for a {@code null} argument
+ * @see Object#hashCode
+ */
+ public static int hashCode(@Nullable Object o) {
+ return o != null ? o.hashCode() : 0;
+ }
+
+ /**
+ * Generates a hash code for a sequence of input values. The hash code is generated as if all
+ * the input values were placed into an array, and that array were hashed by calling
+ * {@link Arrays#hashCode(Object[])}.
+ *
+ * <p>This method is useful for implementing {@link Object#hashCode()} on objects containing
+ * multiple fields. For example, if an object that has three fields, {@code x}, {@code y}, and
+ * {@code z}, one could write:
+ *
+ * <blockquote><pre>
+ * @Override public int hashCode() {
+ * return ObjectsCompat.hash(x, y, z);
+ * }
+ * </pre></blockquote>
+ *
+ * <b>Warning: When a single object reference is supplied, the returned value does not equal the
+ * hash code of that object reference.</b> This value can be computed by calling
+ * {@link #hashCode(Object)}.
+ *
+ * @param values the values to be hashed
+ * @return a hash value of the sequence of input values
+ * @see Arrays#hashCode(Object[])
+ */
+ public static int hash(@Nullable Object... values) {
+ if (Build.VERSION.SDK_INT >= 19) {
+ return Objects.hash(values);
+ } else {
+ return Arrays.hashCode(values);
+ }
+ }
}
diff --git a/compat/src/main/java/android/support/v4/view/ViewConfigurationCompat.java b/compat/src/main/java/android/support/v4/view/ViewConfigurationCompat.java
index f14b806..60d37a9 100644
--- a/compat/src/main/java/android/support/v4/view/ViewConfigurationCompat.java
+++ b/compat/src/main/java/android/support/v4/view/ViewConfigurationCompat.java
@@ -27,10 +27,7 @@
/**
* Helper for accessing features in {@link ViewConfiguration}.
- *
- * @deprecated Use {@link ViewConfiguration} directly.
*/
-@Deprecated
public final class ViewConfigurationCompat {
private static final String TAG = "ViewConfigCompat";
diff --git a/compat/tests/java/android/support/v4/graphics/TypefaceCompatUtilTest.java b/compat/tests/java/android/support/v4/graphics/TypefaceCompatUtilTest.java
new file mode 100644
index 0000000..47e6130
--- /dev/null
+++ b/compat/tests/java/android/support/v4/graphics/TypefaceCompatUtilTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.graphics;
+
+import android.content.ContentResolver;
+import android.content.ContentUris;
+import android.content.Context;
+import android.net.Uri;
+import android.os.Build;
+import android.support.annotation.RequiresApi;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.v4.provider.MockFontProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+
+@SmallTest
+public class TypefaceCompatUtilTest {
+
+ public Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ }
+
+ @Test
+ @RequiresApi(19)
+ public void testMmapNullPfd() {
+ if (Build.VERSION.SDK_INT < 19) {
+ // The API tested here requires SDK level 19.
+ return;
+ }
+ final Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(MockFontProvider.AUTHORITY).build();
+ final Uri fileUri = ContentUris.withAppendedId(uri, MockFontProvider.INVALID_FONT_FILE_ID);
+ // Should not crash.
+ TypefaceCompatUtil.mmap(mContext, null, fileUri);
+ }
+}
diff --git a/compat/tests/java/android/support/v4/provider/MockFontProvider.java b/compat/tests/java/android/support/v4/provider/MockFontProvider.java
index f584d68..04759d0 100644
--- a/compat/tests/java/android/support/v4/provider/MockFontProvider.java
+++ b/compat/tests/java/android/support/v4/provider/MockFontProvider.java
@@ -40,10 +40,12 @@
* Provides a test Content Provider implementing {@link FontsContractCompat}.
*/
public class MockFontProvider extends ContentProvider {
+ public static final String AUTHORITY = "android.support.provider.fonts.font";
+
static final String[] FONT_FILES = {
"samplefont.ttf", "large_a.ttf", "large_b.ttf", "large_c.ttf", "large_d.ttf"
};
- private static final int INVALID_FONT_FILE_ID = -1;
+ public static final int INVALID_FONT_FILE_ID = -1;
private static final int SAMPLE_FONT_FILE_0_ID = 0;
private static final int LARGE_A_FILE_ID = 1;
private static final int LARGE_B_FILE_ID = 2;
diff --git a/compat/tests/java/android/support/v4/util/ObjectsCompatTest.java b/compat/tests/java/android/support/v4/util/ObjectsCompatTest.java
index b836ae0..f48f9b7 100644
--- a/compat/tests/java/android/support/v4/util/ObjectsCompatTest.java
+++ b/compat/tests/java/android/support/v4/util/ObjectsCompatTest.java
@@ -16,6 +16,7 @@
package android.support.v4.util;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -48,4 +49,12 @@
assertTrue(ObjectsCompat.equals(a, c));
}
+ @Test
+ public void testHashCode() {
+ String a = "aaa";
+ String n = null;
+
+ assertEquals(ObjectsCompat.hashCode(a), a.hashCode());
+ assertEquals(ObjectsCompat.hashCode(n), 0);
+ }
}
diff --git a/lifecycle/extensions/api/current.txt b/lifecycle/extensions/api/current.txt
index bf093a9..4ced8af 100644
--- a/lifecycle/extensions/api/current.txt
+++ b/lifecycle/extensions/api/current.txt
@@ -5,14 +5,6 @@
method public <T extends android.app.Application> T getApplication();
}
- public deprecated class LifecycleActivity extends android.support.v4.app.FragmentActivity {
- ctor public LifecycleActivity();
- }
-
- public deprecated class LifecycleFragment extends android.support.v4.app.Fragment {
- ctor public LifecycleFragment();
- }
-
public class LifecycleService extends android.app.Service implements android.arch.lifecycle.LifecycleOwner {
ctor public LifecycleService();
method public android.arch.lifecycle.Lifecycle getLifecycle();
@@ -35,7 +27,7 @@
}
public class ViewModelProviders {
- ctor public ViewModelProviders();
+ ctor public deprecated ViewModelProviders();
method public static android.arch.lifecycle.ViewModelProvider of(android.support.v4.app.Fragment);
method public static android.arch.lifecycle.ViewModelProvider of(android.support.v4.app.FragmentActivity);
method public static android.arch.lifecycle.ViewModelProvider of(android.support.v4.app.Fragment, android.arch.lifecycle.ViewModelProvider.Factory);
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/LifecycleActivity.java b/lifecycle/extensions/src/main/java/android/arch/lifecycle/LifecycleActivity.java
deleted file mode 100644
index 26bd508..0000000
--- a/lifecycle/extensions/src/main/java/android/arch/lifecycle/LifecycleActivity.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.arch.lifecycle;
-
-import android.support.v4.app.FragmentActivity;
-
-/**
- * @deprecated Use {@code android.support.v7.app.AppCompatActivity} instead of this class.
- */
-@Deprecated
-public class LifecycleActivity extends FragmentActivity {
-}
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/LifecycleFragment.java b/lifecycle/extensions/src/main/java/android/arch/lifecycle/LifecycleFragment.java
deleted file mode 100644
index c0da66b..0000000
--- a/lifecycle/extensions/src/main/java/android/arch/lifecycle/LifecycleFragment.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.arch.lifecycle;
-
-import android.support.v4.app.Fragment;
-
-/**
- * @deprecated Use {@link Fragment} instead of it.
- */
-@Deprecated
-public class LifecycleFragment extends Fragment {
-}
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProviders.java b/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProviders.java
index b4b20aa..3b92eda 100644
--- a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProviders.java
+++ b/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelProviders.java
@@ -32,6 +32,13 @@
*/
public class ViewModelProviders {
+ /**
+ * @deprecated This class should not be directly instantiated
+ */
+ @Deprecated
+ public ViewModelProviders() {
+ }
+
@SuppressLint("StaticFieldLeak")
private static DefaultFactory sDefaultFactory;
diff --git a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelStores.java b/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelStores.java
index d7d769d..e79c934 100644
--- a/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelStores.java
+++ b/lifecycle/extensions/src/main/java/android/arch/lifecycle/ViewModelStores.java
@@ -40,6 +40,9 @@
*/
@MainThread
public static ViewModelStore of(@NonNull FragmentActivity activity) {
+ if (activity instanceof ViewModelStoreOwner) {
+ return ((ViewModelStoreOwner) activity).getViewModelStore();
+ }
return holderFragmentFor(activity).getViewModelStore();
}
@@ -51,6 +54,9 @@
*/
@MainThread
public static ViewModelStore of(@NonNull Fragment fragment) {
+ if (fragment instanceof ViewModelStoreOwner) {
+ return ((ViewModelStoreOwner) fragment).getViewModelStore();
+ }
return holderFragmentFor(fragment).getViewModelStore();
}
}
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/ClassWriter.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/ClassWriter.kt
index 8cf511f..ebd0adf 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/ClassWriter.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/ClassWriter.kt
@@ -112,11 +112,11 @@
abstract class SharedMethodSpec(val baseName: String) {
abstract fun getUniqueKey(): String
- abstract fun prepare(writer: ClassWriter, builder: MethodSpec.Builder)
+ abstract fun prepare(methodName: String, writer: ClassWriter, builder: MethodSpec.Builder)
fun build(writer: ClassWriter, name: String): MethodSpec {
val builder = MethodSpec.methodBuilder(name)
- prepare(writer, builder)
+ prepare(name, writer, builder)
return builder.build()
}
}
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/EntityCursorConverterWriter.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/EntityCursorConverterWriter.kt
index a96e23c..b9d6aec 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/EntityCursorConverterWriter.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/EntityCursorConverterWriter.kt
@@ -22,8 +22,8 @@
import android.arch.persistence.room.ext.S
import android.arch.persistence.room.ext.T
import android.arch.persistence.room.solver.CodeGenScope
-import android.arch.persistence.room.vo.Entity
import android.arch.persistence.room.vo.EmbeddedField
+import android.arch.persistence.room.vo.Entity
import android.arch.persistence.room.vo.FieldWithIndex
import com.squareup.javapoet.CodeBlock
import com.squareup.javapoet.MethodSpec
@@ -38,7 +38,7 @@
return "generic_entity_converter_of_${entity.element.qualifiedName}"
}
- override fun prepare(writer: ClassWriter, builder: MethodSpec.Builder) {
+ override fun prepare(methodName: String, writer: ClassWriter, builder: MethodSpec.Builder) {
builder.apply {
val cursorParam = ParameterSpec
.builder(AndroidTypeNames.CURSOR, "cursor").build()
diff --git a/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/RelationCollectorMethodWriter.kt b/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/RelationCollectorMethodWriter.kt
index 71f0510..ecd9b59 100644
--- a/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/RelationCollectorMethodWriter.kt
+++ b/room/compiler/src/main/kotlin/android/arch/persistence/room/writer/RelationCollectorMethodWriter.kt
@@ -19,6 +19,7 @@
import android.arch.persistence.room.ext.AndroidTypeNames
import android.arch.persistence.room.ext.L
import android.arch.persistence.room.ext.N
+import android.arch.persistence.room.ext.RoomTypeNames
import android.arch.persistence.room.ext.S
import android.arch.persistence.room.ext.T
import android.arch.persistence.room.solver.CodeGenScope
@@ -34,7 +35,7 @@
/**
* Writes the method that fetches the relations of a POJO and assigns them into the given map.
*/
-class RelationCollectorMethodWriter(val collector: RelationCollector)
+class RelationCollectorMethodWriter(private val collector: RelationCollector)
: ClassWriter.SharedMethodSpec(
"fetchRelationship${collector.relation.entity.tableName.stripNonJava()}" +
"As${collector.relation.pojoTypeName.toString().stripNonJava()}") {
@@ -51,7 +52,7 @@
"-${relation.createLoadAllSql()}"
}
- override fun prepare(writer: ClassWriter, builder: MethodSpec.Builder) {
+ override fun prepare(methodName: String, writer: ClassWriter, builder: MethodSpec.Builder) {
val scope = CodeGenScope(writer)
val relation = collector.relation
@@ -74,6 +75,41 @@
addStatement("return")
}
endControlFlow()
+ addStatement("// check if the size is too big, if so divide")
+ beginControlFlow("if($N.size() > $T.MAX_BIND_PARAMETER_CNT)",
+ param, RoomTypeNames.ROOM_DB).apply {
+ // divide it into chunks
+ val tmpMapVar = scope.getTmpVar("_tmpInnerMap")
+ addStatement("$T $L = new $T($L.MAX_BIND_PARAMETER_CNT)",
+ collector.mapTypeName, tmpMapVar,
+ collector.mapTypeName, RoomTypeNames.ROOM_DB)
+ val mapIndexVar = scope.getTmpVar("_mapIndex")
+ val tmpIndexVar = scope.getTmpVar("_tmpIndex")
+ val limitVar = scope.getTmpVar("_limit")
+ addStatement("$T $L = 0", TypeName.INT, mapIndexVar)
+ addStatement("$T $L = 0", TypeName.INT, tmpIndexVar)
+ addStatement("final $T $L = $N.size()", TypeName.INT, limitVar, param)
+ beginControlFlow("while($L < $L)", mapIndexVar, limitVar).apply {
+ addStatement("$L.put($N.keyAt($L), $N.valueAt($L))",
+ tmpMapVar, param, mapIndexVar, param, mapIndexVar)
+ addStatement("$L++", mapIndexVar)
+ addStatement("$L++", tmpIndexVar)
+ beginControlFlow("if($L == $T.MAX_BIND_PARAMETER_CNT)",
+ tmpIndexVar, RoomTypeNames.ROOM_DB).apply {
+ // recursively load that batch
+ addStatement("$L($L)", methodName, tmpMapVar)
+ // clear nukes the backing data hence we create a new one
+ addStatement("$L = new $T($T.MAX_BIND_PARAMETER_CNT)",
+ tmpMapVar, collector.mapTypeName, RoomTypeNames.ROOM_DB)
+ addStatement("$L = 0", tmpIndexVar)
+ }.endControlFlow()
+ }.endControlFlow()
+ beginControlFlow("if($L > 0)", tmpIndexVar).apply {
+ // load the last batch
+ addStatement("$L($L)", methodName, tmpMapVar)
+ }.endControlFlow()
+ addStatement("return")
+ }.endControlFlow()
collector.queryWriter.prepareReadAndBind(sqlQueryVar, stmtVar, scope)
addStatement("final $T $L = $N.query($L)", AndroidTypeNames.CURSOR, cursorVar,
diff --git a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/test/PojoWithRelationTest.java b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/test/PojoWithRelationTest.java
index f9ff4c2..c3ebfe9 100644
--- a/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/test/PojoWithRelationTest.java
+++ b/room/integration-tests/testapp/src/androidTest/java/android/arch/persistence/room/integration/testapp/test/PojoWithRelationTest.java
@@ -35,6 +35,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -188,4 +189,46 @@
new UserAndPetAdoptionDates(user, Arrays.asList(new Date(300), new Date(700)))
)));
}
+
+ @Test
+ public void largeRelation_child() {
+ User user = TestUtil.createUser(3);
+ List<Pet> pets = new ArrayList<>();
+ for (int i = 0; i < 2000; i++) {
+ Pet pet = TestUtil.createPet(i + 1);
+ pet.setUserId(3);
+ }
+ mUserDao.insert(user);
+ mPetDao.insertAll(pets.toArray(new Pet[pets.size()]));
+ List<UserAndAllPets> result = mUserPetDao.loadAllUsersWithTheirPets();
+ assertThat(result.size(), is(1));
+ assertThat(result.get(0).user, is(user));
+ assertThat(result.get(0).pets, is(pets));
+ }
+
+ @Test
+ public void largeRelation_parent() {
+ final List<User> users = new ArrayList<>();
+ final List<Pet> pets = new ArrayList<>();
+ for (int i = 0; i < 2000; i++) {
+ User user = TestUtil.createUser(i + 1);
+ users.add(user);
+ Pet pet = TestUtil.createPet(i + 1);
+ pet.setUserId(user.getId());
+ pets.add(pet);
+ }
+ mDatabase.runInTransaction(new Runnable() {
+ @Override
+ public void run() {
+ mUserDao.insertAll(users.toArray(new User[users.size()]));
+ mPetDao.insertAll(pets.toArray(new Pet[pets.size()]));
+ }
+ });
+ List<UserAndAllPets> result = mUserPetDao.loadAllUsersWithTheirPets();
+ assertThat(result.size(), is(2000));
+ for (int i = 0; i < 2000; i++) {
+ assertThat(result.get(i).user, is(users.get(i)));
+ assertThat(result.get(i).pets, is(Collections.singletonList(pets.get(i))));
+ }
+ }
}
diff --git a/room/runtime/src/main/java/android/arch/persistence/room/RoomDatabase.java b/room/runtime/src/main/java/android/arch/persistence/room/RoomDatabase.java
index 2a108f9..70d832b 100644
--- a/room/runtime/src/main/java/android/arch/persistence/room/RoomDatabase.java
+++ b/room/runtime/src/main/java/android/arch/persistence/room/RoomDatabase.java
@@ -52,6 +52,13 @@
//@SuppressWarnings({"unused", "WeakerAccess"})
public abstract class RoomDatabase {
private static final String DB_IMPL_SUFFIX = "_Impl";
+ /**
+ * Unfortunately, we cannot read this value so we are only setting it to the SQLite default.
+ *
+ * @hide
+ */
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ public static final int MAX_BIND_PARAMETER_CNT = 999;
// set by the generated open helper.
protected volatile SupportSQLiteDatabase mDatabase;
private SupportSQLiteOpenHelper mOpenHelper;
diff --git a/samples/Support13Demos/src/main/AndroidManifest.xml b/samples/Support13Demos/src/main/AndroidManifest.xml
index af7fad2..6be99b6 100644
--- a/samples/Support13Demos/src/main/AndroidManifest.xml
+++ b/samples/Support13Demos/src/main/AndroidManifest.xml
@@ -77,13 +77,5 @@
</intent-filter>
</activity>
- <activity android:name=".view.inputmethod.CommitContentSupport"
- android:label="@string/commit_content_support">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="com.example.android.supportv13.SUPPORT13_SAMPLE_CODE" />
- </intent-filter>
- </activity>
-
</application>
</manifest>
diff --git a/samples/Support13Demos/src/main/java/com/example/android/supportv13/Shakespeare.java b/samples/Support13Demos/src/main/java/com/example/android/supportv13/Shakespeare.java
deleted file mode 100644
index 01f8dc8..0000000
--- a/samples/Support13Demos/src/main/java/com/example/android/supportv13/Shakespeare.java
+++ /dev/null
@@ -1,223 +0,0 @@
-package com.example.android.supportv13;
-
-public final class Shakespeare {
- /**
- * Our data, part 1.
- */
- public static final String[] TITLES =
- {
- "Henry IV (1)",
- "Henry V",
- "Henry VIII",
- "Richard II",
- "Richard III",
- "Merchant of Venice",
- "Othello",
- "King Lear"
- };
-
- /**
- * Our data, part 2.
- */
- public static final String[] DIALOGUE =
- {
- "So shaken as we are, so wan with care," +
- "Find we a time for frighted peace to pant," +
- "And breathe short-winded accents of new broils" +
- "To be commenced in strands afar remote." +
- "No more the thirsty entrance of this soil" +
- "Shall daub her lips with her own children's blood;" +
- "Nor more shall trenching war channel her fields," +
- "Nor bruise her flowerets with the armed hoofs" +
- "Of hostile paces: those opposed eyes," +
- "Which, like the meteors of a troubled heaven," +
- "All of one nature, of one substance bred," +
- "Did lately meet in the intestine shock" +
- "And furious close of civil butchery" +
- "Shall now, in mutual well-beseeming ranks," +
- "March all one way and be no more opposed" +
- "Against acquaintance, kindred and allies:" +
- "The edge of war, like an ill-sheathed knife," +
- "No more shall cut his master. Therefore, friends," +
- "As far as to the sepulchre of Christ," +
- "Whose soldier now, under whose blessed cross" +
- "We are impressed and engaged to fight," +
- "Forthwith a power of English shall we levy;" +
- "Whose arms were moulded in their mothers' womb" +
- "To chase these pagans in those holy fields" +
- "Over whose acres walk'd those blessed feet" +
- "Which fourteen hundred years ago were nail'd" +
- "For our advantage on the bitter cross." +
- "But this our purpose now is twelve month old," +
- "And bootless 'tis to tell you we will go:" +
- "Therefore we meet not now. Then let me hear" +
- "Of you, my gentle cousin Westmoreland," +
- "What yesternight our council did decree" +
- "In forwarding this dear expedience.",
-
- "Hear him but reason in divinity," +
- "And all-admiring with an inward wish" +
- "You would desire the king were made a prelate:" +
- "Hear him debate of commonwealth affairs," +
- "You would say it hath been all in all his study:" +
- "List his discourse of war, and you shall hear" +
- "A fearful battle render'd you in music:" +
- "Turn him to any cause of policy," +
- "The Gordian knot of it he will unloose," +
- "Familiar as his garter: that, when he speaks," +
- "The air, a charter'd libertine, is still," +
- "And the mute wonder lurketh in men's ears," +
- "To steal his sweet and honey'd sentences;" +
- "So that the art and practic part of life" +
- "Must be the mistress to this theoric:" +
- "Which is a wonder how his grace should glean it," +
- "Since his addiction was to courses vain," +
- "His companies unletter'd, rude and shallow," +
- "His hours fill'd up with riots, banquets, sports," +
- "And never noted in him any study," +
- "Any retirement, any sequestration" +
- "From open haunts and popularity.",
-
- "I come no more to make you laugh: things now," +
- "That bear a weighty and a serious brow," +
- "Sad, high, and working, full of state and woe," +
- "Such noble scenes as draw the eye to flow," +
- "We now present. Those that can pity, here" +
- "May, if they think it well, let fall a tear;" +
- "The subject will deserve it. Such as give" +
- "Their money out of hope they may believe," +
- "May here find truth too. Those that come to see" +
- "Only a show or two, and so agree" +
- "The play may pass, if they be still and willing," +
- "I'll undertake may see away their shilling" +
- "Richly in two short hours. Only they" +
- "That come to hear a merry bawdy play," +
- "A noise of targets, or to see a fellow" +
- "In a long motley coat guarded with yellow," +
- "Will be deceived; for, gentle hearers, know," +
- "To rank our chosen truth with such a show" +
- "As fool and fight is, beside forfeiting" +
- "Our own brains, and the opinion that we bring," +
- "To make that only true we now intend," +
- "Will leave us never an understanding friend." +
- "Therefore, for goodness' sake, and as you are known" +
- "The first and happiest hearers of the town," +
- "Be sad, as we would make ye: think ye see" +
- "The very persons of our noble story" +
- "As they were living; think you see them great," +
- "And follow'd with the general throng and sweat" +
- "Of thousand friends; then in a moment, see" +
- "How soon this mightiness meets misery:" +
- "And, if you can be merry then, I'll say" +
- "A man may weep upon his wedding-day.",
-
- "First, heaven be the record to my speech!" +
- "In the devotion of a subject's love," +
- "Tendering the precious safety of my prince," +
- "And free from other misbegotten hate," +
- "Come I appellant to this princely presence." +
- "Now, Thomas Mowbray, do I turn to thee," +
- "And mark my greeting well; for what I speak" +
- "My body shall make good upon this earth," +
- "Or my divine soul answer it in heaven." +
- "Thou art a traitor and a miscreant," +
- "Too good to be so and too bad to live," +
- "Since the more fair and crystal is the sky," +
- "The uglier seem the clouds that in it fly." +
- "Once more, the more to aggravate the note," +
- "With a foul traitor's name stuff I thy throat;" +
- "And wish, so please my sovereign, ere I move," +
- "What my tongue speaks my right drawn sword may prove.",
-
- "Now is the winter of our discontent" +
- "Made glorious summer by this sun of York;" +
- "And all the clouds that lour'd upon our house" +
- "In the deep bosom of the ocean buried." +
- "Now are our brows bound with victorious wreaths;" +
- "Our bruised arms hung up for monuments;" +
- "Our stern alarums changed to merry meetings," +
- "Our dreadful marches to delightful measures." +
- "Grim-visaged war hath smooth'd his wrinkled front;" +
- "And now, instead of mounting barded steeds" +
- "To fright the souls of fearful adversaries," +
- "He capers nimbly in a lady's chamber" +
- "To the lascivious pleasing of a lute." +
- "But I, that am not shaped for sportive tricks," +
- "Nor made to court an amorous looking-glass;" +
- "I, that am rudely stamp'd, and want love's majesty" +
- "To strut before a wanton ambling nymph;" +
- "I, that am curtail'd of this fair proportion," +
- "Cheated of feature by dissembling nature," +
- "Deformed, unfinish'd, sent before my time" +
- "Into this breathing world, scarce half made up," +
- "And that so lamely and unfashionable" +
- "That dogs bark at me as I halt by them;" +
- "Why, I, in this weak piping time of peace," +
- "Have no delight to pass away the time," +
- "Unless to spy my shadow in the sun" +
- "And descant on mine own deformity:" +
- "And therefore, since I cannot prove a lover," +
- "To entertain these fair well-spoken days," +
- "I am determined to prove a villain" +
- "And hate the idle pleasures of these days." +
- "Plots have I laid, inductions dangerous," +
- "By drunken prophecies, libels and dreams," +
- "To set my brother Clarence and the king" +
- "In deadly hate the one against the other:" +
- "And if King Edward be as true and just" +
- "As I am subtle, false and treacherous," +
- "This day should Clarence closely be mew'd up," +
- "About a prophecy, which says that 'G'" +
- "Of Edward's heirs the murderer shall be." +
- "Dive, thoughts, down to my soul: here" +
- "Clarence comes.",
-
- "To bait fish withal: if it will feed nothing else," +
- "it will feed my revenge. He hath disgraced me, and" +
- "hindered me half a million; laughed at my losses," +
- "mocked at my gains, scorned my nation, thwarted my" +
- "bargains, cooled my friends, heated mine" +
- "enemies; and what's his reason? I am a Jew. Hath" +
- "not a Jew eyes? hath not a Jew hands, organs," +
- "dimensions, senses, affections, passions? fed with" +
- "the same food, hurt with the same weapons, subject" +
- "to the same diseases, healed by the same means," +
- "warmed and cooled by the same winter and summer, as" +
- "a Christian is? If you prick us, do we not bleed?" +
- "if you tickle us, do we not laugh? if you poison" +
- "us, do we not die? and if you wrong us, shall we not" +
- "revenge? If we are like you in the rest, we will" +
- "resemble you in that. If a Jew wrong a Christian," +
- "what is his humility? Revenge. If a Christian" +
- "wrong a Jew, what should his sufferance be by" +
- "Christian example? Why, revenge. The villany you" +
- "teach me, I will execute, and it shall go hard but I" +
- "will better the instruction.",
-
- "Virtue! a fig! 'tis in ourselves that we are thus" +
- "or thus. Our bodies are our gardens, to the which" +
- "our wills are gardeners: so that if we will plant" +
- "nettles, or sow lettuce, set hyssop and weed up" +
- "thyme, supply it with one gender of herbs, or" +
- "distract it with many, either to have it sterile" +
- "with idleness, or manured with industry, why, the" +
- "power and corrigible authority of this lies in our" +
- "wills. If the balance of our lives had not one" +
- "scale of reason to poise another of sensuality, the" +
- "blood and baseness of our natures would conduct us" +
- "to most preposterous conclusions: but we have" +
- "reason to cool our raging motions, our carnal" +
- "stings, our unbitted lusts, whereof I take this that" +
- "you call love to be a sect or scion.",
-
- "Blow, winds, and crack your cheeks! rage! blow!" +
- "You cataracts and hurricanoes, spout" +
- "Till you have drench'd our steeples, drown'd the cocks!" +
- "You sulphurous and thought-executing fires," +
- "Vaunt-couriers to oak-cleaving thunderbolts," +
- "Singe my white head! And thou, all-shaking thunder," +
- "Smite flat the thick rotundity o' the world!" +
- "Crack nature's moulds, an germens spill at once," +
- "That make ingrateful man!"
- };
-}
diff --git a/samples/Support13Demos/src/main/java/com/example/android/supportv13/view/CheckableFrameLayout.java b/samples/Support13Demos/src/main/java/com/example/android/supportv13/view/CheckableFrameLayout.java
deleted file mode 100644
index e2383de..0000000
--- a/samples/Support13Demos/src/main/java/com/example/android/supportv13/view/CheckableFrameLayout.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.supportv13.view;
-
-import android.content.Context;
-import android.graphics.drawable.ColorDrawable;
-import android.util.AttributeSet;
-import android.widget.Checkable;
-import android.widget.FrameLayout;
-
-public class CheckableFrameLayout extends FrameLayout implements Checkable {
- private boolean mChecked;
-
- public CheckableFrameLayout(Context context) {
- super(context);
- }
-
- public CheckableFrameLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- public void setChecked(boolean checked) {
- mChecked = checked;
- setBackgroundDrawable(checked ? new ColorDrawable(0xff0000a0) : null);
- }
-
- @Override
- public boolean isChecked() {
- return mChecked;
- }
-
- @Override
- public void toggle() {
- setChecked(!mChecked);
- }
-
-}
diff --git a/samples/Support13Demos/src/main/res/drawable-hdpi/alert_dialog_icon.png b/samples/Support13Demos/src/main/res/drawable-hdpi/alert_dialog_icon.png
deleted file mode 100755
index fe54477..0000000
--- a/samples/Support13Demos/src/main/res/drawable-hdpi/alert_dialog_icon.png
+++ /dev/null
Binary files differ
diff --git a/samples/Support13Demos/src/main/res/drawable-mdpi/alert_dialog_icon.png b/samples/Support13Demos/src/main/res/drawable-mdpi/alert_dialog_icon.png
deleted file mode 100644
index 0a7de04..0000000
--- a/samples/Support13Demos/src/main/res/drawable-mdpi/alert_dialog_icon.png
+++ /dev/null
Binary files differ
diff --git a/samples/Support13Demos/src/main/res/layout/simple_list_item_checkable_1.xml b/samples/Support13Demos/src/main/res/layout/simple_list_item_checkable_1.xml
deleted file mode 100644
index 84017a6..0000000
--- a/samples/Support13Demos/src/main/res/layout/simple_list_item_checkable_1.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<com.example.android.supportv4.view.CheckableFrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TextView
- android:id="@android:id/text1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:minHeight="?android:attr/listPreferredItemHeight"
- android:gravity="center_vertical"
- />
-</com.example.android.supportv4.view.CheckableFrameLayout>
diff --git a/samples/Support13Demos/src/main/res/values/colors.xml b/samples/Support13Demos/src/main/res/values/colors.xml
deleted file mode 100644
index e50c7a0..0000000
--- a/samples/Support13Demos/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <drawable name="red">#7f00</drawable>
- <drawable name="blue">#770000ff</drawable>
- <drawable name="green">#7700ff00</drawable>
- <drawable name="yellow">#77ffff00</drawable>
-</resources>
diff --git a/samples/Support13Demos/src/main/res/values/strings.xml b/samples/Support13Demos/src/main/res/values/strings.xml
index b0950b2..7c621e9 100644
--- a/samples/Support13Demos/src/main/res/values/strings.xml
+++ b/samples/Support13Demos/src/main/res/values/strings.xml
@@ -20,11 +20,6 @@
<string name="hello_world"><b>Hello, <i>World!</i></b></string>
<string name="retained">Retained state</string>
- <string name="alert_dialog_two_buttons_title">
- Lorem ipsum dolor sit aie consectetur adipiscing\nPlloaso mako nuto
- siwuf cakso dodtos anr koop.
- </string>
-
<string name="fragment_nesting_pager_support">Fragment/Nesting Pager</string>
<string name="fragment_nesting_state_pager_support">Fragment/Nesting State Pager</string>
@@ -34,9 +29,4 @@
<string name="last">Last</string>
<string name="fragment_state_pager_support">Fragment/State Pager</string>
-
- <string name="action_bar_tabs_pager">Fragment/Action Bar Tabs Pager</string>
-
- <string name="commit_content_support">View/Input Method/Commit Content</string>
-
</resources>
diff --git a/samples/Support4Demos/src/main/AndroidManifest.xml b/samples/Support4Demos/src/main/AndroidManifest.xml
index 812d4e8..66f34dc 100644
--- a/samples/Support4Demos/src/main/AndroidManifest.xml
+++ b/samples/Support4Demos/src/main/AndroidManifest.xml
@@ -424,6 +424,14 @@
</provider>
<!-- END_INCLUDE(file_provider_declaration) -->
+ <activity android:name=".view.inputmethod.CommitContentSupport"
+ android:label="@string/commit_content_support">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.supportv13.SUPPORT13_SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<!-- MediaBrowserCompat Sample -->
<activity android:name=".media.MediaBrowserSupport"
android:label="@string/media_browser_support">
diff --git a/samples/Support13Demos/src/main/java/com/example/android/supportv13/view/inputmethod/CommitContentSupport.java b/samples/Support4Demos/src/main/java/com/example/android/supportv4/view/inputmethod/CommitContentSupport.java
similarity index 93%
rename from samples/Support13Demos/src/main/java/com/example/android/supportv13/view/inputmethod/CommitContentSupport.java
rename to samples/Support4Demos/src/main/java/com/example/android/supportv4/view/inputmethod/CommitContentSupport.java
index 78d64cd..335fa76 100644
--- a/samples/Support13Demos/src/main/java/com/example/android/supportv13/view/inputmethod/CommitContentSupport.java
+++ b/samples/Support4Demos/src/main/java/com/example/android/supportv4/view/inputmethod/CommitContentSupport.java
@@ -11,22 +11,19 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License
+ * limitations under the License.
*/
-package com.example.android.supportv13.view.inputmethod;
-
-import com.example.android.supportv13.R;
-
-import android.support.v13.view.inputmethod.EditorInfoCompat;
-import android.support.v13.view.inputmethod.InputConnectionCompat;
-import android.support.v13.view.inputmethod.InputContentInfoCompat;
+package com.example.android.supportv4.view.inputmethod;
import android.app.Activity;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
+import android.support.v13.view.inputmethod.EditorInfoCompat;
+import android.support.v13.view.inputmethod.InputConnectionCompat;
+import android.support.v13.view.inputmethod.InputContentInfoCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.inputmethod.EditorInfo;
@@ -36,14 +33,18 @@
import android.widget.LinearLayout;
import android.widget.TextView;
+import com.example.android.supportv4.R;
+
import java.util.ArrayList;
import java.util.Arrays;
+/**
+ * Demo activity for using {@link InputConnectionCompat}.
+ */
public class CommitContentSupport extends Activity {
private static final String INPUT_CONTENT_INFO_KEY = "COMMIT_CONTENT_INPUT_CONTENT_INFO";
private static final String COMMIT_CONTENT_FLAGS_KEY = "COMMIT_CONTENT_FLAGS";
-
- private static String TAG = "CommitContentSupport";
+ private static final String TAG = "CommitContentSupport";
private WebView mWebView;
private TextView mLabel;
@@ -108,7 +109,7 @@
}
private boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags,
- Bundle opts, String[] contentMimeTypes) {
+ String[] contentMimeTypes) {
// Clear the temporary permission (if any). See below about why we do this here.
try {
if (mCurrentInputContentInfo != null) {
@@ -211,14 +212,9 @@
final InputConnection ic = super.onCreateInputConnection(editorInfo);
EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
final InputConnectionCompat.OnCommitContentListener callback =
- new InputConnectionCompat.OnCommitContentListener() {
- @Override
- public boolean onCommitContent(InputContentInfoCompat inputContentInfo,
- int flags, Bundle opts) {
- return CommitContentSupport.this.onCommitContent(
- inputContentInfo, flags, opts, mimeTypes);
- }
- };
+ (inputContentInfo, flags, opts) ->
+ CommitContentSupport.this.onCommitContent(
+ inputContentInfo, flags, mimeTypes);
return InputConnectionCompat.createWrapper(ic, editorInfo, callback);
}
};
diff --git a/samples/Support13Demos/src/main/res/layout/commit_content.xml b/samples/Support4Demos/src/main/res/layout/commit_content.xml
similarity index 100%
rename from samples/Support13Demos/src/main/res/layout/commit_content.xml
rename to samples/Support4Demos/src/main/res/layout/commit_content.xml
diff --git a/samples/Support4Demos/src/main/res/values/strings.xml b/samples/Support4Demos/src/main/res/values/strings.xml
index 83404e8..86adb94 100644
--- a/samples/Support4Demos/src/main/res/values/strings.xml
+++ b/samples/Support4Demos/src/main/res/values/strings.xml
@@ -241,4 +241,6 @@
<string name="drawable_compat_no_tint">Not tint</string>
<string name="drawable_compat_color_tint">Color tint</string>
<string name="drawable_compat_color_list_tint">Color state list</string>
+
+ <string name="commit_content_support">View/Input Method/Commit Content</string>
</resources>
diff --git a/v13/build.gradle b/v13/build.gradle
index 88e0bc0..9965d1d 100644
--- a/v13/build.gradle
+++ b/v13/build.gradle
@@ -1,4 +1,3 @@
-import static android.support.dependencies.DependenciesKt.*
import android.support.LibraryGroups
import android.support.LibraryVersions
@@ -9,11 +8,6 @@
dependencies {
api(project(":support-annotations"))
api(project(":support-v4"))
-
- androidTestImplementation(TEST_RUNNER)
- androidTestImplementation(ESPRESSO_CORE)
- androidTestImplementation(MOCKITO_CORE, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
- androidTestImplementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
}
android {
diff --git a/v13/tests/AndroidManifest.xml b/v13/tests/AndroidManifest.xml
deleted file mode 100644
index 3ec7e98..0000000
--- a/v13/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.support.v13.test">
- <uses-sdk android:targetSdkVersion="${target-sdk-version}"/>
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
-
- <application>
- <activity android:name="android.support.v13.app.FragmentCompatTestActivity" />
- </application>
-
-</manifest>
diff --git a/v13/tests/NO_DOCS b/v13/tests/NO_DOCS
deleted file mode 100644
index 092a39c..0000000
--- a/v13/tests/NO_DOCS
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-Having this file, named NO_DOCS, in a directory will prevent
-Android javadocs from being generated for java files under
-the directory. This is especially useful for test projects.
diff --git a/v13/tests/java/android/support/v13/app/FragmentCompatTest.java b/v13/tests/java/android/support/v13/app/FragmentCompatTest.java
deleted file mode 100644
index 34b01f1..0000000
--- a/v13/tests/java/android/support/v13/app/FragmentCompatTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.support.v13.app;
-
-import static org.mockito.AdditionalMatchers.aryEq;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.same;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-import android.Manifest;
-import android.app.Activity;
-import android.app.Fragment;
-import android.os.Build;
-import android.support.annotation.NonNull;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SdkSuppress;
-import android.support.test.filters.SmallTest;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.support.v13.app.FragmentCompat.PermissionCompatDelegate;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
-public class FragmentCompatTest {
- @Rule
- public ActivityTestRule<FragmentCompatTestActivity> mActivityRule =
- new ActivityTestRule<>(FragmentCompatTestActivity.class);
-
- private Activity mActivity;
- private TestFragment mFragment;
-
- @Before
- public void setup() throws Throwable {
- mActivity = mActivityRule.getActivity();
- mFragment = attachTestFragment();
- }
-
- @SmallTest
- @Test
- public void testFragmentCompatDelegate() {
- FragmentCompat.PermissionCompatDelegate delegate = mock(PermissionCompatDelegate.class);
-
- // First test setting the delegate
- FragmentCompat.setPermissionCompatDelegate(delegate);
-
- FragmentCompat.requestPermissions(mFragment, new String[]{
- Manifest.permission.ACCESS_FINE_LOCATION}, 42);
- verify(delegate).requestPermissions(same(mFragment),
- aryEq(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}), eq(42));
-
- // Now test clearing the delegate
- FragmentCompat.setPermissionCompatDelegate(null);
-
- FragmentCompat.requestPermissions(mFragment, new String[]{
- Manifest.permission.ACCESS_FINE_LOCATION}, 42);
-
- verifyNoMoreInteractions(delegate);
- }
-
- private TestFragment attachTestFragment() throws Throwable {
- final TestFragment fragment = new TestFragment();
- mActivityRule.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mActivity.getFragmentManager().beginTransaction()
- .add(fragment, null)
- .addToBackStack(null)
- .commitAllowingStateLoss();
- mActivity.getFragmentManager().executePendingTransactions();
- }
- });
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
- return fragment;
- }
-
- /**
- * Empty class to satisfy java class dependency.
- */
- public static class TestFragment extends Fragment implements
- FragmentCompat.OnRequestPermissionsResultCallback {
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
- @NonNull int[] grantResults) {}
- }
-}
diff --git a/v13/tests/java/android/support/v13/app/FragmentCompatTestActivity.java b/v13/tests/java/android/support/v13/app/FragmentCompatTestActivity.java
deleted file mode 100644
index b3ab763..0000000
--- a/v13/tests/java/android/support/v13/app/FragmentCompatTestActivity.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.support.v13.app;
-
-import android.app.Activity;
-
-public class FragmentCompatTestActivity extends Activity {
-}
diff --git a/v7/appcompat/src/main/java/android/support/v7/widget/ButtonBarLayout.java b/v7/appcompat/src/main/java/android/support/v7/widget/ButtonBarLayout.java
index b47a568..f4bbc6c 100644
--- a/v7/appcompat/src/main/java/android/support/v7/widget/ButtonBarLayout.java
+++ b/v7/appcompat/src/main/java/android/support/v7/widget/ButtonBarLayout.java
@@ -35,9 +35,6 @@
*/
@RestrictTo(LIBRARY_GROUP)
public class ButtonBarLayout extends LinearLayout {
- /** Minimum screen height required for button stacking. */
- private static final int ALLOW_STACKING_MIN_HEIGHT_DP = 320;
-
/** Amount of the second button to "peek" above the fold when stacked. */
private static final int PEEK_BUTTON_DP = 16;
@@ -50,11 +47,8 @@
public ButtonBarLayout(Context context, AttributeSet attrs) {
super(context, attrs);
- final boolean allowStackingDefault =
- getResources().getConfiguration().screenHeightDp >= ALLOW_STACKING_MIN_HEIGHT_DP;
final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ButtonBarLayout);
- mAllowStacking = ta.getBoolean(R.styleable.ButtonBarLayout_allowStacking,
- allowStackingDefault);
+ mAllowStacking = ta.getBoolean(R.styleable.ButtonBarLayout_allowStacking, true);
ta.recycle();
}