Skip to content

Commit

Permalink
[Build] Update to compileSdkVersion 34 and update catalog to use andr…
Browse files Browse the repository at this point in the history
…oidx.activity:activity:1.8.0-alpha05

PiperOrigin-RevId: 539031943
  • Loading branch information
Material Design Team authored and hunterstich committed Jun 9, 2023
1 parent 7a3f30b commit 2336c23
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ allprojects {
}

ext {
compileSdkVersion = 'android-UpsideDownCake'
compileSdkVersion = 34
minSdkVersion = 14
targetSdkVersion = 33

Expand Down
2 changes: 1 addition & 1 deletion catalog/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
api 'androidx.constraintlayout:constraintlayout:2.1.0'
api 'androidx.gridlayout:gridlayout:1.0.0'
api "androidx.multidex:multidex:2.0.1"
api "androidx.activity:activity:1.8.0-alpha02"
api "androidx.activity:activity:1.8.0-alpha05"
api "androidx.recyclerview:recyclerview:1.2.1"
api 'androidx.window:window:1.0.0-beta04'
api "androidx.window:window-java:1.0.0-beta04"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.material.catalog.R;

import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -29,12 +30,11 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.window.BackEvent;
import androidx.activity.BackEventCompat;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.bottomappbar.BottomAppBarTopEdgeTreatment;
Expand All @@ -59,27 +59,30 @@ public class BottomAppBarMainDemoFragment extends DemoFragment {

private final OnBackPressedCallback bottomDrawerOnBackPressedCallback =
new OnBackPressedCallback(/* enabled= */ false) {
@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackStarted(@NonNull BackEvent backEvent) {
bottomDrawerBehavior.startBackProgress(backEvent);
public void handleOnBackStarted(@NonNull BackEventCompat backEvent) {
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
bottomDrawerBehavior.startBackProgress(backEvent.toBackEvent());
}
}

@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackProgressed(@NonNull BackEvent backEvent) {
bottomDrawerBehavior.updateBackProgress(backEvent);
public void handleOnBackProgressed(@NonNull BackEventCompat backEvent) {
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
bottomDrawerBehavior.updateBackProgress(backEvent.toBackEvent());
}
}

@Override
public void handleOnBackPressed() {
bottomDrawerBehavior.handleBackInvoked();
}

@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackCancelled() {
bottomDrawerBehavior.cancelBackProgress();
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
bottomDrawerBehavior.cancelBackProgress();
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.material.catalog.R;

import android.app.Activity;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.util.DisplayMetrics;
Expand All @@ -29,12 +30,11 @@
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.window.BackEvent;
import androidx.activity.BackEventCompat;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
Expand All @@ -50,27 +50,30 @@ public class BottomSheetMainDemoFragment extends DemoFragment {
private final OnBackPressedCallback persistentBottomSheetBackCallback =
new OnBackPressedCallback(/* enabled= */ false) {

@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackStarted(@NonNull BackEvent backEvent) {
persistentBottomSheetBehavior.startBackProgress(backEvent);
public void handleOnBackStarted(@NonNull BackEventCompat backEvent) {
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
persistentBottomSheetBehavior.startBackProgress(backEvent.toBackEvent());
}
}

@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackProgressed(@NonNull BackEvent backEvent) {
persistentBottomSheetBehavior.updateBackProgress(backEvent);
public void handleOnBackProgressed(@NonNull BackEventCompat backEvent) {
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
persistentBottomSheetBehavior.updateBackProgress(backEvent.toBackEvent());
}
}

@Override
public void handleOnBackPressed() {
persistentBottomSheetBehavior.handleBackInvoked();
}

@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackCancelled() {
persistentBottomSheetBehavior.cancelBackProgress();
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
persistentBottomSheetBehavior.cancelBackProgress();
}
}
};

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

import static android.view.View.NO_ID;

import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -31,14 +32,13 @@
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.window.BackEvent;
import androidx.activity.BackEventCompat;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.GravityInt;
import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.coordinatorlayout.widget.CoordinatorLayout.LayoutParams;
Expand Down Expand Up @@ -405,27 +405,30 @@ public void onSlide(@NonNull View sheet, float slideOffset) {
private OnBackPressedCallback createNonModalOnBackPressedCallback(
SideSheetBehavior<View> behavior) {
return new OnBackPressedCallback(/* enabled= */ false) {
@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackStarted(@NonNull BackEvent backEvent) {
behavior.startBackProgress(backEvent);
public void handleOnBackStarted(@NonNull BackEventCompat backEvent) {
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
behavior.startBackProgress(backEvent.toBackEvent());
}
}

@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackProgressed(@NonNull BackEvent backEvent) {
behavior.updateBackProgress(backEvent);
public void handleOnBackProgressed(@NonNull BackEventCompat backEvent) {
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
behavior.updateBackProgress(backEvent.toBackEvent());
}
}

@Override
public void handleOnBackPressed() {
behavior.handleBackInvoked();
}

@RequiresApi(VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void handleOnBackCancelled() {
behavior.cancelBackProgress();
if (VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
behavior.cancelBackProgress();
}
}
};
}
Expand Down

0 comments on commit 2336c23

Please sign in to comment.