diff --git a/app/src/main/java/com/hippo/ehviewer/data/ListUrlBuilder.java b/app/src/main/java/com/hippo/ehviewer/data/GalleryListUrlBuilder.java similarity index 77% rename from app/src/main/java/com/hippo/ehviewer/data/ListUrlBuilder.java rename to app/src/main/java/com/hippo/ehviewer/data/GalleryListUrlBuilder.java index 555a62520..fd004e954 100644 --- a/app/src/main/java/com/hippo/ehviewer/data/ListUrlBuilder.java +++ b/app/src/main/java/com/hippo/ehviewer/data/GalleryListUrlBuilder.java @@ -15,6 +15,14 @@ package com.hippo.ehviewer.data; -public class ListUrlBuilder { +public class GalleryListUrlBuilder { + + /** + * Make them the same + * @param glub The template + */ + public void set(GalleryListUrlBuilder glub) { + + } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/GalleryListFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/GalleryListFragment.java new file mode 100644 index 000000000..e59395cb4 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/GalleryListFragment.java @@ -0,0 +1,21 @@ +/* + * 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.ui.fragment; + +import android.support.v4.app.Fragment; + +public class GalleryListFragment extends Fragment{ +} 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 new file mode 100644 index 000000000..a137dab9e --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/SearchFragment.java @@ -0,0 +1,45 @@ +/* + * 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.ui.fragment; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.hippo.ehviewer.R; +import com.hippo.ehviewer.data.GalleryListUrlBuilder; + +public class SearchFragment extends Fragment { + + private OnSearchListener mOnSearchListener; + + public void setOnSearchListener(OnSearchListener listener) { + mOnSearchListener = listener; + } + + public View onCreateView(LayoutInflater inflater,ViewGroup container, + Bundle savedInstanceState) { + + View mRootView = inflater.inflate(R.layout.fragment_search, container, false); + return mRootView; + } + + public interface OnSearchListener { + public void onSearch(GalleryListUrlBuilder glub); + } +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java index 5db84fc9d..4e9f28641 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java @@ -15,14 +15,31 @@ package com.hippo.ehviewer.ui.scene; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; + import com.hippo.ehviewer.R; +import com.hippo.ehviewer.data.GalleryListUrlBuilder; +import com.hippo.ehviewer.ui.fragment.GalleryListFragment; +import com.hippo.ehviewer.ui.fragment.SearchFragment; import com.hippo.scene.Scene; -public class GalleryListScene extends Scene { +public class GalleryListScene extends Scene implements SearchFragment.OnSearchListener { + + private ViewPager mViewPager; + + private GalleryListPagerAdapter mAdapter; @Override public void onCreate() { setContentView(R.layout.scene_gallery_list); + + mViewPager = (ViewPager) findViewById(R.id.viewPager); + + mAdapter = new GalleryListPagerAdapter(getSupportFragmentManager()); + mViewPager.setAdapter(mAdapter); } @Override @@ -39,4 +56,32 @@ public class GalleryListScene extends Scene { public void onDestroy() { dispatchRemove(); } + + @Override + public void onSearch(GalleryListUrlBuilder glub) { + + } + + public class GalleryListPagerAdapter extends FragmentPagerAdapter { + + public GalleryListPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public int getCount() { + return 2; + } + + @Override + public Fragment getItem(int i) { + if (i == 0) { + SearchFragment fragment = new SearchFragment(); + fragment.setOnSearchListener(GalleryListScene.this); + return fragment; + } else { + return new GalleryListFragment(); + } + } + } } diff --git a/app/src/main/java/com/hippo/ehviewer/widget/CategoryTable.java b/app/src/main/java/com/hippo/ehviewer/widget/CategoryTable.java new file mode 100644 index 000000000..5b76d5897 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/widget/CategoryTable.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2014-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.TableLayout; + +import com.hippo.ehviewer.R; +import com.hippo.ehviewer.util.EhUtils; +import com.hippo.util.Utils; +import com.hippo.widget.CheckTextView; + +public class CategoryTable extends TableLayout { + + private CheckTextView mDoujinshi; + private CheckTextView mManga; + private CheckTextView mArtistCG; + private CheckTextView mGameCG; + private CheckTextView mWestern; + private CheckTextView mNonH; + private CheckTextView mImageSets; + private CheckTextView mCosplay; + private CheckTextView mAsianPorn; + private CheckTextView mMisc; + + + public CategoryTable(Context context) { + super(context); + init(); + } + + public CategoryTable(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public void init() { + 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); + mGameCG = (CheckTextView)findViewById(R.id.button_gamecg); + mWestern = (CheckTextView)findViewById(R.id.button_western); + mNonH = (CheckTextView)findViewById(R.id.button_non_h); + mImageSets = (CheckTextView)findViewById(R.id.button_imageset); + mCosplay = (CheckTextView)findViewById(R.id.button_cosplay); + mAsianPorn = (CheckTextView)findViewById(R.id.button_asianporn); + mMisc = (CheckTextView)findViewById(R.id.button_misc); + } + + /** + * Set each button checked or not according to category. + * + * @param category + */ + public void setCategory(int category) { + mDoujinshi.setChecked(!Utils.int2boolean(category & EhUtils.DOUJINSHI)); + mManga.setChecked(!Utils.int2boolean(category & EhUtils.MANGA)); + mArtistCG.setChecked(!Utils.int2boolean(category & EhUtils.ARTIST_CG)); + mGameCG.setChecked(!Utils.int2boolean(category & EhUtils.GAME_CG)); + mWestern.setChecked(!Utils.int2boolean(category & EhUtils.WESTERN)); + mNonH.setChecked(!Utils.int2boolean(category & EhUtils.NON_H)); + mImageSets.setChecked(!Utils.int2boolean(category & EhUtils.IMAGE_SET)); + mCosplay.setChecked(!Utils.int2boolean(category & EhUtils.COSPLAY)); + mAsianPorn.setChecked(!Utils.int2boolean(category & EhUtils.ASIAN_PORN)); + mMisc.setChecked(!Utils.int2boolean(category & EhUtils.MISC)); + } + + /** + * Get category according to button. + * @return + */ + public int getCategory() { + int category = 0; + if (!mDoujinshi.isChecked()) category |= EhUtils.DOUJINSHI; + if (!mManga.isChecked()) category |= EhUtils.MANGA; + if (!mArtistCG.isChecked()) category |= EhUtils.ARTIST_CG; + if (!mGameCG.isChecked()) category |= EhUtils.GAME_CG; + if (!mWestern.isChecked()) category |= EhUtils.WESTERN; + if (!mNonH.isChecked()) category |= EhUtils.NON_H; + if (!mImageSets.isChecked()) category |= EhUtils.IMAGE_SET; + if (!mCosplay.isChecked()) category |= EhUtils.COSPLAY; + if (!mAsianPorn.isChecked()) category |= EhUtils.ASIAN_PORN; + if (!mMisc.isChecked()) category |= EhUtils.MISC; + return category; + } +} diff --git a/app/src/main/java/com/hippo/scene/Scene.java b/app/src/main/java/com/hippo/scene/Scene.java index 75feefd46..4dd11188a 100644 --- a/app/src/main/java/com/hippo/scene/Scene.java +++ b/app/src/main/java/com/hippo/scene/Scene.java @@ -15,6 +15,7 @@ package com.hippo.scene; +import android.support.v4.app.FragmentManager; import android.view.View; import android.widget.FrameLayout; @@ -110,4 +111,11 @@ public abstract class Scene { finish(); } + /** + * Return the FragmentManager for interacting with fragments associated + * with StageActivity. + */ + public FragmentManager getSupportFragmentManager() { + return mStageActivity.getSupportFragmentManager(); + } } diff --git a/app/src/main/java/com/hippo/scene/StageActivity.java b/app/src/main/java/com/hippo/scene/StageActivity.java index b9b2b91c5..39cf6a913 100644 --- a/app/src/main/java/com/hippo/scene/StageActivity.java +++ b/app/src/main/java/com/hippo/scene/StageActivity.java @@ -148,7 +148,6 @@ public abstract class StageActivity extends AbsActionBarActivity { } } - @Override public void onBackPressed() { if (mCurrentScene != null) { diff --git a/app/src/main/java/com/hippo/widget/CheckTextView.java b/app/src/main/java/com/hippo/widget/CheckTextView.java new file mode 100644 index 000000000..0e8f1fc7e --- /dev/null +++ b/app/src/main/java/com/hippo/widget/CheckTextView.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2014-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.widget; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; +import android.util.AttributeSet; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.TextView; + +public class CheckTextView extends TextView implements OnClickListener{ + + private static int MASK = 0xba000000; + + private Paint mPaint; + private Rect mRect = new Rect(); + + private boolean mChecked = false; + + public CheckTextView(Context context) { + super(context); + init(); + } + + public CheckTextView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CheckTextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(); + } + + private void init() { + mPaint = new Paint(); + mPaint.setColor(MASK); + setOnClickListener(this); + } + + @Override + public void onClick(View v) { + mChecked = !mChecked; + invalidate(); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + mRect.set(0, 0, right - left, bottom - top); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + if (mChecked) { + canvas.drawRect(mRect, mPaint); + } + } + + public void setChecked(boolean checked) { + mChecked = checked; + invalidate(); + } + + public boolean isChecked() { + return mChecked; + } +} diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml new file mode 100644 index 000000000..fda2f620b --- /dev/null +++ b/app/src/main/res/layout/fragment_search.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + diff --git a/app/src/main/res/layout/scene_gallery_list.xml b/app/src/main/res/layout/scene_gallery_list.xml index f67f21ba3..fe8769ca2 100644 --- a/app/src/main/res/layout/scene_gallery_list.xml +++ b/app/src/main/res/layout/scene_gallery_list.xml @@ -13,9 +13,9 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + diff --git a/app/src/main/res/layout/widget_category_table.xml b/app/src/main/res/layout/widget_category_table.xml new file mode 100644 index 000000000..7861b86b1 --- /dev/null +++ b/app/src/main/res/layout/widget_category_table.xml @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-sw720dp-land/dimens.xml b/app/src/main/res/values-sw720dp-land/dimens.xml new file mode 100644 index 000000000..0a1c56fc3 --- /dev/null +++ b/app/src/main/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,24 @@ + + + + + + + + 128dp + 128dp + + diff --git a/app/src/main/res/values-sw720dp/dimens.xml b/app/src/main/res/values-sw720dp/dimens.xml new file mode 100644 index 000000000..f9795f702 --- /dev/null +++ b/app/src/main/res/values-sw720dp/dimens.xml @@ -0,0 +1,23 @@ + + + + + + + 80dp + 80dp + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 1be936175..59cf00765 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -15,6 +15,28 @@ --> + + #fff44336 + + #ffff9800 + + #ffFbc02d + + #ff4caf50 + + #ff8bc34a + + #ff2196f3 + + #ff3f51b5 + + #ff9c27b0 + + #ff9575cd + + #fff06292 + @android:color/black + #ff009688 #ff00796b @@ -31,6 +53,7 @@ #ff303030 #ffeeeeee + #ffe1e1e0 @color/material_teal_500 @color/material_teal_700 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 000000000..7b521cf02 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,24 @@ + + + + + + 0dp + 0dp + 0dp + 0dp + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2efeb6ccd..f6ca3cc22 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,9 +15,22 @@ --> - EhViewer + EhViewer - Do not be a\nsad pandroid + Do not be a\nsad pandroid + + + DOUJINSHI + MANGA + ARTIST CG + GAME CG + WESTERN + NON-H + IMAGE SET + COSPLAY + ASIAN PORN + MISC + UNKNOWN diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 65a1f7dde..c35570635 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -26,4 +26,12 @@ 44dp + + +