Compare commits

...
206 Commits
Author SHA1 Message Date
seven332 a472d0509a 1.2.0 2018-10-25 20:08:37 +08:00
seven332 3f71a97cbd Change colorEdgeEffect 2018-10-25 19:26:06 +08:00
seven332 ed8c818d4f Adjust dark theme color 2018-10-25 18:40:27 +08:00
seven332 1db14cd998 Parse gallery list in thumbnail view 2018-10-25 16:02:04 +08:00
seven332 d06dd87ff4 Adjust text color 2018-10-25 14:32:26 +08:00
seven332 a31a64efd6 Revert textColor of ButtonInCard 2018-10-25 14:14:18 +08:00
seven332 cfa87a5a02 Adjust text color 2018-10-25 14:00:03 +08:00
seven332 2833691c34 Adjust text color 2018-10-25 13:37:25 +08:00
seven332 22d6ed8c39 Revert colorPrimary and colorAccent 2018-10-24 19:05:29 +08:00
seven332 110bae7cb7 Adjust progress view color 2018-10-22 13:45:15 +08:00
seven332 5bd7d6fae3 Adjust gallery detail header button background color 2018-10-22 13:35:59 +08:00
seven332 afa45fd8d9 Change black colorPrimary and colorAccent to grey_700 2018-10-22 13:08:16 +08:00
seven332 2c544607ec Add tagGroupBackgroundColor and tagBackgroundColor attribute 2018-10-22 13:05:38 +08:00
seven332 730b52d6cd Fix RatingBar color 2018-10-20 01:45:54 +08:00
seven332 0704579d26 Adjust card elevation 2018-10-20 01:41:20 +08:00
seven332 cb92fbad3d Don't finish the activity in second level of SettingsActivity 2018-10-19 23:07:45 +08:00
seven332 c7c6f8f706 Disable right swipe of HistoryScene 2018-10-19 23:04:06 +08:00
seven332 fdd81e21b1 Adjust card color 2018-10-19 22:54:02 +08:00
seven332 1093da6565 Update strings.xml 2018-10-19 22:13:12 +08:00
seven332 c625315a76 Apply theme to GalleryActivity 2018-10-19 22:09:04 +08:00
seven332 1deb4c2d6c Add dark widget color 2018-10-19 21:55:48 +08:00
seven332 9201b9baed Apply theme to dialog background 2018-10-19 21:52:43 +08:00
seven332 557bd9f54b Apply theme to play icon 2018-10-19 21:47:28 +08:00
seven332 0353dbdb27 Add activated color to reactive items 2018-10-19 21:45:13 +08:00
seven332 8b07cf62a9 Yellow RatingBar 2018-10-19 21:12:32 +08:00
seven332 111025cb98 Change colorControlActivated 2018-10-19 20:39:57 +08:00
seven332 b3d9c4c2b9 Apply theme to Security 2018-10-19 20:04:32 +08:00
seven332 f2695b6a2c Apply theme to some drawables 2018-10-19 19:39:52 +08:00
seven332 f6ec40e8ed Revert colorPrimary and colorAccent 2018-10-19 19:19:39 +08:00
seven332 9bc6920448 Add galleryDetailDivider attribute 2018-10-19 19:03:31 +08:00
seven332 abb8483723 Apply theme to Guides 2018-10-19 18:47:53 +08:00
seven332 81eadbb794 Apply theme to image_failed 2018-10-19 18:11:33 +08:00
seven332 22cc32778d Use system image in Html 2018-10-19 16:56:59 +08:00
seven332 c9d432b7c8 Change colorPrimary and colorAccent of dark theme and black theme 2018-10-19 16:48:53 +08:00
seven332 168a1dcfb2 Apply theme to text 2018-10-19 16:39:42 +08:00
seven332 b6718078f2 Add widgetColorThemePrimary and widgetColorThemeAccent attributes 2018-10-19 15:59:59 +08:00
seven332 960a7751ad Apply theme to ShadowLinearLayout 2018-10-19 15:34:22 +08:00
seven332 e5335de859 Apply theme to content color 2018-10-19 15:26:46 +08:00
seven332 1eb960eaf9 Clean theme 2018-10-19 14:57:09 +08:00
seven332 6bc9f0da64 Apply theme to big icons 2018-10-19 14:08:48 +08:00
seven332 f4d986a5bd Rename attributes
colorDivider -> dividerColor
colorToolbar -> toolbarColor
colorDrawablePrimary -> textColorThemeAccent
colorDrawableThemePrimary -> drawableColorPrimary
colorTextThemeAccent -> drawableColorThemePrimary
2018-10-19 13:56:33 +08:00
seven332 9aa22aab34 Apply theme to accent text 2018-10-18 23:08:31 +08:00
seven332 afa839ed0b Rename color drawable attribute
colorDrawableOpposite -> colorDrawablePrimary
colorDrawablePrimary -> colorDrawableThemePrimary
2018-10-18 23:01:57 +08:00
seven332 f2725331fe Fix duplicate clipboard text test 2018-10-18 22:20:55 +08:00
seven332 590963024a Apply theme to Ripple 2018-10-18 22:10:50 +08:00
seven332 1f55977182 Apply theme to the color of comment vote 2018-10-18 21:51:18 +08:00
seven332 4bed3d5b8e Rename colorXXXDrawable to colorDrawableXXX 2018-10-18 21:45:42 +08:00
seven332 7eab4e00e1 Replace @color/primary_text_light with ?android:attr/textColorPrimary 2018-10-18 21:39:28 +08:00
seven332 776813df17 Add colorPrimaryDrawable attribute 2018-10-18 21:36:22 +08:00
seven332 12beeedf29 Rename colorPrimaryDrawable to colorOppositeDrawable 2018-10-18 20:06:11 +08:00
seven332 d0e7f25fd9 Apply theme to AddDeleteDrawable and DrawerArrowDrawable 2018-10-18 19:58:50 +08:00
seven332 ab2a066992 Optimize themes.xml 2018-10-18 18:42:19 +08:00
seven332 596f95e463 Fix toolbarPopupTheme 2018-10-18 16:43:46 +08:00
seven332 79d07f98a8 Change Toolbar popup them 2018-10-18 15:53:42 +08:00
seven332 22ec2e8926 Change Toolbar background color 2018-10-18 15:33:53 +08:00
seven332 bc4d20d0a4 Fix SearchBar animations 2018-10-18 14:44:47 +08:00
seven332 84ed520c1c Change divider color 2018-10-18 14:37:59 +08:00
seven332 34eb6a423a Use CardView instead of card 9 png drawable 2018-10-18 13:28:07 +08:00
seven332 7dc1491c26 Use ?android:attr/windowBackground to draw background 2018-10-18 13:02:25 +08:00
seven332 6ecce9ddc5 Add dark theme and black theme 2018-10-18 12:56:56 +08:00
seven332 029373a8d2 Recreate all activities if theme changed 2018-10-18 12:44:43 +08:00
seven332 e8c06fd876 Add theme setting 2018-10-17 23:07:01 +08:00
seven332 8c9218e8af Use a non-reflect way to change how PreferenceActivity looks
Android P doesn't support invoking hidden API.
2018-10-15 22:31:53 +08:00
jerry855202 f922d41775 Fixed rCN text in rTW
"不允許螢幕抓取" was still rCN, fixed in this commit
2018-10-13 17:59:29 +08:00
seven332 e483105eb2 Android Studio 3.2.0 2018-10-10 18:26:20 +08:00
seven332 9aecb79b17 Calculate height of history item at runtime 2018-10-10 18:25:33 +08:00
seven332 bfc6bf07d9 Calculate height of download item at runtime 2018-10-10 15:51:39 +08:00
seven332 b671999e5a Calculate height of gallery list item at runtime 2018-10-10 13:13:20 +08:00
seven332 3ed2cb329c Remove the link of Google+ Community
Google+ is dying.
2018-10-09 15:20:05 +08:00
seven332 fe9970523f Avoid detecting current gallery 2018-09-23 16:00:30 +08:00
seven332 62944f7b71 Lint on release builds 2018-09-19 20:00:09 +08:00
seven332 a7e1101c87 Statement about about donation 2018-09-19 19:58:40 +08:00
seven332 b79d991b25 Set favoriteName null if isFavorited is false 2018-09-19 16:19:08 +08:00
seven332 10a15fc5cf fix: only update favoriteName after success 2018-09-19 15:50:37 +08:00
Tsukatsuki Kanade 428a5ab20e fix: change favoriteName b4 send request 2018-09-19 15:47:58 +08:00
Tsukatsuki Kanade b3d19d752b fix: update favoriteName after added favorite 2018-09-19 15:47:58 +08:00
Tsukatsuki Kanade 73b702aa56 feat: Add favorite gallery name to scene 2018-09-19 15:47:58 +08:00
hzy980512 3360035402 Fix choices of words 2018-09-18 10:19:26 +08:00
hzy980512 b97069a04e A little fix 2018-09-18 10:19:26 +08:00
hzy980512 9df8d050b2 Add some new translations 2018-09-18 10:19:26 +08:00
hzy980512 ba4ca96b77 Add some translations 2018-09-18 10:19:26 +08:00
hzy980512 fd93baf583 Add some new translations 2018-09-18 10:19:26 +08:00
hzy980512 0a9a1976cd Grammar fix 2018-09-18 10:19:26 +08:00
hzy980512 450e05c819 Make some sentences shorter 2018-09-18 10:19:26 +08:00
hzy980512 59d36d29da Fix some bugs, where quotes break the sentences 2018-09-18 10:19:26 +08:00
seven332 f0cd92f82e Check settings while try showing gallery page count 2018-09-17 11:34:32 +08:00
seven332 e847338ef4 Light background toolbar popup 2018-09-17 00:32:17 +08:00
seven332 23c34258ff Update strings.xml 2018-09-16 23:36:58 +08:00
seven332 d441960107 Update strings.xml 2018-09-16 23:35:53 +08:00
seven332 185ae6beb4 1.1.0 2018-09-16 22:18:06 +08:00
seven332 d84376e4dc Google style reorder icon 2018-09-16 22:12:26 +08:00
seven332 dcc6af3367 Update local favourites count 2018-09-14 19:48:48 +08:00
seven332 1cd8ef1b47 Back up gallery list moved from local favourites to cloud favourites 2018-09-14 19:35:02 +08:00
seven332 f8c5caf6bc Don't throw null exception 2018-09-14 19:15:39 +08:00
seven332 8e84b5b67b Update libraries 2018-09-14 13:33:32 +08:00
seven332 dc697af081 Show identity cookies 2018-09-14 13:32:03 +08:00
seven332 a69f36b652 Don't cache gif while reading
Update GLGallery
2018-09-02 14:53:33 +08:00
seven332 d5c788fe80 Add resetting reading progress 2018-09-02 01:25:43 +08:00
seven332 021fe45c8d Fix string format in zh-rTW translation 2018-09-01 20:56:43 +08:00
seven332 18881e549f Save gallery toke to saved filename 2018-08-15 21:54:35 +08:00
seven332 ed2f3510d8 Android Studio 3.1.4 2018-08-07 14:02:04 +08:00
seven332 5290340b97 Show gallery pages 2018-08-06 13:25:12 +08:00
hzy980512 9514d42032 Fix translations 2018-07-31 10:38:23 +08:00
hzy980512 2cc140eaf4 Translations fix 2018-07-31 10:38:23 +08:00
hzy980512 c4934fc89e Fix translations 2018-07-31 10:38:23 +08:00
seven332 7feb5552c1 Always print errors in EhEngine 2018-07-30 10:03:24 +08:00
seven332 fce659c41c Fix error_bad_status_code chinese string 2018-07-23 19:13:53 +08:00
seven332 2e899f5fa8 SSLException is network error 2018-07-20 14:03:43 +08:00
hzy980512 4580d781db Correct a typo 2018-07-18 12:14:16 +08:00
hzy980512 6fdab6f89c Fix a typo 2018-07-18 12:14:16 +08:00
hzy980512 145b6523e9 Fixed grammar 2018-07-18 12:14:16 +08:00
hzy980512 1d03d35685 Fix translation 2018-07-18 12:14:16 +08:00
hzy980512 71396bc632 Fix translation 2018-07-18 12:14:16 +08:00
hzy980512 511d70838a Fix more translations 2018-07-18 12:14:16 +08:00
hzy980512 1e31052767 Some fixes 2018-07-18 12:14:16 +08:00
hzy980512 e1c88c53f3 Some more corrections 2018-07-18 12:14:16 +08:00
hzy980512 de16081c79 Some corrections 2018-07-18 12:14:16 +08:00
hzy980512 e9d1ce1720 Some corrections 2018-07-18 12:14:16 +08:00
hzy980512 3bce3c41f2 Some corrections 2018-07-18 12:14:16 +08:00
hzy980512 c71729c560 Correcting sentences 2018-07-18 12:14:16 +08:00
seven332 3cbf5d0a8f Disable no media file checker at during startup 2018-07-16 13:56:07 +08:00
hzy980512 6f99f5a226 Fix translations 2018-07-12 16:48:34 +08:00
hzy980512 252dcb6175 Corrections 2018-07-12 16:48:34 +08:00
hzy980512 72971341b2 Corrections 2018-07-12 16:48:34 +08:00
hzy980512 32f4205240 Improved 2018-07-12 16:48:34 +08:00
hzy980512 36e66a8714 Grammar fix 2018-07-12 16:48:34 +08:00
hzy980512 7ee1777e7b More fixes of errors 2018-07-12 16:48:34 +08:00
hzy980512 d8dc9ad576 Fix of translation 2018-07-11 22:17:20 +08:00
hzy980512 8ae8842f81 A little fix of translation 2018-07-11 21:31:35 +08:00
hzy980512 ddb82292f9 Update strings.xml 2018-07-11 21:31:35 +08:00
hzy980512 83ade321bb A little fix 2018-07-11 21:31:35 +08:00
hzy980512 a4ea8a6bfc Add support for French and German translations 2018-07-11 21:31:35 +08:00
hzy980512 2d32852d18 Update Spanish translations (partly) 2018-07-11 21:31:35 +08:00
hzy980512 3ef3510ad3 Fix crash when there's an image in clipboard 2018-07-11 21:31:35 +08:00
hzy980512 82cb0eb7d6 Add strings for language switcher 2018-07-11 21:31:35 +08:00
hzy980512 2c428d3306 Add new languages to language switcher 2018-07-11 21:31:35 +08:00
hzy980512 5fa9e8677d Improve English translation 2018-07-11 21:31:35 +08:00
hzy980512 b57abfdc57 Add French and German translations 2018-07-11 21:31:35 +08:00
hzy980512 2f7906d3db Correct errors and update Japanese translation 2018-07-11 21:31:35 +08:00
seven332 d56f86b47e Show password toggle 2018-07-02 19:25:25 +08:00
seven332 e558be2b89 Disable clipboard check if the top scene is solid 2018-06-25 14:53:33 +08:00
seven332 66cab7b41e Close #417, click error text to refresh 2018-06-25 13:55:49 +08:00
seven332 4f431bb7ea Check ClipData null 2018-06-22 15:37:24 +08:00
seven332 d411623da6 Only save the hash code of the text in the clipboard 2018-06-21 13:42:53 +08:00
seven332 d121e839c9 Close #312, read gallery link from clipboard 2018-06-14 20:28:31 +08:00
seven332 c397bd0211 Close #276, save drawer view state 2018-06-13 15:18:48 +08:00
seven332 ec2782ddad Android Studio 3.1.3 2018-06-11 21:52:40 +08:00
scese250 6b6a60ae02 Updated spanish translation
Translated new options and updated some texts.

Thanks for keep working in this great app!!
2018-06-07 18:55:10 +08:00
seven332 f870674bd2 Use intent chooser when sharing 2018-06-05 21:03:59 +08:00
seven332 6af75a9758 1.0.30 2018-06-04 11:07:40 +08:00
seven332 e4fc925b04 Fix preview page estimation 2018-05-24 20:11:05 +08:00
seven332 2262779ba0 Close #396, fix preload pages calculation 2018-05-10 20:32:16 +08:00
lilymaniac b52cd2a619 Update Korean localization
Catch up to commit 8bad20e58c ("add option of disable auto update").
2018-05-02 22:03:06 +08:00
onlymash 8bad20e58c add option of disable auto update 2018-05-02 13:03:56 +08:00
seven332 30ca44b9c6 Android Studio 3.1.2 2018-04-28 22:47:30 +08:00
seven332 cf43ed965e Add Filter.hashCode() 2018-04-28 22:47:01 +08:00
onlymash dab29819bd make gradlew executable for linux 2018-04-28 22:29:50 +08:00
seven332 5fb090f241 No more mandatory check on igneous field 2018-04-20 09:15:59 +08:00
onlymash ff84c63445 update fav drawer 2018-04-10 22:13:37 +08:00
onlymash 140ace739e update support libs 2018-04-10 22:13:37 +08:00
onlymash 5f8c078367 rename recyclerview drawer layout 2018-04-10 22:13:37 +08:00
onlymash faddb37557 save favorites count 2018-04-10 22:13:37 +08:00
onlymash 5d8fe06d5c fix favories layout & count issue 2018-04-10 22:13:37 +08:00
seven332 2e34913c7d Android Studio 3.1.1 2018-04-10 22:10:10 +08:00
onlymash 6cc607469b update favorites list layout 2018-04-08 12:10:12 +08:00
onlymash 26eff55e6d update favorites right drawer layout 2018-04-08 12:10:12 +08:00
PYC 9a5743dd67 Correct the japanese sentence. 2018-04-02 12:02:32 +08:00
onlymash 0b547147b1 fix judgment issue 2018-04-02 11:56:56 +08:00
onlymash 6bd3bd5e80 fix judgment issue 2018-04-02 11:56:56 +08:00
onlymash af93a6730e update shortcut background 2018-03-29 19:30:58 +08:00
onlymash 27e4bd4e0b merge background color to color.xml 2018-03-29 19:30:58 +08:00
onlymash 459b27253a redraw shortcut icon 2018-03-29 19:30:58 +08:00
onlymash bb99570cd4 update shortcut foreground icon inset 2018-03-29 19:30:58 +08:00
onlymash 3f2b62c119 restore unifile 2018-03-29 19:30:58 +08:00
onlymash 91e9975a24 update shortcut 2018-03-29 19:30:58 +08:00
onlymash 00485efd0e update shortcut 2018-03-29 19:30:58 +08:00
onlymash c5d56243e0 update shortcut icon 2018-03-29 19:30:58 +08:00
onlymash b8c3229d9f add license to shortcut icon 2018-03-29 19:30:58 +08:00
onlymash 8cf935accc fix shortcuts 2018-03-29 19:30:58 +08:00
onlymash 2cf5589369 shortcuts: update icons 2018-03-29 19:30:58 +08:00
onlymash 89addaf211 update unifile 2018-03-29 19:30:58 +08:00
onlymash f5409c7b8a update shortcut 2018-03-29 19:30:58 +08:00
onlymash 733ddb5964 remove process 2018-03-29 19:30:58 +08:00
onlymash 537380eeb7 update shortcut categories 2018-03-29 19:30:58 +08:00
onlymash e44473f26b clean import 2018-03-29 19:30:58 +08:00
onlymash a503832016 update app shortcuts 2018-03-29 19:30:58 +08:00
onlymash 4935995342 update manifest 2018-03-29 19:30:58 +08:00
onlymash a367373c87 add shortcut icon for android 7.1 2018-03-29 19:30:58 +08:00
onlymash 62cd2e4809 add app shortcuts 2018-03-29 19:30:58 +08:00
seven332 7df7defa92 Save the images, which will be shared, to temp dir 2018-03-28 09:35:17 +08:00
seven332 56b42c67d5 Fix gallery favorite block 2018-03-27 18:06:05 +08:00
seven332 d1afcc2f54 Fix the parsing, language to Local 2018-03-27 17:09:09 +08:00
seven332 f6b05ed42b Fix strings 2018-03-27 16:51:01 +08:00
seven332 095334d338 Recreate all activities after changing app language 2018-03-27 14:01:05 +08:00
seven332 dac0ef178d Add RecordingApplication 2018-03-27 13:59:35 +08:00
seven332 c23a502e9e Add app language option 2018-03-27 13:40:58 +08:00
seven332 5ddd652076 Ignore past error while reading 2018-03-27 10:53:45 +08:00
seven332 3f9e3f620d Android Studio 3.1.0 2018-03-27 10:29:50 +08:00
seven332 1c62fe9615 1.0.29 2018-03-26 22:46:55 +08:00
seven332 8703102c97 Update UniFile 2018-03-26 22:45:45 +08:00
onlymash 28ab591769 update showPageDialog 2018-03-26 20:42:12 +08:00
onlymash 8cc2bfbced dynamically add dialog items 2018-03-26 20:42:12 +08:00
onlymash 7612dde6d4 clean string.xml 2018-03-26 20:42:12 +08:00
onlymash 5188fe7170 only show 'Save to...' at KiKat or higher 2018-03-26 20:42:12 +08:00
onlymash c31048e829 clean import 2018-03-26 20:42:12 +08:00
onlymash 44629bb405 support image custom save 2018-03-26 20:42:12 +08:00
188 changed files with 4626 additions and 1354 deletions

No files matched your search

+15 -14
View File
@@ -1,5 +1,3 @@
import com.android.build.gradle.internal.tasks.DefaultAndroidTask
apply plugin: 'com.android.application'
apply plugin: 'android-chinese-string'
@@ -10,11 +8,11 @@ android {
applicationId "com.hippo.ehviewer"
minSdkVersion 14
targetSdkVersion 27
versionCode 81
versionName "1.0.28"
versionCode 85
versionName "1.2.0"
vectorDrawables.useSupportLibrary = true
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW",
"es", "ja", "ko"
"es", "ja", "ko", "fr", "de"
}
compileOptions {
@@ -23,8 +21,9 @@ android {
}
lintOptions {
abortOnError false
checkReleaseBuilds false
disable 'MissingTranslation'
abortOnError true
checkReleaseBuilds true
}
buildTypes {
@@ -52,7 +51,7 @@ task copyNotice(type: Copy) {
finalizedBy ":daogenerator:executeDaoGenerator"
}
tasks.withType(DefaultAndroidTask) {
tasks.withType(JavaCompile) {
task -> task.dependsOn copyNotice
}
@@ -63,9 +62,11 @@ clean {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$supportLibrary"
implementation "com.android.support:cardview-v7:$supportLibrary"
implementation "com.android.support:design:$supportLibrary"
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
implementation 'com.github.seven332:android-recaptcha:2bbb3459a8'
implementation 'com.github.seven332:android-resource:0.1.0'
implementation 'com.github.seven332:animator:0.1.0'
implementation 'com.github.seven332:beerbelly:0.1.4'
implementation 'com.github.seven332:conaco:0.1.5-eh'
@@ -81,25 +82,25 @@ dependencies {
implementation 'com.github.seven332:ripple:0.1.2'
implementation 'com.github.seven332:streampipe:0.1.0'
implementation 'com.github.seven332:tuxiang:0.1.2'
implementation 'com.github.seven332:unifile:0.2.0'
implementation 'com.github.seven332:unifile:b59c14e47b'
implementation 'com.github.seven332:yorozuya:0.1.2'
implementation 'com.github.seven332:yorozuya-thread:0.1.1'
implementation 'com.github.seven332:yorozuya-collect:0.1.4'
implementation 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.9.2'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
implementation 'org.greenrobot:greendao:2.2.1'
implementation 'org.jsoup:jsoup:1.11.2'
implementation 'org.jsoup:jsoup:1.11.3'
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.4'
testImplementation 'org.robolectric:robolectric:3.8'
testImplementation 'org.jooq:joor:0.9.6'
}
configurations.all {
resolutionStrategy {
force 'com.github.seven332:glgallery:0f276c0'
force 'com.github.seven332:glgallery:c56b14c6fa'
force 'com.github.seven332:glview-image:4c744db'
force 'com.github.seven332:image:bab9b11'
force 'com.github.seven332:image:bbf0bbb0a0'
exclude group: 'com.github.seven332', module: 'okhttp'
}
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="start_all"
android:enabled="true"
android:icon="@drawable/ic_shortcut_start"
android:shortcutShortLabel="@string/download_start_all"
android:shortcutLongLabel="@string/download_start_all"
android:shortcutDisabledMessage="@string/download_start_all">
<intent
android:action="start_all"
android:targetPackage="com.hippo.ehviewer.debug"
android:targetClass="com.hippo.ehviewer.shortcuts.ShortcutsActivity"/>
<categories android:name="android.shortcut.conversation" />
</shortcut>
<shortcut
android:shortcutId="stop_all"
android:enabled="true"
android:icon="@drawable/ic_shortcut_stop"
android:shortcutShortLabel="@string/download_stop_all"
android:shortcutLongLabel="@string/download_stop_all"
android:shortcutDisabledMessage="@string/download_stop_all">
<intent
android:action="stop_all"
android:targetPackage="com.hippo.ehviewer.debug"
android:targetClass="com.hippo.ehviewer.shortcuts.ShortcutsActivity" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
</shortcuts>
+19 -8
View File
@@ -48,6 +48,9 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
@@ -100,50 +103,58 @@
<activity
android:name="com.hippo.ehviewer.ui.SettingsActivity"
android:configChanges="screenSize|uiMode"
android:theme="@style/AppTheme"/>
android:theme="@style/AppTheme.Settings"/>
<activity
android:name="com.hippo.ehviewer.ui.ExcludedLanguagesActivity"
android:configChanges="screenSize|uiMode"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme.Toolbar"
android:label="@string/excluded_languages"/>
<activity
android:name="com.hippo.ehviewer.ui.DirPickerActivity"
android:configChanges="screenSize|uiMode"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme.Toolbar"
android:label="@string/dir_picker"/>
<activity
android:name="com.hippo.ehviewer.ui.LicenseActivity"
android:configChanges="screenSize|uiMode"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme.Toolbar"
android:label="@string/license"/>
<activity
android:name="com.hippo.ehviewer.ui.FilterActivity"
android:configChanges="screenSize|uiMode"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme.Toolbar"
android:label="@string/filter"/>
<activity
android:name="com.hippo.ehviewer.ui.SetSecurityActivity"
android:configChanges="screenSize|uiMode"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme.Toolbar"
android:label="@string/set_pattern_protection"/>
<activity
android:name="com.hippo.ehviewer.ui.UConfigActivity"
android:configChanges="screenSize|uiMode"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme.Toolbar"
android:label="@string/u_config"/>
<activity
android:name="com.hippo.ehviewer.ui.HostsActivity"
android:configChanges="screenSize|uiMode"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/AppTheme.Toolbar"
android:label="@string/hosts"/>
<activity
android:name="com.hippo.ehviewer.shortcuts.ShortcutsActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:excludeFromRecents="true"
android:taskAffinity=""
android:launchMode="singleTask">
</activity>
<service
android:name="com.hippo.ehviewer.download.DownloadService"
android:label="@string/download_service_label"/>
@@ -0,0 +1,108 @@
/*
* Copyright 2018 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.app;
import android.content.Context;
import android.preference.PreferenceActivity;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.hippo.ehviewer.R;
import java.util.ArrayList;
import java.util.List;
public abstract class PrettyPreferenceActivity extends AppCompatPreferenceActivity {
@Override
public void setListAdapter(ListAdapter adapter) {
int count = adapter.getCount();
List<PreferenceActivity.Header> headers = new ArrayList<>(count);
for (int i = 0; i < count; ++i) {
headers.add((PreferenceActivity.Header) adapter.getItem(i));
}
super.setListAdapter(new HeaderAdapter(this, headers, R.layout.item_preference_header, true));
}
private static class HeaderAdapter extends ArrayAdapter<PreferenceActivity.Header> {
private static class HeaderViewHolder {
ImageView icon;
TextView title;
TextView summary;
}
private LayoutInflater mInflater;
private int mLayoutResId;
private boolean mRemoveIconIfEmpty;
private HeaderAdapter(Context context, List<PreferenceActivity.Header> objects, int layoutResId,
boolean removeIconBehavior) {
super(context, 0, objects);
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mLayoutResId = layoutResId;
mRemoveIconIfEmpty = removeIconBehavior;
}
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
HeaderViewHolder holder;
View view;
if (convertView == null) {
view = mInflater.inflate(mLayoutResId, parent, false);
holder = new HeaderViewHolder();
holder.icon = view.findViewById(android.R.id.icon);
holder.title = view.findViewById(android.R.id.title);
holder.summary = view.findViewById(android.R.id.summary);
view.setTag(holder);
} else {
view = convertView;
holder = (HeaderViewHolder) view.getTag();
}
// All view fields must be updated every time, because the view may be recycled
PreferenceActivity.Header header = getItem(position);
if (mRemoveIconIfEmpty) {
if (header.iconRes == 0) {
holder.icon.setVisibility(View.GONE);
} else {
holder.icon.setVisibility(View.VISIBLE);
holder.icon.setImageResource(header.iconRes);
}
} else {
holder.icon.setImageResource(header.iconRes);
}
holder.title.setText(header.getTitle(getContext().getResources()));
CharSequence summary = header.getSummary(getContext().getResources());
if (!TextUtils.isEmpty(summary)) {
holder.summary.setVisibility(View.VISIBLE);
holder.summary.setText(summary);
} else {
holder.summary.setVisibility(View.GONE);
}
return view;
}
}
}
@@ -0,0 +1,61 @@
/*
* Copyright 2018 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.content;
/*
* Created by Hippo on 2018/3/27.
*/
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.LocaleList;
import java.util.Locale;
public class ContextLocalWrapper extends ContextWrapper {
public ContextLocalWrapper(Context base) {
super(base);
}
public static ContextLocalWrapper wrap(Context context, Locale newLocale) {
Resources res = context.getResources();
Configuration configuration = res.getConfiguration();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
configuration.setLocale(newLocale);
LocaleList localeList = new LocaleList(newLocale);
LocaleList.setDefault(localeList);
configuration.setLocales(localeList);
context = context.createConfigurationContext(configuration);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
configuration.setLocale(newLocale);
context = context.createConfigurationContext(configuration);
} else {
configuration.locale = newLocale;
res.updateConfiguration(configuration, res.getDisplayMetrics());
}
return new ContextLocalWrapper(context);
}
}
@@ -0,0 +1,90 @@
/*
* Copyright 2018 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.content;
/*
* Created by Hippo on 2018/3/27.
*/
import android.app.Activity;
import android.os.Bundle;
import com.hippo.scene.SceneApplication;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public abstract class RecordingApplication extends SceneApplication {
private List<WeakReference<Activity>> list = new LinkedList<>();
@Override
public void onCreate() {
super.onCreate();
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
list.add(new java.lang.ref.WeakReference<>(activity));
}
@Override
public void onActivityDestroyed(Activity activity) {
Iterator<WeakReference<Activity>> iterator = list.iterator();
while (iterator.hasNext()) {
WeakReference<Activity> reference = iterator.next();
Activity a = reference.get();
// Remove current activity and null
if (a == null || a == activity) {
iterator.remove();
}
}
}
@Override
public void onActivityStarted(Activity activity) {}
@Override
public void onActivityResumed(Activity activity) {}
@Override
public void onActivityPaused(Activity activity) {}
@Override
public void onActivityStopped(Activity activity) {}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {}
});
}
public void recreate() {
// Copy list
ArrayList<Activity> listCopy = new ArrayList<>(list.size());
for (WeakReference<Activity> reference: list) {
Activity activity = reference.get();
if (activity == null) continue;
listCopy.add(activity);
}
// Finish all activities
for (int i = listCopy.size() - 1; i >= 0; --i) {
listCopy.get(i).recreate();
}
}
}
@@ -46,13 +46,13 @@ public class AddDeleteDrawable extends Drawable {
/**
* @param context used to get the configuration for the drawable from
*/
public AddDeleteDrawable(Context context) {
public AddDeleteDrawable(Context context, int color) {
Resources resources = context.getResources();
mSize = resources.getDimensionPixelSize(R.dimen.add_size);
float barThickness = Math.round(resources.getDimension(R.dimen.add_thickness));
mPaint.setColor(resources.getColor(R.color.primary_drawable_light));
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.MITER);
mPaint.setStrokeCap(Paint.Cap.BUTT);
@@ -28,6 +28,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorInt;
import com.hippo.ehviewer.R;
import com.hippo.yorozuya.MathUtils;
@@ -66,11 +67,11 @@ public class DrawerArrowDrawable extends Drawable {
/**
* @param context used to get the configuration for the drawable from
*/
public DrawerArrowDrawable(Context context) {
public DrawerArrowDrawable(Context context, int color) {
Resources resources = context.getResources();
mPaint.setAntiAlias(true);
mPaint.setColor(resources.getColor(R.color.primary_drawable_light));
mPaint.setColor(color);
mSize = resources.getDimensionPixelSize(R.dimen.dad_drawable_size);
// round this because having this floating may cause bad measurements
mBarSize = Math.round(resources.getDimension(R.dimen.dad_bar_size));
@@ -144,6 +145,11 @@ public class DrawerArrowDrawable extends Drawable {
canvas.restore();
}
public void setColor(@ColorInt int color) {
mPaint.setColor(color);
invalidateSelf();
}
@Override
public void setAlpha(int i) {
mPaint.setAlpha(i);
@@ -26,9 +26,9 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.LruCache;
import android.util.Log;
import com.hippo.beerbelly.SimpleDiskCache;
import com.hippo.conaco.Conaco;
import com.hippo.content.RecordingApplication;
import com.hippo.ehviewer.client.EhClient;
import com.hippo.ehviewer.client.EhCookieStore;
import com.hippo.ehviewer.client.EhDns;
@@ -40,7 +40,6 @@ import com.hippo.ehviewer.ui.CommonOperations;
import com.hippo.image.Image;
import com.hippo.image.ImageBitmap;
import com.hippo.network.StatusCodeException;
import com.hippo.scene.SceneApplication;
import com.hippo.text.Html;
import com.hippo.unifile.UniFile;
import com.hippo.util.BitmapUtils;
@@ -49,21 +48,20 @@ import com.hippo.yorozuya.FileUtils;
import com.hippo.yorozuya.IntIdGenerator;
import com.hippo.yorozuya.OSUtils;
import com.hippo.yorozuya.SimpleHandler;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
public class EhApplication extends SceneApplication implements Thread.UncaughtExceptionHandler {
public class EhApplication extends RecordingApplication implements Thread.UncaughtExceptionHandler {
private static final String TAG = EhApplication.class.getSimpleName();
public static final boolean BETA = false;
public static final boolean AUTO_UPDATE = true;
private static final boolean DEBUG_CONACO = false;
private static final boolean DEBUG_PRINT_NATIVE_MEMORY = false;
@@ -113,13 +111,14 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
Analytics.start(this);
}
// Check no media file
UniFile downloadLocation = Settings.getDownloadLocation();
if (Settings.getMediaScan()) {
CommonOperations.removeNoMediaFile(downloadLocation);
} else {
CommonOperations.ensureNoMediaFile(downloadLocation);
}
// Disable no media file checker for now. Some devices stuck here.
// // Check no media file
// UniFile downloadLocation = Settings.getDownloadLocation();
// if (Settings.getMediaScan()) {
// CommonOperations.removeNoMediaFile(downloadLocation);
// } else {
// CommonOperations.ensureNoMediaFile(downloadLocation);
// }
// Clear temp dir
clearTempDir();
@@ -149,6 +148,9 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
if (null != dir) {
FileUtils.deleteContent(dir);
}
// Add .nomedia to external temp dir
CommonOperations.ensureNoMediaFile(UniFile.fromFile(AppConfig.getExternalTempDir()));
}
private void update() {
@@ -237,6 +237,17 @@ public class Settings {
/********************
****** Eh
********************/
public static final String KEY_THEME = "theme";
public static final int THEME_LIGHT = 0;
public static final int THEME_DARK = 1;
public static final int THEME_BLACK = 2;
private static final int DEFAULT_THEME = THEME_LIGHT;
public static int getTheme() {
return getIntFromStr(KEY_THEME, DEFAULT_THEME);
}
public static final String KEY_GALLERY_SITE = "gallery_site";
private static final int DEFAULT_GALLERY_SITE = 1;
@@ -314,6 +325,13 @@ public class Settings {
return getBoolean(KEY_SHOW_JPN_TITLE, DEFAULT_SHOW_JPN_TITLE);
}
private static final String KEY_SHOW_GALLERY_PAGES = "show_gallery_pages";
private static final boolean DEFAULT_SHOW_GALLERY_PAGES = false;
public static boolean getShowGalleryPages() {
return getBoolean(KEY_SHOW_GALLERY_PAGES, DEFAULT_SHOW_GALLERY_PAGES);
}
public static final String KEY_DEFAULT_CATEGORIES = "default_categories";
public static final int DEFAULT_DEFAULT_CATEGORIES = EhUtils.ALL_CATEGORY;
@@ -718,26 +736,42 @@ public class Settings {
/********************
****** Favorites
********************/
public static final String KEY_FAV_CAT_0 = "fav_cat_0";
public static final String KEY_FAV_CAT_1 = "fav_cat_1";
public static final String KEY_FAV_CAT_2 = "fav_cat_2";
public static final String KEY_FAV_CAT_3 = "fav_cat_3";
public static final String KEY_FAV_CAT_4 = "fav_cat_4";
public static final String KEY_FAV_CAT_5 = "fav_cat_5";
public static final String KEY_FAV_CAT_6 = "fav_cat_6";
public static final String KEY_FAV_CAT_7 = "fav_cat_7";
public static final String KEY_FAV_CAT_8 = "fav_cat_8";
public static final String KEY_FAV_CAT_9 = "fav_cat_9";
public static final String DEFAULT_FAV_CAT_0 = "Favorites 0";
public static final String DEFAULT_FAV_CAT_1 = "Favorites 1";
public static final String DEFAULT_FAV_CAT_2 = "Favorites 2";
public static final String DEFAULT_FAV_CAT_3 = "Favorites 3";
public static final String DEFAULT_FAV_CAT_4 = "Favorites 4";
public static final String DEFAULT_FAV_CAT_5 = "Favorites 5";
public static final String DEFAULT_FAV_CAT_6 = "Favorites 6";
public static final String DEFAULT_FAV_CAT_7 = "Favorites 7";
public static final String DEFAULT_FAV_CAT_8 = "Favorites 8";
public static final String DEFAULT_FAV_CAT_9 = "Favorites 9";
private static final String KEY_FAV_CAT_0 = "fav_cat_0";
private static final String KEY_FAV_CAT_1 = "fav_cat_1";
private static final String KEY_FAV_CAT_2 = "fav_cat_2";
private static final String KEY_FAV_CAT_3 = "fav_cat_3";
private static final String KEY_FAV_CAT_4 = "fav_cat_4";
private static final String KEY_FAV_CAT_5 = "fav_cat_5";
private static final String KEY_FAV_CAT_6 = "fav_cat_6";
private static final String KEY_FAV_CAT_7 = "fav_cat_7";
private static final String KEY_FAV_CAT_8 = "fav_cat_8";
private static final String KEY_FAV_CAT_9 = "fav_cat_9";
private static final String DEFAULT_FAV_CAT_0 = "Favorites 0";
private static final String DEFAULT_FAV_CAT_1 = "Favorites 1";
private static final String DEFAULT_FAV_CAT_2 = "Favorites 2";
private static final String DEFAULT_FAV_CAT_3 = "Favorites 3";
private static final String DEFAULT_FAV_CAT_4 = "Favorites 4";
private static final String DEFAULT_FAV_CAT_5 = "Favorites 5";
private static final String DEFAULT_FAV_CAT_6 = "Favorites 6";
private static final String DEFAULT_FAV_CAT_7 = "Favorites 7";
private static final String DEFAULT_FAV_CAT_8 = "Favorites 8";
private static final String DEFAULT_FAV_CAT_9 = "Favorites 9";
private static final String KEY_FAV_COUNT_0 = "fav_count_0";
private static final String KEY_FAV_COUNT_1 = "fav_count_1";
private static final String KEY_FAV_COUNT_2 = "fav_count_2";
private static final String KEY_FAV_COUNT_3 = "fav_count_3";
private static final String KEY_FAV_COUNT_4 = "fav_count_4";
private static final String KEY_FAV_COUNT_5 = "fav_count_5";
private static final String KEY_FAV_COUNT_6 = "fav_count_6";
private static final String KEY_FAV_COUNT_7 = "fav_count_7";
private static final String KEY_FAV_COUNT_8 = "fav_count_8";
private static final String KEY_FAV_COUNT_9 = "fav_count_9";
private static final String KEY_FAV_LOCAL = "fav_local";
private static final String KEY_FAV_CLOUD = "fav_cloud";
private static final int DEFAULT_FAV_COUNT = 0;
public static String[] getFavCat() {
String[] favCat = new String[10];
@@ -770,6 +804,53 @@ public class Settings {
.apply();
}
public static int[] getFavCount() {
int[] favCount = new int[10];
favCount[0] = sSettingsPre.getInt(KEY_FAV_COUNT_0, DEFAULT_FAV_COUNT);
favCount[1] = sSettingsPre.getInt(KEY_FAV_COUNT_1, DEFAULT_FAV_COUNT);
favCount[2] = sSettingsPre.getInt(KEY_FAV_COUNT_2, DEFAULT_FAV_COUNT);
favCount[3] = sSettingsPre.getInt(KEY_FAV_COUNT_3, DEFAULT_FAV_COUNT);
favCount[4] = sSettingsPre.getInt(KEY_FAV_COUNT_4, DEFAULT_FAV_COUNT);
favCount[5] = sSettingsPre.getInt(KEY_FAV_COUNT_5, DEFAULT_FAV_COUNT);
favCount[6] = sSettingsPre.getInt(KEY_FAV_COUNT_6, DEFAULT_FAV_COUNT);
favCount[7] = sSettingsPre.getInt(KEY_FAV_COUNT_7, DEFAULT_FAV_COUNT);
favCount[8] = sSettingsPre.getInt(KEY_FAV_COUNT_8, DEFAULT_FAV_COUNT);
favCount[9] = sSettingsPre.getInt(KEY_FAV_COUNT_9, DEFAULT_FAV_COUNT);
return favCount;
}
public static void putFavCount(int[] count) {
Assert.assertEquals(10, count.length);
sSettingsPre.edit()
.putInt(KEY_FAV_COUNT_0, count[0])
.putInt(KEY_FAV_COUNT_1, count[1])
.putInt(KEY_FAV_COUNT_2, count[2])
.putInt(KEY_FAV_COUNT_3, count[3])
.putInt(KEY_FAV_COUNT_4, count[4])
.putInt(KEY_FAV_COUNT_5, count[5])
.putInt(KEY_FAV_COUNT_6, count[6])
.putInt(KEY_FAV_COUNT_7, count[7])
.putInt(KEY_FAV_COUNT_8, count[8])
.putInt(KEY_FAV_COUNT_9, count[9])
.apply();
}
public static int getFavLocalCount() {
return sSettingsPre.getInt(KEY_FAV_LOCAL, DEFAULT_FAV_COUNT);
}
public static void putFavLocalCount(int count) {
sSettingsPre.edit().putInt(KEY_FAV_LOCAL, count).apply();
}
public static int getFavCloudCount() {
return sSettingsPre.getInt(KEY_FAV_CLOUD, DEFAULT_FAV_COUNT);
}
public static void putFavCloudCount(int count) {
sSettingsPre.edit().putInt(KEY_FAV_CLOUD, count).apply();
}
private static final String KEY_RECENT_FAV_CAT = "recent_fav_cat";
private static final int DEFAULT_RECENT_FAV_CAT = FavListUrlBuilder.FAV_CAT_ALL;
@@ -886,6 +967,8 @@ public class Settings {
********************/
private static final String KEY_BETA_UPDATE_CHANNEL = "beta_update_channel";
private static final boolean DEFAULT_BETA_UPDATE_CHANNEL = EhApplication.BETA;
private static final String KEY_AUTO_CHECK_FOR_UPDATES = "auto_check_for_updates";
private static final boolean DEFAULT_AUTO_CHECK_FOR_UPDATES = EhApplication.AUTO_UPDATE;
public static boolean getBetaUpdateChannel() {
return getBoolean(KEY_BETA_UPDATE_CHANNEL, DEFAULT_BETA_UPDATE_CHANNEL);
@@ -895,6 +978,10 @@ public class Settings {
putBoolean(KEY_BETA_UPDATE_CHANNEL, value);
}
public static boolean getAutoCheckUpdateEnable() {
return getBoolean(KEY_AUTO_CHECK_FOR_UPDATES, DEFAULT_AUTO_CHECK_FOR_UPDATES);
}
/********************
****** Crash
********************/
@@ -963,6 +1050,17 @@ public class Settings {
putBoolean(KEY_BUILT_IN_HOSTS, value);
}
public static final String KEY_APP_LANGUAGE = "app_language";
private static final String DEFAULT_APP_LANGUAGE = "system";
public static String getAppLanguage() {
return getString(KEY_APP_LANGUAGE, DEFAULT_APP_LANGUAGE);
}
public static void putAppLanguage(String value) {
putString(KEY_APP_LANGUAGE, value);
}
/********************
****** Guide
********************/
@@ -1020,4 +1118,15 @@ public class Settings {
public static void putGuideGallery(boolean value) {
putBoolean(KEY_GUIDE_GALLERY, value);
}
private static final String KEY_CLIPBOARD_TEXT_HASH_CODE = "clipboard_text_hash_code";
private static final int DEFAULT_CLIPBOARD_TEXT_HASH_CODE = 0;
public static int getClipboardTextHashCode() {
return getInt(KEY_CLIPBOARD_TEXT_HASH_CODE, DEFAULT_CLIPBOARD_TEXT_HASH_CODE);
}
public static void putClipboardTextHashCode(int value) {
putInt(KEY_CLIPBOARD_TEXT_HASH_CODE, value);
}
}
@@ -92,7 +92,7 @@ public class EhEngine {
sEhFilter = EhFilter.getInstance();
}
private static void throwException(Call call, int code, @Nullable Headers headers,
private static void doThrowException(Call call, int code, @Nullable Headers headers,
@Nullable String body, Exception e) throws Exception {
if (call.isCanceled()) {
throw new CancelledException();
@@ -119,6 +119,20 @@ public class EhEngine {
if (code >= 400) {
throw new StatusCodeException(code);
}
if (e != null) {
throw e;
}
}
private static void throwException(Call call, int code, @Nullable Headers headers,
@Nullable String body, Exception e) throws Exception {
try {
doThrowException(call, code, headers, body, e);
} catch (Throwable error) {
error.printStackTrace();
throw error;
}
}
public static String signIn(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
@@ -197,7 +211,7 @@ public class EhEngine {
}
}
if (list.size() > 0 && (Settings.getShowJpnTitle() || sEhFilter.needCallApi())) {
if (list.size() > 0 && (Settings.getShowJpnTitle() || Settings.getShowGalleryPages() || sEhFilter.needCallApi())) {
// Fill by api
fillGalleryListByApi(task, okHttpClient, list);
@@ -893,7 +907,7 @@ public class EhEngine {
}
}
if (list.size() > 0 && (Settings.getShowJpnTitle() || sEhFilter.needCallApi())) {
if (list.size() > 0 && (Settings.getShowJpnTitle() || Settings.getShowGalleryPages() || sEhFilter.needCallApi())) {
// Fill by api
fillGalleryListByApi(task, okHttpClient, list);
@@ -17,13 +17,13 @@
package com.hippo.ehviewer.client;
import android.support.annotation.NonNull;
import android.util.Pair;
import com.hippo.ehviewer.Settings;
import com.hippo.network.UrlBuilder;
import java.util.List;
import java.util.ListIterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.HttpUrl;
public class EhUrl {
@@ -58,6 +58,8 @@ public class EhUrl {
private static final String URL_PREFIX_THUMB_E = "https://ehgt.org/t/";
private static final String URL_PREFIX_THUMB_EX = "https://exhentai.org/t/";
public static final Pattern PATTERN_DETAIL_URL = Pattern.compile("g/(\\d+)/([0-9a-f]{10})");
public static String getGalleryDetailUrl(long gid, String token) {
return getGalleryDetailUrl(gid, token, 0, false);
}
@@ -179,4 +181,13 @@ public class EhUrl {
return originUrl;
}
}
public static Pair<Long, String> parseGalleryDetailUrl(String url) {
Matcher matcher = PATTERN_DETAIL_URL.matcher(url);
if (matcher.find()) {
return new Pair<>(Long.parseLong(matcher.group(1)), matcher.group(2));
} else {
return null;
}
}
}
@@ -40,6 +40,7 @@ public class GalleryDetail extends GalleryInfo {
public GalleryComment[] comments;
public int previewPages;
public PreviewSet previewSet;
public String favoriteName;
@Override
public int describeContents() {
@@ -64,6 +65,7 @@ public class GalleryDetail extends GalleryInfo {
dest.writeParcelableArray(this.comments, 0);
dest.writeInt(this.previewPages);
dest.writeParcelable(previewSet, flags);
dest.writeString(this.favoriteName);
}
public GalleryDetail() {
@@ -96,6 +98,7 @@ public class GalleryDetail extends GalleryInfo {
}
this.previewPages = in.readInt();
this.previewSet = in.readParcelable(PreviewSet.class.getClassLoader());
this.favoriteName = in.readString();
}
public static final Creator<GalleryDetail> CREATOR = new Creator<GalleryDetail>() {
@@ -90,6 +90,7 @@ public class GalleryInfo implements Parcelable {
public float rating;
@Nullable
public String[] simpleTags;
public int pages;
public int thumbWidth;
public int thumbHeight;
@@ -53,6 +53,7 @@ public class GalleryApiParser {
tags[j] = tagJa.getString(j);
}
gi.simpleTags = tags;
gi.pages = Integer.parseInt(g.getString("filecount"));
}
}
@@ -227,6 +227,14 @@ public class GalleryDetailParser {
// isFavorited
Element gdf = gm.getElementById("gdf");
gd.isFavorited = null != gdf && !StringUtils.trim(gdf.text()).equals("Add to Favorites");
if (gdf != null) {
final String favoriteName = StringUtils.trim(gdf.text());
if (favoriteName.equals("Add to Favorites")) {
gd.favoriteName = null;
} else {
gd.favoriteName = StringUtils.trim(gdf.text());
}
}
} catch (Exception e) {
throw new ParseException("Can't parse gallery detail", body);
}
@@ -182,6 +182,60 @@ public class GalleryListParser {
return gi;
}
@Nullable
private static GalleryInfo parseGalleryInfoThumbVersion(Element e) {
GalleryInfo gi = new GalleryInfo();
// Title (required)
Element id2 = JsoupUtils.getElementByClass(e, "id2");
if (id2 == null) {
return null;
}
gi.title = id2.text().trim();
// gid, token (required)
Element a = id2.children().first();
if (a == null) {
return null;
}
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(a.attr("href"));
if (result == null) {
return null;
}
gi.gid = result.gid;
gi.token = result.token;
// Thumbnail
Element id3 = JsoupUtils.getElementByClass(e, "id3");
if (id3 != null) {
a = id3.children().first();
if (a != null) {
Element img = a.children().first();
if (img != null) {
gi.thumb = EhUtils.handleThumbUrlResolution(img.attr("src"));
}
}
}
// Category
Element id41 = JsoupUtils.getElementByClass(e, "id41");
if (id41 != null) {
gi.category = EhUtils.getCategory(id41.attr("title").trim());
} else {
gi.category = EhUtils.UNKNOWN;
}
// Rating
Element id43 = JsoupUtils.getElementByClass(e, "id43");
if (id43 != null) {
gi.rating = NumberUtils.parseFloatSafely(parseRating(id43.attr("style")), -1.0f);
} else {
gi.rating = -1.0f;
}
return gi;
}
public static Result parse(@NonNull String body) throws Exception {
Result result = new Result();
Document d = Jsoup.parse(body);
@@ -213,6 +267,23 @@ public class GalleryListParser {
throw new ParseException("Can't parse gallery list", body);
}
// Maybe it's thumbnail version
if (result.galleryInfoList.isEmpty()) {
try {
Elements es = d.getElementsByClass("itg").first().children();
List<GalleryInfo> list = new ArrayList<>(es.size() - 1);
for (int i = 0; i < es.size(); i++) {
GalleryInfo gi = parseGalleryInfoThumbVersion(es.get(i));
if (null != gi) {
list.add(gi);
}
}
result.galleryInfoList = list;
} catch (Exception e) {
throw new ParseException("Can't parse gallery list", body);
}
}
return result;
}
}
@@ -16,7 +16,9 @@
package com.hippo.ehviewer.download;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
@@ -25,8 +27,11 @@ import com.hippo.ehviewer.EhDB;
import com.hippo.ehviewer.client.data.GalleryInfo;
import com.hippo.ehviewer.dao.DownloadInfo;
import com.hippo.ehviewer.dao.DownloadLabel;
import com.hippo.ehviewer.spider.SpiderDen;
import com.hippo.ehviewer.spider.SpiderInfo;
import com.hippo.ehviewer.spider.SpiderQueen;
import com.hippo.image.Image;
import com.hippo.unifile.UniFile;
import com.hippo.yorozuya.ConcurrentPool;
import com.hippo.yorozuya.MathUtils;
import com.hippo.yorozuya.ObjectUtils;
@@ -35,6 +40,7 @@ import com.hippo.yorozuya.collect.LongList;
import com.hippo.yorozuya.collect.SparseIJArray;
import com.hippo.yorozuya.collect.SparseJLArray;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -562,6 +568,49 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
}
}
@SuppressLint("StaticFieldLeak")
public void resetAllReadingProgress() {
LinkedList<DownloadInfo> list = new LinkedList<>(mAllInfoList);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
GalleryInfo galleryInfo = new GalleryInfo();
for (DownloadInfo downloadInfo : list) {
galleryInfo.gid = downloadInfo.gid;
galleryInfo.token = downloadInfo.token;
galleryInfo.title = downloadInfo.title;
galleryInfo.thumb = downloadInfo.thumb;
galleryInfo.category = downloadInfo.category;
galleryInfo.posted = downloadInfo.posted;
galleryInfo.uploader = downloadInfo.uploader;
galleryInfo.rating = downloadInfo.rating;
UniFile downloadDir = SpiderDen.getGalleryDownloadDir(galleryInfo);
if (downloadDir == null) {
continue;
}
UniFile file = downloadDir.findFile(".ehviewer");
if (file == null) {
continue;
}
SpiderInfo spiderInfo = SpiderInfo.read(file);
if (spiderInfo == null) {
continue;
}
spiderInfo.startPage = 0;
try {
spiderInfo.write(file.openOutputStream());
} catch (IOException e) {
Log.e(TAG, "Can't write SpiderInfo", e);
}
}
return null;
}
}.execute();
}
// Update in DB
// Update listener
// No ensureDownload
@@ -73,7 +73,7 @@ public class EhGalleryProvider extends GalleryProvider2 implements SpiderQueen.O
@NonNull
@Override
public String getImageFilename(int index) {
return String.format(Locale.US, "%d-%08d", mGalleryInfo.gid, index + 1);
return String.format(Locale.US, "%d-%s-%08d", mGalleryInfo.gid, mGalleryInfo.token, index + 1);
}
@Override
@@ -0,0 +1,105 @@
/*
* Copyright 2018 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.preference;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.util.AttributeSet;
import android.widget.Toast;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.client.EhCookieStore;
import com.hippo.ehviewer.client.EhUrl;
import com.hippo.preference.MessagePreference;
import com.hippo.text.Html;
import java.util.LinkedList;
import java.util.List;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
public class IdentityCookiePreference extends MessagePreference {
private String message;
public IdentityCookiePreference(Context context) {
super(context);
init();
}
public IdentityCookiePreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public IdentityCookiePreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
EhCookieStore store = EhApplication.getEhCookieStore(getContext());
List<Cookie> eCookies = store.getCookies(HttpUrl.get(EhUrl.HOST_E));
List<Cookie> exCookies = store.getCookies(HttpUrl.get(EhUrl.HOST_EX));
List<Cookie> cookies = new LinkedList<>(eCookies);
cookies.addAll(exCookies);
String ipbMemberId = null;
String ipbPassHash = null;
String igneous = null;
for (int i = 0, n = cookies.size(); i < n; i++) {
Cookie cookie = cookies.get(i);
switch (cookie.name()) {
case EhCookieStore.KEY_IPD_MEMBER_ID:
ipbMemberId = cookie.value();
break;
case EhCookieStore.KEY_IPD_PASS_HASH:
ipbPassHash = cookie.value();
break;
case EhCookieStore.KEY_IGNEOUS:
igneous = cookie.value();
break;
}
}
if (ipbMemberId != null || ipbPassHash != null || igneous != null) {
message = EhCookieStore.KEY_IPD_MEMBER_ID + ": " + ipbMemberId + "<br>"
+ EhCookieStore.KEY_IPD_PASS_HASH + ": " + ipbPassHash + "<br>"
+ EhCookieStore.KEY_IGNEOUS + ": " + igneous;
setDialogMessage(Html.fromHtml(getContext().getString(R.string.settings_eh_identity_cookies_signed, message)));
message = message.replace("<br>", "\n");
} else {
setDialogMessage(getContext().getString(R.string.settings_eh_identity_cookies_tourist));
}
}
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder);
if (message != null) {
builder.setPositiveButton(R.string.settings_eh_identity_cookies_copy, (dialog, which) -> {
ClipboardManager cmb = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setPrimaryClip(ClipData.newPlainText(null, message));
Toast.makeText(getContext(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
IdentityCookiePreference.this.onClick(dialog, which);
});
}
}
}
@@ -0,0 +1,44 @@
/*
* Copyright 2018 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.shortcuts;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.hippo.ehviewer.download.DownloadService;
/**
* Created by onlymash on 3/25/18.
*/
public class ShortcutsActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String action = null;
Intent intent = getIntent();
if (intent != null){
action = intent.getAction();
if (action != null && (action.equals(DownloadService.ACTION_START_ALL) ||
action.equals(DownloadService.ACTION_STOP_ALL))){
startService(new Intent(this, DownloadService.class).setAction(action));
}
}
finish();
}
}
@@ -430,11 +430,11 @@ public final class SpiderQueen implements Runnable {
}
public Object forceRequest(int index) {
return request(index, true, false);
return request(index, true, true, false);
}
public Object request(int index) {
return request(index, false, true);
return request(index, true, false, true);
}
private int getPageState(int index) {
@@ -483,7 +483,7 @@ public final class SpiderQueen implements Runnable {
* Float for download percent<br>
* null for wait
*/
private Object request(int index, boolean force, boolean addNeighbor) {
private Object request(int index, boolean ignoreError, boolean force, boolean addNeighbor) {
if (mQueenThread == null) {
return null;
}
@@ -492,7 +492,8 @@ public final class SpiderQueen implements Runnable {
int state = getPageState(index);
// Fix state for force
if (force && (state == STATE_FINISHED || state == STATE_FAILED)) {
if ((force && (state == STATE_FINISHED || state == STATE_FAILED)) ||
(ignoreError && state == STATE_FAILED)) {
// Update state to none at once
updatePageState(index, STATE_NONE);
state = STATE_NONE;
@@ -518,7 +519,7 @@ public final class SpiderQueen implements Runnable {
} else {
size = Integer.MAX_VALUE;
}
for (int i = index + 1, n = index + i + mPreloadNumber; i < n && i < size; i++) {
for (int i = index + 1, n = index + 1 + mPreloadNumber; i < n && i < size; i++) {
if (STATE_NONE == getPageState(i)) {
mRequestPageQueue2.add(i);
}
@@ -713,10 +714,13 @@ public final class SpiderQueen implements Runnable {
spiderInfo.pages = GalleryDetailParser.parsePages(body);
spiderInfo.previewPages = GalleryDetailParser.parsePreviewPages(body);
PreviewSet previewSet = GalleryDetailParser.parsePreviewSet(body);
if ((index >= 0 && index < spiderInfo.pages - 1) || (index == 0 && spiderInfo.pages == 1)) {
spiderInfo.previewPerPage = previewSet.size();
} else {
spiderInfo.previewPerPage = Math.max(spiderInfo.previewPerPage, previewSet.size());
if (previewSet.size() > 0) {
if (index == 0) {
spiderInfo.previewPerPage = previewSet.size();
} else {
spiderInfo.previewPerPage = previewSet.getPosition(0) / index;
}
}
for (int i = 0, n = previewSet.size(); i < n; i++) {
@@ -762,6 +766,9 @@ public final class SpiderQueen implements Runnable {
} else {
previewIndex = 0;
}
if (spiderInfo.previewPages > 0) {
previewIndex = Math.min(previewIndex, spiderInfo.previewPages - 1);
}
try {
String url = EhUrl.getGalleryDetailUrl(
@@ -1048,6 +1055,8 @@ public final class SpiderQueen implements Runnable {
boolean interrupt = false;
boolean leakSkipHathKey = false;
Log.d("TAG", "index = " + index);
// Try twice
for (int i = 0; i < 5; i++) {
if (leakSkipHathKey) {
@@ -1400,7 +1409,7 @@ public final class SpiderQueen implements Runnable {
// Can't find the file, it might be removed from cache,
// Reset it state and request it
updatePageState(index, STATE_NONE, null);
request(index, false, false);
request(index, false, false, false);
continue;
}
@@ -33,6 +33,7 @@ import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.UrlOpener;
import com.hippo.ehviewer.client.EhClient;
import com.hippo.ehviewer.client.EhRequest;
import com.hippo.ehviewer.client.data.GalleryDetail;
import com.hippo.ehviewer.client.data.GalleryInfo;
import com.hippo.ehviewer.dao.DownloadLabel;
import com.hippo.ehviewer.download.DownloadManager;
@@ -185,27 +186,31 @@ public final class CommonOperations {
public static void addToFavorites(final Activity activity, final GalleryInfo galleryInfo,
final EhClient.Callback<Void> listener) {
int slot = Settings.getDefaultFavSlot();
String[] items = new String[11];
items[0] = activity.getString(R.string.local_favorites);
String[] favCat = Settings.getFavCat();
System.arraycopy(favCat, 0, items, 1, 10);
if (slot >= -1 && slot <= 9) {
doAddToFavorites(activity, galleryInfo, slot, listener);
String newFavoriteName = slot >= 0 ? items[slot + 1] : null;
doAddToFavorites(activity, galleryInfo, slot, galleryInfo instanceof GalleryDetail
? new UpdateFavoriteNameCallback(listener, (GalleryDetail) galleryInfo, newFavoriteName)
: listener);
} else {
String[] items = new String[11];
items[0] = activity.getString(R.string.local_favorites);
String[] favCat = Settings.getFavCat();
System.arraycopy(favCat, 0, items, 1, 10);
new ListCheckBoxDialogBuilder(activity, items,
new ListCheckBoxDialogBuilder.OnItemClickListener() {
@Override
public void onItemClick(ListCheckBoxDialogBuilder builder, AlertDialog dialog, int position) {
int slot = position - 1;
doAddToFavorites(activity, galleryInfo, slot, listener);
if (builder.isChecked()) {
Settings.putDefaultFavSlot(slot);
} else {
Settings.putDefaultFavSlot(Settings.INVALID_DEFAULT_FAV_SLOT);
}
(builder, dialog, position) -> {
int slot1 = position - 1;
String newFavoriteName = (slot1 >= 0 && slot1 <= 9) ? items[slot1+1] : null;
doAddToFavorites(activity, galleryInfo, slot1, galleryInfo instanceof GalleryDetail
? new UpdateFavoriteNameCallback(listener, (GalleryDetail) galleryInfo, newFavoriteName)
: listener);
if (builder.isChecked()) {
Settings.putDefaultFavSlot(slot1);
} else {
Settings.putDefaultFavSlot(Settings.INVALID_DEFAULT_FAV_SLOT);
}
}, activity.getString(R.string.remember_favorite_collection), false)
.setTitle(R.string.add_favorites_dialog_title)
.setOnCancelListener(dialog -> listener.onCancel())
.show();
}
}
@@ -216,10 +221,42 @@ public final class CommonOperations {
EhRequest request = new EhRequest();
request.setMethod(EhClient.METHOD_ADD_FAVORITES);
request.setArgs(galleryInfo.gid, galleryInfo.token, -1, "");
request.setCallback(listener);
request.setCallback(galleryInfo instanceof GalleryDetail
? new UpdateFavoriteNameCallback(listener, (GalleryDetail) galleryInfo, null)
: listener);
client.execute(request);
}
private static class UpdateFavoriteNameCallback implements EhClient.Callback<Void> {
private final EhClient.Callback<Void> delegate;
private final GalleryDetail detail;
private final String newFavoriteName;
UpdateFavoriteNameCallback(EhClient.Callback<Void> delegate, GalleryDetail detail,
String newFavoriteName) {
this.delegate = delegate;
this.detail = detail;
this.newFavoriteName = newFavoriteName;
}
@Override
public void onSuccess(Void result) {
detail.favoriteName = newFavoriteName;
delegate.onSuccess(result);
}
@Override
public void onFailure(Exception e) {
delegate.onFailure(e);
}
@Override
public void onCancel() {
delegate.onCancel();
}
}
// TODO Add context if activity and context are different style
public static void startDownload(final MainActivity activity, final GalleryInfo galleryInfo, boolean forceDefault) {
final DownloadManager dm = EhApplication.getDownloadManager(activity);
@@ -25,12 +25,11 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.R;
import com.hippo.ripple.Ripple;
import com.hippo.widget.DirExplorer;
import com.hippo.yorozuya.ViewUtils;
import java.io.File;
public class DirPickerActivity extends ToolbarActivity
@@ -70,7 +69,7 @@ public class DirPickerActivity extends ToolbarActivity
mDirExplorer.setCurrentFile(file);
mDirExplorer.setOnChangeDirListener(this);
Ripple.addRipple(mOk, false);
Ripple.addRipple(mOk, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme));
mOk.setOnClickListener(this);
@@ -16,22 +16,29 @@
package com.hippo.ehviewer.ui;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.WindowManager;
import com.google.analytics.tracking.android.EasyTracker;
import com.hippo.content.ContextLocalWrapper;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.Settings;
import java.util.Locale;
public abstract class EhActivity extends AppCompatActivity {
private boolean mTrackStarted;
@StyleRes
protected abstract int getThemeResId(int theme);
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(getThemeResId(Settings.getTheme()));
super.onCreate(savedInstanceState);
((EhApplication) getApplication()).registerActivity(this);
@@ -74,4 +81,26 @@ public abstract class EhActivity extends AppCompatActivity {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
}
@Override
protected void attachBaseContext(Context newBase) {
Locale locale = null;
String language = Settings.getAppLanguage();
if (language != null && !language.equals("system")) {
String[] split = language.split("-");
if (split.length == 1) {
locale = new Locale(split[0]);
} else if (split.length == 2) {
locale = new Locale(split[0], split[1]);
} else if (split.length == 3) {
locale = new Locale(split[0], split[1], split[2]);
}
}
if (locale != null) {
newBase = ContextLocalWrapper.wrap(newBase, locale);
}
super.attachBaseContext(newBase);
}
}
@@ -16,22 +16,30 @@
package com.hippo.ehviewer.ui;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.support.annotation.StyleRes;
import android.view.WindowManager;
import com.google.analytics.tracking.android.EasyTracker;
import com.hippo.app.AppCompatPreferenceActivity;
import com.hippo.app.PrettyPreferenceActivity;
import com.hippo.content.ContextLocalWrapper;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.Settings;
import java.util.Locale;
public abstract class EhPreferenceActivity extends AppCompatPreferenceActivity {
public abstract class EhPreferenceActivity extends PrettyPreferenceActivity {
private boolean mTrackStarted;
@StyleRes
protected abstract int getThemeResId(int theme);
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(getThemeResId(Settings.getTheme()));
super.onCreate(savedInstanceState);
((EhApplication) getApplication()).registerActivity(this);
@@ -74,4 +82,27 @@ public abstract class EhPreferenceActivity extends AppCompatPreferenceActivity {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
}
@Override
protected void attachBaseContext(Context newBase) {
Locale locale = null;
String language = Settings.getAppLanguage();
if (language != null && !language.equals("system")) {
String[] split = language.split("-");
if (split.length == 1) {
locale = new Locale(split[0]);
} else if (split.length == 2) {
locale = new Locale(split[0], split[1]);
} else if (split.length == 3) {
locale = new Locale(split[0], split[1], split[2]);
}
}
if (locale == null) {
locale = Resources.getSystem().getConfiguration().locale;
}
newBase = ContextLocalWrapper.wrap(newBase, locale);
super.attachBaseContext(newBase);
}
}
@@ -25,7 +25,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
@@ -164,11 +164,12 @@ public class ExcludedLanguagesActivity extends ToolbarActivity
mDeselectAll.setOnClickListener(this);
mInvertSelection.setOnClickListener(this);
Ripple.addRipple(mCancel, false);
Ripple.addRipple(mOk, false);
Ripple.addRipple(mSelectAll, false);
Ripple.addRipple(mDeselectAll, false);
Ripple.addRipple(mInvertSelection, false);
boolean isDarkTheme = !AttrResources.getAttrBoolean(this, R.attr.isLightTheme);
Ripple.addRipple(mCancel, isDarkTheme);
Ripple.addRipple(mOk, isDarkTheme);
Ripple.addRipple(mSelectAll, isDarkTheme);
Ripple.addRipple(mDeselectAll, isDarkTheme);
Ripple.addRipple(mInvertSelection, isDarkTheme);
}
private boolean isDecimal(String str) {
@@ -20,6 +20,7 @@ import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -47,7 +48,7 @@ import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.AppConfig;
import com.hippo.ehviewer.BuildConfig;
import com.hippo.ehviewer.R;
@@ -69,13 +70,17 @@ import com.hippo.util.SystemUiHelper;
import com.hippo.widget.ColorView;
import com.hippo.yorozuya.AnimationUtils;
import com.hippo.yorozuya.ConcurrentPool;
import com.hippo.yorozuya.IOUtils;
import com.hippo.yorozuya.MathUtils;
import com.hippo.yorozuya.ResourcesUtils;
import com.hippo.yorozuya.SimpleAnimatorListener;
import com.hippo.yorozuya.SimpleHandler;
import com.hippo.yorozuya.ViewUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChangeListener,
GalleryView.Listener {
@@ -94,11 +99,14 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
private static final long SLIDER_ANIMATION_DURING = 150;
private static final long HIDE_SLIDER_DELAY = 3000;
private static final int WRITE_REQUEST_CODE = 43;
private String mAction;
private String mFilename;
private Uri mUri;
private GalleryInfo mGalleryInfo;
private int mPage;
private String mCacheFileName;
@Nullable
private GLRootView mGLRootView;
@@ -173,6 +181,19 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
}
};
@Override
protected int getThemeResId(int theme) {
switch (theme) {
case Settings.THEME_LIGHT:
default:
return R.style.AppTheme_Gallery;
case Settings.THEME_DARK:
return R.style.AppTheme_Gallery_Dark;
case Settings.THEME_BLACK:
return R.style.AppTheme_Gallery_Black;
}
}
private void buildProvider() {
if (mGalleryProvider != null) {
return;
@@ -272,22 +293,21 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
mGLRootView = (GLRootView) ViewUtils.$$(this, R.id.gl_root_view);
mGalleryAdapter = new GalleryAdapter(mGLRootView, mGalleryProvider);
Resources resources = getResources();
int primaryColor = ResourcesUtils.getAttrColor(this, R.attr.colorPrimary);
mGalleryView = new GalleryView.Builder(this, mGalleryAdapter)
.setListener(this)
.setLayoutMode(Settings.getReadingDirection())
.setScaleMode(Settings.getPageScaling())
.setStartPosition(Settings.getStartPosition())
.setStartPage(startPage)
.setBackgroundColor(resources.getColor(R.color.gallery_background))
.setEdgeColor(primaryColor & 0xffffff | 0x33000000)
.setBackgroundColor(AttrResources.getAttrColor(this, android.R.attr.colorBackground))
.setEdgeColor(AttrResources.getAttrColor(this, R.attr.colorEdgeEffect) & 0xffffff | 0x33000000)
.setPagerInterval(Settings.getShowPageInterval() ? resources.getDimensionPixelOffset(R.dimen.gallery_pager_interval) : 0)
.setScrollInterval(Settings.getShowPageInterval() ? resources.getDimensionPixelOffset(R.dimen.gallery_scroll_interval) : 0)
.setPageMinHeight(resources.getDimensionPixelOffset(R.dimen.gallery_page_min_height))
.setPageInfoInterval(resources.getDimensionPixelOffset(R.dimen.gallery_page_info_interval))
.setProgressColor(primaryColor)
.setProgressColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary))
.setProgressSize(resources.getDimensionPixelOffset(R.dimen.gallery_progress_size))
.setPageTextColor(resources.getColor(R.color.secondary_text_default_dark))
.setPageTextColor(AttrResources.getAttrColor(this, android.R.attr.textColorSecondary))
.setPageTextSize(resources.getDimensionPixelOffset(R.dimen.gallery_page_text_size))
.setPageTextTypeface(Typeface.DEFAULT)
.setErrorTextColor(resources.getColor(R.color.red_500))
@@ -613,6 +633,16 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
SimpleHandler.getInstance().post(task);
}
@Override
public void onTapErrorText(int index) {
NotifyTask task = mNotifyTaskPool.pop();
if (task == null) {
task = new NotifyTask();
}
task.setData(NotifyTask.KEY_TAP_ERROR_TEXT, index);
SimpleHandler.getInstance().post(task);
}
@Override
public void onLongPressPage(int index) {
NotifyTask task = mNotifyTaskPool.pop();
@@ -837,7 +867,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
return;
}
File dir = AppConfig.getExternalImageDir();
File dir = AppConfig.getExternalTempDir();
if (null == dir) {
Toast.makeText(this, R.string.error_cant_create_temp_file, Toast.LENGTH_SHORT).show();
return;
@@ -862,17 +892,15 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
Uri uri = new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(BuildConfig.FILE_PROVIDER_AUTHORITY)
.appendPath("image")
.appendPath("temp")
.appendPath(filename)
.build();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType(mimeType);
startActivity(Intent.createChooser(intent, getString(R.string.share_image)));
// Sync media store
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, file.getUri()));
}
private void saveImage(int page) {
@@ -897,32 +925,107 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, file.getUri()));
}
private void saveImageTo(int page) {
if (null == mGalleryProvider) {
return;
}
File dir = getCacheDir();
UniFile file;
if (null == (file = mGalleryProvider.save(page, UniFile.fromFile(dir), mGalleryProvider.getImageFilename(page)))) {
Toast.makeText(this, R.string.error_cant_save_image, Toast.LENGTH_SHORT).show();
return;
}
String filename = file.getName();
if (filename == null) {
Toast.makeText(this, R.string.error_cant_save_image, Toast.LENGTH_SHORT).show();
return;
}
mCacheFileName = filename;
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_TITLE, filename);
startActivityForResult(intent, WRITE_REQUEST_CODE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
if (requestCode == WRITE_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
if (resultData != null){
Uri uri = resultData.getData();
String filepath = getCacheDir() + "/" + mCacheFileName;
File cachefile = new File(filepath);
InputStream is = null;
OutputStream os = null;
ContentResolver resolver = getContentResolver();
try {
is = new FileInputStream(cachefile);
os = resolver.openOutputStream(uri);
IOUtils.copy(is, os);
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
cachefile.delete();
Toast.makeText(this, getString(R.string.image_saved, uri.getPath()), Toast.LENGTH_SHORT).show();
// Sync media store
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri));
}
}
}
private void showPageDialog(final int page) {
Resources resources = GalleryActivity.this.getResources();
new AlertDialog.Builder(GalleryActivity.this)
.setTitle(resources.getString(R.string.page_menu_title, page + 1))
.setItems(R.array.page_menu_entries, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mGalleryProvider == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(GalleryActivity.this);
builder.setTitle(resources.getString(R.string.page_menu_title, page + 1));
switch (which) {
case 0: // Refresh
mGalleryProvider.forceRequest(page);
break;
case 1: // Share
shareImage(page);
break;
case 2: // Save
saveImage(page);
break;
case 3: // Add a bookmark
break;
}
}
}).show();
final CharSequence[] items;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
items = new CharSequence[]{
getString(R.string.page_menu_refresh),
getString(R.string.page_menu_share),
getString(R.string.page_menu_save),
getString(R.string.page_menu_save_to)};
}else {
items = new CharSequence[]{
getString(R.string.page_menu_refresh),
getString(R.string.page_menu_share),
getString(R.string.page_menu_save)};
}
pageDialogListener(builder, items, page);
builder.show();
}
private void pageDialogListener(AlertDialog.Builder builder, CharSequence[] items, int page){
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mGalleryProvider == null) {
return;
}
switch (which) {
case 0: // Refresh
mGalleryProvider.forceRequest(page);
break;
case 1: // Share
shareImage(page);
break;
case 2: // Save
saveImage(page);
break;
case 3: // Save to
saveImageTo(page);
break;
}
}
});
}
private class NotifyTask implements Runnable {
@@ -932,7 +1035,8 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
public static final int KEY_CURRENT_INDEX = 2;
public static final int KEY_TAP_SLIDER_AREA = 3;
public static final int KEY_TAP_MENU_AREA = 4;
public static final int KEY_LONG_PRESS_PAGE = 5;
public static final int KEY_TAP_ERROR_TEXT = 5;
public static final int KEY_LONG_PRESS_PAGE = 6;
private int mKey;
private int mValue;
@@ -965,6 +1069,12 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
}
}
private void onTapErrorText(int index) {
if (mGalleryProvider != null) {
mGalleryProvider.forceRequest(index);
}
}
private void onLongPressPage(final int index) {
showPageDialog(index);
}
@@ -992,6 +1102,9 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
case KEY_TAP_SLIDER_AREA:
onTapSliderArea();
break;
case KEY_TAP_ERROR_TEXT:
onTapErrorText(mValue);
break;
case KEY_LONG_PRESS_PAGE:
onLongPressPage(mValue);
break;
@@ -37,6 +37,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
import com.hippo.ehviewer.EhApplication;
@@ -81,11 +82,11 @@ public class HostsActivity extends ToolbarActivity
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL,
getResources().getColor(R.color.divider),
AttrResources.getAttrColor(this, R.attr.dividerColor),
LayoutUtils.dp2pix(this, 1));
decoration.setShowLastDivider(true);
recyclerView.addItemDecoration(decoration);
recyclerView.setSelector(Ripple.generateRippleDrawable(this, false));
recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme)));
recyclerView.setHasFixedSize(true);
recyclerView.setOnItemClickListener(this);
recyclerView.setPadding(
@@ -17,6 +17,9 @@
package com.hippo.ehviewer.ui;
import android.Manifest;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
@@ -33,18 +36,19 @@ import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import android.util.Pair;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.hippo.drawerlayout.DrawerLayout;
import com.hippo.ehviewer.AppConfig;
import com.hippo.ehviewer.Crash;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.client.EhUrl;
import com.hippo.ehviewer.client.EhUrlOpener;
import com.hippo.ehviewer.client.EhUtils;
import com.hippo.ehviewer.client.data.ListUrlBuilder;
@@ -81,8 +85,8 @@ import com.hippo.util.PermissionRequester;
import com.hippo.widget.LoadImageView;
import com.hippo.yorozuya.IOUtils;
import com.hippo.yorozuya.ResourcesUtils;
import com.hippo.yorozuya.SimpleHandler;
import com.hippo.yorozuya.ViewUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -96,6 +100,7 @@ public final class MainActivity extends StageActivity
private static final int REQUEST_CODE_SETTINGS = 0;
private static final String KEY_NAV_CHECKED_ITEM = "nav_checked_item";
private static final String KEY_CLIP_TEXT_HASH_CODE = "clip_text_hash_code";
/*---------------
Whole life cycle
@@ -113,6 +118,8 @@ public final class MainActivity extends StageActivity
private int mNavCheckedItem = 0;
private int mClipTextHashCode = 0;
static {
registerLaunchMode(SecurityScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
registerLaunchMode(WarningScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
@@ -135,6 +142,19 @@ public final class MainActivity extends StageActivity
registerLaunchMode(ProgressScene.class, SceneFragment.LAUNCH_MODE_STANDARD);
}
@Override
protected int getThemeResId(int theme) {
switch (theme) {
case Settings.THEME_LIGHT:
default:
return R.style.AppTheme_Main;
case Settings.THEME_DARK:
return R.style.AppTheme_Main_Dark;
case Settings.THEME_BLACK:
return R.style.AppTheme_Main_Black;
}
}
@Override
public int getContainerViewId() {
return R.id.fragment_container;
@@ -331,7 +351,9 @@ public final class MainActivity extends StageActivity
if (savedInstanceState == null) {
onInit();
CommonOperations.checkUpdate(this, false);
if (Settings.getAutoCheckUpdateEnable()) {
CommonOperations.checkUpdate(this, false);
}
checkDownloadLocation();
if (Settings.getCellularNetworkWarning()) {
checkCellularNetwork();
@@ -364,16 +386,20 @@ public final class MainActivity extends StageActivity
// Check permission
PermissionRequester.request(this, Manifest.permission.WRITE_EXTERNAL_STORAGE,
getString(R.string.write_rationale), PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);
mClipTextHashCode = Settings.getClipboardTextHashCode();
}
private void onRestore(Bundle savedInstanceState) {
mNavCheckedItem = savedInstanceState.getInt(KEY_NAV_CHECKED_ITEM);
mClipTextHashCode = savedInstanceState.getInt(KEY_CLIP_TEXT_HASH_CODE);
}
@Override
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
super.onSaveInstanceState(outState, outPersistentState);
outState.putInt(KEY_NAV_CHECKED_ITEM, mNavCheckedItem);
outState.putInt(KEY_CLIP_TEXT_HASH_CODE, mClipTextHashCode);
}
@Override
@@ -392,6 +418,69 @@ public final class MainActivity extends StageActivity
super.onResume();
setNavCheckedItem(mNavCheckedItem);
checkClipboardUrl();
}
@Override
protected void onTransactScene() {
super.onTransactScene();
checkClipboardUrl();
}
private void checkClipboardUrl() {
SimpleHandler.getInstance().postDelayed(() -> {
if (!isSolid()) {
checkClipboardUrlInternal();
}
}, 300);
}
private boolean isSolid() {
Class<?> topClass = getTopSceneClass();
return topClass == null || SolidScene.class.isAssignableFrom(topClass);
}
private String getTextFromClipboard() {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) {
ClipData clip = clipboard.getPrimaryClip();
if (clip != null && clip.getItemCount() > 0 && clip.getItemAt(0).getText() != null) {
return clip.getItemAt(0).getText().toString();
}
}
return null;
}
private void checkClipboardUrlInternal() {
String text = getTextFromClipboard();
int hashCode = text != null ? text.hashCode() : 0;
if (text != null && hashCode != 0 && mClipTextHashCode != hashCode && Settings.getClipboardTextHashCode() != hashCode) {
Pair<Long, String> pair = EhUrl.parseGalleryDetailUrl(text);
if (pair != null) {
long gid = pair.first;
String token = pair.second;
new AlertDialog.Builder(this)
.setTitle(R.string.clipboard_gallery_url_dialog_title)
.setMessage(R.string.clipboard_gallery_url_dialog_message)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
Bundle args = new Bundle();
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN);
args.putLong(GalleryDetailScene.KEY_GID, gid);
args.putString(GalleryDetailScene.KEY_TOKEN, token);
startScene(new Announcer(GalleryDetailScene.class).setArgs(args));
})
.show();
}
}
if (mClipTextHashCode != hashCode) {
mClipTextHashCode = hashCode;
Settings.putClipboardTextHashCode(hashCode);
}
}
@Override
@@ -413,7 +502,7 @@ public final class MainActivity extends StageActivity
if (scene instanceof BaseScene && mRightDrawer != null && mDrawerLayout != null) {
BaseScene baseScene = (BaseScene) scene;
mRightDrawer.removeAllViews();
View drawerView = baseScene.onCreateDrawerView(
View drawerView = baseScene.createDrawerView(
baseScene.getLayoutInflater2(), mRightDrawer, savedInstanceState);
if (drawerView != null) {
mRightDrawer.addView(drawerView);
@@ -430,7 +519,7 @@ public final class MainActivity extends StageActivity
if (scene instanceof BaseScene) {
BaseScene baseScene = (BaseScene) scene;
baseScene.onDestroyDrawerView();
baseScene.destroyDrawerView();
}
}
@@ -17,31 +17,22 @@
package com.hippo.ehviewer.ui;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.ui.fragment.AboutFragment;
import com.hippo.ehviewer.ui.fragment.AdvancedFragment;
import com.hippo.ehviewer.ui.fragment.DownloadFragment;
import com.hippo.ehviewer.ui.fragment.EhFragment;
import com.hippo.ehviewer.ui.fragment.ReadFragment;
import com.hippo.ehviewer.ui.fragment.PrivacyFragment;
import com.hippo.ehviewer.ui.fragment.ReadFragment;
import com.hippo.util.DrawableManager;
import java.lang.reflect.Field;
import java.util.List;
public final class SettingsActivity extends EhPreferenceActivity {
@@ -57,75 +48,17 @@ public final class SettingsActivity extends EhPreferenceActivity {
PrivacyFragment.class.getName(),
};
private class FakeLayoutInflater extends LayoutInflater {
private final LayoutInflater mInflater;
protected FakeLayoutInflater(LayoutInflater inflater) {
super(null);
mInflater = inflater;
}
@Override
public LayoutInflater cloneInContext(Context newContext) {
return null;
}
@Override
public View inflate(int resource, ViewGroup root, boolean attachToRoot) {
return mInflater.inflate(R.layout.item_preference_header, root, attachToRoot);
}
}
@SuppressWarnings("TryWithIdenticalCatches")
private void replaceHeaderLayoutResId() {
try {
ListAdapter adapter = getListAdapter();
Class headerAdapterClazz = Class.forName("android.preference.PreferenceActivity$HeaderAdapter");
if (!headerAdapterClazz.isInstance(adapter)) {
return;
}
boolean ok = false;
// For lollipop and above this work
try {
Field field = headerAdapterClazz.getDeclaredField("mLayoutResId");
field.setAccessible(true);
field.setInt(adapter, R.layout.item_preference_header);
ok = true;
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
// For pre-lollipop this work
if (!ok) {
try {
Field field = headerAdapterClazz.getDeclaredField("mInflater");
field.setAccessible(true);
field.set(adapter, new FakeLayoutInflater((LayoutInflater) field.get(adapter)));
ok = true;
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (ClassCastException e) {
e.printStackTrace();
}
}
if (ok) {
getListView().setDivider(new ColorDrawable(Color.TRANSPARENT));
getListView().setDividerHeight(0);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
@Override
protected int getThemeResId(int theme) {
switch (theme) {
case Settings.THEME_LIGHT:
default:
return R.style.AppTheme_Settings;
case Settings.THEME_DARK:
return R.style.AppTheme_Settings_Dark;
case Settings.THEME_BLACK:
return R.style.AppTheme_Settings_Black;
}
}
private void setActionBarUpIndicator(Drawable drawable) {
@@ -145,15 +78,13 @@ public final class SettingsActivity extends EhPreferenceActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24));
replaceHeaderLayoutResId();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
@@ -25,9 +25,23 @@ import android.view.View;
import android.view.ViewGroup;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
public abstract class ToolbarActivity extends EhActivity {
@Override
protected int getThemeResId(int theme) {
switch (theme) {
case Settings.THEME_LIGHT:
default:
return R.style.AppTheme_Toolbar;
case Settings.THEME_DARK:
return R.style.AppTheme_Toolbar_Dark;
case Settings.THEME_BLACK:
return R.style.AppTheme_Toolbar_Black;
}
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
super.setContentView(R.layout.activity_toolbar);
@@ -19,18 +19,20 @@ package com.hippo.ehviewer.ui.fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.support.v7.app.AlertDialog;
import android.util.Base64;
import android.widget.TextView;
import android.widget.Toast;
import com.hippo.ehviewer.Analytics;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.ui.CommonOperations;
import com.hippo.util.AppHelper;
import java.io.UnsupportedEncodingException;
public class AboutFragment extends PreferenceFragment
implements Preference.OnPreferenceClickListener {
@@ -49,14 +51,12 @@ public class AboutFragment extends PreferenceFragment
Preference checkForUpdate = findPreference(KEY_CHECK_FOR_UPDATES);
author.setSummary(getString(R.string.settings_about_author_summary).replace('$', '@'));
donate.setSummary(getString(R.string.settings_about_donate_summary).replace('$', '@'));
author.setOnPreferenceClickListener(this);
donate.setOnPreferenceClickListener(this);
checkForUpdate.setOnPreferenceClickListener(this);
}
@Override
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
@@ -64,17 +64,51 @@ public class AboutFragment extends PreferenceFragment
AppHelper.sendEmail(getActivity(), EhApplication.getDeveloperEmail(),
"About EhViewer", null);
} else if (KEY_DONATE.equals(key)) {
ClipboardManager cmb = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setPrimaryClip(ClipData.newPlainText(null, "seven332$163.com".replace('$', '@')));
Toast.makeText(getActivity(), R.string.settings_about_donate_toast, Toast.LENGTH_SHORT).show();
new AlertDialog.Builder(getActivity())
.setTitle(R.string.settings_about_donate)
.setMessage(getString(R.string.settings_about_donate_message).replace('$', '@'))
.show();
showDonationDialog();
} else if (KEY_CHECK_FOR_UPDATES.equals(key)) {
CommonOperations.checkUpdate(getActivity(), true);
}
return true;
}
private void showDonationDialog() {
AlertDialog dialog = new AlertDialog.Builder(getActivity())
.setView(R.layout.dialog_donate)
.show();
String alipayStr = base64Decode("c2V2ZW4zMzJAMTYzLmNvbQ==");
TextView alipayText = dialog.findViewById(R.id.alipay_text);
alipayText.setText(alipayStr);
dialog.findViewById(R.id.alipay_copy).setOnClickListener(v -> copyToClipboard(alipayStr));
String paypalStr = base64Decode("aHR0cHM6Ly9wYXlwYWwubWUvc2V2ZW4zMzI=");
TextView paypalText = dialog.findViewById(R.id.paypal_text);
paypalText.setText(paypalStr);
dialog.findViewById(R.id.paypal_open).setOnClickListener(v -> openUrl(paypalStr));
dialog.findViewById(R.id.paypal_copy).setOnClickListener(v -> copyToClipboard(paypalStr));
}
private static String base64Decode(String encoded) {
byte[] bytes = Base64.decode(encoded, Base64.DEFAULT);
try {
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
private void copyToClipboard(String text) {
ClipboardManager cmb = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
if (cmb != null) {
cmb.setPrimaryClip(ClipData.newPlainText(null, text));
Toast.makeText(getActivity(), R.string.settings_about_donate_copied, Toast.LENGTH_SHORT).show();
}
}
private void openUrl(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
Intent chooser = Intent.createChooser(intent, "");
startActivity(chooser);
}
}
@@ -24,24 +24,24 @@ import android.content.res.Resources;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.text.TextUtils;
import android.widget.Toast;
import com.hippo.ehviewer.AppConfig;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.EhDB;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.util.LogCat;
import com.hippo.util.ReadableTime;
import java.io.File;
import java.util.Arrays;
public class AdvancedFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
public class AdvancedFragment extends PreferenceFragment
implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
private static final String KEY_DUMP_LOGCAT = "dump_logcat";
private static final String KEY_CLEAR_MEMORY_CACHE = "clear_memory_cache";
private static final String KEY_APP_LANGUAGE = "app_language";
private static final String KEY_EXPORT_DATA = "export_data";
private static final String KEY_IMPORT_DATA = "import_data";
@@ -52,6 +52,7 @@ public class AdvancedFragment extends PreferenceFragment implements Preference.O
Preference dumpLogcat = findPreference(KEY_DUMP_LOGCAT);
Preference clearMemoryCache = findPreference(KEY_CLEAR_MEMORY_CACHE);
Preference appLanguage = findPreference(KEY_APP_LANGUAGE);
Preference exportData = findPreference(KEY_EXPORT_DATA);
Preference importData = findPreference(KEY_IMPORT_DATA);
@@ -59,6 +60,8 @@ public class AdvancedFragment extends PreferenceFragment implements Preference.O
clearMemoryCache.setOnPreferenceClickListener(this);
exportData.setOnPreferenceClickListener(this);
importData.setOnPreferenceClickListener(this);
appLanguage.setOnPreferenceChangeListener(this);
}
@Override
@@ -131,4 +134,14 @@ public class AdvancedFragment extends PreferenceFragment implements Preference.O
}
}).show();
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
if (KEY_APP_LANGUAGE.equals(key)) {
((EhApplication) getActivity().getApplication()).recreate();
return true;
}
return false;
}
}
@@ -20,7 +20,7 @@ import android.app.Activity;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
@@ -32,11 +32,13 @@ public class EhFragment extends PreferenceFragment
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.eh_settings);
Preference theme = findPreference(Settings.KEY_THEME);
Preference gallerySite = findPreference(Settings.KEY_GALLERY_SITE);
Preference listMode = findPreference(Settings.KEY_LIST_MODE);
Preference detailSize = findPreference(Settings.KEY_DETAIL_SIZE);
Preference thumbSize = findPreference(Settings.KEY_THUMB_SIZE);
theme.setOnPreferenceChangeListener(this);
gallerySite.setOnPreferenceChangeListener(this);
listMode.setOnPreferenceChangeListener(this);
detailSize.setOnPreferenceChangeListener(this);
@@ -46,7 +48,10 @@ public class EhFragment extends PreferenceFragment
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
if (Settings.KEY_GALLERY_SITE.equals(key)) {
if (Settings.KEY_THEME.equals(key)) {
((EhApplication) getActivity().getApplication()).recreate();
return true;
} else if (Settings.KEY_GALLERY_SITE.equals(key)) {
getActivity().setResult(Activity.RESULT_OK);
return true;
} else if (Settings.KEY_LIST_MODE.equals(key)) {
@@ -19,18 +19,20 @@ package com.hippo.ehviewer.ui.scene;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.annotation.StyleRes;
import android.support.v4.app.FragmentActivity;
import android.support.v4.widget.DrawerLayout;
import android.util.SparseArray;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.hippo.ehviewer.ui.MainActivity;
import com.hippo.scene.SceneFragment;
import com.hippo.util.AppHelper;
@@ -40,8 +42,16 @@ public abstract class BaseScene extends SceneFragment {
public static final int LENGTH_SHORT = 0;
public static final int LENGTH_LONG = 1;
public static final String KEY_DRAWER_VIEW_STATE =
"com.hippo.ehviewer.ui.scene.BaseScene:DRAWER_VIEW_STATE";
private Context mThemeContext;
@Nullable
private View drawerView;
@Nullable
private SparseArray<Parcelable> drawerViewState;
public void updateAvatar() {
FragmentActivity activity = getActivity();
if (activity instanceof MainActivity) {
@@ -132,11 +142,39 @@ public abstract class BaseScene extends SceneFragment {
return 0;
}
public final View createDrawerView(LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
drawerView = onCreateDrawerView(inflater, container, savedInstanceState);
if (drawerView != null) {
SparseArray<Parcelable> saved = drawerViewState;
if (saved == null && savedInstanceState != null) {
saved = savedInstanceState.getSparseParcelableArray(KEY_DRAWER_VIEW_STATE);
}
if (saved != null) {
drawerView.restoreHierarchyState(saved);
}
}
return drawerView;
}
public View onCreateDrawerView(LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return null;
}
public final void destroyDrawerView() {
if (drawerView != null) {
drawerViewState = new SparseArray<>();
drawerView.saveHierarchyState(drawerViewState);
}
onDestroyDrawerView();
drawerView = null;
}
public void onDestroyDrawerView() {
}
@@ -222,4 +260,15 @@ public abstract class BaseScene extends SceneFragment {
AppHelper.showSoftInput(activity, view);
}
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
if (drawerView != null) {
drawerViewState = new SparseArray<>();
drawerView.saveHierarchyState(drawerViewState);
outState.putSparseParcelableArray(KEY_DRAWER_VIEW_STATE, drawerViewState);
}
}
}
@@ -196,12 +196,6 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
} else {
mIpbPassHashLayout.setError(null);
}
if (TextUtils.isEmpty(igneous)) {
mIgneousLayout.setError(getString(R.string.text_is_empty));
return;
} else {
mIgneousLayout.setError(null);
}
hideSoftInput();
@@ -242,7 +236,9 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
store.addCookie(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_EX));
store.addCookie(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_E));
store.addCookie(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_EX));
store.addCookie(newCookie(EhCookieStore.KEY_IGNEOUS, igneous, EhUrl.DOMAIN_E));
store.addCookie(newCookie(EhCookieStore.KEY_IGNEOUS, igneous, EhUrl.DOMAIN_EX));
if (!igneous.isEmpty()) {
store.addCookie(newCookie(EhCookieStore.KEY_IGNEOUS, igneous, EhUrl.DOMAIN_E));
store.addCookie(newCookie(EhCookieStore.KEY_IGNEOUS, igneous, EhUrl.DOMAIN_EX));
}
}
}
@@ -21,7 +21,7 @@ import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.Crash;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
@@ -70,8 +70,9 @@ public class CrashScene extends SolidScene implements View.OnClickListener {
mCancel.setOnClickListener(this);
mSend.setOnClickListener(this);
Ripple.addRipple(mCancel, true);
Ripple.addRipple(mSend, true);
boolean isDarkTheme = !AttrResources.getAttrBoolean(getContext2(), R.attr.isLightTheme);
Ripple.addRipple(mCancel, isDarkTheme);
Ripple.addRipple(mSend, isDarkTheme);
return view;
}
@@ -50,11 +50,11 @@ import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.github.amlcurran.showcaseview.ShowcaseView;
import com.github.amlcurran.showcaseview.SimpleShowcaseEventListener;
import com.github.amlcurran.showcaseview.targets.PointTarget;
import com.github.amlcurran.showcaseview.targets.ViewTarget;
import com.hippo.android.resource.AttrResources;
import com.hippo.app.CheckBoxDialogBuilder;
import com.hippo.conaco.DataContainer;
import com.hippo.conaco.ProgressNotifier;
@@ -91,18 +91,15 @@ import com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager;
import com.hippo.yorozuya.FileUtils;
import com.hippo.yorozuya.IOUtils;
import com.hippo.yorozuya.ObjectUtils;
import com.hippo.yorozuya.ResourcesUtils;
import com.hippo.yorozuya.ViewUtils;
import com.hippo.yorozuya.collect.LongList;
import junit.framework.Assert;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import junit.framework.Assert;
public class DownloadsScene extends ToolbarScene
implements DownloadManager.DownloadInfoListener,
@@ -301,7 +298,7 @@ public class DownloadsScene extends ToolbarScene
mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
mRecyclerView.setDrawSelectorOnTop(true);
mRecyclerView.hasFixedSize();
mRecyclerView.setClipToPadding(false);
@@ -327,7 +324,7 @@ public class DownloadsScene extends ToolbarScene
fastScroller.attachToRecyclerView(mRecyclerView);
HandlerDrawable handlerDrawable = new HandlerDrawable();
handlerDrawable.setColor(ResourcesUtils.getAttrColor(context, R.attr.colorAccent));
handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
fastScroller.setHandlerDrawable(handlerDrawable);
fastScroller.setOnDragHandlerListener(this);
@@ -489,6 +486,17 @@ public class DownloadsScene extends ToolbarScene
}
return true;
}
case R.id.action_reset_reading_progress: {
new AlertDialog.Builder(getContext())
.setMessage(R.string.reset_reading_progress_message)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
if (mDownloadManager != null) {
mDownloadManager.resetAllReadingProgress();
}
}).show();
return true;
}
}
return false;
}
@@ -635,7 +643,7 @@ public class DownloadsScene extends ToolbarScene
if (list == null) {
return false;
}
if (position < 0 && position >= list.size()) {
if (position < 0 || position >= list.size()) {
return false;
}
@@ -1074,8 +1082,10 @@ public class DownloadsScene extends ToolbarScene
thumb.setOnClickListener(this);
start.setOnClickListener(this);
stop.setOnClickListener(this);
Ripple.addRipple(start, false);
Ripple.addRipple(stop, false);
boolean isDarkTheme = !AttrResources.getAttrBoolean(getContext2(), R.attr.isLightTheme);
Ripple.addRipple(start, isDarkTheme);
Ripple.addRipple(stop, isDarkTheme);
}
@Override
@@ -1092,7 +1102,7 @@ public class DownloadsScene extends ToolbarScene
}
int size = list.size();
int index = recyclerView.getChildAdapterPosition(itemView);
if (index < 0 && index >= size) {
if (index < 0 || index >= size) {
return;
}
@@ -1121,10 +1131,17 @@ public class DownloadsScene extends ToolbarScene
private class DownloadAdapter extends RecyclerView.Adapter<DownloadHolder> {
private final LayoutInflater mInflater;
private final int mListThumbWidth;
private final int mListThumbHeight;
public DownloadAdapter() {
mInflater = getLayoutInflater2();
Assert.assertNotNull(mInflater);
View calculator = mInflater.inflate(R.layout.item_gallery_list_thumb_height, null);
ViewUtils.measureView(calculator, 1024, ViewGroup.LayoutParams.WRAP_CONTENT);
mListThumbHeight = calculator.getMeasuredHeight();
mListThumbWidth = mListThumbHeight * 2 / 3;
}
@Override
@@ -1137,7 +1154,14 @@ public class DownloadsScene extends ToolbarScene
@Override
public DownloadHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new DownloadHolder(mInflater.inflate(R.layout.item_download, parent, false));
DownloadHolder holder = new DownloadHolder(mInflater.inflate(R.layout.item_download, parent, false));
ViewGroup.LayoutParams lp = holder.thumb.getLayoutParams();
lp.width = mListThumbWidth;
lp.height = mListThumbHeight;
holder.thumb.setLayoutParams(lp);
return holder;
}
@Override
@@ -29,6 +29,7 @@ import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
@@ -43,19 +44,16 @@ import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.github.amlcurran.showcaseview.ShowcaseView;
import com.github.amlcurran.showcaseview.SimpleShowcaseEventListener;
import com.github.amlcurran.showcaseview.targets.PointTarget;
import com.hippo.android.resource.AttrResources;
import com.hippo.annotation.Implemented;
import com.hippo.drawable.DrawerArrowDrawable;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.FastScroller;
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.EhDB;
import com.hippo.ehviewer.R;
@@ -70,6 +68,7 @@ import com.hippo.ehviewer.ui.MainActivity;
import com.hippo.ehviewer.ui.annotation.DrawerLifeCircle;
import com.hippo.ehviewer.ui.annotation.ViewLifeCircle;
import com.hippo.ehviewer.ui.annotation.WholeLifeCircle;
import com.hippo.ehviewer.widget.EhDrawerLayout;
import com.hippo.ehviewer.widget.SearchBar;
import com.hippo.refreshlayout.RefreshLayout;
import com.hippo.ripple.Ripple;
@@ -80,9 +79,7 @@ import com.hippo.util.DrawableManager;
import com.hippo.widget.ContentLayout;
import com.hippo.widget.FabLayout;
import com.hippo.widget.SearchBarMover;
import com.hippo.yorozuya.LayoutUtils;
import com.hippo.yorozuya.ObjectUtils;
import com.hippo.yorozuya.ResourcesUtils;
import com.hippo.yorozuya.SimpleHandler;
import com.hippo.yorozuya.ViewUtils;
@@ -96,7 +93,7 @@ import java.util.List;
public class FavoritesScene extends BaseScene implements
EasyRecyclerView.OnItemClickListener, EasyRecyclerView.OnItemLongClickListener,
FastScroller.OnDragHandlerListener, SearchBarMover.Helper, SearchBar.Helper,
FabLayout.OnClickFabListener, EasyRecyclerView.CustomChoiceListener, AdapterView.OnItemClickListener {
FabLayout.OnClickFabListener, EasyRecyclerView.CustomChoiceListener {
private static final long ANIMATE_TIME = 300L;
@@ -129,12 +126,11 @@ public class FavoritesScene extends BaseScene implements
private DrawerArrowDrawable mLeftDrawable;
@Nullable
@DrawerLifeCircle
private ArrayAdapter<String> mDrawerAdapter;
private EhDrawerLayout mDrawerLayout;
@Nullable
@DrawerLifeCircle
private List<String> mDrawerList;
private FavDrawerAdapter mDrawerAdapter;
@Nullable
@WholeLifeCircle
private EhClient mClient;
@@ -143,13 +139,16 @@ public class FavoritesScene extends BaseScene implements
private String[] mFavCatArray;
@Nullable
@WholeLifeCircle
private int[] mFavCountArray;
@Nullable
@WholeLifeCircle
private FavListUrlBuilder mUrlBuilder;
public int current; // -1 for error
public int limit; // -1 for error
@Nullable
private int[] mFavCountArray;
private int mFavLocalCount = 0;
private int mFavCountSum = 0;
private boolean mHasFirstRefresh;
private boolean mSearchMode;
@@ -181,6 +180,9 @@ public class FavoritesScene extends BaseScene implements
Assert.assertNotNull(context);
mClient = EhApplication.getEhClient(context);
mFavCatArray = Settings.getFavCat();
mFavCountArray = Settings.getFavCount();
mFavLocalCount = Settings.getFavLocalCount();
mFavCountSum = Settings.getFavCloudCount();
if (savedInstanceState == null) {
onInit();
@@ -206,7 +208,7 @@ public class FavoritesScene extends BaseScene implements
}
@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
boolean hasFirstRefresh;
@@ -227,6 +229,8 @@ public class FavoritesScene extends BaseScene implements
mClient = null;
mFavCatArray = null;
mFavCountArray = null;
mFavCountSum = 0;
mUrlBuilder = null;
}
@@ -236,6 +240,9 @@ public class FavoritesScene extends BaseScene implements
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.scene_favorites, container, false);
ContentLayout contentLayout = (ContentLayout) view.findViewById(R.id.content_layout);
MainActivity activity = getActivity2();
Assert.assertNotNull(activity);
mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(activity, R.id.draw_view);
mRecyclerView = contentLayout.getRecyclerView();
FastScroller fastScroller = contentLayout.getFastScroller();
RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
@@ -253,7 +260,7 @@ public class FavoritesScene extends BaseScene implements
contentLayout.getFastScroller().setOnDragHandlerListener(this);
mAdapter = new FavoritesAdapter(inflater, resources, mRecyclerView, Settings.getListMode());
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
mRecyclerView.setDrawSelectorOnTop(true);
mRecyclerView.hasFixedSize();
mRecyclerView.setClipToPadding(false);
@@ -267,7 +274,7 @@ public class FavoritesScene extends BaseScene implements
refreshLayout.setHeaderTranslationY(paddingTopSB);
mLeftDrawable = new DrawerArrowDrawable(context);
mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
mSearchBar.setLeftDrawable(mLeftDrawable);
mSearchBar.setRightDrawable(DrawableManager.getDrawable(context, R.drawable.v_magnify_x24));
mSearchBar.setHelper(this);
@@ -410,95 +417,76 @@ public class FavoritesScene extends BaseScene implements
mOldKeyword = null;
}
private class InfoHolder extends RecyclerView.ViewHolder {
private class FavDrawerHolder extends RecyclerView.ViewHolder {
private final TextView key;
private final TextView value;
public InfoHolder(View itemView) {
private FavDrawerHolder(View itemView) {
super(itemView);
key = (TextView) ViewUtils.$$(itemView, R.id.key);
value = (TextView) ViewUtils.$$(itemView, R.id.value);
}
}
private class InfoAdapter extends RecyclerView.Adapter<InfoHolder> {
private static final int TYPE_HEADER = 0;
private static final int TYPE_DATA = 1;
private class FavDrawerAdapter extends RecyclerView.Adapter<FavDrawerHolder> {
private final LayoutInflater mInflater;
public InfoAdapter(LayoutInflater inflater) {
private FavDrawerAdapter(LayoutInflater inflater) {
mInflater = inflater;
}
@Override
public int getItemViewType(int position) {
return 0 == position ? TYPE_HEADER : TYPE_DATA;
return position;
}
@NonNull
@Override
public InfoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new InfoHolder(mInflater.inflate(TYPE_HEADER == viewType ?
R.layout.item_favorite_info_header : R.layout.item_favorite_info_data, parent, false));
public FavDrawerHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new FavDrawerHolder(mInflater.inflate(R.layout.item_drawer_favorites, parent, false));
}
@Override
@SuppressLint("SetTextI18n")
public void onBindViewHolder(InfoHolder holder, int position) {
public void onBindViewHolder(@NonNull FavDrawerHolder holder, int position) {
if (0 == position) {
holder.key.setText(R.string.collections);
holder.value.setText(R.string.count);
holder.itemView.setEnabled(false);
holder.key.setText(R.string.local_favorites);
holder.value.setText(Integer.toString(mFavLocalCount));
holder.itemView.setEnabled(true);
} else if (1 == position){
holder.key.setText(R.string.cloud_favorites);
holder.value.setText(Integer.toString(mFavCountSum));
holder.itemView.setEnabled(true);
} else {
if (null == mFavCatArray || null == mFavCountArray ||
mFavCatArray.length < position || mFavCountArray.length < position) {
mFavCatArray.length < (position - 1) ||
mFavCountArray.length < (position - 1)) {
return;
}
holder.key.setText(mFavCatArray[position - 1]);
holder.value.setText(Integer.toString(mFavCountArray[position - 1]));
holder.key.setText(mFavCatArray[position - 2]);
holder.value.setText(Integer.toString(mFavCountArray[position - 2]));
holder.itemView.setEnabled(true);
}
}
@Override
public int getItemCount() {
return 11;
if (null == mFavCatArray) {
return 2;
}
return 12;
}
}
@SuppressLint("InflateParams")
private void showFavoritesInfoDialog() {
Context context = getContext2();
if (null == context || null == mFavCatArray || null == mFavCountArray) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
context = builder.getContext();
final LayoutInflater inflater = LayoutInflater.from(context);
EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_recycler_view, null);
rv.setAdapter(new InfoAdapter(inflater));
rv.setLayoutManager(new LinearLayoutManager(context));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider),
LayoutUtils.dp2pix(context, 1));
decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
rv.addItemDecoration(decoration);
rv.setSelector(Ripple.generateRippleDrawable(context, false));
rv.setClipToPadding(false);
builder.setView(rv).show();
}
@Override
public View onCreateDrawerView(LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.drawer_list, container, false);
Toolbar toolbar = (Toolbar) ViewUtils.$$(view, R.id.toolbar);
ListView listView = (ListView) view.findViewById(R.id.list_view);
View view = inflater.inflate(R.layout.drawer_list_rv, container, false);
final Context context = getContext2();
Toolbar toolbar = (Toolbar) ViewUtils.$$(view, R.id.toolbar);
Assert.assertNotNull(context);
toolbar.setTitle(R.string.collections);
@@ -508,9 +496,6 @@ public class FavoritesScene extends BaseScene implements
public boolean onMenuItemClick(MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.action_info:
showFavoritesInfoDialog();
return true;
case R.id.action_default_favorites_slot:
String[] items = new String[12];
items[0] = getString(R.string.let_me_select);
@@ -531,15 +516,13 @@ public class FavoritesScene extends BaseScene implements
}
});
mDrawerList = new ArrayList<>(12);
mDrawerList.add(getString(R.string.local_favorites));
mDrawerList.add(getString(R.string.cloud_favorites));
if (mFavCatArray != null) {
Collections.addAll(mDrawerList, mFavCatArray);
}
mDrawerAdapter = new ArrayAdapter<>(context, R.layout.item_simple_list, mDrawerList);
listView.setAdapter(mDrawerAdapter);
listView.setOnItemClickListener(this);
EasyRecyclerView recyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view_drawer);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
mDrawerAdapter = new FavDrawerAdapter(inflater);
recyclerView.setAdapter(mDrawerAdapter);
recyclerView.setOnItemClickListener(this);
return view;
}
@@ -549,7 +532,6 @@ public class FavoritesScene extends BaseScene implements
super.onDestroyDrawerView();
mDrawerAdapter = null;
mDrawerList = null;
}
@Override
@@ -590,19 +572,53 @@ public class FavoritesScene extends BaseScene implements
@Override
@Implemented(EasyRecyclerView.OnItemClickListener.class)
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
mRecyclerView.toggleItemChecked(position);
} else if (mHelper != null) {
GalleryInfo gi = mHelper.getDataAt(position);
Bundle args = new Bundle();
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
View thumb;
if (ApiHelper.SUPPORT_TRANSITION && null != (thumb = view.findViewById(R.id.thumb))) {
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(Gravity.RIGHT)){
// Skip if in search mode
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
return true;
}
if (mUrlBuilder == null || mHelper == null) {
return true;
}
// Local favorite position is 0, All favorite position is 1, so position - 2 is OK
int newFavCat = position - 2;
// Check is the same
if (mUrlBuilder.getFavCat() == newFavCat) {
return true;
}
// Ensure outOfCustomChoiceMode to avoid error
if (mRecyclerView != null) {
mRecyclerView.isInCustomChoice();
}
exitSearchMode(true);
mUrlBuilder.setKeyword(null);
mUrlBuilder.setFavCat(newFavCat);
updateSearchBar();
mHelper.refresh();
closeDrawer(Gravity.RIGHT);
} else {
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
mRecyclerView.toggleItemChecked(position);
} else if (mHelper != null) {
GalleryInfo gi = mHelper.getDataAt(position);
Bundle args = new Bundle();
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
View thumb;
if (ApiHelper.SUPPORT_TRANSITION && null != (thumb = view.findViewById(R.id.thumb))) {
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
}
startScene(announcer);
}
startScene(announcer);
}
return true;
}
@@ -805,41 +821,6 @@ public class FavoritesScene extends BaseScene implements
}
}
@Override
@Implemented(AdapterView.OnItemClickListener.class)
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Skip if in search mode
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
return;
}
if (mUrlBuilder == null || mHelper == null) {
return;
}
// Local favorite position is 0, All favorite position is 1, so position - 2 is OK
int newFavCat = position - 2;
// Check is the same
if (mUrlBuilder.getFavCat() == newFavCat) {
return;
}
// Ensure outOfCustomChoiceMode to avoid error
if (mRecyclerView != null) {
mRecyclerView.isInCustomChoice();
}
exitSearchMode(true);
mUrlBuilder.setKeyword(null);
mUrlBuilder.setFavCat(newFavCat);
updateSearchBar();
mHelper.refresh();
closeDrawer(Gravity.RIGHT);
}
private void enterSearchMode(boolean animation) {
if (mSearchMode ||mSearchBar == null || mSearchBarMover == null || mLeftDrawable == null) {
return;
@@ -864,22 +845,26 @@ public class FavoritesScene extends BaseScene implements
if (mHelper != null && mSearchBarMover != null &&
mHelper.isCurrentTask(taskId)) {
if (mFavCatArray != null && mDrawerList != null) {
for (int i = 0; i < 10; i++) {
mFavCatArray[i] = result.catArray[i];
mDrawerList.set(i + 2, result.catArray[i]);
}
if (mDrawerAdapter != null) {
mDrawerAdapter.notifyDataSetChanged();
}
if (mFavCatArray != null) {
System.arraycopy(result.catArray, 0, mFavCatArray, 0,10);
}
mFavCountArray = result.countArray;
if (mFavCountArray != null){
mFavCountSum = 0;
for (int i = 0; i < 10; i++ ){
mFavCountSum = mFavCountSum + mFavCountArray[i];
}
Settings.putFavCloudCount(mFavCountSum);
}
updateSearchBar();
mHelper.setPages(taskId, result.pages);
mHelper.onGetPageData(taskId, result.galleryInfoList);
if (mDrawerAdapter != null) {
mDrawerAdapter.notifyDataSetChanged();
}
}
}
@@ -899,6 +884,7 @@ public class FavoritesScene extends BaseScene implements
} else {
list = EhDB.searchLocalFavorites(keyword);
}
if (list.size() == 0) {
mHelper.setPages(taskId, 0);
mHelper.onGetPageData(taskId, Collections.EMPTY_LIST);
@@ -906,6 +892,14 @@ public class FavoritesScene extends BaseScene implements
mHelper.setPages(taskId, 1);
mHelper.onGetPageData(taskId, list);
}
if (TextUtils.isEmpty(keyword)) {
mFavLocalCount = list.size();
Settings.putFavLocalCount(mFavLocalCount);
if (mDrawerAdapter != null) {
mDrawerAdapter.notifyDataSetChanged();
}
}
}
}
@@ -1037,13 +1031,14 @@ public class FavoritesScene extends BaseScene implements
gidArray[i] = gi.gid;
tokenArray[i] = gi.token;
}
List<GalleryInfo> modifyGiListBackup = new ArrayList<>(mModifyGiList);
mModifyGiList.clear();
EhRequest request = new EhRequest();
request.setMethod(EhClient.METHOD_ADD_FAVORITES_RANGE);
request.setCallback(new AddFavoritesListener(getContext(),
activity.getStageId(), getTag(),
taskId, mUrlBuilder.getKeyword()));
taskId, mUrlBuilder.getKeyword(), modifyGiListBackup));
request.setArgs(gidArray, tokenArray, mModifyFavCat);
mClient.execute(request);
} else {
@@ -1143,12 +1138,14 @@ public class FavoritesScene extends BaseScene implements
private final int mTaskId;
private final String mKeyword;
private final List<GalleryInfo> mBackup;
public AddFavoritesListener(Context context, int stageId,
String sceneTag, int taskId, String keyword) {
private AddFavoritesListener(Context context, int stageId,
String sceneTag, int taskId, String keyword, List<GalleryInfo> backup) {
super(context, stageId, sceneTag);
mTaskId = taskId;
mKeyword = keyword;
mBackup = backup;
}
@Override
@@ -1161,6 +1158,10 @@ public class FavoritesScene extends BaseScene implements
@Override
public void onFailure(Exception e) {
// TODO It's a failure, add all of backup back to db.
// But how to known which one is failed?
EhDB.putLocalFavorites(mBackup);
FavoritesScene scene = getScene();
if (scene != null) {
scene.onGetFavoritesLocal(mKeyword, mTaskId);
@@ -1183,7 +1184,7 @@ public class FavoritesScene extends BaseScene implements
private final boolean mLocal;
private final String mKeyword;
public GetFavoritesListener(Context context, int stageId,
private GetFavoritesListener(Context context, int stageId,
String sceneTag, int taskId, boolean local, String keyword) {
super(context, stageId, sceneTag);
mTaskId = taskId;
@@ -1195,6 +1196,7 @@ public class FavoritesScene extends BaseScene implements
public void onSuccess(FavoritesParser.Result result) {
// Put fav cat
Settings.putFavCat(result.catArray);
Settings.putFavCount(result.countArray);
FavoritesScene scene = getScene();
if (scene != null) {
if (mLocal) {
@@ -27,8 +27,8 @@ import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.hippo.drawable.TriangleDrawable;
import com.hippo.easyrecyclerview.MarginItemDecoration;
import com.hippo.ehviewer.R;
@@ -38,7 +38,7 @@ import com.hippo.ehviewer.client.EhUtils;
import com.hippo.ehviewer.client.data.GalleryInfo;
import com.hippo.ehviewer.widget.TileThumb;
import com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager;
import com.hippo.yorozuya.ViewUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -59,6 +59,8 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
private final int mPaddingTopSB;
private MarginItemDecoration mListDecoration;
private MarginItemDecoration mGirdDecoration;
private final int mListThumbWidth;
private final int mListThumbHeight;
private int mType = TYPE_INVALID;
public GalleryAdapter(@NonNull LayoutInflater inflater, @NonNull Resources resources,
@@ -72,6 +74,11 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
mRecyclerView.setAdapter(this);
mRecyclerView.setLayoutManager(mLayoutManager);
View calculator = inflater.inflate(R.layout.item_gallery_list_thumb_height, null);
ViewUtils.measureView(calculator, 1024, ViewGroup.LayoutParams.WRAP_CONTENT);
mListThumbHeight = calculator.getMeasuredHeight();
mListThumbWidth = mListThumbHeight * 2 / 3;
setType(type);
}
@@ -147,7 +154,17 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
layoutId = R.layout.item_gallery_grid;
break;
}
return new GalleryHolder(mInflater.inflate(layoutId, parent, false));
GalleryHolder holder = new GalleryHolder(mInflater.inflate(layoutId, parent, false));
if (viewType == TYPE_LIST) {
ViewGroup.LayoutParams lp = holder.thumb.getLayoutParams();
lp.width = mListThumbWidth;
lp.height = mListThumbHeight;
holder.thumb.setLayoutParams(lp);
}
return holder;
}
@Override
@@ -179,6 +196,17 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
category.setBackgroundColor(EhUtils.getCategoryColor(gi.category));
}
holder.posted.setText(gi.posted);
if (gi.pages == 0 || !Settings.getShowGalleryPages()) {
holder.pages.setText(null);
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) holder.simpleLanguage.getLayoutParams();
lp.addRule(RelativeLayout.LEFT_OF, 0);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
} else {
holder.pages.setText(Integer.toString(gi.pages) + "P");
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) holder.simpleLanguage.getLayoutParams();
lp.addRule(RelativeLayout.LEFT_OF, R.id.pages);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
}
holder.simpleLanguage.setText(gi.simpleLanguage);
break;
}
@@ -51,7 +51,7 @@ import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
import com.hippo.ehviewer.EhApplication;
@@ -83,11 +83,9 @@ import com.hippo.yorozuya.SimpleAnimatorListener;
import com.hippo.yorozuya.StringUtils;
import com.hippo.yorozuya.ViewUtils;
import com.hippo.yorozuya.collect.IntList;
import junit.framework.Assert;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
public final class GalleryCommentsScene extends ToolbarScene
implements EasyRecyclerView.OnItemClickListener,
@@ -205,11 +203,11 @@ public final class GalleryCommentsScene extends ToolbarScene
mRecyclerView.setLayoutManager(new LinearLayoutManager(context,
LinearLayoutManager.VERTICAL, false));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider),
LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setShowLastDivider(true);
mRecyclerView.addItemDecoration(decoration);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setOnItemClickListener(this);
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(),
@@ -322,7 +320,7 @@ public final class GalleryCommentsScene extends ToolbarScene
rv.setAdapter(new RecyclerView.Adapter<InfoHolder>() {
@Override
public InfoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new InfoHolder(inflater.inflate(R.layout.item_favorite_info_data, parent, false));
return new InfoHolder(inflater.inflate(R.layout.item_drawer_favorites, parent, false));
}
@Override
@@ -338,11 +336,11 @@ public final class GalleryCommentsScene extends ToolbarScene
});
rv.setLayoutManager(new LinearLayoutManager(context));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider),
LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
rv.addItemDecoration(decoration);
rv.setSelector(Ripple.generateRippleDrawable(context, false));
rv.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
rv.setClipToPadding(false);
builder.setView(rv).show();
}
@@ -637,7 +635,7 @@ public final class GalleryCommentsScene extends ToolbarScene
SpannableString ss = new SpannableString(scoreString);
ss.setSpan(new RelativeSizeSpan(0.8f), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.secondary_text_default_light))
ss.setSpan(new ForegroundColorSpan(AttrResources.getAttrColor(context, android.R.attr.textColorSecondary))
, 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.append(" ").append(ss);
}
@@ -53,7 +53,7 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RatingBar;
import android.widget.TextView;
import com.hippo.android.resource.AttrResources;
import com.hippo.beerbelly.BeerBelly;
import com.hippo.drawable.RoundSideRectDrawable;
import com.hippo.ehviewer.AppConfig;
@@ -106,9 +106,6 @@ import com.hippo.yorozuya.IOUtils;
import com.hippo.yorozuya.IntIdGenerator;
import com.hippo.yorozuya.SimpleHandler;
import com.hippo.yorozuya.ViewUtils;
import junit.framework.Assert;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -116,6 +113,7 @@ import java.io.OutputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import junit.framework.Assert;
public class GalleryDetailScene extends BaseScene implements View.OnClickListener,
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener,
@@ -431,6 +429,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
mTip.setCompoundDrawables(null, drawable, null, null);
mTip.setOnClickListener(this);
boolean isDarkTheme = !AttrResources.getAttrBoolean(context, R.attr.isLightTheme);
mHeader = ViewUtils.$$(mainView, R.id.header);
mColorBg = ViewUtils.$$(mHeader, R.id.color_bg);
mThumb = (LoadImageView) ViewUtils.$$(mHeader, R.id.thumb);
@@ -441,9 +440,9 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
mActionGroup = (ViewGroup) ViewUtils.$$(mHeader, R.id.action_card);
mDownload = (TextView) ViewUtils.$$(mActionGroup, R.id.download);
mRead = ViewUtils.$$(mActionGroup, R.id.read);
Ripple.addRipple(mOtherActions, false);
Ripple.addRipple(mDownload, false);
Ripple.addRipple(mRead, false);
Ripple.addRipple(mOtherActions, isDarkTheme);
Ripple.addRipple(mDownload, isDarkTheme);
Ripple.addRipple(mRead, isDarkTheme);
mUploader.setOnClickListener(this);
mCategory.setOnClickListener(this);
mOtherActions.setOnClickListener(this);
@@ -462,7 +461,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
mSize = (TextView) ViewUtils.$$(mInfo, R.id.size);
mPosted = (TextView) ViewUtils.$$(mInfo, R.id.posted);
mFavoredTimes = (TextView) ViewUtils.$$(mInfo, R.id.favoredTimes);
Ripple.addRipple(mInfo, false);
Ripple.addRipple(mInfo, isDarkTheme);
mInfo.setOnClickListener(this);
mActions = ViewUtils.$$(belowHeader, R.id.actions);
@@ -477,13 +476,13 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
mRate = (TextView) ViewUtils.$$(mActions, R.id.rate);
mSimilar = (TextView) ViewUtils.$$(mActions, R.id.similar);
mSearchCover = (TextView) ViewUtils.$$(mActions, R.id.search_cover);
Ripple.addRipple(mHeartGroup, false);
Ripple.addRipple(mTorrent, false);
Ripple.addRipple(mArchive, false);
Ripple.addRipple(mShare, false);
Ripple.addRipple(mRate, false);
Ripple.addRipple(mSimilar, false);
Ripple.addRipple(mSearchCover, false);
Ripple.addRipple(mHeartGroup, isDarkTheme);
Ripple.addRipple(mTorrent, isDarkTheme);
Ripple.addRipple(mArchive, isDarkTheme);
Ripple.addRipple(mShare, isDarkTheme);
Ripple.addRipple(mRate, isDarkTheme);
Ripple.addRipple(mSimilar, isDarkTheme);
Ripple.addRipple(mSearchCover, isDarkTheme);
mHeartGroup.setOnClickListener(this);
mTorrent.setOnClickListener(this);
mArchive.setOnClickListener(this);
@@ -498,13 +497,13 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
mComments = (LinearLayout) ViewUtils.$$(belowHeader, R.id.comments);
mCommentsText = (TextView) ViewUtils.$$(mComments, R.id.comments_text);
Ripple.addRipple(mComments, false);
Ripple.addRipple(mComments, isDarkTheme);
mComments.setOnClickListener(this);
mPreviews = ViewUtils.$$(belowHeader, R.id.previews);
mGridLayout = (SimpleGridAutoSpanLayout) ViewUtils.$$(mPreviews, R.id.grid_layout);
mPreviewText = (TextView) ViewUtils.$$(mPreviews, R.id.preview_text);
Ripple.addRipple(mPreviews, false);
Ripple.addRipple(mPreviews, isDarkTheme);
mPreviews.setOnClickListener(this);
mProgress = ViewUtils.$$(mainView, R.id.progress);
@@ -724,7 +723,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
}
if ((oldState == STATE_INIT || oldState == STATE_FAILED || oldState == STATE_REFRESH) &&
(state == STATE_NORMAL || state == STATE_REFRESH_HEADER)) {
(state == STATE_NORMAL || state == STATE_REFRESH_HEADER) && AttrResources.getAttrBoolean(getContext2(), R.attr.isLightTheme)) {
if (!createCircularReveal()) {
SimpleHandler.getInstance().post(new Runnable() {
@Override
@@ -766,6 +765,11 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
if (gd.isFavorited || EhDB.containLocalFavorites(gd.gid)) {
mHeart.setVisibility(View.VISIBLE);
if (gd.favoriteName == null) {
mHeart.setText(R.string.local_favorites);
} else {
mHeart.setText(gd.favoriteName);
}
mHeartOutline.setVisibility(View.GONE);
} else {
mHeart.setVisibility(View.GONE);
@@ -830,8 +834,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
mNoTags.setVisibility(View.GONE);
}
int colorTag = resources.getColor(R.color.colorPrimary);
int colorName = resources.getColor(R.color.purple_a400);
int colorTag = AttrResources.getAttrColor(context, R.attr.tagBackgroundColor);
int colorName = AttrResources.getAttrColor(context, R.attr.tagGroupBackgroundColor);
for (GalleryTagGroup tg : tagGroups) {
LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.gallery_tag_group, mTags, false);
ll.setOrientation(LinearLayout.HORIZONTAL);
@@ -1533,11 +1537,19 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
private void onModifyFavoritesSuccess(boolean addOrRemove) {
mModifingFavorites = false;
if (mGalleryDetail != null) {
mGalleryDetail.isFavorited = !addOrRemove;
mGalleryDetail.isFavorited = !addOrRemove && mGalleryDetail.favoriteName != null;
updateFavoriteDrawable();
}
}
private void onModifyFavoritesFailure(boolean addOrRemove) {
mModifingFavorites = false;
}
private void onModifyFavoritesCancel(boolean addOrRemove) {
mModifingFavorites = false;
}
private class ModifyFavoritesListener extends EhCallback<GalleryDetailScene, Void> {
private final boolean mAddOrRemove;
@@ -1564,10 +1576,19 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
public void onFailure(Exception e) {
showTip(mAddOrRemove ? R.string.remove_from_favorite_failure :
R.string.add_to_favorite_failure, LENGTH_SHORT);
GalleryDetailScene scene = getScene();
if (scene != null) {
scene.onModifyFavoritesFailure(mAddOrRemove);
}
}
@Override
public void onCancel() {}
public void onCancel() {
GalleryDetailScene scene = getScene();
if (scene != null) {
scene.onModifyFavoritesCancel(mAddOrRemove);
}
}
@Override
public boolean isInstance(SceneFragment scene) {
@@ -32,6 +32,7 @@ class GalleryHolder extends RecyclerView.ViewHolder {
public final SimpleRatingView rating;
public final TextView category;
public final TextView posted;
public final TextView pages;
public final TextView simpleLanguage;
public GalleryHolder(View itemView) {
@@ -43,6 +44,7 @@ class GalleryHolder extends RecyclerView.ViewHolder {
rating = (SimpleRatingView) itemView.findViewById(R.id.rating);
category = (TextView) itemView.findViewById(R.id.category);
posted = (TextView) itemView.findViewById(R.id.posted);
pages = (TextView) itemView.findViewById(R.id.pages);
simpleLanguage = (TextView) itemView.findViewById(R.id.simple_language);
}
}
@@ -29,20 +29,19 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.client.EhUrl;
import com.hippo.ehviewer.client.EhUtils;
import com.hippo.ehviewer.client.data.GalleryDetail;
import com.hippo.ripple.Ripple;
import com.hippo.yorozuya.LayoutUtils;
import com.hippo.yorozuya.ViewUtils;
import junit.framework.Assert;
import java.util.ArrayList;
import junit.framework.Assert;
public final class GalleryInfoScene extends ToolbarScene implements EasyRecyclerView.OnItemClickListener {
@@ -128,6 +127,8 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
mValues.add(Integer.toString(gd.torrentCount));
mKeys.add(resources.getString(R.string.key_torrent_url));
mValues.add(gd.torrentUrl);
mKeys.add(resources.getString(R.string.favorite_name));
mValues.add(gd.favoriteName);
}
protected void onInit() {
@@ -163,11 +164,12 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
mRecyclerView.setAdapter(adapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider),
LinearDividerItemDecoration.VERTICAL,
AttrResources.getAttrColor(context, R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
mRecyclerView.addItemDecoration(decoration);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
mRecyclerView.setClipToPadding(false);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setOnItemClickListener(this);
@@ -197,6 +199,12 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
if (null != context && 0 != position && null != mValues) {
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setPrimaryClip(ClipData.newPlainText(null, mValues.get(position)));
if (position == 3) {
// Save it to avoid detect the gallery
Settings.putClipboardTextHashCode(mValues.get(position).hashCode());
}
showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
return true;
} else {
@@ -49,10 +49,10 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.github.amlcurran.showcaseview.ShowcaseView;
import com.github.amlcurran.showcaseview.SimpleShowcaseEventListener;
import com.github.amlcurran.showcaseview.targets.PointTarget;
import com.hippo.android.resource.AttrResources;
import com.hippo.app.CheckBoxDialogBuilder;
import com.hippo.app.EditTextDialogBuilder;
import com.hippo.drawable.AddDeleteDrawable;
@@ -92,13 +92,11 @@ import com.hippo.yorozuya.MathUtils;
import com.hippo.yorozuya.SimpleAnimatorListener;
import com.hippo.yorozuya.StringUtils;
import com.hippo.yorozuya.ViewUtils;
import junit.framework.Assert;
import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import junit.framework.Assert;
public final class GalleryListScene extends BaseScene
implements EasyRecyclerView.OnItemClickListener, EasyRecyclerView.OnItemLongClickListener,
@@ -414,7 +412,7 @@ public final class GalleryListScene extends BaseScene
mAdapter = new GalleryListAdapter(inflater, resources,
mRecyclerView, Settings.getListMode());
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
mRecyclerView.setDrawSelectorOnTop(true);
mRecyclerView.hasFixedSize();
mRecyclerView.setClipToPadding(false);
@@ -427,8 +425,8 @@ public final class GalleryListScene extends BaseScene
refreshLayout.setHeaderTranslationY(paddingTopSB);
mLeftDrawable = new DrawerArrowDrawable(context);
mRightDrawable = new AddDeleteDrawable(context);
mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
mRightDrawable = new AddDeleteDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
mSearchBar.setLeftDrawable(mLeftDrawable);
mSearchBar.setRightDrawable(mRightDrawable);
mSearchBar.setHelper(this);
@@ -446,8 +444,7 @@ public final class GalleryListScene extends BaseScene
mFabLayout.setOnExpandListener(this);
addAboveSnackView(mFabLayout);
mActionFabDrawable = new AddDeleteDrawable(context);
mActionFabDrawable.setColor(resources.getColor(R.color.primary_drawable_dark));
mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark));
mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);
mSearchFab.setOnClickListener(this);
@@ -31,7 +31,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager;
@@ -42,6 +41,7 @@ import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAct
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionRemoveItem;
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractSwipeableItemViewHolder;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.FastScroller;
import com.hippo.easyrecyclerview.HandlerDrawable;
@@ -64,12 +64,9 @@ import com.hippo.util.DrawableManager;
import com.hippo.view.ViewTransition;
import com.hippo.widget.LoadImageView;
import com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager;
import com.hippo.yorozuya.ResourcesUtils;
import com.hippo.yorozuya.ViewUtils;
import junit.framework.Assert;
import de.greenrobot.dao.query.LazyList;
import junit.framework.Assert;
public class HistoryScene extends ToolbarScene
implements EasyRecyclerView.OnItemClickListener,
@@ -127,7 +124,7 @@ public class HistoryScene extends ToolbarScene
layoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
mRecyclerView.setDrawSelectorOnTop(true);
mRecyclerView.hasFixedSize();
mRecyclerView.setClipToPadding(false);
@@ -144,7 +141,7 @@ public class HistoryScene extends ToolbarScene
fastScroller.attachToRecyclerView(mRecyclerView);
HandlerDrawable handlerDrawable = new HandlerDrawable();
handlerDrawable.setColor(ResourcesUtils.getAttrColor(context, R.attr.colorAccent));
handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
fastScroller.setHandlerDrawable(handlerDrawable);
updateLazyList();
@@ -323,9 +320,16 @@ public class HistoryScene extends ToolbarScene
implements SwipeableItemAdapter<HistoryHolder> {
private final LayoutInflater mInflater;
private final int mListThumbWidth;
private final int mListThumbHeight;
public HistoryAdapter() {
mInflater = getLayoutInflater2();
View calculator = mInflater.inflate(R.layout.item_gallery_list_thumb_height, null);
ViewUtils.measureView(calculator, 1024, ViewGroup.LayoutParams.WRAP_CONTENT);
mListThumbHeight = calculator.getMeasuredHeight();
mListThumbWidth = mListThumbHeight * 2 / 3;
}
@Override
@@ -339,7 +343,14 @@ public class HistoryScene extends ToolbarScene
@Override
public HistoryHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new HistoryHolder(mInflater.inflate(R.layout.item_gallery_list, parent, false));
HistoryHolder holder = new HistoryHolder(mInflater.inflate(R.layout.item_gallery_list, parent, false));
ViewGroup.LayoutParams lp = holder.thumb.getLayoutParams();
lp.width = mListThumbWidth;
lp.height = mListThumbHeight;
holder.thumb.setLayoutParams(lp);
return holder;
}
@Override
@@ -376,7 +387,7 @@ public class HistoryScene extends ToolbarScene
@Override
public int onGetSwipeReactionType(HistoryHolder holder, int position, int x, int y) {
return SwipeableItemConstants.REACTION_CAN_SWIPE_BOTH_H;
return SwipeableItemConstants.REACTION_CAN_SWIPE_LEFT;
}
@Override
@@ -386,8 +397,8 @@ public class HistoryScene extends ToolbarScene
public SwipeResultAction onSwipeItem(HistoryHolder holder, int position, int result) {
switch (result) {
case SwipeableItemConstants.RESULT_SWIPED_LEFT:
case SwipeableItemConstants.RESULT_SWIPED_RIGHT:
return new SwipeResultActionClear(position);
case SwipeableItemConstants.RESULT_SWIPED_RIGHT:
case SwipeableItemConstants.RESULT_CANCELED:
default:
return new SwipeResultActionDefault();
@@ -18,15 +18,13 @@ package com.hippo.ehviewer.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.yorozuya.ViewUtils;
@@ -60,9 +58,9 @@ public class GalleryGuideView extends ViewGroup implements View.OnClickListener
}
private void init(Context context) {
mBgColor = ContextCompat.getColor(context, R.color.guide_bg);
mBgColor = AttrResources.getAttrColor(context, R.attr.guideBackgroundColor);
mPaint = new Paint();
mPaint.setColor(Color.WHITE);
mPaint.setColor(AttrResources.getAttrColor(context, R.attr.guideTitleColor));
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(context.getResources().getDimension(R.dimen.gallery_guide_divider_width));
setOnClickListener(this);
@@ -26,6 +26,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@@ -38,23 +39,20 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.hippo.ehviewer.R;
import com.hippo.view.ViewTransition;
import com.hippo.yorozuya.AnimationUtils;
import com.hippo.yorozuya.MathUtils;
import com.hippo.yorozuya.SimpleAnimatorListener;
import com.hippo.yorozuya.ViewUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SearchBar extends FrameLayout implements View.OnClickListener,
public class SearchBar extends CardView implements View.OnClickListener,
TextView.OnEditorActionListener, TextWatcher,
SearchEditText.SearchEditTextListener {
@@ -111,8 +109,6 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
}
private void init(Context context) {
setBackgroundResource(R.drawable.card_white_no_padding_2dp);
mSearchDatabase = SearchDatabase.getInstance(getContext());
LayoutInflater inflater = LayoutInflater.from(context);
@@ -37,7 +37,7 @@ import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.MarginItemDecoration;
import com.hippo.ehviewer.R;
@@ -46,7 +46,6 @@ import com.hippo.ehviewer.client.exception.EhException;
import com.hippo.ripple.Ripple;
import com.hippo.widget.RadioGridGroup;
import com.hippo.yorozuya.ViewUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -139,7 +138,7 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
mNormalSearchModeHelp = (ImageView) normalView.findViewById(R.id.normal_search_mode_help);
mEnableAdvanceSwitch = (SwitchCompat) normalView.findViewById(R.id.search_enable_advance);
mNormalSearchModeHelp.setOnClickListener(this);
Ripple.addRipple(mNormalSearchModeHelp, false);
Ripple.addRipple(mNormalSearchModeHelp, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme));
mEnableAdvanceSwitch.setOnCheckedChangeListener(SearchLayout.this);
mEnableAdvanceSwitch.setSwitchPadding(resources.getDimensionPixelSize(R.dimen.switch_padding));
@@ -24,6 +24,7 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.R;
import com.hippo.yorozuya.collect.IntList;
@@ -102,7 +103,7 @@ public class SceneFragment extends Fragment {
super.onViewCreated(view, savedInstanceState);
view.setTag(R.id.fragment_tag, getTag());
view.setBackgroundColor(getResources().getColor(R.color.background_light));
view.setBackgroundDrawable(AttrResources.getAttrDrawable(getContext(), android.R.attr.windowBackground));
// Notify
FragmentActivity activity = getActivity();
@@ -231,6 +231,9 @@ public abstract class StageActivity extends EhActivity {
protected void onUnregister() {
}
protected void onTransactScene() {
}
public int getStageId() {
return mStageId;
}
@@ -311,6 +314,7 @@ public abstract class StageActivity extends EhActivity {
// Commit
transaction.commitAllowingStateLoss();
onTransactScene();
// New arguments
if (args != null && fragment instanceof SceneFragment) {
@@ -384,6 +388,7 @@ public abstract class StageActivity extends EhActivity {
// Commit
transaction.commitAllowingStateLoss();
onTransactScene();
// Check request
if (announcer.requestFrom != null) {
@@ -460,6 +465,7 @@ public abstract class StageActivity extends EhActivity {
// Commit
transaction.commitAllowingStateLoss();
onTransactScene();
if (!createNewScene && args != null) {
// TODO Call onNewArguments when view created ?
@@ -538,6 +544,7 @@ public abstract class StageActivity extends EhActivity {
}
transaction.remove(scene);
transaction.commitAllowingStateLoss();
onTransactScene();
// Remove tag
mSceneTagList.remove(index);
@@ -562,6 +569,7 @@ public abstract class StageActivity extends EhActivity {
transaction.detach(fragment);
transaction.attach(fragment);
transaction.commitAllowingStateLoss();
onTransactScene();
}
@Override
+5 -9
View File
@@ -46,9 +46,10 @@ import android.text.style.TextAppearanceSpan;
import android.text.style.TypefaceSpan;
import android.text.style.URLSpan;
import android.text.style.UnderlineSpan;
import com.hippo.ehviewer.R;
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Locale;
import org.ccil.cowan.tagsoup.HTMLSchema;
import org.ccil.cowan.tagsoup.Parser;
import org.xml.sax.Attributes;
@@ -58,11 +59,6 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Locale;
/**
* This class processes HTML strings into displayable styled text.
* Not all HTML tags are supported.
@@ -678,7 +674,7 @@ class HtmlToSpannedConverter implements ContentHandler {
}
if (d == null) {
d = Html.sResources.getDrawable(R.drawable.image_failed);
d = Resources.getSystem().getDrawable(android.R.drawable.ic_menu_report_image);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
}
@@ -58,9 +58,10 @@ public class AppHelper {
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, text);
sendIntent.setType("text/plain");
Intent chooser = Intent.createChooser(sendIntent, from.getString(R.string.share));
try {
from.startActivity(sendIntent);
from.startActivity(chooser);
return true;
} catch (ActivityNotFoundException e) {
Toast.makeText(from, R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show();
@@ -18,19 +18,17 @@ package com.hippo.util;
import android.support.annotation.NonNull;
import com.hippo.ehviewer.GetText;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.client.exception.EhException;
import com.hippo.network.StatusCodeException;
import org.apache.http.conn.ConnectTimeoutException;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import javax.net.ssl.SSLException;
import org.apache.http.conn.ConnectTimeoutException;
public final class ExceptionUtils {
@@ -56,7 +54,7 @@ public final class ExceptionUtils {
return sb.toString();
} else if (e instanceof ProtocolException && e.getMessage().startsWith("Too many follow-up requests:")) {
return GetText.getString(R.string.error_redirection);
} else if (e instanceof ProtocolException || e instanceof SocketException) {
} else if (e instanceof ProtocolException || e instanceof SocketException || e instanceof SSLException) {
return GetText.getString(R.string.error_socket);
} else if (e instanceof EhException) {
return e.getMessage();
@@ -30,7 +30,7 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.FastScroller;
import com.hippo.easyrecyclerview.HandlerDrawable;
@@ -43,9 +43,7 @@ import com.hippo.util.ExceptionUtils;
import com.hippo.view.ViewTransition;
import com.hippo.yorozuya.IntIdGenerator;
import com.hippo.yorozuya.LayoutUtils;
import com.hippo.yorozuya.ResourcesUtils;
import com.hippo.yorozuya.collect.IntList;
import java.util.ArrayList;
import java.util.List;
@@ -92,7 +90,7 @@ public class ContentLayout extends FrameLayout {
mFastScroller.attachToRecyclerView(mRecyclerView);
HandlerDrawable drawable = new HandlerDrawable();
drawable.setColor(ResourcesUtils.getAttrColor(context, R.attr.colorAccent));
drawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
mFastScroller.setHandlerDrawable(drawable);
mRefreshLayout.setHeaderColorSchemeResources(
@@ -24,13 +24,12 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.hippo.android.resource.AttrResources;
import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
import com.hippo.ehviewer.R;
import com.hippo.ripple.Ripple;
import com.hippo.yorozuya.LayoutUtils;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
@@ -73,11 +72,11 @@ public class DirExplorer extends EasyRecyclerView implements EasyRecyclerView.On
setAdapter(mAdapter);
setLayoutManager(new LinearLayoutManager(context));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL, getResources().getColor(R.color.divider),
LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setShowLastDivider(true);
addItemDecoration(decoration);
setSelector(Ripple.generateRippleDrawable(context, false));
setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
setOnItemClickListener(this);
mCurrentFile = Environment.getExternalStorageDirectory();
@@ -29,7 +29,6 @@ import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.hippo.conaco.Conaco;
import com.hippo.conaco.ConacoTask;
import com.hippo.conaco.DataContainer;
@@ -40,7 +39,7 @@ import com.hippo.ehviewer.R;
import com.hippo.image.ImageBitmap;
import com.hippo.image.ImageDrawable;
import com.hippo.image.RecycledException;
import com.hippo.util.DrawableManager;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -309,7 +308,7 @@ public class LoadImageView extends FixedAspectImageView implements Unikery<Image
public void onFailure() {
mFailed = true;
clearDrawable();
setImageDrawable(getContext().getResources().getDrawable(R.drawable.image_failed));
setImageDrawable(DrawableManager.getDrawable(getContext(), R.drawable.image_failed));
if (mRetryType == RETRY_TYPE_CLICK) {
setOnClickListener(this);
} else if (mRetryType == RETRY_TYPE_LONG_CLICK) {
@@ -38,9 +38,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.Interpolator;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.R;
import java.util.ArrayList;
import java.util.List;
@@ -270,7 +269,8 @@ public class LockPatternView extends View {
mPathPaint.setAntiAlias(true);
mPathPaint.setDither(true);
mRegularColor = getResources().getColor(R.color.lock_pattern_view_regular_color);
mRegularColor = getResources().getColor(AttrResources.getAttrBoolean(context, R.attr.isLightTheme) ?
R.color.lock_pattern_view_regular_color_light : R.color.lock_pattern_view_regular_color_dark);
mErrorColor = getResources().getColor(R.color.lock_pattern_view_error_color);
mSuccessColor = getResources().getColor(R.color.lock_pattern_view_success_color);
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2015 Hippo Seven
~ Copyright 2018 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -17,8 +17,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:color="@color/colorPrimary"/>
<item android:state_enabled="false" android:color="@color/primary_text_disabled_light"/>
<item android:color="@color/primary_text_default_light"/>
<item android:state_activated="true" android:color="@color/content_activated_black"/>
<item android:color="@color/content_black"/>
</selector>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2015 Hippo Seven
~ Copyright 2018 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/primary_text_disabled_light"/>
<item android:color="@color/primary_text_default_light"/>
<item android:state_activated="true" android:color="@color/content_activated_dark"/>
<item android:color="@color/content_dark"/>
</selector>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2015 Hippo Seven
~ Copyright 2018 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/secondary_text_disabled_dark"/>
<item android:color="@color/secondary_text_default_dark"/>
<item android:state_activated="true" android:color="@color/content_activated_light"/>
<item android:color="@color/content_light"/>
</selector>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2015 Hippo Seven
~ Copyright 2018 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -16,6 +16,6 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/primary_text_disabled_dark"/>
<item android:color="@color/primary_text_default_dark"/>
<item android:state_enabled="false" android:color="@color/primary_text_disabled_material_black"/>
<item android:color="@color/primary_text_default_material_black"/>
</selector>
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 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
~ 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/secondary_text_disabled_light"/>
<item android:color="@color/secondary_text_default_light"/>
</selector>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:pathData="M46,24A22,22 0,0 1,24 46,22 22,0 0,1 2,24 22,22 0,0 1,24 2,22 22,0 0,1 46,24Z"
android:fillColor="@color/shortcut_bg"
android:fillAlpha="1"/>
<path
android:pathData="M20,17V31L31,24Z"
android:fillColor="@color/colorPrimary"
android:fillAlpha="1"/>
</vector>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:pathData="M46,24A22,22 0,0 1,24 46,22 22,0 0,1 2,24 22,22 0,0 1,24 2,22 22,0 0,1 46,24Z"
android:fillColor="@color/shortcut_bg"
android:fillAlpha="1"/>
<path
android:pathData="m18,31h4L22,17h-4zM26,17v14h4L30,17Z"
android:fillColor="@color/colorPrimary"
android:fillAlpha="1"/>
</vector>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/shortcut_bg"/>
<foreground android:drawable="@drawable/ic_play_arrow_108dp"/>
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/shortcut_bg"/>
<foreground android:drawable="@drawable/ic_pause_108dp"/>
</adaptive-icon>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

+1 -1
View File
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/big_icon"
android:fillColor="?attr/drawableColorSecondary"
android:pathData="@string/pd_big_download"/>
</vector>
+1 -1
View File
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/big_icon"
android:fillColor="?attr/drawableColorSecondary"
android:pathData="@string/pd_big_filter"/>
</vector>
+1 -1
View File
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/big_icon"
android:fillColor="?attr/drawableColorSecondary"
android:pathData="@string/pd_big_history"/>
</vector>
+1 -1
View File
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/big_icon"
android:fillColor="?attr/drawableColorSecondary"
android:pathData="@string/pd_big_label"/>
</vector>
+1 -1
View File
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/big_icon"
android:fillColor="?attr/drawableColorSecondary"
android:pathData="@string/pd_big_search"/>
</vector>
+1 -1
View File
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/big_icon"
android:fillColor="?attr/drawableColorSecondary"
android:pathData="@string/pd_big_weird_face"/>
</vector>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2016 Hippo Seven
~ Copyright 2018 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -15,10 +15,13 @@
~ limitations under the License.
-->
<selector
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@drawable/card_grey_no_padding_2dp"/>
<item android:drawable="@drawable/card_white_no_padding_2dp"/>
<solid
android:color="@color/divider_dark"/>
</selector>
<size
android:height="1dp"/>
</shape>
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@color/divider"/>
android:color="@color/divider_light"/>
<size
android:height="1dp"/>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:pathData="m42,68h8V40H42ZM58,40v28h8V40Z"
android:fillColor="@color/colorPrimary"
android:fillAlpha="1"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:pathData="M46,40V68L68,54Z"
android:fillColor="@color/colorPrimary"
android:fillAlpha="1"/>
</vector>
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2016 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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="48dp"
android:width="48dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?attr/drawableColorPrimary"
android:pathData="@string/pd_file_image"/>
</vector>
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="?attr/colorPrimary"
android:fillColor="?attr/drawableColorThemePrimary"
android:pathData="@string/pd_adb"/>
</vector>
@@ -23,7 +23,7 @@
android:viewportHeight="24.0">
<path
android:fillColor="?attr/colorPrimary"
android:fillColor="?attr/drawableColorThemePrimary"
android:pathData="@string/pd_archive"/>
</vector>
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="?attr/colorPrimary"
android:fillColor="?attr/drawableColorThemePrimary"
android:pathData="@string/pd_book_open"/>
</vector>
+1 -1
View File
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/primary_drawable_light"
android:fillColor="?attr/drawableColorPrimary"
android:pathData="@string/pd_delete"/>
</vector>
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="?attr/colorPrimary"
android:fillColor="?attr/drawableColorThemePrimary"
android:pathData="@string/pd_download"/>
</vector>
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="?attr/colorPrimary"
android:fillColor="?attr/drawableColorThemePrimary"
android:pathData="@string/pd_file_find"/>
</vector>
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="?attr/colorPrimary"
android:fillColor="?attr/drawableColorThemePrimary"
android:pathData="@string/pd_heart_outline"/>
</vector>
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="?attr/colorPrimary"
android:fillColor="?attr/drawableColorThemePrimary"
android:pathData="@string/pd_heart"/>
</vector>
@@ -23,7 +23,7 @@
android:viewportHeight="24">
<path
android:fillColor="@color/primary_drawable_light"
android:fillColor="?attr/drawableColorPrimary"
android:pathData="@string/pd_help_circle"/>
</vector>
Loaded 100 of 188 files, more files were not shown because too many files have changed in this diff. Show more