Leave some space for nav bar in KK and above
This commit is contained in:
1 parent
4fccbefdd2
commit
e1b463314d
14 files changed
+166
-81
No files matched your search
@@ -53,6 +53,10 @@ public class ContentActivity extends StageActivity {
|
||||
return mContentLayout.getFitPaddingBottom();
|
||||
}
|
||||
|
||||
public void setOnGetFitPaddingListener(ContentLayout.OnGetFitPaddingListener listener) {
|
||||
mContentLayout.setOnGetFitPaddingListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StageLayout getStageLayout() {
|
||||
return mContentLayout;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
@@ -31,25 +32,23 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.data.UnsupportedSearch;
|
||||
import com.hippo.ehviewer.ui.ContentActivity;
|
||||
import com.hippo.ehviewer.widget.ContentLayout;
|
||||
import com.hippo.ehviewer.widget.SearchLayout;
|
||||
import com.hippo.scene.Scene;
|
||||
import com.hippo.scene.StageActivity;
|
||||
import com.hippo.util.Log;
|
||||
import com.hippo.widget.Appbar;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GalleryListScene extends Scene implements SearchLayout.SearhLayoutHelper,
|
||||
Scene.ActivityResultListener {
|
||||
Scene.ActivityResultListener, ContentLayout.OnGetFitPaddingListener {
|
||||
|
||||
private final static int PAGE_INDEX_SEARCH = 0;
|
||||
private final static int PAGE_INDEX_LIST = 1;
|
||||
private final static int PAGE_NUMBER = 2;
|
||||
|
||||
private StageActivity mActivity;
|
||||
private ContentActivity mActivity;
|
||||
private Resources mResources;
|
||||
|
||||
private View mSearchView;
|
||||
@@ -64,10 +63,11 @@ public class GalleryListScene extends Scene implements SearchLayout.SearhLayoutH
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
mActivity = getStageActivity();
|
||||
mActivity = (ContentActivity) getStageActivity();
|
||||
mResources = mActivity.getResources();
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View onCreateSceneView(Bundle savedInstanceState) {
|
||||
LayoutInflater inflater = mActivity.getLayoutInflater();
|
||||
@@ -93,9 +93,20 @@ public class GalleryListScene extends Scene implements SearchLayout.SearhLayoutH
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
mViewPager.setCurrentItem(PAGE_INDEX_LIST);
|
||||
|
||||
// Fit Padding Bottom
|
||||
mActivity.setOnGetFitPaddingListener(this);
|
||||
int fitPaddingBottom = mActivity.getFitPaddingBottom();
|
||||
if (fitPaddingBottom != -1) {
|
||||
setFitPaddingBottom(fitPaddingBottom);
|
||||
}
|
||||
|
||||
return sceneView;
|
||||
}
|
||||
|
||||
private void setFitPaddingBottom(int fitPaddingBottom) {
|
||||
mSearchLayout.setFitPaddingBottom(fitPaddingBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(@NotNull SparseArray<Parcelable> savedStates) {
|
||||
super.onRestoreInstanceState(savedStates);
|
||||
@@ -107,11 +118,7 @@ public class GalleryListScene extends Scene implements SearchLayout.SearhLayoutH
|
||||
|
||||
@Override
|
||||
public void onRequestSearch(ListUrlBuilder lub) {
|
||||
try {
|
||||
Log.d(lub.build(EhClient.SOURCE_EX));
|
||||
} catch (UnsupportedSearch unsupportedSearch) {
|
||||
unsupportedSearch.printStackTrace();
|
||||
}
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,6 +147,11 @@ public class GalleryListScene extends Scene implements SearchLayout.SearhLayoutH
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetFitPadding(int l, int t, int r, int b) {
|
||||
setFitPaddingBottom(b);
|
||||
}
|
||||
|
||||
private class SimplePagerAdapter extends PagerAdapter {
|
||||
@Override
|
||||
public int getCount() {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ContentLayout extends StageLayout {
|
||||
|
||||
private OnGetPaddingListener mOnGetPaddingListener;
|
||||
private OnGetFitPaddingListener mOnGetFitPaddingListener;
|
||||
|
||||
private int mFitPaddingLeft = -1;
|
||||
private int mFitPaddingTop = -1;
|
||||
@@ -55,8 +55,8 @@ public class ContentLayout extends StageLayout {
|
||||
mFitPaddingTop = 0;
|
||||
mFitPaddingRight = 0;
|
||||
mFitPaddingBottom = insets.bottom;
|
||||
if (mOnGetPaddingListener != null) {
|
||||
mOnGetPaddingListener.onGetPadding(mFitPaddingLeft, mFitPaddingTop,
|
||||
if (mOnGetFitPaddingListener != null) {
|
||||
mOnGetFitPaddingListener.onGetFitPadding(mFitPaddingLeft, mFitPaddingTop,
|
||||
mFitPaddingRight, mFitPaddingBottom);
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public class ContentLayout extends StageLayout {
|
||||
return super.fitSystemWindows(insets);
|
||||
}
|
||||
|
||||
public void setOnGetPaddingListener(OnGetPaddingListener listener) {
|
||||
mOnGetPaddingListener = listener;
|
||||
public void setOnGetFitPaddingListener(OnGetFitPaddingListener listener) {
|
||||
mOnGetFitPaddingListener = listener;
|
||||
}
|
||||
|
||||
public int getFitPaddingLeft() {
|
||||
@@ -85,7 +85,7 @@ public class ContentLayout extends StageLayout {
|
||||
return mFitPaddingBottom;
|
||||
}
|
||||
|
||||
public interface OnGetPaddingListener {
|
||||
public void onGetPadding(int l, int t, int r, int b);
|
||||
public interface OnGetFitPaddingListener {
|
||||
public void onGetFitPadding(int l, int t, int r, int b);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import android.widget.TextView;
|
||||
import com.hippo.effect.ripple.RippleSalon;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.data.ListUrlBuilder;
|
||||
import com.hippo.util.UiUtils;
|
||||
import com.hippo.util.ViewUtils;
|
||||
import com.hippo.widget.FloatLabelEditText;
|
||||
import com.hippo.widget.FloatingActionButton;
|
||||
@@ -111,6 +112,9 @@ public class SearchLayout extends FrameLayout implements CompoundButton.OnChecke
|
||||
|
||||
private Bitmap mSearchImage;
|
||||
|
||||
private int mFabMarginBottomOrigin;
|
||||
private int mSearchPaddingBottomOrigin;
|
||||
|
||||
public SearchLayout(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
@@ -144,15 +148,22 @@ public class SearchLayout extends FrameLayout implements CompoundButton.OnChecke
|
||||
mSearchContainer.setItemAnimator(mAnimator);
|
||||
|
||||
mFab.setOnClickListener(this);
|
||||
mFabMarginBottomOrigin = mResources.getDimensionPixelSize(R.dimen.content_fab_margin_bottom);
|
||||
mSearchPaddingBottomOrigin = mResources.getDimensionPixelSize(R.dimen.content_padding_bottom);
|
||||
}
|
||||
|
||||
public void setFitPaddingBottom(int paddingBottom) {
|
||||
mSearchContainer.setClipToPadding(false);
|
||||
mSearchContainer.setPadding(
|
||||
mSearchContainer.getPaddingLeft(),
|
||||
mSearchContainer.getPaddingTop(),
|
||||
mSearchContainer.getPaddingRight(),
|
||||
paddingBottom);
|
||||
mSearchPaddingBottomOrigin + paddingBottom);
|
||||
|
||||
if (!UiUtils.isTable(mContext)) {
|
||||
LayoutParams lp = (LayoutParams) mFab.getLayoutParams();
|
||||
lp.bottomMargin = mFabMarginBottomOrigin + paddingBottom;
|
||||
mFab.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHelper(SearhLayoutHelper helper) {
|
||||
|
||||
@@ -19,6 +19,8 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
public class UiUtils {
|
||||
|
||||
private static float sDensity;
|
||||
@@ -87,4 +89,15 @@ public class UiUtils {
|
||||
hsv[2] *= 0.9f;
|
||||
return Color.HSVToColor(hsv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this device is table.
|
||||
* For sw600dp is true
|
||||
*
|
||||
* @param context the context
|
||||
* @return true for table
|
||||
*/
|
||||
public static boolean isTable(Context context) {
|
||||
return context.getResources().getBoolean(R.bool.is_table);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<com.hippo.widget.recyclerview.EasyRecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="@dimen/appbar_size"
|
||||
android:paddingLeft="@dimen/content_padding_start"
|
||||
android:paddingRight="@dimen/content_padding_end"
|
||||
android:clipToPadding="false"/>
|
||||
|
||||
<com.hippo.widget.FloatingActionButton
|
||||
xmlns:auto="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginTop="@dimen/appbar_fab_margin_top"
|
||||
android:layout_marginRight="@dimen/content_fab_margin_end"
|
||||
auto:fabColor="?attr/colorAccent"
|
||||
auto:fabDrawable="@drawable/ic_fab_search"/>
|
||||
|
||||
</merge>
|
||||
@@ -20,16 +20,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/content_padding_start"
|
||||
android:paddingRight="@dimen/content_padding_end"/>
|
||||
android:paddingRight="@dimen/content_padding_end"
|
||||
android:paddingTop="@dimen/content_padding_top"
|
||||
android:paddingBottom="@dimen/content_padding_bottom"
|
||||
android:clipToPadding="false"/>
|
||||
|
||||
<com.hippo.widget.FloatingActionButton
|
||||
xmlns:auto="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/FloatingActionButton"
|
||||
style="@style/FloatingActionButton.Content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right|bottom"
|
||||
android:layout_marginRight="@dimen/keyline_margin"
|
||||
android:layout_marginBottom="@dimen/keyline_margin"
|
||||
auto:fabColor="?attr/colorAccent"
|
||||
auto:fabDrawable="@drawable/ic_fab_search"/>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (C) 2015 Hippo Seven
|
||||
~
|
||||
@@ -15,15 +16,6 @@
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<!-- FloatingActionButton -->
|
||||
<style name="FloatingActionButton">
|
||||
<item name="android:minWidth">56dp</item>
|
||||
<item name="android:minHeight">56dp</item>
|
||||
</style>
|
||||
|
||||
<style name="FloatingActionButton.Small">
|
||||
<item name="android:minWidth">40dp</item>
|
||||
<item name="android:minHeight">40dp</item>
|
||||
</style>
|
||||
<bool name="is_table">true</bool>
|
||||
|
||||
</resources>
|
||||
@@ -18,7 +18,12 @@
|
||||
<!-- Content -->
|
||||
<dimen name="content_padding_start">52dp</dimen>
|
||||
<dimen name="content_padding_end">52dp</dimen>
|
||||
<dimen name="content_fab_margin_end">24dp</dimen>
|
||||
<dimen name="content_padding_top">@dimen/appbar_size</dimen>
|
||||
<dimen name="content_padding_bottom">0dp</dimen>
|
||||
<dimen name="content_fab_margin_start">0dp</dimen>
|
||||
<dimen name="content_fab_margin_end">@dimen/keyline_margin</dimen>
|
||||
<dimen name="content_fab_margin_top">196dp</dimen>
|
||||
<dimen name="content_fab_margin_bottom">0dp</dimen>
|
||||
|
||||
<!-- Search category -->
|
||||
<dimen name="search_category_padding_start">52dp</dimen>
|
||||
@@ -40,7 +45,6 @@
|
||||
|
||||
<!-- AppBar -->
|
||||
<dimen name="appbar_height">224dp</dimen>
|
||||
<dimen name="appbar_fab_margin_top">196dp</dimen>
|
||||
|
||||
<!-- CategoryTable -->
|
||||
<dimen name="category_table_item_height">48dp</dimen>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<!-- FloatingActionButton -->
|
||||
<style name="FloatingActionButton.Content">
|
||||
<item name="android:layout_gravity">right</item>
|
||||
<item name="android:layout_marginLeft">@dimen/content_fab_margin_start</item>
|
||||
<item name="android:layout_marginRight">@dimen/content_fab_margin_end</item>
|
||||
<item name="android:layout_marginTop">@dimen/content_fab_margin_top</item>
|
||||
<item name="android:layout_marginBottom">@dimen/content_fab_margin_bottom</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (C) 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<!-- Fab -->
|
||||
<dimen name="fab_size">56dp</dimen>
|
||||
<dimen name="fab_size_small">40dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<bool name="is_table">false</bool>
|
||||
|
||||
</resources>
|
||||
@@ -18,7 +18,12 @@
|
||||
<!-- Search Content -->
|
||||
<dimen name="content_padding_start">0dp</dimen>
|
||||
<dimen name="content_padding_end">0dp</dimen>
|
||||
<dimen name="content_fab_margin_end">0dp</dimen>
|
||||
<dimen name="content_padding_top">0dp</dimen>
|
||||
<dimen name="content_padding_bottom">72dp</dimen>
|
||||
<dimen name="content_fab_margin_start">0dp</dimen>
|
||||
<dimen name="content_fab_margin_end">@dimen/keyline_margin</dimen>
|
||||
<dimen name="content_fab_margin_top">0dp</dimen>
|
||||
<dimen name="content_fab_margin_bottom">@dimen/keyline_margin</dimen>
|
||||
|
||||
<!-- Search category -->
|
||||
<dimen name="search_category_padding_start">16dp</dimen>
|
||||
@@ -60,4 +65,8 @@
|
||||
<!-- Default elevation -->
|
||||
<dimen name="default_elevation">4dp</dimen>
|
||||
|
||||
<!-- Fab -->
|
||||
<dimen name="fab_size">60dp</dimen>
|
||||
<dimen name="fab_size_small">44dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -25,13 +25,21 @@
|
||||
|
||||
<!-- FloatingActionButton -->
|
||||
<style name="FloatingActionButton">
|
||||
<item name="android:minWidth">60dp</item>
|
||||
<item name="android:minHeight">60dp</item>
|
||||
<item name="android:minWidth">@dimen/fab_size</item>
|
||||
<item name="android:minHeight">@dimen/fab_size</item>
|
||||
</style>
|
||||
|
||||
<style name="FloatingActionButton.Small">
|
||||
<item name="android:minWidth">44dp</item>
|
||||
<item name="android:minHeight">44dp</item>
|
||||
<item name="android:minWidth">@dimen/fab_size_small</item>
|
||||
<item name="android:minHeight">@dimen/fab_size_small</item>
|
||||
</style>
|
||||
|
||||
<style name="FloatingActionButton.Content">
|
||||
<item name="android:layout_gravity">right|bottom</item>
|
||||
<item name="android:layout_marginLeft">@dimen/content_fab_margin_start</item>
|
||||
<item name="android:layout_marginRight">@dimen/content_fab_margin_end</item>
|
||||
<item name="android:layout_marginTop">@dimen/content_fab_margin_top</item>
|
||||
<item name="android:layout_marginBottom">@dimen/content_fab_margin_bottom</item>
|
||||
</style>
|
||||
|
||||
<!-- FloatLabelEditText -->
|
||||
|
||||
Reference in new issue
Block a user