Merge "Fix the header can't be scrolling problem in landscape mode"
This commit is contained in:
committed by
Android (Google) Code Review
commit
a44044dfe6
@@ -46,6 +46,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageItemInfo;
|
import android.content.pm.PackageItemInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@@ -433,7 +434,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
mResetAppsHelper.onRestoreInstanceState(savedInstanceState);
|
mResetAppsHelper.onRestoreInstanceState(savedInstanceState);
|
||||||
|
|
||||||
mAppBarLayout = getActivity().findViewById(R.id.app_bar);
|
mAppBarLayout = getActivity().findViewById(R.id.app_bar);
|
||||||
disableToolBarScrollableBehavior();
|
autoSetCollapsingToolbarLayoutScrolling();
|
||||||
|
|
||||||
return mRootView;
|
return mRootView;
|
||||||
}
|
}
|
||||||
@@ -906,7 +907,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableToolBarScrollableBehavior() {
|
private void autoSetCollapsingToolbarLayoutScrolling() {
|
||||||
final CoordinatorLayout.LayoutParams params =
|
final CoordinatorLayout.LayoutParams params =
|
||||||
(CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
|
(CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
|
||||||
final AppBarLayout.Behavior behavior = new AppBarLayout.Behavior();
|
final AppBarLayout.Behavior behavior = new AppBarLayout.Behavior();
|
||||||
@@ -914,7 +915,8 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
new AppBarLayout.Behavior.DragCallback() {
|
new AppBarLayout.Behavior.DragCallback() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
|
public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
|
||||||
return false;
|
return appBarLayout.getResources().getConfiguration().orientation
|
||||||
|
== Configuration.ORIENTATION_LANDSCAPE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
params.setBehavior(behavior);
|
params.setBehavior(behavior);
|
||||||
|
@@ -22,6 +22,7 @@ import android.app.ActivityManager;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.text.LineBreakConfig;
|
import android.graphics.text.LineBreakConfig;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -117,7 +118,7 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
|||||||
LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE)
|
LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE)
|
||||||
.build()));
|
.build()));
|
||||||
}
|
}
|
||||||
disableCollapsingToolbarLayoutScrollingBehavior();
|
autoSetCollapsingToolbarLayoutScrolling();
|
||||||
} else {
|
} else {
|
||||||
super.setContentView(R.layout.settings_base_layout);
|
super.setContentView(R.layout.settings_base_layout);
|
||||||
}
|
}
|
||||||
@@ -252,7 +253,7 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableCollapsingToolbarLayoutScrollingBehavior() {
|
private void autoSetCollapsingToolbarLayoutScrolling() {
|
||||||
if (mAppBarLayout == null) {
|
if (mAppBarLayout == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -263,7 +264,9 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
|||||||
new AppBarLayout.Behavior.DragCallback() {
|
new AppBarLayout.Behavior.DragCallback() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
|
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);
|
params.setBehavior(behavior);
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.datetime.timezone;
|
package com.android.settings.datetime.timezone;
|
||||||
|
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -97,7 +98,7 @@ public abstract class BaseTimeZonePicker extends InstrumentedFragment
|
|||||||
LinearLayoutManager.VERTICAL, /* reverseLayout */ false));
|
LinearLayoutManager.VERTICAL, /* reverseLayout */ false));
|
||||||
mRecyclerView.setAdapter(mAdapter);
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
mAppBarLayout = getActivity().findViewById(R.id.app_bar);
|
mAppBarLayout = getActivity().findViewById(R.id.app_bar);
|
||||||
disableToolBarScrollableBehavior();
|
autoSetCollapsingToolbarLayoutScrolling();
|
||||||
|
|
||||||
// Initialize TimeZoneDataLoader only when mRecyclerView is ready to avoid race
|
// Initialize TimeZoneDataLoader only when mRecyclerView is ready to avoid race
|
||||||
// during onDateLoaderReady callback.
|
// during onDateLoaderReady callback.
|
||||||
@@ -193,7 +194,7 @@ public abstract class BaseTimeZonePicker extends InstrumentedFragment
|
|||||||
void onListItemClick(T item);
|
void onListItemClick(T item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableToolBarScrollableBehavior() {
|
private void autoSetCollapsingToolbarLayoutScrolling() {
|
||||||
CoordinatorLayout.LayoutParams params =
|
CoordinatorLayout.LayoutParams params =
|
||||||
(CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
|
(CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
|
||||||
AppBarLayout.Behavior behavior = new AppBarLayout.Behavior();
|
AppBarLayout.Behavior behavior = new AppBarLayout.Behavior();
|
||||||
@@ -201,7 +202,8 @@ public abstract class BaseTimeZonePicker extends InstrumentedFragment
|
|||||||
new AppBarLayout.Behavior.DragCallback() {
|
new AppBarLayout.Behavior.DragCallback() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
|
public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
|
||||||
return false;
|
return appBarLayout.getResources().getConfiguration().orientation
|
||||||
|
== Configuration.ORIENTATION_LANDSCAPE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
params.setBehavior(behavior);
|
params.setBehavior(behavior);
|
||||||
|
Reference in New Issue
Block a user