Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a472d0509a | ||
|
|
3f71a97cbd | ||
|
|
ed8c818d4f | ||
|
|
1db14cd998 | ||
|
|
d06dd87ff4 | ||
|
|
a31a64efd6 | ||
|
|
cfa87a5a02 | ||
|
|
2833691c34 | ||
|
|
22d6ed8c39 | ||
|
|
110bae7cb7 | ||
|
|
5bd7d6fae3 | ||
|
|
afa45fd8d9 | ||
|
|
2c544607ec | ||
|
|
730b52d6cd | ||
|
|
0704579d26 | ||
|
|
cb92fbad3d | ||
|
|
c7c6f8f706 | ||
|
|
fdd81e21b1 | ||
|
|
1093da6565 | ||
|
|
c625315a76 | ||
|
|
1deb4c2d6c | ||
|
|
9201b9baed | ||
|
|
557bd9f54b | ||
|
|
0353dbdb27 | ||
|
|
8b07cf62a9 | ||
|
|
111025cb98 | ||
|
|
b3d9c4c2b9 | ||
|
|
f2695b6a2c | ||
|
|
f6ec40e8ed | ||
|
|
9bc6920448 | ||
|
|
abb8483723 | ||
|
|
81eadbb794 | ||
|
|
22cc32778d | ||
|
|
c9d432b7c8 | ||
|
|
168a1dcfb2 | ||
|
|
b6718078f2 | ||
|
|
960a7751ad | ||
|
|
e5335de859 | ||
|
|
1eb960eaf9 | ||
|
|
6bc9f0da64 | ||
|
|
f4d986a5bd | ||
|
|
9aa22aab34 | ||
|
|
afa839ed0b | ||
|
|
f2725331fe | ||
|
|
590963024a | ||
|
|
1f55977182 | ||
|
|
4bed3d5b8e | ||
|
|
7eab4e00e1 | ||
|
|
776813df17 | ||
|
|
12beeedf29 | ||
|
|
d0e7f25fd9 | ||
|
|
ab2a066992 | ||
|
|
596f95e463 | ||
|
|
79d07f98a8 | ||
|
|
22ec2e8926 | ||
|
|
bc4d20d0a4 | ||
|
|
84ed520c1c | ||
|
|
34eb6a423a | ||
|
|
7dc1491c26 | ||
|
|
6ecce9ddc5 | ||
|
|
029373a8d2 | ||
|
|
e8c06fd876 | ||
|
|
8c9218e8af | ||
|
|
f922d41775 | ||
|
|
e483105eb2 | ||
|
|
9aecb79b17 | ||
|
|
bfc6bf07d9 | ||
|
|
b671999e5a | ||
|
|
3ed2cb329c | ||
|
|
fe9970523f | ||
|
|
62944f7b71 | ||
|
|
a7e1101c87 | ||
|
|
b79d991b25 | ||
|
|
10a15fc5cf | ||
|
|
428a5ab20e | ||
|
|
b3d19d752b | ||
|
|
73b702aa56 | ||
|
|
3360035402 | ||
|
|
b97069a04e | ||
|
|
9df8d050b2 | ||
|
|
ba4ca96b77 | ||
|
|
fd93baf583 | ||
|
|
0a9a1976cd | ||
|
|
450e05c819 | ||
|
|
59d36d29da | ||
|
|
f0cd92f82e | ||
|
|
e847338ef4 | ||
|
|
23c34258ff | ||
|
|
d441960107 | ||
|
|
185ae6beb4 | ||
|
|
d84376e4dc | ||
|
|
dcc6af3367 | ||
|
|
1cd8ef1b47 | ||
|
|
f8c5caf6bc | ||
|
|
8e84b5b67b | ||
|
|
dc697af081 | ||
|
|
a69f36b652 | ||
|
|
d5c788fe80 | ||
|
|
021fe45c8d | ||
|
|
18881e549f | ||
|
|
ed2f3510d8 | ||
|
|
5290340b97 | ||
|
|
9514d42032 | ||
|
|
2cc140eaf4 | ||
|
|
c4934fc89e | ||
|
|
7feb5552c1 | ||
|
|
fce659c41c | ||
|
|
2e899f5fa8 | ||
|
|
4580d781db | ||
|
|
6fdab6f89c | ||
|
|
145b6523e9 | ||
|
|
1d03d35685 | ||
|
|
71396bc632 | ||
|
|
511d70838a | ||
|
|
1e31052767 | ||
|
|
e1c88c53f3 | ||
|
|
de16081c79 | ||
|
|
e9d1ce1720 | ||
|
|
3bce3c41f2 | ||
|
|
c71729c560 | ||
|
|
3cbf5d0a8f | ||
|
|
6f99f5a226 | ||
|
|
252dcb6175 | ||
|
|
72971341b2 | ||
|
|
32f4205240 | ||
|
|
36e66a8714 | ||
|
|
7ee1777e7b | ||
|
|
d8dc9ad576 | ||
|
|
8ae8842f81 | ||
|
|
ddb82292f9 | ||
|
|
83ade321bb | ||
|
|
a4ea8a6bfc | ||
|
|
2d32852d18 | ||
|
|
3ef3510ad3 | ||
|
|
82cb0eb7d6 | ||
|
|
2c428d3306 | ||
|
|
5fa9e8677d | ||
|
|
b57abfdc57 | ||
|
|
2f7906d3db | ||
|
|
d56f86b47e | ||
|
|
e558be2b89 | ||
|
|
66cab7b41e | ||
|
|
4f431bb7ea | ||
|
|
d411623da6 | ||
|
|
d121e839c9 | ||
|
|
c397bd0211 | ||
|
|
ec2782ddad | ||
|
|
6b6a60ae02 | ||
|
|
f870674bd2 | ||
|
|
6af75a9758 | ||
|
|
e4fc925b04 | ||
|
|
2262779ba0 | ||
|
|
b52cd2a619 | ||
|
|
8bad20e58c | ||
|
|
30ca44b9c6 | ||
|
|
cf43ed965e | ||
|
|
dab29819bd | ||
|
|
5fb090f241 | ||
|
|
ff84c63445 | ||
|
|
140ace739e | ||
|
|
5f8c078367 | ||
|
|
faddb37557 | ||
|
|
5d8fe06d5c | ||
|
|
2e34913c7d | ||
|
|
6cc607469b | ||
|
|
26eff55e6d | ||
|
|
9a5743dd67 | ||
|
|
0b547147b1 | ||
|
|
6bd3bd5e80 | ||
|
|
af93a6730e | ||
|
|
27e4bd4e0b | ||
|
|
459b27253a | ||
|
|
bb99570cd4 | ||
|
|
3f2b62c119 | ||
|
|
91e9975a24 | ||
|
|
00485efd0e | ||
|
|
c5d56243e0 | ||
|
|
b8c3229d9f | ||
|
|
8cf935accc | ||
|
|
2cf5589369 | ||
|
|
89addaf211 | ||
|
|
f5409c7b8a | ||
|
|
733ddb5964 | ||
|
|
537380eeb7 | ||
|
|
e44473f26b | ||
|
|
a503832016 | ||
|
|
4935995342 | ||
|
|
a367373c87 | ||
|
|
62cd2e4809 | ||
|
|
7df7defa92 | ||
|
|
56b42c67d5 | ||
|
|
d1afcc2f54 | ||
|
|
f6b05ed42b | ||
|
|
095334d338 | ||
|
|
dac0ef178d | ||
|
|
c23a502e9e | ||
|
|
5ddd652076 | ||
|
|
3f9e3f620d | ||
|
|
1c62fe9615 | ||
|
|
8703102c97 | ||
|
|
28ab591769 | ||
|
|
8cc2bfbced | ||
|
|
7612dde6d4 | ||
|
|
5188fe7170 | ||
|
|
c31048e829 | ||
|
|
44629bb405 | ||
|
|
3e387b1833 | ||
|
|
080693656a | ||
|
|
bc5479fa96 | ||
|
|
b95892d3b6 | ||
|
|
e1eea40fd7 | ||
|
|
c00fb901a0 | ||
|
|
029bca22ed | ||
|
|
facb931cb6 | ||
|
|
2f319afd40 | ||
|
|
95114502c9 | ||
|
|
2eef9b8fb0 | ||
|
|
6180ea3302 | ||
|
|
bf3ebc5ff8 | ||
|
|
5f77728a7b | ||
|
|
e823834889 | ||
|
|
35c97a7772 | ||
|
|
d59a520aa5 | ||
|
|
6bcdbfeaa4 | ||
|
|
dcb11102f6 | ||
|
|
a0e957b1fd | ||
|
|
c8c0a3aae0 | ||
|
|
aed7acfdc8 | ||
|
|
6707f0ee35 | ||
|
|
44694f351e | ||
|
|
8e3585b32d | ||
|
|
25312953af | ||
|
|
c8a32ba76e | ||
|
|
a97a6682fb | ||
|
|
ed8151632e | ||
|
|
aca061ecf6 | ||
|
|
b2bef7a4b0 | ||
|
|
db63a8f05b | ||
|
|
998f57f435 | ||
|
|
46c9197cce | ||
|
|
3f3c0c6c6a | ||
|
|
ff34acfe59 | ||
|
|
b969177244 | ||
|
|
32efad2b33 | ||
|
|
bad4cdac1a | ||
|
|
5cebca42e9 | ||
|
|
3ef2447eef | ||
|
|
a8faa2930a | ||
|
|
02abba52a7 | ||
|
|
6da2bc352d | ||
|
|
cc39e0dda3 | ||
|
|
c81145d46e | ||
|
|
a56c79d4bb | ||
|
|
fa3f409a70 | ||
|
|
1865924469 | ||
|
|
b3a23ad4e8 | ||
|
|
7a02103e05 |
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
请在阅读完毕后,删除这些文字,并写下对该 Issue 的描述。
|
||||
|
||||
若您能熟练使用现代标准汉语,请务必使用该语言描述 Issue。
|
||||
|
||||
Issue 的内容仅可为
|
||||
* Bug 反馈
|
||||
* 功能申请
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
*.iml
|
||||
.idea
|
||||
/captures
|
||||
release
|
||||
@@ -1,32 +1,40 @@
|
||||
import com.android.build.gradle.internal.tasks.DefaultAndroidTask
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'android-chinese-string'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "25.0.3"
|
||||
compileSdkVersion 27
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.hippo.ehviewer"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 25
|
||||
versionCode 79
|
||||
versionName "1.0.26"
|
||||
targetSdkVersion 27
|
||||
versionCode 85
|
||||
versionName "1.2.0"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW",
|
||||
"es"
|
||||
"es", "ja", "ko", "fr", "de"
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
checkReleaseBuilds false
|
||||
disable 'MissingTranslation'
|
||||
abortOnError true
|
||||
checkReleaseBuilds true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', '"com.hippo.ehviewer.fileprovider"'
|
||||
}
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', '"com.hippo.ehviewer.debug.fileprovider"'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +51,7 @@ task copyNotice(type: Copy) {
|
||||
finalizedBy ":daogenerator:executeDaoGenerator"
|
||||
}
|
||||
|
||||
tasks.withType(DefaultAndroidTask) {
|
||||
tasks.withType(JavaCompile) {
|
||||
task -> task.dependsOn copyNotice
|
||||
}
|
||||
|
||||
@@ -52,43 +60,48 @@ clean {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile "com.android.support:appcompat-v7:$supportLibrary"
|
||||
compile "com.android.support:design:$supportLibrary"
|
||||
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
|
||||
compile 'com.github.seven332:android-recaptcha:2bbb3459a8'
|
||||
compile 'com.github.seven332:animator:0.1.0'
|
||||
compile 'com.github.seven332:beerbelly:0.1.4'
|
||||
compile 'com.github.seven332:conaco:0.1.5-eh'
|
||||
compile 'com.github.seven332:drawerlayout:0.2.1'
|
||||
compile 'com.github.seven332:easyrecyclerview:0.1.1'
|
||||
compile 'com.github.seven332:glgallery:0.1.2'
|
||||
compile 'com.github.seven332:glview:0.1.0'
|
||||
compile 'com.github.seven332:glview-image:0.1.0'
|
||||
compile 'com.github.seven332:hotspot:0.1.0'
|
||||
compile 'com.github.seven332:image:0.1.12'
|
||||
compile 'com.github.seven332:okhttp:3.5.0'
|
||||
compile 'com.github.seven332:refreshlayout:0.1.0'
|
||||
compile 'com.github.seven332:ripple:0.1.2'
|
||||
compile 'com.github.seven332:streampipe:0.1.0'
|
||||
compile 'com.github.seven332:tuxiang:0.1.2'
|
||||
compile 'com.github.seven332:unifile:0.2.0'
|
||||
compile 'com.github.seven332:yorozuya:0.1.2'
|
||||
compile 'com.github.seven332:yorozuya-thread:0.1.1'
|
||||
compile 'com.github.seven332:yorozuya-collect:0.1.4'
|
||||
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.9.2'
|
||||
compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
||||
compile 'org.greenrobot:greendao:2.2.0'
|
||||
compile 'org.jsoup:jsoup:1.9.2'
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.robolectric:robolectric:3.4'
|
||||
testCompile 'org.jooq:joor:0.9.6'
|
||||
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'
|
||||
implementation 'com.github.seven332:drawerlayout:0.2.1'
|
||||
implementation 'com.github.seven332:easyrecyclerview:0.1.1'
|
||||
implementation 'com.github.seven332:glgallery:0.1.2'
|
||||
implementation 'com.github.seven332:glview:0.1.0'
|
||||
implementation 'com.github.seven332:glview-image:0.1.0'
|
||||
implementation 'com.github.seven332:hotspot:0.1.0'
|
||||
implementation 'com.github.seven332:image:0.1.12'
|
||||
implementation 'com.github.seven332:okhttp:3.5.0'
|
||||
implementation 'com.github.seven332:refreshlayout:0.1.0'
|
||||
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: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.11.0'
|
||||
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
||||
implementation 'org.greenrobot:greendao:2.2.1'
|
||||
implementation 'org.jsoup:jsoup:1.11.3'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
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'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="app_name">EhViewer Debug</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="app_name">EhViewer Debug</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="app_name">EhViewer Debug</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="app_name">EhViewer Debug</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="app_name">EhViewer Debug</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="app_name">EhViewer Debug</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="app_name">EhViewer Debug</string>
|
||||
|
||||
</resources>
|
||||
@@ -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>
|
||||
@@ -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,51 +103,65 @@
|
||||
<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=".ui.UConfigActivity"
|
||||
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.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"/>
|
||||
|
||||
<provider
|
||||
android:name="com.hippo.content.FileProvider"
|
||||
android:authorities="com.hippo.ehviewer.fileprovider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:grantUriPermissions="true"
|
||||
android:exported="false">
|
||||
|
||||
|
||||
@@ -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,11 +26,12 @@ 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;
|
||||
import com.hippo.ehviewer.client.EhEngine;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
@@ -39,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;
|
||||
@@ -48,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;
|
||||
@@ -81,6 +80,7 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
private LruCache<Long, GalleryDetail> mGalleryDetailCache;
|
||||
private SimpleDiskCache mSpiderInfoCache;
|
||||
private DownloadManager mDownloadManager;
|
||||
private Hosts mHosts;
|
||||
|
||||
private final List<Activity> mActivityList = new ArrayList<>();
|
||||
|
||||
@@ -111,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();
|
||||
@@ -147,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() {
|
||||
@@ -238,6 +242,7 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
.readTimeout(10, TimeUnit.SECONDS)
|
||||
.writeTimeout(10, TimeUnit.SECONDS)
|
||||
.cookieJar(getEhCookieStore(application))
|
||||
.dns(new EhDns(application))
|
||||
.build();
|
||||
}
|
||||
return application.mOkHttpClient;
|
||||
@@ -303,6 +308,15 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
return application.mDownloadManager;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Hosts getHosts(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
if (application.mHosts == null) {
|
||||
application.mHosts = new Hosts(application, "hosts.db");
|
||||
}
|
||||
return application.mHosts;
|
||||
}
|
||||
|
||||
private boolean handleException(Throwable ex) {
|
||||
if (ex == null) {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/*
|
||||
* Created by Hippo on 2018/3/21.
|
||||
*/
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Pair;
|
||||
import com.hippo.database.MSQLiteBuilder;
|
||||
import com.hippo.util.SqlUtils;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Hosts {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
private static final String TABLE_HOSTS = "HOSTS";
|
||||
private static final String COLUMN_HOST = "HOST";
|
||||
private static final String COLUMN_IP = "IP";
|
||||
|
||||
private static final int DB_VERSION = VERSION_1;
|
||||
|
||||
private final SQLiteOpenHelper helper;
|
||||
private final SQLiteDatabase db;
|
||||
|
||||
public Hosts(Context context, String name) {
|
||||
helper = new MSQLiteBuilder()
|
||||
.version(VERSION_1)
|
||||
.createTable(TABLE_HOSTS)
|
||||
.insertColumn(TABLE_HOSTS, COLUMN_HOST, String.class)
|
||||
.insertColumn(TABLE_HOSTS, COLUMN_IP, String.class)
|
||||
.build(context, name, DB_VERSION);
|
||||
db = helper.getWritableDatabase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a InetAddress with the host.
|
||||
*/
|
||||
@Nullable
|
||||
public InetAddress get(String host) {
|
||||
if (!isValidHost(host)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_HOSTS + " WHERE " + COLUMN_HOST + " = ?;", new String[] {host});
|
||||
try {
|
||||
if (cursor.moveToNext()) {
|
||||
String ip = SqlUtils.getString(cursor, COLUMN_IP, null);
|
||||
return toInetAddress(host, ip);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean contains(String host) {
|
||||
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_HOSTS + " WHERE " + COLUMN_HOST + " = ?;", new String[] {host});
|
||||
try {
|
||||
return cursor.moveToNext();
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the host-ip pair into this hosts.
|
||||
*/
|
||||
public boolean put(String host, String ip) {
|
||||
if (!isValidHost(host) || !isValidIp(ip)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(COLUMN_HOST, host);
|
||||
values.put(COLUMN_IP, ip);
|
||||
|
||||
if (contains(host)) {
|
||||
db.update(TABLE_HOSTS, values, COLUMN_HOST + " = ?", new String[] { host });
|
||||
} else {
|
||||
db.insert(TABLE_HOSTS, null, values);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts delete the entry with the host.
|
||||
*/
|
||||
public void delete(String host) {
|
||||
db.delete(TABLE_HOSTS, COLUMN_HOST + " = ?", new String[] { host });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all data from this host.
|
||||
*/
|
||||
public List<Pair<String, String>> getAll() {
|
||||
List<Pair<String, String>> result = new ArrayList<>();
|
||||
|
||||
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_HOSTS + ";", null);
|
||||
try {
|
||||
while (cursor.moveToNext()) {
|
||||
String host = SqlUtils.getString(cursor, COLUMN_HOST, null);
|
||||
String ip = SqlUtils.getString(cursor, COLUMN_IP, null);
|
||||
|
||||
InetAddress inetAddress = toInetAddress(host, ip);
|
||||
if (inetAddress == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.add(new Pair<>(host, ip));
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static InetAddress toInetAddress(String host, String ip) {
|
||||
if (!isValidHost(host)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ip == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] bytes = parseV4(ip);
|
||||
if (bytes == null) {
|
||||
bytes = parseV6(ip);
|
||||
}
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return InetAddress.getByAddress(host, bytes);
|
||||
} catch (UnknownHostException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the host is valid.
|
||||
*/
|
||||
public static boolean isValidHost(String host) {
|
||||
if (host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (host.length() > 253) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int labelLength = 0;
|
||||
for (int i = 0, n = host.length(); i < n; i++) {
|
||||
char ch = host.charAt(i);
|
||||
|
||||
if (ch == '.') {
|
||||
if (labelLength < 1 || labelLength > 63) {
|
||||
return false;
|
||||
}
|
||||
labelLength = 0;
|
||||
} else {
|
||||
labelLength++;
|
||||
}
|
||||
|
||||
if ((ch < 'a' || ch > 'z') && (ch < '0' || ch > '9') && ch != '-' && ch != '.') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (labelLength < 1 || labelLength > 63) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the ip is valid.
|
||||
*/
|
||||
public static boolean isValidIp(String ip) {
|
||||
return ip != null && (parseV4(ip) != null || parseV6(ip) != null);
|
||||
}
|
||||
|
||||
// org.xbill.DNS.Address.parseV4
|
||||
@Nullable
|
||||
private static byte[] parseV4(String s) {
|
||||
int numDigits;
|
||||
int currentOctet;
|
||||
byte [] values = new byte[4];
|
||||
int currentValue;
|
||||
int length = s.length();
|
||||
|
||||
currentOctet = 0;
|
||||
currentValue = 0;
|
||||
numDigits = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
char c = s.charAt(i);
|
||||
if (c >= '0' && c <= '9') {
|
||||
/* Can't have more than 3 digits per octet. */
|
||||
if (numDigits == 3)
|
||||
return null;
|
||||
/* Octets shouldn't start with 0, unless they are 0. */
|
||||
if (numDigits > 0 && currentValue == 0)
|
||||
return null;
|
||||
numDigits++;
|
||||
currentValue *= 10;
|
||||
currentValue += (c - '0');
|
||||
/* 255 is the maximum value for an octet. */
|
||||
if (currentValue > 255)
|
||||
return null;
|
||||
} else if (c == '.') {
|
||||
/* Can't have more than 3 dots. */
|
||||
if (currentOctet == 3)
|
||||
return null;
|
||||
/* Two consecutive dots are bad. */
|
||||
if (numDigits == 0)
|
||||
return null;
|
||||
values[currentOctet++] = (byte) currentValue;
|
||||
currentValue = 0;
|
||||
numDigits = 0;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
/* Must have 4 octets. */
|
||||
if (currentOctet != 3)
|
||||
return null;
|
||||
/* The fourth octet can't be empty. */
|
||||
if (numDigits == 0)
|
||||
return null;
|
||||
values[currentOctet] = (byte) currentValue;
|
||||
return values;
|
||||
}
|
||||
|
||||
// org.xbill.DNS.Address.parseV6
|
||||
@Nullable
|
||||
private static byte[] parseV6(String s) {
|
||||
int range = -1;
|
||||
byte [] data = new byte[16];
|
||||
|
||||
String [] tokens = s.split(":", -1);
|
||||
|
||||
int first = 0;
|
||||
int last = tokens.length - 1;
|
||||
|
||||
if (tokens[0].length() == 0) {
|
||||
// If the first two tokens are empty, it means the string
|
||||
// started with ::, which is fine. If only the first is
|
||||
// empty, the string started with :, which is bad.
|
||||
if (last - first > 0 && tokens[1].length() == 0)
|
||||
first++;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
if (tokens[last].length() == 0) {
|
||||
// If the last two tokens are empty, it means the string
|
||||
// ended with ::, which is fine. If only the last is
|
||||
// empty, the string ended with :, which is bad.
|
||||
if (last - first > 0 && tokens[last - 1].length() == 0)
|
||||
last--;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
if (last - first + 1 > 8)
|
||||
return null;
|
||||
|
||||
int i, j;
|
||||
for (i = first, j = 0; i <= last; i++) {
|
||||
if (tokens[i].length() == 0) {
|
||||
if (range >= 0)
|
||||
return null;
|
||||
range = j;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tokens[i].indexOf('.') >= 0) {
|
||||
// An IPv4 address must be the last component
|
||||
if (i < last)
|
||||
return null;
|
||||
// There can't have been more than 6 components.
|
||||
if (i > 6)
|
||||
return null;
|
||||
byte [] v4addr = parseV4(tokens[i]);
|
||||
if (v4addr == null)
|
||||
return null;
|
||||
for (int k = 0; k < 4; k++)
|
||||
data[j++] = v4addr[k];
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
for (int k = 0; k < tokens[i].length(); k++) {
|
||||
char c = tokens[i].charAt(k);
|
||||
if (Character.digit(c, 16) < 0)
|
||||
return null;
|
||||
}
|
||||
int x = Integer.parseInt(tokens[i], 16);
|
||||
if (x > 0xFFFF || x < 0)
|
||||
return null;
|
||||
data[j++] = (byte)(x >>> 8);
|
||||
data[j++] = (byte)(x & 0xFF);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (j < 16 && range < 0)
|
||||
return null;
|
||||
|
||||
if (range >= 0) {
|
||||
int empty = 16 - j;
|
||||
System.arraycopy(data, range, data, range + empty, j - range);
|
||||
for (i = range; i < range + empty; i++)
|
||||
data[i] = 0;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -575,6 +593,19 @@ public class Settings {
|
||||
putInt(KEY_SCREEN_LIGHTNESS, value);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Privacy and Security
|
||||
********************/
|
||||
public static final String KEY_SEC_SECURITY = "enable_secure";
|
||||
public static final boolean VALUE_SEC_SECURITY = false;
|
||||
|
||||
public static boolean getEnabledSecurity() {
|
||||
return getBoolean(KEY_SEC_SECURITY, VALUE_SEC_SECURITY);
|
||||
}
|
||||
public static void putEnabledSecurity(boolean value) {
|
||||
putBoolean(KEY_READING_FULLSCREEN, value);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Download
|
||||
********************/
|
||||
@@ -705,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];
|
||||
@@ -757,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;
|
||||
|
||||
@@ -873,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);
|
||||
@@ -882,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
|
||||
********************/
|
||||
@@ -939,6 +1039,28 @@ public class Settings {
|
||||
return getIntFromStr(KEY_READ_CACHE_SIZE, DEFAULT_READ_CACHE_SIZE);
|
||||
}
|
||||
|
||||
public static final String KEY_BUILT_IN_HOSTS = "built_in_hosts";
|
||||
private static final boolean DEFAULT_BUILT_IN_HOSTS = false;
|
||||
|
||||
public static boolean getBuiltInHosts() {
|
||||
return getBoolean(KEY_BUILT_IN_HOSTS, DEFAULT_BUILT_IN_HOSTS);
|
||||
}
|
||||
|
||||
public static void putBuiltInHosts(boolean value) {
|
||||
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
|
||||
********************/
|
||||
@@ -996,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);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import java.util.List;
|
||||
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Request;
|
||||
|
||||
public class EhCookieStore extends CookieRepository {
|
||||
|
||||
@@ -86,41 +85,26 @@ public class EhCookieStore extends CookieRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cookie> loadForRequest(HttpUrl url, Request request) {
|
||||
List<Cookie> cookies = super.loadForRequest(url, request);
|
||||
Object tag = request.tag();
|
||||
public List<Cookie> loadForRequest(HttpUrl url) {
|
||||
List<Cookie> cookies = super.loadForRequest(url);
|
||||
|
||||
boolean checkTips = domainMatch(url, EhUrl.DOMAIN_E);
|
||||
boolean checkUconfig = (domainMatch(url, EhUrl.DOMAIN_E) || domainMatch(url, EhUrl.DOMAIN_EX)) && tag instanceof EhConfig;
|
||||
|
||||
if (checkTips || checkUconfig) {
|
||||
if (checkTips) {
|
||||
List<Cookie> result = new ArrayList<>(cookies.size() + 1);
|
||||
// Add all but skip some
|
||||
for (Cookie cookie: cookies) {
|
||||
String name = cookie.name();
|
||||
if (checkTips && EhConfig.KEY_CONTENT_WARNING.equals(name)) {
|
||||
if (EhConfig.KEY_CONTENT_WARNING.equals(name)) {
|
||||
continue;
|
||||
}
|
||||
if (checkUconfig && EhConfig.KEY_UCONFIG.equals(name)) {
|
||||
if (EhConfig.KEY_UCONFIG.equals(name)) {
|
||||
continue;
|
||||
}
|
||||
result.add(cookie);
|
||||
}
|
||||
// Add some
|
||||
if (checkTips) {
|
||||
result.add(sTipsCookie);
|
||||
}
|
||||
if (checkUconfig) {
|
||||
EhConfig ehConfig = (EhConfig) tag;
|
||||
Cookie uconfigCookie = new Cookie.Builder()
|
||||
.name(EhConfig.KEY_UCONFIG)
|
||||
.value(ehConfig.uconfig())
|
||||
.domain(url.host())
|
||||
.path("/")
|
||||
.expiresAt(Long.MAX_VALUE)
|
||||
.build();
|
||||
result.add(uconfigCookie);
|
||||
}
|
||||
result.add(sTipsCookie);
|
||||
return Collections.unmodifiableList(result);
|
||||
} else {
|
||||
return cookies;
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.client;
|
||||
|
||||
/*
|
||||
* Created by Hippo on 2018/3/23.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.Hosts;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import okhttp3.Dns;
|
||||
|
||||
public class EhDns implements Dns {
|
||||
|
||||
private static final Map<String, InetAddress> builtInHosts;
|
||||
|
||||
static {
|
||||
Map<String, InetAddress> map = new HashMap<>();
|
||||
put(map, "e-hentai.org", "104.24.255.11");
|
||||
put(map, "forums.e-hentai.org", "94.100.18.243");
|
||||
builtInHosts = map;
|
||||
}
|
||||
|
||||
private static void put(Map<String, InetAddress> map, String host, String ip) {
|
||||
InetAddress address = Hosts.toInetAddress(host, ip);
|
||||
if (address != null) {
|
||||
map.put(host, address);
|
||||
}
|
||||
}
|
||||
|
||||
private final Hosts hosts;
|
||||
|
||||
public EhDns(Context context) {
|
||||
hosts = EhApplication.getHosts(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InetAddress> lookup(String hostname) throws UnknownHostException {
|
||||
if (hostname == null) throw new UnknownHostException("hostname == null");
|
||||
|
||||
InetAddress inetAddress = hosts.get(hostname);
|
||||
if (inetAddress != null) {
|
||||
return Collections.singletonList(inetAddress);
|
||||
}
|
||||
|
||||
if (Settings.getBuiltInHosts()) {
|
||||
inetAddress = builtInHosts.get(hostname);
|
||||
if (inetAddress != null) {
|
||||
return Collections.singletonList(inetAddress);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return Arrays.asList(InetAddress.getAllByName(hostname));
|
||||
} catch (NullPointerException e) {
|
||||
UnknownHostException unknownHostException =
|
||||
new UnknownHostException("Broken system behaviour for dns lookup of " + hostname);
|
||||
unknownHostException.initCause(e);
|
||||
throw unknownHostException;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -91,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();
|
||||
@@ -118,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,
|
||||
@@ -196,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);
|
||||
|
||||
@@ -370,8 +385,7 @@ public class EhEngine {
|
||||
public static GalleryComment[] commentGallery(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient, String url, String comment) throws Exception {
|
||||
FormBody.Builder builder = new FormBody.Builder()
|
||||
.add("commenttext", comment)
|
||||
.add("postcomment", "Post New");
|
||||
.add("commenttext_new", comment);
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(builder.build())
|
||||
@@ -392,6 +406,12 @@ public class EhEngine {
|
||||
headers = response.headers();
|
||||
body = response.body().string();
|
||||
Document document = Jsoup.parse(body);
|
||||
|
||||
Elements elements = document.select("#chd + p");
|
||||
if (elements.size() > 0) {
|
||||
throw new EhException(elements.get(0).text());
|
||||
}
|
||||
|
||||
return GalleryDetailParser.parseComments(document);
|
||||
} catch (Exception e) {
|
||||
throwException(call, code, headers, body, e);
|
||||
@@ -887,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>() {
|
||||
|
||||
@@ -63,8 +63,8 @@ public class GalleryInfo implements Parcelable {
|
||||
|
||||
public static final Pattern[] S_LANG_PATTERNS = {
|
||||
Pattern.compile("[(\\[]eng(?:lish)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
// [((\[]ch(?:inese)?[))\]]|[汉漢]化|中[国國][语語]|中文
|
||||
Pattern.compile("[(\uFF08\\[]ch(?:inese)?[)\uFF09\\]]|[汉漢]化|中[国國][语語]|中文", Pattern.CASE_INSENSITIVE),
|
||||
// [((\[]ch(?:inese)?[))\]]|[汉漢]化|中[国國][语語]|中文|中国翻訳
|
||||
Pattern.compile("[(\uFF08\\[]ch(?:inese)?[)\uFF09\\]]|[汉漢]化|中[国國][语語]|中文|中国翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]spanish[)\\]]|[(\\[]Español[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]korean?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]rus(?:sian)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
@@ -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);
|
||||
}
|
||||
@@ -397,7 +405,7 @@ public class GalleryDetailParser {
|
||||
// time
|
||||
Element c3 = JsoupUtils.getElementByClass(element, "c3");
|
||||
String temp = c3.ownText();
|
||||
temp = temp.substring("Posted on ".length(), temp.length() - " by: ".length());
|
||||
temp = temp.substring("Posted on ".length(), temp.length() - " by:".length());
|
||||
comment.time = WEB_COMMENT_DATE_FORMAT.parse(temp).getTime();
|
||||
// user
|
||||
comment.user = c3.child(0).text();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
|
||||
package com.hippo.ehviewer.download;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
@@ -90,6 +92,8 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
private static int sFinishedCount;
|
||||
private static int sDownloadedCount;
|
||||
|
||||
private String CHANNEL_ID;
|
||||
|
||||
public static void clear() {
|
||||
sFailedCount = 0;
|
||||
sFinishedCount = 0;
|
||||
@@ -102,7 +106,12 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
CHANNEL_ID = getPackageName()+".download";
|
||||
mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
|
||||
mNotifyManager.createNotificationChannel(new NotificationChannel(CHANNEL_ID, getString(R.string.download_service),
|
||||
NotificationManager.IMPORTANCE_LOW));
|
||||
}
|
||||
mDownloadManager = EhApplication.getDownloadManager(getApplicationContext());
|
||||
mDownloadManager.setDownloadListener(this);
|
||||
}
|
||||
@@ -208,14 +217,15 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
stopAllIntent.setAction(ACTION_STOP_ALL);
|
||||
PendingIntent piStopAll = PendingIntent.getService(this, 0, stopAllIntent, 0);
|
||||
|
||||
mDownloadingBuilder = new NotificationCompat.Builder(getApplicationContext())
|
||||
mDownloadingBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download)
|
||||
.setOngoing(true)
|
||||
.setAutoCancel(false)
|
||||
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
|
||||
.setColor(getResources().getColor(R.color.colorPrimary))
|
||||
.addAction(R.drawable.ic_pause_x24, getString(R.string.stat_download_action_stop_all), piStopAll)
|
||||
.setShowWhen(false);
|
||||
.setShowWhen(false)
|
||||
.setChannelId(CHANNEL_ID);
|
||||
|
||||
mDownloadingDelay = new NotificationDelay(this, mNotifyManager, mDownloadingBuilder, ID_DOWNLOADING);
|
||||
}
|
||||
@@ -238,14 +248,15 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
PendingIntent piActivity = PendingIntent.getActivity(DownloadService.this, 0,
|
||||
activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
mDownloadedBuilder = new NotificationCompat.Builder(getApplicationContext())
|
||||
mDownloadedBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
|
||||
.setContentTitle(getString(R.string.stat_download_done_title))
|
||||
.setDeleteIntent(piClear)
|
||||
.setOngoing(false)
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(piActivity);
|
||||
.setContentIntent(piActivity)
|
||||
.setChannelId(CHANNEL_ID);
|
||||
|
||||
mDownloadedDelay = new NotificationDelay(this, mNotifyManager, mDownloadedBuilder, ID_DOWNLOADED);
|
||||
}
|
||||
@@ -255,14 +266,15 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
return;
|
||||
}
|
||||
|
||||
m509dBuilder = new NotificationCompat.Builder(getApplicationContext())
|
||||
m509dBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_stat_alert)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
|
||||
.setContentText(getString(R.string.stat_509_alert_title))
|
||||
.setContentText(getString(R.string.stat_509_alert_text))
|
||||
.setAutoCancel(true)
|
||||
.setOngoing(false)
|
||||
.setCategory(NotificationCompat.CATEGORY_ERROR);
|
||||
.setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||
.setChannelId(CHANNEL_ID);
|
||||
|
||||
m509Delay = new NotificationDelay(this, mNotifyManager, m509dBuilder, ID_509);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,12 @@ public final class SpiderDen {
|
||||
@Nullable
|
||||
public OutputStreamPipe openOutputStreamPipe(int index, @Nullable String extension) {
|
||||
if (mMode == SpiderQueen.MODE_READ) {
|
||||
return openCacheOutputStreamPipe(index);
|
||||
// Return the download pipe is the gallery has been downloaded
|
||||
OutputStreamPipe pipe = openDownloadOutputStreamPipe(index, extension);
|
||||
if (pipe == null) {
|
||||
pipe = openCacheOutputStreamPipe(index);
|
||||
}
|
||||
return pipe;
|
||||
} else if (mMode == SpiderQueen.MODE_DOWNLOAD) {
|
||||
return openDownloadOutputStreamPipe(index, extension);
|
||||
} else {
|
||||
|
||||
@@ -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,20 +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.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);
|
||||
@@ -61,4 +70,37 @@ public abstract class EhActivity extends AppCompatActivity {
|
||||
mTrackStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if(Settings.getEnabledSecurity()){
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
|
||||
WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}else{
|
||||
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,20 +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.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);
|
||||
@@ -61,4 +71,38 @@ public abstract class EhPreferenceActivity extends AppCompatPreferenceActivity {
|
||||
mTrackStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if(Settings.getEnabledSecurity()){
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
|
||||
WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}else{
|
||||
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,8 +48,9 @@ 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;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
@@ -68,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 {
|
||||
@@ -93,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;
|
||||
@@ -172,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;
|
||||
@@ -271,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))
|
||||
@@ -612,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();
|
||||
@@ -836,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;
|
||||
@@ -860,18 +891,16 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
|
||||
|
||||
Uri uri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority("com.hippo.ehviewer.fileprovider")
|
||||
.appendPath("image")
|
||||
.authority(BuildConfig.FILE_PROVIDER_AUTHORITY)
|
||||
.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) {
|
||||
@@ -896,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 {
|
||||
@@ -931,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;
|
||||
@@ -964,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);
|
||||
}
|
||||
@@ -991,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;
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
* 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.ui;
|
||||
|
||||
/*
|
||||
* Created by Hippo on 2018/3/23.
|
||||
*/
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
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;
|
||||
import com.hippo.ehviewer.Hosts;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class HostsActivity extends ToolbarActivity
|
||||
implements EasyRecyclerView.OnItemClickListener, View.OnClickListener {
|
||||
|
||||
private static final String DIALOG_TAG_ADD_HOST = AddHostDialogFragment.class.getName();
|
||||
private static final String DIALOG_TAG_EDIT_HOST = EditHostDialogFragment.class.getName();
|
||||
|
||||
private static final String KEY_HOST = "com.hippo.ehviewer.ui.HostsActivity.HOST";
|
||||
private static final String KEY_IP = "com.hippo.ehviewer.ui.HostsActivity.IP";
|
||||
|
||||
private Hosts hosts;
|
||||
private List<Pair<String, String>> data;
|
||||
|
||||
private EasyRecyclerView recyclerView;
|
||||
private View tip;
|
||||
private HostsAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
hosts = EhApplication.getHosts(this);
|
||||
data = hosts.getAll();
|
||||
|
||||
setContentView(R.layout.activity_hosts);
|
||||
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
|
||||
recyclerView = findViewById(R.id.recycler_view);
|
||||
tip = findViewById(R.id.tip);
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
|
||||
adapter = new HostsAdapter();
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
|
||||
LinearDividerItemDecoration.VERTICAL,
|
||||
AttrResources.getAttrColor(this, R.attr.dividerColor),
|
||||
LayoutUtils.dp2pix(this, 1));
|
||||
decoration.setShowLastDivider(true);
|
||||
recyclerView.addItemDecoration(decoration);
|
||||
recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme)));
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setOnItemClickListener(this);
|
||||
recyclerView.setPadding(
|
||||
recyclerView.getPaddingLeft(),
|
||||
recyclerView.getPaddingTop(),
|
||||
recyclerView.getPaddingRight(),
|
||||
recyclerView.getPaddingBottom() + getResources().getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab));
|
||||
|
||||
fab.setOnClickListener(this);
|
||||
|
||||
recyclerView.setVisibility(data.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
tip.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemClick(EasyRecyclerView easyRecyclerView, View view, int position, long id) {
|
||||
Pair<String, String> pair = data.get(position);
|
||||
Bundle args = new Bundle();
|
||||
args.putString(KEY_HOST, pair.first);
|
||||
args.putString(KEY_IP, pair.second);
|
||||
|
||||
DialogFragment fragment = new EditHostDialogFragment();
|
||||
fragment.setArguments(args);
|
||||
fragment.show(getSupportFragmentManager(), DIALOG_TAG_EDIT_HOST);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new AddHostDialogFragment().show(getSupportFragmentManager(), DIALOG_TAG_ADD_HOST);
|
||||
}
|
||||
|
||||
private void notifyHostsChanges() {
|
||||
data = hosts.getAll();
|
||||
recyclerView.setVisibility(data.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
tip.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private class HostsHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public final TextView host;
|
||||
public final TextView ip;
|
||||
|
||||
public HostsHolder(View itemView) {
|
||||
super(itemView);
|
||||
host = itemView.findViewById(R.id.host);
|
||||
ip = itemView.findViewById(R.id.ip);
|
||||
}
|
||||
}
|
||||
|
||||
private class HostsAdapter extends RecyclerView.Adapter<HostsHolder> {
|
||||
|
||||
private final LayoutInflater inflater = getLayoutInflater();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public HostsHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new HostsHolder(inflater.inflate(R.layout.item_hosts, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull HostsHolder holder, int position) {
|
||||
Pair<String, String> pair = data.get(position);
|
||||
holder.host.setText(pair.first);
|
||||
holder.ip.setText(pair.second);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class HostDialogFragment extends DialogFragment {
|
||||
|
||||
private TextView host;
|
||||
private TextView ip;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_hosts, null, false);
|
||||
host = view.findViewById(R.id.host);
|
||||
ip = view.findViewById(R.id.ip);
|
||||
|
||||
Bundle arguments = getArguments();
|
||||
if (savedInstanceState == null && arguments != null) {
|
||||
host.setText(arguments.getString(KEY_HOST));
|
||||
ip.setText(arguments.getString(KEY_IP));
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).setView(view);
|
||||
onCreateDialogBuilder(builder);
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(d -> onCreateDialog((AlertDialog) d));
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
protected abstract void onCreateDialogBuilder(AlertDialog.Builder builder);
|
||||
|
||||
protected abstract void onCreateDialog(AlertDialog dialog);
|
||||
|
||||
protected void put(AlertDialog dialog) {
|
||||
TextView host = dialog.findViewById(R.id.host);
|
||||
TextView ip = dialog.findViewById(R.id.ip);
|
||||
String hostString = host.getText().toString().trim().toLowerCase(Locale.US);
|
||||
String ipString = ip.getText().toString().trim();
|
||||
|
||||
if (!Hosts.isValidHost(hostString)) {
|
||||
TextInputLayout hostInputLayout = dialog.findViewById(R.id.host_input_layout);
|
||||
hostInputLayout.setError(getContext().getString(R.string.invalid_host));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Hosts.isValidIp(ipString)) {
|
||||
TextInputLayout ipInputLayout = dialog.findViewById(R.id.ip_input_layout);
|
||||
ipInputLayout.setError(getContext().getString(R.string.invalid_ip));
|
||||
return;
|
||||
}
|
||||
|
||||
HostsActivity activity = (HostsActivity) dialog.getOwnerActivity();
|
||||
activity.hosts.put(hostString, ipString);
|
||||
activity.notifyHostsChanges();
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
protected void delete(AlertDialog dialog) {
|
||||
TextView host = dialog.findViewById(R.id.host);
|
||||
String hostString = host.getText().toString().trim().toLowerCase(Locale.US);
|
||||
|
||||
HostsActivity activity = (HostsActivity) dialog.getOwnerActivity();
|
||||
activity.hosts.delete(hostString);
|
||||
activity.notifyHostsChanges();
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public static class AddHostDialogFragment extends HostDialogFragment {
|
||||
|
||||
@Override
|
||||
protected void onCreateDialogBuilder(AlertDialog.Builder builder) {
|
||||
builder.setTitle(R.string.add_host);
|
||||
builder.setPositiveButton(R.string.add_host_add, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreateDialog(AlertDialog dialog) {
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> put(dialog));
|
||||
}
|
||||
}
|
||||
|
||||
public static class EditHostDialogFragment extends HostDialogFragment {
|
||||
|
||||
@Override
|
||||
protected void onCreateDialogBuilder(AlertDialog.Builder builder) {
|
||||
builder.setTitle(R.string.edit_host);
|
||||
builder.setPositiveButton(R.string.edit_host_confirm, null);
|
||||
builder.setNegativeButton(R.string.edit_host_delete, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreateDialog(AlertDialog dialog) {
|
||||
dialog.findViewById(R.id.host_input_layout).setEnabled(false);
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> put(dialog));
|
||||
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener(v -> delete(dialog));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,30 +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.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 {
|
||||
@@ -53,77 +45,20 @@ public final class SettingsActivity extends EhPreferenceActivity {
|
||||
DownloadFragment.class.getName(),
|
||||
AdvancedFragment.class.getName(),
|
||||
AboutFragment.class.getName(),
|
||||
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) {
|
||||
@@ -143,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,22 +19,23 @@ 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.OnPreferenceChangeListener,
|
||||
Preference.OnPreferenceClickListener {
|
||||
implements Preference.OnPreferenceClickListener {
|
||||
|
||||
private static final String KEY_AUTHOR = "author";
|
||||
private static final String KEY_DONATE = "donate";
|
||||
@@ -46,30 +47,14 @@ public class AboutFragment extends PreferenceFragment
|
||||
addPreferencesFromResource(R.xml.about_settings);
|
||||
|
||||
Preference author = findPreference(KEY_AUTHOR);
|
||||
Preference enableAnalytics = findPreference(Settings.KEY_ENABLE_ANALYTICS);
|
||||
Preference donate = findPreference(KEY_DONATE);
|
||||
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);
|
||||
|
||||
enableAnalytics.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
if (Settings.KEY_ENABLE_ANALYTICS.equals(key)) {
|
||||
if (newValue instanceof Boolean && (Boolean) newValue) {
|
||||
Analytics.start(getActivity());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,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,25 +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_PATTERN_PROTECTION = "pattern_protection";
|
||||
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";
|
||||
|
||||
@@ -53,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);
|
||||
|
||||
@@ -60,16 +60,13 @@ public class AdvancedFragment extends PreferenceFragment implements Preference.O
|
||||
clearMemoryCache.setOnPreferenceClickListener(this);
|
||||
exportData.setOnPreferenceClickListener(this);
|
||||
importData.setOnPreferenceClickListener(this);
|
||||
|
||||
appLanguage.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
Preference patternProtection = findPreference(KEY_PATTERN_PROTECTION);
|
||||
patternProtection.setSummary(TextUtils.isEmpty(Settings.getSecurity()) ?
|
||||
R.string.settings_advanced_pattern_protection_not_set :
|
||||
R.string.settings_advanced_pattern_protection_set);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,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)) {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.hippo.ehviewer.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
|
||||
/**
|
||||
* Created by Mo10 on 2018/2/10.
|
||||
*/
|
||||
|
||||
public class PrivacyFragment extends PreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
private static final String KEY_PATTERN_PROTECTION = "pattern_protection";
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.privacy_settings);
|
||||
Preference enableAnalytics = findPreference(Settings.KEY_ENABLE_ANALYTICS);
|
||||
|
||||
enableAnalytics.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Preference patternProtection = findPreference(KEY_PATTERN_PROTECTION);
|
||||
patternProtection.setSummary(TextUtils.isEmpty(Settings.getSecurity()) ?
|
||||
R.string.settings_privacy_pattern_protection_not_set :
|
||||
R.string.settings_privacy_pattern_protection_set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
if (Settings.KEY_ENABLE_ANALYTICS.equals(key)) {
|
||||
if (newValue instanceof Boolean && (Boolean) newValue) {
|
||||
Analytics.start(getActivity());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -40,6 +40,14 @@ public abstract class EhCallback<E extends SceneFragment, T> implements EhClient
|
||||
|
||||
public abstract boolean isInstance(SceneFragment scene);
|
||||
|
||||
public Context getContent() {
|
||||
Context context = getStageActivity();
|
||||
if (context == null) {
|
||||
context = getApplication();
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
public EhApplication getApplication() {
|
||||
return mApplication;
|
||||
}
|
||||
@@ -71,4 +79,14 @@ public abstract class EhCallback<E extends SceneFragment, T> implements EhClient
|
||||
length == BaseScene.LENGTH_LONG ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void showTip(String tip, int length) {
|
||||
StageActivity activity = getStageActivity();
|
||||
if (activity instanceof MainActivity) {
|
||||
((MainActivity) activity).showTip(tip, length);
|
||||
} else {
|
||||
Toast.makeText(getApplication(), tip,
|
||||
length == BaseScene.LENGTH_LONG ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -69,6 +69,7 @@ import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.text.URLImageGetter;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.util.TextUrl;
|
||||
import com.hippo.view.ViewTransition;
|
||||
@@ -82,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,
|
||||
@@ -204,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(),
|
||||
@@ -321,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
|
||||
@@ -337,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();
|
||||
}
|
||||
@@ -636,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);
|
||||
}
|
||||
@@ -737,7 +736,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
showTip(R.string.comment_failed, LENGTH_SHORT);
|
||||
showTip(getContent().getString(R.string.comment_failed) + "\n" + ExceptionUtils.getReadableString(e), LENGTH_SHORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.widget.RecaptchaView;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.yorozuya.IntIdGenerator;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
@@ -328,7 +329,7 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
finish();
|
||||
}
|
||||
|
||||
private void whetherToSkip() {
|
||||
private void whetherToSkip(Exception e) {
|
||||
Context context = getContext2();
|
||||
if (null == context) {
|
||||
return;
|
||||
@@ -336,12 +337,12 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.sign_in_failed)
|
||||
.setMessage(R.string.sign_in_failed_plain)
|
||||
.setMessage(ExceptionUtils.getReadableString(e))
|
||||
.setPositiveButton(R.string.get_it, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
public void onSignInEnd() {
|
||||
public void onSignInEnd(Exception e) {
|
||||
Context context = getContext2();
|
||||
if (null == context) {
|
||||
return;
|
||||
@@ -352,7 +353,7 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
} else {
|
||||
mSigningIn = false;
|
||||
hideProgress();
|
||||
whetherToSkip();
|
||||
whetherToSkip(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +376,7 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
|
||||
SignInScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onSignInEnd();
|
||||
scene.onSignInEnd(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +387,7 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
|
||||
SignInScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onSignInEnd();
|
||||
scene.onSignInEnd(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.hippo.yorozuya.ViewUtils;
|
||||
public class SeekBarPanel extends LinearLayout {
|
||||
|
||||
private SeekBar mSeekBar;
|
||||
private int[] mLocation = new int[2];
|
||||
|
||||
public SeekBarPanel(Context context) {
|
||||
super(context);
|
||||
@@ -54,8 +55,9 @@ public class SeekBarPanel extends LinearLayout {
|
||||
if (mSeekBar == null) {
|
||||
return super.onTouchEvent(event);
|
||||
} else {
|
||||
final float offsetX = -mSeekBar.getLeft();
|
||||
final float offsetY = -mSeekBar.getTop();
|
||||
ViewUtils.getLocationInAncestor(mSeekBar, mLocation, this);
|
||||
final float offsetX = -mLocation[0];
|
||||
final float offsetY = -mLocation[1];
|
||||
event.offsetLocation(offsetX, offsetY);
|
||||
mSeekBar.onTouchEvent(event);
|
||||
event.offsetLocation(-offsetX, -offsetY);
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.regex.Pattern;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.CookieJar;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Request;
|
||||
|
||||
public class CookieRepository implements CookieJar {
|
||||
|
||||
@@ -146,7 +145,7 @@ public class CookieRepository implements CookieJar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cookie> loadForRequest(HttpUrl httpUrl, Request request) {
|
||||
public List<Cookie> loadForRequest(HttpUrl httpUrl) {
|
||||
return getCookies(httpUrl);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -38,6 +36,7 @@ public final class ExceptionUtils {
|
||||
|
||||
@NonNull
|
||||
public static String getReadableString(@NonNull Exception e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof MalformedURLException) {
|
||||
return GetText.getString(R.string.error_invalid_url);
|
||||
} else if (e instanceof ConnectTimeoutException ||
|
||||
@@ -55,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>
|
||||
|
Before Width: | Height: | Size: 376 B |
|
Before Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 249 B |
|
Before Width: | Height: | Size: 246 B |
|
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>
|
||||
|
Before Width: | Height: | Size: 342 B |
|
Before Width: | Height: | Size: 338 B |
|
Before Width: | Height: | Size: 435 B |
|
Before Width: | Height: | Size: 641 B |
|
Before Width: | Height: | Size: 639 B |
|
Before Width: | Height: | Size: 574 B |
@@ -23,7 +23,7 @@
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/big_icon"
|
||||
android:fillColor="?attr/drawableColorSecondary"
|
||||
android:pathData="@string/pd_big_download"/>
|
||||
|
||||
</vector>
|
||||