diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/SearchFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/SearchFragment.java index 6e8d90258..082afccc7 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/SearchFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/SearchFragment.java @@ -31,6 +31,7 @@ import android.widget.TextView; import com.hippo.ehviewer.R; import com.hippo.ehviewer.data.GalleryListUrlBuilder; +import com.hippo.ehviewer.widget.AdvanceSearchTable; import com.hippo.ehviewer.widget.CategoryTable; import com.hippo.util.UiUtils; import com.hippo.util.ViewUtils; @@ -64,6 +65,8 @@ public class SearchFragment extends Fragment implements CompoundButton.OnChecked private CheckBox mCheckSpecifyAuthor; private PrefixEditText mTextSearch; private CheckBox mCheckEnableAdvance; + private View mAdvanceView; + private AdvanceSearchTable mTableAdvanceSearch; private LinearLayoutManager mLayoutManager; private SearchAdapter mAdapter; @@ -93,6 +96,7 @@ public class SearchFragment extends Fragment implements CompoundButton.OnChecked public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (buttonView == mCheckSpecifyAuthor) { mTextSearch.setPrefix(isChecked ? "uploader:" : null); + } else if (buttonView == mCheckEnableAdvance) { mEnableAdvance = isChecked; if (mSearchType == SEARCH_TYPE_NORMAL) { @@ -204,6 +208,15 @@ public class SearchFragment extends Fragment implements CompoundButton.OnChecked private void bindAdvanceView(SearchHolder holder) { holder.title.setText(R.string.search_advance); + + if (mAdvanceView == null) { + mInflater.inflate(R.layout.search_advance, holder.content); + mAdvanceView = holder.content.getChildAt(0); + mTableAdvanceSearch = (AdvanceSearchTable) mAdvanceView.findViewById(R.id.search_advance_search_table); + } else { + ViewUtils.removeFromParent(mAdvanceView); + holder.content.addView(mAdvanceView); + } } private void bindTagView(SearchHolder holder) { diff --git a/app/src/main/java/com/hippo/ehviewer/widget/AdvanceSearchTable.java b/app/src/main/java/com/hippo/ehviewer/widget/AdvanceSearchTable.java new file mode 100644 index 000000000..34fce9322 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/widget/AdvanceSearchTable.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +package com.hippo.ehviewer.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.CheckBox; +import android.widget.Spinner; +import android.widget.TableLayout; + +import com.hippo.ehviewer.R; + +public class AdvanceSearchTable extends TableLayout { + + private CheckBox mSname; + private CheckBox mStags; + private CheckBox mSdesc; + private CheckBox mStorr; + private CheckBox mSto; + private CheckBox mSdt1; + private CheckBox mSdt2; + private CheckBox mSh; + private CheckBox mSr; + private Spinner mMinRating; + + public AdvanceSearchTable(Context context) { + super(context); + init(); + } + + public AdvanceSearchTable(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public void init() { + LayoutInflater inflater = LayoutInflater.from(getContext()); + inflater.inflate(R.layout.widget_advance_search_table, this); + + mSname = (CheckBox) findViewById(R.id.search_sname); + mStags = (CheckBox) findViewById(R.id.search_stags); + mSdesc = (CheckBox) findViewById(R.id.search_sdesc); + mStorr = (CheckBox) findViewById(R.id.search_storr); + mSto = (CheckBox) findViewById(R.id.search_sto); + mSdt1 = (CheckBox) findViewById(R.id.search_sdt1); + mSdt2 = (CheckBox) findViewById(R.id.search_sdt2); + mSh = (CheckBox) findViewById(R.id.search_sh); + mSr = (CheckBox) findViewById(R.id.search_sr); + mMinRating = (Spinner) findViewById(R.id.search_min_rating); + } + +} diff --git a/app/src/main/java/com/hippo/ehviewer/widget/CategoryTable.java b/app/src/main/java/com/hippo/ehviewer/widget/CategoryTable.java index 5b76d5897..999495537 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/CategoryTable.java +++ b/app/src/main/java/com/hippo/ehviewer/widget/CategoryTable.java @@ -53,8 +53,6 @@ public class CategoryTable extends TableLayout { LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.widget_category_table, this); - setStretchAllColumns(true); - mDoujinshi = (CheckTextView)findViewById(R.id.button_doujinshi); mManga = (CheckTextView)findViewById(R.id.button_manga); mArtistCG = (CheckTextView)findViewById(R.id.button_artistcg); diff --git a/app/src/main/res/layout/search_advance.xml b/app/src/main/res/layout/search_advance.xml new file mode 100644 index 000000000..82bb9b607 --- /dev/null +++ b/app/src/main/res/layout/search_advance.xml @@ -0,0 +1,20 @@ + + + diff --git a/app/src/main/res/layout/search_category.xml b/app/src/main/res/layout/search_category.xml index 15ba138bb..c880298e5 100644 --- a/app/src/main/res/layout/search_category.xml +++ b/app/src/main/res/layout/search_category.xml @@ -37,6 +37,8 @@ + android:layout_height="wrap_content" + android:paddingLeft="@dimen/search_category_widget_margin_start" + android:paddingRight="@dimen/search_category_widget_margin_start"/> diff --git a/app/src/main/res/layout/search_normal.xml b/app/src/main/res/layout/search_normal.xml index 91ab03e4f..a23e7e155 100644 --- a/app/src/main/res/layout/search_normal.xml +++ b/app/src/main/res/layout/search_normal.xml @@ -28,16 +28,12 @@ android:id="@+id/search_specify_author" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/search_category_widget_margin_start" - android:layout_marginRight="@dimen/search_category_widget_margin_end" android:text="@string/search_specify_author"/> @@ -45,8 +41,6 @@ android:id="@+id/search_enable_advance" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/search_category_widget_margin_start" - android:layout_marginRight="@dimen/search_category_widget_margin_end" android:text="@string/search_enable_advance"/> diff --git a/app/src/main/res/layout/widget_advance_search_table.xml b/app/src/main/res/layout/widget_advance_search_table.xml new file mode 100644 index 000000000..99671ad75 --- /dev/null +++ b/app/src/main/res/layout/widget_advance_search_table.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/widget_category_table.xml b/app/src/main/res/layout/widget_category_table.xml index 23dba62f2..9494ad09a 100644 --- a/app/src/main/res/layout/widget_category_table.xml +++ b/app/src/main/res/layout/widget_category_table.xml @@ -17,20 +17,16 @@ xmlns:android="http://schemas.android.com/apk/res/android" > - - - - - diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml new file mode 100644 index 000000000..3067d2ed6 --- /dev/null +++ b/app/src/main/res/values/arrays.xml @@ -0,0 +1,25 @@ + + + + + + @string/star_2 + @string/star_3 + @string/star_4 + @string/star_5 + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4d5c7001c..5cb4fcd61 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -40,6 +40,23 @@ Image Specify Uploader Enable advance options + + Search Gallery + Search Gallery Tags + Search Gallery Description + Search Torrent Filenames + Only Show Galleries With Torrents + Search Low-Power Tags + Search Downvoted Tags + Show Expunged Galleries + Minimum Rating: + No keyword is OK + + 2 stars + 3 stars + 4 stars + 5 stars +