Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4866e963de | ||
|
|
2b15c8f620 | ||
|
|
d9265610c3 | ||
|
|
81dce7d297 | ||
|
|
078d086362 | ||
|
|
492d483467 | ||
|
|
d9c1b81eb3 | ||
|
|
a2a9dbcb02 | ||
|
|
97c28c04c5 | ||
|
|
f4d8cbf3a4 | ||
|
|
4291493256 | ||
|
|
ce6cb19e73 | ||
|
|
574d09302e | ||
|
|
f37b479400 | ||
|
|
87c27b6256 | ||
|
|
b3881f8562 | ||
|
|
3f8e872d55 | ||
|
|
7e62673e5a | ||
|
|
69be0c48fb | ||
|
|
9d783fa86d | ||
|
|
28b81a0db0 | ||
|
|
3ac1964069 | ||
|
|
a2241e62a3 | ||
|
|
100a3d872e | ||
|
|
413a17acf1 | ||
|
|
79bc2bcd22 | ||
|
|
c6e45cc080 | ||
|
|
7a215acd18 | ||
|
|
3ca6b69984 | ||
|
|
084f352d71 | ||
|
|
f4a16b3edd | ||
|
|
e8d8ee8501 | ||
|
|
9a87701ad6 | ||
|
|
cdc8a7aea6 | ||
|
|
90bfd445d1 | ||
|
|
7493bd57f4 | ||
|
|
629c2bb80d | ||
|
|
4d45d717e2 | ||
|
|
b8e80c6c8c | ||
|
|
efed7776d3 | ||
|
|
56cfc0669b | ||
|
|
6d9ed41382 | ||
|
|
505efbdef6 | ||
|
|
52ab8cebb0 | ||
|
|
e8251ee521 | ||
|
|
d4195c6e5b | ||
|
|
f50975d767 | ||
|
|
4d9452c791 | ||
|
|
474eea094d | ||
|
|
bbb6b634ff | ||
|
|
d5da97141f | ||
|
|
a12f9ba595 | ||
|
|
75944e5a8b | ||
|
|
1aa51a5934 | ||
|
|
092fd6779c | ||
|
|
618dc2b180 | ||
|
|
44a84f2bc2 | ||
|
|
5fb3b61669 | ||
|
|
57a9865d99 | ||
|
|
250e1256b9 | ||
|
|
015bcce8a3 | ||
|
|
b874a259fe | ||
|
|
c8ab84aa9e | ||
|
|
d6efe2c7ba | ||
|
|
46915fed3a | ||
|
|
5d1f599f48 | ||
|
|
9d5877e867 | ||
|
|
e998f80574 |
No files matched your search
@@ -4,15 +4,20 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.2"
|
||||
buildToolsVersion "23.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.hippo.ehviewer"
|
||||
minSdkVersion 16
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 23
|
||||
versionCode 54
|
||||
versionName "1.0.1"
|
||||
versionCode 59
|
||||
versionName "1.0.6"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW"
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -76,12 +81,10 @@ dependencies {
|
||||
compile project(':yorozuya')
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.2.1'
|
||||
compile 'com.android.support:customtabs:23.2.1'
|
||||
compile 'com.android.support:design:23.2.1'
|
||||
compile 'com.android.support:appcompat-v7:23.3.0'
|
||||
compile 'com.android.support:design:23.3.0'
|
||||
compile 'com.github.amlcurran.showcaseview:library:5.4.1'
|
||||
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.8.7'
|
||||
compile 'de.greenrobot:greendao:2.1.0'
|
||||
compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
||||
compile 'org.jsoup:jsoup:1.8.3'
|
||||
}
|
||||
@@ -55,6 +55,19 @@
|
||||
<data android:host="g.e-hentai.org"/>
|
||||
<data android:host="lofi.e-hentai.org"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter android:label="@string/keyword_search">
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter android:label="@string/image_search">
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="image/*"/>
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
@@ -96,7 +109,25 @@
|
||||
android:name="com.hippo.ehviewer.ui.GalleryActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:theme="@style/AppTheme.Gallery"
|
||||
android:launchMode="singleTask"/>
|
||||
android:launchMode="singleTask">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:scheme="file"/>
|
||||
<data android:host="*"/>
|
||||
<data android:pathPattern=".*\\.zip"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:scheme="file"/>
|
||||
<data android:host="*"/>
|
||||
<data android:mimeType="*/*"/>
|
||||
<data android:pathPattern=".*\\.zip"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.SettingsActivity"
|
||||
|
||||
@@ -20,9 +20,15 @@ import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class AppConfig {
|
||||
|
||||
@@ -129,4 +135,31 @@ public class AppConfig {
|
||||
public static File createTempFile() {
|
||||
return FileUtils.createTempFile(getTempDir(), null);
|
||||
}
|
||||
|
||||
public static void saveParseErrorBody(ParseException e) {
|
||||
File dir = getExternalParseErrorDir();
|
||||
if (null == dir) {
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(dir, ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".txt");
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(file);
|
||||
String message = e.getMessage();
|
||||
String body = e.getBody();
|
||||
if (null != message) {
|
||||
os.write(message.getBytes("utf-8"));
|
||||
os.write('\n');
|
||||
}
|
||||
if (null != body) {
|
||||
os.write(body.getBytes("utf-8"));
|
||||
}
|
||||
os.flush();
|
||||
} catch (IOException e1) {
|
||||
// Ignore
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.hippo.conaco.Conaco;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhCookieStore;
|
||||
import com.hippo.ehviewer.client.EhEngine;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.spider.SpiderDen;
|
||||
@@ -42,6 +43,7 @@ import com.hippo.network.StatusCodeException;
|
||||
import com.hippo.okhttp.CookieDB;
|
||||
import com.hippo.scene.SceneApplication;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.BitmapUtils;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
@@ -55,6 +57,8 @@ import java.util.List;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class EhApplication extends SceneApplication implements Thread.UncaughtExceptionHandler {
|
||||
@@ -109,8 +113,18 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
Analytics.start(this);
|
||||
}
|
||||
|
||||
CommonOperations.ensureNoMediaFile(Settings.getDownloadLocation());
|
||||
// Check no media file
|
||||
UniFile downloadLocation = Settings.getDownloadLocation();
|
||||
if (Settings.getMediaScan()) {
|
||||
CommonOperations.removeNoMediaFile(downloadLocation);
|
||||
} else {
|
||||
CommonOperations.ensureNoMediaFile(downloadLocation);
|
||||
}
|
||||
|
||||
// Clear temp dir
|
||||
clearTempDir();
|
||||
|
||||
// Check app update
|
||||
update();
|
||||
|
||||
// Update version code
|
||||
@@ -142,6 +156,29 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
if (version < 52) {
|
||||
Settings.putGuideGallery(true);
|
||||
}
|
||||
if (version < 56) { // Make cookie long live
|
||||
HttpUrl eUrl = HttpUrl.parse(EhUrl.HOST_E);
|
||||
HttpUrl exUrl = HttpUrl.parse(EhUrl.HOST_EX);
|
||||
EhCookieStore cookieStore = getEhCookieStore(this);
|
||||
|
||||
Cookie c;
|
||||
c = cookieStore.get(eUrl, EhCookieStore.KEY_IPD_MEMBER_ID);
|
||||
if (null != c) {
|
||||
cookieStore.add(EhCookieStore.newCookie(c, c.domain(), true, true, true));
|
||||
}
|
||||
c = cookieStore.get(eUrl, EhCookieStore.KEY_IPD_PASS_HASH);
|
||||
if (null != c) {
|
||||
cookieStore.add(EhCookieStore.newCookie(c, c.domain(), true, true, true));
|
||||
}
|
||||
c = cookieStore.get(exUrl, EhCookieStore.KEY_IPD_MEMBER_ID);
|
||||
if (null != c) {
|
||||
cookieStore.add(EhCookieStore.newCookie(c, c.domain(), true, true, true));
|
||||
}
|
||||
c = cookieStore.get(exUrl, EhCookieStore.KEY_IPD_PASS_HASH);
|
||||
if (null != c) {
|
||||
cookieStore.add(EhCookieStore.newCookie(c, c.domain(), true, true, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearMemoryCache() {
|
||||
|
||||
@@ -162,7 +162,12 @@ public class EhDB {
|
||||
gi.category = cursor.getInt(4);
|
||||
gi.thumb = cursor.getString(5);
|
||||
gi.uploader = cursor.getString(6);
|
||||
gi.rating = cursor.getFloat(7);
|
||||
try {
|
||||
// In 0.6.x version, NaN is stored
|
||||
gi.rating = cursor.getFloat(7);
|
||||
} catch (Exception e) {
|
||||
gi.rating = -1.0f;
|
||||
}
|
||||
|
||||
map.put(gi.gid, gi);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.DimenRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
@@ -55,6 +56,7 @@ public class Settings {
|
||||
|
||||
private static EhConfig loadEhConfig() {
|
||||
EhConfig ehConfig= new EhConfig();
|
||||
ehConfig.imageSize = getImageSize();
|
||||
ehConfig.excludedLanguages = getExcludedLanguages();
|
||||
ehConfig.defaultCategories = getDefaultCategories();
|
||||
ehConfig.excludedNamespaces = getExcludedTagNamespaces();
|
||||
@@ -253,6 +255,26 @@ public class Settings {
|
||||
return getIntFromStr(KEY_LIST_MODE, DEFAULT_LIST_MODE);
|
||||
}
|
||||
|
||||
public static final String KEY_THUMB_SIZE = "thumb_size";
|
||||
private static final int DEFAULT_THUMB_SIZE = 1;
|
||||
|
||||
public static int getThumbSize() {
|
||||
return getIntFromStr(KEY_THUMB_SIZE, DEFAULT_THUMB_SIZE);
|
||||
}
|
||||
|
||||
@DimenRes
|
||||
public static int getThumbSizeResId() {
|
||||
switch (getThumbSize()) {
|
||||
case 0:
|
||||
return R.dimen.gallery_grid_column_width_large;
|
||||
default:
|
||||
case 1:
|
||||
return R.dimen.gallery_grid_column_width_middle;
|
||||
case 2:
|
||||
return R.dimen.gallery_grid_column_width_small;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String KEY_SHOW_JPN_TITLE = "show_jpn_title";
|
||||
private static final boolean DEFAULT_SHOW_JPN_TITLE = false;
|
||||
|
||||
@@ -437,6 +459,17 @@ public class Settings {
|
||||
putBoolean(KEY_SHOW_CLOCK, value);
|
||||
}
|
||||
|
||||
private static final String KEY_SHOW_PROGRESS = "gallery_show_progress";
|
||||
private static final boolean DEFAULT_SHOW_PROGRESS = true;
|
||||
|
||||
public static boolean getShowProgress() {
|
||||
return getBoolean(KEY_SHOW_PROGRESS, DEFAULT_SHOW_PROGRESS);
|
||||
}
|
||||
|
||||
public static void putShowProgress(boolean value) {
|
||||
putBoolean(KEY_SHOW_PROGRESS, value);
|
||||
}
|
||||
|
||||
private static final String KEY_SHOW_BATTERY = "gallery_show_battery";
|
||||
private static final boolean DEFAULT_SHOW_BATTERY = true;
|
||||
|
||||
@@ -459,6 +492,39 @@ public class Settings {
|
||||
putBoolean(KEY_VOLUME_PAGE, value);
|
||||
}
|
||||
|
||||
private static final String KEY_READING_FULLSCREEN = "reading_fullscreen";
|
||||
private static final boolean VALUE_READING_FULLSCREEN = true;
|
||||
|
||||
public static boolean getReadingFullscreen() {
|
||||
return getBoolean(KEY_READING_FULLSCREEN, VALUE_READING_FULLSCREEN);
|
||||
}
|
||||
|
||||
public static void putReadingFullscreen(boolean value) {
|
||||
putBoolean(KEY_READING_FULLSCREEN, value);
|
||||
}
|
||||
|
||||
private static final String KEY_CUSTOM_SCREEN_LIGHTNESS = "custom_screen_lightness";
|
||||
private static final boolean DEFAULT_CUSTOM_SCREEN_LIGHTNESS = false;
|
||||
|
||||
public static boolean getCustomScreenLightness() {
|
||||
return getBoolean(KEY_CUSTOM_SCREEN_LIGHTNESS, DEFAULT_CUSTOM_SCREEN_LIGHTNESS);
|
||||
}
|
||||
|
||||
public static void putCustomScreenLightness(boolean value) {
|
||||
putBoolean(KEY_CUSTOM_SCREEN_LIGHTNESS, value);
|
||||
}
|
||||
|
||||
private static final String KEY_SCREEN_LIGHTNESS = "screen_lightness";
|
||||
private static final int DEFAULT_SCREEN_LIGHTNESS = 50;
|
||||
|
||||
public static int getScreenLightness() {
|
||||
return getInt(KEY_SCREEN_LIGHTNESS, DEFAULT_SCREEN_LIGHTNESS);
|
||||
}
|
||||
|
||||
public static void putScreenLightness(int value) {
|
||||
putInt(KEY_SCREEN_LIGHTNESS, value);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Download
|
||||
********************/
|
||||
@@ -493,7 +559,18 @@ public class Settings {
|
||||
putString(KEY_DOWNLOAD_SAVE_QUERY, uri.getEncodedQuery());
|
||||
putString(KEY_DOWNLOAD_SAVE_FRAGMENT, uri.getEncodedFragment());
|
||||
|
||||
CommonOperations.ensureNoMediaFile(location);
|
||||
if (getMediaScan()) {
|
||||
CommonOperations.removeNoMediaFile(location);
|
||||
} else {
|
||||
CommonOperations.ensureNoMediaFile(location);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String KEY_MEDIA_SCAN = "media_scan";
|
||||
private static final boolean DEFAULT_MEDIA_SCAN = false;
|
||||
|
||||
public static boolean getMediaScan() {
|
||||
return getBoolean(KEY_MEDIA_SCAN, DEFAULT_MEDIA_SCAN);
|
||||
}
|
||||
|
||||
private static final String KEY_RECENT_DOWNLOAD_LABEL = "recent_download_label";
|
||||
@@ -551,6 +628,19 @@ public class Settings {
|
||||
putIntToStr(KEY_PRELOAD_IMAGE, value);
|
||||
}
|
||||
|
||||
public static final String KEY_IMAGE_SIZE = "image_size";
|
||||
public static final String DEFAULT_IMAGE_SIZE = EhConfig.IMAGE_SIZE_AUTO;
|
||||
|
||||
public static String getImageSize() {
|
||||
return getString(KEY_IMAGE_SIZE, DEFAULT_IMAGE_SIZE);
|
||||
}
|
||||
|
||||
public static void putImageSize(String value) {
|
||||
sEhConfig.imageSize = value;
|
||||
sEhConfig.setDirty();
|
||||
putString(KEY_IMAGE_SIZE, value);
|
||||
}
|
||||
|
||||
private static final String KEY_DOWNLOAD_ORIGIN_IMAGE = "download_origin_image";
|
||||
private static final boolean DEFAULT_DOWNLOAD_ORIGIN_IMAGE = false;
|
||||
|
||||
@@ -782,6 +872,13 @@ public class Settings {
|
||||
putString(KEY_SECURITY, value);
|
||||
}
|
||||
|
||||
public static final String KEY_READ_CACHE_SIZE = "read_cache_size";
|
||||
public static final int DEFAULT_READ_CACHE_SIZE = 160;
|
||||
|
||||
public static int getReadCacheSize() {
|
||||
return getIntFromStr(KEY_READ_CACHE_SIZE, DEFAULT_READ_CACHE_SIZE);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Guide
|
||||
********************/
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
package com.hippo.ehviewer;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.provider.Browser;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.customtabs.CustomTabsIntent;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -31,14 +29,13 @@ import com.hippo.ehviewer.client.EhUrlOpener;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.StageActivity;
|
||||
import com.hippo.util.CustomTabsHelper;
|
||||
|
||||
public final class UrlOpener {
|
||||
|
||||
private UrlOpener() {
|
||||
}
|
||||
|
||||
public static void openUrl(@NonNull Context context, String url, boolean ehUrl, boolean customTabs) {
|
||||
public static void openUrl(@NonNull Context context, String url, boolean ehUrl) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return;
|
||||
}
|
||||
@@ -59,20 +56,6 @@ public final class UrlOpener {
|
||||
}
|
||||
}
|
||||
|
||||
// CustomTabs
|
||||
if (customTabs && context instanceof Activity) {
|
||||
Activity activity = (Activity) context;
|
||||
String packageName = CustomTabsHelper.getPackageNameToUseFixed(activity);
|
||||
if (packageName != null) {
|
||||
new CustomTabsIntent.Builder()
|
||||
.setToolbarColor(activity.getResources().getColor(R.color.colorPrimary))
|
||||
.setShowTitle(true)
|
||||
.build()
|
||||
.launchUrl(activity, uri);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Intent.ACTION_VIEW
|
||||
intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
|
||||
|
||||
@@ -30,8 +30,20 @@ public class EhConfig implements Cloneable {
|
||||
|
||||
/**
|
||||
* The key of load images through the Hentai@Home Network
|
||||
* @see #LOAD_FROM_HAH_YES
|
||||
* @see #LOAD_FROM_HAH_NO
|
||||
*/
|
||||
private static final String KEY_LOAD_FROM_HAH = "uh";
|
||||
/**
|
||||
* The key of Image Size Settings
|
||||
* @see #IMAGE_SIZE_AUTO
|
||||
* @see #IMAGE_SIZE_780X
|
||||
* @see #IMAGE_SIZE_980X
|
||||
* @see #IMAGE_SIZE_1280X
|
||||
* @see #IMAGE_SIZE_1600X
|
||||
* @see #IMAGE_SIZE_2400X
|
||||
*/
|
||||
private static final String KEY_IMAGE_SIZE = "xr";
|
||||
/**
|
||||
* The key of scale images width
|
||||
*/
|
||||
@@ -40,18 +52,42 @@ public class EhConfig implements Cloneable {
|
||||
* The key of scale images height
|
||||
*/
|
||||
private static final String KEY_SCALE_HEIGHT = "ry";
|
||||
/**
|
||||
* The key of Gallery Name Display
|
||||
* @see #GALLERY_TITLE_DEFAULT
|
||||
* @see #GALLERY_TITLE_JAPANESE
|
||||
*/
|
||||
private static final String KEY_GALLERY_TITLE = "tl";
|
||||
/**
|
||||
* The key of the behavior for downloading archiver
|
||||
* @see #ARCHIVER_DOWNLOAD_MAMS
|
||||
* @see #ARCHIVER_DOWNLOAD_MAAS
|
||||
* @see #ARCHIVER_DOWNLOAD_AAMS
|
||||
* @see #ARCHIVER_DOWNLOAD_AAAS
|
||||
*/
|
||||
private static final String KEY_ARCHIVER_DOWNLOAD = "ar";
|
||||
/**
|
||||
* The key of display mode would you like to use on the front and search pages
|
||||
* @see #LAYOUT_MODE_LIST
|
||||
* @see #LAYOUT_MODE_THUMB
|
||||
*/
|
||||
private static final String KEY_LAYOUT_MODE = "dm";
|
||||
/**
|
||||
* The key for show popular
|
||||
* @see #POPULAR_YES
|
||||
* @see #POPULAR_NO
|
||||
*/
|
||||
private static final String KEY_POPULAR = "prn";
|
||||
/**
|
||||
* The key of categories would you like to view as default on the front page
|
||||
*/
|
||||
private static final String KEY_DEFAULT_CATEGORIES = "cats";
|
||||
/**
|
||||
* The key for favorites sort
|
||||
* @see #FAVORITES_SORT_GALLERY_UPDATE_TIME
|
||||
* @see #FAVORITES_SORT_FAVORITED_TIME
|
||||
*/
|
||||
private static final String KEY_FAVORITES_SORT = "fs";
|
||||
/**
|
||||
* The key of exclude certain namespaces from a default tag search
|
||||
*/
|
||||
@@ -62,34 +98,55 @@ public class EhConfig implements Cloneable {
|
||||
private static final String KEY_EXCLUDED_LANGUAGES = "xl";
|
||||
/**
|
||||
* The key of how many results would you like per page for the index/search page and torrent search pages
|
||||
* @see #RESULT_COUNT_25
|
||||
* @see #RESULT_COUNT_50
|
||||
* @see #RESULT_COUNT_100
|
||||
* @see #RESULT_COUNT_200
|
||||
*/
|
||||
private static final String KEY_RESULT_COUNT = "rc";
|
||||
/**
|
||||
* The key of mouse-over thumb
|
||||
* @see #MOUSE_OVER_YES
|
||||
* @see #MOUSE_OVER_NO
|
||||
*/
|
||||
private static final String KEY_MOUSE_OVER = "tl";
|
||||
private static final String KEY_MOUSE_OVER = "lt";
|
||||
/**
|
||||
* The key of preview size
|
||||
* @see #PREVIEW_SIZE_NORMAL
|
||||
* @see #PREVIEW_SIZE_LARGE
|
||||
*/
|
||||
private static final String KEY_PREVIEW_SIZE = "ts";
|
||||
/**
|
||||
* The key of preview row per page
|
||||
* @see #PREVIEW_ROW_4
|
||||
* @see #PREVIEW_ROW_10
|
||||
* @see #PREVIEW_ROW_20
|
||||
* @see #PREVIEW_ROW_40
|
||||
*/
|
||||
private static final String KEY_PREVIEW_ROW = "tr";
|
||||
/**
|
||||
* The key of sort order for gallery comments
|
||||
* @see #COMMENTS_SORT_OLDEST_FIRST
|
||||
* @see #COMMENTS_SORT_RECENT_FIRST
|
||||
* @see #COMMENTS_SORT_HIGHEST_SCORE_FIRST
|
||||
*/
|
||||
private static final String KEY_COMMENTS_SORT = "cs";
|
||||
/**
|
||||
* The key of show gallery comment votes
|
||||
* @see #COMMENTS_VOTES_POP
|
||||
* @see #COMMENTS_VOTES_ALWAYS
|
||||
*/
|
||||
private static final String KEY_COMMENTS_VOTES = "sc";
|
||||
/**
|
||||
* The key of sort order for gallery tags
|
||||
* @see #TAGS_SORT_ALPHABETICAL
|
||||
* @see #TAGS_SORT_POWER
|
||||
*/
|
||||
private static final String KEY_TAGS_SORT = "to";
|
||||
/**
|
||||
* The key of show gallery page numbers
|
||||
* @see #SHOW_GALLERY_INDEX_NO
|
||||
* @see #SHOW_GALLERY_INDEX_YES
|
||||
*/
|
||||
private static final String KEY_SHOW_GALLERY_INDEX = "pn";
|
||||
/**
|
||||
@@ -104,22 +161,33 @@ public class EhConfig implements Cloneable {
|
||||
private static final String KEY_HAH_CLIENT_PASSKEY = "hk";
|
||||
/**
|
||||
* The key of enable Tag Flagging
|
||||
* @see #ENABLE_TAG_FLAGGING_NO
|
||||
* @see #ENABLE_TAG_FLAGGING_YES
|
||||
*/
|
||||
private static final String KEY_ENABLE_TAG_FLAGGING = "tf";
|
||||
/**
|
||||
* The key of always display the original images instead of the resampled versions
|
||||
* @see #ALWAYS_ORIGINAL_NO
|
||||
* @see #ALWAYS_ORIGINAL_YES
|
||||
*/
|
||||
private static final String KEY_ALWAYS_ORIGINAL = "oi";
|
||||
/**
|
||||
* The key of enable the multi-Page Viewer
|
||||
* @see #MULTI_PAGE_NO
|
||||
* @see #MULTI_PAGE_YES
|
||||
*/
|
||||
private static final String KEY_MULTI_PAGE = "qb";
|
||||
/**
|
||||
* The key of multi-Page Viewer Display Style
|
||||
* @see #MULTI_PAGE_STYLE_C
|
||||
* @see #MULTI_PAGE_STYLE_N
|
||||
* @see #MULTI_PAGE_STYLE_Y
|
||||
*/
|
||||
private static final String KEY_MULTI_PAGE_STYLE = "ms";
|
||||
/**
|
||||
* The key of multi-Page Viewer Thumbnail Pane
|
||||
* @see #MULTI_PAGE_THUMB_HIDE
|
||||
* @see #MULTI_PAGE_THUMB_SHOW
|
||||
*/
|
||||
private static final String KEY_MULTI_PAGE_THUMB = "mt";
|
||||
|
||||
@@ -142,6 +210,40 @@ public class EhConfig implements Cloneable {
|
||||
*/
|
||||
public static final String LOAD_FROM_HAH_NO = "n";
|
||||
|
||||
/**
|
||||
* Image Size Auto
|
||||
*/
|
||||
public static final String IMAGE_SIZE_AUTO = "a";
|
||||
/**
|
||||
* Image Size 780x
|
||||
*/
|
||||
public static final String IMAGE_SIZE_780X = "780";
|
||||
/**
|
||||
* Image Size 980x
|
||||
*/
|
||||
public static final String IMAGE_SIZE_980X = "980";
|
||||
/**
|
||||
* Image Size 1280x
|
||||
*/
|
||||
public static final String IMAGE_SIZE_1280X = "1280";
|
||||
/**
|
||||
* Image Size 1600x
|
||||
*/
|
||||
public static final String IMAGE_SIZE_1600X = "1600";
|
||||
/**
|
||||
* Image Size 2400x
|
||||
*/
|
||||
public static final String IMAGE_SIZE_2400X = "2400";
|
||||
|
||||
/**
|
||||
* Default gallery title
|
||||
*/
|
||||
private static final String GALLERY_TITLE_DEFAULT = "r";
|
||||
/**
|
||||
* Japanese gallery title
|
||||
*/
|
||||
private static final String GALLERY_TITLE_JAPANESE = "j";
|
||||
|
||||
/**
|
||||
* Manual Accept, Manual Start
|
||||
*/
|
||||
@@ -168,6 +270,15 @@ public class EhConfig implements Cloneable {
|
||||
*/
|
||||
public static final String LAYOUT_MODE_THUMB = "t";
|
||||
|
||||
/**
|
||||
* Show popular
|
||||
*/
|
||||
private static final String POPULAR_YES = "y";
|
||||
/**
|
||||
* Don't show popular
|
||||
*/
|
||||
private static final String POPULAR_NO = "n";
|
||||
|
||||
public static final int MISC = 0x1;
|
||||
public static final int DOUJINSHI = 0x2;
|
||||
public static final int MANGA = 0x4;
|
||||
@@ -239,6 +350,15 @@ public class EhConfig implements Cloneable {
|
||||
public static final String OTHER_TRANSLATED = "1279";
|
||||
public static final String OTHER_REWRITE = "2303";
|
||||
|
||||
/**
|
||||
* Sort favorites by last gallery update time
|
||||
*/
|
||||
private static final String FAVORITES_SORT_GALLERY_UPDATE_TIME = "p";
|
||||
/**
|
||||
* Sort favorites by favorited time
|
||||
*/
|
||||
private static final String FAVORITES_SORT_FAVORITED_TIME = "f";
|
||||
|
||||
/**
|
||||
* 25 results per page for the index/search page and torrent search pages
|
||||
*/
|
||||
@@ -412,6 +532,14 @@ public class EhConfig implements Cloneable {
|
||||
*/
|
||||
public String loadFromHAH = LOAD_FROM_HAH_YES;
|
||||
|
||||
/**
|
||||
* Image Size<br/>
|
||||
* key: {@link #KEY_IMAGE_SIZE}<br/>
|
||||
* value: {@link #IMAGE_SIZE_AUTO}, {@link #IMAGE_SIZE_780X}, {@link #IMAGE_SIZE_980X},
|
||||
* {@link #IMAGE_SIZE_1280X}, {@link #IMAGE_SIZE_1600X}, {@link #IMAGE_SIZE_2400X}
|
||||
*/
|
||||
public String imageSize = IMAGE_SIZE_AUTO;
|
||||
|
||||
/**
|
||||
* Scale width<br/>
|
||||
* key: {@link #KEY_SCALE_WIDTH}<br/>
|
||||
@@ -426,6 +554,13 @@ public class EhConfig implements Cloneable {
|
||||
*/
|
||||
public int scaleHeight = 0;
|
||||
|
||||
/**
|
||||
* Gallery title<br/>
|
||||
* key: {@link #KEY_GALLERY_TITLE}<br/>
|
||||
* value: {@link #GALLERY_TITLE_DEFAULT}, {@link #GALLERY_TITLE_JAPANESE}
|
||||
*/
|
||||
public String galleryTitle = GALLERY_TITLE_DEFAULT;
|
||||
|
||||
/**
|
||||
* The default behavior for downloading an archiver<br/>
|
||||
* key: {@link #KEY_ARCHIVER_DOWNLOAD}<br/>
|
||||
@@ -442,6 +577,13 @@ public class EhConfig implements Cloneable {
|
||||
*/
|
||||
public String layoutMode = LAYOUT_MODE_LIST;
|
||||
|
||||
/**
|
||||
* Show popular or not<br/>
|
||||
* key: {@link #KEY_POPULAR}<br/>
|
||||
* value: {@link #POPULAR_YES}, {@link #POPULAR_NO}
|
||||
*/
|
||||
public String popular = POPULAR_YES;
|
||||
|
||||
/**
|
||||
* Default categories on the front page<br/>
|
||||
* key: {@link #KEY_DEFAULT_CATEGORIES}<br/>
|
||||
@@ -450,6 +592,13 @@ public class EhConfig implements Cloneable {
|
||||
*/
|
||||
public int defaultCategories = 0;
|
||||
|
||||
/**
|
||||
* <br/>
|
||||
* key: {@link #KEY_FAVORITES_SORT}<br/>
|
||||
* value: {@link #FAVORITES_SORT_GALLERY_UPDATE_TIME}, {@link #FAVORITES_SORT_FAVORITED_TIME}
|
||||
*/
|
||||
public String favoritesSort = FAVORITES_SORT_FAVORITED_TIME;
|
||||
|
||||
/**
|
||||
* Certain namespaces excluded from a default tag search<br/>
|
||||
* key: {@link #KEY_EXCLUDED_NAMESPACES}<br/>
|
||||
@@ -628,11 +777,15 @@ public class EhConfig implements Cloneable {
|
||||
hahClientIp + "%3A" + hahClientPort : "";
|
||||
String hahClientPasskey = null == this.hahClientPasskey ? "" : this.hahClientPasskey;
|
||||
mUconfig = KEY_LOAD_FROM_HAH + "_" + loadFromHAH + "-" +
|
||||
KEY_IMAGE_SIZE + "_" + imageSize + "-" +
|
||||
KEY_SCALE_WIDTH + "_" + scaleWidth + "-" +
|
||||
KEY_SCALE_HEIGHT + "_" + scaleHeight + "-" +
|
||||
KEY_GALLERY_TITLE + "_" + galleryTitle + "-" +
|
||||
KEY_ARCHIVER_DOWNLOAD + "_" + archiverDownload + "-" +
|
||||
KEY_LAYOUT_MODE + "_" + layoutMode + "-" +
|
||||
KEY_POPULAR + "_" + popular + "-" +
|
||||
KEY_DEFAULT_CATEGORIES + "_" + defaultCategories + "-" +
|
||||
KEY_FAVORITES_SORT + "_" + favoritesSort + "-" +
|
||||
KEY_EXCLUDED_NAMESPACES + "_" + excludedNamespaces + "-" +
|
||||
KEY_EXCLUDED_LANGUAGES + "_" + excludedLanguages + "-" +
|
||||
KEY_RESULT_COUNT + "_" + resultCount + "-" +
|
||||
|
||||
@@ -49,11 +49,15 @@ public class EhCookieStore extends CookieDBStore {
|
||||
contain(EhUrl.DOMAIN_EX, KEY_IPD_PASS_HASH);
|
||||
}
|
||||
|
||||
public static Cookie newCookie(Cookie cookie, String newDomain, boolean forcePersistent, boolean forceNotHostOnly) {
|
||||
public static Cookie newCookie(Cookie cookie, String newDomain, boolean forcePersistent,
|
||||
boolean forceLongLive, boolean forceNotHostOnly) {
|
||||
Cookie.Builder builder = new Cookie.Builder();
|
||||
builder.name(cookie.name());
|
||||
builder.value(cookie.value());
|
||||
if (cookie.persistent()) {
|
||||
|
||||
if (forceLongLive) {
|
||||
builder.expiresAt(Long.MAX_VALUE);
|
||||
} else if (cookie.persistent()) {
|
||||
builder.expiresAt(cookie.expiresAt());
|
||||
} else if (forcePersistent) {
|
||||
builder.expiresAt(Long.MAX_VALUE);
|
||||
@@ -125,7 +129,9 @@ public class EhCookieStore extends CookieDBStore {
|
||||
// Save id and hash for exhentai
|
||||
if (KEY_IPD_MEMBER_ID.equals(cookie.name()) ||
|
||||
KEY_IPD_PASS_HASH.equals(cookie.name())) {
|
||||
result.add(newCookie(cookie, EhUrl.DOMAIN_EX, false, false));
|
||||
result.add(newCookie(cookie, EhUrl.DOMAIN_E, true, true, true));
|
||||
result.add(newCookie(cookie, EhUrl.DOMAIN_EX, true, true, true));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.hippo.ehviewer.client.parser.ForumsParser;
|
||||
import com.hippo.ehviewer.client.parser.GalleryApiParser;
|
||||
import com.hippo.ehviewer.client.parser.GalleryDetailParser;
|
||||
import com.hippo.ehviewer.client.parser.GalleryListParser;
|
||||
import com.hippo.ehviewer.client.parser.GalleryPageParser;
|
||||
import com.hippo.ehviewer.client.parser.GalleryTokenApiParser;
|
||||
import com.hippo.ehviewer.client.parser.ProfileParser;
|
||||
import com.hippo.ehviewer.client.parser.RateGalleryParser;
|
||||
@@ -44,9 +45,7 @@ import com.hippo.ehviewer.client.parser.TorrentParser;
|
||||
import com.hippo.ehviewer.client.parser.VoteCommentParser;
|
||||
import com.hippo.ehviewer.client.parser.WhatsHotParser;
|
||||
import com.hippo.network.StatusCodeException;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
@@ -54,9 +53,6 @@ import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -87,33 +83,6 @@ public class EhEngine {
|
||||
sEhFilter = EhFilter.getInstance();
|
||||
}
|
||||
|
||||
private static void saveParseErrorBody(ParseException e) {
|
||||
File dir = AppConfig.getExternalParseErrorDir();
|
||||
if (null == dir) {
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(dir, ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".txt");
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(file);
|
||||
String message = e.getMessage();
|
||||
String body = e.getBody();
|
||||
if (null != message) {
|
||||
os.write(message.getBytes("utf-8"));
|
||||
os.write('\n');
|
||||
}
|
||||
if (null != body) {
|
||||
os.write(body.getBytes("utf-8"));
|
||||
}
|
||||
os.flush();
|
||||
} catch (IOException e1) {
|
||||
// Ignore
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
}
|
||||
|
||||
private static void throwException(Call call, int code, @Nullable Headers headers,
|
||||
@Nullable String body, Exception e) throws Exception {
|
||||
if (call.isCanceled()) {
|
||||
@@ -132,7 +101,7 @@ public class EhEngine {
|
||||
throw new EhException(body);
|
||||
} else {
|
||||
if (Settings.getSaveParseErrorBody()) {
|
||||
saveParseErrorBody((ParseException) e);
|
||||
AppConfig.saveParseErrorBody((ParseException) e);
|
||||
}
|
||||
throw new EhException(GetText.getString(R.string.error_parse_error));
|
||||
}
|
||||
@@ -500,6 +469,7 @@ public class EhEngine {
|
||||
builder.add("favnote", note != null ? note : "");
|
||||
// submit=Add+to+Favorites is not necessary, just use submit=Apply+Changes all the time
|
||||
builder.add("submit", "Apply Changes");
|
||||
builder.add("update", "1");
|
||||
String url = EhUrl.getAddFavorites(gid, token);
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
@@ -833,4 +803,30 @@ public class EhEngine {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static GalleryPageParser.Result getGalleryPage(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient, String url) throws Exception {
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
int code = -1;
|
||||
try {
|
||||
Response response = call.execute();
|
||||
code = response.code();
|
||||
headers = response.headers();
|
||||
body = response.body().string();
|
||||
return GalleryPageParser.parse(body);
|
||||
} catch (Exception e) {
|
||||
throwException(call, code, headers, body, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ public class EhUrl {
|
||||
public static final String DOMAIN_G = "g.e-hentai.org";
|
||||
public static final String DOMAIN_LOFI = "lofi.e-hentai.org";
|
||||
|
||||
public static final String HOST_E = "http://" + DOMAIN_E + "/";
|
||||
public static final String HOST_EX = "http://" + DOMAIN_EX + "/";
|
||||
public static final String HOST_G = "http://" + DOMAIN_G + "/";
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ public class GalleryDetailParser {
|
||||
if (null != rating_label) {
|
||||
String ratingStr = StringUtils.trim(rating_label.text());
|
||||
if ("Not Yet Rated".equals(ratingStr)) {
|
||||
gd.rating = Float.NaN;
|
||||
gd.rating = -1.0f;
|
||||
} else {
|
||||
int index = ratingStr.indexOf(' ');
|
||||
if (index == -1 || index >= ratingStr.length()) {
|
||||
@@ -208,7 +208,7 @@ public class GalleryDetailParser {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gd.rating = Float.NaN;
|
||||
gd.rating = -1.0f;
|
||||
}
|
||||
|
||||
// isFavorited
|
||||
|
||||
@@ -162,10 +162,10 @@ public class GalleryListParser {
|
||||
// Rating
|
||||
Element it4r = JsoupUtils.getElementByClass(e, "it4r");
|
||||
if (null != it4r) {
|
||||
gi.rating = NumberUtils.parseFloatSafely(parseRating(it4r.attr("style")), Float.NaN);
|
||||
gi.rating = NumberUtils.parseFloatSafely(parseRating(it4r.attr("style")), -1.0f);
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info rating");
|
||||
gi.rating = Float.NaN;
|
||||
gi.rating = -1.0f;
|
||||
}
|
||||
// Uploader
|
||||
Element itu = JsoupUtils.getElementByClass(e, "itu");
|
||||
|
||||
@@ -26,9 +26,9 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class GalleryPageParser {
|
||||
|
||||
private static final Pattern PATTERN_IMAGE_URL = Pattern.compile("<div id=\"i3\"><a[^>]+><img id=\"img\" src=\"([^\"]+)\"");
|
||||
private static final Pattern PATTERN_IMAGE_URL = Pattern.compile("<(?:/iframe|div id=\"i3\")[^>]*><a[^>]+><img[^>]*src=\"(.+?)\"");
|
||||
private static final Pattern PATTERN_SKIP_HATH_KEY = Pattern.compile("onclick=\"return nl\\('([^\\)]+)'\\)");
|
||||
private static final Pattern PATTERN_ORIGIN_IMAGE_URL = Pattern.compile("<div id=\"i7\" class=\"if\"> <img[^>]+/> <a href=\"([^\"]+)\">");
|
||||
private static final Pattern PATTERN_ORIGIN_IMAGE_URL = Pattern.compile("<a href=\"([^\"]+)fullimg.php([^\"]+)\">");
|
||||
|
||||
public static Result parse(String body) throws ParseException {
|
||||
Matcher m;
|
||||
@@ -43,9 +43,10 @@ public class GalleryPageParser {
|
||||
}
|
||||
m = PATTERN_ORIGIN_IMAGE_URL.matcher(body);
|
||||
if (m.find()) {
|
||||
result.originImageUrl = StringUtils.unescapeXml(StringUtils.trim(m.group(1)));
|
||||
result.originImageUrl = StringUtils.unescapeXml(m.group(1)) + "fullimg.php" + StringUtils.unescapeXml(m.group(2));
|
||||
}
|
||||
if (!TextUtils.isEmpty(result.imageUrl) && !TextUtils.isEmpty(result.skipHathKey)) {
|
||||
|
||||
if (!TextUtils.isEmpty(result.imageUrl)) {
|
||||
return result;
|
||||
} else {
|
||||
throw new ParseException("Parse image url and skip hath key error", body);
|
||||
|
||||
@@ -54,15 +54,9 @@ public class EhGalleryProvider extends GalleryProvider implements SpiderQueen.On
|
||||
|
||||
if (mSpiderQueen != null) {
|
||||
mSpiderQueen.removeOnSpiderListener(this);
|
||||
final SpiderQueen spiderQueen = mSpiderQueen;
|
||||
// Activity recreate may called, so wait 3000s
|
||||
SimpleHandler.getInstance().postDelayed(new ReleaseTask(mSpiderQueen), 3000);
|
||||
mSpiderQueen = null;
|
||||
// Activity recreate may called
|
||||
SimpleHandler.getInstance().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SpiderQueen.releaseSpiderQueen(spiderQueen, SpiderQueen.MODE_READ);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,4 +194,21 @@ public class EhGalleryProvider extends GalleryProvider implements SpiderQueen.On
|
||||
public void onGetImageFailure(int index, String error) {
|
||||
notifyPageFailed(index, error);
|
||||
}
|
||||
|
||||
private static class ReleaseTask implements Runnable {
|
||||
|
||||
private SpiderQueen mSpiderQueen;
|
||||
|
||||
public ReleaseTask(SpiderQueen spiderQueen) {
|
||||
mSpiderQueen = spiderQueen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (null != mSpiderQueen) {
|
||||
SpiderQueen.releaseSpiderQueen(mSpiderQueen, SpiderQueen.MODE_READ);
|
||||
mSpiderQueen = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,9 +88,6 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
private static final int METHOD_SET_SCALE_MODE = 18;
|
||||
private static final int METHOD_SET_START_POSITION = 19;
|
||||
private static final int METHOD_ON_ATTACH_TO_ROOT = 20;
|
||||
private static final int METHOD_ON_DETACH_FROM_ROOT = 21;
|
||||
private static final int METHOD_PAUSE = 22;
|
||||
private static final int METHOD_RESUME = 23;
|
||||
|
||||
private final Context mContext;
|
||||
private MovableTextTexture mPageTextTexture;
|
||||
@@ -114,6 +111,7 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
|
||||
private boolean mEnableRequestFill = true;
|
||||
private boolean mRequestFill = false;
|
||||
private boolean mWillFill = false;
|
||||
|
||||
private boolean mScale = false;
|
||||
private boolean mScroll = false;
|
||||
@@ -247,40 +245,17 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
postMethod(METHOD_ON_ATTACH_TO_ROOT);
|
||||
}
|
||||
|
||||
private void onDetachFromRootInternal() {
|
||||
@Override
|
||||
public void onDetachFromRoot() {
|
||||
// When detached, render() will not be called. So do it here
|
||||
detachLayoutManager();
|
||||
if (null != mPageTextTexture) {
|
||||
mPageTextTexture.recycle();
|
||||
mPageTextTexture = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachFromRoot() {
|
||||
super.onDetachFromRoot();
|
||||
mEdgeView.onDetachFromRoot();
|
||||
postMethod(METHOD_ON_DETACH_FROM_ROOT);
|
||||
}
|
||||
|
||||
private void pauseInternal() {
|
||||
mPause = true;
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
postMethod(METHOD_PAUSE);
|
||||
}
|
||||
|
||||
private void resumeInternal() {
|
||||
if (mPause) {
|
||||
mPause = false;
|
||||
if (null != mLayoutManager) {
|
||||
mLayoutManager.bindUnloadedPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
postMethod(METHOD_RESUME);
|
||||
}
|
||||
|
||||
@LayoutMode
|
||||
@@ -311,7 +286,9 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
public void requestFill() {
|
||||
if (mEnableRequestFill) {
|
||||
mRequestFill = true;
|
||||
invalidate();
|
||||
if (!mWillFill) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,15 +762,6 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
case METHOD_ON_ATTACH_TO_ROOT:
|
||||
onAttachToRootInternal();
|
||||
break;
|
||||
case METHOD_ON_DETACH_FROM_ROOT:
|
||||
onDetachFromRootInternal();
|
||||
break;
|
||||
case METHOD_PAUSE:
|
||||
pauseInternal();
|
||||
break;
|
||||
case METHOD_RESUME:
|
||||
resumeInternal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,6 +771,7 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
|
||||
@Override
|
||||
public void render(GLCanvas canvas) {
|
||||
mWillFill = true;
|
||||
int oldCurrentIndex = mCurrentIndex.get();
|
||||
|
||||
// Dispatch method
|
||||
@@ -814,6 +783,7 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
}
|
||||
|
||||
fill();
|
||||
mWillFill = false;
|
||||
|
||||
super.render(canvas);
|
||||
mEdgeView.render(canvas);
|
||||
@@ -975,8 +945,6 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
|
||||
public abstract void onDataChanged();
|
||||
|
||||
public abstract void bindUnloadedPage();
|
||||
|
||||
public abstract void onPageLeft();
|
||||
|
||||
public abstract void onPageRight();
|
||||
|
||||
@@ -449,9 +449,8 @@ public class PagerLayoutManager extends GalleryView.LayoutManager {
|
||||
image.getScaleDefault(scales);
|
||||
float scale = image.getScale();
|
||||
float endScale = scales[0];
|
||||
for (int i = 0, size = scales.length; i < size; i++) {
|
||||
float value = scales[i];
|
||||
if (scale < value) {
|
||||
for (float value: scales) {
|
||||
if (scale < value - 0.01f) {
|
||||
endScale = value;
|
||||
break;
|
||||
}
|
||||
@@ -717,23 +716,6 @@ public class PagerLayoutManager extends GalleryView.LayoutManager {
|
||||
mGalleryView.requestFill();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindUnloadedPage() {
|
||||
if (null == mAdapter) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null != mCurrent && !mCurrent.getImageView().isLoaded()) {
|
||||
mAdapter.bind(mCurrent, mIndex);
|
||||
}
|
||||
if (null != mPrevious && !mPrevious.getImageView().isLoaded()) {
|
||||
mAdapter.bind(mPrevious, mIndex - 1);
|
||||
}
|
||||
if (null != mNext && !mNext.getImageView().isLoaded()) {
|
||||
mAdapter.bind(mNext, mIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageLeft() {
|
||||
int size = mAdapter.size();
|
||||
|
||||
@@ -22,12 +22,15 @@ import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.gallery.GalleryProvider;
|
||||
import com.hippo.gl.anim.Animation;
|
||||
import com.hippo.gl.view.GLView;
|
||||
import com.hippo.gl.widget.GLEdgeView;
|
||||
import com.hippo.gl.widget.GLProgressView;
|
||||
import com.hippo.gl.widget.GLTextureView;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
@@ -39,7 +42,13 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
private static final int INTERVAL = 24;
|
||||
|
||||
private static final float RESERVATIONS = 0.5f;
|
||||
private static final float RESERVATION = 1f;
|
||||
|
||||
private static final float MAX_SCALE = 2.0f;
|
||||
private static final float MIN_SCALE = 1.0f;
|
||||
private static final float SCALE_ERROR = 0.01f;
|
||||
|
||||
private static final int INVALID_TOP = Integer.MAX_VALUE;
|
||||
|
||||
private GalleryView.Adapter mAdapter;
|
||||
|
||||
@@ -49,16 +58,22 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
private final LinkedList<GalleryPageView> mPages = new LinkedList<>();
|
||||
private final LinkedList<GalleryPageView> mTempPages = new LinkedList<>();
|
||||
|
||||
private int mOffset;
|
||||
private float mScale = 0.5f;
|
||||
private int mOffsetX;
|
||||
private int mOffsetY;
|
||||
private int mDeltaX;
|
||||
private int mDeltaY;
|
||||
private int mFirstShownLoadedPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
private int mKeepTopPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
private int mKeepTop = INVALID_TOP;
|
||||
private int mFirstShownPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
private boolean mScrollUp;
|
||||
private boolean mFlingUp;
|
||||
private boolean mStopAnimationFinger;
|
||||
|
||||
private final int mInterval;
|
||||
|
||||
private final PageFling mPageFling;
|
||||
private final SmoothScaler mSmoothScaler;
|
||||
|
||||
// Current index
|
||||
private int mIndex;
|
||||
@@ -71,14 +86,20 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
mInterval = LayoutUtils.dp2pix(context, INTERVAL);
|
||||
mPageFling = new PageFling(context);
|
||||
mSmoothScaler = new SmoothScaler();
|
||||
}
|
||||
|
||||
private void resetParameters() {
|
||||
mOffset = 0;
|
||||
mScale = 1.0f;
|
||||
mOffsetX = 0;
|
||||
mOffsetY = 0;
|
||||
mDeltaX = 0;
|
||||
mDeltaY = 0;
|
||||
mFirstShownLoadedPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
mKeepTopPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
mKeepTop = INVALID_TOP;
|
||||
mFirstShownPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
mScrollUp = false;
|
||||
mFlingUp = false;
|
||||
mStopAnimationFinger = false;
|
||||
}
|
||||
|
||||
@@ -166,6 +187,19 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isInScreen(GalleryPageView page) {
|
||||
int height = mGalleryView.getHeight();
|
||||
Rect bound = page.bounds();
|
||||
int pageTop = bound.top;
|
||||
int pageBottom = bound.bottom;
|
||||
return (pageTop >= 0 && pageTop < height) || (pageBottom > 0 && pageBottom <= height) ||
|
||||
(pageTop < 0 && pageBottom > height);
|
||||
}
|
||||
|
||||
private float getReservation() {
|
||||
return Math.max(RESERVATION, (((1 + 2 * RESERVATION) * mScale) - 1) / 2);
|
||||
}
|
||||
|
||||
private void fillPages(int startIndex, int startOffset) {
|
||||
final GalleryView.Adapter adapter = mAdapter;
|
||||
final GalleryView galleryView = mGalleryView;
|
||||
@@ -173,11 +207,13 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
final LinkedList<GalleryPageView> tempPages = mTempPages;
|
||||
final int width = galleryView.getWidth();
|
||||
final int height = galleryView.getHeight();
|
||||
final int pageWidth = (int) (width * mScale);
|
||||
final int size = adapter.size();
|
||||
final int interval = mInterval;
|
||||
final int minY = (int) (-height * RESERVATIONS);
|
||||
final int maxY = (int) (height * (1 + RESERVATIONS));
|
||||
final int widthSpec = GLView.MeasureSpec.makeMeasureSpec(width, GLView.MeasureSpec.EXACTLY);
|
||||
final float reservation = getReservation();
|
||||
final int minY = (int) (-height * reservation);
|
||||
final int maxY = (int) (height * (1 + reservation));
|
||||
final int widthSpec = GLView.MeasureSpec.makeMeasureSpec(pageWidth, GLView.MeasureSpec.EXACTLY);
|
||||
final int heightSpec = GLView.MeasureSpec.makeMeasureSpec(height, GLView.MeasureSpec.UNSPECIFIED);
|
||||
|
||||
// Fix start index and start offset
|
||||
@@ -241,6 +277,14 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
tempPages.addAll(pages);
|
||||
pages.clear();
|
||||
|
||||
// Sanitize offsetX
|
||||
int margin = pageWidth - width;
|
||||
if (margin >= 0) {
|
||||
mOffsetX = MathUtils.clamp(mOffsetX, -margin, 0);
|
||||
} else {
|
||||
mOffsetX = -margin / 2;
|
||||
}
|
||||
|
||||
// Layout start page
|
||||
GalleryPageView page = getPageForIndex(tempPages, startIndex, true);
|
||||
if (null == page) {
|
||||
@@ -250,7 +294,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
}
|
||||
pages.add(page);
|
||||
page.measure(widthSpec, heightSpec);
|
||||
page.layout(0, startOffset, width, startOffset + page.getMeasuredHeight());
|
||||
page.layout(mOffsetX, startOffset, mOffsetX + pageWidth, startOffset + page.getMeasuredHeight());
|
||||
|
||||
// Prepare for check up and down
|
||||
int bottomOffset = startOffset - interval;
|
||||
@@ -267,7 +311,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
}
|
||||
pages.addFirst(page);
|
||||
page.measure(widthSpec, heightSpec);
|
||||
page.layout(0, bottomOffset - page.getMeasuredHeight(), width, bottomOffset);
|
||||
page.layout(mOffsetX, bottomOffset - page.getMeasuredHeight(), mOffsetX + pageWidth, bottomOffset);
|
||||
// Update
|
||||
bottomOffset -= page.getMeasuredHeight() + interval;
|
||||
index--;
|
||||
@@ -294,7 +338,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
}
|
||||
pages.addLast(page);
|
||||
page.measure(widthSpec, heightSpec);
|
||||
page.layout(0, topOffset, width, topOffset + page.getMeasuredHeight());
|
||||
page.layout(mOffsetX, topOffset, mOffsetX + pageWidth, topOffset + page.getMeasuredHeight());
|
||||
// Update
|
||||
topOffset += page.getMeasuredHeight() + interval;
|
||||
index++;
|
||||
@@ -330,7 +374,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
p.offsetTopAndBottom(offset);
|
||||
}
|
||||
int bottom = pagesTop - interval + offset;
|
||||
page.layout(0, bottom - page.getMeasuredHeight(), width, bottom);
|
||||
page.layout(mOffsetX, bottom - page.getMeasuredHeight(), mOffsetX + pageWidth, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +388,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
if (!pages.isEmpty()) {
|
||||
page = pages.getFirst();
|
||||
mIndex = page.getIndex();
|
||||
mOffset = page.bounds().top;
|
||||
mOffsetY = page.bounds().top;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +398,6 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
GalleryView galleryView = mGalleryView;
|
||||
AssertUtils.assertNotEquals("The PagerLayoutManager is not attached", adapter, null);
|
||||
|
||||
int height = galleryView.getHeight();
|
||||
int size = adapter.size();
|
||||
String errorStr = adapter.getError();
|
||||
|
||||
@@ -418,45 +461,49 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
removeAllPages();
|
||||
}
|
||||
|
||||
// Find first shown loaded page top
|
||||
GalleryPageView firstShownLoadedPage = null;
|
||||
int firstShownLoadedPageTop = mOffset;
|
||||
if (mFirstShownLoadedPageIndex != GalleryPageView.INVALID_INDEX) {
|
||||
// Find keep index and keep top
|
||||
int keepTop = INVALID_TOP;
|
||||
int keepTopIndex;
|
||||
if (GalleryPageView.INVALID_INDEX != mKeepTopPageIndex) {
|
||||
keepTopIndex = mKeepTopPageIndex;
|
||||
keepTop = mKeepTop;
|
||||
} else if (GalleryPageView.INVALID_INDEX != mFirstShownPageIndex) {
|
||||
keepTopIndex = mFirstShownPageIndex;
|
||||
} else {
|
||||
keepTopIndex = GalleryPageView.INVALID_INDEX;
|
||||
}
|
||||
if (GalleryPageView.INVALID_INDEX != keepTopIndex && INVALID_TOP == keepTop) {
|
||||
keepTop = mOffsetY;
|
||||
for (GalleryPageView page : pages) {
|
||||
// Check first shown loaded page
|
||||
if (mFirstShownLoadedPageIndex == page.getIndex()) {
|
||||
firstShownLoadedPage = page;
|
||||
// Check keep page
|
||||
if (keepTopIndex == page.getIndex()) {
|
||||
break;
|
||||
}
|
||||
firstShownLoadedPageTop += page.getHeight() + mInterval;
|
||||
keepTop += page.getHeight() + mInterval;
|
||||
}
|
||||
}
|
||||
|
||||
int startIndex;
|
||||
int startOffset;
|
||||
if (null != firstShownLoadedPage) {
|
||||
startIndex = mFirstShownLoadedPageIndex;
|
||||
startOffset = firstShownLoadedPageTop;
|
||||
if (GalleryPageView.INVALID_INDEX != keepTopIndex) {
|
||||
startIndex = keepTopIndex;
|
||||
startOffset = keepTop;
|
||||
} else {
|
||||
startIndex = mIndex;
|
||||
startOffset = mOffset;
|
||||
startOffset = mOffsetY;
|
||||
}
|
||||
fillPages(startIndex, startOffset);
|
||||
|
||||
// Get first shown loaded image
|
||||
mFirstShownLoadedPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
// Get first shown image
|
||||
mFirstShownPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
for (GalleryPageView page : mPages) {
|
||||
// Check first shown loaded page
|
||||
if (!page.isLoaded()) {
|
||||
if ((mScrollUp || mFlingUp) && !page.isLoaded()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Rect bound = page.bounds();
|
||||
int pageTop = bound.top;
|
||||
int pageBottom = bound.bottom;
|
||||
if ((pageTop >= 0 && pageTop < height) || (pageBottom > 0 && pageBottom <= height) ||
|
||||
(pageTop < 0 && pageBottom > height)) {
|
||||
mFirstShownLoadedPageIndex = page.getIndex();
|
||||
if (isInScreen(page)) {
|
||||
mFirstShownPageIndex = page.getIndex();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -473,12 +520,25 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
@Override
|
||||
public void onUp() {
|
||||
mScrollUp = false;
|
||||
mGalleryView.getEdgeView().onRelease();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDoubleTapConfirmed(float x, float y) {
|
||||
if (mPages.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float startScale = mScale;
|
||||
float endScale;
|
||||
if (startScale < MAX_SCALE - SCALE_ERROR) {
|
||||
endScale = MAX_SCALE;
|
||||
} else {
|
||||
endScale = MIN_SCALE;
|
||||
}
|
||||
|
||||
mSmoothScaler.startSmoothScaler(x, y, startScale, endScale, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -492,7 +552,6 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
mDeltaX += dx;
|
||||
mDeltaY += dy;
|
||||
|
||||
/*
|
||||
if (mDeltaX < 0) {
|
||||
edgeView.onPull(-mDeltaX, y, GLEdgeView.LEFT);
|
||||
if (!edgeView.isFinished(GLEdgeView.RIGHT)) {
|
||||
@@ -504,7 +563,6 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
edgeView.onRelease(GLEdgeView.LEFT);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (mDeltaY < 0) {
|
||||
edgeView.onPull(-mDeltaY, x, GLEdgeView.TOP);
|
||||
@@ -521,7 +579,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
private void getBottomState() {
|
||||
List<GalleryPageView> pages = mPages;
|
||||
int bottom = mOffset;
|
||||
int bottom = mOffsetY;
|
||||
int i = 0;
|
||||
for (GalleryPageView page : pages) {
|
||||
if (i != 0) {
|
||||
@@ -538,49 +596,70 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
// True for get top or bottom
|
||||
private boolean scrollInternal(float dx, float dy, boolean fling, float x, float y) {
|
||||
if (mPages.size() == 0) {
|
||||
if (mPages.size() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GalleryView galleryView = mGalleryView;
|
||||
int width = galleryView.getWidth();
|
||||
int height = galleryView.getHeight();
|
||||
int pageWidth = (int) (width * mScale);
|
||||
final float reservation = getReservation();
|
||||
boolean requestFill = false;
|
||||
int remainY = (int) dy;
|
||||
boolean result = false;
|
||||
|
||||
int margin = pageWidth - width;
|
||||
int dxInt = (int) dx;
|
||||
if (margin > 0 && 0 != dxInt) {
|
||||
int oldOffsetX = mOffsetX;
|
||||
int exceptOffsetX = oldOffsetX - dxInt;
|
||||
mOffsetX = MathUtils.clamp(exceptOffsetX, -margin, 0);
|
||||
if (mOffsetX != oldOffsetX) {
|
||||
requestFill = true;
|
||||
}
|
||||
// Do not show over scroll effect for left and right
|
||||
/*
|
||||
int extraOffsetX = mOffsetX - exceptOffsetX;
|
||||
if (0 != extraOffsetX) {
|
||||
overScrollEdge(extraOffsetX, 0, x, y);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
int remainY = (int) dy;
|
||||
while (remainY != 0) {
|
||||
if (remainY < 0) { // Try to show top
|
||||
int limit;
|
||||
if (mIndex > 0) {
|
||||
limit = (int) (-height * RESERVATIONS) + mInterval;
|
||||
limit = (int) (-height * reservation) + mInterval;
|
||||
} else {
|
||||
limit = 0;
|
||||
}
|
||||
|
||||
if (mOffset - remainY <= limit) {
|
||||
mOffset -= remainY;
|
||||
if (mOffsetY - remainY <= limit) {
|
||||
mOffsetY -= remainY;
|
||||
remainY = 0;
|
||||
requestFill = true;
|
||||
mDeltaX = 0;
|
||||
mDeltaY = 0;
|
||||
} else {
|
||||
if (mIndex > 0) {
|
||||
mOffset = limit;
|
||||
remainY = remainY + limit - mOffset;
|
||||
mOffsetY = limit;
|
||||
remainY = remainY + limit - mOffsetY;
|
||||
// Offset one pixel to avoid infinite loop
|
||||
++mOffset;
|
||||
++mOffsetY;
|
||||
++remainY;
|
||||
galleryView.forceFill();
|
||||
requestFill = false;
|
||||
mDeltaX = 0;
|
||||
mDeltaY = 0;
|
||||
} else {
|
||||
if (mOffset != limit) {
|
||||
mOffset = limit;
|
||||
if (mOffsetY != limit) {
|
||||
mOffsetY = limit;
|
||||
requestFill = true;
|
||||
}
|
||||
if (!fling) {
|
||||
overScrollEdge(0, remainY + limit - mOffset, x, y);
|
||||
overScrollEdge(0, remainY + limit - mOffsetY, x, y);
|
||||
}
|
||||
remainY = 0;
|
||||
result = true;
|
||||
@@ -593,7 +672,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
int limit;
|
||||
if (hasNext) {
|
||||
limit = (int) (height * (1 + RESERVATIONS)) - mInterval;
|
||||
limit = (int) (height * (1 + reservation)) - mInterval;
|
||||
} else {
|
||||
limit = height;
|
||||
}
|
||||
@@ -601,25 +680,25 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
limit = Math.min(bottom, limit);
|
||||
|
||||
if (bottom - remainY >= limit) {
|
||||
mOffset -= remainY;
|
||||
mOffsetY -= remainY;
|
||||
remainY = 0;
|
||||
requestFill = true;
|
||||
mDeltaX = 0;
|
||||
mDeltaY = 0;
|
||||
} else {
|
||||
if (hasNext) {
|
||||
mOffset -= bottom - limit;
|
||||
mOffsetY -= bottom - limit;
|
||||
remainY = remainY + limit - bottom;
|
||||
// Offset one pixel to avoid infinite loop
|
||||
--mOffset;
|
||||
--mOffsetY;
|
||||
--remainY;
|
||||
galleryView.forceFill();
|
||||
requestFill = false;
|
||||
mDeltaX = 0;
|
||||
mDeltaY = 0;
|
||||
} else {
|
||||
if (mOffset != limit) {
|
||||
mOffset -= bottom - limit;
|
||||
if (mOffsetY != limit) {
|
||||
mOffsetY -= bottom - limit;
|
||||
requestFill = true;
|
||||
}
|
||||
if (!fling) {
|
||||
@@ -641,6 +720,8 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
@Override
|
||||
public void onScroll(float dx, float dy, float totalX, float totalY, float x, float y) {
|
||||
mKeepTopPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
mKeepTop = INVALID_TOP;
|
||||
mScrollUp = dy < 0;
|
||||
scrollInternal(dx, dy, false, x, y);
|
||||
}
|
||||
@@ -651,13 +732,28 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
return;
|
||||
}
|
||||
|
||||
mScrollUp = velocityY > 0;
|
||||
mKeepTopPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
mKeepTop = INVALID_TOP;
|
||||
mFlingUp = velocityY > 0;
|
||||
|
||||
int maxX;
|
||||
int minX;
|
||||
int width = mGalleryView.getWidth();
|
||||
int pageWidth = (int) (width * mScale);
|
||||
int margin = pageWidth - width;
|
||||
if (margin > 0) {
|
||||
maxX = -mOffsetX;
|
||||
minX = -margin + mOffsetX;
|
||||
} else {
|
||||
maxX = 0;
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
int maxY;
|
||||
if (mIndex > 0) {
|
||||
maxY = Integer.MAX_VALUE;
|
||||
} else {
|
||||
maxY = -mOffset;
|
||||
maxY = -mOffsetY;
|
||||
}
|
||||
|
||||
getBottomState();
|
||||
@@ -670,23 +766,66 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
minY = mGalleryView.getHeight() - bottom;
|
||||
}
|
||||
|
||||
mPageFling.startFling((int) velocityX, 0, 0,
|
||||
mPageFling.startFling((int) velocityX, minX, maxX,
|
||||
(int) velocityY, minY, maxY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canScale() {
|
||||
return false;
|
||||
return mPages.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScale(float focusX, float focusY, float scale) {
|
||||
if (mPages.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
float oldScale = mScale;
|
||||
mScale = MathUtils.clamp(oldScale * scale, MIN_SCALE, MAX_SCALE);
|
||||
scale = mScale / oldScale;
|
||||
|
||||
if (oldScale != mScale) {
|
||||
GalleryPageView page = null;
|
||||
// Keep scale page origin position
|
||||
for (GalleryPageView p : mPages) {
|
||||
if (p.bounds().top < focusY) {
|
||||
page = p;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null != page) {
|
||||
mKeepTopPageIndex = page.getIndex();
|
||||
mKeepTop = page.bounds().top;
|
||||
|
||||
mGalleryView.forceFill();
|
||||
int oldKeepTop = mKeepTop;
|
||||
mKeepTop = INVALID_TOP;
|
||||
|
||||
// Apply scroll
|
||||
int newOffsetX = (int) (focusX - ((focusX - mOffsetX) * scale));
|
||||
int newKeepTop;
|
||||
if (page.isLoaded()) {
|
||||
newKeepTop = (int) (focusY - ((focusY - oldKeepTop) * scale));
|
||||
} else {
|
||||
newKeepTop = oldKeepTop;
|
||||
}
|
||||
scrollInternal(mOffsetX - newOffsetX, oldKeepTop - newKeepTop, false, focusX, focusY);
|
||||
} else {
|
||||
Log.e(TAG, "Can't find target page");
|
||||
mKeepTopPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
mKeepTop = INVALID_TOP;
|
||||
mGalleryView.forceFill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUpdateAnimation(long time) {
|
||||
boolean invalidate = mPageFling.calculate(time);
|
||||
invalidate |= mSmoothScaler.calculate(time);
|
||||
return invalidate;
|
||||
}
|
||||
|
||||
@@ -705,21 +844,6 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
mGalleryView.requestFill();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindUnloadedPage() {
|
||||
if (null == mAdapter || 0 <= mPages.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = mIndex;
|
||||
for (GalleryPageView page: mPages) {
|
||||
if (!page.getImageView().isLoaded()) {
|
||||
mAdapter.bind(page, index);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageLeft() {
|
||||
int size = mAdapter.size();
|
||||
@@ -727,8 +851,11 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
return;
|
||||
}
|
||||
|
||||
///////
|
||||
// UP
|
||||
///////
|
||||
GalleryView galleryView = mGalleryView;
|
||||
if (mIndex == 0 && mOffset >= 0) {
|
||||
if (mIndex == 0 && mOffsetY >= 0) {
|
||||
GLEdgeView edgeView = galleryView.getEdgeView();
|
||||
edgeView.onPull(galleryView.getHeight(),
|
||||
galleryView.getWidth() / 2, GLEdgeView.TOP);
|
||||
@@ -736,13 +863,37 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
} else {
|
||||
// Cancel all animations
|
||||
cancelAllAnimations();
|
||||
mOffset += galleryView.getHeight() / 2;
|
||||
// Backup offset
|
||||
int offset = mOffset;
|
||||
// Reset parameters
|
||||
resetParameters();
|
||||
// Restore offset
|
||||
mOffset = offset;
|
||||
|
||||
// Get first shown page
|
||||
GalleryPageView previousPage = null;
|
||||
GalleryPageView firstShownPage = null;
|
||||
for (GalleryPageView p: mPages) {
|
||||
if (isInScreen(p)) {
|
||||
firstShownPage = p;
|
||||
break;
|
||||
}
|
||||
previousPage = p;
|
||||
}
|
||||
|
||||
int height = galleryView.getHeight();
|
||||
int maxOffset = height - mInterval;
|
||||
if (null == firstShownPage) {
|
||||
Log.e(TAG, "Can't find first shown page when paging left");
|
||||
mOffsetY += height / 2;
|
||||
} else {
|
||||
int firstShownTop = firstShownPage.bounds().top;
|
||||
if (firstShownTop >= 0) {
|
||||
if (null == previousPage) {
|
||||
Log.e(TAG, "Can't find previous page when paging left and offsetY == 0");
|
||||
mOffsetY += height / 2;
|
||||
} else {
|
||||
mOffsetY += Math.min(maxOffset, -previousPage.bounds().top);
|
||||
}
|
||||
} else {
|
||||
mOffsetY += Math.min(maxOffset, -firstShownTop);
|
||||
}
|
||||
}
|
||||
|
||||
// Request fill
|
||||
mGalleryView.requestFill();
|
||||
}
|
||||
@@ -755,6 +906,9 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
return;
|
||||
}
|
||||
|
||||
/////////
|
||||
// DOWN
|
||||
/////////
|
||||
GalleryView galleryView = mGalleryView;
|
||||
getBottomState();
|
||||
int bottom = mBottomStateBottom;
|
||||
@@ -767,13 +921,38 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
} else {
|
||||
// Cancel all animations
|
||||
cancelAllAnimations();
|
||||
mOffset -= galleryView.getHeight() / 2;
|
||||
// Backup offset
|
||||
int offset = mOffset;
|
||||
// Reset parameters
|
||||
resetParameters();
|
||||
// Restore offset
|
||||
mOffset = offset;
|
||||
|
||||
// Get first shown page
|
||||
GalleryPageView lastShownPage = null;
|
||||
GalleryPageView nextPage = null;
|
||||
for (GalleryPageView p: mPages) {
|
||||
if (isInScreen(p)) {
|
||||
lastShownPage = p;
|
||||
} else if (null != lastShownPage) {
|
||||
nextPage = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int height = galleryView.getHeight();
|
||||
int maxOffset = height - mInterval;
|
||||
if (null == lastShownPage) {
|
||||
Log.e(TAG, "Can't find last shown page when paging left");
|
||||
mOffsetY -= height / 2;
|
||||
} else {
|
||||
int lastShownBottom = lastShownPage.bounds().bottom;
|
||||
if (lastShownBottom <= height) {
|
||||
if (null == nextPage) {
|
||||
Log.e(TAG, "Can't find previous page when paging left and offsetY == 0");
|
||||
mOffsetY -= height / 2;
|
||||
} else {
|
||||
mOffsetY -= Math.min(maxOffset, nextPage.bounds().bottom - height);
|
||||
}
|
||||
} else {
|
||||
mOffsetY -= Math.min(maxOffset, lastShownBottom - height);
|
||||
}
|
||||
}
|
||||
|
||||
// Request fill
|
||||
mGalleryView.requestFill();
|
||||
}
|
||||
@@ -796,13 +975,8 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
@Override
|
||||
public int getCurrentIndex() {
|
||||
int height = mGalleryView.getHeight();
|
||||
for (GalleryPageView page : mPages) {
|
||||
Rect bound = page.bounds();
|
||||
int pageTop = bound.top;
|
||||
int pageBottom = bound.bottom;
|
||||
if ((pageTop >= 0 && pageTop < height) || (pageBottom > 0 && pageBottom <= height) ||
|
||||
(pageTop < 0 && pageBottom > height)) {
|
||||
if (isInScreen(page)) {
|
||||
return page.getIndex();
|
||||
}
|
||||
}
|
||||
@@ -816,9 +990,13 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
// Can't get size now, assume size is MAX
|
||||
size = Integer.MAX_VALUE;
|
||||
}
|
||||
if (index == mIndex || index < 0 || index >= size) {
|
||||
if (index < 0 || index >= size) {
|
||||
return;
|
||||
}
|
||||
|
||||
mKeepTopPageIndex = index;
|
||||
mKeepTop = INVALID_TOP;
|
||||
|
||||
if (mPages.isEmpty()) {
|
||||
mIndex = index;
|
||||
} else {
|
||||
@@ -834,25 +1012,18 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
if (targetPage != null) {
|
||||
// Cancel all animations
|
||||
cancelAllAnimations();
|
||||
mOffset -= targetPage.bounds().top;
|
||||
// Backup offset
|
||||
int offset = mOffset;
|
||||
// Reset parameters
|
||||
resetParameters();
|
||||
// Restore offset
|
||||
mOffset = offset;
|
||||
mOffsetY -= targetPage.bounds().top;
|
||||
// Request fill
|
||||
mGalleryView.requestFill();
|
||||
} else {
|
||||
mIndex = index;
|
||||
mOffsetY = 0;
|
||||
// Cancel all animations
|
||||
cancelAllAnimations();
|
||||
// Remove all view
|
||||
removeProgress();
|
||||
removeErrorView();
|
||||
removeAllPages();
|
||||
// Reset parameters
|
||||
resetParameters();
|
||||
// Request fill
|
||||
mGalleryView.requestFill();
|
||||
}
|
||||
@@ -884,7 +1055,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
class PageFling extends Fling {
|
||||
private class PageFling extends Fling {
|
||||
|
||||
private int mVelocityX;
|
||||
private int mVelocityY;
|
||||
@@ -950,9 +1121,11 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
@Override
|
||||
protected void onFinish() {
|
||||
mFlingUp = false;
|
||||
|
||||
int index = mIndex;
|
||||
|
||||
boolean topEdge = index <= 0 && mOffset >= 0;
|
||||
boolean topEdge = index <= 0 && mOffsetY >= 0;
|
||||
|
||||
getBottomState();
|
||||
int bottom = mBottomStateBottom;
|
||||
@@ -971,4 +1144,40 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SmoothScaler extends Animation {
|
||||
|
||||
private float mFocusX;
|
||||
private float mFocusY;
|
||||
private float mStartScale;
|
||||
private float mEndScale;
|
||||
private float mLastScale;
|
||||
|
||||
public SmoothScaler() {
|
||||
setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
|
||||
}
|
||||
|
||||
public void startSmoothScaler(float focusX, float focusY,
|
||||
float startScale, float endScale, int duration) {
|
||||
mFocusX = focusX;
|
||||
mFocusY = focusY;
|
||||
mStartScale = startScale;
|
||||
mEndScale = endScale;
|
||||
mLastScale = startScale;
|
||||
setDuration(duration);
|
||||
start();
|
||||
mGalleryView.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCalculate(float progress) {
|
||||
if (mPages.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float scale = MathUtils.lerp(mStartScale, mEndScale, progress);
|
||||
onScale(mFocusX, mFocusY, scale / mLastScale);
|
||||
mLastScale = scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
|
||||
public class CleanRedundancyPreference extends TaskPreference {
|
||||
|
||||
public CleanRedundancyPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public CleanRedundancyPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public CleanRedundancyPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Task onCreateTask() {
|
||||
return new ClearTask(getContext());
|
||||
}
|
||||
|
||||
private static class ClearTask extends Task {
|
||||
|
||||
private final EhApplication mApplication;
|
||||
private final DownloadManager mManager;
|
||||
|
||||
public ClearTask(@NonNull Context context) {
|
||||
super(context);
|
||||
mApplication = (EhApplication) context.getApplicationContext();
|
||||
mManager = EhApplication.getDownloadManager(mApplication);
|
||||
}
|
||||
|
||||
// True for cleared
|
||||
private boolean clearFile(UniFile file) {
|
||||
String name = file.getName();
|
||||
int index = name.indexOf('-');
|
||||
if (index >= 0) {
|
||||
name = name.substring(0, index);
|
||||
}
|
||||
long gid = NumberUtils.parseLongSafely(name, -1L);
|
||||
if (-1L == gid) {
|
||||
return false;
|
||||
}
|
||||
if (mManager.containDownloadInfo(gid)) {
|
||||
return false;
|
||||
}
|
||||
file.delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doInBackground(Void... params) {
|
||||
UniFile dir = Settings.getDownloadLocation();
|
||||
if (null == dir) {
|
||||
return 0;
|
||||
}
|
||||
UniFile[] files = dir.listFiles();
|
||||
if (null == files) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (UniFile f: files) {
|
||||
if (clearFile(f)) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Object o) {
|
||||
int count;
|
||||
if (o instanceof Integer) {
|
||||
count = (Integer) o;
|
||||
} else {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
Toast.makeText(mApplication, 0 == count ?
|
||||
mApplication.getString(R.string.settings_download_clean_redundancy_no_redundancy):
|
||||
mApplication.getString(R.string.settings_download_clean_redundancy_done, count), Toast.LENGTH_SHORT).show();
|
||||
super.onPostExecute(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.hippo.unifile.FilenameFilter;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.Utilities;
|
||||
import com.hippo.yorozuya.io.InputStreamPipe;
|
||||
import com.hippo.yorozuya.io.OutputStreamPipe;
|
||||
@@ -54,7 +55,8 @@ public final class SpiderDen {
|
||||
private static SimpleDiskCache sCache;
|
||||
|
||||
public static void initialize(Context context) {
|
||||
sCache = new SimpleDiskCache(new File(context.getCacheDir(), "image"), 160 * 1024 * 1024);
|
||||
sCache = new SimpleDiskCache(new File(context.getCacheDir(), "image"),
|
||||
MathUtils.clamp(Settings.getReadCacheSize(), 40, 640) * 1024 * 1024);
|
||||
}
|
||||
|
||||
private static class StartWithFilenameFilter implements FilenameFilter {
|
||||
|
||||
@@ -102,6 +102,10 @@ public class SpiderInfo {
|
||||
spiderInfo.previewPerPage = Integer.parseInt(IOUtils.readAsciiLine(is));
|
||||
// Pages
|
||||
spiderInfo.pages = Integer.parseInt(IOUtils.readAsciiLine(is));
|
||||
// Check pages
|
||||
if (spiderInfo.pages <= 0) {
|
||||
return null;
|
||||
}
|
||||
// PToken
|
||||
spiderInfo.pTokenMap = new SparseArray<>(spiderInfo.pages);
|
||||
while (true) { // EOFException will raise
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.hippo.ehviewer.GetText;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhConfig;
|
||||
import com.hippo.ehviewer.client.EhEngine;
|
||||
import com.hippo.ehviewer.client.EhRequestBuilder;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
@@ -48,6 +49,7 @@ import com.hippo.ehviewer.gallery.GalleryProvider;
|
||||
import com.hippo.ehviewer.gallery.gl.GalleryPageView;
|
||||
import com.hippo.image.Image;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.OSUtils;
|
||||
@@ -64,7 +66,6 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -421,11 +422,11 @@ public class SpiderQueen implements Runnable {
|
||||
}
|
||||
|
||||
public Object forceRequest(int index) {
|
||||
return request(index, true);
|
||||
return request(index, true, false);
|
||||
}
|
||||
|
||||
public Object request(int index) {
|
||||
return request(index, false);
|
||||
return request(index, false, true);
|
||||
}
|
||||
|
||||
private int getPageState(int index) {
|
||||
@@ -471,7 +472,7 @@ public class SpiderQueen implements Runnable {
|
||||
* Float for download percent<br>
|
||||
* null for wait
|
||||
*/
|
||||
private Object request(int index, boolean force) {
|
||||
private Object request(int index, boolean force, boolean addNeighbor) {
|
||||
if (mQueenThread == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -494,8 +495,8 @@ public class SpiderQueen implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
// For not force add, add next some pages to request queue
|
||||
if (!force) {
|
||||
// Add next some pages to request queue
|
||||
if (addNeighbor) {
|
||||
mRequestPageQueue2.clear();
|
||||
int[] pageStateArray = mPageStateArray;
|
||||
int size;
|
||||
@@ -905,6 +906,55 @@ public class SpiderQueen implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePageState(int index, @State int state) {
|
||||
updatePageState(index, state, null);
|
||||
}
|
||||
|
||||
private boolean isStateDone(int state) {
|
||||
return state == STATE_FINISHED || state == STATE_FAILED;
|
||||
}
|
||||
|
||||
private void updatePageState(int index, @State int state, String error) {
|
||||
int oldState;
|
||||
synchronized (mPageStateLock) {
|
||||
oldState = mPageStateArray[index];
|
||||
mPageStateArray[index] = state;
|
||||
|
||||
if (!isStateDone(oldState) && isStateDone(state)) {
|
||||
mDownloadedPages.incrementAndGet();
|
||||
} else if (isStateDone(oldState) && !isStateDone(state)) {
|
||||
mDownloadedPages.decrementAndGet();
|
||||
}
|
||||
if (oldState != STATE_FINISHED && state == STATE_FINISHED) {
|
||||
mFinishedPages.incrementAndGet();
|
||||
} else if (oldState == STATE_FINISHED && state != STATE_FINISHED) {
|
||||
mFinishedPages.decrementAndGet();
|
||||
}
|
||||
|
||||
// Clear
|
||||
if (state == STATE_DOWNLOADING) {
|
||||
mPageErrorMap.remove(index);
|
||||
} else if (state == STATE_FINISHED || state == STATE_FAILED) {
|
||||
mPagePercentMap.remove(index);
|
||||
}
|
||||
|
||||
// Get default error
|
||||
if (state == STATE_FAILED) {
|
||||
if (error == null) {
|
||||
error = GetText.getString(R.string.error_unknown);
|
||||
}
|
||||
mPageErrorMap.put(index, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify listeners
|
||||
if (state == STATE_FAILED) {
|
||||
notifyPageFailure(index, error);
|
||||
} else if (state == STATE_FINISHED) {
|
||||
notifyPageSuccess(index);
|
||||
}
|
||||
}
|
||||
|
||||
private class SpiderWorker implements Runnable {
|
||||
|
||||
private final long mGid;
|
||||
@@ -913,67 +963,14 @@ public class SpiderQueen implements Runnable {
|
||||
mGid = mGalleryInfo.gid;
|
||||
}
|
||||
|
||||
private void updatePageState(int index, @State int state) {
|
||||
updatePageState(index, state, null);
|
||||
}
|
||||
|
||||
private boolean isStateDone(int state) {
|
||||
return state == STATE_FINISHED || state == STATE_FAILED;
|
||||
}
|
||||
|
||||
private void updatePageState(int index, @State int state, String error) {
|
||||
int oldState;
|
||||
synchronized (mPageStateLock) {
|
||||
oldState = mPageStateArray[index];
|
||||
mPageStateArray[index] = state;
|
||||
|
||||
if (!isStateDone(oldState) && isStateDone(state)) {
|
||||
mDownloadedPages.incrementAndGet();
|
||||
} else if (isStateDone(oldState) && !isStateDone(state)) {
|
||||
mDownloadedPages.decrementAndGet();
|
||||
}
|
||||
if (oldState != STATE_FINISHED && state == STATE_FINISHED) {
|
||||
mFinishedPages.incrementAndGet();
|
||||
} else if (oldState == STATE_FINISHED && state != STATE_FINISHED) {
|
||||
mFinishedPages.decrementAndGet();
|
||||
}
|
||||
|
||||
// Clear
|
||||
if (state == STATE_DOWNLOADING) {
|
||||
mPageErrorMap.remove(index);
|
||||
} else if (state == STATE_FINISHED || state == STATE_FAILED) {
|
||||
mPagePercentMap.remove(index);
|
||||
}
|
||||
|
||||
// Get default error
|
||||
if (state == STATE_FAILED) {
|
||||
if (error == null) {
|
||||
error = GetText.getString(R.string.error_unknown);
|
||||
}
|
||||
mPageErrorMap.put(index, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify listeners
|
||||
if (state == STATE_FAILED) {
|
||||
notifyPageFailure(index, error);
|
||||
} else if (state == STATE_FINISHED) {
|
||||
notifyPageSuccess(index);
|
||||
}
|
||||
}
|
||||
|
||||
private GalleryPageParser.Result getImageUrl(long gid, int index, String pToken,
|
||||
String skipHathKey) throws IOException, ParseException, Image509Exception {
|
||||
String skipHathKey) throws Exception {
|
||||
String url = EhUrl.getPageUrl(gid, index, pToken);
|
||||
if (skipHathKey != null) {
|
||||
url = url + "?nl=" + skipHathKey;
|
||||
}
|
||||
if (DEBUG_LOG) {
|
||||
Log.d(TAG, url);
|
||||
}
|
||||
Response response = mHttpClient.newCall(new EhRequestBuilder(url).build()).execute();
|
||||
String body = response.body().string();
|
||||
GalleryPageParser.Result result = GalleryPageParser.parse(body);
|
||||
|
||||
GalleryPageParser.Result result = EhEngine.getGalleryPage(null, mHttpClient, url);
|
||||
if (StringUtils.endsWith(result.imageUrl, URL_509_SUFFIX_ARRAY)) {
|
||||
// Get 509
|
||||
// Notify listeners
|
||||
@@ -993,17 +990,18 @@ public class SpiderQueen implements Runnable {
|
||||
|
||||
// Try twice
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (i > 0 && TextUtils.isEmpty(skipHathKey)) {
|
||||
// No need to get image url twice without skip hath key
|
||||
break;
|
||||
}
|
||||
|
||||
GalleryPageParser.Result result = null;
|
||||
try {
|
||||
result = getImageUrl(gid, index, pToken, skipHathKey);
|
||||
} catch (MalformedURLException e) {
|
||||
error = GetText.getString(R.string.error_invalid_url);
|
||||
} catch (IOException e) {
|
||||
error = GetText.getString(R.string.error_socket);
|
||||
} catch (ParseException e) {
|
||||
error = GetText.getString(R.string.error_parse_error);
|
||||
} catch (Image509Exception e) {
|
||||
error = GetText.getString(R.string.error_509);
|
||||
} catch (Exception e) {
|
||||
error = ExceptionUtils.getReadableString(e);
|
||||
}
|
||||
if (result == null) {
|
||||
// Get image url failed
|
||||
@@ -1294,7 +1292,10 @@ public class SpiderQueen implements Runnable {
|
||||
InputStreamPipe pipe = mSpiderDen.openInputStreamPipe(index);
|
||||
if (pipe == null) {
|
||||
mDecodingIndex.lazySet(GalleryPageView.INVALID_INDEX);
|
||||
notifyGetImageFailure(index, GetText.getString(R.string.error_not_found));
|
||||
// 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);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class CommonOperations {
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
UrlOpener.openUrl(mActivity, url, false, false);
|
||||
UrlOpener.openUrl(mActivity, url, false);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
@@ -309,4 +309,15 @@ public final class CommonOperations {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeNoMediaFile(UniFile file) {
|
||||
if (null == file) {
|
||||
return;
|
||||
}
|
||||
|
||||
UniFile noMedia = file.subFile(".nomedia");
|
||||
if (null != noMedia && noMedia.isFile()) {
|
||||
noMedia.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,10 @@ import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Spinner;
|
||||
@@ -63,8 +65,10 @@ import com.hippo.gl.view.GLRootView;
|
||||
import com.hippo.image.Image;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.SystemUiHelper;
|
||||
import com.hippo.widget.ColorView;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.ConcurrentPool;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
@@ -81,6 +85,7 @@ public class GalleryActivity extends EhActivity
|
||||
|
||||
public static final String KEY_ACTION = "action";
|
||||
public static final String KEY_FILENAME = "filename";
|
||||
public static final String KEY_URI = "uri";
|
||||
public static final String KEY_GALLERY_INFO = "gallery_info";
|
||||
public static final String KEY_PAGE = "page";
|
||||
public static final String KEY_CURRENT_INDEX = "current_index";
|
||||
@@ -90,6 +95,7 @@ public class GalleryActivity extends EhActivity
|
||||
|
||||
private String mAction;
|
||||
private String mFilename;
|
||||
private Uri mUri;
|
||||
private GalleryInfo mGalleryInfo;
|
||||
private int mPage;
|
||||
|
||||
@@ -105,9 +111,13 @@ public class GalleryActivity extends EhActivity
|
||||
private SystemUiHelper mSystemUiHelper;
|
||||
private boolean mShowSystemUi;
|
||||
|
||||
@Nullable
|
||||
private ColorView mMaskView;
|
||||
@Nullable
|
||||
private View mClock;
|
||||
@Nullable
|
||||
private TextView mProgress;
|
||||
@Nullable
|
||||
private View mBattery;
|
||||
@Nullable
|
||||
private View mSeekBarPanel;
|
||||
@@ -178,6 +188,11 @@ public class GalleryActivity extends EhActivity
|
||||
if (mGalleryInfo != null) {
|
||||
mGalleryProvider = new EhGalleryProvider(this, mGalleryInfo);
|
||||
}
|
||||
} else if (Intent.ACTION_VIEW.equals(mAction)) {
|
||||
if (mUri != null) {
|
||||
// Only support zip now
|
||||
mGalleryProvider = new ZipGalleryProvider(new File(mUri.getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +204,7 @@ public class GalleryActivity extends EhActivity
|
||||
|
||||
mAction = intent.getAction();
|
||||
mFilename = intent.getStringExtra(KEY_FILENAME);
|
||||
mUri = intent.getData();
|
||||
mGalleryInfo = intent.getParcelableExtra(KEY_GALLERY_INFO);
|
||||
mPage = intent.getIntExtra(KEY_PAGE, -1);
|
||||
buildProvider();
|
||||
@@ -197,6 +213,7 @@ public class GalleryActivity extends EhActivity
|
||||
private void onRestore(@NonNull Bundle savedInstanceState) {
|
||||
mAction = savedInstanceState.getString(KEY_ACTION);
|
||||
mFilename = savedInstanceState.getString(KEY_FILENAME);
|
||||
mUri= savedInstanceState.getParcelable(KEY_URI);
|
||||
mGalleryInfo = savedInstanceState.getParcelable(KEY_GALLERY_INFO);
|
||||
mPage = savedInstanceState.getInt(KEY_PAGE, -1);
|
||||
mCurrentIndex = savedInstanceState.getInt(KEY_CURRENT_INDEX);
|
||||
@@ -208,6 +225,7 @@ public class GalleryActivity extends EhActivity
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString(KEY_ACTION, mAction);
|
||||
outState.putString(KEY_FILENAME, mFilename);
|
||||
outState.putParcelable(KEY_URI, mUri);
|
||||
if (mGalleryInfo != null) {
|
||||
outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo);
|
||||
}
|
||||
@@ -217,6 +235,14 @@ public class GalleryActivity extends EhActivity
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
if (Settings.getReadingFullscreen() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window w = getWindow();
|
||||
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
|
||||
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
||||
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
|
||||
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
@@ -250,20 +276,25 @@ public class GalleryActivity extends EhActivity
|
||||
glRootView.setContentPane(mGalleryView);
|
||||
|
||||
// System UI helper
|
||||
int systemUiLevel;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
systemUiLevel = SystemUiHelper.LEVEL_IMMERSIVE;
|
||||
} else {
|
||||
systemUiLevel = SystemUiHelper.LEVEL_LOW_PROFILE;
|
||||
if (Settings.getReadingFullscreen()) {
|
||||
int systemUiLevel;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
systemUiLevel = SystemUiHelper.LEVEL_IMMERSIVE;
|
||||
} else {
|
||||
systemUiLevel = SystemUiHelper.LEVEL_HIDE_STATUS_BAR;
|
||||
}
|
||||
mSystemUiHelper = new SystemUiHelper(this, systemUiLevel,
|
||||
SystemUiHelper.FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES | SystemUiHelper.FLAG_IMMERSIVE_STICKY);
|
||||
mSystemUiHelper.hide();
|
||||
mShowSystemUi = false;
|
||||
}
|
||||
mSystemUiHelper = new SystemUiHelper(this, systemUiLevel,
|
||||
SystemUiHelper.FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES | SystemUiHelper.FLAG_IMMERSIVE_STICKY);
|
||||
mSystemUiHelper.hide();
|
||||
mShowSystemUi = false;
|
||||
|
||||
mMaskView = (ColorView) ViewUtils.$$(this, R.id.mask);
|
||||
mClock = ViewUtils.$$(this, R.id.clock);
|
||||
mProgress = (TextView) ViewUtils.$$(this, R.id.progress);
|
||||
mBattery = ViewUtils.$$(this, R.id.battery);
|
||||
mClock.setVisibility(Settings.getShowClock() ? View.VISIBLE : View.GONE);
|
||||
mProgress.setVisibility(Settings.getShowProgress() ? View.VISIBLE : View.GONE);
|
||||
mBattery.setVisibility(Settings.getShowBattery() ? View.VISIBLE : View.GONE);
|
||||
|
||||
mSeekBarPanel = ViewUtils.$$(this, R.id.seek_bar_panel);
|
||||
@@ -300,6 +331,9 @@ public class GalleryActivity extends EhActivity
|
||||
}
|
||||
setRequestedOrientation(orientation);
|
||||
|
||||
// Screen lightness
|
||||
setScreenLightness(Settings.getCustomScreenLightness(), Settings.getScreenLightness());
|
||||
|
||||
if (Settings.getGuideGallery()) {
|
||||
FrameLayout mainLayout = (FrameLayout) ViewUtils.$$(this, R.id.main);
|
||||
mainLayout.addView(new GalleryGuideView(this));
|
||||
@@ -320,6 +354,10 @@ public class GalleryActivity extends EhActivity
|
||||
mGalleryProvider = null;
|
||||
}
|
||||
|
||||
mMaskView = null;
|
||||
mClock = null;
|
||||
mProgress = null;
|
||||
mBattery = null;
|
||||
mSeekBarPanel = null;
|
||||
mLeftText = null;
|
||||
mRightText = null;
|
||||
@@ -328,24 +366,6 @@ public class GalleryActivity extends EhActivity
|
||||
SimpleHandler.getInstance().removeCallbacks(mHideSliderRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if (null != mGalleryView) {
|
||||
mGalleryView.pause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (null != mGalleryView) {
|
||||
mGalleryView.resume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
@@ -452,6 +472,18 @@ public class GalleryActivity extends EhActivity
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void updateProgress() {
|
||||
if (mProgress == null) {
|
||||
return;
|
||||
}
|
||||
if (mSize <= 0 || mCurrentIndex < 0) {
|
||||
mProgress.setText(null);
|
||||
} else {
|
||||
mProgress.setText((mCurrentIndex + 1) + "/" + mSize);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void updateSlider() {
|
||||
if (mSeekBar == null || mRightText == null || mLeftText == null || mSize <= 0 || mCurrentIndex < 0) {
|
||||
@@ -667,6 +699,34 @@ public class GalleryActivity extends EhActivity
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lightness 0 - 200
|
||||
*/
|
||||
private void setScreenLightness(boolean enable, int lightness) {
|
||||
if (null == mMaskView) {
|
||||
return;
|
||||
}
|
||||
|
||||
Window w = getWindow();
|
||||
WindowManager.LayoutParams lp = w.getAttributes();
|
||||
if (enable) {
|
||||
lightness = MathUtils.clamp(lightness, 0, 200);
|
||||
if (lightness > 100) {
|
||||
mMaskView.setColor(0);
|
||||
// Avoid BRIGHTNESS_OVERRIDE_OFF,
|
||||
// screen may be off when lp.screenBrightness is 0.0f
|
||||
lp.screenBrightness = Math.max((lightness - 100) / 100.0f, 0.01f);
|
||||
} else {
|
||||
mMaskView.setColor(MathUtils.lerp(0xde, 0x00, lightness / 100.0f) << 24);
|
||||
lp.screenBrightness = 0.01f;
|
||||
}
|
||||
} else {
|
||||
mMaskView.setColor(0);
|
||||
lp.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
|
||||
}
|
||||
w.setAttributes(lp);
|
||||
}
|
||||
|
||||
private class GalleryMenuHelper implements DialogInterface.OnClickListener {
|
||||
|
||||
private final View mView;
|
||||
@@ -676,8 +736,12 @@ public class GalleryActivity extends EhActivity
|
||||
private final Spinner mStartPosition;
|
||||
private final SwitchCompat mKeepScreenOn;
|
||||
private final SwitchCompat mShowClock;
|
||||
private final SwitchCompat mShowProgress;
|
||||
private final SwitchCompat mShowBattery;
|
||||
private final SwitchCompat mVolumePage;
|
||||
private final SwitchCompat mReadingFullscreen;
|
||||
private final SwitchCompat mCustomScreenLightness;
|
||||
private final SeekBar mScreenLightness;
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
public GalleryMenuHelper(Context context) {
|
||||
@@ -688,8 +752,12 @@ public class GalleryActivity extends EhActivity
|
||||
mStartPosition = (Spinner) mView.findViewById(R.id.start_position);
|
||||
mKeepScreenOn = (SwitchCompat) mView.findViewById(R.id.keep_screen_on);
|
||||
mShowClock = (SwitchCompat) mView.findViewById(R.id.show_clock);
|
||||
mShowProgress = (SwitchCompat) mView.findViewById(R.id.show_progress);
|
||||
mShowBattery = (SwitchCompat) mView.findViewById(R.id.show_battery);
|
||||
mVolumePage = (SwitchCompat) mView.findViewById(R.id.volume_page);
|
||||
mReadingFullscreen = (SwitchCompat) mView.findViewById(R.id.reading_fullscreen);
|
||||
mCustomScreenLightness = (SwitchCompat) mView.findViewById(R.id.custom_screen_lightness);
|
||||
mScreenLightness = (SeekBar) mView.findViewById(R.id.screen_lightness);
|
||||
|
||||
mScreenRotation.setSelection(Settings.getScreenRotation());
|
||||
mReadingDirection.setSelection(Settings.getReadingDirection());
|
||||
@@ -697,8 +765,20 @@ public class GalleryActivity extends EhActivity
|
||||
mStartPosition.setSelection(Settings.getStartPosition());
|
||||
mKeepScreenOn.setChecked(Settings.getKeepScreenOn());
|
||||
mShowClock.setChecked(Settings.getShowClock());
|
||||
mShowProgress.setChecked(Settings.getShowProgress());
|
||||
mShowBattery.setChecked(Settings.getShowBattery());
|
||||
mVolumePage.setChecked(Settings.getVolumePage());
|
||||
mReadingFullscreen.setChecked(Settings.getReadingFullscreen());
|
||||
mCustomScreenLightness.setChecked(Settings.getCustomScreenLightness());
|
||||
mScreenLightness.setProgress(Settings.getScreenLightness());
|
||||
mScreenLightness.setEnabled(Settings.getCustomScreenLightness());
|
||||
|
||||
mCustomScreenLightness.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mScreenLightness.setEnabled(isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
@@ -713,8 +793,14 @@ public class GalleryActivity extends EhActivity
|
||||
int startPosition = ImageView.sanitizeStartPosition(mStartPosition.getSelectedItemPosition());
|
||||
boolean keepScreenOn = mKeepScreenOn.isChecked();
|
||||
boolean showClock = mShowClock.isChecked();
|
||||
boolean showProgress = mShowProgress.isChecked();
|
||||
boolean showBattery = mShowBattery.isChecked();
|
||||
boolean volumePage = mVolumePage.isChecked();
|
||||
boolean readingFullscreen = mReadingFullscreen.isChecked();
|
||||
boolean customScreenLightness = mCustomScreenLightness.isChecked();
|
||||
int screenLightness = mScreenLightness.getProgress();
|
||||
|
||||
boolean oldReadingFullscreen = Settings.getReadingFullscreen();
|
||||
|
||||
Settings.putScreenRotation(screenRotation);
|
||||
Settings.putReadingDirection(layoutMode);
|
||||
@@ -722,8 +808,12 @@ public class GalleryActivity extends EhActivity
|
||||
Settings.putStartPosition(startPosition);
|
||||
Settings.putKeepScreenOn(keepScreenOn);
|
||||
Settings.putShowClock(showClock);
|
||||
Settings.putShowProgress(showProgress);
|
||||
Settings.putShowBattery(showBattery);
|
||||
Settings.putVolumePage(volumePage);
|
||||
Settings.putReadingFullscreen(readingFullscreen);
|
||||
Settings.putCustomScreenLightness(customScreenLightness);
|
||||
Settings.putScreenLightness(screenLightness);
|
||||
|
||||
int orientation;
|
||||
switch (screenRotation) {
|
||||
@@ -752,13 +842,21 @@ public class GalleryActivity extends EhActivity
|
||||
if (mClock != null) {
|
||||
mClock.setVisibility(showClock ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (mProgress != null) {
|
||||
mProgress.setVisibility(showProgress ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (mBattery != null) {
|
||||
mBattery.setVisibility(showBattery ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
setScreenLightness(customScreenLightness, screenLightness);
|
||||
|
||||
// Update slider
|
||||
mLayoutMode = layoutMode;
|
||||
updateSlider();
|
||||
|
||||
if (oldReadingFullscreen != readingFullscreen) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -893,10 +991,12 @@ public class GalleryActivity extends EhActivity
|
||||
case KEY_SIZE:
|
||||
GalleryActivity.this.mSize = mValue;
|
||||
updateSlider();
|
||||
updateProgress();
|
||||
break;
|
||||
case KEY_CURRENT_INDEX:
|
||||
GalleryActivity.this.mCurrentIndex = mValue;
|
||||
updateSlider();
|
||||
updateProgress();
|
||||
break;
|
||||
case KEY_TAP_MENU_AREA:
|
||||
onTapMenuArea();
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.hippo.ehviewer.ui;
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
@@ -28,7 +30,6 @@ import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -39,11 +40,13 @@ import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.EhUrlOpener;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.ui.scene.AnalyticsScene;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
import com.hippo.ehviewer.ui.scene.CookieSignInScene;
|
||||
@@ -64,16 +67,24 @@ import com.hippo.ehviewer.ui.scene.SelectSiteScene;
|
||||
import com.hippo.ehviewer.ui.scene.SignInScene;
|
||||
import com.hippo.ehviewer.ui.scene.WarningScene;
|
||||
import com.hippo.ehviewer.ui.scene.WebViewSignInScene;
|
||||
import com.hippo.io.UniFileInputStreamPipe;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.StageActivity;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.BitmapUtils;
|
||||
import com.hippo.util.PermissionRequester;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout;
|
||||
import com.hippo.widget.drawerlayout.DrawerLayout;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.ResourcesUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public final class MainActivity extends StageActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
@@ -99,7 +110,7 @@ public final class MainActivity extends StageActivity
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private SlidingDrawerLayout mDrawerLayout;
|
||||
private DrawerLayout mDrawerLayout;
|
||||
@Nullable
|
||||
private NavigationView mNavView;
|
||||
@Nullable
|
||||
@@ -253,6 +264,38 @@ public final class MainActivity extends StageActivity
|
||||
return announcer;
|
||||
}
|
||||
|
||||
private File saveImageToTempFile(UniFile file) {
|
||||
if (null == file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
bitmap = BitmapUtils.decodeStream(new UniFileInputStreamPipe(file), -1, -1, 500 * 500, false, false, null);
|
||||
} catch (OutOfMemoryError e) {
|
||||
// Ignore
|
||||
}
|
||||
if (null == bitmap) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File temp = AppConfig.createTempFile();
|
||||
if (null == temp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(temp);
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
|
||||
return temp;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleIntent(Intent intent) {
|
||||
if (intent == null) {
|
||||
return false;
|
||||
@@ -265,6 +308,29 @@ public final class MainActivity extends StageActivity
|
||||
startScene(processAnnouncer(announcer));
|
||||
return true;
|
||||
}
|
||||
} else if (Intent.ACTION_SEND.equals(action)) {
|
||||
String type = intent.getType();
|
||||
if ("text/plain".equals(type)) {
|
||||
ListUrlBuilder builder = new ListUrlBuilder();
|
||||
builder.setKeyword(intent.getStringExtra(Intent.EXTRA_TEXT));
|
||||
startScene(processAnnouncer(GalleryListScene.getStartAnnouncer(builder)));
|
||||
return true;
|
||||
} else if (type.startsWith("image/")) {
|
||||
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (null != uri) {
|
||||
UniFile file = UniFile.fromUri(this, uri);
|
||||
File temp = saveImageToTempFile(file);
|
||||
if (null != temp) {
|
||||
ListUrlBuilder builder = new ListUrlBuilder();
|
||||
builder.setMode(ListUrlBuilder.MODE_IMAGE_SEARCH);
|
||||
builder.setImagePath(temp.getPath());
|
||||
builder.setUseSimilarityScan(true);
|
||||
builder.setShowExpunged(true);
|
||||
startScene(processAnnouncer(GalleryListScene.getStartAnnouncer(builder)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -292,7 +358,7 @@ public final class MainActivity extends StageActivity
|
||||
protected void onCreate2(@Nullable Bundle savedInstanceState) {
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
mDrawerLayout = (SlidingDrawerLayout) ViewUtils.$$(this, R.id.draw_view);
|
||||
mDrawerLayout = (DrawerLayout) ViewUtils.$$(this, R.id.draw_view);
|
||||
mNavView = (NavigationView) ViewUtils.$$(this, R.id.nav_view);
|
||||
mRightDrawer = (FrameLayout) ViewUtils.$$(this, R.id.right_drawer);
|
||||
View headerLayout = mNavView.getHeaderView(0);
|
||||
@@ -323,7 +389,8 @@ public final class MainActivity extends StageActivity
|
||||
|
||||
private void checkDownloadLocation() {
|
||||
UniFile uniFile = Settings.getDownloadLocation();
|
||||
if (null != uniFile && uniFile.ensureDir()) {
|
||||
// null == uniFile for first start
|
||||
if (null == uniFile || uniFile.ensureDir()) {
|
||||
return;
|
||||
}
|
||||
new AlertDialog.Builder(this)
|
||||
@@ -390,9 +457,9 @@ public final class MainActivity extends StageActivity
|
||||
baseScene.getLayoutInflater2(), mRightDrawer, savedInstanceState);
|
||||
if (drawerView != null) {
|
||||
mRightDrawer.addView(drawerView);
|
||||
mDrawerLayout.setDrawerLockMode(SlidingDrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
|
||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
|
||||
} else {
|
||||
mDrawerLayout.setDrawerLockMode(SlidingDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
|
||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.hippo.ehviewer.ui;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -62,6 +63,17 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
|
||||
mPatternView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == mCancel) {
|
||||
|
||||
@@ -32,10 +32,13 @@ import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.DirPickerActivity;
|
||||
import com.hippo.unifile.UniFile;
|
||||
|
||||
public class DownloadFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
|
||||
public class DownloadFragment extends PreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener,
|
||||
Preference.OnPreferenceClickListener {
|
||||
|
||||
public static final int REQUEST_CODE_PICK_IMAGE_DIR = 0;
|
||||
public static final int REQUEST_CODE_PICK_IMAGE_DIR_L = 1;
|
||||
@@ -50,10 +53,15 @@ public class DownloadFragment extends PreferenceFragment implements Preference.O
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.download_settings);
|
||||
|
||||
Preference mediaScan = findPreference(Settings.KEY_MEDIA_SCAN);
|
||||
Preference imageSize = findPreference(Settings.KEY_IMAGE_SIZE);
|
||||
mDownloadLocation = findPreference(KEY_DOWNLOAD_LOCATION);
|
||||
|
||||
onUpdateDownloadLocation();
|
||||
|
||||
mediaScan.setOnPreferenceChangeListener(this);
|
||||
imageSize.setOnPreferenceChangeListener(this);
|
||||
|
||||
if (mDownloadLocation != null) {
|
||||
mDownloadLocation.setOnPreferenceClickListener(this);
|
||||
}
|
||||
@@ -181,4 +189,26 @@ public class DownloadFragment extends PreferenceFragment implements Preference.O
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
if (Settings.KEY_MEDIA_SCAN.equals(key)) {
|
||||
if (newValue instanceof Boolean) {
|
||||
UniFile downloadLocation = Settings.getDownloadLocation();
|
||||
if ((Boolean) newValue) {
|
||||
CommonOperations.removeNoMediaFile(downloadLocation);
|
||||
} else {
|
||||
CommonOperations.ensureNoMediaFile(downloadLocation);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (Settings.KEY_IMAGE_SIZE.equals(key)) {
|
||||
if (newValue instanceof String) {
|
||||
Settings.putImageSize((String) newValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,11 @@ public class EhFragment extends PreferenceFragment
|
||||
|
||||
Preference gallerySite = findPreference(Settings.KEY_GALLERY_SITE);
|
||||
Preference listMode = findPreference(Settings.KEY_LIST_MODE);
|
||||
Preference thumbSize = findPreference(Settings.KEY_THUMB_SIZE);
|
||||
|
||||
gallerySite.setOnPreferenceChangeListener(this);
|
||||
listMode.setOnPreferenceChangeListener(this);
|
||||
thumbSize.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,6 +50,8 @@ public class EhFragment extends PreferenceFragment
|
||||
} else if (Settings.KEY_LIST_MODE.equals(key)) {
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
return true;
|
||||
} else if (Settings.KEY_THUMB_SIZE.equals(key)) {
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ 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.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.SimpleItemAnimator;
|
||||
import android.support.v7.widget.StaggeredGridLayoutManager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
@@ -45,6 +45,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
@@ -59,6 +60,7 @@ import com.hippo.app.CheckBoxDialogBuilder;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.easyrecyclerview.HandlerDrawable;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -82,12 +84,12 @@ import com.hippo.util.DrawableManager;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.FabLayout;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.LongList;
|
||||
import com.hippo.yorozuya.ObjectUtils;
|
||||
import com.hippo.yorozuya.ResourcesUtils;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -131,7 +133,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
@Nullable
|
||||
private DownloadAdapter mAdapter;
|
||||
@Nullable
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private AutoStaggeredGridLayoutManager mLayoutManager;
|
||||
|
||||
private ShowcaseView mShowcaseView;
|
||||
|
||||
@@ -278,6 +280,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
|
||||
Context context = getContext2();
|
||||
AssertUtils.assertNotNull(content);
|
||||
Resources resources = context.getResources();
|
||||
|
||||
Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_download);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
@@ -286,7 +289,9 @@ public class DownloadsScene extends ToolbarScene
|
||||
mAdapter = new DownloadAdapter();
|
||||
mAdapter.setHasStableIds(true);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mLayoutManager = new LinearLayoutManager(context);
|
||||
mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
|
||||
mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(R.dimen.gallery_list_column_width));
|
||||
mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
@@ -301,9 +306,12 @@ public class DownloadsScene extends ToolbarScene
|
||||
if (itemAnimator instanceof SimpleItemAnimator) {
|
||||
((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
|
||||
}
|
||||
int paddingH = context.getResources().getDimensionPixelOffset(R.dimen.list_content_margin_h);
|
||||
int paddingV = context.getResources().getDimensionPixelOffset(R.dimen.list_content_margin_v);
|
||||
mRecyclerView.setPadding(paddingV, paddingH, paddingV, paddingH);
|
||||
int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
|
||||
int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
|
||||
int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
|
||||
MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
|
||||
mRecyclerView.addItemDecoration(decoration);
|
||||
decoration.applyPaddings(mRecyclerView);
|
||||
if (mInitPosition >= 0) {
|
||||
mRecyclerView.scrollToPosition(mInitPosition);
|
||||
mInitPosition = -1;
|
||||
@@ -328,11 +336,16 @@ public class DownloadsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
private void guide() {
|
||||
if (Settings.getGuideDownloadThumb()) {
|
||||
SimpleHandler.getInstance().post(new Runnable() {
|
||||
if (Settings.getGuideDownloadThumb() && null != mRecyclerView) {
|
||||
mRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void run() {
|
||||
guideDownloadThumb();
|
||||
public void onGlobalLayout() {
|
||||
if (Settings.getGuideDownloadThumb()) {
|
||||
guideDownloadThumb();
|
||||
}
|
||||
if (null != mRecyclerView) {
|
||||
ViewUtils.removeOnGlobalLayoutListener(mRecyclerView.getViewTreeObserver(), this);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -346,7 +359,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
guideDownloadLabels();
|
||||
return;
|
||||
}
|
||||
int position = mLayoutManager.findFirstCompletelyVisibleItemPosition();
|
||||
int position = mLayoutManager.findFirstCompletelyVisibleItemPositions(null)[0];
|
||||
if (position < 0) {
|
||||
guideDownloadLabels();
|
||||
return;
|
||||
|
||||
@@ -244,7 +244,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
Context context = getContext2();
|
||||
AssertUtils.assertNotNull(context);
|
||||
Resources resources = context.getResources();
|
||||
int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.list_padding_top_search_bar);
|
||||
int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
|
||||
|
||||
mHelper = new FavoritesHelper();
|
||||
mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit));
|
||||
@@ -260,8 +260,6 @@ public class FavoritesScene extends BaseScene implements
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
|
||||
mRecyclerView.setCustomCheckedListener(this);
|
||||
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop() + paddingTopSB,
|
||||
mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
|
||||
|
||||
fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
|
||||
fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());
|
||||
|
||||
@@ -33,12 +33,12 @@ import android.widget.TextView;
|
||||
import com.hippo.drawable.TriangleDrawable;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.widget.TileThumb;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.widget.recyclerview.AutoGridLayoutManager;
|
||||
import com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -58,7 +58,9 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
private final Resources mResources;
|
||||
private final RecyclerView mRecyclerView;
|
||||
private final AutoStaggeredGridLayoutManager mLayoutManager;
|
||||
private RecyclerView.ItemDecoration mGirdDecoration;
|
||||
private final int mPaddingTopSB;
|
||||
private MarginItemDecoration mListDecoration;
|
||||
private MarginItemDecoration mGirdDecoration;
|
||||
private int mType = TYPE_INVALID;
|
||||
|
||||
public GalleryAdapter(@NonNull LayoutInflater inflater, @NonNull Resources resources,
|
||||
@@ -67,16 +69,20 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
mResources = resources;
|
||||
mRecyclerView = recyclerView;
|
||||
mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
|
||||
mPaddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
|
||||
|
||||
mRecyclerView.setAdapter(this);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
|
||||
int paddingH = mResources.getDimensionPixelOffset(R.dimen.list_content_margin_h);
|
||||
int paddingV = mResources.getDimensionPixelOffset(R.dimen.list_content_margin_v);
|
||||
mRecyclerView.setPadding(paddingV, paddingH, paddingV, paddingH);
|
||||
setType(type);
|
||||
}
|
||||
|
||||
private void adjustPaddings() {
|
||||
RecyclerView recyclerView = mRecyclerView;
|
||||
recyclerView.setPadding(recyclerView.getPaddingLeft(), recyclerView.getPaddingTop() + mPaddingTopSB,
|
||||
recyclerView.getPaddingRight(), recyclerView.getPaddingBottom());
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return mType;
|
||||
}
|
||||
@@ -87,27 +93,44 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
}
|
||||
mType = type;
|
||||
|
||||
RecyclerView recyclerView = mRecyclerView;
|
||||
switch (type) {
|
||||
default:
|
||||
case GalleryAdapter.TYPE_LIST: {
|
||||
int columnWidth = mResources.getDimensionPixelOffset(R.dimen.gallery_list_column_width);
|
||||
mLayoutManager.setColumnSize(columnWidth);
|
||||
mLayoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_MIN_SIZE);
|
||||
mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
|
||||
if (null != mGirdDecoration) {
|
||||
mRecyclerView.removeItemDecoration(mGirdDecoration);
|
||||
recyclerView.removeItemDecoration(mGirdDecoration);
|
||||
}
|
||||
if (null == mListDecoration) {
|
||||
int interval = mResources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
|
||||
int paddingH = mResources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
|
||||
int paddingV = mResources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
|
||||
mListDecoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
|
||||
}
|
||||
recyclerView.addItemDecoration(mListDecoration);
|
||||
mListDecoration.applyPaddings(recyclerView);
|
||||
adjustPaddings();
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case GalleryAdapter.TYPE_GRID: {
|
||||
int columnWidth = mResources.getDimensionPixelOffset(R.dimen.gallery_grid_column_width);
|
||||
int columnWidth = mResources.getDimensionPixelOffset(Settings.getThumbSizeResId());
|
||||
mLayoutManager.setColumnSize(columnWidth);
|
||||
mLayoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE);
|
||||
if (null == mGirdDecoration) {
|
||||
mGirdDecoration = new MarginItemDecoration(
|
||||
mResources.getDimensionPixelOffset(R.dimen.gallery_grid_margin) / 2);
|
||||
mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_SUITABLE_SIZE);
|
||||
if (null != mListDecoration) {
|
||||
recyclerView.removeItemDecoration(mListDecoration);
|
||||
}
|
||||
mRecyclerView.addItemDecoration(mGirdDecoration);
|
||||
if (null == mGirdDecoration) {
|
||||
int interval = mResources.getDimensionPixelOffset(R.dimen.gallery_grid_interval);
|
||||
int paddingH = mResources.getDimensionPixelOffset(R.dimen.gallery_grid_margin_h);
|
||||
int paddingV = mResources.getDimensionPixelOffset(R.dimen.gallery_grid_margin_v);
|
||||
mGirdDecoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
|
||||
}
|
||||
recyclerView.addItemDecoration(mGirdDecoration);
|
||||
mGirdDecoration.applyPaddings(recyclerView);
|
||||
adjustPaddings();
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
Context context = getContext2();
|
||||
AssertUtils.assertNotNull(context);
|
||||
Resources resources = context.getResources();
|
||||
int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.list_padding_bottom_fab);
|
||||
int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);
|
||||
|
||||
Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_weird_face);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
@@ -400,7 +400,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
commentHolder.comment.clearCurrentSpan();
|
||||
|
||||
if (span instanceof URLSpan) {
|
||||
UrlOpener.openUrl(activity, ((URLSpan) span).getURL(), true, true);
|
||||
UrlOpener.openUrl(activity, ((URLSpan) span).getURL(), true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -490,7 +490,8 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
mFab.setY(fabStartY);
|
||||
mFab.setScaleX(0.0f);
|
||||
mFab.setScaleY(0.0f);
|
||||
mFab.animate().translationX(0.0f).translationY(0.0f).scaleX(1.0f).scaleY(1.0f)
|
||||
mFab.setRotation(-45.0f);
|
||||
mFab.animate().translationX(0.0f).translationY(0.0f).scaleX(1.0f).scaleY(1.0f).rotation(0.0f)
|
||||
.setInterpolator(AnimationUtils.SLOW_FAST_SLOW_INTERPOLATOR)
|
||||
.setDuration(300L).setListener(new SimpleAnimatorListener() {
|
||||
@Override
|
||||
|
||||
@@ -61,6 +61,7 @@ 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.ehviewer.UrlOpener;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
@@ -895,7 +896,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mPreviewText.setText(R.string.more_previews);
|
||||
}
|
||||
|
||||
int columnWidth = resources.getDimensionPixelOffset(R.dimen.preview_grid_column_width);
|
||||
int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId());
|
||||
mGridLayout.setColumnSize(columnWidth);
|
||||
mGridLayout.setStrategy(SimpleGridAutoSpanLayout.STRATEGY_SUITABLE_SIZE);
|
||||
for (int i = 0, size = previewSet.size(); i < size; i++) {
|
||||
@@ -913,7 +914,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
private static String getRatingText(float rating, Resources resources) {
|
||||
String undefine = "(´_ゝ`)";
|
||||
if (Float.isNaN(rating)) {
|
||||
if (-1.0f == rating) {
|
||||
return undefine;
|
||||
}
|
||||
|
||||
@@ -987,7 +988,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
String url = getGalleryDetailUrl(false);
|
||||
Activity activity = getActivity2();
|
||||
if (null != url && null != activity) {
|
||||
UrlOpener.openUrl(activity, url, false, false);
|
||||
UrlOpener.openUrl(activity, url, false);
|
||||
}
|
||||
break;
|
||||
case R.id.action_refresh:
|
||||
@@ -1293,7 +1294,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
UrlOpener.openUrl(context, EhUrl.getTagDefinitionUrl(tag2), false, true);
|
||||
UrlOpener.openUrl(context, EhUrl.getTagDefinitionUrl(tag2), false);
|
||||
break;
|
||||
case 1:
|
||||
addTagFilter(tag);
|
||||
@@ -1486,7 +1487,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
e.printStackTrace();
|
||||
Context context = getContext2();
|
||||
if (null != context && null != mTip) {
|
||||
String error = ExceptionUtils.getReadableString(context, e);
|
||||
String error = ExceptionUtils.getReadableString(e);
|
||||
mTip.setText(error);
|
||||
adjustViewVisibility(STATE_FAILED, true);
|
||||
}
|
||||
@@ -1658,7 +1659,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mProgressView.setVisibility(View.GONE);
|
||||
mErrorText.setVisibility(View.VISIBLE);
|
||||
mListView.setVisibility(View.GONE);
|
||||
mErrorText.setText(ExceptionUtils.getReadableString(context, e));
|
||||
mErrorText.setText(ExceptionUtils.getReadableString(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -400,8 +400,8 @@ public final class GalleryListScene extends BaseScene
|
||||
mFabLayout = (FabLayout) ViewUtils.$$(mainLayout, R.id.fab_layout);
|
||||
mSearchFab = ViewUtils.$$(mainLayout, R.id.search_fab);
|
||||
|
||||
int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.list_padding_top_search_bar);
|
||||
int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.list_padding_bottom_fab);
|
||||
int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
|
||||
int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);
|
||||
|
||||
mViewTransition = new ViewTransition(contentLayout, mSearchLayout);
|
||||
|
||||
@@ -418,8 +418,6 @@ public final class GalleryListScene extends BaseScene
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop() + paddingTopSB,
|
||||
mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
|
||||
mRecyclerView.addOnScrollListener(mOnScrollListener);
|
||||
|
||||
fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
|
||||
@@ -881,7 +879,8 @@ public final class GalleryListScene extends BaseScene
|
||||
mShowActionFab = true;
|
||||
View fab = mFabLayout.getPrimaryFab();
|
||||
fab.setVisibility(View.VISIBLE);
|
||||
fab.animate().scaleX(1.0f).scaleY(1.0f).setListener(null)
|
||||
fab.setRotation(-45.0f);
|
||||
fab.animate().scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setListener(null)
|
||||
.setDuration(ANIMATE_TIME).setStartDelay(0L)
|
||||
.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start();
|
||||
}
|
||||
@@ -916,7 +915,8 @@ public final class GalleryListScene extends BaseScene
|
||||
.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR).start();
|
||||
}
|
||||
mSearchFab.setVisibility(View.VISIBLE);
|
||||
mSearchFab.animate().scaleX(1.0f).scaleY(1.0f).setListener(null)
|
||||
mSearchFab.setRotation(-45.0f);
|
||||
mSearchFab.animate().scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setListener(null)
|
||||
.setDuration(ANIMATE_TIME).setStartDelay(delay)
|
||||
.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start();
|
||||
} else {
|
||||
@@ -950,7 +950,8 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
View fab = mFabLayout.getPrimaryFab();
|
||||
fab.setVisibility(View.VISIBLE);
|
||||
fab.animate().scaleX(1.0f).scaleY(1.0f).setListener(null)
|
||||
fab.setRotation(-45.0f);
|
||||
fab.animate().scaleX(1.0f).scaleY(1.0f).rotation(0.0f).setListener(null)
|
||||
.setDuration(ANIMATE_TIME).setStartDelay(delay)
|
||||
.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).start();
|
||||
|
||||
@@ -1227,10 +1228,14 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
|
||||
public static void startScene(SceneFragment scene, ListUrlBuilder lub) {
|
||||
scene.startScene(getStartAnnouncer(lub));
|
||||
}
|
||||
|
||||
public static Announcer getStartAnnouncer(ListUrlBuilder lub) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(KEY_ACTION, ACTION_LIST_URL_BUILDER);
|
||||
args.putParcelable(KEY_LIST_URL_BUILDER, lub);
|
||||
scene.startScene(new Announcer(GalleryListScene.class).setArgs(args));
|
||||
return new Announcer(GalleryListScene.class).setArgs(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
@@ -141,15 +142,16 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
|
||||
mAdapter = new GalleryPreviewAdapter();
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
int columnWidth = resources.getDimensionPixelOffset(R.dimen.preview_grid_column_width);
|
||||
int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId());
|
||||
AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth);
|
||||
layoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
int padding = LayoutUtils.dp2pix(context, 4);
|
||||
mRecyclerView.setPadding(padding, padding, padding, padding);
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.addItemDecoration(new MarginItemDecoration(padding));
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
int padding = LayoutUtils.dp2pix(context, 4);
|
||||
MarginItemDecoration decoration = new MarginItemDecoration(padding, padding, padding, padding, padding);
|
||||
mRecyclerView.addItemDecoration(decoration);
|
||||
decoration.applyPaddings(mRecyclerView);
|
||||
|
||||
mHelper = new GalleryPreviewHelper();
|
||||
contentLayout.setHelper(mHelper);
|
||||
|
||||
@@ -25,8 +25,8 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.StaggeredGridLayoutManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@@ -46,6 +46,7 @@ import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractSwipeableItemView
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.easyrecyclerview.HandlerDrawable;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
@@ -62,6 +63,7 @@ import com.hippo.util.ApiHelper;
|
||||
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.AssertUtils;
|
||||
import com.hippo.yorozuya.ResourcesUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
@@ -119,7 +121,10 @@ public class HistoryScene extends ToolbarScene
|
||||
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
|
||||
animator.setSupportsChangeAnimations(false);
|
||||
mRecyclerView.setItemAnimator(animator);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
|
||||
AutoStaggeredGridLayoutManager layoutManager = new AutoStaggeredGridLayoutManager(
|
||||
0, StaggeredGridLayoutManager.VERTICAL);
|
||||
layoutManager.setColumnSize(resources.getDimensionPixelOffset(R.dimen.gallery_list_column_width));
|
||||
layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
@@ -127,9 +132,12 @@ public class HistoryScene extends ToolbarScene
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
int paddingH = resources.getDimensionPixelOffset(R.dimen.list_content_margin_h);
|
||||
int paddingV = resources.getDimensionPixelOffset(R.dimen.list_content_margin_v);
|
||||
mRecyclerView.setPadding(paddingV, paddingH, paddingV, paddingH);
|
||||
int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
|
||||
int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
|
||||
int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
|
||||
MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
|
||||
mRecyclerView.addItemDecoration(decoration);
|
||||
decoration.applyPaddings(mRecyclerView);
|
||||
guardManager.attachRecyclerView(mRecyclerView);
|
||||
swipeManager.attachRecyclerView(mRecyclerView);
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ public final class ProgressScene extends BaseScene implements View.OnClickListen
|
||||
|
||||
if (null != context && null != mViewTransition && null != mTip) {
|
||||
// Show tip
|
||||
mError = ExceptionUtils.getReadableString(context, e);
|
||||
mError = ExceptionUtils.getReadableString(e);
|
||||
mViewTransition.showView(1);
|
||||
mTip.setText(mError);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -43,7 +42,6 @@ import com.hippo.ehviewer.client.parser.ProfileParser;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
@@ -219,7 +217,7 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
}
|
||||
|
||||
if (mRegister == v) {
|
||||
UrlOpener.openUrl(activity, EhUrl.URL_REGISTER, false, true);
|
||||
UrlOpener.openUrl(activity, EhUrl.URL_REGISTER, false);
|
||||
} else if (mSignIn == v) {
|
||||
signIn();
|
||||
} else if (mSignInViaWebView == v) {
|
||||
@@ -329,12 +327,11 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.sign_in_failed)
|
||||
.setMessage(R.string.sign_in_failed_plain)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.get_it, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
public void onSignInSuccess() {
|
||||
public void onSignInEnd() {
|
||||
Context context = getContext2();
|
||||
if (null == context) {
|
||||
return;
|
||||
@@ -349,38 +346,12 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
}
|
||||
}
|
||||
|
||||
public void onSignInFailure(Exception e) {
|
||||
Context context = getContext2();
|
||||
if (null == context) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSigningIn = false;
|
||||
Toast.makeText(context, ExceptionUtils.getReadableString(context, e),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
hideProgress();
|
||||
whetherToSkip();
|
||||
}
|
||||
|
||||
public void onGetProfileSuccess() {
|
||||
public void onGetProfileEnd() {
|
||||
mSigningIn = false;
|
||||
updateAvatar();
|
||||
redirectTo();
|
||||
}
|
||||
|
||||
public void onGetProfileFailure(Exception e) {
|
||||
Context context = getContext2();
|
||||
if (null == context) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSigningIn = false;
|
||||
Toast.makeText(context, ExceptionUtils.getReadableString(context, e),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
hideProgress();
|
||||
whetherToSkip();
|
||||
}
|
||||
|
||||
private class SignInListener extends EhCallback<SignInScene, String> {
|
||||
|
||||
public SignInListener(Context context, int stageId, String sceneTag) {
|
||||
@@ -394,7 +365,7 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
|
||||
SignInScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onSignInSuccess();
|
||||
scene.onSignInEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +376,7 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
|
||||
SignInScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onSignInFailure(e);
|
||||
scene.onSignInEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +405,7 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
|
||||
SignInScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onGetProfileSuccess();
|
||||
scene.onGetProfileEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +416,7 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
|
||||
SignInScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onGetProfileFailure(e);
|
||||
scene.onGetProfileEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class WebViewSignInScene extends BaseScene {
|
||||
}
|
||||
|
||||
private void addCookie(Context context, String domain, Cookie cookie) {
|
||||
EhApplication.getEhCookieStore(context).add(EhCookieStore.newCookie(cookie, domain, true, true));
|
||||
EhApplication.getEhCookieStore(context).add(EhCookieStore.newCookie(cookie, domain, true, true, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,9 +20,9 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.widget.DrawerView;
|
||||
import com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayoutChild;
|
||||
import com.hippo.widget.drawerlayout.DrawerLayoutChild;
|
||||
|
||||
public class EhDrawerView extends DrawerView implements SlidingDrawerLayoutChild {
|
||||
public class EhDrawerView extends DrawerView implements DrawerLayoutChild {
|
||||
|
||||
private int mFitPaddingTop;
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.widget.drawerlayout.DrawerLayoutChild;
|
||||
|
||||
public class EhNavigationView extends NavigationView implements DrawerLayoutChild {
|
||||
|
||||
private static final int SCRIM_COLOR = 0x44000000;
|
||||
private static final boolean DRAW_SCRIM = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
private Paint mPaint;
|
||||
private int mFitPaddingTop;
|
||||
|
||||
public EhNavigationView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public EhNavigationView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public EhNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
|
||||
if (DRAW_SCRIM && mFitPaddingTop > 0) {
|
||||
if (null == mPaint) {
|
||||
mPaint = new Paint();
|
||||
mPaint.setColor(SCRIM_COLOR);
|
||||
}
|
||||
canvas.drawRect(0, 0, getWidth(), mFitPaddingTop, mPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFitPadding(int top, int bottom) {
|
||||
mFitPaddingTop = top;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutPaddingTop() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutPaddingBottom() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,9 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.scene.StageLayout;
|
||||
import com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayoutChild;
|
||||
import com.hippo.widget.drawerlayout.DrawerLayoutChild;
|
||||
|
||||
public class EhStageLayout extends StageLayout implements SlidingDrawerLayoutChild {
|
||||
public class EhStageLayout extends StageLayout implements DrawerLayoutChild {
|
||||
|
||||
private int mFitPaddingTop;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -69,7 +69,7 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
|
||||
private int mState = STATE_NORMAL;
|
||||
|
||||
private final Path mPath = new Path();
|
||||
private final Rect mRect = new Rect();
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
private int mBaseHeight;
|
||||
@@ -111,7 +111,7 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
setBackgroundResource(R.drawable.card_white_2dp);
|
||||
setBackgroundResource(R.drawable.card_white_no_padding_2dp);
|
||||
|
||||
mSearchDatabase = SearchDatabase.getInstance(getContext());
|
||||
|
||||
@@ -425,10 +425,9 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
if (mInAnimation) {
|
||||
final int state = canvas.save();
|
||||
float bottom = MathUtils.lerp(mBaseHeight, mHeight, mProgress);
|
||||
mPath.rewind();
|
||||
mPath.addRect(0f, 0f, mWidth, bottom, Path.Direction.CW);
|
||||
canvas.clipPath(mPath);
|
||||
int bottom = MathUtils.lerp(mBaseHeight, mHeight, mProgress);
|
||||
mRect.set(0, 0, mWidth, bottom);
|
||||
canvas.clipRect(mRect);
|
||||
super.draw(canvas);
|
||||
canvas.restoreToCount(state);
|
||||
} else {
|
||||
|
||||
@@ -18,12 +18,12 @@ package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.AppCompatEditText;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class SearchEditText extends EditText {
|
||||
public class SearchEditText extends AppCompatEditText {
|
||||
|
||||
private SearchEditTextListener mListener;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.exception.EhException;
|
||||
@@ -122,9 +123,13 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
setAdapter(mAdapter);
|
||||
setHasFixedSize(true);
|
||||
setClipToPadding(false);
|
||||
int paddingH = resources.getDimensionPixelOffset(R.dimen.list_content_margin_h);
|
||||
int paddingV = resources.getDimensionPixelOffset(R.dimen.list_content_margin_v);
|
||||
setPadding(paddingV, paddingH, paddingV, paddingH);
|
||||
int interval = resources.getDimensionPixelOffset(R.dimen.search_layout_interval);
|
||||
int paddingH = resources.getDimensionPixelOffset(R.dimen.search_layout_margin_h);
|
||||
int paddingV = resources.getDimensionPixelOffset(R.dimen.search_layout_margin_v);
|
||||
MarginItemDecoration decoration = new MarginItemDecoration(
|
||||
interval, paddingH, paddingV, paddingH, paddingV);
|
||||
addItemDecoration(decoration);
|
||||
decoration.applyPaddings(this);
|
||||
|
||||
// Create normal view
|
||||
View normalView = mInflater.inflate(R.layout.search_normal, null);
|
||||
|
||||
@@ -25,7 +25,11 @@ import android.view.View;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
|
||||
/**
|
||||
* 5 stars, from 0 to 10
|
||||
*/
|
||||
public class SimpleRatingView extends View {
|
||||
|
||||
private Drawable mStarDrawable;
|
||||
@@ -96,7 +100,7 @@ public class SimpleRatingView extends View {
|
||||
public void setRating(float rating) {
|
||||
if (mRating != rating) {
|
||||
mRating = rating;
|
||||
int ratingInt = (int) Math.ceil(rating * 2);
|
||||
int ratingInt = MathUtils.clamp((int) Math.ceil(rating * 2), 0, 10);
|
||||
if (mRatingInt != ratingInt) {
|
||||
mRatingInt = ratingInt;
|
||||
invalidate();
|
||||
|
||||
@@ -573,28 +573,34 @@ public class GLRootView extends GLSurfaceView
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||
unfreeze();
|
||||
super.surfaceChanged(holder, format, w, h);
|
||||
|
||||
requestLayoutContentPane();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
unfreeze();
|
||||
super.surfaceCreated(holder);
|
||||
|
||||
if (mContentView != null && !mContentView.isAttachedToRoot()) {
|
||||
mContentView.attachToRoot(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
unfreeze();
|
||||
super.surfaceDestroyed(holder);
|
||||
|
||||
if (mContentView != null && mContentView.isAttachedToRoot()) {
|
||||
mContentView.detachFromRoot();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
unfreeze();
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mContentView != null) {
|
||||
mContentView.detachFromRoot();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.hippo.okhttp;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -176,6 +178,35 @@ public class CookieDBStore implements CookieJar {
|
||||
}
|
||||
}
|
||||
|
||||
private Cookie getInternal(HttpUrl url, String name, List<CookieWithID> cookies) {
|
||||
for (Iterator<CookieWithID> i = cookies.iterator(); i.hasNext();) {
|
||||
CookieWithID cwi = i.next();
|
||||
Cookie cookie = cwi.cookie;
|
||||
// Check expired
|
||||
if (hasExpired(cookie)) {
|
||||
// Remove from list
|
||||
i.remove();
|
||||
// Remove from DB
|
||||
CookieDB.removeCookie(cwi.id);
|
||||
} else if (cookie.name().equals(name) && cookie.matches(url)) {
|
||||
return cookie;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public synchronized Cookie get(HttpUrl url, String name) {
|
||||
String host = url.host();
|
||||
for (String key : map.keySet()) {
|
||||
if (domainMatch(host, key)) {
|
||||
List<CookieWithID> cookies = map.get(key);
|
||||
return getInternal(url, name, cookies);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized List<Cookie> get(HttpUrl url) {
|
||||
List<Cookie> result = new ArrayList<>();
|
||||
|
||||
@@ -185,6 +216,7 @@ public class CookieDBStore implements CookieJar {
|
||||
List<CookieWithID> cookies = map.get(key);
|
||||
// cookies can not be null
|
||||
getInternal(url, cookies, result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* 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.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
public class SeekBarPreference extends Preference implements SeekBar.OnSeekBarChangeListener {
|
||||
|
||||
private int mProgress;
|
||||
private int mMax;
|
||||
private boolean mTrackingTouch;
|
||||
|
||||
public SeekBarPreference(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0, 0);
|
||||
}
|
||||
|
||||
public SeekBarPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0, 0);
|
||||
}
|
||||
|
||||
public SeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SeekBarPreference, defStyleAttr, defStyleRes);
|
||||
setMax(a.getInt(R.styleable.SeekBarPreference_max, mMax));
|
||||
a.recycle();
|
||||
|
||||
setLayoutResource(R.layout.preference_widget_seekbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindView(View view) {
|
||||
super.onBindView(view);
|
||||
SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
|
||||
seekBar.setOnSeekBarChangeListener(this);
|
||||
seekBar.setMax(mMax);
|
||||
seekBar.setProgress(mProgress);
|
||||
seekBar.setEnabled(isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
|
||||
setProgress(restoreValue ? getPersistedInt(mProgress)
|
||||
: (Integer) defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||
return a.getInt(index, 0);
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
if (max != mMax) {
|
||||
mMax = max;
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
setProgress(progress, true);
|
||||
}
|
||||
|
||||
private void setProgress(int progress, boolean notifyChanged) {
|
||||
if (progress > mMax) {
|
||||
progress = mMax;
|
||||
}
|
||||
if (progress < 0) {
|
||||
progress = 0;
|
||||
}
|
||||
if (progress != mProgress) {
|
||||
mProgress = progress;
|
||||
persistInt(progress);
|
||||
if (notifyChanged) {
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return mProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist the seekBar's progress value if callChangeListener
|
||||
* returns true, otherwise set the seekBar's progress to the stored value
|
||||
*/
|
||||
void syncProgress(SeekBar seekBar) {
|
||||
int progress = seekBar.getProgress();
|
||||
if (progress != mProgress) {
|
||||
if (callChangeListener(progress)) {
|
||||
setProgress(progress, false);
|
||||
} else {
|
||||
seekBar.setProgress(mProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(
|
||||
SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (fromUser && !mTrackingTouch) {
|
||||
syncProgress(seekBar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
mTrackingTouch = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
mTrackingTouch = false;
|
||||
if (seekBar.getProgress() != mProgress) {
|
||||
syncProgress(seekBar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
/*
|
||||
* Suppose a client uses this preference type without persisting. We
|
||||
* must save the instance state so it is able to, for example, survive
|
||||
* orientation changes.
|
||||
*/
|
||||
|
||||
final Parcelable superState = super.onSaveInstanceState();
|
||||
if (isPersistent()) {
|
||||
// No need to save instance state since it's persistent
|
||||
return superState;
|
||||
}
|
||||
|
||||
// Save the instance state
|
||||
final SavedState myState = new SavedState(superState);
|
||||
myState.progress = mProgress;
|
||||
myState.max = mMax;
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (!state.getClass().equals(SavedState.class)) {
|
||||
// Didn't save state for us in onSaveInstanceState
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
|
||||
// Restore the instance state
|
||||
SavedState myState = (SavedState) state;
|
||||
super.onRestoreInstanceState(myState.getSuperState());
|
||||
mProgress = myState.progress;
|
||||
mMax = myState.max;
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* SavedState, a subclass of {@link BaseSavedState}, will store the state
|
||||
* of MyPreference, a subclass of Preference.
|
||||
* <p>
|
||||
* It is important to always call through to super methods.
|
||||
*/
|
||||
private static class SavedState extends BaseSavedState {
|
||||
int progress;
|
||||
int max;
|
||||
|
||||
public SavedState(Parcel source) {
|
||||
super(source);
|
||||
|
||||
// Restore the click counter
|
||||
progress = source.readInt();
|
||||
max = source.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
|
||||
// Save the click counter
|
||||
dest.writeInt(progress);
|
||||
dest.writeInt(max);
|
||||
}
|
||||
|
||||
public SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static final Parcelable.Creator<SavedState> CREATOR =
|
||||
new Parcelable.Creator<SavedState>() {
|
||||
@Override
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedState[] newArray(int size) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,6 @@ public class UrlPreference extends Preference {
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
UrlOpener.openUrl(getContext(), mUrl, true, true);
|
||||
UrlOpener.openUrl(getContext(), mUrl, true);
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ public class LinkMovementMethod2 extends ScrollingMovementMethod {
|
||||
if (action == MotionEvent.ACTION_UP) {
|
||||
ClickableSpan span = link[0];
|
||||
if (span instanceof URLSpan) {
|
||||
UrlOpener.openUrl(widget.getContext(), ((URLSpan) span).getURL(), true, true);
|
||||
UrlOpener.openUrl(widget.getContext(), ((URLSpan) span).getURL(), true);
|
||||
} else {
|
||||
span.onClick(widget);
|
||||
}
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// 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.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Helper class for Custom Tabs.
|
||||
*/
|
||||
public class CustomTabsHelper {
|
||||
private static final String TAG = "CustomTabsHelper";
|
||||
static final String STABLE_PACKAGE = "com.android.chrome";
|
||||
static final String BETA_PACKAGE = "com.chrome.beta";
|
||||
static final String DEV_PACKAGE = "com.chrome.dev";
|
||||
static final String LOCAL_PACKAGE = "com.google.android.apps.chrome";
|
||||
private static final String ACTION_CUSTOM_TABS_CONNECTION =
|
||||
"android.support.customtabs.action.CustomTabsService";
|
||||
private static final String UNINITIALIZED = "UNINITIALIZED";
|
||||
|
||||
private static String sPackageNameToUse = UNINITIALIZED;
|
||||
|
||||
private CustomTabsHelper() {}
|
||||
|
||||
/**
|
||||
* The browser of smartisan is terrible
|
||||
*/
|
||||
public static String getPackageNameToUseFixed(Context context) {
|
||||
if (!UNINITIALIZED.equals(sPackageNameToUse)) return sPackageNameToUse;
|
||||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
|
||||
// Get all apps that can handle VIEW intents.
|
||||
Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
|
||||
List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(activityIntent, 0);
|
||||
List<String> packagesSupportingCustomTabs = new ArrayList<>();
|
||||
for (ResolveInfo info : resolvedActivityList) {
|
||||
Intent serviceIntent = new Intent();
|
||||
serviceIntent.setAction(ACTION_CUSTOM_TABS_CONNECTION);
|
||||
serviceIntent.setPackage(info.activityInfo.packageName);
|
||||
if (pm.resolveService(serviceIntent, 0) != null) {
|
||||
packagesSupportingCustomTabs.add(info.activityInfo.packageName);
|
||||
}
|
||||
}
|
||||
|
||||
// Now packagesSupportingCustomTabs contains all apps that can handle both VIEW intents
|
||||
// and service calls.
|
||||
if (packagesSupportingCustomTabs.isEmpty()) {
|
||||
sPackageNameToUse = null;
|
||||
} else if (packagesSupportingCustomTabs.contains(STABLE_PACKAGE)) {
|
||||
sPackageNameToUse = STABLE_PACKAGE;
|
||||
} else if (packagesSupportingCustomTabs.contains(BETA_PACKAGE)) {
|
||||
sPackageNameToUse = BETA_PACKAGE;
|
||||
} else if (packagesSupportingCustomTabs.contains(DEV_PACKAGE)) {
|
||||
sPackageNameToUse = DEV_PACKAGE;
|
||||
} else if (packagesSupportingCustomTabs.contains(LOCAL_PACKAGE)) {
|
||||
sPackageNameToUse = LOCAL_PACKAGE;
|
||||
} else {
|
||||
sPackageNameToUse = null;
|
||||
}
|
||||
return sPackageNameToUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes through all apps that handle VIEW intents and have a warmup service. Picks
|
||||
* the one chosen by the user if there is one, otherwise makes a best effort to return a
|
||||
* valid package name.
|
||||
*
|
||||
* This is <strong>not</strong> threadsafe.
|
||||
*
|
||||
* @param context {@link Context} to use for accessing {@link PackageManager}.
|
||||
* @return The package name recommended to use for connecting to custom tabs related components.
|
||||
*/
|
||||
public static String getPackageNameToUse(Context context) {
|
||||
if (sPackageNameToUse != null) return sPackageNameToUse;
|
||||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
// Get default VIEW intent handler.
|
||||
Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
|
||||
ResolveInfo defaultViewHandlerInfo = pm.resolveActivity(activityIntent, 0);
|
||||
String defaultViewHandlerPackageName = null;
|
||||
if (defaultViewHandlerInfo != null) {
|
||||
defaultViewHandlerPackageName = defaultViewHandlerInfo.activityInfo.packageName;
|
||||
}
|
||||
|
||||
// Get all apps that can handle VIEW intents.
|
||||
List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(activityIntent, 0);
|
||||
List<String> packagesSupportingCustomTabs = new ArrayList<>();
|
||||
for (ResolveInfo info : resolvedActivityList) {
|
||||
Intent serviceIntent = new Intent();
|
||||
serviceIntent.setAction(ACTION_CUSTOM_TABS_CONNECTION);
|
||||
serviceIntent.setPackage(info.activityInfo.packageName);
|
||||
if (pm.resolveService(serviceIntent, 0) != null) {
|
||||
packagesSupportingCustomTabs.add(info.activityInfo.packageName);
|
||||
}
|
||||
}
|
||||
|
||||
// Now packagesSupportingCustomTabs contains all apps that can handle both VIEW intents
|
||||
// and service calls.
|
||||
if (packagesSupportingCustomTabs.isEmpty()) {
|
||||
sPackageNameToUse = null;
|
||||
} else if (packagesSupportingCustomTabs.size() == 1) {
|
||||
sPackageNameToUse = packagesSupportingCustomTabs.get(0);
|
||||
} else if (!TextUtils.isEmpty(defaultViewHandlerPackageName)
|
||||
&& !hasSpecializedHandlerIntents(context, activityIntent)
|
||||
&& packagesSupportingCustomTabs.contains(defaultViewHandlerPackageName)) {
|
||||
sPackageNameToUse = defaultViewHandlerPackageName;
|
||||
} else if (packagesSupportingCustomTabs.contains(STABLE_PACKAGE)) {
|
||||
sPackageNameToUse = STABLE_PACKAGE;
|
||||
} else if (packagesSupportingCustomTabs.contains(BETA_PACKAGE)) {
|
||||
sPackageNameToUse = BETA_PACKAGE;
|
||||
} else if (packagesSupportingCustomTabs.contains(DEV_PACKAGE)) {
|
||||
sPackageNameToUse = DEV_PACKAGE;
|
||||
} else if (packagesSupportingCustomTabs.contains(LOCAL_PACKAGE)) {
|
||||
sPackageNameToUse = LOCAL_PACKAGE;
|
||||
}
|
||||
return sPackageNameToUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check whether there is a specialized handler for a given intent.
|
||||
* @param intent The intent to check with.
|
||||
* @return Whether there is a specialized handler for the given intent.
|
||||
*/
|
||||
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<ResolveInfo> handlers = pm.queryIntentActivities(
|
||||
intent,
|
||||
PackageManager.GET_RESOLVED_FILTER);
|
||||
if (handlers == null || handlers.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
for (ResolveInfo resolveInfo : handlers) {
|
||||
IntentFilter filter = resolveInfo.filter;
|
||||
if (filter == null) continue;
|
||||
if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
|
||||
if (resolveInfo.activityInfo == null) continue;
|
||||
return true;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "Runtime exception while getting specialized handlers");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -17,15 +17,16 @@
|
||||
package com.hippo.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
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;
|
||||
@@ -36,28 +37,30 @@ public final class ExceptionUtils {
|
||||
private static final String TAG = ExceptionUtils.class.getSimpleName();
|
||||
|
||||
@NonNull
|
||||
public static String getReadableString(@NonNull Context context, @NonNull Exception e) {
|
||||
if (e instanceof ConnectTimeoutException ||
|
||||
public static String getReadableString(@NonNull Exception e) {
|
||||
if (e instanceof MalformedURLException) {
|
||||
return GetText.getString(R.string.error_invalid_url);
|
||||
} else if (e instanceof ConnectTimeoutException ||
|
||||
e instanceof SocketTimeoutException) {
|
||||
return context.getString(R.string.error_timeout);
|
||||
return GetText.getString(R.string.error_timeout);
|
||||
} else if (e instanceof UnknownHostException) {
|
||||
return context.getString(R.string.error_unknown_host);
|
||||
return GetText.getString(R.string.error_unknown_host);
|
||||
} else if (e instanceof StatusCodeException) {
|
||||
StatusCodeException sce = (StatusCodeException) e;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(context.getString(R.string.error_bad_status_code, sce.getResponseCode()));
|
||||
sb.append(GetText.getString(R.string.error_bad_status_code, sce.getResponseCode()));
|
||||
if (sce.isIdentifiedResponseCode()) {
|
||||
sb.append(", ").append(sce.getMessage());
|
||||
}
|
||||
return sb.toString();
|
||||
} else if (e instanceof ProtocolException && e.getMessage().startsWith("Too many follow-up requests:")) {
|
||||
return context.getString(R.string.error_redirection);
|
||||
return GetText.getString(R.string.error_redirection);
|
||||
} else if (e instanceof ProtocolException || e instanceof SocketException) {
|
||||
return context.getString(R.string.error_socket);
|
||||
return GetText.getString(R.string.error_socket);
|
||||
} else if (e instanceof EhException) {
|
||||
return e.getMessage();
|
||||
} else {
|
||||
return context.getString(R.string.error_unknown);
|
||||
return GetText.getString(R.string.error_unknown);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class ColorView extends View {
|
||||
|
||||
private int mColor;
|
||||
|
||||
public ColorView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ColorView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ColorView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
if (mColor != color) {
|
||||
mColor = color;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
canvas.drawColor(mColor);
|
||||
}
|
||||
}
|
||||
@@ -670,7 +670,7 @@ public class ContentLayout extends FrameLayout {
|
||||
String readableError;
|
||||
if (e != null) {
|
||||
e.printStackTrace();
|
||||
readableError = ExceptionUtils.getReadableString(getContext(), e);
|
||||
readableError = ExceptionUtils.getReadableString(e);
|
||||
} else {
|
||||
readableError = getContext().getString(R.string.error_unknown);
|
||||
}
|
||||
|
||||
@@ -256,14 +256,20 @@ public class FabLayout extends ViewGroup implements View.OnClickListener {
|
||||
|
||||
|
||||
private void setPrimaryFabAnimation(final View child, final boolean expanded, boolean delay) {
|
||||
float startRotation;
|
||||
float endRotation;
|
||||
float startScale;
|
||||
float endScale;
|
||||
Interpolator interpolator;
|
||||
if (expanded) {
|
||||
startRotation = -45.0f;
|
||||
endRotation = 0.0f;
|
||||
startScale = 0.0f;
|
||||
endScale = 1.0f;
|
||||
interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR;
|
||||
} else {
|
||||
startRotation = 0.0f;
|
||||
endRotation = 0.0f;
|
||||
startScale = 1.0f;
|
||||
endScale = 0.0f;
|
||||
interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR;
|
||||
@@ -271,9 +277,11 @@ public class FabLayout extends ViewGroup implements View.OnClickListener {
|
||||
|
||||
child.setScaleX(startScale);
|
||||
child.setScaleY(startScale);
|
||||
child.setRotation(startRotation);
|
||||
child.animate()
|
||||
.scaleX(endScale)
|
||||
.scaleY(endScale)
|
||||
.rotation(endRotation)
|
||||
.setStartDelay(delay ? ANIMATE_TIME : 0L)
|
||||
.setDuration(ANIMATE_TIME)
|
||||
.setInterpolator(interpolator)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.widget.slidingdrawerlayout;
|
||||
package com.hippo.widget.drawerlayout;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
@@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
@@ -51,7 +52,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.AnimatorUpdateListener,
|
||||
public class DrawerLayout extends ViewGroup implements ValueAnimator.AnimatorUpdateListener,
|
||||
Animator.AnimatorListener {
|
||||
|
||||
@IntDef({STATE_CLOSED, STATE_SLIDING, STATE_OPEN})
|
||||
@@ -98,6 +99,18 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
Build.VERSION.SDK_INT >= 21;
|
||||
private static final int DRAWER_ELEVATION = 10; //dp
|
||||
|
||||
private static final int MIN_DRAWER_MARGIN = 56;
|
||||
|
||||
private static final DrawerLayoutInsetsHelper INSETS_HELPER;
|
||||
|
||||
static {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
INSETS_HELPER = new DrawerLayoutInsetsHelperL();
|
||||
} else {
|
||||
INSETS_HELPER = null;
|
||||
}
|
||||
}
|
||||
|
||||
private float mDrawerElevation;
|
||||
|
||||
private int mMinDrawerMargin;
|
||||
@@ -139,10 +152,8 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
private int mFitPaddingTop = 0;
|
||||
private int mFitPaddingBottom = 0;
|
||||
|
||||
private int mStatusBarColor = Color.BLACK;
|
||||
private int mNavigationBarColor = Color.BLACK;
|
||||
|
||||
private static int sDefaultMinDrawerMargin = 56;
|
||||
private Paint mStatusBarPaint;
|
||||
private Paint mNavigationBarPaint;
|
||||
|
||||
/**
|
||||
* Listener for monitoring events about drawers.
|
||||
@@ -179,21 +190,12 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
void onDrawerStateChanged(View drawerView, int newState);
|
||||
}
|
||||
|
||||
/**
|
||||
* minMargin should be app bar height in Material design
|
||||
*
|
||||
* @param minMargin
|
||||
*/
|
||||
public static void setDefaultMinDrawerMargin(int minMargin) {
|
||||
sDefaultMinDrawerMargin = minMargin;
|
||||
}
|
||||
|
||||
public SlidingDrawerLayout(Context context, AttributeSet attrs) {
|
||||
public DrawerLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public SlidingDrawerLayout(Context context, AttributeSet attrs,
|
||||
public DrawerLayout(Context context, AttributeSet attrs,
|
||||
int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
@@ -206,7 +208,7 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
mRightState = STATE_CLOSED;
|
||||
mLeftPercent = 0.0f;
|
||||
mRightPercent = 0.0f;
|
||||
mMinDrawerMargin = sDefaultMinDrawerMargin;
|
||||
mMinDrawerMargin = LayoutUtils.dp2pix(context, MIN_DRAWER_MARGIN);
|
||||
mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
|
||||
mAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
|
||||
mAnimator.addUpdateListener(this);
|
||||
@@ -214,8 +216,16 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
mAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
|
||||
mCancelAnimation = false;
|
||||
mDrawerElevation = LayoutUtils.dp2pix(context, DRAWER_ELEVATION);
|
||||
mStatusBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
|
||||
mStatusBarPaint.setColor(Color.BLACK);
|
||||
mNavigationBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
|
||||
mNavigationBarPaint.setColor(Color.BLACK);
|
||||
|
||||
setWillNotDraw(false);
|
||||
|
||||
if (INSETS_HELPER != null) {
|
||||
INSETS_HELPER.setupForWindowInsets(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDrawerListener(DrawerListener listener) {
|
||||
@@ -498,8 +508,8 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
int paddingTop = 0;
|
||||
int paddingBottom = mFitPaddingBottom;
|
||||
if (child instanceof SlidingDrawerLayoutChild) {
|
||||
SlidingDrawerLayoutChild dlc = (SlidingDrawerLayoutChild) child;
|
||||
if (child instanceof DrawerLayoutChild) {
|
||||
DrawerLayoutChild dlc = (DrawerLayoutChild) child;
|
||||
paddingTop = dlc.getLayoutPaddingTop();
|
||||
paddingBottom = dlc.getLayoutPaddingBottom() + mFitPaddingBottom;
|
||||
}
|
||||
@@ -517,8 +527,8 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
}
|
||||
}
|
||||
final int drawerWidthSpec = getChildMeasureSpec(widthMeasureSpec,
|
||||
lp.leftMargin + lp.rightMargin,
|
||||
Math.min(widthSize - mMinDrawerMargin, lp.width));
|
||||
lp.leftMargin + lp.rightMargin + mMinDrawerMargin,
|
||||
Math.min(widthSize, lp.width));
|
||||
final int drawerHeightSpec = getChildMeasureSpec(heightMeasureSpec,
|
||||
lp.topMargin + lp.bottomMargin + paddingTop + paddingBottom,
|
||||
lp.height);
|
||||
@@ -547,8 +557,8 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
int paddingTop = 0;
|
||||
int paddingBottom = mFitPaddingBottom;
|
||||
if (child instanceof SlidingDrawerLayoutChild) {
|
||||
SlidingDrawerLayoutChild dlc = (SlidingDrawerLayoutChild) child;
|
||||
if (child instanceof DrawerLayoutChild) {
|
||||
DrawerLayoutChild dlc = (DrawerLayoutChild) child;
|
||||
paddingTop = dlc.getLayoutPaddingTop();
|
||||
paddingBottom = dlc.getLayoutPaddingBottom() + mFitPaddingBottom;
|
||||
}
|
||||
@@ -770,8 +780,8 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
int xInt = (int) x;
|
||||
int yInt = (int) y;
|
||||
|
||||
if (activitedDrawer instanceof SlidingDrawerLayoutChild) {
|
||||
SlidingDrawerLayoutChild dlc = (SlidingDrawerLayoutChild) activitedDrawer;
|
||||
if (activitedDrawer instanceof DrawerLayoutChild) {
|
||||
DrawerLayoutChild dlc = (DrawerLayoutChild) activitedDrawer;
|
||||
int paddingTop = dlc.getLayoutPaddingTop();
|
||||
int paddingBottom = dlc.getLayoutPaddingBottom();
|
||||
if (yInt < paddingTop || yInt >= getHeight() - paddingBottom) {
|
||||
@@ -978,11 +988,11 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
}
|
||||
|
||||
public void setStatusBarColor(int statusBarColor) {
|
||||
mStatusBarColor = statusBarColor;
|
||||
mStatusBarPaint.setColor(statusBarColor);
|
||||
}
|
||||
|
||||
public void setNavigationBarColor(int navigationBarColor) {
|
||||
mNavigationBarColor = navigationBarColor;
|
||||
mNavigationBarPaint.setColor(navigationBarColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1012,18 +1022,12 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
super.onDraw(canvas);
|
||||
|
||||
if (mFitPaddingTop != 0) {
|
||||
int saved = canvas.save();
|
||||
canvas.clipRect(0, 0, getWidth(), mFitPaddingTop);
|
||||
canvas.drawColor(mStatusBarColor);
|
||||
canvas.restoreToCount(saved);
|
||||
canvas.drawRect(0, 0, getWidth(), mFitPaddingTop, mStatusBarPaint);
|
||||
}
|
||||
|
||||
if (mFitPaddingBottom != 0) {
|
||||
int saved = canvas.save();
|
||||
int height = getHeight();
|
||||
canvas.clipRect(0, height - mFitPaddingBottom, getWidth(), height);
|
||||
canvas.drawColor(mNavigationBarColor);
|
||||
canvas.restoreToCount(saved);
|
||||
canvas.drawRect(0, height - mFitPaddingBottom, getWidth(), height, mNavigationBarPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,8 +1041,8 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
|
||||
for (int i = 0, n = getChildCount(); i < n; i++) {
|
||||
View view = getChildAt(i);
|
||||
if (view instanceof SlidingDrawerLayoutChild) {
|
||||
((SlidingDrawerLayoutChild) view).setFitPadding(mFitPaddingTop, mFitPaddingBottom);
|
||||
if (view instanceof DrawerLayoutChild) {
|
||||
((DrawerLayoutChild) view).setFitPadding(mFitPaddingTop, mFitPaddingBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1216,7 +1220,7 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
View activatedDrawer = null;
|
||||
if (mLeftDrawer != null && mLeftDrawer.getRight() > 0) {
|
||||
activatedDrawer = mLeftDrawer;
|
||||
} else if (mRightDrawer != null && mRightDrawer.getLeft() < SlidingDrawerLayout.this.getWidth()) {
|
||||
} else if (mRightDrawer != null && mRightDrawer.getLeft() < DrawerLayout.this.getWidth()) {
|
||||
activatedDrawer = mRightDrawer;
|
||||
}
|
||||
if (activatedDrawer == null) {
|
||||
@@ -1225,8 +1229,8 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
|
||||
int paddingTop = 0;
|
||||
int paddingBottom = 0;
|
||||
if (activatedDrawer instanceof SlidingDrawerLayoutChild) {
|
||||
SlidingDrawerLayoutChild dlc = (SlidingDrawerLayoutChild) activatedDrawer;
|
||||
if (activatedDrawer instanceof DrawerLayoutChild) {
|
||||
DrawerLayoutChild dlc = (DrawerLayoutChild) activatedDrawer;
|
||||
paddingTop = dlc.getLayoutPaddingTop();
|
||||
paddingBottom = dlc.getLayoutPaddingBottom();
|
||||
}
|
||||
@@ -1240,7 +1244,7 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
|
||||
c.clipRect(0, paddingTop, width, height - paddingBottom);
|
||||
}
|
||||
|
||||
// Draw drak background
|
||||
// Draw dark background
|
||||
c.drawARGB(MathUtils.lerp(FORM, TO, mPercent), 0, 0, 0);
|
||||
|
||||
if (activatedDrawer == mLeftDrawer) {
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.widget.slidingdrawerlayout;
|
||||
package com.hippo.widget.drawerlayout;
|
||||
|
||||
public interface SlidingDrawerLayoutChild {
|
||||
public interface DrawerLayoutChild {
|
||||
|
||||
void setFitPadding(int top, int bottom);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.hippo.widget.drawerlayout;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public interface DrawerLayoutInsetsHelper {
|
||||
void setupForWindowInsets(View view);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.hippo.widget.drawerlayout;
|
||||
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.view.View;
|
||||
|
||||
public class DrawerLayoutInsetsHelperL implements DrawerLayoutInsetsHelper {
|
||||
|
||||
@Override
|
||||
public void setupForWindowInsets(View view) {
|
||||
if (ViewCompat.getFitsSystemWindows(view)) {
|
||||
// Now set the sys ui flags to enable us to lay out in the window insets
|
||||
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.os.Build;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.view.animation.FastOutSlowInInterpolator;
|
||||
import android.view.View;
|
||||
@@ -36,6 +38,9 @@ import android.view.animation.Interpolator;
|
||||
*/
|
||||
final class SwipeProgressBar {
|
||||
|
||||
private static final boolean SUPPORT_CLIPRECT_DIFFERENCE =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
|
||||
|
||||
// Default progress animation colors are grays.
|
||||
private final static int COLOR1 = 0xB3000000;
|
||||
private final static int COLOR2 = 0x80000000;
|
||||
@@ -136,12 +141,20 @@ final class SwipeProgressBar {
|
||||
}
|
||||
|
||||
void draw(Canvas canvas) {
|
||||
// API < 18 do not support clipRect(Region.Op.DIFFERENCE).
|
||||
// So draw twice for finish animation
|
||||
if (draw(canvas, true)) {
|
||||
draw(canvas, false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean draw(Canvas canvas, boolean first) {
|
||||
Rect bounds = mBounds;
|
||||
final int width = bounds.width();
|
||||
final int height = bounds.height();
|
||||
final int cx = bounds.centerX();
|
||||
final int cy = bounds.centerY();
|
||||
boolean drawTriggerWhileFinishing = false;
|
||||
boolean drawAgain = false;
|
||||
int restoreCount = canvas.save();
|
||||
canvas.clipRect(bounds);
|
||||
|
||||
@@ -158,7 +171,7 @@ final class SwipeProgressBar {
|
||||
// don't repost.
|
||||
if ((now - mFinishTime) >= FINISH_ANIMATION_DURATION_MS) {
|
||||
mFinishTime = 0;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, use a 0 opacity alpha layer to clear the animation
|
||||
@@ -169,8 +182,20 @@ final class SwipeProgressBar {
|
||||
float pct = (finishProgress / 100f);
|
||||
// Radius of the circle is half of the screen.
|
||||
float clearRadius = width / 2 * INTERPOLATOR.getInterpolation(pct);
|
||||
mClipRect.set(cx - clearRadius, 0, cx + clearRadius, height);
|
||||
canvas.saveLayerAlpha(mClipRect, 0, 0);
|
||||
if (SUPPORT_CLIPRECT_DIFFERENCE) {
|
||||
mClipRect.set(cx - clearRadius, bounds.top, cx + clearRadius, bounds.bottom);
|
||||
canvas.clipRect(mClipRect, Region.Op.DIFFERENCE);
|
||||
} else {
|
||||
if (first) {
|
||||
// First time left
|
||||
drawAgain = true;
|
||||
mClipRect.set(bounds.left, bounds.top, cx - clearRadius, bounds.bottom);
|
||||
} else {
|
||||
// Second time right
|
||||
mClipRect.set(cx + clearRadius, bounds.top, bounds.right, bounds.bottom);
|
||||
}
|
||||
canvas.clipRect(mClipRect);
|
||||
}
|
||||
// Only draw the trigger if there is a space in the center of
|
||||
// this refreshing view that needs to be filled in by the
|
||||
// trigger. If the progress view is just still animating, let it
|
||||
@@ -239,6 +264,7 @@ final class SwipeProgressBar {
|
||||
}
|
||||
}
|
||||
canvas.restoreToCount(restoreCount);
|
||||
return drawAgain;
|
||||
}
|
||||
|
||||
private void drawTrigger(Canvas canvas, int cx, int cy) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
APP_ABI := all
|
||||
APP_PLATFORM := android-16
|
||||
APP_PLATFORM := android-15
|
||||
APP_OPTIM := release
|
||||
|
||||
APP_CFLAGS += -ffunction-sections -fdata-sections -fPIC
|
||||
|
||||
|
Before Width: | Height: | Size: 375 B |
|
After Width: | Height: | Size: 376 B |
|
Before Width: | Height: | Size: 380 B |
|
After Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 250 B |
|
After Width: | Height: | Size: 249 B |
|
Before Width: | Height: | Size: 247 B |
|
After Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 342 B |
|
After Width: | Height: | Size: 342 B |
|
Before Width: | Height: | Size: 343 B |
|
After Width: | Height: | Size: 338 B |
|
Before Width: | Height: | Size: 643 B |
|
After Width: | Height: | Size: 641 B |
|
Before Width: | Height: | Size: 636 B |
|
After Width: | Height: | Size: 639 B |
@@ -18,7 +18,7 @@
|
||||
<selector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_activated="true" android:drawable="@drawable/card_grey_2dp"/>
|
||||
<item android:drawable="@drawable/card_white_2dp"/>
|
||||
<item android:state_activated="true" android:drawable="@drawable/card_grey_no_padding_2dp"/>
|
||||
<item android:drawable="@drawable/card_white_no_padding_2dp"/>
|
||||
|
||||
</selector>
|
||||
@@ -0,0 +1,74 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
|
||||
android:background="?android:attr/activatedBackgroundIndicator"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:ellipsize="marquee" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="10" />
|
||||
|
||||
<!-- Preference should place its actual preference widget here. -->
|
||||
<LinearLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@android:id/summary"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:minWidth="@dimen/preference_widget_width"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/summary"
|
||||
android:layout_toRightOf="@android:id/widget_frame"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
@@ -40,12 +40,11 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ok"
|
||||
style="@style/CardButton"
|
||||
style="?attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:text="@android:string/ok"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
android:background="@null"/>
|
||||
android:textColor="?attr/colorPrimary"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -35,6 +35,14 @@
|
||||
android:layout_marginRight="@dimen/gallery_widget_margin_h"
|
||||
android:textColor="@color/secondary_text_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/gallery_widget_margin_v"
|
||||
android:textColor="@color/secondary_text_dark"/>
|
||||
|
||||
<com.hippo.widget.BatteryView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/battery"
|
||||
@@ -87,4 +95,10 @@
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
</com.hippo.ehviewer.widget.SeekBarPanel>
|
||||
|
||||
<com.hippo.widget.ColorView
|
||||
android:id="@+id/mask"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -18,10 +18,9 @@
|
||||
<com.hippo.widget.SafeCoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout
|
||||
<com.hippo.widget.drawerlayout.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/draw_view"
|
||||
android:layout_width="match_parent"
|
||||
@@ -31,17 +30,15 @@
|
||||
<com.hippo.ehviewer.widget.EhStageLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"/>
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
<com.hippo.ehviewer.widget.EhNavigationView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
android:maxWidth="@dimen/drawer_max_width"
|
||||
android:fitsSystemWindows="true"
|
||||
app:headerLayout="@layout/nav_header_main"
|
||||
app:menu="@menu/nav_drawer_main"/>
|
||||
|
||||
@@ -54,5 +51,5 @@
|
||||
android:background="@color/background_light"
|
||||
android:clickable="true"/>
|
||||
|
||||
</com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout>
|
||||
</com.hippo.widget.drawerlayout.DrawerLayout>
|
||||
</com.hippo.widget.SafeCoordinatorLayout>
|
||||
@@ -136,6 +136,13 @@
|
||||
android:text="@string/settings_read_show_clock"
|
||||
android:textColor="@color/primary_text_dark"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/show_progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_read_show_progress"
|
||||
android:textColor="@color/primary_text_dark"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/show_battery"
|
||||
android:layout_width="match_parent"
|
||||
@@ -150,5 +157,25 @@
|
||||
android:text="@string/settings_read_volume_page"
|
||||
android:textColor="@color/primary_text_dark"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/reading_fullscreen"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_read_reading_fullscreen"
|
||||
android:textColor="@color/primary_text_dark"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/custom_screen_lightness"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_read_custom_screen_lightness"
|
||||
android:textColor="@color/primary_text_dark"/>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/screen_lightness"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="200"/>
|
||||
|
||||
</LinearLayout>
|
||||
</com.hippo.widget.IndicatingScrollView>
|
||||
@@ -128,7 +128,7 @@
|
||||
android:layout_marginLeft="@dimen/keyline_margin"
|
||||
android:layout_marginRight="@dimen/keyline_margin"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/card_white_2dp">
|
||||
android:background="@drawable/card_white_no_padding_2dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/download"
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/card_background">
|
||||
android:background="@drawable/card_background_no_padding">
|
||||
|
||||
<com.hippo.widget.LoadImageView
|
||||
android:id="@+id/thumb"
|
||||
android:layout_width="@dimen/list_thumb_width"
|
||||
android:layout_height="@dimen/list_thumb_height"/>
|
||||
android:layout_width="@dimen/gallery_list_thumb_width"
|
||||
android:layout_height="@dimen/gallery_list_thumb_height"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/card_background">
|
||||
android:background="@drawable/card_background_no_padding">
|
||||
|
||||
<com.hippo.widget.LoadImageView
|
||||
android:id="@+id/thumb"
|
||||
android:layout_width="@dimen/list_thumb_width"
|
||||
android:layout_height="@dimen/list_thumb_height"
|
||||
android:layout_width="@dimen/gallery_list_thumb_width"
|
||||
android:layout_height="@dimen/gallery_list_thumb_height"
|
||||
app:retryType="none"/>
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/preference_item_padding_side"
|
||||
android:paddingRight="?android:attr/scrollbarSize"
|
||||
android:background="?android:attr/activatedBackgroundIndicator">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingRight="@dimen/preference_item_padding_inner"
|
||||
android:paddingTop="6dip"
|
||||
android:paddingBottom="6dip">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="10"/>
|
||||
|
||||
<!-- Preference should place its actual preference widget here. -->
|
||||
<LinearLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@android:id/summary"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:minWidth="@dimen/preference_widget_width"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/summary"
|
||||
android:layout_toRightOf="@android:id/widget_frame"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
@@ -31,9 +31,9 @@
|
||||
android:id="@+id/search_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/list_search_bar_margin"
|
||||
android:layout_marginRight="@dimen/list_search_bar_margin"
|
||||
android:layout_marginTop="8dp"/>
|
||||
android:layout_marginLeft="@dimen/gallery_search_bar_margin_h"
|
||||
android:layout_marginRight="@dimen/gallery_search_bar_margin_h"
|
||||
android:layout_marginTop="@dimen/gallery_search_bar_margin_v"/>
|
||||
|
||||
<com.hippo.widget.FabLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
android:id="@+id/search_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/list_search_bar_margin"
|
||||
android:layout_marginRight="@dimen/list_search_bar_margin"
|
||||
android:layout_marginTop="8dp"/>
|
||||
android:layout_marginLeft="@dimen/gallery_search_bar_margin_h"
|
||||
android:layout_marginRight="@dimen/gallery_search_bar_margin_h"
|
||||
android:layout_marginTop="@dimen/gallery_search_bar_margin_v"/>
|
||||
|
||||
<com.hippo.widget.FabLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/card_white_2dp">
|
||||
android:background="@drawable/card_white_no_padding_2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -24,41 +24,42 @@
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp">
|
||||
android:layout_height="48dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/search_menu"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:padding="16dp"/>
|
||||
android:padding="12dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/search_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="56dp"
|
||||
android:layout_marginRight="56dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="@dimen/text_large"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="48dp"
|
||||
android:layout_marginRight="48dp"
|
||||
android:textSize="@dimen/text_little_large"
|
||||
android:textColor="@color/secondary_text_light"
|
||||
android:singleLine="true"
|
||||
android:maxLines="1"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/search_action"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:padding="16dp"/>
|
||||
android:padding="12dp"/>
|
||||
|
||||
<com.hippo.ehviewer.widget.SearchEditText
|
||||
android:id="@+id/search_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="56dp"
|
||||
android:layout_marginRight="56dp"
|
||||
android:layout_marginLeft="48dp"
|
||||
android:layout_marginRight="48dp"
|
||||
android:textSize="@dimen/text_little_small"
|
||||
android:background="@null"
|
||||
android:singleLine="true"
|
||||
android:maxLines="1"
|
||||
|
||||
|
Before Width: | Height: | Size: 979 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 654 B After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 3.1 KiB |
@@ -15,15 +15,9 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<resources>
|
||||
|
||||
<path
|
||||
android:fillColor="@color/primary_drawable_dark"
|
||||
android:pathData="@string/pd_label"/>
|
||||
<!-- Custom preference -->
|
||||
<dimen name="preference_widget_width">72dp</dimen>
|
||||
|
||||
</vector>
|
||||
</resources>
|
||||
@@ -15,15 +15,9 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<resources>
|
||||
|
||||
<path
|
||||
android:fillColor="@color/primary_drawable_light"
|
||||
android:pathData="@string/pd_close"/>
|
||||
<!-- Custom preference -->
|
||||
<dimen name="preference_widget_width">56dp</dimen>
|
||||
|
||||
</vector>
|
||||
</resources>
|
||||