diff options
-rw-r--r-- | res/layout/component_selector.xml | 5 | ||||
-rw-r--r-- | res/layout/fragment_pager_list.xml | 6 | ||||
-rw-r--r-- | res/layout/save_apply_button.xml | 4 | ||||
-rw-r--r-- | res/layout/shop_themes.xml | 4 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/ChooserActivity.java | 4 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/ComponentSelector.java | 4 | ||||
-rw-r--r-- | src/com/cyngn/theme/widget/NavBarSpace.java | 38 |
7 files changed, 45 insertions, 20 deletions
diff --git a/res/layout/component_selector.xml b/res/layout/component_selector.xml index 0ef1e42..ef54a89 100644 --- a/res/layout/component_selector.xml +++ b/res/layout/component_selector.xml @@ -35,10 +35,7 @@ themes:fillColor="@android:color/white"/> </FrameLayout> - - <!-- This view will be set to gone if the device does not have a navigation bar --> - <Space - android:id="@+id/navbar_padding" + <com.cyngn.theme.widget.NavBarSpace android:layout_width="match_parent" android:layout_height="@*android:dimen/system_bar_height"/> </com.cyngn.theme.chooser.ComponentSelector>
\ No newline at end of file diff --git a/res/layout/fragment_pager_list.xml b/res/layout/fragment_pager_list.xml index 6886391..b0c212b 100644 --- a/res/layout/fragment_pager_list.xml +++ b/res/layout/fragment_pager_list.xml @@ -162,9 +162,9 @@ <Space android:layout_width="match_parent" android:layout_height="@dimen/expanded_card_margin_top" /> - <Space android:id="@+id/nav_bar_spacer" - android:layout_width="match_parent" - android:layout_height="@*android:dimen/system_bar_height" /> + <com.cyngn.theme.widget.NavBarSpace + android:layout_width="match_parent" + android:layout_height="@*android:dimen/system_bar_height" /> </LinearLayout> </LinearLayout> </com.cyngn.theme.widget.LockableScrollView> diff --git a/res/layout/save_apply_button.xml b/res/layout/save_apply_button.xml index 70d3b18..14ef286 100644 --- a/res/layout/save_apply_button.xml +++ b/res/layout/save_apply_button.xml @@ -29,8 +29,8 @@ android:background="@drawable/save_apply_button_selector"/> </LinearLayout> - <Space - android:id="@+id/navbar_padding" + + <com.cyngn.theme.widget.NavBarSpace android:layout_width="match_parent" android:layout_height="@*android:dimen/system_bar_height"/> diff --git a/res/layout/shop_themes.xml b/res/layout/shop_themes.xml index 90ffec1..727741f 100644 --- a/res/layout/shop_themes.xml +++ b/res/layout/shop_themes.xml @@ -26,9 +26,7 @@ android:focusable="true" android:background="@drawable/shop_themes_bg"/> - <!-- This view will be set to gone if the device does not have a navigation bar --> - <Space - android:id="@+id/navbar_padding" + <com.cyngn.theme.widget.NavBarSpace android:layout_width="match_parent" android:layout_height="@*android:dimen/system_bar_height"/> </LinearLayout>
\ No newline at end of file diff --git a/src/com/cyngn/theme/chooser/ChooserActivity.java b/src/com/cyngn/theme/chooser/ChooserActivity.java index 70f3e2a..b79be93 100644 --- a/src/com/cyngn/theme/chooser/ChooserActivity.java +++ b/src/com/cyngn/theme/chooser/ChooserActivity.java @@ -157,10 +157,6 @@ public class ChooserActivity extends FragmentActivity mShopThemesLayout = findViewById(R.id.shop_themes_layout); mSaveApplyLayout = findViewById(R.id.save_apply_layout); - if (!Utils.hasNavigationBar(this)) { - mSaveApplyLayout.findViewById(R.id.navbar_padding).setVisibility(View.GONE); - mShopThemesLayout.findViewById(R.id.navbar_padding).setVisibility(View.GONE); - } mSaveApplyLayout.findViewById(R.id.save_apply_button).setOnClickListener( new View.OnClickListener() { @Override diff --git a/src/com/cyngn/theme/chooser/ComponentSelector.java b/src/com/cyngn/theme/chooser/ComponentSelector.java index 10c6590..4bf0ec4 100644 --- a/src/com/cyngn/theme/chooser/ComponentSelector.java +++ b/src/com/cyngn/theme/chooser/ComponentSelector.java @@ -164,10 +164,6 @@ public class ComponentSelector extends LinearLayout PageIndicator indicator = (PageIndicator) findViewById(R.id.page_indicator); indicator.setViewPager(mPager); - // set navbar_padding to GONE if no on screen navigation bar is available - if (!Utils.hasNavigationBar(mContext)) { - findViewById(R.id.navbar_padding).setVisibility(View.GONE); - } setEnabled(false); } diff --git a/src/com/cyngn/theme/widget/NavBarSpace.java b/src/com/cyngn/theme/widget/NavBarSpace.java new file mode 100644 index 0000000..afe71a6 --- /dev/null +++ b/src/com/cyngn/theme/widget/NavBarSpace.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 The CyanogenMod, Inc. + */ +package com.cyngn.theme.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import com.cyngn.theme.util.Utils; + +/** + * A simple view used to pad layouts so that content floats above the + * navigation bar. This is best used with transparent or translucent + * navigation bars where the content can go behind them. + */ +public class NavBarSpace extends View { + + public NavBarSpace(Context context) { + this(context, null); + } + + public NavBarSpace(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public NavBarSpace(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + if (!Utils.hasNavigationBar(mContext)) { + int width = MeasureSpec.getSize(widthMeasureSpec); + setMeasuredDimension(width, 0); + } + } +} |