Add source

This commit is contained in:
seven332 committed 2015-02-02 00:28:27 +08:00
1 parent 9817a3c74d
commit 089aaf79bc
17 files changed
+661 -8

No files matched your search

@@ -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) {
}
}
@@ -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{
}
@@ -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);
}
}
@@ -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();
}
}
}
}
@@ -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;
}
}
@@ -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();
}
}
@@ -148,7 +148,6 @@ public abstract class StageActivity extends AbsActionBarActivity {
}
}
@Override
public void onBackPressed() {
if (mCurrentScene != null) {
@@ -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;
}
}
@@ -0,0 +1,38 @@
<?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.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/search_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="@dimen/search_padding_start"
android:paddingLeft="@dimen/search_padding_start"
android:paddingEnd="@dimen/search_padding_end"
android:paddingRight="@dimen/search_padding_end"
android:paddingTop="@dimen/search_padding_top"
android:paddingBottom="@dimen/search_padding_bottom">
<com.hippo.ehviewer.widget.CategoryTable
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
@@ -13,9 +13,9 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
</android.support.v4.view.ViewPager>
@@ -0,0 +1,183 @@
<?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>
<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:text="@string/doujinshi" />
<com.hippo.widget.CheckTextView
android:id="@+id/button_manga"
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="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:textColor="@color/manga"
android:text="@string/manga" />
</TableRow>
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_artistcg"
style="@style/CategoryText"
android:layout_width="0dp"
android:layout_height="wrap_content"
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:text="@string/artist_cg" />
<com.hippo.widget.CheckTextView
android:id="@+id/button_gamecg"
style="@style/CategoryText"
android:layout_width="0dp"
android:layout_height="wrap_content"
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:text="@string/game_cg" />
</TableRow>
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_western"
style="@style/CategoryText"
android:layout_width="0dp"
android:layout_height="wrap_content"
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:text="@string/western" />
<com.hippo.widget.CheckTextView
android:id="@+id/button_non_h"
style="@style/CategoryText"
android:layout_width="0dp"
android:layout_height="wrap_content"
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:text="@string/non_h" />
</TableRow>
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_imageset"
style="@style/CategoryText"
android:layout_width="0dp"
android:layout_height="wrap_content"
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:text="@string/image_set" />
<com.hippo.widget.CheckTextView
android:id="@+id/button_cosplay"
style="@style/CategoryText"
android:layout_width="0dp"
android:layout_height="wrap_content"
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:text="@string/cosplay" />
</TableRow>
<TableRow>
<com.hippo.widget.CheckTextView
android:id="@+id/button_asianporn"
style="@style/CategoryText"
android:layout_width="0dp"
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:text="@string/asian_porn" />
<com.hippo.widget.CheckTextView
android:id="@+id/button_misc"
style="@style/CategoryText"
android:layout_width="0dp"
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:text="@string/misc" />
</TableRow>
</merge>
@@ -0,0 +1,24 @@
<?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>
<!-- Search view padding in its container -->
<dimen name="search_padding_start">128dp</dimen>
<dimen name="search_padding_end">128dp</dimen>
</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>
<!-- Search view padding in its container -->
<dimen name="search_padding_start">80dp</dimen>
<dimen name="search_padding_end">80dp</dimen>
</resources>
+23
View File
@@ -15,6 +15,28 @@
-->
<resources>
<!-- Red -->
<color name="doujinshi">#fff44336</color>
<!-- Orange -->
<color name="manga">#ffff9800</color>
<!-- Yellow 700 -->
<color name="artist_cg">#ffFbc02d</color>
<!-- Green -->
<color name="game_cg">#ff4caf50</color>
<!-- Light Green -->
<color name="western">#ff8bc34a</color>
<!-- Blue -->
<color name="non_h">#ff2196f3</color>
<!-- Indigo -->
<color name="image_set">#ff3f51b5</color>
<!-- Purple -->
<color name="cosplay">#ff9c27b0</color>
<!-- Deep Purple 300 -->
<color name="asian_porn">#ff9575cd</color>
<!-- Pink 300 -->
<color name="misc">#fff06292</color>
<color name="unknown_bg">@android:color/black</color>
<color name="material_teal_500">#ff009688</color>
<color name="material_teal_700">#ff00796b</color>
@@ -31,6 +53,7 @@
<color name="background_dark">#ff303030</color>
<color name="background_light">#ffeeeeee</color>
<color name="background_light_card">#ffe1e1e0</color>
<color name="primary">@color/material_teal_500</color>
<color name="primary_dark">@color/material_teal_700</color>
+24
View File
@@ -0,0 +1,24 @@
<?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>
<!-- Search view padding in its container -->
<dimen name="search_padding_start">0dp</dimen>
<dimen name="search_padding_end">0dp</dimen>
<dimen name="search_padding_top">0dp</dimen>
<dimen name="search_padding_bottom">0dp</dimen>
</resources>
+15 -2
View File
@@ -15,9 +15,22 @@
-->
<resources>
<string name="app_name">EhViewer</string>
<string name="app_name" translatable="false">EhViewer</string>
<!-- Start activity -->
<string name="tip_welcome">Do not be a\nsad pandroid</string>
<string name="tip_welcome" translatable="false">Do not be a\nsad pandroid</string>
<!-- Category -->
<string name="doujinshi" translatable="false">DOUJINSHI</string>
<string name="manga" translatable="false">MANGA</string>
<string name="artist_cg" translatable="false">ARTIST CG</string>
<string name="game_cg" translatable="false">GAME CG</string>
<string name="western" translatable="false">WESTERN</string>
<string name="non_h" translatable="false">NON-H</string>
<string name="image_set" translatable="false">IMAGE SET</string>
<string name="cosplay" translatable="false">COSPLAY</string>
<string name="asian_porn" translatable="false">ASIAN PORN</string>
<string name="misc" translatable="false">MISC</string>
<string name="unknown" translatable="false">UNKNOWN</string>
</resources>
+8
View File
@@ -26,4 +26,12 @@
<item name="android:minHeight">44dp</item>
</style>
<!-- CategoryText -->
<style name="CategoryText">
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Subhead</item>
<item name="android:textStyle">bold</item>
<item name="android:gravity">center</item>
<item name="android:minHeight">40dp</item>
</style>
</resources>