添加 CategoryTable
This commit is contained in:
1 parent
ab9b7e59d9
commit
eaae310f05
11 files changed
+416
-356
No files matched your search
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2014 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
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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 android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_doujinshi"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
android:background="@color/doujinshi_bg"
|
||||
android:text="@string/doujinshi" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_manga"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
android:background="@color/manga_bg"
|
||||
android:text="@string/manga" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_artistcg"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
android:background="@color/artist_cg_bg"
|
||||
android:text="@string/artist_cg" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_gamecg"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
android:background="@color/game_cg_bg"
|
||||
android:text="@string/game_cg" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_western"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
android:background="@color/western_bg"
|
||||
android:text="@string/western" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_non_h"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
android:background="@color/non_h_bg"
|
||||
android:text="@string/non_h" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_imageset"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
android:background="@color/image_set_bg"
|
||||
android:text="@string/image_set" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_cosplay"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
android:background="@color/cosplay_bg"
|
||||
android:text="@string/cosplay" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_asianporn"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
android:background="@color/asian_porn_bg"
|
||||
android:text="@string/asian_porn" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_misc"
|
||||
style="@style/SearchCategory"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
android:background="@color/misc_bg"
|
||||
android:text="@string/misc" />
|
||||
</TableRow>
|
||||
</merge>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 Hippo Seven
|
||||
<!--
|
||||
Copyright (C) 2014 Hippo Seven
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -12,119 +13,23 @@
|
||||
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.
|
||||
-->
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TableLayout
|
||||
<com.hippo.ehviewer.widget.CategoryTable
|
||||
android:id="@+id/category_table"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:stretchColumns="*" >
|
||||
android:layout_marginTop="12dp" />
|
||||
|
||||
<TableRow android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_doujinshi"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/doujinshi_bg"
|
||||
android:text="@string/doujinshi" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_manga"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/manga_bg"
|
||||
android:text="@string/manga" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_artistcg"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/artist_cg_bg"
|
||||
android:text="@string/artist_cg" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_gamecg"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/game_cg_bg"
|
||||
android:text="@string/game_cg" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_western"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/western_bg"
|
||||
android:text="@string/western" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_non_h"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/non_h_bg"
|
||||
android:text="@string/non_h" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_imageset"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/image_set_bg"
|
||||
android:text="@string/image_set" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_cosplay"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/cosplay_bg"
|
||||
android:text="@string/cosplay" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:layout_marginBottom="8dp" >
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_asianporn"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginRight="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/asian_porn_bg"
|
||||
android:text="@string/asian_porn" />
|
||||
|
||||
<com.hippo.ehviewer.widget.CheckTextView
|
||||
android:id="@+id/button_misc"
|
||||
android:layout_width="0.0dp"
|
||||
android:layout_marginLeft="6.0dp"
|
||||
style="@style/SearchCategory"
|
||||
android:background="@color/misc_bg"
|
||||
android:text="@string/misc" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox_uploader"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -132,7 +37,7 @@
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:text="@string/checkbox_uploader" />
|
||||
|
||||
|
||||
<com.hippo.ehviewer.widget.PrefixEditText
|
||||
android:id="@+id/search_text"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -187,6 +187,10 @@
|
||||
<string name="popular_display_settings_title">热门</string>
|
||||
<string name="show_popular_update_time_title">显示热门更新时间</string>
|
||||
<string name="eh_settings_title">EH</string>
|
||||
|
||||
<string name="list_eh_settings_title">列表</string>
|
||||
<string name="list_default_category">列表默认分类</string>
|
||||
|
||||
<string name="detail_eh_settings_title">详情</string>
|
||||
<string name="preview_mode_title">预览图模式</string>
|
||||
<string name="preview_mode_normal">正常预览图</string>
|
||||
|
||||
@@ -186,6 +186,12 @@
|
||||
<string name="popular_display_settings_title">Popular</string>
|
||||
<string name="show_popular_update_time_title">Show popular update time</string>
|
||||
<string name="eh_settings_title">EH</string>
|
||||
|
||||
|
||||
<string name="list_eh_settings_title">List</string>
|
||||
<string name="list_default_category">List default category</string>
|
||||
|
||||
|
||||
<string name="detail_eh_settings_title">Detail</string>
|
||||
<string name="preview_mode_title">Preview mode</string>
|
||||
<string name="preview_mode_normal">Normal</string>
|
||||
|
||||
+20
-18
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 Hippo Seven
|
||||
<!--
|
||||
Copyright (C) 2014 Hippo Seven
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -12,27 +13,28 @@
|
||||
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.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/detail_eh_settings_title">
|
||||
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<PreferenceCategory android:title="@string/list_eh_settings_title" >
|
||||
<Preference
|
||||
android:key="list_default_category"
|
||||
android:title="@string/list_default_category" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/detail_eh_settings_title" >
|
||||
<com.hippo.ehviewer.preference.AutoListPreference
|
||||
android:key="preview_mode"
|
||||
android:title="@string/preview_mode_title"
|
||||
android:defaultValue="l"
|
||||
android:entries="@array/preview_mode_entries"
|
||||
android:entryValues="@array/preview_mode_entry_values"
|
||||
android:defaultValue="l"
|
||||
android:summary="%s" />
|
||||
|
||||
android:key="preview_mode"
|
||||
android:summary="%s"
|
||||
android:title="@string/preview_mode_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="preview_per_row"
|
||||
android:title="@string/preview_per_row_title"
|
||||
android:defaultValue="3"
|
||||
android:inputType="number"
|
||||
android:defaultValue="3" />
|
||||
|
||||
android:key="preview_per_row"
|
||||
android:title="@string/preview_per_row_title" />
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -144,16 +144,16 @@ public class HttpHelper {
|
||||
return c.getString(R.string.em_redirection_error);
|
||||
|
||||
else if (e instanceof SocketException)
|
||||
return "SocketException : " + e.getMessage();
|
||||
return "SocketException: " + e.getMessage();
|
||||
|
||||
else if (e instanceof SadPandaException)
|
||||
return SAD_PANDA_ERROR;
|
||||
|
||||
else if (e instanceof GetBodyException)
|
||||
return "获取失败"; // TODO
|
||||
return "Sad Panda"; // TODO
|
||||
|
||||
else
|
||||
return e.getMessage();
|
||||
return e.getClass().getSimpleName() + ": " +e.getMessage();
|
||||
}
|
||||
|
||||
private boolean isUrlCookiable(URL url) {
|
||||
|
||||
@@ -626,7 +626,7 @@ public abstract class AbstractGalleryActivity extends AbstractSlidingActivity
|
||||
default:
|
||||
mRefreshTextView.setRefreshing(false);
|
||||
mRefreshTextView.setVisibility(View.GONE);
|
||||
new SuperToast(AbstractGalleryActivity.this, "错误的页面数",SuperToast.ERROR).show(); // TODO
|
||||
new SuperToast(AbstractGalleryActivity.this, eMsg, SuperToast.ERROR).show(); // TODO
|
||||
}
|
||||
mHlv.setAnyRefreshComplete(false);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ import com.hippo.ehviewer.util.Theme;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
import com.hippo.ehviewer.util.Util;
|
||||
import com.hippo.ehviewer.widget.AlertButton;
|
||||
import com.hippo.ehviewer.widget.CheckTextView;
|
||||
import com.hippo.ehviewer.widget.CategoryTable;
|
||||
import com.hippo.ehviewer.widget.DialogBuilder;
|
||||
import com.hippo.ehviewer.widget.FswView;
|
||||
import com.hippo.ehviewer.widget.OnFitSystemWindowsListener;
|
||||
@@ -386,48 +386,11 @@ public class MangaListActivity extends AbstractGalleryActivity
|
||||
lus = new ListUrls();
|
||||
lus.setTag(et.getText().toString());
|
||||
} else {
|
||||
CheckTextView checkImageDoujinshi = (CheckTextView) view
|
||||
.findViewById(R.id.button_doujinshi);
|
||||
CheckTextView checkImageManga = (CheckTextView) view
|
||||
.findViewById(R.id.button_manga);
|
||||
CheckTextView checkImageArtistcg = (CheckTextView) view
|
||||
.findViewById(R.id.button_artistcg);
|
||||
CheckTextView checkImageGamecg = (CheckTextView) view
|
||||
.findViewById(R.id.button_gamecg);
|
||||
CheckTextView checkImageWestern = (CheckTextView) view
|
||||
.findViewById(R.id.button_western);
|
||||
CheckTextView checkImageNonH = (CheckTextView) view
|
||||
.findViewById(R.id.button_non_h);
|
||||
CheckTextView checkImageImageset = (CheckTextView) view
|
||||
.findViewById(R.id.button_imageset);
|
||||
CheckTextView checkImageCosplay = (CheckTextView) view
|
||||
.findViewById(R.id.button_cosplay);
|
||||
CheckTextView checkImageAsianporn = (CheckTextView) view
|
||||
.findViewById(R.id.button_asianporn);
|
||||
CheckTextView checkImageMisc = (CheckTextView) view
|
||||
.findViewById(R.id.button_misc);
|
||||
int type;
|
||||
|
||||
int type = 0;
|
||||
if (!checkImageDoujinshi.isPressed())
|
||||
type |= ListUrls.DOUJINSHI;
|
||||
if (!checkImageManga.isPressed())
|
||||
type |= ListUrls.MANGA;
|
||||
if (!checkImageArtistcg.isPressed())
|
||||
type |= ListUrls.ARTIST_CG;
|
||||
if (!checkImageGamecg.isPressed())
|
||||
type |= ListUrls.GAME_CG;
|
||||
if (!checkImageWestern.isPressed())
|
||||
type |= ListUrls.WESTERN;
|
||||
if (!checkImageNonH.isPressed())
|
||||
type |= ListUrls.NON_H;
|
||||
if (!checkImageImageset.isPressed())
|
||||
type |= ListUrls.IMAGE_SET;
|
||||
if (!checkImageCosplay.isPressed())
|
||||
type |= ListUrls.COSPLAY;
|
||||
if (!checkImageAsianporn.isPressed())
|
||||
type |= ListUrls.ASIAN_PORN;
|
||||
if (!checkImageMisc.isPressed())
|
||||
type |= ListUrls.MISC;
|
||||
CategoryTable ct = (CategoryTable) view
|
||||
.findViewById(R.id.category_table);
|
||||
type = ct.getCategory();
|
||||
|
||||
EditText et = (EditText)view.findViewById(R.id.search_text);
|
||||
|
||||
@@ -713,69 +676,10 @@ public class MangaListActivity extends AbstractGalleryActivity
|
||||
searchNormal.setVisibility(View.VISIBLE);
|
||||
searchTag.setVisibility(View.GONE);
|
||||
|
||||
// Normal
|
||||
CheckTextView checkImageDoujinshi = (CheckTextView) view
|
||||
.findViewById(R.id.button_doujinshi);
|
||||
CheckTextView checkImageManga = (CheckTextView) view
|
||||
.findViewById(R.id.button_manga);
|
||||
CheckTextView checkImageArtistcg = (CheckTextView) view
|
||||
.findViewById(R.id.button_artistcg);
|
||||
CheckTextView checkImageGamecg = (CheckTextView) view
|
||||
.findViewById(R.id.button_gamecg);
|
||||
CheckTextView checkImageWestern = (CheckTextView) view
|
||||
.findViewById(R.id.button_western);
|
||||
CheckTextView checkImageNonH = (CheckTextView) view
|
||||
.findViewById(R.id.button_non_h);
|
||||
CheckTextView checkImageImageset = (CheckTextView) view
|
||||
.findViewById(R.id.button_imageset);
|
||||
CheckTextView checkImageCosplay = (CheckTextView) view
|
||||
.findViewById(R.id.button_cosplay);
|
||||
CheckTextView checkImageAsianporn = (CheckTextView) view
|
||||
.findViewById(R.id.button_asianporn);
|
||||
CheckTextView checkImageMisc = (CheckTextView) view
|
||||
.findViewById(R.id.button_misc);
|
||||
|
||||
int type = listUrls.getType();
|
||||
if ((type & ListUrls.DOUJINSHI) == 0)
|
||||
checkImageDoujinshi.setChecked(true);
|
||||
else
|
||||
checkImageDoujinshi.setChecked(false);
|
||||
if ((type & ListUrls.MANGA) == 0)
|
||||
checkImageManga.setChecked(true);
|
||||
else
|
||||
checkImageManga.setChecked(false);
|
||||
if ((type & ListUrls.ARTIST_CG) == 0)
|
||||
checkImageArtistcg.setChecked(true);
|
||||
else
|
||||
checkImageArtistcg.setChecked(false);
|
||||
if ((type & ListUrls.GAME_CG) == 0)
|
||||
checkImageGamecg.setChecked(true);
|
||||
else
|
||||
checkImageGamecg.setChecked(false);
|
||||
if ((type & ListUrls.WESTERN) == 0)
|
||||
checkImageWestern.setChecked(true);
|
||||
else
|
||||
checkImageWestern.setChecked(false);
|
||||
if ((type & ListUrls.NON_H) == 0)
|
||||
checkImageNonH.setChecked(true);
|
||||
else
|
||||
checkImageNonH.setChecked(false);
|
||||
if ((type & ListUrls.IMAGE_SET) == 0)
|
||||
checkImageImageset.setChecked(true);
|
||||
else
|
||||
checkImageImageset.setChecked(false);
|
||||
if ((type & ListUrls.COSPLAY) == 0)
|
||||
checkImageCosplay.setChecked(true);
|
||||
else
|
||||
checkImageCosplay.setChecked(false);
|
||||
if ((type & ListUrls.ASIAN_PORN) == 0)
|
||||
checkImageAsianporn.setChecked(true);
|
||||
else
|
||||
checkImageAsianporn.setChecked(false);
|
||||
if ((type & ListUrls.MISC) == 0)
|
||||
checkImageMisc.setChecked(true);
|
||||
else
|
||||
checkImageMisc.setChecked(false);
|
||||
int category = listUrls.getType();
|
||||
CategoryTable ct = (CategoryTable) view
|
||||
.findViewById(R.id.category_table);
|
||||
ct.setCategory(category);
|
||||
|
||||
EditText et = (EditText)view.findViewById(R.id.search_text);
|
||||
et.setText(listUrls.getSearch());
|
||||
|
||||
@@ -23,24 +23,6 @@ import java.net.MalformedURLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.UpdateHelper;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Favorite;
|
||||
import com.hippo.ehviewer.util.Theme;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
import com.hippo.ehviewer.util.Util;
|
||||
import com.hippo.ehviewer.widget.AlertButton;
|
||||
import com.hippo.ehviewer.widget.DialogBuilder;
|
||||
import com.hippo.ehviewer.widget.FileExplorerView;
|
||||
import com.hippo.ehviewer.widget.SuperDialogUtil;
|
||||
import com.hippo.ehviewer.widget.SuperToast;
|
||||
import com.hippo.ehviewer.ehclient.EhInfo;
|
||||
import com.hippo.ehviewer.network.Downloader;
|
||||
import com.hippo.ehviewer.preference.AutoListPreference;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
@@ -67,35 +49,53 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.UpdateHelper;
|
||||
import com.hippo.ehviewer.ehclient.EhInfo;
|
||||
import com.hippo.ehviewer.network.Downloader;
|
||||
import com.hippo.ehviewer.preference.AutoListPreference;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Favorite;
|
||||
import com.hippo.ehviewer.util.Theme;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
import com.hippo.ehviewer.util.Util;
|
||||
import com.hippo.ehviewer.widget.AlertButton;
|
||||
import com.hippo.ehviewer.widget.DialogBuilder;
|
||||
import com.hippo.ehviewer.widget.FileExplorerView;
|
||||
import com.hippo.ehviewer.widget.SuperDialogUtil;
|
||||
import com.hippo.ehviewer.widget.SuperToast;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig;
|
||||
|
||||
public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
@SuppressWarnings("unused")
|
||||
private static String TAG = "Settings";
|
||||
|
||||
|
||||
public static final String KEY_FRAGMENT = "FRAGMENT";
|
||||
public static final int DEFAULT = -0x1;
|
||||
public static final int DISPLAY = 0x0;
|
||||
public static final int DATA = 0x1;
|
||||
public static final int ABOUT = 0x2;
|
||||
|
||||
|
||||
private SystemBarConfig mSystemBarConfig;
|
||||
private List<TranslucentPreferenceFragment> mFragments;
|
||||
private ListView mListView;
|
||||
private int originPaddingRight;
|
||||
private int originPaddingBottom;
|
||||
|
||||
|
||||
public void adjustPadding() {
|
||||
if (mListView != null && mSystemBarConfig != null) {
|
||||
|
||||
|
||||
switch (Ui.getOrientation(this)) {
|
||||
case Ui.ORIENTATION_PORTRAIT:
|
||||
|
||||
|
||||
mListView.setPadding(mListView.getPaddingLeft(),
|
||||
mSystemBarConfig.getStatusBarHeight() + mSystemBarConfig.getActionBarHeight(),
|
||||
originPaddingRight,
|
||||
mSystemBarConfig.getNavigationBarHeight());
|
||||
break;
|
||||
case Ui.ORIENTATION_LANDSCAPE:
|
||||
|
||||
|
||||
mListView.setPadding(mListView.getPaddingLeft(),
|
||||
mSystemBarConfig.getStatusBarHeight() + mSystemBarConfig.getActionBarHeight(),
|
||||
originPaddingRight + mSystemBarConfig.getNavigationBarWidth(),
|
||||
@@ -104,26 +104,26 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
|
||||
for (TranslucentPreferenceFragment f : mFragments) {
|
||||
if (f.isVisible()) {
|
||||
f.adjustPadding();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If no fragment is visible, just headers is shown
|
||||
adjustPadding();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
// Set random color
|
||||
int color = Config.getRandomThemeColor() ? Theme.getRandomDeepColor() : Config.getThemeColor();
|
||||
color = color & 0x00ffffff | 0xdd000000;
|
||||
@@ -131,18 +131,18 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
final ActionBar actionBar = getActionBar();
|
||||
actionBar.setBackgroundDrawable(drawable);
|
||||
mSystemBarConfig = Ui.translucent(this, color);
|
||||
|
||||
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
mFragments = new LinkedList<TranslucentPreferenceFragment>();
|
||||
|
||||
|
||||
mListView = getListView();
|
||||
mListView.setClipToPadding(false);
|
||||
originPaddingRight = mListView.getPaddingRight();
|
||||
originPaddingBottom = mListView.getPaddingBottom();
|
||||
|
||||
|
||||
adjustPadding();
|
||||
|
||||
|
||||
/*
|
||||
switch (savedInstanceState.getInt(KEY_FRAGMENT, DEFAULT)) {
|
||||
case DISPLAY:
|
||||
@@ -154,7 +154,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
@@ -162,37 +162,37 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
public SystemBarConfig getSystemBarConfig() {
|
||||
return mSystemBarConfig;
|
||||
}
|
||||
|
||||
|
||||
public List<TranslucentPreferenceFragment> getFragments() {
|
||||
return mFragments;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBuildHeaders(List<Header> target) {
|
||||
loadHeadersFromResource(R.xml.settings_headers, target);
|
||||
}
|
||||
|
||||
|
||||
private static final String[] ENTRY_FRAGMENTS = {
|
||||
DisplayFragment.class.getName(),
|
||||
EhFragment.class.getName(),
|
||||
DataFragment.class.getName(),
|
||||
AboutFragment.class.getName()
|
||||
};
|
||||
|
||||
|
||||
private static final int[] FRAGMENT_ICONS = {
|
||||
R.drawable.ic_setting_display,
|
||||
R.drawable.ic_action_panda,
|
||||
R.drawable.ic_setting_data,
|
||||
R.drawable.ic_action_info
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isValidFragment(String fragmentName) {
|
||||
for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) {
|
||||
@@ -200,20 +200,20 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static abstract class TranslucentPreferenceFragment extends PreferenceFragment {
|
||||
|
||||
|
||||
protected SettingsActivity mActivity;
|
||||
private SystemBarConfig mSystemBarConfig;
|
||||
private ListView mListView;
|
||||
private int originPaddingRight;
|
||||
private int originPaddingBottom;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mActivity = (SettingsActivity)getActivity();
|
||||
|
||||
|
||||
String fragmentName = getClass().getName();
|
||||
int fragmentIndex = -1;
|
||||
for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) {
|
||||
@@ -226,12 +226,12 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
mActivity.getActionBar().setIcon(
|
||||
FRAGMENT_ICONS[fragmentIndex]);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
SettingsActivity activity = (SettingsActivity)getActivity();
|
||||
activity.getFragments().add(this);
|
||||
|
||||
|
||||
View child;
|
||||
if (view instanceof ViewGroup
|
||||
&& (child = ((ViewGroup)view).getChildAt(0)) != null
|
||||
@@ -244,7 +244,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
adjustPadding();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void adjustPadding() {
|
||||
if (mListView != null && mSystemBarConfig != null) {
|
||||
switch (Ui.getOrientation(getActivity())) {
|
||||
@@ -254,7 +254,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
originPaddingRight,
|
||||
mSystemBarConfig.getNavigationBarHeight());
|
||||
break;
|
||||
|
||||
|
||||
case Ui.ORIENTATION_LANDSCAPE:
|
||||
mListView.setPadding(mListView.getPaddingLeft(),
|
||||
mSystemBarConfig.getStatusBarHeight() + mSystemBarConfig.getActionBarHeight(),
|
||||
@@ -265,29 +265,29 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class DisplayFragment extends TranslucentPreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
|
||||
private static final String KEY_SCREEN_ORIENTATION = "screen_orientation";
|
||||
private static final String KEY_RANDOM_THEME_COLOR = "random_theme_color";
|
||||
private static final String KEY_THEME_COLOR = "theme_color";
|
||||
|
||||
|
||||
private AutoListPreference mScreenOrientation;
|
||||
private CheckBoxPreference mRandomThemeColor;
|
||||
private Preference mThemeColor;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.display_settings);
|
||||
|
||||
|
||||
mScreenOrientation = (AutoListPreference)findPreference(KEY_SCREEN_ORIENTATION);
|
||||
mScreenOrientation.setOnPreferenceChangeListener(this);
|
||||
mRandomThemeColor = (CheckBoxPreference)findPreference(KEY_RANDOM_THEME_COLOR);
|
||||
mRandomThemeColor.setOnPreferenceChangeListener(this);
|
||||
mThemeColor = (Preference)findPreference(KEY_THEME_COLOR);
|
||||
|
||||
mThemeColor = findPreference(KEY_THEME_COLOR);
|
||||
|
||||
mThemeColor.setEnabled(!mRandomThemeColor.isChecked());
|
||||
}
|
||||
|
||||
@@ -297,47 +297,52 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
if (KEY_SCREEN_ORIENTATION.equals(key)) {
|
||||
mActivity.setRequestedOrientation(
|
||||
Config.screenOriPre2Value(Integer.parseInt((String) newValue)));
|
||||
|
||||
|
||||
} else if (KEY_RANDOM_THEME_COLOR.equals(key)) {
|
||||
new SuperToast(mActivity, R.string.restart_to_take_effect).show();
|
||||
mThemeColor.setEnabled(!(Boolean)newValue);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class EhFragment extends TranslucentPreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
implements Preference.OnPreferenceChangeListener,
|
||||
Preference.OnPreferenceClickListener {
|
||||
|
||||
private static final String KEY_LIST_DEFAULT_CATEGORY = "list_default_category";
|
||||
private static final String KEY_PREVIEW_MODE = "preview_mode";
|
||||
private static final String KEY_PREVIEW_PER_ROW = "preview_per_row";
|
||||
|
||||
|
||||
private Preference mListDefaultCategory;
|
||||
private AutoListPreference mPreviewMode;
|
||||
private EditTextPreference mPreviewPerRow;
|
||||
|
||||
|
||||
|
||||
|
||||
private void setPPREnabled(String previewMode) {
|
||||
if (previewMode.equals(Config.PREVIEW_MODE_LARGE))
|
||||
mPreviewPerRow.setEnabled(true);
|
||||
else
|
||||
mPreviewPerRow.setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.eh_settings);
|
||||
|
||||
|
||||
mListDefaultCategory = findPreference(KEY_LIST_DEFAULT_CATEGORY);
|
||||
mListDefaultCategory.setOnPreferenceClickListener(this);
|
||||
mPreviewMode = (AutoListPreference)findPreference(KEY_PREVIEW_MODE);
|
||||
mPreviewMode.setOnPreferenceChangeListener(this);
|
||||
mPreviewPerRow = (EditTextPreference)findPreference(KEY_PREVIEW_PER_ROW);
|
||||
mPreviewPerRow.setOnPreferenceChangeListener(this);
|
||||
|
||||
|
||||
mPreviewPerRow.setSummary(mPreviewPerRow.getText());
|
||||
setPPREnabled(mPreviewMode.getValue());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final String key = preference.getKey();
|
||||
@@ -345,7 +350,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
String newPreviewMode = (String)newValue;
|
||||
EhInfo.getInstance(mActivity).setPreviewMode(newPreviewMode);
|
||||
setPPREnabled(newPreviewMode);
|
||||
|
||||
|
||||
} else if (KEY_PREVIEW_PER_ROW.equals(key)) {
|
||||
try {
|
||||
int value = Integer.parseInt((String)newValue);
|
||||
@@ -356,49 +361,59 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
new SuperToast(mActivity, R.string.invalid_input, SuperToast.ERROR).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
final String key = preference.getKey();
|
||||
if (KEY_LIST_DEFAULT_CATEGORY.equals(key)) {
|
||||
DialogBuilder dialogBuilder = new DialogBuilder(mActivity)
|
||||
.setTitle("");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class DataFragment extends TranslucentPreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener,
|
||||
Preference.OnPreferenceClickListener {
|
||||
|
||||
|
||||
private static final String KEY_CACHE_SIZE = "cache_size";
|
||||
private static final String KEY_CLEAR_CACHE = "clear_cache";
|
||||
private static final String KEY_DOWNLOAD_PATH = "download_path";
|
||||
private static final String KEY_MEDIA_SCAN = "media_scan";
|
||||
private static final String KEY_DEFAULT_FAVORITE = "default_favorite";
|
||||
|
||||
|
||||
private AlertDialog mDirSelectDialog;
|
||||
|
||||
|
||||
private EditTextPreference mCacheSize;
|
||||
private Preference mClearCache;
|
||||
private Preference mDownloadPath;
|
||||
private CheckBoxPreference mMediaScan;
|
||||
private ListPreference mDefaultFavorite;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.data_settings);
|
||||
|
||||
|
||||
mCacheSize = (EditTextPreference)findPreference(KEY_CACHE_SIZE);
|
||||
mCacheSize.setOnPreferenceChangeListener(this);
|
||||
mClearCache = (Preference)findPreference(KEY_CLEAR_CACHE);
|
||||
mClearCache = findPreference(KEY_CLEAR_CACHE);
|
||||
mClearCache.setOnPreferenceClickListener(this);
|
||||
mDownloadPath = (Preference)findPreference(KEY_DOWNLOAD_PATH);
|
||||
mDownloadPath = findPreference(KEY_DOWNLOAD_PATH);
|
||||
mDownloadPath.setOnPreferenceClickListener(this);
|
||||
mMediaScan = (CheckBoxPreference)findPreference(KEY_MEDIA_SCAN);
|
||||
mMediaScan.setOnPreferenceChangeListener(this);
|
||||
mDefaultFavorite = (ListPreference)findPreference(KEY_DEFAULT_FAVORITE);
|
||||
|
||||
|
||||
// Set summary
|
||||
updateClearCacheSummary();
|
||||
mDownloadPath.setSummary(Config.getDownloadPath());
|
||||
|
||||
|
||||
int i = 0;
|
||||
String[] entrise = new String[Favorite.FAVORITE_TITLES.length + 1];
|
||||
entrise[i++] = getString(R.string.none);
|
||||
@@ -406,7 +421,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
entrise[i++] = str;
|
||||
mDefaultFavorite.setEntries(entrise);
|
||||
}
|
||||
|
||||
|
||||
private void updateClearCacheSummary() {
|
||||
/*
|
||||
if (Cache.diskCache != null) {
|
||||
@@ -422,13 +437,13 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object objValue) {
|
||||
final String key = preference.getKey();
|
||||
if (KEY_CACHE_SIZE.equals(key)) {
|
||||
/*
|
||||
|
||||
|
||||
long cacheSize = 0;
|
||||
try {
|
||||
cacheSize = Integer.parseInt((String) objValue) * 1024 * 1024;
|
||||
@@ -437,7 +452,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
.setMessage(R.string.input_error).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (cacheSize <= 0 && Cache.diskCache != null) {
|
||||
Cache.diskCache.clear();
|
||||
Cache.diskCache.close();
|
||||
@@ -466,7 +481,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -481,11 +496,11 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
} else if (KEY_DOWNLOAD_PATH.equals(key)) {
|
||||
View view = LayoutInflater.from(mActivity)
|
||||
.inflate(R.layout.dir_selection, null);
|
||||
final FileExplorerView fileExplorerView =
|
||||
final FileExplorerView fileExplorerView =
|
||||
(FileExplorerView)view.findViewById(R.id.file_list);
|
||||
final TextView warning =
|
||||
(TextView)view.findViewById(R.id.warning);
|
||||
|
||||
|
||||
String downloadPath = Config.getDownloadPath();
|
||||
DialogBuilder dialogBuilder = new DialogBuilder(mActivity)
|
||||
.setView(view, new LinearLayout.LayoutParams(
|
||||
@@ -498,7 +513,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
final EditText et = new EditText(mActivity);
|
||||
et.setText("New folder");
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
int x = Ui.dp2pix(8);
|
||||
lp.leftMargin = x;
|
||||
@@ -528,7 +543,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
.setMessage(R.string.cur_dir_not_writable).show();
|
||||
else {
|
||||
String downloadPath = fileExplorerView.getCurPath();
|
||||
|
||||
|
||||
// Update .nomedia file
|
||||
// TODO Should I delete .nomedia in old download dir ?
|
||||
if (!Config.getMediaScan()) {
|
||||
@@ -538,7 +553,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Config.setDownloadPath(downloadPath);
|
||||
mDownloadPath.setSummary(downloadPath);
|
||||
((AlertButton)v).dialog.dismiss();
|
||||
@@ -546,12 +561,12 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
}
|
||||
}).setSimpleNegativeButton();
|
||||
final TextView title = dialogBuilder.getTitleView();
|
||||
|
||||
|
||||
if (fileExplorerView.canWrite())
|
||||
warning.setVisibility(View.GONE);
|
||||
else
|
||||
warning.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
fileExplorerView.setPath(downloadPath);
|
||||
fileExplorerView.setOnItemClickListener(
|
||||
new AdapterView.OnItemClickListener() {
|
||||
@@ -566,19 +581,19 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
warning.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mDirSelectDialog = dialogBuilder.create();
|
||||
mDirSelectDialog.show();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class AboutFragment extends TranslucentPreferenceFragment
|
||||
implements Preference.OnPreferenceClickListener,
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
|
||||
private static final String KEY_AUTHOR = "author";
|
||||
private static final String KEY_CHANGELOG = "changelog";
|
||||
private static final String KEY_THANKS = "thanks";
|
||||
@@ -587,7 +602,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
private static final String KEY_CHECK_UPDATE = "check_for_update";
|
||||
private static final String KEY_ALLOW_ANALYICS = "allow_analyics";
|
||||
private static final String KEY_ABOUT_ANALYICS = "about_analyics";
|
||||
|
||||
|
||||
private Preference mAuthor;
|
||||
private Preference mChangelog;
|
||||
private Preference mThanks;
|
||||
@@ -596,27 +611,27 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
private Preference mCheckUpdate;
|
||||
private CheckBoxPreference mAllowAnalyics;
|
||||
private Preference mAboutAnalyics;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.about_settings);
|
||||
|
||||
mAuthor = (Preference)findPreference(KEY_AUTHOR);
|
||||
|
||||
mAuthor = findPreference(KEY_AUTHOR);
|
||||
mAuthor.setOnPreferenceClickListener(this);
|
||||
mChangelog = (Preference)findPreference(KEY_CHANGELOG);
|
||||
mChangelog = findPreference(KEY_CHANGELOG);
|
||||
mChangelog.setOnPreferenceClickListener(this);
|
||||
mThanks = (Preference)findPreference(KEY_THANKS);
|
||||
mThanks = findPreference(KEY_THANKS);
|
||||
mThanks.setOnPreferenceClickListener(this);
|
||||
mWebsite = (Preference)findPreference(KEY_WEBSITE);
|
||||
mWebsite = findPreference(KEY_WEBSITE);
|
||||
mWebsite.setOnPreferenceClickListener(this);
|
||||
mSource = (Preference)findPreference(KEY_SOURCE);
|
||||
mSource = findPreference(KEY_SOURCE);
|
||||
mSource.setOnPreferenceClickListener(this);
|
||||
mCheckUpdate = (Preference)findPreference(KEY_CHECK_UPDATE);
|
||||
mCheckUpdate = findPreference(KEY_CHECK_UPDATE);
|
||||
mCheckUpdate.setOnPreferenceClickListener(this);
|
||||
mAllowAnalyics = (CheckBoxPreference)findPreference(KEY_ALLOW_ANALYICS);
|
||||
mAllowAnalyics.setOnPreferenceChangeListener(this);
|
||||
mAboutAnalyics = (Preference)findPreference(KEY_ABOUT_ANALYICS);
|
||||
mAboutAnalyics = findPreference(KEY_ABOUT_ANALYICS);
|
||||
mAboutAnalyics.setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
@@ -628,14 +643,14 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
i.setData(Uri.parse("mailto:ehviewersu@gmail.com"));
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, "About EhViewer");
|
||||
startActivity(i);
|
||||
|
||||
|
||||
} else if (KEY_CHANGELOG.equals(key)) {
|
||||
InputStream is = mActivity.getResources()
|
||||
.openRawResource(R.raw.change_log);
|
||||
new DialogBuilder(mActivity).setTitle(R.string.changelog)
|
||||
.setLongMessage(Util.InputStream2String(is, "utf-8"))
|
||||
.setSimpleNegativeButton().create().show();
|
||||
|
||||
|
||||
} else if (KEY_THANKS.equals(key)) {
|
||||
InputStream is = mActivity.getResources()
|
||||
.openRawResource(R.raw.thanks);
|
||||
@@ -644,17 +659,17 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
new DialogBuilder(mActivity).setTitle(R.string.thanks)
|
||||
.setView(webView, false).setSimpleNegativeButton()
|
||||
.create().show();
|
||||
|
||||
|
||||
} else if (KEY_WEBSITE.equals(key)) {
|
||||
Uri uri = Uri.parse("http://www.ehviewer.com");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
} else if (KEY_SOURCE.equals(key)) {
|
||||
Uri uri = Uri.parse("https://github.com/seven332/EhViewer");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
} else if (KEY_CHECK_UPDATE.equals(key)) {
|
||||
mCheckUpdate.setSummary(R.string.checking_update);
|
||||
mCheckUpdate.setEnabled(false);
|
||||
@@ -704,7 +719,7 @@ public class SettingsActivity extends AbstractPreferenceActivity {
|
||||
UpdateHelper.setEnabled(true);
|
||||
}
|
||||
}).checkUpdate();
|
||||
|
||||
|
||||
} else if (KEY_ABOUT_ANALYICS.equals(key)) {
|
||||
new DialogBuilder(mActivity).setTitle(R.string.about_analyics_title)
|
||||
.setMessageAutoLink(Linkify.WEB_URLS)
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* 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.ListUrls;
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
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.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);
|
||||
}
|
||||
|
||||
private final boolean int2boolean(int integer) {
|
||||
return integer == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set each button checked or not according to category.
|
||||
*
|
||||
* @param category
|
||||
*/
|
||||
public void setCategory(int category) {
|
||||
|
||||
System.out.println("category = " + category);
|
||||
|
||||
mDoujinshi.setChecked(!int2boolean(category & ListUrls.DOUJINSHI));
|
||||
mManga.setChecked(!int2boolean(category & ListUrls.MANGA));
|
||||
mArtistCG.setChecked(!int2boolean(category & ListUrls.ARTIST_CG));
|
||||
mGameCG.setChecked(!int2boolean(category & ListUrls.GAME_CG));
|
||||
mWestern.setChecked(!int2boolean(category & ListUrls.WESTERN));
|
||||
mNonH.setChecked(!int2boolean(category & ListUrls.NON_H));
|
||||
mImageSets.setChecked(!int2boolean(category & ListUrls.IMAGE_SET));
|
||||
mCosplay.setChecked(!int2boolean(category & ListUrls.COSPLAY));
|
||||
mAsianPorn.setChecked(!int2boolean(category & ListUrls.ASIAN_PORN));
|
||||
mMisc.setChecked(!int2boolean(category & ListUrls.MISC));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category according to button.
|
||||
* @return
|
||||
*/
|
||||
public int getCategory() {
|
||||
int category = 0;
|
||||
if (!mDoujinshi.isChecked()) category |= ListUrls.DOUJINSHI;
|
||||
if (!mManga.isChecked()) category |= ListUrls.MANGA;
|
||||
if (!mArtistCG.isChecked()) category |= ListUrls.ARTIST_CG;
|
||||
if (!mGameCG.isChecked()) category |= ListUrls.GAME_CG;
|
||||
if (!mWestern.isChecked()) category |= ListUrls.WESTERN;
|
||||
if (!mNonH.isChecked()) category |= ListUrls.NON_H;
|
||||
if (!mImageSets.isChecked()) category |= ListUrls.IMAGE_SET;
|
||||
if (!mCosplay.isChecked()) category |= ListUrls.COSPLAY;
|
||||
if (!mAsianPorn.isChecked()) category |= ListUrls.ASIAN_PORN;
|
||||
if (!mMisc.isChecked()) category |= ListUrls.MISC;
|
||||
return category;
|
||||
}
|
||||
}
|
||||
@@ -21,60 +21,60 @@ import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class CheckTextView extends TextView implements OnClickListener{
|
||||
@SuppressWarnings("unused")
|
||||
private static String TAG = "CheckImage";
|
||||
|
||||
|
||||
private static int MASK = 0xbb000000;
|
||||
|
||||
|
||||
private Paint mPaint;
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("DrawAllocation")
|
||||
@Override
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (mChecked)
|
||||
canvas.drawRect(canvas.getClipBounds(), mPaint);
|
||||
}
|
||||
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
mChecked = checked;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public boolean isPressed() {
|
||||
|
||||
public boolean isChecked() {
|
||||
return mChecked;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user