Merge "Refactor some transition codes." into sc-dev am: 8c1c7b63a7
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14660513 Change-Id: I254f5266556d0fa498f37a99c5ab6dbf56fa806c
This commit is contained in:
@@ -233,18 +233,6 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SILKY_HOME)) {
|
|
||||||
// Enable Activity transitions
|
|
||||||
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
|
|
||||||
final MaterialSharedAxis enterTransition = new MaterialSharedAxis(
|
|
||||||
MaterialSharedAxis.X, /* forward */true);
|
|
||||||
getWindow().setEnterTransition(enterTransition);
|
|
||||||
|
|
||||||
final MaterialSharedAxis returnTransition = new MaterialSharedAxis(
|
|
||||||
MaterialSharedAxis.X, /* forward */false);
|
|
||||||
getWindow().setReturnTransition(returnTransition);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
Log.d(LOG_TAG, "Starting onCreate");
|
Log.d(LOG_TAG, "Starting onCreate");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
@@ -77,6 +77,7 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
|
|
||||||
protected CollapsingToolbarLayout mCollapsingToolbarLayout;
|
protected CollapsingToolbarLayout mCollapsingToolbarLayout;
|
||||||
private int mCategoriesUpdateTaskCount;
|
private int mCategoriesUpdateTaskCount;
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@@ -129,21 +130,39 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setActionBar(@androidx.annotation.Nullable Toolbar toolbar) {
|
||||||
|
super.setActionBar(toolbar);
|
||||||
|
|
||||||
|
mToolbar = toolbar;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigateUp() {
|
public boolean onNavigateUp() {
|
||||||
if (!super.onNavigateUp()) {
|
if (!super.onNavigateUp()) {
|
||||||
finish();
|
finishAfterTransition();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
final int id = item.getItemId();
|
||||||
|
if (id == android.R.id.home) {
|
||||||
|
// Make the up button behave the same as the back button.
|
||||||
|
finishAfterTransition();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startActivity(Intent intent) {
|
public void startActivity(Intent intent) {
|
||||||
if (!Utils.isPageTransitionEnabled(this)) {
|
if (!Utils.isPageTransitionEnabled(this)) {
|
||||||
super.startActivity(intent);
|
super.startActivity(intent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.startActivity(intent, getActivityOptionsBundle());
|
super.startActivity(intent, createActivityOptionsBundleForTransition(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -152,11 +171,7 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
super.startActivity(intent, options);
|
super.startActivity(intent, options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (options != null) {
|
super.startActivity(intent, createActivityOptionsBundleForTransition(options));
|
||||||
super.startActivity(intent, getMergedBundleForTransition(options));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.startActivity(intent, getActivityOptionsBundle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -167,7 +182,8 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
super.startActivityForResult(intent, requestCode);
|
super.startActivityForResult(intent, requestCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.startActivityForResult(intent, requestCode, getActivityOptionsBundle());
|
super.startActivityForResult(intent, requestCode,
|
||||||
|
createActivityOptionsBundleForTransition(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -177,12 +193,8 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
super.startActivityForResult(intent, requestCode, options);
|
super.startActivityForResult(intent, requestCode, options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (options != null) {
|
super.startActivityForResult(intent, requestCode,
|
||||||
super.startActivityForResult(intent, requestCode,
|
createActivityOptionsBundleForTransition(options));
|
||||||
getMergedBundleForTransition(options));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.startActivityForResult(intent, requestCode, getActivityOptionsBundle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -192,7 +204,8 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
super.startActivityForResultAsUser(intent, requestCode, userHandle);
|
super.startActivityForResultAsUser(intent, requestCode, userHandle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.startActivityForResultAsUser(intent, requestCode, getActivityOptionsBundle(),
|
super.startActivityForResultAsUser(intent, requestCode,
|
||||||
|
createActivityOptionsBundleForTransition(null),
|
||||||
userHandle);
|
userHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,17 +255,6 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
((ViewGroup) findViewById(R.id.content_frame)).addView(view, params);
|
((ViewGroup) findViewById(R.id.content_frame)).addView(view, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
|
||||||
final int id = item.getItemId();
|
|
||||||
if (id == android.R.id.home) {
|
|
||||||
// Make the up button behave the same as the back button.
|
|
||||||
onBackPressed();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(CharSequence title) {
|
public void setTitle(CharSequence title) {
|
||||||
if (mCollapsingToolbarLayout != null) {
|
if (mCollapsingToolbarLayout != null) {
|
||||||
@@ -341,20 +343,21 @@ public class SettingsBaseActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bundle getActivityOptionsBundle() {
|
@androidx.annotation.Nullable
|
||||||
final Toolbar toolbar = findViewById(R.id.action_bar);
|
private Bundle createActivityOptionsBundleForTransition(
|
||||||
return ActivityOptions.makeSceneTransitionAnimation(this, toolbar,
|
@androidx.annotation.Nullable Bundle options) {
|
||||||
"shared_element_view").toBundle();
|
if (mToolbar == null) {
|
||||||
}
|
Log.w(TAG, "setActionBar(Toolbar) is not called. Cannot apply settings transition!");
|
||||||
|
return options;
|
||||||
private Bundle getMergedBundleForTransition(@NonNull Bundle options) {
|
|
||||||
final Bundle mergedBundle = new Bundle();
|
|
||||||
mergedBundle.putAll(options);
|
|
||||||
final Bundle activityOptionsBundle = getActivityOptionsBundle();
|
|
||||||
if (activityOptionsBundle != null) {
|
|
||||||
mergedBundle.putAll(activityOptionsBundle);
|
|
||||||
}
|
}
|
||||||
return mergedBundle;
|
final Bundle transitionOptions = ActivityOptions.makeSceneTransitionAnimation(this,
|
||||||
|
mToolbar, "shared_element_view").toBundle();
|
||||||
|
if (options == null) {
|
||||||
|
return transitionOptions;
|
||||||
|
}
|
||||||
|
final Bundle mergedOptions = new Bundle(options);
|
||||||
|
mergedOptions.putAll(transitionOptions);
|
||||||
|
return mergedOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CategoryListener {
|
public interface CategoryListener {
|
||||||
|
Reference in New Issue
Block a user