Fix the header can't be scrolling problem in landscape mode

- Settings header is restricted scrolling by this ag/15029686
- To void some pages can't show the contain part while heading unscrolling.
  We allow the header can be scrolling in the landscape mode.

Fixes: 207353353
Test: make RunSettingsRoboTests -j
Change-Id: Ice97c6244716d4768167feb78588807d13b06a94
This commit is contained in:
Sunny Shao
2022-08-11 15:33:45 +08:00
parent 248895db72
commit 151a088094
3 changed files with 16 additions and 9 deletions

View File

@@ -22,6 +22,7 @@ import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.text.LineBreakConfig;
import android.os.Bundle;
@@ -117,7 +118,7 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE)
.build()));
}
disableCollapsingToolbarLayoutScrollingBehavior();
autoSetCollapsingToolbarLayoutScrolling();
} else {
super.setContentView(R.layout.settings_base_layout);
}
@@ -252,7 +253,7 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
return false;
}
private void disableCollapsingToolbarLayoutScrollingBehavior() {
private void autoSetCollapsingToolbarLayoutScrolling() {
if (mAppBarLayout == null) {
return;
}
@@ -263,7 +264,9 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
new AppBarLayout.Behavior.DragCallback() {
@Override
public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
return false;
// Header can be scrolling while device in landscape mode.
return appBarLayout.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE;
}
});
params.setBehavior(behavior);