Nav bar: fix tablet density change issues

- Re-inflate the contents of the NavigationBarInflaterView
 - Call up to parent to notify the contents has been reinflated
 - Fix how default tunable is handled, so that the resource is
   reloaded on density change

Change-Id: If25f68d01eedd3319b0c270e1cf80ac382eea637
Fixes: 27227522
This commit is contained in:
Jason Monk
2016-05-20 11:21:59 -04:00
parent 761f70d5a6
commit 9a6552d71f
3 changed files with 41 additions and 31 deletions

View File

@@ -27,12 +27,6 @@
<com.android.systemui.statusbar.phone.NavigationBarInflaterView
android:id="@+id/navigation_inflater"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include android:id="@+id/rot0" layout="@layout/navigation_layout" />
<include android:id="@+id/rot90" layout="@layout/navigation_layout_rot90" />
</com.android.systemui.statusbar.phone.NavigationBarInflaterView>
android:layout_height="match_parent" />
</com.android.systemui.statusbar.phone.NavigationBarView>

View File

@@ -24,7 +24,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Space;
import com.android.systemui.R;
@@ -90,6 +89,7 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
if (mDensity != newConfig.densityDpi) {
mDensity = newConfig.densityDpi;
createInflaters();
inflateChildren();
clearViews();
inflateLayout(mCurrentLayout);
}
@@ -98,12 +98,25 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mRot0 = (FrameLayout) findViewById(R.id.rot0);
mRot90 = (FrameLayout) findViewById(R.id.rot90);
inflateChildren();
clearViews();
inflateLayout(getDefaultLayout());
}
private void inflateChildren() {
removeAllViews();
mRot0 = (FrameLayout) mLayoutInflater.inflate(R.layout.navigation_layout, this, false);
mRot0.setId(R.id.rot0);
addView(mRot0);
mRot90 = (FrameLayout) mLayoutInflater.inflate(R.layout.navigation_layout_rot90, this,
false);
mRot90.setId(R.id.rot90);
addView(mRot90);
if (getParent() instanceof NavigationBarView) {
((NavigationBarView) getParent()).updateRotatedViews();
}
}
protected String getDefaultLayout() {
return mContext.getString(R.string.config_navBarLayout);
}
@@ -123,9 +136,6 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
@Override
public void onTuningChanged(String key, String newValue) {
if (NAV_BAR_VIEWS.equals(key)) {
if (newValue == null) {
newValue = getDefaultLayout();
}
if (!Objects.equals(mCurrentLayout, newValue)) {
clearViews();
inflateLayout(newValue);
@@ -162,6 +172,9 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
protected void inflateLayout(String newLayout) {
mCurrentLayout = newLayout;
if (newLayout == null) {
newLayout = getDefaultLayout();
}
String[] sets = newLayout.split(GRAVITY_SEPARATOR, 3);
String[] start = sets[0].split(BUTTON_SEPARATOR);
String[] center = sets[1].split(BUTTON_SEPARATOR);

View File

@@ -492,17 +492,7 @@ public class NavigationBarView extends LinearLayout {
@Override
public void onFinishInflate() {
mRotatedViews[Surface.ROTATION_0] =
mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);
mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);
mRotatedViews[Surface.ROTATION_270] = mRotatedViews[Surface.ROTATION_90];
mCurrentView = mRotatedViews[Surface.ROTATION_0];
for (int i = 0; i < mButtonDisatchers.size(); i++) {
mButtonDisatchers.valueAt(i).setCurrentView(mCurrentView);
}
updateRotatedViews();
((NavigationBarInflaterView) findViewById(R.id.navigation_inflater)).setButtonDispatchers(
mButtonDisatchers);
@@ -544,15 +534,16 @@ public class NavigationBarView extends LinearLayout {
}
}
private void updateRecentsIcon() {
getRecentsButton().setImageDrawable(mDockedStackExists ? mDockedIcon : mRecentIcon);
void updateRotatedViews() {
mRotatedViews[Surface.ROTATION_0] =
mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);
mRotatedViews[Surface.ROTATION_270] =
mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);
updateCurrentView();
}
public boolean isVertical() {
return mVertical;
}
public void reorient() {
private void updateCurrentView() {
final int rot = mDisplay.getRotation();
for (int i=0; i<4; i++) {
mRotatedViews[i].setVisibility(View.GONE);
@@ -563,6 +554,18 @@ public class NavigationBarView extends LinearLayout {
mButtonDisatchers.valueAt(i).setCurrentView(mCurrentView);
}
updateLayoutTransitionsEnabled();
}
private void updateRecentsIcon() {
getRecentsButton().setImageDrawable(mDockedStackExists ? mDockedIcon : mRecentIcon);
}
public boolean isVertical() {
return mVertical;
}
public void reorient() {
updateCurrentView();
getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);