diff options
author | d34d <clark@cyngn.com> | 2015-03-19 09:35:18 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyngn.com> | 2015-03-20 16:06:19 +0000 |
commit | 2b022420a62eb3fb39a6c1783a3dd65ab701eed0 (patch) | |
tree | ab6a38ad7f739ea0290ab77680c56884f853b9fe /src | |
parent | a503d05a5e142b94676724b527fb1b9cce8a2980 (diff) | |
download | packages_apps_ThemeChooser-2b022420a62eb3fb39a6c1783a3dd65ab701eed0.tar.gz packages_apps_ThemeChooser-2b022420a62eb3fb39a6c1783a3dd65ab701eed0.tar.bz2 packages_apps_ThemeChooser-2b022420a62eb3fb39a6c1783a3dd65ab701eed0.zip |
Properly pad layouts when on screen nav is used
This patch checks if the device has no hardware keys or if the user
has enabled on screen navigation even though the device has hardware
keys.
Change-Id: Ie93280a275735567390e2cdc34a82d4de63a8450
Diffstat (limited to 'src')
-rw-r--r-- | src/com/cyngn/theme/util/Utils.java | 18 | ||||
-rw-r--r-- | src/com/cyngn/theme/widget/NavBarSpace.java | 11 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/com/cyngn/theme/util/Utils.java b/src/com/cyngn/theme/util/Utils.java index cbcbe4a..3fe8c63 100644 --- a/src/com/cyngn/theme/util/Utils.java +++ b/src/com/cyngn/theme/util/Utils.java @@ -21,12 +21,15 @@ import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; import android.graphics.Point; import android.graphics.Rect; +import android.os.RemoteException; +import android.provider.Settings; import android.provider.ThemesContract; import android.util.Log; import android.util.TypedValue; -import android.view.ViewConfiguration; +import android.view.IWindowManager; import android.view.WindowManager; +import android.view.WindowManagerGlobal; import com.cyngn.theme.chooser.ChooserActivity; import java.io.File; @@ -244,7 +247,18 @@ public class Utils { } public static boolean hasNavigationBar(Context context) { - return !ViewConfiguration.get(context).hasPermanentMenuKey(); + boolean needsNavigationBar = false; + try { + IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); + needsNavigationBar = wm.needsNavigationBar(); + } catch (RemoteException e) { + } + // Need to also check for devices with hardware keys where the user has chosen to use + // the on screen navigation bar + needsNavigationBar = needsNavigationBar || + Settings.Secure.getInt(context.getContentResolver(), + Settings.Secure.DEV_FORCE_SHOW_NAVBAR, 0) == 1; + return needsNavigationBar; } public static Bitmap loadBitmapBlob(Cursor cursor, int columnIdx) { diff --git a/src/com/cyngn/theme/widget/NavBarSpace.java b/src/com/cyngn/theme/widget/NavBarSpace.java index 71dce4d..993e9cf 100644 --- a/src/com/cyngn/theme/widget/NavBarSpace.java +++ b/src/com/cyngn/theme/widget/NavBarSpace.java @@ -28,11 +28,12 @@ public class NavBarSpace extends View { } @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - if (!Utils.hasNavigationBar(mContext)) { - int width = MeasureSpec.getSize(widthMeasureSpec); - setMeasuredDimension(width, 0); + protected void onFinishInflate() { + super.onFinishInflate(); + if (!Utils.hasNavigationBar(getContext())) { + this.setVisibility(View.GONE); + } else { + this.setVisibility(View.VISIBLE); } } } |