Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/core-ktx/api/current.ignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// Baseline format: 1.0
ChangedDeprecated: androidx.core.util.SizeKt#component1(androidx.core.util.SizeFCompat):
Source breaking change: Method androidx.core.util.SizeKt.component1 has changed deprecation state false --> true
ChangedDeprecated: androidx.core.util.SizeKt#component2(androidx.core.util.SizeFCompat):
Source breaking change: Method androidx.core.util.SizeKt.component2 has changed deprecation state false --> true


RemovedFromBytecode: androidx.core.content.ContextKt#getSystemService(android.content.Context):
Binary breaking change: method androidx.core.content.ContextKt.getSystemService(android.content.Context) has been removed from bytecode
RemovedFromBytecode: androidx.core.text.SpannedStringKt#getSpans(android.text.Spanned, int, int):
Expand Down
4 changes: 2 additions & 2 deletions core/core-ktx/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ package androidx.core.util {
public final class SizeKt {
method public static inline operator int component1(android.util.Size);
method public static inline operator float component1(android.util.SizeF);
method public static inline operator float component1(androidx.core.util.SizeFCompat);
method @Deprecated public static inline operator float component1(androidx.core.util.SizeFCompat);
method public static inline operator int component2(android.util.Size);
method public static inline operator float component2(android.util.SizeF);
method public static inline operator float component2(androidx.core.util.SizeFCompat);
method @Deprecated public static inline operator float component2(androidx.core.util.SizeFCompat);
}

public final class SparseArrayKt {
Expand Down
6 changes: 6 additions & 0 deletions core/core-ktx/api/restricted_current.ignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// Baseline format: 1.0
ChangedDeprecated: androidx.core.util.SizeKt#component1(androidx.core.util.SizeFCompat):
Source breaking change: Method androidx.core.util.SizeKt.component1 has changed deprecation state false --> true
ChangedDeprecated: androidx.core.util.SizeKt#component2(androidx.core.util.SizeFCompat):
Source breaking change: Method androidx.core.util.SizeKt.component2 has changed deprecation state false --> true


RemovedFromBytecode: androidx.core.content.ContextKt#getSystemService(android.content.Context):
Binary breaking change: method androidx.core.content.ContextKt.getSystemService(android.content.Context) has been removed from bytecode
RemovedFromBytecode: androidx.core.text.SpannedStringKt#getSpans(android.text.Spanned, int, int):
Expand Down
4 changes: 2 additions & 2 deletions core/core-ktx/api/restricted_current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ package androidx.core.util {
public final class SizeKt {
method public static inline operator int component1(android.util.Size);
method public static inline operator float component1(android.util.SizeF);
method public static inline operator float component1(androidx.core.util.SizeFCompat);
method @Deprecated public static inline operator float component1(androidx.core.util.SizeFCompat);
method public static inline operator int component2(android.util.Size);
method public static inline operator float component2(android.util.SizeF);
method public static inline operator float component2(androidx.core.util.SizeFCompat);
method @Deprecated public static inline operator float component2(androidx.core.util.SizeFCompat);
}

public final class SparseArrayKt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ import kotlinx.coroutines.suspendCancellableCoroutine
/**
* Return the handle to a system-level service by class.
*
* @see ContextCompat.getSystemService
* @see Context.getSystemService
*/
public inline fun <reified T : Any> Context.getSystemService(): T? =
ContextCompat.getSystemService(this, T::class.java)
public inline fun <reified T : Any> Context.getSystemService(): T? = getSystemService(T::class.java)

/**
* Executes [block] on a [TypedArray] receiver. The [TypedArray] holds the attribute values in [set]
Expand Down
2 changes: 2 additions & 0 deletions core/core-ktx/src/main/java/androidx/core/util/Size.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public inline operator fun SizeF.component2(): Float = height
* val (w, h) = mySize
* ```
*/
@Deprecated("Use SizeF.component1()")
public inline operator fun SizeFCompat.component1(): Float = width

/**
Expand All @@ -79,4 +80,5 @@ public inline operator fun SizeFCompat.component1(): Float = width
* val (w, h) = mySize
* ```
*/
@Deprecated("Use SizeF.component2()")
public inline operator fun SizeFCompat.component2(): Float = height
226 changes: 113 additions & 113 deletions core/core/api/current.txt

Large diffs are not rendered by default.

226 changes: 113 additions & 113 deletions core/core/api/restricted_current.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import android.view.View;

import androidx.core.view.ViewCompat;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;

Expand All @@ -46,7 +45,7 @@ public String getDescription() {
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();

ViewCompat.setLayoutDirection(view, layoutDirection);
view.setLayoutDirection(layoutDirection);

uiController.loopMainThreadUntilIdle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.core.widget.TextViewCompat;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;

Expand Down Expand Up @@ -134,7 +133,7 @@ public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();

TextView textView = (TextView) view;
TextViewCompat.setTextAppearance(textView, styleResId);
textView.setTextAppearance(styleResId);

uiController.loopMainThreadUntilIdle();
}
Expand Down Expand Up @@ -163,7 +162,7 @@ public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();

TextView textView = (TextView) view;
TextViewCompat.setCompoundDrawablesRelative(textView, start, top, end, bottom);
textView.setCompoundDrawablesRelative(start, top, end, bottom);

uiController.loopMainThreadUntilIdle();
}
Expand Down Expand Up @@ -192,8 +191,7 @@ public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();

TextView textView = (TextView) view;
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
textView, start, top, end, bottom);
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);

uiController.loopMainThreadUntilIdle();
}
Expand Down Expand Up @@ -222,8 +220,7 @@ public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();

TextView textView = (TextView) view;
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
textView, start, top, end, bottom);
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);

uiController.loopMainThreadUntilIdle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import androidx.core.R;
import androidx.core.app.NotificationCompat.MessagingStyle.Message;
import androidx.core.app.NotificationCompat.Style;
import androidx.core.content.ContextCompat;
import androidx.core.content.LocusIdCompat;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.graphics.drawable.IconCompat;
Expand Down Expand Up @@ -3034,15 +3033,15 @@ public void testCallStyle_callStyleLegacyNotificationScreening() {
// Check that the decline action has the suggested color and title.
assertEquals(mContext.getString(R.string.call_notification_hang_up_action),
notification.actions[0].title.toString());
assertEquals(ContextCompat.getColor(mContext, R.color.call_notification_decline_color),
assertEquals(mContext.getColor(R.color.call_notification_decline_color),
((SpannableStringBuilder) notification.actions[0].title).getSpans(0,
notification.actions[0].title.length(),
ForegroundColorSpan.class)[0].getForegroundColor());

// Check that the answer action has the suggested color and title.
assertEquals(mContext.getString(R.string.call_notification_answer_action),
notification.actions[1].title.toString());
assertEquals(ContextCompat.getColor(mContext, R.color.call_notification_answer_color),
assertEquals(mContext.getColor(R.color.call_notification_answer_color),
((SpannableStringBuilder) notification.actions[1].title).getSpans(0,
notification.actions[1].title.length(),
ForegroundColorSpan.class)[0].getForegroundColor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ public void testMetaDataTargets() {
buildPath(Environment.getExternalStorageDirectory(), "Android", "obb", "foobar"));
assertEquals("content://moocow/test_external/Android/obb/foobar", actual.toString());

File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(mContext, null);
File[] externalFilesDirs = mContext.getExternalFilesDirs(null);
actual = FileProvider.getUriForFile(mContext, TEST_AUTHORITY,
buildPath(externalFilesDirs[0], "foo", "bar"));
assertEquals("content://moocow/test_external_files/foo/bar", actual.toString());

File[] externalCacheDirs = ContextCompat.getExternalCacheDirs(mContext);
File[] externalCacheDirs = mContext.getExternalCacheDirs();
actual = FileProvider.getUriForFile(mContext, TEST_AUTHORITY,
buildPath(externalCacheDirs[0], "foo", "bar"));
assertEquals("content://moocow/test_external_cache/foo/bar", actual.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

import androidx.core.app.Person;
import androidx.core.app.TestActivity;
import androidx.core.content.ContextCompat;
import androidx.core.content.LocusIdCompat;
import androidx.core.graphics.drawable.IconCompat;
import androidx.core.test.R;
Expand Down Expand Up @@ -115,14 +114,14 @@ public void testAddToIntent_badgeActivity() {
assertEquals(mAction, intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT));
assertNull(intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE));

verifyBadgeBitmap(intent, ContextCompat.getColor(mContext, R.color.test_red),
ContextCompat.getColor(mContext, R.color.test_blue));
verifyBadgeBitmap(intent, mContext.getColor(R.color.test_red),
mContext.getColor(R.color.test_blue));
}

@Test
public void testAddToIntent_badgeApplication() {
ApplicationInfo appInfo = spy(mContext.getApplicationInfo());
doReturn(ContextCompat.getDrawable(mContext, R.drawable.test_drawable_green))
doReturn(mContext.getDrawable(R.drawable.test_drawable_green))
.when(appInfo).loadIcon(any(PackageManager.class));
doReturn(appInfo).when(mContext).getApplicationInfo();

Expand All @@ -134,8 +133,8 @@ public void testAddToIntent_badgeApplication() {
assertEquals(mAction, intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT));
assertNull(intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE));

verifyBadgeBitmap(intent, ContextCompat.getColor(mContext, R.color.test_red),
ContextCompat.getColor(mContext, R.color.test_green));
verifyBadgeBitmap(intent, mContext.getColor(R.color.test_red),
mContext.getColor(R.color.test_green));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import android.os.Bundle;
import android.os.Parcel;

import androidx.core.content.ContextCompat;
import androidx.core.test.R;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
Expand Down Expand Up @@ -112,11 +111,11 @@ public void testAddBitmapToShortcutIntent_badged() {
bitmap.eraseColor(Color.RED);
Intent intent = new Intent();

Drawable badge = ContextCompat.getDrawable(context, R.drawable.test_drawable_blue);
Drawable badge = context.getDrawable(R.drawable.test_drawable_blue);
IconCompat.createWithBitmap(bitmap).addToShortcutIntent(intent, badge, mContext);
assertNotSame(bitmap, intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON));

verifyBadgeBitmap(intent, Color.RED, ContextCompat.getColor(context, R.color.test_blue));
verifyBadgeBitmap(intent, Color.RED, context.getColor(R.color.test_blue));
}

@Test
Expand All @@ -131,13 +130,13 @@ public void testAddResourceToShortcutIntent_badged() {
assertNull(intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON));

intent = new Intent();
Drawable badge = ContextCompat.getDrawable(context, R.drawable.test_drawable_red);
Drawable badge = context.getDrawable(R.drawable.test_drawable_red);
IconCompat.createWithResource(context, R.drawable.test_drawable_blue)
.addToShortcutIntent(intent, badge, mContext);

assertNull(intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE));
verifyBadgeBitmap(intent, ContextCompat.getColor(context, R.color.test_blue),
ContextCompat.getColor(context, R.color.test_red));
verifyBadgeBitmap(intent, context.getColor(R.color.test_blue),
context.getColor(R.color.test_red));
}

@Test
Expand Down Expand Up @@ -402,8 +401,7 @@ public void testResourceTypeIcon_oldFormat() {

assertNotNull(actualDrawable);
Bitmap actualBitmap = drawDrawableToBitmap(actualDrawable);
Drawable expectedDrawable =
ContextCompat.getDrawable(mContext, R.drawable.test_drawable_green);
Drawable expectedDrawable = mContext.getDrawable(R.drawable.test_drawable_green);
Bitmap expectedBitmap = drawDrawableToBitmap(expectedDrawable);
assertTrue(actualBitmap.sameAs(expectedBitmap));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void createAsyncWhenAsyncAvailable() throws InterruptedException {
Message message = Message.obtain(handler, new Runnable() {
@Override
public void run() {
isAsync.set(MessageCompat.isAsynchronous(self.get()));
isAsync.set(self.get().isAsynchronous());
latch.countDown();
}
});
Expand Down Expand Up @@ -160,7 +160,7 @@ public void createAsyncWithCallbackWhenAsyncAvailable() throws InterruptedExcept
Handler handler = HandlerCompat.createAsync(mThread.getLooper(), new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
isAsync.set(MessageCompat.isAsynchronous(msg));
isAsync.set(msg.isAsynchronous());
latch.countDown();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public class SoftwareKeyboardControllerCompatActivityTest {
WindowInsetsCompat.CONSUMED
}

scenario.onActivity { ViewCompat.requestApplyInsets(this) }
scenario.onActivity { requestApplyInsets() }

try {
// Perform the action
Expand Down
32 changes: 30 additions & 2 deletions core/core/src/main/java/androidx/core/app/ActivityCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import androidx.annotation.IdRes;
import androidx.annotation.IntRange;
import androidx.annotation.ReplaceWith;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.content.ContextCompat;
Expand Down Expand Up @@ -212,6 +213,7 @@ public static void setPermissionCompatDelegate(
* @deprecated Use {@link Activity#invalidateOptionsMenu()} directly.
*/
@Deprecated
@ReplaceWith(expression = "activity.invalidateOptionsMenu()")
public static boolean invalidateOptionsMenu(Activity activity) {
activity.invalidateOptionsMenu();
return true;
Expand All @@ -236,7 +238,10 @@ public static boolean invalidateOptionsMenu(Activity activity) {
* {@link ActivityOptionsCompat} for how to build the Bundle
* supplied here; there are no supported definitions for
* building it manually.
* @deprecated Call {@link Activity#startActivityForResult(Intent, int, Bundle)} directly.
*/
@Deprecated
@ReplaceWith(expression = "activity.startActivityForResult(intent, requestCode, options)")
public static void startActivityForResult(@NonNull Activity activity, @NonNull Intent intent,
int requestCode, @Nullable Bundle options) {
activity.startActivityForResult(intent, requestCode, options);
Expand Down Expand Up @@ -267,7 +272,11 @@ public static void startActivityForResult(@NonNull Activity activity, @NonNull I
* {@link ActivityOptionsCompat} for how to build the Bundle
* supplied here; there are no supported definitions for
* building it manually.
* @deprecated Call {@link Activity#startIntentSenderForResult(IntentSender, int, Intent, int,
* int, int, Bundle)} directly.
*/
@Deprecated
@ReplaceWith(expression = "activity.startIntentSenderForResult(intent, requestCode, fillInIntent, flagsMask, flagsValues, extraFlags, options)")
public static void startIntentSenderForResult(@NonNull Activity activity,
@NonNull IntentSender intent, int requestCode, @Nullable Intent fillInIntent,
int flagsMask, int flagsValues, int extraFlags, @Nullable Bundle options)
Expand All @@ -282,7 +291,11 @@ public static void startIntentSenderForResult(@NonNull Activity activity,
*
* <p>On Android 4.1+ calling this method will call through to the native version of this
* method. For other platforms {@link Activity#finish()} will be called instead.</p>
*
* @deprecated Call {@link Activity#finishAffinity()} directly.
*/
@Deprecated
@ReplaceWith(expression = "activity.finishAffinity()")
public static void finishAffinity(@NonNull Activity activity) {
activity.finishAffinity();
}
Expand All @@ -293,9 +306,10 @@ public static void finishAffinity(@NonNull Activity activity) {
* {@link Activity#finish()} is called. If no entry Transition was used, finish() is called
* immediately and the Activity exit Transition is run.
*
* <p>On Android 4.4 or lower, this method only finishes the Activity with no
* special exit transition.</p>
* @deprecated Call {@link Activity#finishAfterTransition()} directly.
*/
@Deprecated
@ReplaceWith(expression = "activity.finishAfterTransition()")
public static void finishAfterTransition(@NonNull Activity activity) {
activity.finishAfterTransition();
}
Expand All @@ -315,7 +329,11 @@ public static void finishAfterTransition(@NonNull Activity activity) {
*
* <p>Note that this is <em>not</em> a security feature -- you can not trust the
* referrer information, applications can spoof it.</p>
*
* @deprecated Call {@link Activity#getReferrer()} directly.
*/
@Deprecated
@ReplaceWith(expression = "activity.getReferrer()")
public static @Nullable Uri getReferrer(@NonNull Activity activity) {
return activity.getReferrer();
}
Expand Down Expand Up @@ -385,10 +403,20 @@ public static void setExitSharedElementCallback(@NonNull Activity activity,
activity.setExitSharedElementCallback(frameworkCallback);
}

/**
* @deprecated Call {@link Activity#postponeEnterTransition()} directly.
*/
@Deprecated
@ReplaceWith(expression = "activity.postponeEnterTransition()")
public static void postponeEnterTransition(@NonNull Activity activity) {
activity.postponeEnterTransition();
}

/**
* @deprecated Call {@link Activity#startPostponedEnterTransition()} directly.
*/
@Deprecated
@ReplaceWith(expression = "activity.startPostponedEnterTransition()")
public static void startPostponedEnterTransition(@NonNull Activity activity) {
activity.startPostponedEnterTransition();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ protected ActivityOptionsCompat() {

/**
* Returns the created options as a Bundle, which can be passed to
* {@link androidx.core.content.ContextCompat#startActivity(Context, android.content.Intent, Bundle)}.
* {@link Context#startActivity(android.content.Intent, Bundle)}.
* Note that the returned Bundle is still owned by the ActivityOptions
* object; you must not modify it, but can supply it to the startActivity
* methods that take an options Bundle.
Expand Down
Loading
Loading