Improve search

This commit is contained in:
seven332 committed 2015-02-08 22:26:01 +08:00
1 parent cde8aa7f62
commit b6654f09af
10 files changed
+265 -58

No files matched your search

@@ -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) {
@@ -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);
}
}
@@ -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);
@@ -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.
-->
<com.hippo.ehviewer.widget.AdvanceSearchTable
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/search_advance_search_table"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
+3 -1
View File
@@ -37,6 +37,8 @@
<FrameLayout
android:id="@+id/category_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:paddingLeft="@dimen/search_category_widget_margin_start"
android:paddingRight="@dimen/search_category_widget_margin_start"/>
</LinearLayout>
@@ -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"/>
<com.hippo.widget.PrefixEditText
android:id="@+id/search_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/search_category_widget_margin_start"
android:layout_marginRight="@dimen/search_category_widget_margin_end"
android:hint="@string/hint_no_keyword"
android:singleLine="true"/>
@@ -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"/>
</LinearLayout>
@@ -0,0 +1,101 @@
<?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">
<TableRow>
<CheckBox
android:id="@+id/search_sname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="@string/search_sname"/>
<CheckBox
android:id="@+id/search_stags"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="@string/search_stags"/>
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/search_sdesc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/search_sdesc"/>
<CheckBox
android:id="@+id/search_storr"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/search_storr"/>
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/search_sto"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/search_sto"/>
<CheckBox
android:id="@+id/search_sdt1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/search_sdt1"/>
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/search_sdt2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/search_sdt2"/>
<CheckBox
android:id="@+id/search_sh"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/search_sh"/>
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/search_sr"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/search_sr"/>
<Spinner
android:id="@+id/search_min_rating"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/search_min_rating"/>
</TableRow>
</merge>
@@ -17,20 +17,16 @@
xmlns:android="http://schemas.android.com/apk/res/android" >
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_doujinshi"
style="@style/CategoryText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="8dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:textColor="@color/doujinshi"
android:background="@color/doujinshi"
android:textColor="@android:color/white"
android:text="@string/doujinshi" />
<com.hippo.widget.CheckTextView
@@ -39,18 +35,14 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="8dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:textColor="@color/manga"
android:background="@color/manga"
android:textColor="@android:color/white"
android:text="@string/manga" />
</TableRow>
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_artistcg"
style="@style/CategoryText"
@@ -59,11 +51,9 @@
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:textColor="@color/artist_cg"
android:background="@color/artist_cg"
android:textColor="@android:color/white"
android:text="@string/artist_cg" />
<com.hippo.widget.CheckTextView
@@ -74,16 +64,13 @@
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:textColor="@color/game_cg"
android:background="@color/game_cg"
android:textColor="@android:color/white"
android:text="@string/game_cg" />
</TableRow>
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_western"
style="@style/CategoryText"
@@ -92,11 +79,9 @@
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:textColor="@color/western"
android:background="@color/western"
android:textColor="@android:color/white"
android:text="@string/western" />
<com.hippo.widget.CheckTextView
@@ -107,16 +92,13 @@
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:textColor="@color/non_h"
android:background="@color/non_h"
android:textColor="@android:color/white"
android:text="@string/non_h" />
</TableRow>
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_imageset"
style="@style/CategoryText"
@@ -125,11 +107,9 @@
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:textColor="@color/image_set"
android:background="@color/image_set"
android:textColor="@android:color/white"
android:text="@string/image_set" />
<com.hippo.widget.CheckTextView
@@ -140,16 +120,13 @@
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:textColor="@color/cosplay"
android:background="@color/cosplay"
android:textColor="@android:color/white"
android:text="@string/cosplay" />
</TableRow>
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_asianporn"
style="@style/CategoryText"
@@ -157,12 +134,9 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:textColor="@color/asian_porn"
android:background="@color/asian_porn"
android:textColor="@android:color/white"
android:text="@string/asian_porn" />
<com.hippo.widget.CheckTextView
@@ -172,12 +146,9 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:textColor="@color/misc"
android:background="@color/misc"
android:textColor="@android:color/white"
android:text="@string/misc" />
</TableRow>
+25
View File
@@ -0,0 +1,25 @@
<?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>
<string-array name="search_min_rating">
<item>@string/star_2</item>
<item>@string/star_3</item>
<item>@string/star_4</item>
<item>@string/star_5</item>
</string-array>
</resources>
+17
View File
@@ -40,6 +40,23 @@
<string name="search_image">Image</string>
<string name="search_specify_author">Specify Uploader</string>
<string name="search_enable_advance">Enable advance options</string>
<string name="search_sname">Search Gallery</string>
<string name="search_stags">Search Gallery Tags</string>
<string name="search_sdesc">Search Gallery Description</string>
<string name="search_storr">Search Torrent Filenames</string>
<string name="search_sto">Only Show Galleries With Torrents</string>
<string name="search_sdt1">Search Low-Power Tags</string>
<string name="search_sdt2">Search Downvoted Tags</string>
<string name="search_sh">Show Expunged Galleries</string>
<string name="search_sr">Minimum Rating:</string>
<string name="hint_no_keyword">No keyword is OK</string>
<!-- search_min_rating -->
<string name="star_2">2 stars</string>
<string name="star_3">3 stars</string>
<string name="star_4">4 stars</string>
<string name="star_5">5 stars</string>
</resources>