Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
073f6d1b60 | ||
|
|
a30f5e992c | ||
|
|
6cb209a11f | ||
|
|
ed8ad35968 | ||
|
|
896d731069 | ||
|
|
37bec12843 | ||
|
|
bf97290e57 | ||
|
|
83b0d1e961 | ||
|
|
775ccfba7f | ||
|
|
a05246c405 | ||
|
|
2dd26e9b00 | ||
|
|
44a39ff230 | ||
|
|
43272ac535 | ||
|
|
36128830f9 | ||
|
|
006788ea2e | ||
|
|
e071599391 | ||
|
|
f3b42f0070 | ||
|
|
81c22811d6 | ||
|
|
c4e35189ec | ||
|
|
d10242c722 | ||
|
|
664e830c7b | ||
|
|
7ae50430f8 | ||
|
|
f2ca9fd70b | ||
|
|
faad776d59 | ||
|
|
9572447b59 | ||
|
|
950870afdb | ||
|
|
1e6f681643 | ||
|
|
d89b9bbec9 | ||
|
|
397b0d91aa | ||
|
|
a3ce06c07f | ||
|
|
bf16b13ca9 | ||
|
|
407f5b102c | ||
|
|
04ae2c1b4b | ||
|
|
b6a6863f6c | ||
|
|
60351a5f1c | ||
|
|
3c4605944e | ||
|
|
f3b442fbcd | ||
|
|
8263ead395 | ||
|
|
59085f1371 | ||
|
|
9276244b28 | ||
|
|
15d4819089 | ||
|
|
34109d3a93 | ||
|
|
160601d333 | ||
|
|
a81f4b40f1 | ||
|
|
94a838f4b7 | ||
|
|
866e3f8885 | ||
|
|
8eb43c6893 | ||
|
|
f1cfe21780 | ||
|
|
bd7cc665e2 | ||
|
|
af2102ded8 | ||
|
|
bc2877a1aa | ||
|
|
95f7cc016c | ||
|
|
5fe5737769 | ||
|
|
be8f78fa4f | ||
|
|
db5caa9d00 | ||
|
|
a931983219 | ||
|
|
e28a143358 | ||
|
|
f99a7f8cbf |
No files matched your search
@@ -531,6 +531,15 @@ This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
|
||||
======================================================================
|
||||
Library ("ShowcaseView")
|
||||
======================================================================
|
||||
|
||||
Copyright Alex Curran (@amlcurran) © 2012-2014. All rights reserved.
|
||||
|
||||
This library is distributed under an Apache 2.0 License.
|
||||
|
||||
|
||||
======================================================================
|
||||
Font ("Slabo")
|
||||
======================================================================
|
||||
|
||||
@@ -52,6 +52,7 @@ Here is the libraries
|
||||
- [libpng](http://www.libpng.org/pub/png/libpng.html)
|
||||
- [okhttp](https://github.com/square/okhttp)
|
||||
- [roaster](https://github.com/forge/roaster)
|
||||
- [ShowcaseView](https://github.com/amlcurran/ShowcaseView)
|
||||
- [Slabo](https://github.com/TiroTypeworks/Slabo)
|
||||
- [TagSoup](http://home.ccil.org/~cowan/tagsoup/)
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ android {
|
||||
applicationId "com.hippo.ehviewer"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 23
|
||||
versionCode 48
|
||||
versionName "0.9.0"
|
||||
versionCode 49
|
||||
versionName "0.9.1"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ dependencies {
|
||||
compile 'com.android.support:appcompat-v7:23.2.0'
|
||||
compile 'com.android.support:customtabs:23.2.0'
|
||||
compile 'com.android.support:design:23.2.0'
|
||||
compile 'com.github.amlcurran.showcaseview:library:5.4.1'
|
||||
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.8.6'
|
||||
compile 'de.greenrobot:greendao:2.0.0'
|
||||
compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
||||
|
||||
@@ -69,6 +69,12 @@
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:theme="@style/AppTheme"/>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.ExcludedLanguagesActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:label="@string/excluded_languages"/>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.DirPickerActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
|
||||
@@ -99,12 +99,12 @@ public class AddDeleteDrawable extends Drawable {
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return mSize;
|
||||
return mSize * 6 / 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return mSize;
|
||||
return mSize * 6 / 5;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.drawable;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class RoundDrawable extends Drawable {
|
||||
|
||||
private final Paint mPaint;
|
||||
private final RectF mRectF;
|
||||
|
||||
public RoundDrawable(int color) {
|
||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
|
||||
mPaint.setColor(color);
|
||||
mRectF = new RectF();
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
mPaint.setColor(color);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
super.onBoundsChange(bounds);
|
||||
mRectF.set(bounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.drawOval(mRectF, mPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
mPaint.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
mPaint.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.OPAQUE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.drawable;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class TriangleDrawable extends Drawable {
|
||||
|
||||
private final Paint mPaint;
|
||||
private final Path mPath;
|
||||
|
||||
public TriangleDrawable(int color) {
|
||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
|
||||
mPaint.setColor(color);
|
||||
mPath = new Path();
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
mPaint.setColor(color);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
super.onBoundsChange(bounds);
|
||||
mPath.reset();
|
||||
mPath.moveTo(bounds.left, bounds.top);
|
||||
mPath.lineTo(bounds.right, bounds.top);
|
||||
mPath.lineTo(bounds.right, bounds.bottom);
|
||||
mPath.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.drawPath(mPath, mPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
mPaint.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
mPaint.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.OPAQUE;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ public class AppConfig {
|
||||
private static final String TEMP = "temp";
|
||||
private static final String IMAGE = "image";
|
||||
private static final String CRASH = "crash";
|
||||
private static final String PARSE_ERROR = "parse_error";
|
||||
private static final String LOGCAT = "logcat";
|
||||
|
||||
private static Context sContext;
|
||||
|
||||
@@ -91,6 +93,16 @@ public class AppConfig {
|
||||
return getDirInExternalAppDir(CRASH);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File getExternalParseErrorDir() {
|
||||
return getDirInExternalAppDir(PARSE_ERROR);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File getExternalLogcatDir() {
|
||||
return getDirInExternalAppDir(LOGCAT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File createExternalTempFile() {
|
||||
return FileUtils.createTempFile(getExternalTempDir(), null);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.hippo.yorozuya.Messenger;
|
||||
|
||||
public final class Constants {
|
||||
|
||||
public static final int MESSAGE_ID_LIST_MODE;
|
||||
|
||||
static {
|
||||
Messenger messenger = Messenger.getInstance();
|
||||
MESSAGE_ID_LIST_MODE = messenger.newId();
|
||||
}
|
||||
|
||||
private Constants(){}
|
||||
}
|
||||
@@ -17,16 +17,17 @@
|
||||
package com.hippo.ehviewer;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentCallbacks2;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Debug;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.util.LruCache;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.hippo.beerbelly.LruCacheEx;
|
||||
import com.hippo.beerbelly.SimpleDiskCache;
|
||||
import com.hippo.conaco.Conaco;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
@@ -67,9 +68,9 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
private OkHttpClient mOkHttpClient;
|
||||
private BitmapHelper mBitmapHelper;
|
||||
private Conaco<Bitmap> mConaco;
|
||||
private LruCacheEx<Long, GalleryDetail> mGalleryDetailCache;
|
||||
private LruCacheEx<String, LargePreviewSet> mLargePreviewSetCache;
|
||||
private LruCacheEx<Long, Integer> mPreviewPagesCache;
|
||||
private LruCache<Long, GalleryDetail> mGalleryDetailCache;
|
||||
private LruCache<String, LargePreviewSet> mLargePreviewSetCache;
|
||||
private LruCache<Long, Integer> mPreviewPagesCache;
|
||||
private SimpleDiskCache mSpiderInfoCache;
|
||||
private DownloadManager mDownloadManager;
|
||||
|
||||
@@ -99,10 +100,6 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
Analytics.start(this);
|
||||
}
|
||||
|
||||
if (BETA) {
|
||||
Settings.putBetaUpdateChannel(true);
|
||||
}
|
||||
|
||||
// Update version code
|
||||
try {
|
||||
PackageInfo pi= getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
@@ -116,6 +113,26 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrimMemory(int level) {
|
||||
super.onTrimMemory(level);
|
||||
|
||||
if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW) {
|
||||
if (null != mConaco) {
|
||||
mConaco.clearMemoryCache();
|
||||
}
|
||||
if (null != mGalleryDetailCache) {
|
||||
mGalleryDetailCache.evictAll();
|
||||
}
|
||||
if (null != mLargePreviewSetCache) {
|
||||
mLargePreviewSetCache.evictAll();
|
||||
}
|
||||
if (null != mPreviewPagesCache) {
|
||||
mPreviewPagesCache.evictAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void debugNativeMemory() {
|
||||
new Runnable() {
|
||||
@Override
|
||||
@@ -228,31 +245,31 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static LruCacheEx<Long, GalleryDetail> getGalleryDetailCache(@NonNull Context context) {
|
||||
public static LruCache<Long, GalleryDetail> getGalleryDetailCache(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
if (application.mGalleryDetailCache == null) {
|
||||
// Max size 25, 3 min timeout
|
||||
application.mGalleryDetailCache = new LruCacheEx<>(25, 3 * 60 * 1000);
|
||||
application.mGalleryDetailCache = new LruCache<>(25);
|
||||
}
|
||||
return application.mGalleryDetailCache;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static LruCacheEx<String, LargePreviewSet> getLargePreviewSetCache(@NonNull Context context) {
|
||||
public static LruCache<String, LargePreviewSet> getLargePreviewSetCache(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
if (application.mLargePreviewSetCache == null) {
|
||||
// Max size 50, 3 min timeout
|
||||
application.mLargePreviewSetCache = new LruCacheEx<>(50, 3 * 60 * 1000);
|
||||
application.mLargePreviewSetCache = new LruCache<>(50);
|
||||
}
|
||||
return application.mLargePreviewSetCache;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static LruCacheEx<Long, Integer> getPreviewPagesCache(@NonNull Context context) {
|
||||
public static LruCache<Long, Integer> getPreviewPagesCache(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
if (application.mPreviewPagesCache == null) {
|
||||
// Max size 50, 3 min timeout
|
||||
application.mPreviewPagesCache = new LruCacheEx<>(50, 3 * 60 * 1000);
|
||||
application.mPreviewPagesCache = new LruCache<>(50);
|
||||
}
|
||||
return application.mPreviewPagesCache;
|
||||
}
|
||||
|
||||
@@ -297,9 +297,9 @@ public class EhDB {
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized List<DownloadInfo> getAllDownloadInfos() {
|
||||
public static synchronized List<DownloadInfo> getAllDownloadInfo() {
|
||||
DownloadsDao dao = sDaoSession.getDownloadsDao();
|
||||
List<DownloadInfo> list = dao.queryBuilder().orderAsc(DownloadsDao.Properties.Time).list();
|
||||
List<DownloadInfo> list = dao.queryBuilder().orderDesc(DownloadsDao.Properties.Time).list();
|
||||
// Fix state
|
||||
for (DownloadInfo info: list) {
|
||||
if (info.state == DownloadInfo.STATE_WAIT || info.state == DownloadInfo.STATE_DOWNLOAD) {
|
||||
|
||||
@@ -23,9 +23,11 @@ import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.client.EhConfig;
|
||||
import com.hippo.ehviewer.client.data.FavListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.gallery.gl.GalleryView;
|
||||
import com.hippo.ehviewer.gallery.gl.ImageView;
|
||||
import com.hippo.unifile.UniFile;
|
||||
@@ -38,6 +40,8 @@ import java.io.File;
|
||||
|
||||
public class Settings {
|
||||
|
||||
private static final String TAG = Settings.class.getSimpleName();
|
||||
|
||||
private static Context sContext;
|
||||
private static SharedPreferences sSettingsPre;
|
||||
private static EhConfig sEhConfig;
|
||||
@@ -50,12 +54,20 @@ public class Settings {
|
||||
|
||||
private static EhConfig loadEhConfig() {
|
||||
EhConfig ehConfig= new EhConfig();
|
||||
// TODO
|
||||
ehConfig.excludedLanguages = getExcludedLanguages();
|
||||
ehConfig.defaultCategories = getDefaultCategories();
|
||||
ehConfig.excludedNamespaces = getExcludedTagNamespaces();
|
||||
ehConfig.setDirty();
|
||||
return ehConfig;
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key, boolean defValue) {
|
||||
return sSettingsPre.getBoolean(key, defValue);
|
||||
try {
|
||||
return sSettingsPre.getBoolean(key, defValue);
|
||||
} catch (ClassCastException e) {
|
||||
Log.d(TAG, "Get ClassCastException when get " + key + " value", e);
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void putBoolean(String key, boolean value) {
|
||||
@@ -63,7 +75,12 @@ public class Settings {
|
||||
}
|
||||
|
||||
public static int getInt(String key, int defValue) {
|
||||
return sSettingsPre.getInt(key, defValue);
|
||||
try {
|
||||
return sSettingsPre.getInt(key, defValue);
|
||||
} catch (ClassCastException e) {
|
||||
Log.d(TAG, "Get ClassCastException when get " + key + " value", e);
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void putInt(String key, int value) {
|
||||
@@ -71,7 +88,12 @@ public class Settings {
|
||||
}
|
||||
|
||||
public static long getLong(String key, long defValue) {
|
||||
return sSettingsPre.getLong(key, defValue);
|
||||
try {
|
||||
return sSettingsPre.getLong(key, defValue);
|
||||
} catch (ClassCastException e) {
|
||||
Log.d(TAG, "Get ClassCastException when get " + key + " value", e);
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void putLong(String key, long value) {
|
||||
@@ -79,7 +101,12 @@ public class Settings {
|
||||
}
|
||||
|
||||
public static float getFloat(String key, float defValue) {
|
||||
return sSettingsPre.getFloat(key, defValue);
|
||||
try {
|
||||
return sSettingsPre.getFloat(key, defValue);
|
||||
} catch (ClassCastException e) {
|
||||
Log.d(TAG, "Get ClassCastException when get " + key + " value", e);
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void putFloat(String key, float value) {
|
||||
@@ -87,7 +114,12 @@ public class Settings {
|
||||
}
|
||||
|
||||
public static String getString(String key, String defValue) {
|
||||
return sSettingsPre.getString(key, defValue);
|
||||
try {
|
||||
return sSettingsPre.getString(key, defValue);
|
||||
} catch (ClassCastException e) {
|
||||
Log.d(TAG, "Get ClassCastException when get " + key + " value", e);
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void putString(String key, String value) {
|
||||
@@ -95,7 +127,12 @@ public class Settings {
|
||||
}
|
||||
|
||||
public static int getIntFromStr(String key, int defValue) {
|
||||
return NumberUtils.parseIntSafely(sSettingsPre.getString(key, Integer.toString(defValue)), defValue);
|
||||
try {
|
||||
return NumberUtils.parseIntSafely(sSettingsPre.getString(key, Integer.toString(defValue)), defValue);
|
||||
} catch (ClassCastException e) {
|
||||
Log.d(TAG, "Get ClassCastException when get " + key + " value", e);
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void putIntToStr(String key, int value) {
|
||||
@@ -164,6 +201,13 @@ public class Settings {
|
||||
/********************
|
||||
****** Eh
|
||||
********************/
|
||||
public static final String KEY_LIST_MODE = "list_mode";
|
||||
private static final int DEFAULT_LIST_MODE = 0;
|
||||
|
||||
public static int getListMode() {
|
||||
return getIntFromStr(KEY_LIST_MODE, DEFAULT_LIST_MODE);
|
||||
}
|
||||
|
||||
private static final String KEY_SHOW_JPN_TITLE = "show_jpn_title";
|
||||
private static final boolean DEFAULT_SHOW_JPN_TITLE = false;
|
||||
|
||||
@@ -171,6 +215,45 @@ public class Settings {
|
||||
return getBoolean(KEY_SHOW_JPN_TITLE, DEFAULT_SHOW_JPN_TITLE);
|
||||
}
|
||||
|
||||
public static final String KEY_DEFAULT_CATEGORIES = "default_categories";
|
||||
public static final int DEFAULT_DEFAULT_CATEGORIES = ListUrlBuilder.ALL_CATEGORT;
|
||||
|
||||
public static int getDefaultCategories() {
|
||||
return getInt(KEY_DEFAULT_CATEGORIES, DEFAULT_DEFAULT_CATEGORIES);
|
||||
}
|
||||
|
||||
public static void putDefaultCategories(int value) {
|
||||
sEhConfig.defaultCategories = value;
|
||||
sEhConfig.setDirty();
|
||||
putInt(KEY_DEFAULT_CATEGORIES, value);
|
||||
}
|
||||
|
||||
public static final String KEY_EXCLUDED_TAG_NAMESPACES = "excluded_tag_namespaces";
|
||||
private static final int DEFAULT_EXCLUDED_TAG_NAMESPACES = 0;
|
||||
|
||||
public static int getExcludedTagNamespaces() {
|
||||
return getInt(KEY_EXCLUDED_TAG_NAMESPACES, DEFAULT_EXCLUDED_TAG_NAMESPACES);
|
||||
}
|
||||
|
||||
public static void putExcludedTagNamespaces(int value) {
|
||||
sEhConfig.excludedNamespaces = value;
|
||||
sEhConfig.setDirty();
|
||||
putInt(KEY_EXCLUDED_TAG_NAMESPACES, value);
|
||||
}
|
||||
|
||||
public static final String KEY_EXCLUDED_LANGUAGES = "excluded_languages";
|
||||
private static final String DEFAULT_EXCLUDED_LANGUAGES = null;
|
||||
|
||||
public static String getExcludedLanguages() {
|
||||
return getString(KEY_EXCLUDED_LANGUAGES, DEFAULT_EXCLUDED_LANGUAGES);
|
||||
}
|
||||
|
||||
public static void putExcludedLanguages(String value) {
|
||||
sEhConfig.excludedLanguages = value;
|
||||
sEhConfig.setDirty();
|
||||
putString(KEY_EXCLUDED_LANGUAGES, value);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Read
|
||||
********************/
|
||||
@@ -322,6 +405,28 @@ public class Settings {
|
||||
putString(KEY_DEFAULT_DOWNLOAD_LABEL, value);
|
||||
}
|
||||
|
||||
private static final String KEY_MULTI_THREAD_DOWNLOAD = "download_thread";
|
||||
private static final int DEFAULT_MULTI_THREAD_DOWNLOAD = 3;
|
||||
|
||||
public static int getMultiThreadDownload() {
|
||||
return getIntFromStr(KEY_MULTI_THREAD_DOWNLOAD, DEFAULT_MULTI_THREAD_DOWNLOAD);
|
||||
}
|
||||
|
||||
public static void putMultiThreadDownload(int value) {
|
||||
putIntToStr(KEY_MULTI_THREAD_DOWNLOAD, value);
|
||||
}
|
||||
|
||||
private static final String KEY_PRELOAD_IMAGE = "preload_image";
|
||||
private static final int DEFAULT_PRELOAD_IMAGE = 5;
|
||||
|
||||
public static int getPreloadImage() {
|
||||
return getIntFromStr(KEY_PRELOAD_IMAGE, DEFAULT_PRELOAD_IMAGE);
|
||||
}
|
||||
|
||||
public static void putPreloadImage(int value) {
|
||||
putIntToStr(KEY_PRELOAD_IMAGE, value);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Favorites
|
||||
********************/
|
||||
@@ -389,7 +494,7 @@ public class Settings {
|
||||
}
|
||||
|
||||
// -1 for local, 0 - 9 for cloud favorite, other for no default fav slot
|
||||
private static final String KEY_DEFAULT_FAV_SLOT = "default_favorite";
|
||||
private static final String KEY_DEFAULT_FAV_SLOT = "default_favorite_2";
|
||||
public static final int INVALID_DEFAULT_FAV_SLOT = -2;
|
||||
private static final int DEFAULT_DEFAULT_FAV_SLOT = INVALID_DEFAULT_FAV_SLOT;
|
||||
|
||||
@@ -506,14 +611,75 @@ public class Settings {
|
||||
****** Crash
|
||||
********************/
|
||||
private static final String KEY_CRASH_FILENAME = "crash_filename";
|
||||
private static final String VALUE_CRASH_FILENAME = null;
|
||||
private static final String DEFAULT_CRASH_FILENAME = null;
|
||||
|
||||
public static String getCrashFilename() {
|
||||
return getString(KEY_CRASH_FILENAME, VALUE_CRASH_FILENAME);
|
||||
return getString(KEY_CRASH_FILENAME, DEFAULT_CRASH_FILENAME);
|
||||
}
|
||||
|
||||
@SuppressLint("CommitPrefEdits")
|
||||
public static void putCrashFilename(String value) {
|
||||
sSettingsPre.edit().putString(KEY_CRASH_FILENAME, value).commit();
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Advanced
|
||||
********************/
|
||||
public static final String KEY_SAVE_PARSE_ERROR_BODY = "save_parse_error_body";
|
||||
private static final boolean DEFAULT_SAVE_PARSE_ERROR_BODY = EhApplication.BETA;
|
||||
|
||||
public static boolean getSaveParseErrorBody() {
|
||||
return getBoolean(KEY_SAVE_PARSE_ERROR_BODY, DEFAULT_SAVE_PARSE_ERROR_BODY);
|
||||
}
|
||||
|
||||
public static void putSaveParseErrorBody(boolean value) {
|
||||
putBoolean(KEY_SAVE_PARSE_ERROR_BODY, value);
|
||||
}
|
||||
|
||||
/********************
|
||||
****** Guide
|
||||
********************/
|
||||
private static final String KEY_GUIDE_QUICK_SEARCH = "guide_quick_search";
|
||||
private static final boolean DEFAULT_GUIDE_QUICK_SEARCH = true;
|
||||
|
||||
public static boolean getGuideQuickSearch() {
|
||||
return getBoolean(KEY_GUIDE_QUICK_SEARCH, DEFAULT_GUIDE_QUICK_SEARCH);
|
||||
}
|
||||
|
||||
public static void putGuideQuickSearch(boolean value) {
|
||||
putBoolean(KEY_GUIDE_QUICK_SEARCH, value);
|
||||
}
|
||||
|
||||
private static final String KEY_GUIDE_COLLECTIONS = "guide_collections";
|
||||
private static final boolean DEFAULT_GUIDE_COLLECTIONS = true;
|
||||
|
||||
public static boolean getGuideCollections() {
|
||||
return getBoolean(KEY_GUIDE_COLLECTIONS, DEFAULT_GUIDE_COLLECTIONS);
|
||||
}
|
||||
|
||||
public static void putGuideCollections(boolean value) {
|
||||
putBoolean(KEY_GUIDE_COLLECTIONS, value);
|
||||
}
|
||||
|
||||
private static final String KEY_GUIDE_DOWNLOAD_THUMB = "guide_download_thumb";
|
||||
private static final boolean DEFAULT_GUIDE_DOWNLOAD_THUMB = true;
|
||||
|
||||
public static boolean getGuideDownloadThumb() {
|
||||
return getBoolean(KEY_GUIDE_DOWNLOAD_THUMB, DEFAULT_GUIDE_DOWNLOAD_THUMB);
|
||||
}
|
||||
|
||||
public static void putGuideDownloadThumb(boolean value) {
|
||||
putBoolean(KEY_GUIDE_DOWNLOAD_THUMB, value);
|
||||
}
|
||||
|
||||
private static final String KEY_GUIDE_DOWNLOAD_LABELS = "guide_download_labels";
|
||||
private static final boolean DEFAULT_GUIDE_DOWNLOAD_LABELS = true;
|
||||
|
||||
public static boolean getGuideDownloadLabels() {
|
||||
return getBoolean(KEY_GUIDE_DOWNLOAD_LABELS, DEFAULT_GUIDE_DOWNLOAD_LABELS);
|
||||
}
|
||||
|
||||
public static void puttGuideDownloadLabels(boolean value) {
|
||||
putBoolean(KEY_GUIDE_DOWNLOAD_LABELS, value);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package com.hippo.ehviewer.client;
|
||||
public class EhCacheKeyFactory {
|
||||
|
||||
public static String getThumbKey(long gid) {
|
||||
return "thumb:" + gid;
|
||||
return "preview:large:" + gid + ":" + 0; // "thumb:" + gid;
|
||||
}
|
||||
|
||||
public static String getNormalPreviewKey(long gid, int index) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class EhCookieStore extends CookieDBStore {
|
||||
public static final String KEY_IPD_MEMBER_ID = "ipb_member_id";
|
||||
public static final String KEY_IPD_PASS_HASH = "ipb_pass_hash";
|
||||
|
||||
public void cleanUpForSignIn() {
|
||||
public void signOut() {
|
||||
removeAll();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,10 @@ import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.GetText;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
@@ -41,11 +43,17 @@ import com.hippo.ehviewer.client.parser.SignInParser;
|
||||
import com.hippo.ehviewer.client.parser.TorrentParser;
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -71,6 +79,33 @@ public class EhEngine {
|
||||
|
||||
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
|
||||
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()) {
|
||||
@@ -88,6 +123,9 @@ public class EhEngine {
|
||||
if (body != null && !body.contains("<")){
|
||||
throw new EhException(body);
|
||||
} else {
|
||||
if (Settings.getSaveParseErrorBody()) {
|
||||
saveParseErrorBody((ParseException) e);
|
||||
}
|
||||
throw new EhException(GetText.getString(R.string.error_parse_error));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,9 +115,14 @@ public class EhUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void signOut(Context context) {
|
||||
EhApplication.getEhCookieStore(context).signOut();
|
||||
Settings.putAvatar(null);
|
||||
Settings.putDisplayName(null);
|
||||
}
|
||||
|
||||
public static boolean hasSignedIn(Context context) {
|
||||
return EhApplication.getEhCookieStore(context).hasSignedIn() &&
|
||||
Settings.getDisplayName() != null;
|
||||
return EhApplication.getEhCookieStore(context).hasSignedIn();
|
||||
}
|
||||
|
||||
public static String getSuitableTitle(GalleryInfo gi) {
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
|
||||
@@ -25,13 +28,24 @@ import org.jsoup.nodes.Element;
|
||||
|
||||
public class ProfileParser {
|
||||
|
||||
private static final String TAG = ProfileParser.class.getSimpleName();
|
||||
|
||||
public static Result parse(String body) throws ParseException {
|
||||
try {
|
||||
Result result = new Result();
|
||||
Document d = Jsoup.parse(body, EhUrl.URL_FORUMS);
|
||||
Document d = Jsoup.parse(body);
|
||||
Element profilename = d.getElementById("profilename");
|
||||
result.displayName = profilename.child(0).text();
|
||||
result.avatar = profilename.nextElementSibling().nextElementSibling().child(0).attr("src");
|
||||
try {
|
||||
result.avatar = profilename.nextElementSibling().nextElementSibling().child(0).attr("src");
|
||||
if (TextUtils.isEmpty(result.avatar)) {
|
||||
result.avatar = null;
|
||||
} else if (!result.avatar.startsWith("http")) {
|
||||
result.avatar = EhUrl.URL_FORUMS + result.avatar;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.i(TAG, "No avatar");
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
throw new ParseException("Parse forums error", body);
|
||||
|
||||
@@ -50,26 +50,23 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
@NonNull
|
||||
// All download info list
|
||||
private final LinkedList<DownloadInfo> mAllInfoList;
|
||||
// All download info map
|
||||
private final SparseJLArray<DownloadInfo> mAllInfoMap;
|
||||
// label and info list map, without default label info list
|
||||
private final Map<String, LinkedList<DownloadInfo>> mMap;
|
||||
// All labels without default label
|
||||
@NonNull
|
||||
private final List<DownloadLabel> mLabelList;
|
||||
// Store download info with default label
|
||||
@NonNull
|
||||
private final LinkedList<DownloadInfo> mDefaultInfoList;
|
||||
// For quick search
|
||||
@NonNull
|
||||
private final SparseJLArray<DownloadInfo> mAllInfoMap;
|
||||
// Store download info wait to start
|
||||
@NonNull
|
||||
private final LinkedList<DownloadInfo> mWaitList;
|
||||
@NonNull
|
||||
|
||||
private final SpeedReminder mSpeedReminder;
|
||||
|
||||
@Nullable
|
||||
private DownloadListener mDownloadListener;
|
||||
@NonNull
|
||||
private final List<DownloadInfoListener> mDownloadInfoListeners;
|
||||
|
||||
@Nullable
|
||||
@@ -77,12 +74,12 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
@Nullable
|
||||
private SpiderQueen mCurrentSpider;
|
||||
|
||||
@NonNull
|
||||
private final ConcurrentPool<NotifyTask> mNotifyTaskPool = new ConcurrentPool<>(5);
|
||||
|
||||
public DownloadManager(Context context) {
|
||||
mContext = context;
|
||||
|
||||
// Get all labels
|
||||
List<DownloadLabel> labels = EhDB.getAllDownloadLabelList();
|
||||
mLabelList = labels;
|
||||
|
||||
@@ -92,21 +89,28 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
for (DownloadLabel label : labels) {
|
||||
map.put(label.getLabel(), new LinkedList<DownloadInfo>());
|
||||
}
|
||||
|
||||
// Create default for non tag
|
||||
mDefaultInfoList = new LinkedList<>();
|
||||
// Create all download info map
|
||||
SparseJLArray<DownloadInfo> allInfoMap = new SparseJLArray<>();
|
||||
|
||||
// Get all info
|
||||
List<DownloadInfo> allInfoList = EhDB.getAllDownloadInfo();
|
||||
mAllInfoList = new LinkedList<>(allInfoList);
|
||||
|
||||
// Create all info map
|
||||
SparseJLArray<DownloadInfo> allInfoMap = new SparseJLArray<>(allInfoList.size() + 10);
|
||||
mAllInfoMap = allInfoMap;
|
||||
|
||||
// Fill download info list
|
||||
List<DownloadInfo> allInfoList = EhDB.getAllDownloadInfos();
|
||||
for (DownloadInfo info: allInfoList) {
|
||||
for (int i = 0, n = allInfoList.size(); i < n; i++) {
|
||||
DownloadInfo info = allInfoList.get(i);
|
||||
|
||||
// Add to all info map
|
||||
allInfoMap.put(info.gid, info);
|
||||
|
||||
// Add to each label list
|
||||
LinkedList<DownloadInfo> list = getInfoListForLabel(info.label);
|
||||
if (list == null) {
|
||||
// Can't find the label in label list
|
||||
list = new LinkedList<>();
|
||||
map.put(info.label, list);
|
||||
if (!containLabel(info.label)) {
|
||||
@@ -262,9 +266,10 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
Log.e(TAG, "Can't find download info list with label: " + label);
|
||||
return;
|
||||
}
|
||||
list.add(info);
|
||||
list.addFirst(info);
|
||||
|
||||
// Add to all download list and map
|
||||
mAllInfoList.addFirst(info);
|
||||
mAllInfoMap.put(galleryInfo.gid, info);
|
||||
|
||||
// Add to wait list
|
||||
@@ -319,11 +324,9 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
void startAllDownload() {
|
||||
boolean update = false;
|
||||
// Start all STATE_NONE and STATE_FAILED item
|
||||
// TODO keep order in wait list
|
||||
SparseJLArray<DownloadInfo> allInfoMap = mAllInfoMap;
|
||||
List<DownloadInfo> waitList = mWaitList;
|
||||
for (int i = 0, n = allInfoMap.size(); i < n; i++) {
|
||||
DownloadInfo info = allInfoMap.valueAt(i);
|
||||
LinkedList<DownloadInfo> allInfoList = mAllInfoList;
|
||||
LinkedList<DownloadInfo> waitList = mWaitList;
|
||||
for (DownloadInfo info: allInfoList) {
|
||||
if (info.state == DownloadInfo.STATE_NONE || info.state == DownloadInfo.STATE_FAILED) {
|
||||
update = true;
|
||||
// Set state DownloadInfo.STATE_WAIT
|
||||
@@ -363,14 +366,12 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
Log.e(TAG, "Can't find download info list with label: " + label);
|
||||
return;
|
||||
}
|
||||
list.add(info);
|
||||
list.addFirst(info);
|
||||
|
||||
// Add to all download list and map
|
||||
mAllInfoList.addFirst(info);
|
||||
mAllInfoMap.put(galleryInfo.gid, info);
|
||||
|
||||
// Add to wait list
|
||||
mWaitList.add(info);
|
||||
|
||||
// Save to
|
||||
EhDB.putDownloadInfo(info);
|
||||
|
||||
@@ -381,7 +382,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
}
|
||||
|
||||
|
||||
void stopDownload(long gid) {
|
||||
public void stopDownload(long gid) {
|
||||
DownloadInfo info = stopDownloadInternal(gid);
|
||||
if (info != null) {
|
||||
// Update listener
|
||||
@@ -411,7 +412,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
}
|
||||
}
|
||||
|
||||
void stopRangeDownload(LongList gidList) {
|
||||
public void stopRangeDownload(LongList gidList) {
|
||||
stopRangeDownloadInternal(gidList);
|
||||
|
||||
// Update listener
|
||||
@@ -423,7 +424,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
ensureDownload();
|
||||
}
|
||||
|
||||
void stopAllDownload() {
|
||||
public void stopAllDownload() {
|
||||
// Stop all in wait list
|
||||
for (DownloadInfo info : mWaitList) {
|
||||
info.state = DownloadInfo.STATE_NONE;
|
||||
@@ -441,7 +442,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
}
|
||||
}
|
||||
|
||||
void deleteDownload(long gid) {
|
||||
public void deleteDownload(long gid) {
|
||||
stopDownloadInternal(gid);
|
||||
DownloadInfo info = mAllInfoMap.get(gid);
|
||||
if (info != null) {
|
||||
@@ -449,6 +450,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
EhDB.removeDownloadInfo(info.gid);
|
||||
|
||||
// Remove all list and map
|
||||
mAllInfoList.remove(info);
|
||||
mAllInfoMap.remove(info.gid);
|
||||
|
||||
// Remove label list
|
||||
@@ -469,7 +471,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
}
|
||||
}
|
||||
|
||||
void deleteRangeDownload(LongList gidList) {
|
||||
public void deleteRangeDownload(LongList gidList) {
|
||||
stopRangeDownloadInternal(gidList);
|
||||
|
||||
for (int i = 0, n = gidList.size(); i < n; i++) {
|
||||
@@ -484,6 +486,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
EhDB.removeDownloadInfo(info.gid);
|
||||
|
||||
// Remove from all info map
|
||||
mAllInfoList.remove(info);
|
||||
mAllInfoMap.remove(info.gid);
|
||||
|
||||
// Remove from label list
|
||||
@@ -598,8 +601,6 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
for (DownloadInfo info: list) {
|
||||
if (ObjectUtils.equal(info.label, label)) {
|
||||
continue;
|
||||
@@ -614,13 +615,10 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
srcList.remove(info);
|
||||
dstList.add(info);
|
||||
info.label = label;
|
||||
// TODO Other comparator
|
||||
Collections.sort(dstList, sDateAscComparator);
|
||||
Collections.sort(dstList, sDateDescComparator);
|
||||
|
||||
// Save to DB
|
||||
EhDB.putDownloadInfo(info);
|
||||
|
||||
changed = true;
|
||||
}
|
||||
|
||||
for (DownloadInfoListener l: mDownloadInfoListeners) {
|
||||
@@ -717,7 +715,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
}
|
||||
|
||||
// Sort
|
||||
Collections.sort(mDefaultInfoList, sDateAscComparator);
|
||||
Collections.sort(mDefaultInfoList, sDateDescComparator);
|
||||
|
||||
// Notify listener
|
||||
for (DownloadInfoListener l: mDownloadInfoListeners) {
|
||||
@@ -814,6 +812,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
private long mContentLength;
|
||||
private long mReceivedSize;
|
||||
private int mBytesRead;
|
||||
@SuppressWarnings("unused")
|
||||
private String mError;
|
||||
private int mFinished;
|
||||
private int mDownloaded;
|
||||
@@ -1075,10 +1074,10 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Comparator<DownloadInfo> sDateAscComparator = new Comparator<DownloadInfo>() {
|
||||
private static final Comparator<DownloadInfo> sDateDescComparator = new Comparator<DownloadInfo>() {
|
||||
@Override
|
||||
public int compare(DownloadInfo lhs, DownloadInfo rhs) {
|
||||
return lhs.time - rhs.time > 0 ? 1 : -1;
|
||||
return lhs.time - rhs.time > 0 ? -1 : 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.dao.DownloadInfo;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
@@ -296,7 +297,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
|
||||
ensureDownloadingBuilder();
|
||||
|
||||
mDownloadingBuilder.setContentTitle(info.title)
|
||||
mDownloadingBuilder.setContentTitle(EhUtils.getSuitableTitle(info))
|
||||
.setContentText(null)
|
||||
.setContentInfo(null)
|
||||
.setProgress(0, 0, true);
|
||||
@@ -321,7 +322,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
} else {
|
||||
text = getString(R.string.download_speed_text, text);
|
||||
}
|
||||
mDownloadingBuilder.setContentTitle(info.title)
|
||||
mDownloadingBuilder.setContentTitle(EhUtils.getSuitableTitle(info))
|
||||
.setContentText(text)
|
||||
.setContentInfo(info.total == -1 || info.finished == -1 ? null : info.finished + "/" + info.total)
|
||||
.setProgress(info.total, info.finished, false);
|
||||
@@ -354,7 +355,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
int index = sItemStateArray.indexOfKey(gid);
|
||||
if (index < 0) { // Not contain
|
||||
sItemStateArray.put(gid, finish);
|
||||
sItemTitleArray.put(gid, info.title);
|
||||
sItemTitleArray.put(gid, EhUtils.getSuitableTitle(info));
|
||||
sDownloadedCount++;
|
||||
if (finish) {
|
||||
sFinishedCount++;
|
||||
@@ -364,7 +365,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
} else { // Contain
|
||||
boolean oldFinish = sItemStateArray.valueAt(index);
|
||||
sItemStateArray.put(gid, finish);
|
||||
sItemTitleArray.put(gid, info.title);
|
||||
sItemTitleArray.put(gid, EhUtils.getSuitableTitle(info));
|
||||
if (oldFinish && !finish) {
|
||||
sFinishedCount--;
|
||||
sFailedCount++;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.widget.CategoryTable;
|
||||
import com.hippo.preference.DialogPreference;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public class DefaultCategoryPreference extends DialogPreference {
|
||||
|
||||
@Nullable
|
||||
private CategoryTable mCategoryTable;
|
||||
|
||||
public DefaultCategoryPreference(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public DefaultCategoryPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public DefaultCategoryPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public DefaultCategoryPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setDialogLayoutResource(R.layout.preference_dialog_default_categories);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogCreated(AlertDialog dialog) {
|
||||
super.onDialogCreated(dialog);
|
||||
mCategoryTable = (CategoryTable) ViewUtils.$$(dialog, R.id.category_table);
|
||||
mCategoryTable.setCategory(Settings.getDefaultCategories());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
super.onDialogClosed(positiveResult);
|
||||
if (null != mCategoryTable && positiveResult) {
|
||||
Settings.putDefaultCategories(mCategoryTable.getCategory());
|
||||
}
|
||||
mCategoryTable = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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.v7.app.AlertDialog;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.preference.DialogPreference;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public class ExcludedTagNamespacesPreference extends DialogPreference {
|
||||
|
||||
private View mTableLayout;
|
||||
|
||||
private static final int[] EXCLUDED_TAG_GROUP_RES_ID = {
|
||||
R.id.tag_group_reclass,
|
||||
R.id.tag_group_language,
|
||||
R.id.tag_group_parody,
|
||||
R.id.tag_group_character,
|
||||
R.id.tag_group_group,
|
||||
R.id.tag_group_artist,
|
||||
R.id.tag_group_male,
|
||||
R.id.tag_group_female,
|
||||
};
|
||||
|
||||
private static final int[] EXCLUDED_TAG_GROUP_ID = {
|
||||
0x1,
|
||||
0x2,
|
||||
0x4,
|
||||
0x8,
|
||||
0x10,
|
||||
0x20,
|
||||
0x40,
|
||||
0x80
|
||||
};
|
||||
|
||||
public ExcludedTagNamespacesPreference(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public ExcludedTagNamespacesPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public ExcludedTagNamespacesPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public ExcludedTagNamespacesPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setDialogLayoutResource(R.layout.preference_dialog_excluded_tag_namespaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogCreated(AlertDialog dialog) {
|
||||
super.onDialogCreated(dialog);
|
||||
mTableLayout = ViewUtils.$$(dialog, R.id.table_layout);
|
||||
setExcludedTagNamespaces(mTableLayout, Settings.getExcludedTagNamespaces());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
super.onDialogClosed(positiveResult);
|
||||
if (null != mTableLayout && positiveResult) {
|
||||
Settings.putExcludedTagNamespaces(getExcludedTagNamespaces(mTableLayout));
|
||||
}
|
||||
mTableLayout = null;
|
||||
}
|
||||
|
||||
private void setExcludedTagNamespaces(View view, int value) {
|
||||
for (int i = 0; i < EXCLUDED_TAG_GROUP_RES_ID.length; i++) {
|
||||
CheckBox cb = (CheckBox) view.findViewById(EXCLUDED_TAG_GROUP_RES_ID[i]);
|
||||
cb.setChecked(NumberUtils.int2boolean(value & EXCLUDED_TAG_GROUP_ID[i]));
|
||||
}
|
||||
}
|
||||
|
||||
private int getExcludedTagNamespaces(View view) {
|
||||
int newValue = 0;
|
||||
for (int i = 0; i < EXCLUDED_TAG_GROUP_RES_ID.length; i++) {
|
||||
CheckBox cb = (CheckBox) view.findViewById(EXCLUDED_TAG_GROUP_RES_ID[i]);
|
||||
if (cb.isChecked()) {
|
||||
newValue |= EXCLUDED_TAG_GROUP_ID[i];
|
||||
}
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.v7.app.AlertDialog;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.preference.MessagePreference;
|
||||
|
||||
public class SignOutPreference extends MessagePreference {
|
||||
|
||||
public SignOutPreference(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public SignOutPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public SignOutPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public SignOutPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setDialogMessage(getContext().getString(R.string.settings_eh_sign_out_warning));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
builder.setPositiveButton(R.string.settings_eh_sign_out_yes, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
super.onDialogClosed(positiveResult);
|
||||
if (positiveResult) {
|
||||
EhUtils.signOut(getContext());
|
||||
Toast.makeText(getContext(), R.string.settings_eh_sign_out_tip, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.hippo.beerbelly.SimpleDiskCache;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
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.gallery.GalleryProvider;
|
||||
import com.hippo.io.UniFileInputStreamPipe;
|
||||
@@ -61,7 +62,7 @@ public final class SpiderDen {
|
||||
// Read from DB
|
||||
String dirname = EhDB.getDownloadDirname(galleryInfo.gid);
|
||||
if (dirname == null) {
|
||||
dirname = FileUtils.sanitizeFilename(galleryInfo.gid + "-" + galleryInfo.title);
|
||||
dirname = FileUtils.sanitizeFilename(galleryInfo.gid + "-" + EhUtils.getSuitableTitle(galleryInfo));
|
||||
// Put into DB
|
||||
EhDB.putDownloadDirname(galleryInfo.gid, dirname);
|
||||
}
|
||||
|
||||
@@ -100,9 +100,6 @@ public class SpiderQueen implements Runnable {
|
||||
public static final int STATE_FINISHED = 2;
|
||||
public static final int STATE_FAILED = 3;
|
||||
|
||||
private static final int NUMBER_SPIDER_WORKER = 3;
|
||||
private static final int NUMBER_PRELOAD = 5;
|
||||
|
||||
public static final String SPIDER_INFO_FILENAME = ".ehviewer";
|
||||
|
||||
private static final String[] URL_509_SUFFIX_ARRAY = {
|
||||
@@ -169,11 +166,17 @@ public class SpiderQueen implements Runnable {
|
||||
|
||||
private final List<OnSpiderListener> mSpiderListeners = new ArrayList<>();
|
||||
|
||||
private final int mSpiderWorkerNumber;
|
||||
private final int mPreloadNumber;
|
||||
|
||||
private SpiderQueen(EhApplication application, @NonNull GalleryInfo galleryInfo) {
|
||||
mHttpClient = EhApplication.getOkHttpClient(application);
|
||||
mSpiderInfoCache = EhApplication.getSpiderInfoCache(application);
|
||||
mGalleryInfo = galleryInfo;
|
||||
mSpiderDen = new SpiderDen(mGalleryInfo);
|
||||
|
||||
mSpiderWorkerNumber = Settings.getMultiThreadDownload();
|
||||
mPreloadNumber = Settings.getPreloadImage();
|
||||
}
|
||||
|
||||
public void addOnSpiderListener(OnSpiderListener listener) {
|
||||
@@ -311,18 +314,19 @@ public class SpiderQueen implements Runnable {
|
||||
mSpiderDen.setMode(mMode);
|
||||
|
||||
// Update download page
|
||||
boolean downloadMode;
|
||||
boolean intoDownloadMode = false;
|
||||
synchronized (mRequestPageQueue) {
|
||||
if (mMode == MODE_DOWNLOAD) {
|
||||
mDownloadPage = 0;
|
||||
downloadMode = true;
|
||||
if (mDownloadPage < 0) {
|
||||
mDownloadPage = 0;
|
||||
intoDownloadMode = true;
|
||||
}
|
||||
} else {
|
||||
mDownloadPage = -1;
|
||||
downloadMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadMode && mPageStateArray != null) {
|
||||
if (intoDownloadMode && mPageStateArray != null) {
|
||||
// Clear download state
|
||||
synchronized (mPageStateLock) {
|
||||
int[] temp = mPageStateArray;
|
||||
@@ -494,7 +498,7 @@ public class SpiderQueen implements Runnable {
|
||||
} else {
|
||||
size = Integer.MAX_VALUE;
|
||||
}
|
||||
for (int i = index + 1, n = index + i + NUMBER_PRELOAD; i < n && i < size; i++) {
|
||||
for (int i = index + 1, n = index + i + mPreloadNumber; i < n && i < size; i++) {
|
||||
if (STATE_NONE == getPageState(i)) {
|
||||
mRequestPageQueue2.add(i);
|
||||
}
|
||||
@@ -538,7 +542,7 @@ public class SpiderQueen implements Runnable {
|
||||
private void ensureWorkers() {
|
||||
synchronized (mWorkerLock) {
|
||||
if (mWorkers == null) {
|
||||
mWorkers = new Thread[NUMBER_SPIDER_WORKER];
|
||||
mWorkers = new Thread[mSpiderWorkerNumber];
|
||||
}
|
||||
|
||||
for (int i = 0, n = mWorkers.length; i < n; i++) {
|
||||
|
||||
@@ -216,10 +216,10 @@ public final class CommonOperations {
|
||||
client.execute(request);
|
||||
}
|
||||
|
||||
public static void startDownload(final Activity activity, final GalleryInfo galleryInfo) {
|
||||
public static void startDownload(final Activity activity, final GalleryInfo galleryInfo, boolean forceDefault) {
|
||||
final DownloadManager dm = EhApplication.getDownloadManager(activity);
|
||||
|
||||
boolean justStart = dm.containDownloadInfo(galleryInfo.gid);
|
||||
boolean justStart = forceDefault || dm.containDownloadInfo(galleryInfo.gid);
|
||||
String label = null;
|
||||
// Get default download label
|
||||
if (!justStart && Settings.getHasDefaultDownloadLabel()) {
|
||||
|
||||
@@ -40,6 +40,8 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
|
||||
public static final String KEY_FILE_URI = "file_uri";
|
||||
|
||||
public static final String KEY_FILE_PATH = "file_path";
|
||||
|
||||
/*---------------
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@@ -54,7 +56,6 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_dir_picker);
|
||||
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
|
||||
|
||||
@@ -62,13 +63,11 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
mDirExplorer = (DirExplorer) ViewUtils.$$(this, R.id.dir_explorer);
|
||||
mOk = ViewUtils.$$(this, R.id.ok);
|
||||
|
||||
File file = null;
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
Uri fileUri = intent.getParcelableExtra(KEY_FILE_URI);
|
||||
if (fileUri != null) {
|
||||
file = new File(fileUri.getPath());
|
||||
}
|
||||
File file;
|
||||
if (null == savedInstanceState) {
|
||||
file = onInit();
|
||||
} else {
|
||||
file = onRestore(savedInstanceState);
|
||||
}
|
||||
|
||||
mDirExplorer.setCurrentFile(file);
|
||||
@@ -81,6 +80,34 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
mPath.setText(mDirExplorer.getCurrentFile().getPath());
|
||||
}
|
||||
|
||||
private File onInit() {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
Uri fileUri = intent.getParcelableExtra(KEY_FILE_URI);
|
||||
if (fileUri != null) {
|
||||
return new File(fileUri.getPath());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private File onRestore(@NonNull Bundle savedInstanceState) {
|
||||
String filePath = savedInstanceState.getString(KEY_FILE_PATH);
|
||||
if (null != filePath) {
|
||||
return new File(filePath);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (null != mDirExplorer) {
|
||||
outState.putString(KEY_FILE_PATH, mDirExplorer.getCurrentFile().getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
* 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.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhConfig;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.widget.SensitiveCheckBox;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public class ExcludedLanguagesActivity extends ToolbarActivity
|
||||
implements View.OnClickListener {
|
||||
|
||||
private static final String KEY_SELECTIONS = "selections";
|
||||
|
||||
private static final int ROW_COUNT = 17;
|
||||
private static final int[] LANGUAGE_STR_IDS = {
|
||||
R.string.language_japanese,
|
||||
R.string.language_english,
|
||||
R.string.language_chinese,
|
||||
R.string.language_dutch,
|
||||
R.string.language_french,
|
||||
R.string.language_german,
|
||||
R.string.language_hungarian,
|
||||
R.string.language_italian,
|
||||
R.string.language_korean,
|
||||
R.string.language_polish,
|
||||
R.string.language_portuguese,
|
||||
R.string.language_russian,
|
||||
R.string.language_spanish,
|
||||
R.string.language_thai,
|
||||
R.string.language_vietnamese,
|
||||
R.string.language_na,
|
||||
R.string.language_other
|
||||
};
|
||||
|
||||
private static final String[] LANGUAGES = {
|
||||
EhConfig.JAPANESE_TRANSLATED,
|
||||
EhConfig.JAPANESE_REWRITE,
|
||||
EhConfig.ENGLISH_ORIGINAL,
|
||||
EhConfig.ENGLISH_TRANSLATED,
|
||||
EhConfig.ENGLISH_REWRITE,
|
||||
EhConfig.CHINESE_ORIGINAL,
|
||||
EhConfig.CHINESE_TRANSLATED,
|
||||
EhConfig.CHINESE_REWRITE,
|
||||
EhConfig.DUTCH_ORIGINAL,
|
||||
EhConfig.DUTCH_TRANSLATED,
|
||||
EhConfig.DUTCH_REWRITE,
|
||||
EhConfig.FRENCH_ORIGINAL,
|
||||
EhConfig.FRENCH_TRANSLATED,
|
||||
EhConfig.FRENCH_REWRITE,
|
||||
EhConfig.GERMAN_ORIGINAL,
|
||||
EhConfig.GERMAN_TRANSLATED,
|
||||
EhConfig.GERMAN_REWRITE,
|
||||
EhConfig.HUNGARIAN_ORIGINAL,
|
||||
EhConfig.HUNGARIAN_TRANSLATED,
|
||||
EhConfig.HUNGARIAN_REWRITE,
|
||||
EhConfig.ITALIAN_ORIGINAL,
|
||||
EhConfig.ITALIAN_TRANSLATED,
|
||||
EhConfig.ITALIAN_REWRITE,
|
||||
EhConfig.KOREAN_ORIGINAL,
|
||||
EhConfig.KOREAN_TRANSLATED,
|
||||
EhConfig.KOREAN_REWRITE,
|
||||
EhConfig.POLISH_ORIGINAL,
|
||||
EhConfig.POLISH_TRANSLATED,
|
||||
EhConfig.POLISH_REWRITE,
|
||||
EhConfig.PORTUGUESE_ORIGINAL,
|
||||
EhConfig.PORTUGUESE_TRANSLATED,
|
||||
EhConfig.PORTUGUESE_REWRITE,
|
||||
EhConfig.RUSSIAN_ORIGINAL,
|
||||
EhConfig.RUSSIAN_TRANSLATED,
|
||||
EhConfig.RUSSIAN_REWRITE,
|
||||
EhConfig.SPANISH_ORIGINAL,
|
||||
EhConfig.SPANISH_TRANSLATED,
|
||||
EhConfig.SPANISH_REWRITE,
|
||||
EhConfig.THAI_ORIGINAL,
|
||||
EhConfig.THAI_TRANSLATED,
|
||||
EhConfig.THAI_REWRITE,
|
||||
EhConfig.VIETNAMESE_ORIGINAL,
|
||||
EhConfig.VIETNAMESE_TRANSLATED,
|
||||
EhConfig.VIETNAMESE_REWRITE,
|
||||
EhConfig.NA_ORIGINAL,
|
||||
EhConfig.NA_TRANSLATED,
|
||||
EhConfig.NA_REWRITE,
|
||||
EhConfig.OTHER_ORIGINAL,
|
||||
EhConfig.OTHER_TRANSLATED,
|
||||
EhConfig.OTHER_REWRITE};
|
||||
|
||||
private final boolean[][] mSelections = new boolean[ROW_COUNT][3];
|
||||
|
||||
/*---------------
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private View mCancel;
|
||||
@Nullable
|
||||
private View mOk;
|
||||
@Nullable
|
||||
private View mSelectAll;
|
||||
@Nullable
|
||||
private View mDeselectAll;
|
||||
@Nullable
|
||||
private View mInvertSelection;
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private LanguageAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.scene_excluded_languages);
|
||||
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
|
||||
|
||||
if (null == savedInstanceState) {
|
||||
onInit();
|
||||
} else {
|
||||
onRestore(savedInstanceState);
|
||||
}
|
||||
|
||||
mCancel = ViewUtils.$$(this, R.id.cancel);
|
||||
mOk = ViewUtils.$$(this, R.id.ok);
|
||||
mSelectAll = ViewUtils.$$(this, R.id.select_all);
|
||||
mDeselectAll = ViewUtils.$$(this, R.id.deselect_all);
|
||||
mInvertSelection = ViewUtils.$$(this, R.id.invert_selection);
|
||||
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view);
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mAdapter = new LanguageAdapter();
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
mCancel.setOnClickListener(this);
|
||||
mOk.setOnClickListener(this);
|
||||
mSelectAll.setOnClickListener(this);
|
||||
mDeselectAll.setOnClickListener(this);
|
||||
mInvertSelection.setOnClickListener(this);
|
||||
|
||||
RippleSalon.addRipple(mCancel, false);
|
||||
RippleSalon.addRipple(mOk, false);
|
||||
RippleSalon.addRipple(mSelectAll, false);
|
||||
RippleSalon.addRipple(mDeselectAll, false);
|
||||
RippleSalon.addRipple(mInvertSelection, false);
|
||||
}
|
||||
|
||||
private boolean isDecimal(String str) {
|
||||
int length = str.length();
|
||||
|
||||
// "" is not decimal
|
||||
if (length <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
char ch = str.charAt(i);
|
||||
if (ch < '0' || ch > '9') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void onInit() {
|
||||
String excludedLanguages = Settings.getExcludedLanguages();
|
||||
if (null == excludedLanguages) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] languages = excludedLanguages.split("x");
|
||||
|
||||
int iLength = languages.length;
|
||||
int jLength = LANGUAGES.length;
|
||||
for (int i = 0, j = 0; i < iLength; i++) {
|
||||
String language = languages[i];
|
||||
if (!isDecimal(language)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (; j < jLength; j++) {
|
||||
String pattern = LANGUAGES[j];
|
||||
if (pattern.equals(language)) {
|
||||
// Get it
|
||||
int row = (j + 1) / 3;
|
||||
int column = (j + 1) % 3;
|
||||
mSelections[row][column] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long saveSelectionsToLong() {
|
||||
boolean[][] selections = mSelections;
|
||||
long value = 0;
|
||||
for (int i = 0; i < ROW_COUNT; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (selections[i][j]) {
|
||||
value |= 1 << (i * 3 + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private void restoreSelectionsFromLong(long value) {
|
||||
boolean[][] selections = mSelections;
|
||||
for (int i = 0; i < ROW_COUNT; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
selections[i][j] = 0 != ((value >>> (i * 3 + j)) & 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onRestore(@NonNull Bundle savedInstanceState) {
|
||||
restoreSelectionsFromLong(savedInstanceState.getLong(KEY_SELECTIONS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putLong(KEY_SELECTIONS, saveSelectionsToLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
mCancel = null;
|
||||
mOk = null;
|
||||
mSelectAll = null;
|
||||
mDeselectAll = null;
|
||||
mInvertSelection = null;
|
||||
mRecyclerView = null;
|
||||
mAdapter = 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 (null == mAdapter) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (v == mCancel) {
|
||||
finish();
|
||||
} else if (v == mOk) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i = -1;
|
||||
boolean first = true;
|
||||
for (boolean[] selections : mSelections) {
|
||||
for (boolean b : selections) {
|
||||
i++;
|
||||
if (i == 0) {
|
||||
continue;
|
||||
}
|
||||
if (b) {
|
||||
if (!first) {
|
||||
sb.append("x");
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
sb.append(LANGUAGES[i - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String excludedLanguages = sb.toString();
|
||||
Settings.putExcludedLanguages(excludedLanguages);
|
||||
finish();
|
||||
} else if (v == mSelectAll) {
|
||||
for (boolean[] selections : mSelections) {
|
||||
int length = selections.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
selections[i] = true;
|
||||
}
|
||||
}
|
||||
mAdapter.notifyDataSetChanged();
|
||||
} else if (v == mDeselectAll) {
|
||||
for (boolean[] selections : mSelections) {
|
||||
int length = selections.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
selections[i] = false;
|
||||
}
|
||||
}
|
||||
mAdapter.notifyDataSetChanged();
|
||||
} else if (v == mInvertSelection) {
|
||||
for (boolean[] selections : mSelections) {
|
||||
int length = selections.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
selections[i] = !selections[i];
|
||||
}
|
||||
}
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private class LanguageHolder extends RecyclerView.ViewHolder
|
||||
implements SensitiveCheckBox.OnCheckedChangeListener {
|
||||
|
||||
public TextView language;
|
||||
public SensitiveCheckBox original;
|
||||
public SensitiveCheckBox translated;
|
||||
public SensitiveCheckBox rewrite;
|
||||
|
||||
public LanguageHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
ViewGroup viewGroup = (ViewGroup) itemView;
|
||||
language = (TextView) viewGroup.getChildAt(0);
|
||||
original = (SensitiveCheckBox) viewGroup.getChildAt(1);
|
||||
translated = (SensitiveCheckBox) viewGroup.getChildAt(2);
|
||||
rewrite = (SensitiveCheckBox) viewGroup.getChildAt(3);
|
||||
|
||||
original.setOnCheckedChangeListener(this);
|
||||
translated.setOnCheckedChangeListener(this);
|
||||
rewrite.setOnCheckedChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(SensitiveCheckBox view, boolean isChecked, boolean fromUser) {
|
||||
if (fromUser) {
|
||||
int row = getAdapterPosition();
|
||||
if (row < 0) {
|
||||
return;
|
||||
}
|
||||
int column;
|
||||
if (view == original) {
|
||||
column = 0;
|
||||
} else if (view == translated) {
|
||||
column = 1;
|
||||
} else {
|
||||
column = 2;
|
||||
}
|
||||
mSelections[row][column] = !mSelections[row][column];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class LanguageAdapter extends RecyclerView.Adapter<LanguageHolder> {
|
||||
|
||||
@Override
|
||||
public LanguageHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new LanguageHolder(getLayoutInflater().inflate(R.layout.item_excluded_languages, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(LanguageHolder holder, int position) {
|
||||
holder.language.setText(LANGUAGE_STR_IDS[position]);
|
||||
if (position == 0) {
|
||||
holder.original.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
holder.original.setVisibility(View.VISIBLE);
|
||||
}
|
||||
boolean[] selections = mSelections[position];
|
||||
holder.original.setChecked(selections[0]);
|
||||
holder.translated.setChecked(selections[1]);
|
||||
holder.rewrite.setChecked(selections[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return ROW_COUNT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@ public class GalleryActivity extends TrackedActivity
|
||||
public static final String KEY_GALLERY_INFO = "gallery_info";
|
||||
public static final String KEY_PAGE = "page";
|
||||
public static final String KEY_SHOWING = "showing";
|
||||
public static final String KEY_CURRENT_INDEX = "current_index";
|
||||
|
||||
private static final long SLIDER_ANIMATION_DURING = 150;
|
||||
private static final long HIDE_SLIDER_DELAY = 3000;
|
||||
@@ -179,7 +180,8 @@ public class GalleryActivity extends TrackedActivity
|
||||
mAction = savedInstanceState.getString(KEY_ACTION);
|
||||
mFilename = savedInstanceState.getString(KEY_FILENAME);
|
||||
mGalleryInfo = savedInstanceState.getParcelable(KEY_GALLERY_INFO);
|
||||
mPage = savedInstanceState.getInt(KEY_ACTION, -1);
|
||||
mPage = savedInstanceState.getInt(KEY_PAGE, -1);
|
||||
mCurrentIndex = savedInstanceState.getInt(KEY_CURRENT_INDEX);
|
||||
buildProvider();
|
||||
}
|
||||
|
||||
@@ -193,6 +195,7 @@ public class GalleryActivity extends TrackedActivity
|
||||
}
|
||||
outState.putBoolean(KEY_SHOWING, mSystemUiShowing);
|
||||
outState.putInt(KEY_PAGE, mPage);
|
||||
outState.putInt(KEY_CURRENT_INDEX, mCurrentIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -335,10 +338,18 @@ public class GalleryActivity extends TrackedActivity
|
||||
// Check volume
|
||||
if (Settings.getVolumePage()) {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||
mGalleryView.pageLeft();
|
||||
if (mLayoutMode == GalleryView.LAYOUT_MODE_RIGHT_TO_LEFT) {
|
||||
mGalleryView.pageRight();
|
||||
} else {
|
||||
mGalleryView.pageLeft();
|
||||
}
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
mGalleryView.pageRight();
|
||||
if (mLayoutMode == GalleryView.LAYOUT_MODE_RIGHT_TO_LEFT) {
|
||||
mGalleryView.pageLeft();
|
||||
} else {
|
||||
mGalleryView.pageRight();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.hippo.ehviewer.ui;
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.support.annotation.IdRes;
|
||||
@@ -34,6 +35,7 @@ import android.view.Gravity;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.Crash;
|
||||
@@ -73,6 +75,8 @@ public final class MainActivity extends StageActivity
|
||||
|
||||
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
|
||||
|
||||
private static final int REQUEST_CODE_UPDATE_PROFILE = 0;
|
||||
|
||||
private static final String KEY_NAV_CHECKED_ITEM = "nav_checked_item";
|
||||
|
||||
public static final int CHECK_STEP_WARNING = 0;
|
||||
@@ -94,6 +98,8 @@ public final class MainActivity extends StageActivity
|
||||
private FrameLayout mRightDrawer;
|
||||
@Nullable
|
||||
private LoadImageView mAvatar;
|
||||
@Nullable
|
||||
private TextView mDisplayName;
|
||||
|
||||
private int mNavCheckedItem = 0;
|
||||
|
||||
@@ -257,8 +263,15 @@ public final class MainActivity extends StageActivity
|
||||
mRightDrawer = (FrameLayout) ViewUtils.$$(this, R.id.right_drawer);
|
||||
View headerLayout = mNavView.getHeaderView(0);
|
||||
mAvatar = (LoadImageView) ViewUtils.$$(headerLayout, R.id.avatar);
|
||||
mDisplayName = (TextView) ViewUtils.$$(headerLayout, R.id.display_name);
|
||||
|
||||
updateAvatar();
|
||||
// Pre-L need shadow drawable
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_left, Gravity.LEFT);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_right, Gravity.RIGHT);
|
||||
}
|
||||
|
||||
updateProfile();
|
||||
|
||||
if (mNavView != null) {
|
||||
mNavView.setNavigationItemSelectedListener(this);
|
||||
@@ -295,6 +308,8 @@ public final class MainActivity extends StageActivity
|
||||
mDrawerLayout = null;
|
||||
mNavView = null;
|
||||
mRightDrawer = null;
|
||||
mAvatar = null;
|
||||
mDisplayName = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -344,8 +359,8 @@ public final class MainActivity extends StageActivity
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAvatar() {
|
||||
if (null == mAvatar) {
|
||||
public void updateProfile() {
|
||||
if (null == mAvatar || null == mDisplayName) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -355,6 +370,12 @@ public final class MainActivity extends StageActivity
|
||||
} else {
|
||||
mAvatar.load(avatarUrl, avatarUrl);
|
||||
}
|
||||
|
||||
String displayName = Settings.getDisplayName();
|
||||
if (TextUtils.isEmpty(displayName)) {
|
||||
displayName = getString(R.string.default_display_name);
|
||||
}
|
||||
mDisplayName.setText(displayName);
|
||||
}
|
||||
|
||||
public int getDrawerLockMode(int edgeGravity) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.widget.ListAdapter;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.fragment.AboutFragment;
|
||||
import com.hippo.ehviewer.ui.fragment.AdvancedFragment;
|
||||
import com.hippo.ehviewer.ui.fragment.DownloadFragment;
|
||||
import com.hippo.ehviewer.ui.fragment.EhFragment;
|
||||
import com.hippo.ehviewer.ui.fragment.ReadFragment;
|
||||
@@ -50,6 +51,7 @@ public final class SettingsActivity extends TrackedPreferenceActivity {
|
||||
EhFragment.class.getName(),
|
||||
ReadFragment.class.getName(),
|
||||
DownloadFragment.class.getName(),
|
||||
AdvancedFragment.class.getName(),
|
||||
AboutFragment.class.getName(),
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
@@ -28,7 +27,6 @@ import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.UrlOpener;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.LicenseActivity;
|
||||
import com.hippo.util.ActivityHelper;
|
||||
|
||||
public class AboutFragment extends PreferenceFragment
|
||||
@@ -43,7 +41,6 @@ public class AboutFragment extends PreferenceFragment
|
||||
private static final String KEY_LICENSE = "license";
|
||||
private static final String KEY_DONATE = "donate";
|
||||
private static final String KEY_CHECK_FOR_UPDATES = "check_for_updates";
|
||||
private static final String KEY_BETA_UPDATE_CHANNEL = "beta_update_channel";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -56,20 +53,17 @@ public class AboutFragment extends PreferenceFragment
|
||||
Preference website = findPreference(KEY_WEBSITE);
|
||||
Preference source = findPreference(KEY_SOURCE);
|
||||
Preference changelog = findPreference(KEY_CHANGELOG);
|
||||
Preference license = findPreference(KEY_LICENSE);
|
||||
Preference donate = findPreference(KEY_DONATE);
|
||||
Preference checkForUpdate = findPreference(KEY_CHECK_FOR_UPDATES);
|
||||
Preference betaUpdateChannel = findPreference(KEY_BETA_UPDATE_CHANNEL);
|
||||
|
||||
author.setSummary(getString(R.string.settings_about_author_summary).replace('$', '@'));
|
||||
betaUpdateChannel.setDefaultValue(EhApplication.BETA);
|
||||
donate.setSummary(getString(R.string.settings_about_donate_summary).replace('$', '@'));
|
||||
|
||||
author.setOnPreferenceClickListener(this);
|
||||
googlePlus.setOnPreferenceClickListener(this);
|
||||
website.setOnPreferenceClickListener(this);
|
||||
source.setOnPreferenceClickListener(this);
|
||||
changelog.setOnPreferenceClickListener(this);
|
||||
license.setOnPreferenceClickListener(this);
|
||||
donate.setOnPreferenceClickListener(this);
|
||||
checkForUpdate.setOnPreferenceClickListener(this);
|
||||
|
||||
@@ -83,6 +77,7 @@ public class AboutFragment extends PreferenceFragment
|
||||
if (newValue instanceof Boolean && (Boolean) newValue) {
|
||||
Analytics.start(getActivity());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -105,9 +100,6 @@ public class AboutFragment extends PreferenceFragment
|
||||
} else if (KEY_CHANGELOG.equals(key)) {
|
||||
UrlOpener.openUrl(getActivity(), "http://www.ehviewer.com/changlog",
|
||||
false, true);
|
||||
} else if (KEY_LICENSE.equals(key)) {
|
||||
Intent intent = new Intent(getActivity(), LicenseActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (KEY_DONATE.equals(key)) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.settings_about_donate)
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.ui.fragment;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.util.LogCat;
|
||||
import com.hippo.util.ReadableTime;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AdvancedFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
|
||||
|
||||
private static final String KEY_DUMP_LOGCAT = "dump_logcat";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.advanced_settings);
|
||||
|
||||
Preference dumpLogcat = findPreference(KEY_DUMP_LOGCAT);
|
||||
|
||||
dumpLogcat.setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
if (KEY_DUMP_LOGCAT.equals(key)) {
|
||||
boolean ok;
|
||||
File file = null;
|
||||
File dir = AppConfig.getExternalLogcatDir();
|
||||
if (dir != null) {
|
||||
file = new File(dir, "logcat-" + ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".txt");
|
||||
ok = LogCat.save(file);
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
Resources resources = getResources();
|
||||
Toast.makeText(getActivity(),
|
||||
ok ? resources.getString(R.string.settings_about_dump_logcat_to, file.getPath()) :
|
||||
resources.getString(R.string.settings_about_dump_logcat_failed), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -17,15 +17,34 @@
|
||||
package com.hippo.ehviewer.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
|
||||
import com.hippo.ehviewer.Constants;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.yorozuya.Messenger;
|
||||
|
||||
public class EhFragment extends PreferenceFragment {
|
||||
public class EhFragment extends PreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.eh_settings);
|
||||
|
||||
Preference listMode = findPreference(Settings.KEY_LIST_MODE);
|
||||
|
||||
listMode.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
if (Settings.KEY_LIST_MODE.equals(key)) {
|
||||
Messenger.getInstance().notify(Constants.MESSAGE_ID_LIST_MODE, null);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public abstract class BaseScene extends SceneFragment {
|
||||
public void updateAvatar() {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof MainActivity) {
|
||||
((MainActivity) activity).updateAvatar();
|
||||
((MainActivity) activity).updateProfile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhCookieStore;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.util.ActivityHelper;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
@@ -196,8 +197,9 @@ public class CookieSignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
return;
|
||||
}
|
||||
|
||||
EhUtils.signOut(getContext());
|
||||
|
||||
EhCookieStore store = EhApplication.getEhCookieStore(context);
|
||||
store.removeAll();
|
||||
store.add(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_E));
|
||||
store.add(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_EX));
|
||||
store.add(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_E));
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
@@ -28,16 +28,14 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
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.Toolbar;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -49,6 +47,10 @@ import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.amlcurran.showcaseview.ShowcaseView;
|
||||
import com.github.amlcurran.showcaseview.SimpleShowcaseEventListener;
|
||||
import com.github.amlcurran.showcaseview.targets.PointTarget;
|
||||
import com.github.amlcurran.showcaseview.targets.ViewTarget;
|
||||
import com.hippo.app.CheckBoxDialogBuilder;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.FastScroller;
|
||||
@@ -66,12 +68,9 @@ import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.download.DownloadService;
|
||||
import com.hippo.ehviewer.spider.SpiderDen;
|
||||
import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.ehviewer.ui.annotation.ViewLifeCircle;
|
||||
import com.hippo.ehviewer.ui.annotation.WholeLifeCircle;
|
||||
import com.hippo.ehviewer.widget.SimpleRatingView;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
@@ -82,6 +81,7 @@ 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;
|
||||
@@ -99,27 +99,30 @@ public class DownloadsScene extends ToolbarScene
|
||||
|
||||
public static final String ACTION_CLEAR_DOWNLOAD_SERVICE = "clear_download_service";
|
||||
|
||||
/*---------------
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
private DownloadManager mDownloadManager;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private ViewTransition mViewTransition;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private FabLayout mFabLayout;
|
||||
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private DownloadAdapter mAdapter;
|
||||
|
||||
@Nullable
|
||||
@WholeLifeCircle
|
||||
private String mLabel;
|
||||
@Nullable
|
||||
@WholeLifeCircle
|
||||
private List<DownloadInfo> mList;
|
||||
|
||||
/*---------------
|
||||
View life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private ViewTransition mViewTransition;
|
||||
@Nullable
|
||||
private FabLayout mFabLayout;
|
||||
@Nullable
|
||||
private DownloadAdapter mAdapter;
|
||||
@Nullable
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
|
||||
@Override
|
||||
public int getNavCheckedItem() {
|
||||
return R.id.nav_downloads;
|
||||
@@ -142,8 +145,8 @@ public class DownloadsScene extends ToolbarScene
|
||||
|
||||
handleArguments(getArguments());
|
||||
|
||||
DownloadManager manager = EhApplication.getDownloadManager(getContext());
|
||||
manager.addDownloadInfoListener(this);
|
||||
mDownloadManager = EhApplication.getDownloadManager(getContext());
|
||||
mDownloadManager.addDownloadInfoListener(this);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
onInit();
|
||||
@@ -156,19 +159,28 @@ public class DownloadsScene extends ToolbarScene
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mList = null;
|
||||
DownloadManager manager = EhApplication.getDownloadManager(getContext());
|
||||
|
||||
DownloadManager manager = mDownloadManager;
|
||||
if (null == manager) {
|
||||
manager = EhApplication.getDownloadManager(getContext());
|
||||
} else {
|
||||
mDownloadManager = null;
|
||||
}
|
||||
manager.removeDownloadInfoListener(this);
|
||||
}
|
||||
|
||||
private void updateForLabel() {
|
||||
DownloadManager manager = EhApplication.getDownloadManager(getContext());
|
||||
if (null == mDownloadManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mLabel == null) {
|
||||
mList = manager.getDefaultDownloadInfoList();
|
||||
mList = mDownloadManager.getDefaultDownloadInfoList();
|
||||
} else {
|
||||
mList = manager.getLabelDownloadInfoList(mLabel);
|
||||
mList = mDownloadManager.getLabelDownloadInfoList(mLabel);
|
||||
if (mList == null) {
|
||||
mLabel = null;
|
||||
mList = manager.getDefaultDownloadInfoList();
|
||||
mList = mDownloadManager.getDefaultDownloadInfoList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +233,8 @@ public class DownloadsScene extends ToolbarScene
|
||||
mAdapter = new DownloadAdapter();
|
||||
mAdapter.setHasStableIds(true);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mLayoutManager = new LinearLayoutManager(getContext());
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
@@ -252,9 +265,85 @@ public class DownloadsScene extends ToolbarScene
|
||||
|
||||
updateView();
|
||||
|
||||
guide();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void guide() {
|
||||
if (Settings.getGuideDownloadThumb()) {
|
||||
SimpleHandler.getInstance().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
guideDownloadThumb();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
guideDownloadLabels();
|
||||
}
|
||||
}
|
||||
|
||||
private void guideDownloadThumb() {
|
||||
if (!Settings.getGuideDownloadThumb() || null == mLayoutManager || null == mRecyclerView) {
|
||||
guideDownloadLabels();
|
||||
return;
|
||||
}
|
||||
int position = mLayoutManager.findFirstCompletelyVisibleItemPosition();
|
||||
if (position < 0) {
|
||||
guideDownloadLabels();
|
||||
return;
|
||||
}
|
||||
RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(position);
|
||||
if (null == holder) {
|
||||
guideDownloadLabels();
|
||||
return;
|
||||
}
|
||||
|
||||
new ShowcaseView.Builder(getActivity())
|
||||
.withMaterialShowcase()
|
||||
.setStyle(R.style.Guide)
|
||||
.setTarget(new ViewTarget(((DownloadHolder) holder).thumb))
|
||||
.blockAllTouches()
|
||||
.setContentTitle(R.string.guide_download_thumb_title)
|
||||
.setContentText(R.string.guide_download_thumb_text)
|
||||
.replaceEndButton(R.layout.button_guide)
|
||||
.setShowcaseEventListener(new SimpleShowcaseEventListener() {
|
||||
@Override
|
||||
public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
|
||||
ViewUtils.removeFromParent(showcaseView);
|
||||
Settings.putGuideDownloadThumb(false);
|
||||
guideDownloadLabels();
|
||||
}
|
||||
}).build();
|
||||
}
|
||||
|
||||
private void guideDownloadLabels() {
|
||||
if (!Settings.getGuideDownloadLabels()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||
Point point = new Point();
|
||||
display.getSize(point);
|
||||
|
||||
new ShowcaseView.Builder(getActivity())
|
||||
.withMaterialShowcase()
|
||||
.setStyle(R.style.Guide)
|
||||
.setTarget(new PointTarget(point.x, point.y / 3))
|
||||
.blockAllTouches()
|
||||
.setContentTitle(R.string.guide_download_labels_title)
|
||||
.setContentText(R.string.guide_download_labels_text)
|
||||
.replaceEndButton(R.layout.button_guide)
|
||||
.setShowcaseEventListener(new SimpleShowcaseEventListener() {
|
||||
@Override
|
||||
public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
|
||||
ViewUtils.removeFromParent(showcaseView);
|
||||
Settings.puttGuideDownloadLabels(false);
|
||||
openDrawer(Gravity.RIGHT);
|
||||
}
|
||||
}).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
@@ -262,6 +351,17 @@ public class DownloadsScene extends ToolbarScene
|
||||
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
mRecyclerView = null;
|
||||
mFabLayout = null;
|
||||
mViewTransition = null;
|
||||
mAdapter = null;
|
||||
mLayoutManager = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationClick() {
|
||||
onBackPressed();
|
||||
@@ -288,28 +388,15 @@ public class DownloadsScene extends ToolbarScene
|
||||
return true;
|
||||
}
|
||||
case R.id.action_stop_all: {
|
||||
Intent intent = new Intent(getActivity(), DownloadService.class);
|
||||
intent.setAction(DownloadService.ACTION_STOP_ALL);
|
||||
getActivity().startService(intent);
|
||||
if (null != mDownloadManager) {
|
||||
mDownloadManager.stopAllDownload();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case R.id.action_label: {
|
||||
openDrawer(Gravity.RIGHT);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
mRecyclerView = null;
|
||||
mFabLayout = null;
|
||||
mViewTransition = null;
|
||||
mAdapter = null;
|
||||
}
|
||||
|
||||
public void updateView() {
|
||||
if (mViewTransition != null) {
|
||||
if (mList == null || mList.size() == 0) {
|
||||
@@ -337,7 +424,11 @@ public class DownloadsScene extends ToolbarScene
|
||||
startScene(new Announcer(DownloadLabelsScene.class));
|
||||
return true;
|
||||
case R.id.action_default_download_label:
|
||||
DownloadManager dm = EhApplication.getDownloadManager(getContext());
|
||||
DownloadManager dm = mDownloadManager;
|
||||
if (null == dm) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<DownloadLabel> list = dm.getLabelList();
|
||||
final String[] items = new String[list.size() + 2];
|
||||
items[0] = getString(R.string.let_me_select);
|
||||
@@ -524,10 +615,9 @@ public class DownloadsScene extends ToolbarScene
|
||||
break;
|
||||
}
|
||||
case 2: { // Stop
|
||||
Intent intent = new Intent(getActivity(), DownloadService.class);
|
||||
intent.setAction(DownloadService.ACTION_STOP_RANGE);
|
||||
intent.putExtra(DownloadService.KEY_GID_LIST, gidList);
|
||||
getActivity().startService(intent);
|
||||
if (null != mDownloadManager) {
|
||||
mDownloadManager.stopRangeDownload(gidList);
|
||||
}
|
||||
// Cancel check mode
|
||||
recyclerView.outOfCustomChoiceMode();
|
||||
break;
|
||||
@@ -668,22 +758,36 @@ public class DownloadsScene extends ToolbarScene
|
||||
holder.rating.setVisibility(View.VISIBLE);
|
||||
holder.category.setVisibility(View.VISIBLE);
|
||||
holder.state.setVisibility(View.VISIBLE);
|
||||
holder.progressBar.setVisibility(View.INVISIBLE);
|
||||
holder.percent.setVisibility(View.INVISIBLE);
|
||||
holder.speed.setVisibility(View.INVISIBLE);
|
||||
holder.progressBar.setVisibility(View.GONE);
|
||||
holder.percent.setVisibility(View.GONE);
|
||||
holder.speed.setVisibility(View.GONE);
|
||||
if (info.state == DownloadInfo.STATE_WAIT || info.state == DownloadInfo.STATE_DOWNLOAD) {
|
||||
holder.start.setVisibility(View.GONE);
|
||||
holder.stop.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.start.setVisibility(View.VISIBLE);
|
||||
holder.stop.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.state.setText(state);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void bindProgress(DownloadHolder holder, DownloadInfo info) {
|
||||
holder.uploader.setVisibility(View.INVISIBLE);
|
||||
holder.rating.setVisibility(View.INVISIBLE);
|
||||
holder.category.setVisibility(View.INVISIBLE);
|
||||
holder.state.setVisibility(View.INVISIBLE);
|
||||
holder.uploader.setVisibility(View.GONE);
|
||||
holder.rating.setVisibility(View.GONE);
|
||||
holder.category.setVisibility(View.GONE);
|
||||
holder.state.setVisibility(View.GONE);
|
||||
holder.progressBar.setVisibility(View.VISIBLE);
|
||||
holder.percent.setVisibility(View.VISIBLE);
|
||||
holder.speed.setVisibility(View.VISIBLE);
|
||||
if (info.state == DownloadInfo.STATE_WAIT || info.state == DownloadInfo.STATE_DOWNLOAD) {
|
||||
holder.start.setVisibility(View.GONE);
|
||||
holder.stop.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.start.setVisibility(View.VISIBLE);
|
||||
holder.stop.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (info.total <= 0 || info.finished < 0) {
|
||||
holder.percent.setText(null);
|
||||
@@ -730,10 +834,9 @@ public class DownloadsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
// Delete
|
||||
Intent intent = new Intent(getActivity(), DownloadService.class);
|
||||
intent.setAction(DownloadService.ACTION_DELETE);
|
||||
intent.putExtra(DownloadService.KEY_GID, mGalleryInfo.gid);
|
||||
getActivity().startService(intent);
|
||||
if (null != mDownloadManager) {
|
||||
mDownloadManager.deleteDownload(mGalleryInfo.gid);
|
||||
}
|
||||
|
||||
// Delete image files
|
||||
boolean checked = mBuilder.isChecked();
|
||||
@@ -773,10 +876,9 @@ public class DownloadsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
// Delete
|
||||
Intent intent = new Intent(getActivity(), DownloadService.class);
|
||||
intent.setAction(DownloadService.ACTION_DELETE_RANGE);
|
||||
intent.putExtra(DownloadService.KEY_GID_LIST, mGidList);
|
||||
getActivity().startService(intent);
|
||||
if (null != mDownloadManager) {
|
||||
mDownloadManager.deleteRangeDownload(mGidList);
|
||||
}
|
||||
|
||||
// Delete image files
|
||||
boolean checked = mBuilder.isChecked();
|
||||
@@ -887,8 +989,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, list.get(index));
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
DownloadHolder holder = (DownloadHolder) recyclerView.getChildViewHolder(itemView);
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(holder));
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
} else if (start == v) {
|
||||
@@ -897,14 +998,13 @@ public class DownloadsScene extends ToolbarScene
|
||||
intent.putExtra(DownloadService.KEY_GALLERY_INFO, list.get(index));
|
||||
getActivity().startService(intent);
|
||||
} else if (stop == v) {
|
||||
Intent intent = new Intent(getActivity(), DownloadService.class);
|
||||
intent.setAction(DownloadService.ACTION_STOP);
|
||||
intent.putExtra(DownloadService.KEY_GID, list.get(index).gid);
|
||||
getActivity().startService(intent);
|
||||
if (null != mDownloadManager) {
|
||||
mDownloadManager.stopDownload(list.get(index).gid);
|
||||
}
|
||||
} else if (delete == v) {
|
||||
GalleryInfo galleryInfo = list.get(index);
|
||||
CheckBoxDialogBuilder builder = new CheckBoxDialogBuilder(getContext(),
|
||||
getString(R.string.download_remove_dialog_message, galleryInfo.title),
|
||||
getString(R.string.download_remove_dialog_message, EhUtils.getSuitableTitle(galleryInfo)),
|
||||
getString(R.string.download_remove_dialog_check_text),
|
||||
Settings.getRemoveImageFiles());
|
||||
DeleteDialogHelper helper = new DeleteDialogHelper(galleryInfo, builder);
|
||||
@@ -915,38 +1015,6 @@ public class DownloadsScene extends ToolbarScene
|
||||
}
|
||||
}
|
||||
|
||||
private static class EnterGalleryDetailTransaction implements TransitionHelper {
|
||||
|
||||
private final DownloadHolder mHolder;
|
||||
|
||||
public EnterGalleryDetailTransaction(DownloadHolder holder) {
|
||||
mHolder = holder;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onTransition(Context context, FragmentTransaction transaction,
|
||||
Fragment exit, Fragment enter) {
|
||||
if (mHolder == null || !(enter instanceof GalleryDetailScene)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
transaction.addSharedElement(mHolder.thumb, mHolder.thumb.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.title, mHolder.title.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.uploader, mHolder.uploader.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.category, mHolder.category.getTransitionName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class DownloadAdapter extends RecyclerView.Adapter<DownloadHolder> {
|
||||
|
||||
@Override
|
||||
@@ -970,7 +1038,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
}
|
||||
DownloadInfo info = mList.get(position);
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(info.gid), info.thumb, true);
|
||||
holder.title.setText(info.title);
|
||||
holder.title.setText(EhUtils.getSuitableTitle(info));
|
||||
holder.uploader.setText(info.uploader);
|
||||
holder.rating.setRating(info.rating);
|
||||
TextView category = holder.category;
|
||||
@@ -985,9 +1053,6 @@ public class DownloadsScene extends ToolbarScene
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
long gid = info.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
holder.title.setTransitionName(TransitionNameFactory.getTitleTransitionName(gid));
|
||||
holder.uploader.setTransitionName(TransitionNameFactory.getUploaderTransitionName(gid));
|
||||
holder.category.setTransitionName(TransitionNameFactory.getCategoryTransitionName(gid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.ui.scene;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
class EnterGalleryDetailTransaction implements TransitionHelper {
|
||||
|
||||
private final View mThumb;
|
||||
|
||||
public EnterGalleryDetailTransaction(View thumb) {
|
||||
mThumb = thumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTransition(Context context, FragmentTransaction transaction,
|
||||
Fragment exit, Fragment enter) {
|
||||
if (mThumb == null || !(enter instanceof GalleryDetailScene)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
transaction.addSharedElement(mThumb, mThumb.getTransitionName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -16,28 +16,25 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -46,8 +43,10 @@ import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.amlcurran.showcaseview.ShowcaseView;
|
||||
import com.github.amlcurran.showcaseview.SimpleShowcaseEventListener;
|
||||
import com.github.amlcurran.showcaseview.targets.PointTarget;
|
||||
import com.hippo.annotation.Implemented;
|
||||
import com.hippo.drawable.DrawerArrowDrawable;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
@@ -56,11 +55,9 @@ import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.FavListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.exception.NotFoundException;
|
||||
@@ -69,24 +66,22 @@ import com.hippo.ehviewer.ui.annotation.DrawerLifeCircle;
|
||||
import com.hippo.ehviewer.ui.annotation.ViewLifeCircle;
|
||||
import com.hippo.ehviewer.ui.annotation.WholeLifeCircle;
|
||||
import com.hippo.ehviewer.widget.SearchBar;
|
||||
import com.hippo.ehviewer.widget.SimpleRatingView;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.StageActivity;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.widget.ContentLayout;
|
||||
import com.hippo.widget.FabLayout;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.widget.SearchBarMover;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.widget.refreshlayout.RefreshLayout;
|
||||
import com.hippo.yorozuya.ObjectUtils;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
// TODO Bug for FavoritesScene and GalleryListScene, if list view of SearchBar expand first, RecyclerView padding top will be wrong
|
||||
@@ -217,9 +212,16 @@ public class FavoritesScene extends BaseScene implements
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
boolean hasFirstRefresh;
|
||||
if (mHelper != null && 1 == mHelper.getShownViewIndex()) {
|
||||
hasFirstRefresh = false;
|
||||
} else {
|
||||
hasFirstRefresh = mHasFirstRefresh;
|
||||
}
|
||||
outState.putBoolean(KEY_HAS_FIRST_REFRESH, hasFirstRefresh);
|
||||
outState.putParcelable(KEY_URL_BUILDER, mUrlBuilder);
|
||||
outState.putBoolean(KEY_SEARCH_MODE, mSearchMode);
|
||||
outState.putBoolean(KEY_HAS_FIRST_REFRESH, mHasFirstRefresh);
|
||||
outState.putIntArray(KEY_FAV_COUNT_ARRAY, mFavCountArray);
|
||||
outState.putInt(KEY_ALL_COUNT, mAllCount);
|
||||
outState.putInt(KEY_ALL_LIMIT, mAllLimit);
|
||||
@@ -238,24 +240,23 @@ public class FavoritesScene extends BaseScene implements
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
Resources resources = getResources();
|
||||
|
||||
View view = inflater.inflate(R.layout.scene_favorites, container, false);
|
||||
ContentLayout contentLayout = (ContentLayout) view.findViewById(R.id.content_layout);
|
||||
mRecyclerView = contentLayout.getRecyclerView();
|
||||
AssertUtils.assertNotNull(mRecyclerView);
|
||||
mSearchBar = (SearchBar) view.findViewById(R.id.search_bar);
|
||||
AssertUtils.assertNotNull(mSearchBar);
|
||||
mFabLayout = (FabLayout) view.findViewById(R.id.fab_layout);
|
||||
AssertUtils.assertNotNull(mFabLayout);
|
||||
FastScroller fastScroller = contentLayout.getFastScroller();
|
||||
RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
|
||||
mSearchBar = (SearchBar) ViewUtils.$$(view, R.id.search_bar);
|
||||
mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
|
||||
|
||||
Resources resources = getResources();
|
||||
int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.list_padding_top_search_bar);
|
||||
|
||||
mHelper = new FavoritesHelper();
|
||||
contentLayout.setHelper(mHelper);
|
||||
contentLayout.getFastScroller().setOnDragHandlerListener(this);
|
||||
|
||||
mAdapter = new FavoritesAdapter();
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 1);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
@@ -264,9 +265,17 @@ public class FavoritesScene extends BaseScene implements
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
|
||||
mRecyclerView.setCustomCheckedListener(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);
|
||||
mAdapter = new FavoritesAdapter(LayoutInflater.from(getContext()),
|
||||
getContext(), mRecyclerView, layoutManager, Settings.getListMode());
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mAdapter.register();
|
||||
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop() + paddingTopSB,
|
||||
mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
|
||||
|
||||
fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
|
||||
fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());
|
||||
|
||||
refreshLayout.setHeaderTranslationY(paddingTopSB);
|
||||
|
||||
mLeftDrawable = new DrawerArrowDrawable(getContext());
|
||||
mSearchBar.setLeftDrawable(mLeftDrawable);
|
||||
@@ -293,9 +302,38 @@ public class FavoritesScene extends BaseScene implements
|
||||
mHelper.firstRefresh();
|
||||
}
|
||||
|
||||
guideCollections();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void guideCollections() {
|
||||
if (!Settings.getGuideCollections()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||
Point point = new Point();
|
||||
display.getSize(point);
|
||||
|
||||
new ShowcaseView.Builder(getActivity())
|
||||
.withMaterialShowcase()
|
||||
.setStyle(R.style.Guide)
|
||||
.setTarget(new PointTarget(point.x, point.y / 3))
|
||||
.blockAllTouches()
|
||||
.setContentTitle(R.string.guide_collections_title)
|
||||
.setContentText(R.string.guide_collections_text)
|
||||
.replaceEndButton(R.layout.button_guide)
|
||||
.setShowcaseEventListener(new SimpleShowcaseEventListener() {
|
||||
@Override
|
||||
public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
|
||||
ViewUtils.removeFromParent(showcaseView);
|
||||
Settings.putGuideCollections(false);
|
||||
openDrawer(Gravity.RIGHT);
|
||||
}
|
||||
}).build();
|
||||
}
|
||||
|
||||
// keyword of mUrlBuilder, fav cat of mUrlBuilder, mFavCatArray.
|
||||
// They changed, call it
|
||||
private void updateSearchBar() {
|
||||
@@ -348,12 +386,21 @@ public class FavoritesScene extends BaseScene implements
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
if (null != mAdapter) {
|
||||
mAdapter.unregister();
|
||||
mAdapter = null;
|
||||
}
|
||||
if (null != mHelper) {
|
||||
if (1 == mHelper.getShownViewIndex()) {
|
||||
mHasFirstRefresh = false;
|
||||
}
|
||||
mHelper = null;
|
||||
}
|
||||
|
||||
mRecyclerView = null;
|
||||
mSearchBar = null;
|
||||
mFabLayout = null;
|
||||
|
||||
mAdapter = null;
|
||||
mHelper = null;
|
||||
mSearchBarMover = null;
|
||||
mLeftDrawable = null;
|
||||
|
||||
@@ -419,9 +466,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
mDrawerList.add(getString(R.string.local_favorites));
|
||||
mDrawerList.add(getString(R.string.cloud_favorites));
|
||||
if (mFavCatArray != null) {
|
||||
for (String favCat: mFavCatArray) {
|
||||
mDrawerList.add(favCat);
|
||||
}
|
||||
Collections.addAll(mDrawerList, mFavCatArray);
|
||||
}
|
||||
mDrawerAdapter = new ArrayAdapter<>(getContext(), R.layout.item_simple_list, mDrawerList);
|
||||
listView.setAdapter(mDrawerAdapter);
|
||||
@@ -480,9 +525,9 @@ public class FavoritesScene extends BaseScene implements
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
FavoritesHolder holder = (FavoritesHolder) mRecyclerView.getChildViewHolder(view);
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(holder));
|
||||
View thumb;
|
||||
if (ApiHelper.SUPPORT_TRANSITION && null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
}
|
||||
@@ -774,7 +819,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
private void onGetFavoritesFailure(Exception e, int taskId) {
|
||||
if (mHelper != null && mSearchBarMover != null &&
|
||||
mHelper.isCurrentTask(taskId)) {
|
||||
mHelper.onGetExpection(taskId, e);
|
||||
mHelper.onGetException(taskId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -787,7 +832,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
list = EhDB.searchLocalFavorites(keyword);
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
mHelper.onGetExpection(taskId, new NotFoundException());
|
||||
mHelper.onGetException(taskId, new NotFoundException());
|
||||
} else {
|
||||
mHelper.setPages(taskId, 1);
|
||||
mHelper.onGetPageData(taskId, list);
|
||||
@@ -883,103 +928,22 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
}
|
||||
|
||||
private static class EnterGalleryDetailTransaction implements TransitionHelper {
|
||||
private class FavoritesAdapter extends GalleryAdapter {
|
||||
|
||||
private final FavoritesHolder mHolder;
|
||||
|
||||
public EnterGalleryDetailTransaction(FavoritesHolder holder) {
|
||||
mHolder = holder;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onTransition(Context context, FragmentTransaction transaction,
|
||||
Fragment exit, Fragment enter) {
|
||||
if (mHolder == null || !(enter instanceof GalleryDetailScene)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
transaction.addSharedElement(mHolder.thumb, mHolder.thumb.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.title, mHolder.title.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.uploader, mHolder.uploader.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.category, mHolder.category.getTransitionName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class FavoritesHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final LoadImageView thumb;
|
||||
private final TextView title;
|
||||
private final TextView uploader;
|
||||
private final SimpleRatingView rating;
|
||||
private final TextView category;
|
||||
private final TextView posted;
|
||||
private final TextView simpleLanguage;
|
||||
|
||||
public FavoritesHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
thumb = (LoadImageView) itemView.findViewById(R.id.thumb);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
uploader = (TextView) itemView.findViewById(R.id.uploader);
|
||||
rating = (SimpleRatingView) itemView.findViewById(R.id.rating);
|
||||
category = (TextView) itemView.findViewById(R.id.category);
|
||||
posted = (TextView) itemView.findViewById(R.id.posted);
|
||||
simpleLanguage = (TextView) itemView.findViewById(R.id.simple_language);
|
||||
}
|
||||
}
|
||||
|
||||
private class FavoritesAdapter extends RecyclerView.Adapter<FavoritesHolder> {
|
||||
|
||||
@Override
|
||||
public FavoritesHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new FavoritesHolder(getActivity().getLayoutInflater()
|
||||
.inflate(R.layout.item_gallery_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void onBindViewHolder(FavoritesHolder holder, int position) {
|
||||
if (mHelper == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GalleryInfo gi = mHelper.getDataAt(position);
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb, true);
|
||||
holder.title.setText(EhUtils.getSuitableTitle(gi));
|
||||
holder.uploader.setText(gi.uploader);
|
||||
holder.rating.setRating(gi.rating);
|
||||
TextView category = holder.category;
|
||||
String newCategoryText = EhUtils.getCategory(gi.category);
|
||||
if (!newCategoryText.equals(category.getText())) {
|
||||
category.setText(newCategoryText);
|
||||
category.setBackgroundColor(EhUtils.getCategoryColor(gi.category));
|
||||
}
|
||||
holder.posted.setText(gi.posted);
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
|
||||
// Update transition name
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
holder.title.setTransitionName(TransitionNameFactory.getTitleTransitionName(gid));
|
||||
holder.uploader.setTransitionName(TransitionNameFactory.getUploaderTransitionName(gid));
|
||||
holder.category.setTransitionName(TransitionNameFactory.getCategoryTransitionName(gid));
|
||||
}
|
||||
public FavoritesAdapter(LayoutInflater inflater, Context context,
|
||||
RecyclerView recyclerView, GridLayoutManager layoutManager, int type) {
|
||||
super(inflater, context, recyclerView, layoutManager, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mHelper != null ? mHelper.size() : 0;
|
||||
return null != mHelper ? mHelper.size() : 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GalleryInfo getDataAt(int position) {
|
||||
return null != mHelper ? mHelper.getDataAt(position) : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* 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.ui.scene;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.drawable.TriangleDrawable;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.Constants;
|
||||
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.util.ApiHelper;
|
||||
import com.hippo.util.LayoutUtils2;
|
||||
import com.hippo.yorozuya.Messenger;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> implements Messenger.Receiver {
|
||||
|
||||
@IntDef({TYPE_LIST, TYPE_GRID})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface Type {}
|
||||
|
||||
public static final int TYPE_INVALID = -1;
|
||||
public static final int TYPE_LIST = 0;
|
||||
public static final int TYPE_GRID = 1;
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
private final Context mContext;
|
||||
private final Resources mResources;
|
||||
private final RecyclerView mRecyclerView;
|
||||
private final GridLayoutManager mLayoutManager;
|
||||
private RecyclerView.ItemDecoration mGirdDecoration;
|
||||
private int mType = TYPE_INVALID;
|
||||
|
||||
public GalleryAdapter(LayoutInflater inflater, Context context,
|
||||
RecyclerView recyclerView, GridLayoutManager layoutManager, int type) {
|
||||
mInflater = inflater;
|
||||
mContext = context;
|
||||
mResources = context.getResources();
|
||||
mRecyclerView = recyclerView;
|
||||
mLayoutManager = layoutManager;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
if (type == mType) {
|
||||
return;
|
||||
}
|
||||
mType = type;
|
||||
|
||||
switch (type) {
|
||||
default:
|
||||
case GalleryAdapter.TYPE_LIST: {
|
||||
int minWidth = mResources.getDimensionPixelOffset(R.dimen.gallery_list_min_width);
|
||||
int spanCount = LayoutUtils2.calculateSpanCount(mContext, minWidth);
|
||||
mLayoutManager.setSpanCount(spanCount);
|
||||
if (null != mGirdDecoration) {
|
||||
mRecyclerView.removeItemDecoration(mGirdDecoration);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case GalleryAdapter.TYPE_GRID: {
|
||||
int minWidth = mResources.getDimensionPixelOffset(R.dimen.gallery_grid_min_width);
|
||||
int spanCount = LayoutUtils2.calculateSpanCount(mContext, minWidth);
|
||||
mLayoutManager.setSpanCount(spanCount);
|
||||
if (null == mGirdDecoration) {
|
||||
mGirdDecoration = new MarginItemDecoration(
|
||||
mResources.getDimensionPixelOffset(R.dimen.list_content_interval));
|
||||
}
|
||||
mRecyclerView.addItemDecoration(mGirdDecoration);
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GalleryHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
int layoutId;
|
||||
switch (viewType) {
|
||||
default:
|
||||
case TYPE_LIST:
|
||||
layoutId = R.layout.item_gallery_list;
|
||||
break;
|
||||
case TYPE_GRID:
|
||||
layoutId = R.layout.item_gallery_grid;
|
||||
break;
|
||||
}
|
||||
return new GalleryHolder(mInflater.inflate(layoutId, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return mType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract GalleryInfo getDataAt(int position);
|
||||
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void onBindViewHolder(GalleryHolder holder, int position) {
|
||||
GalleryInfo gi = getDataAt(position);
|
||||
if (null == gi) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mType) {
|
||||
default:
|
||||
case TYPE_LIST: {
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb);
|
||||
holder.title.setText(EhUtils.getSuitableTitle(gi));
|
||||
holder.uploader.setText(gi.uploader);
|
||||
holder.rating.setRating(gi.rating);
|
||||
TextView category = holder.category;
|
||||
String newCategoryText = EhUtils.getCategory(gi.category);
|
||||
if (!newCategoryText.equals(category.getText())) {
|
||||
category.setText(newCategoryText);
|
||||
category.setBackgroundColor(EhUtils.getCategoryColor(gi.category));
|
||||
}
|
||||
holder.posted.setText(gi.posted);
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
break;
|
||||
}
|
||||
case TYPE_GRID: {
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb);
|
||||
View category = holder.category;
|
||||
Drawable drawable = category.getBackground();
|
||||
int color = EhUtils.getCategoryColor(gi.category);
|
||||
if (!(drawable instanceof TriangleDrawable)) {
|
||||
drawable = new TriangleDrawable(color);
|
||||
category.setBackground(drawable);
|
||||
} else {
|
||||
((TriangleDrawable) drawable).setColor(color);
|
||||
}
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Update transition name
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
}
|
||||
}
|
||||
|
||||
public void register() {
|
||||
Messenger.getInstance().register(Constants.MESSAGE_ID_LIST_MODE, this);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
Messenger.getInstance().unregister(Constants.MESSAGE_ID_LIST_MODE, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(int id, Object obj) {
|
||||
setType(Settings.getListMode());
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package com.hippo.ehviewer.ui.scene;
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
@@ -53,6 +54,7 @@ import com.hippo.scene.StageActivity;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.text.URLImageGetter;
|
||||
import com.hippo.util.ActivityHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.util.TextUrl;
|
||||
import com.hippo.view.ViewTransition;
|
||||
@@ -60,6 +62,7 @@ import com.hippo.widget.LinkifyTextView;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public final class GalleryCommentsScene extends ToolbarScene
|
||||
implements EasyRecyclerView.OnItemClickListener,
|
||||
@@ -134,11 +137,17 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.scene_gallery_comments, container, false);
|
||||
EasyRecyclerView recyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view);
|
||||
View tip = view.findViewById(R.id.tip);
|
||||
mEditPanel = view.findViewById(R.id.edit_panel);
|
||||
mSendImage = (ImageView) mEditPanel.findViewById(R.id.send);
|
||||
mEditText = (EditText) mEditPanel.findViewById(R.id.edit_text);
|
||||
mFab = (FloatingActionButton) view.findViewById(R.id.fab);
|
||||
TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
|
||||
mEditPanel = ViewUtils.$$(view, R.id.edit_panel);
|
||||
mSendImage = (ImageView) ViewUtils.$$(mEditPanel, R.id.send);
|
||||
mEditText = (EditText) ViewUtils.$$(mEditPanel, R.id.edit_text);
|
||||
mFab = (FloatingActionButton) ViewUtils.$$(view, R.id.fab);
|
||||
|
||||
int paddingBottomFab = getResources().getDimensionPixelOffset(R.dimen.list_padding_bottom_fab);
|
||||
|
||||
Drawable drawable = DrawableManager.getDrawable(getContext(), R.drawable.big_weird_face);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
tip.setCompoundDrawables(null, drawable, null, null);
|
||||
|
||||
mAdapter = new CommentAdapter();
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
@@ -153,6 +162,8 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setOnItemClickListener(this);
|
||||
recyclerView.setOnItemLongClickListener(this);
|
||||
recyclerView.setPadding(recyclerView.getPaddingLeft(), recyclerView.getPaddingTop(),
|
||||
recyclerView.getPaddingRight(), recyclerView.getPaddingBottom() + paddingBottomFab);
|
||||
|
||||
mSendImage.setOnClickListener(this);
|
||||
mFab.setOnClickListener(this);
|
||||
@@ -184,7 +195,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
@Override
|
||||
public void onNavigationClick() {
|
||||
finish();
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,7 +74,6 @@ import com.hippo.ehviewer.client.parser.RateGalleryParser;
|
||||
import com.hippo.ehviewer.dao.DownloadInfo;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.ehviewer.ui.annotation.ViewLifeCircle;
|
||||
import com.hippo.ehviewer.ui.annotation.WholeLifeCircle;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.scene.Announcer;
|
||||
@@ -87,6 +86,7 @@ import com.hippo.util.ActivityHelper;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.LayoutUtils2;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.AutoWrapLayout;
|
||||
@@ -103,7 +103,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class GalleryDetailScene extends BaseScene implements View.OnClickListener,
|
||||
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener {
|
||||
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener,
|
||||
View.OnLongClickListener{
|
||||
|
||||
@IntDef({STATE_INIT, STATE_NORMAL, STATE_REFRESH, STATE_REFRESH_HEADER, STATE_FAILED})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@@ -128,131 +129,93 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
private static final String KEY_GALLERY_DETAIL = "gallery_detail";
|
||||
private static final String KEY_REQUEST_ID = "request_id";
|
||||
private static final String KEY_DOWNLOAD_STATE = "download_state";
|
||||
|
||||
/*---------------
|
||||
View life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private ViewGroup mFailedView;
|
||||
private TextView mTip;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mFailedText;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
// Header
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private View mHeader;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private View mColorBg;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private LoadImageView mThumb;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mTitle;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mUploader;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mCategory;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private ImageView mOtherActions;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private ViewGroup mActionGroup;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mDownload;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private View mRead;
|
||||
// Below header
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private View mBelowHeader;
|
||||
// Info
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private View mInfo;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mLanguage;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mPages;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mSize;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mPosted;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mFavoredTimes;
|
||||
// Actions
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private View mActions;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mRatingText;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private RatingBar mRating;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private View mHeartGroup;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mHeart;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mHeartOutline;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mTorrent;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mShare;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mRate;
|
||||
// Tags
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private LinearLayout mTags;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mNoTags;
|
||||
// Comments
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private LinearLayout mComments;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mCommentsText;
|
||||
// Previews
|
||||
@Nullable
|
||||
private View mPreviews;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private SimpleGridLayout mGridLayout;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private TextView mPreviewText;
|
||||
// Progress
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private View mProgress;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private ViewTransition mViewTransition2;
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private PopupMenu mPopupMenu;
|
||||
|
||||
@WholeLifeCircle
|
||||
@@ -379,10 +342,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
} else {
|
||||
onRestore(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
private void onInit() {
|
||||
handleArgs(getArguments());
|
||||
long gid = getGid();
|
||||
if (gid != -1) {
|
||||
mDownloadState = EhApplication.getDownloadManager(getContext()).getDownloadState(gid);
|
||||
@@ -391,6 +351,10 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
private void onInit() {
|
||||
handleArgs(getArguments());
|
||||
}
|
||||
|
||||
private void onRestore(Bundle savedInstanceState) {
|
||||
mAction = savedInstanceState.getString(KEY_ACTION);
|
||||
mGalleryInfo = savedInstanceState.getParcelable(KEY_GALLERY_INFO);
|
||||
@@ -398,7 +362,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mToken = savedInstanceState.getString(KEY_TOKEN);
|
||||
mGalleryDetail = savedInstanceState.getParcelable(KEY_GALLERY_DETAIL);
|
||||
mRequestId = savedInstanceState.getInt(KEY_REQUEST_ID);
|
||||
mDownloadState = savedInstanceState.getInt(KEY_DOWNLOAD_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -419,7 +382,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
outState.putParcelable(KEY_GALLERY_DETAIL, mGalleryDetail);
|
||||
}
|
||||
outState.putInt(KEY_REQUEST_ID, mRequestId);
|
||||
outState.putInt(KEY_DOWNLOAD_STATE, mDownloadState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -431,10 +393,13 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
ViewGroup main = (ViewGroup) ViewUtils.$$(view, R.id.main);
|
||||
View mainView = ViewUtils.$$(main, R.id.scroll_view);
|
||||
View progressView = ViewUtils.$$(main, R.id.progress_view);
|
||||
mFailedView = (ViewGroup) ViewUtils.$$(main, R.id.tip);
|
||||
mFailedText = (TextView) ViewUtils.$$(mFailedView, R.id.tip_text);
|
||||
mFailedView.setOnClickListener(this);
|
||||
mViewTransition = new ViewTransition(mainView, progressView, mFailedView);
|
||||
mTip = (TextView) ViewUtils.$$(main, R.id.tip);
|
||||
mViewTransition = new ViewTransition(mainView, progressView, mTip);
|
||||
|
||||
Drawable drawable = DrawableManager.getDrawable(getContext(), R.drawable.big_weird_face);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
mTip.setCompoundDrawables(null, drawable, null, null);
|
||||
mTip.setOnClickListener(this);
|
||||
|
||||
mHeader = ViewUtils.$$(mainView, R.id.header);
|
||||
mColorBg = ViewUtils.$$(mHeader, R.id.color_bg);
|
||||
@@ -453,6 +418,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mCategory.setOnClickListener(this);
|
||||
mOtherActions.setOnClickListener(this);
|
||||
mDownload.setOnClickListener(this);
|
||||
mDownload.setOnLongClickListener(this);
|
||||
mRead.setOnClickListener(this);
|
||||
|
||||
mBelowHeader = mainView.findViewById(R.id.below_header);
|
||||
@@ -517,7 +483,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
adjustViewVisibility(STATE_REFRESH, false);
|
||||
}
|
||||
} else {
|
||||
mFailedText.setText(R.string.error_cannot_find_gallery);
|
||||
mTip.setText(R.string.error_cannot_find_gallery);
|
||||
adjustViewVisibility(STATE_FAILED, false);
|
||||
}
|
||||
|
||||
@@ -537,8 +503,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
EhApplication.getDownloadManager(getContext()).removeDownloadInfoListener(this);
|
||||
|
||||
mFailedView = null;
|
||||
mFailedText = null;
|
||||
mTip = null;
|
||||
mViewTransition = null;
|
||||
|
||||
mHeader = null;
|
||||
@@ -827,7 +792,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
String tagStr = tg.getTagAt(j);
|
||||
tag.setText(tagStr);
|
||||
tag.setBackgroundDrawable(new RoundSideRectDrawable(colorTag));
|
||||
tag.setTag(R.id.tag, tagStr);
|
||||
tag.setTag(R.id.tag, tg.groupName + ":" + tagStr);
|
||||
tag.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
@@ -883,6 +848,10 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mPreviewText.setText(R.string.more_previews);
|
||||
}
|
||||
|
||||
int minWidth = getResources().getDimensionPixelOffset(R.dimen.preview_grid_min_width);
|
||||
int spanCount = LayoutUtils2.calculateSpanCount(getContext(), minWidth);
|
||||
mGridLayout.setColumnCount(spanCount);
|
||||
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
for (int i = 0, size = previewSet.size(); i < size; i++) {
|
||||
View view = inflater.inflate(R.layout.item_gallery_preview, mGridLayout, false);
|
||||
@@ -988,7 +957,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mFailedView == v) {
|
||||
if (mTip == v) {
|
||||
if (request()) {
|
||||
adjustViewVisibility(STATE_REFRESH, true);
|
||||
}
|
||||
@@ -1015,15 +984,9 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
lub.setCategory(category);
|
||||
GalleryListScene.startScene(this, lub);
|
||||
} else if (mDownload == v) {
|
||||
// Add download
|
||||
GalleryInfo galleryInfo = null;
|
||||
if (mGalleryInfo != null) {
|
||||
galleryInfo = mGalleryInfo;
|
||||
} else if (mGalleryDetail != null) {
|
||||
galleryInfo = mGalleryDetail;
|
||||
}
|
||||
GalleryInfo galleryInfo = getGalleryInfo();
|
||||
if (galleryInfo != null) {
|
||||
CommonOperations.startDownload(getActivity(), galleryInfo);
|
||||
CommonOperations.startDownload(getActivity(), galleryInfo, false);
|
||||
}
|
||||
} else if (mRead == v) {
|
||||
GalleryInfo galleryInfo = null;
|
||||
@@ -1134,6 +1097,18 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (mDownload == v) {
|
||||
GalleryInfo galleryInfo = getGalleryInfo();
|
||||
if (galleryInfo != null) {
|
||||
CommonOperations.startDownload(getActivity(), galleryInfo, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (ApiHelper.SUPPORT_TRANSITION && mViewTransition != null && mThumb != null &&
|
||||
@@ -1143,11 +1118,10 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
// Only show transaction when thumb can be seen
|
||||
if (location[1] + mThumb.getHeight() > 0) {
|
||||
setTransitionName();
|
||||
finish(new ExitTransaction(mThumb, mTitle, mUploader, mCategory));
|
||||
finish(new ExitTransaction(mThumb));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -1251,15 +1225,9 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private static class ExitTransaction implements TransitionHelper {
|
||||
|
||||
private final View mThumb;
|
||||
private final View mTitle;
|
||||
private final View mUploader;
|
||||
private final View mCategory;
|
||||
|
||||
public ExitTransaction(View thumb, View title, View uploader, View category) {
|
||||
public ExitTransaction(View thumb) {
|
||||
mThumb = thumb;
|
||||
mTitle = title;
|
||||
mUploader = uploader;
|
||||
mCategory = category;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1280,9 +1248,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
transaction.addSharedElement(mThumb, mThumb.getTransitionName());
|
||||
transaction.addSharedElement(mTitle, mTitle.getTransitionName());
|
||||
transaction.addSharedElement(mUploader, mUploader.getTransitionName());
|
||||
transaction.addSharedElement(mCategory, mCategory.getTransitionName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1290,6 +1255,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private void onGetGalleryDetailSuccess(GalleryDetail result) {
|
||||
mGalleryDetail = result;
|
||||
if (isViewCreated()) {
|
||||
updateDownloadState();
|
||||
adjustViewVisibility(STATE_NORMAL, true);
|
||||
bindViewSecond();
|
||||
}
|
||||
@@ -1299,8 +1265,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
e.printStackTrace();
|
||||
if (isViewCreated()) {
|
||||
String error = ExceptionUtils.getReadableString(getContext(), e);
|
||||
if (mFailedText != null) {
|
||||
mFailedText.setText(error);
|
||||
if (mTip != null) {
|
||||
mTip.setText(error);
|
||||
adjustViewVisibility(STATE_FAILED, true);
|
||||
}
|
||||
}
|
||||
@@ -1372,7 +1338,9 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private final TextView mErrorText;
|
||||
private final ListView mListView;
|
||||
|
||||
@Nullable
|
||||
private EhRequest mRequest;
|
||||
@Nullable
|
||||
private Dialog mDialog;
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@@ -1395,11 +1363,15 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
public void setDialog(Dialog dialog) {
|
||||
public void setDialog(@Nullable Dialog dialog) {
|
||||
mDialog = dialog;
|
||||
}
|
||||
|
||||
private void bind(Pair<String, String>[] data) {
|
||||
if (null == mDialog) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == data.length) {
|
||||
mProgressView.setVisibility(View.GONE);
|
||||
mErrorText.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.ui.scene;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.widget.SimpleRatingView;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
|
||||
class GalleryHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public final LoadImageView thumb;
|
||||
public final TextView title;
|
||||
public final TextView uploader;
|
||||
public final SimpleRatingView rating;
|
||||
public final TextView category;
|
||||
public final TextView posted;
|
||||
public final TextView simpleLanguage;
|
||||
|
||||
public GalleryHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
thumb = (LoadImageView) itemView.findViewById(R.id.thumb);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
uploader = (TextView) itemView.findViewById(R.id.uploader);
|
||||
rating = (SimpleRatingView) itemView.findViewById(R.id.rating);
|
||||
category = (TextView) itemView.findViewById(R.id.category);
|
||||
posted = (TextView) itemView.findViewById(R.id.posted);
|
||||
simpleLanguage = (TextView) itemView.findViewById(R.id.simple_language);
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -47,6 +48,9 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
public static final String KEY_KEYS = "keys";
|
||||
public static final String KEY_VALUES = "values";
|
||||
|
||||
/*---------------
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private ArrayList<String> mKeys;
|
||||
@Nullable
|
||||
@@ -147,7 +151,7 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.scene_gallery_info, container, false);
|
||||
|
||||
EasyRecyclerView recyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view);
|
||||
EasyRecyclerView recyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
|
||||
InfoAdapter adapter = new InfoAdapter();
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
@@ -184,7 +188,7 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
|
||||
@Override
|
||||
public void onNavigationClick() {
|
||||
finish();
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
private static class InfoHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@@ -17,29 +17,26 @@
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -50,6 +47,9 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.amlcurran.showcaseview.ShowcaseView;
|
||||
import com.github.amlcurran.showcaseview.SimpleShowcaseEventListener;
|
||||
import com.github.amlcurran.showcaseview.targets.PointTarget;
|
||||
import com.hippo.app.EditTextDialogBuilder;
|
||||
import com.hippo.drawable.AddDeleteDrawable;
|
||||
import com.hippo.drawable.DrawerArrowDrawable;
|
||||
@@ -59,7 +59,6 @@ import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
@@ -68,21 +67,18 @@ import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.parser.GalleryListParser;
|
||||
import com.hippo.ehviewer.dao.QuickSearch;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.widget.FitPaddingLayout;
|
||||
import com.hippo.ehviewer.widget.SearchBar;
|
||||
import com.hippo.ehviewer.widget.SearchLayout;
|
||||
import com.hippo.ehviewer.widget.SimpleRatingView;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.StageActivity;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.ContentLayout;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.widget.SearchBarMover;
|
||||
import com.hippo.widget.refreshlayout.RefreshLayout;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener;
|
||||
@@ -132,8 +128,6 @@ public final class GalleryListScene extends BaseScene
|
||||
View life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private FitPaddingLayout mFitPaddingLayout;
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private SearchLayout mSearchLayout;
|
||||
@@ -239,7 +233,14 @@ public final class GalleryListScene extends BaseScene
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(KEY_HAS_FIRST_REFRESH, mHasFirstRefresh);
|
||||
|
||||
boolean hasFirstRefresh;
|
||||
if (mHelper != null && 1 == mHelper.getShownViewIndex()) {
|
||||
hasFirstRefresh = false;
|
||||
} else {
|
||||
hasFirstRefresh = mHasFirstRefresh;
|
||||
}
|
||||
outState.putBoolean(KEY_HAS_FIRST_REFRESH, hasFirstRefresh);
|
||||
outState.putParcelable(KEY_LIST_URL_BUILDER, mUrlBuilder);
|
||||
outState.putInt(KEY_STATE, mState);
|
||||
}
|
||||
@@ -297,14 +298,21 @@ public final class GalleryListScene extends BaseScene
|
||||
String keyword = builder.getKeyword();
|
||||
int category = builder.getCategory();
|
||||
|
||||
// Update search edit text
|
||||
if (!TextUtils.isEmpty(keyword) && null != mSearchBar) {
|
||||
mSearchBar.setText(keyword);
|
||||
}
|
||||
|
||||
// Update title
|
||||
String title = getSuitableTitleForUrlBuilder(getResources(), builder, true);
|
||||
if (null == title) {
|
||||
title = resources.getString(R.string.search);
|
||||
}
|
||||
if (mSearchBar != null) {
|
||||
if (null != mSearchBar) {
|
||||
mSearchBar.setTitle(title);
|
||||
}
|
||||
|
||||
// Update nav checked item
|
||||
int checkedItemId;
|
||||
if (ListUrlBuilder.MODE_NORMAL == builder.getMode() &&
|
||||
EhUtils.NONE == category &&
|
||||
@@ -327,12 +335,17 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
Resources resources = getContext().getResources();
|
||||
|
||||
mFitPaddingLayout = (FitPaddingLayout) ViewUtils.$$(view, R.id.main_layout);
|
||||
ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mFitPaddingLayout, R.id.content_layout);
|
||||
View mainLayout = ViewUtils.$$(view, R.id.main_layout);
|
||||
ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mainLayout, R.id.content_layout);
|
||||
mRecyclerView = contentLayout.getRecyclerView();
|
||||
mSearchLayout = (SearchLayout) ViewUtils.$$(mFitPaddingLayout, R.id.search_layout);
|
||||
mSearchBar = (SearchBar) ViewUtils.$$(mFitPaddingLayout, R.id.search_bar);
|
||||
mFab = (FloatingActionButton) ViewUtils.$$(mFitPaddingLayout, R.id.fab);
|
||||
FastScroller fastScroller = contentLayout.getFastScroller();
|
||||
RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
|
||||
mSearchLayout = (SearchLayout) ViewUtils.$$(mainLayout, R.id.search_layout);
|
||||
mSearchBar = (SearchBar) ViewUtils.$$(mainLayout, R.id.search_bar);
|
||||
mFab = (FloatingActionButton) ViewUtils.$$(mainLayout, R.id.fab);
|
||||
|
||||
int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.list_padding_top_search_bar);
|
||||
int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.list_padding_bottom_fab);
|
||||
|
||||
mViewTransition = new ViewTransition(contentLayout, mSearchLayout);
|
||||
|
||||
@@ -341,18 +354,25 @@ public final class GalleryListScene extends BaseScene
|
||||
contentLayout.setHelper(mHelper);
|
||||
contentLayout.getFastScroller().setOnDragHandlerListener(this);
|
||||
|
||||
mAdapter = new GalleryListAdapter();
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 1);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
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);
|
||||
mAdapter = new GalleryListAdapter(LayoutInflater.from(getContext()),
|
||||
getContext(), mRecyclerView, layoutManager, Settings.getListMode());
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mAdapter.register();
|
||||
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop() + paddingTopSB,
|
||||
mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
|
||||
|
||||
fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
|
||||
fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());
|
||||
|
||||
refreshLayout.setHeaderTranslationY(paddingTopSB);
|
||||
|
||||
mLeftDrawable = new DrawerArrowDrawable(getContext());
|
||||
mRightDrawable = new AddDeleteDrawable(getContext());
|
||||
@@ -363,6 +383,8 @@ public final class GalleryListScene extends BaseScene
|
||||
setSearchBarHint(getContext(), mSearchBar);
|
||||
|
||||
mSearchLayout.setHelper(this);
|
||||
mSearchLayout.setPadding(mSearchLayout.getPaddingLeft(), mSearchLayout.getPaddingTop() + paddingTopSB,
|
||||
mSearchLayout.getPaddingRight(), mSearchLayout.getPaddingBottom() + paddingBottomFab);
|
||||
|
||||
mFab.setOnClickListener(this);
|
||||
|
||||
@@ -382,29 +404,64 @@ public final class GalleryListScene extends BaseScene
|
||||
mHelper.firstRefresh();
|
||||
}
|
||||
|
||||
guideQuickSearch();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void guideQuickSearch() {
|
||||
if (!Settings.getGuideQuickSearch()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||
Point point = new Point();
|
||||
display.getSize(point);
|
||||
|
||||
new ShowcaseView.Builder(getActivity())
|
||||
.withMaterialShowcase()
|
||||
.setStyle(R.style.Guide)
|
||||
.setTarget(new PointTarget(point.x, point.y / 3))
|
||||
.blockAllTouches()
|
||||
.setContentTitle(R.string.guide_quick_search_title)
|
||||
.setContentText(R.string.guide_quick_search_text)
|
||||
.replaceEndButton(R.layout.button_guide)
|
||||
.setShowcaseEventListener(new SimpleShowcaseEventListener() {
|
||||
@Override
|
||||
public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
|
||||
ViewUtils.removeFromParent(showcaseView);
|
||||
Settings.putGuideQuickSearch(false);
|
||||
openDrawer(Gravity.RIGHT);
|
||||
}
|
||||
}).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
// End animation
|
||||
if (mSearchBarMover != null) {
|
||||
if (null != mSearchBarMover) {
|
||||
mSearchBarMover.cancelAnimation();
|
||||
mSearchBarMover = null;
|
||||
}
|
||||
if (null != mAdapter) {
|
||||
mAdapter.unregister();
|
||||
mAdapter = null;
|
||||
}
|
||||
if (null != mHelper) {
|
||||
if (1 == mHelper.getShownViewIndex()) {
|
||||
mHasFirstRefresh = false;
|
||||
}
|
||||
mHelper = null;
|
||||
}
|
||||
|
||||
mFitPaddingLayout = null;
|
||||
mRecyclerView = null;
|
||||
mSearchLayout = null;
|
||||
mSearchBar = null;
|
||||
mFab = null;
|
||||
mViewTransition = null;
|
||||
mAdapter = null;
|
||||
mHelper = null;
|
||||
mLeftDrawable = null;
|
||||
mRightDrawable = null;
|
||||
mSearchBarMover = null;
|
||||
mFabAnimatorListener = null;
|
||||
}
|
||||
|
||||
@@ -555,38 +612,6 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
}
|
||||
|
||||
private static class EnterGalleryDetailTransaction implements TransitionHelper {
|
||||
|
||||
private final GalleryListHolder mHolder;
|
||||
|
||||
public EnterGalleryDetailTransaction(GalleryListHolder holder) {
|
||||
mHolder = holder;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onTransition(Context context, FragmentTransaction transaction,
|
||||
Fragment exit, Fragment enter) {
|
||||
if (mHolder == null || !(enter instanceof GalleryDetailScene)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
transaction.addSharedElement(mHolder.thumb, mHolder.thumb.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.title, mHolder.title.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.uploader, mHolder.uploader.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.category, mHolder.category.getTransitionName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
if (null == mHelper || null == mRecyclerView) {
|
||||
@@ -598,9 +623,9 @@ public final class GalleryListScene extends BaseScene
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
GalleryListHolder holder = (GalleryListHolder) mRecyclerView.getChildViewHolder(view);
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(holder));
|
||||
View thumb;
|
||||
if (ApiHelper.SUPPORT_TRANSITION && null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
return true;
|
||||
@@ -620,7 +645,7 @@ public final class GalleryListScene extends BaseScene
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0: // Download
|
||||
CommonOperations.startDownload(getActivity(), gi);
|
||||
CommonOperations.startDownload(getActivity(), gi, false);
|
||||
break;
|
||||
case 1: // Favorites
|
||||
CommonOperations.addToFavorites(getActivity(), gi,
|
||||
@@ -654,7 +679,9 @@ public final class GalleryListScene extends BaseScene
|
||||
mFabAnimatorListener = new SimpleAnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mFab.setVisibility(View.INVISIBLE);
|
||||
if (null != mFab) {
|
||||
mFab.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -853,16 +880,10 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
public void onStateChange(SearchBar searchBar, int newState, int oldState, boolean animation) {
|
||||
if (null == mFitPaddingLayout || null == mLeftDrawable || null == mRightDrawable) {
|
||||
if (null == mLeftDrawable || null == mRightDrawable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newState == SearchBar.STATE_NORMAL) {
|
||||
mFitPaddingLayout.setEnableUpdatePaddingTop(true);
|
||||
} else {
|
||||
mFitPaddingLayout.setEnableUpdatePaddingTop(false);
|
||||
}
|
||||
|
||||
switch (oldState) {
|
||||
default:
|
||||
case SearchBar.STATE_NORMAL:
|
||||
@@ -921,77 +942,23 @@ public final class GalleryListScene extends BaseScene
|
||||
scene.startScene(new Announcer(GalleryListScene.class).setArgs(args));
|
||||
}
|
||||
|
||||
private class GalleryListHolder extends RecyclerView.ViewHolder {
|
||||
private class GalleryListAdapter extends GalleryAdapter {
|
||||
|
||||
private final LoadImageView thumb;
|
||||
private final TextView title;
|
||||
private final TextView uploader;
|
||||
private final SimpleRatingView rating;
|
||||
private final TextView category;
|
||||
private final TextView posted;
|
||||
private final TextView simpleLanguage;
|
||||
|
||||
public GalleryListHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
thumb = (LoadImageView) itemView.findViewById(R.id.thumb);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
uploader = (TextView) itemView.findViewById(R.id.uploader);
|
||||
rating = (SimpleRatingView) itemView.findViewById(R.id.rating);
|
||||
category = (TextView) itemView.findViewById(R.id.category);
|
||||
posted = (TextView) itemView.findViewById(R.id.posted);
|
||||
simpleLanguage = (TextView) itemView.findViewById(R.id.simple_language);
|
||||
}
|
||||
}
|
||||
|
||||
private class GalleryListAdapter extends RecyclerView.Adapter<GalleryListHolder> {
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
public GalleryListAdapter() {
|
||||
mInflater = getActivity().getLayoutInflater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GalleryListHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new GalleryListHolder(mInflater.inflate(R.layout.item_gallery_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void onBindViewHolder(GalleryListHolder holder, int position) {
|
||||
if (null == mHelper) {
|
||||
return;
|
||||
}
|
||||
|
||||
GalleryInfo gi = mHelper.getDataAt(position);
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb, true);
|
||||
holder.title.setText(EhUtils.getSuitableTitle(gi));
|
||||
holder.uploader.setText(gi.uploader);
|
||||
holder.rating.setRating(gi.rating);
|
||||
TextView category = holder.category;
|
||||
String newCategoryText = EhUtils.getCategory(gi.category);
|
||||
if (!newCategoryText.equals(category.getText())) {
|
||||
category.setText(newCategoryText);
|
||||
category.setBackgroundColor(EhUtils.getCategoryColor(gi.category));
|
||||
}
|
||||
holder.posted.setText(gi.posted);
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
|
||||
// Update transition name
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
holder.title.setTransitionName(TransitionNameFactory.getTitleTransitionName(gid));
|
||||
holder.uploader.setTransitionName(TransitionNameFactory.getUploaderTransitionName(gid));
|
||||
holder.category.setTransitionName(TransitionNameFactory.getCategoryTransitionName(gid));
|
||||
}
|
||||
public GalleryListAdapter(LayoutInflater inflater, Context context,
|
||||
RecyclerView recyclerView, GridLayoutManager layoutManager, int type) {
|
||||
super(inflater, context, recyclerView, layoutManager, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return null != mHelper ? mHelper.size() : 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GalleryInfo getDataAt(int position) {
|
||||
return null != mHelper ? mHelper.getDataAt(position) : null;
|
||||
}
|
||||
}
|
||||
|
||||
private class GalleryListHelper extends ContentLayout.ContentHelper<GalleryInfo> {
|
||||
@@ -1068,7 +1035,7 @@ public final class GalleryListScene extends BaseScene
|
||||
private void onGetGalleryListFailure(Exception e, int taskId) {
|
||||
if (mHelper != null && mSearchBarMover != null &&
|
||||
mHelper.isCurrentTask(taskId) && isViewCreated()) {
|
||||
mHelper.onGetExpection(taskId, e);
|
||||
mHelper.onGetException(taskId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1084,7 +1051,7 @@ public final class GalleryListScene extends BaseScene
|
||||
private void onGetWhatsHotFailure(Exception e, int taskId) {
|
||||
if (mHelper != null && mSearchBarMover != null &&
|
||||
mHelper.isCurrentTask(taskId) && isViewCreated()) {
|
||||
mHelper.onGetExpection(taskId, e);
|
||||
mHelper.onGetException(taskId, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.StageActivity;
|
||||
import com.hippo.util.LayoutUtils2;
|
||||
import com.hippo.widget.ContentLayout;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.widget.Slider;
|
||||
@@ -110,8 +111,15 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
boolean hasFirstRefresh;
|
||||
if (mHelper != null && 1 == mHelper.getShownViewIndex()) {
|
||||
hasFirstRefresh = false;
|
||||
} else {
|
||||
hasFirstRefresh = mHasFirstRefresh;
|
||||
}
|
||||
outState.putBoolean(KEY_HAS_FIRST_REFRESH, hasFirstRefresh);
|
||||
outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo);
|
||||
outState.putBoolean(KEY_HAS_FIRST_REFRESH, mHasFirstRefresh);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -125,7 +133,9 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
|
||||
mAdapter = new GalleryPreviewAdapter();
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 3)); // TODO hardcode
|
||||
int minWidth = getResources().getDimensionPixelOffset(R.dimen.preview_grid_min_width);
|
||||
int spanCount = LayoutUtils2.calculateSpanCount(getContext(), minWidth);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(getContext(), spanCount));
|
||||
int padding = LayoutUtils.dp2pix(getContext(), 4);
|
||||
recyclerView.setPadding(padding, padding, padding, padding);
|
||||
recyclerView.setClipToPadding(false);
|
||||
@@ -147,8 +157,15 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
if (null != mHelper) {
|
||||
if (1 == mHelper.getShownViewIndex()) {
|
||||
mHasFirstRefresh = false;
|
||||
}
|
||||
mHelper = null;
|
||||
}
|
||||
|
||||
mAdapter = null;
|
||||
mHelper = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,7 +205,7 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
|
||||
@Override
|
||||
public void onNavigationClick() {
|
||||
finish();
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -245,7 +262,7 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
@Override
|
||||
protected void getPageData(final int taskId, int type, int page) {
|
||||
if (null == mClient || null == mGalleryInfo) {
|
||||
onGetExpection(taskId, new EhException(getString(R.string.error_cannot_find_gallery)));
|
||||
onGetException(taskId, new EhException(getString(R.string.error_cannot_find_gallery)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -318,7 +335,7 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
|
||||
private void onGetLargePreviewSetFailure(Exception e, int taskId) {
|
||||
if (mHelper != null && mHelper.isCurrentTask(taskId) && isViewCreated()) {
|
||||
mHelper.onGetExpection(taskId, e);
|
||||
mHelper.onGetException(taskId, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,20 +16,14 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -40,21 +34,18 @@ import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.easyrecyclerview.HandlerDrawable;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.dao.HistoryInfo;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.widget.SimpleRatingView;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.StageActivity;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.yorozuya.ResourcesUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
@@ -68,8 +59,6 @@ public class HistoryScene extends ToolbarScene
|
||||
View life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private ViewTransition mViewTransition;
|
||||
@Nullable
|
||||
private HistoryAdapter mAdapter;
|
||||
@@ -87,7 +76,7 @@ public class HistoryScene extends ToolbarScene
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.scene_history, container, false);
|
||||
View content = ViewUtils.$$(view, R.id.content);
|
||||
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
|
||||
EasyRecyclerView recyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
|
||||
FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
|
||||
TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
|
||||
mViewTransition = new ViewTransition(content, tip);
|
||||
@@ -96,23 +85,21 @@ public class HistoryScene extends ToolbarScene
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
tip.setCompoundDrawables(null, drawable, null, null);
|
||||
|
||||
Resources resources = getResources();
|
||||
|
||||
mList = EhDB.getHistoryLazyList();
|
||||
mAdapter = new HistoryAdapter();
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
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);
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 1);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
recyclerView.setDrawSelectorOnTop(true);
|
||||
recyclerView.hasFixedSize();
|
||||
recyclerView.setClipToPadding(false);
|
||||
recyclerView.setOnItemClickListener(this);
|
||||
recyclerView.setOnItemLongClickListener(this);
|
||||
mAdapter = new HistoryAdapter(LayoutInflater.from(getContext()),
|
||||
getContext(), recyclerView, layoutManager, Settings.getListMode());
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
mAdapter.register();
|
||||
|
||||
fastScroller.attachToRecyclerView(mRecyclerView);
|
||||
fastScroller.attachToRecyclerView(recyclerView);
|
||||
HandlerDrawable handlerDrawable = new HandlerDrawable();
|
||||
handlerDrawable.setColor(ResourcesUtils.getAttrColor(getContext(), R.attr.colorAccent));
|
||||
fastScroller.setHandlerDrawable(handlerDrawable);
|
||||
@@ -137,18 +124,27 @@ public class HistoryScene extends ToolbarScene
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
mRecyclerView = null;
|
||||
mViewTransition = null;
|
||||
mAdapter = null;
|
||||
if (null != mList) {
|
||||
mList.close();
|
||||
mList = null;
|
||||
}
|
||||
if (null != mAdapter) {
|
||||
mAdapter.unregister();
|
||||
mAdapter = null;
|
||||
}
|
||||
|
||||
mViewTransition = null;
|
||||
mAdapter = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationClick() {
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
if (null == mList || null == mRecyclerView) {
|
||||
if (null == mList) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -156,9 +152,9 @@ public class HistoryScene extends ToolbarScene
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, mList.get(position));
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
HistoryHolder holder = (HistoryHolder) mRecyclerView.getChildViewHolder(view);
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(holder));
|
||||
View thumb;
|
||||
if (ApiHelper.SUPPORT_TRANSITION && null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
return true;
|
||||
@@ -178,7 +174,7 @@ public class HistoryScene extends ToolbarScene
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0: // Download
|
||||
CommonOperations.startDownload(getActivity(), gi);
|
||||
CommonOperations.startDownload(getActivity(), gi, false);
|
||||
break;
|
||||
case 1: // Favorites
|
||||
CommonOperations.addToFavorites(getActivity(), gi,
|
||||
@@ -191,103 +187,22 @@ public class HistoryScene extends ToolbarScene
|
||||
return true;
|
||||
}
|
||||
|
||||
private class HistoryHolder extends RecyclerView.ViewHolder {
|
||||
private class HistoryAdapter extends GalleryAdapter {
|
||||
|
||||
private final LoadImageView thumb;
|
||||
private final TextView title;
|
||||
private final TextView uploader;
|
||||
private final SimpleRatingView rating;
|
||||
private final TextView category;
|
||||
private final TextView posted;
|
||||
private final TextView simpleLanguage;
|
||||
|
||||
public HistoryHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
thumb = (LoadImageView) itemView.findViewById(R.id.thumb);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
uploader = (TextView) itemView.findViewById(R.id.uploader);
|
||||
rating = (SimpleRatingView) itemView.findViewById(R.id.rating);
|
||||
category = (TextView) itemView.findViewById(R.id.category);
|
||||
posted = (TextView) itemView.findViewById(R.id.posted);
|
||||
simpleLanguage = (TextView) itemView.findViewById(R.id.simple_language);
|
||||
}
|
||||
}
|
||||
|
||||
private class HistoryAdapter extends RecyclerView.Adapter<HistoryHolder> {
|
||||
|
||||
@Override
|
||||
public HistoryHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new HistoryHolder(getActivity().getLayoutInflater()
|
||||
.inflate(R.layout.item_gallery_list, parent, false));
|
||||
public HistoryAdapter(LayoutInflater inflater, Context context,
|
||||
RecyclerView recyclerView, GridLayoutManager layoutManager, int type) {
|
||||
super(inflater, context, recyclerView, layoutManager, type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void onBindViewHolder(HistoryHolder holder, int position) {
|
||||
if (null == mList) {
|
||||
return;
|
||||
}
|
||||
|
||||
GalleryInfo gi = mList.get(position);
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb, true);
|
||||
holder.title.setText(EhUtils.getSuitableTitle(gi));
|
||||
holder.uploader.setText(gi.uploader);
|
||||
holder.rating.setRating(gi.rating);
|
||||
TextView category = holder.category;
|
||||
String newCategoryText = EhUtils.getCategory(gi.category);
|
||||
if (!newCategoryText.equals(category.getText())) {
|
||||
category.setText(newCategoryText);
|
||||
category.setBackgroundColor(EhUtils.getCategoryColor(gi.category));
|
||||
}
|
||||
holder.posted.setText(gi.posted);
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
|
||||
// Update transition name
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
holder.title.setTransitionName(TransitionNameFactory.getTitleTransitionName(gid));
|
||||
holder.uploader.setTransitionName(TransitionNameFactory.getUploaderTransitionName(gid));
|
||||
holder.category.setTransitionName(TransitionNameFactory.getCategoryTransitionName(gid));
|
||||
}
|
||||
public GalleryInfo getDataAt(int position) {
|
||||
return null != mList ? mList.get(position) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList != null ? mList.size() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static class EnterGalleryDetailTransaction implements TransitionHelper {
|
||||
|
||||
private final HistoryHolder mHolder;
|
||||
|
||||
public EnterGalleryDetailTransaction(HistoryHolder holder) {
|
||||
mHolder = holder;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onTransition(Context context, FragmentTransaction transaction,
|
||||
Fragment exit, Fragment enter) {
|
||||
if (mHolder == null || !(enter instanceof GalleryDetailScene)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
transaction.addSharedElement(mHolder.thumb, mHolder.thumb.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.title, mHolder.title.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.uploader, mHolder.uploader.getTransitionName());
|
||||
transaction.addSharedElement(mHolder.category, mHolder.category.getTransitionName());
|
||||
return true;
|
||||
return null != mList ? mList.size() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -32,6 +33,7 @@ import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.StageActivity;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.view.ViewTransition;
|
||||
|
||||
@@ -59,8 +61,7 @@ public final class ProgressScene extends BaseScene implements View.OnClickListen
|
||||
private String mPToken;
|
||||
private int mPage;
|
||||
|
||||
private View mTip;
|
||||
private TextView mTipText;
|
||||
private TextView mTip;
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
@Override
|
||||
@@ -155,11 +156,13 @@ public final class ProgressScene extends BaseScene implements View.OnClickListen
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.scene_progress, container, false);
|
||||
View progress = view.findViewById(R.id.progress);
|
||||
mTip = view.findViewById(R.id.tip);
|
||||
mTipText = (TextView) mTip.findViewById(R.id.tip_text);
|
||||
mTip = (TextView) view.findViewById(R.id.tip);
|
||||
|
||||
Drawable drawable = DrawableManager.getDrawable(getContext(), R.drawable.big_weird_face);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
mTip.setCompoundDrawables(null, drawable, null, null);
|
||||
mTip.setOnClickListener(this);
|
||||
mTipText.setText(mError);
|
||||
mTip.setText(mError);
|
||||
|
||||
mViewTransition = new ViewTransition(progress, mTip);
|
||||
|
||||
@@ -200,7 +203,7 @@ public final class ProgressScene extends BaseScene implements View.OnClickListen
|
||||
if (isViewCreated()) {
|
||||
// Show tip
|
||||
mViewTransition.showView(1);
|
||||
mTipText.setText(mError);
|
||||
mTip.setText(mError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,6 @@ public final class QuickSearchScene extends ToolbarScene {
|
||||
View life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private ViewTransition mViewTransition;
|
||||
@Nullable
|
||||
private RecyclerView.Adapter mAdapter;
|
||||
@@ -89,9 +87,9 @@ public final class QuickSearchScene extends ToolbarScene {
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.scene_label_list, container, false);
|
||||
|
||||
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
|
||||
EasyRecyclerView recyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
|
||||
TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
|
||||
mViewTransition = new ViewTransition(mRecyclerView, tip);
|
||||
mViewTransition = new ViewTransition(recyclerView, tip);
|
||||
|
||||
Drawable drawable = DrawableManager.getDrawable(getContext(), R.drawable.big_search);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
@@ -115,13 +113,13 @@ public final class QuickSearchScene extends ToolbarScene {
|
||||
mAdapter = adapter;
|
||||
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
|
||||
animator.setSupportsChangeAnimations(false);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
mRecyclerView.setItemAnimator(animator);
|
||||
guardManager.attachRecyclerView(mRecyclerView);
|
||||
swipeManager.attachRecyclerView(mRecyclerView);
|
||||
dragDropManager.attachRecyclerView(mRecyclerView);
|
||||
recyclerView.hasFixedSize();
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setItemAnimator(animator);
|
||||
guardManager.attachRecyclerView(recyclerView);
|
||||
swipeManager.attachRecyclerView(recyclerView);
|
||||
dragDropManager.attachRecyclerView(recyclerView);
|
||||
|
||||
updateView();
|
||||
|
||||
@@ -139,11 +137,14 @@ public final class QuickSearchScene extends ToolbarScene {
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
mRecyclerView = null;
|
||||
mViewTransition = null;
|
||||
mAdapter = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationClick() {
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
private void updateView() {
|
||||
if (mViewTransition != null) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.hippo.ehviewer.UrlOpener;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.parser.ProfileParser;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
@@ -266,7 +267,7 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
showProgress(true);
|
||||
|
||||
// Clean up for sign in
|
||||
EhApplication.getEhCookieStore(getContext()).cleanUpForSignIn();
|
||||
EhUtils.signOut(getContext());
|
||||
|
||||
EhCallback callback = new SignInListener(getContext(),
|
||||
((StageActivity) getActivity()).getStageId(), getTag());
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.webkit.WebViewClient;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.client.EhCookieStore;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -40,8 +41,6 @@ import okhttp3.HttpUrl;
|
||||
|
||||
public class WebViewSignInScene extends BaseScene {
|
||||
|
||||
public static final String KEY_DISPLAY_NAME = "display_name";
|
||||
|
||||
/*---------------
|
||||
View life cycle
|
||||
---------------*/
|
||||
@@ -56,10 +55,10 @@ public class WebViewSignInScene extends BaseScene {
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public View onCreateView(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
EhApplication.getEhCookieStore(getContext()).removeAll();
|
||||
EhUtils.signOut(getContext());
|
||||
CookieManager.getInstance().removeAllCookie();
|
||||
mWebView = new WebView(getContext());
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
|
||||
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* 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.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.widget.OffsetLayout;
|
||||
import com.hippo.yorozuya.IntList;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FitPaddingLayout extends OffsetLayout {
|
||||
|
||||
private static final String KEY_SUPER = "super";
|
||||
private static final String KEY_PADDING_TOP_1 = "padding_top_1";
|
||||
private static final String KEY_PADDING_TOP_2 = "padding_top_2";
|
||||
private static final String KEY_PADDING_TOP_3 = "padding_top_3";
|
||||
private static final String KEY_PADDING_BOTTOM_1 = "padding_bottom_1";
|
||||
private static final String KEY_PADDING_BOTTOM_2 = "padding_bottom_2";
|
||||
private static final String KEY_PADDING_BOTTOM_3 = "padding_bottom_3";
|
||||
|
||||
private int mFitTop1;
|
||||
private int mFitTop2;
|
||||
private int mFitTop3;
|
||||
private int mContentId1;
|
||||
private int mContentId2;
|
||||
private int mContentId3;
|
||||
private int mFitBottom1;
|
||||
private int mFitBottom2;
|
||||
private int mFitBottom3;
|
||||
|
||||
private boolean mOnce;
|
||||
|
||||
private int mOriginalPaddingTop1 = -1;
|
||||
private int mOriginalPaddingTop2 = -1;
|
||||
private int mOriginalPaddingTop3 = -1;
|
||||
private int mOriginalPaddingBottom1 = -1;
|
||||
private int mOriginalPaddingBottom2 = -1;
|
||||
private int mOriginalPaddingBottom3 = -1;
|
||||
|
||||
private boolean mEnableUpdatePaddingTop = true;
|
||||
|
||||
private boolean mUpdated = false;
|
||||
|
||||
private List<View> mContentList = new ArrayList<>();
|
||||
private IntList mPaddingTopList = new IntList();
|
||||
private IntList mPaddingBottomList = new IntList();
|
||||
|
||||
private Runnable mUpdatePaddingTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0, size = mContentList.size(); i < size; i++) {
|
||||
View content = mContentList.get(i);
|
||||
int paddingTop = mPaddingTopList.get(i);
|
||||
int paddingBottom = mPaddingBottomList.get(i);
|
||||
content.setPadding(content.getPaddingLeft(),
|
||||
paddingTop == -1 ? content.getPaddingTop() : paddingTop,
|
||||
content.getPaddingRight(),
|
||||
paddingBottom == -1 ? content.getPaddingBottom() : paddingBottom);
|
||||
}
|
||||
mContentList.clear();
|
||||
mPaddingTopList.clear();
|
||||
mPaddingBottomList.clear();
|
||||
}
|
||||
};
|
||||
|
||||
public FitPaddingLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public FitPaddingLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FitPaddingLayout);
|
||||
mFitTop1 = a.getResourceId(R.styleable.FitPaddingLayout_fitTop1, 0);
|
||||
mFitTop2 = a.getResourceId(R.styleable.FitPaddingLayout_fitTop2, 0);
|
||||
mFitTop3 = a.getResourceId(R.styleable.FitPaddingLayout_fitTop3, 0);
|
||||
mContentId1 = a.getResourceId(R.styleable.FitPaddingLayout_content1, 0);
|
||||
mContentId2 = a.getResourceId(R.styleable.FitPaddingLayout_content2, 0);
|
||||
mContentId3 = a.getResourceId(R.styleable.FitPaddingLayout_content3, 0);
|
||||
mFitBottom1 = a.getResourceId(R.styleable.FitPaddingLayout_fitBottom1, 0);
|
||||
mFitBottom2 = a.getResourceId(R.styleable.FitPaddingLayout_fitBottom2, 0);
|
||||
mFitBottom3 = a.getResourceId(R.styleable.FitPaddingLayout_fitBottom3, 0);
|
||||
mOnce = a.getBoolean(R.styleable.FitPaddingLayout_once, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
public void setEnableUpdatePaddingTop(boolean enableUpdatePaddingTop) {
|
||||
mEnableUpdatePaddingTop = enableUpdatePaddingTop;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private View findViewByIdEx(int id) {
|
||||
return id == 0 ? null : findViewById(id);
|
||||
}
|
||||
|
||||
private boolean updatePadding(View content, View fitTop, View fitBottom,
|
||||
int originalPaddingTop, int originalPaddingBottom, int[] paddings, int[] newPaddins) {
|
||||
if (content == null || (fitTop == null && fitBottom == null)) {
|
||||
return false;
|
||||
}
|
||||
if (originalPaddingTop == -1) {
|
||||
originalPaddingTop = content.getPaddingTop();
|
||||
}
|
||||
if (originalPaddingBottom == -1) {
|
||||
originalPaddingBottom = content.getPaddingBottom();
|
||||
}
|
||||
paddings[0] = originalPaddingTop;
|
||||
paddings[1] = originalPaddingBottom;
|
||||
|
||||
int newPaddingTop = -1;
|
||||
int newPaddingBottom = -1;
|
||||
if (fitTop != null) {
|
||||
newPaddingTop = originalPaddingTop + fitTop.getBottom() -
|
||||
((LayoutParams) fitTop.getLayoutParams()).offsetY;
|
||||
}
|
||||
if (fitBottom != null) {
|
||||
newPaddingBottom = originalPaddingBottom + getHeight() - fitBottom.getTop() -
|
||||
((LayoutParams) fitBottom.getLayoutParams()).offsetY;
|
||||
}
|
||||
newPaddins[0] = newPaddingTop;
|
||||
newPaddins[1] = newPaddingBottom;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isNeedUpdatePadding(View content, int paddingTop, int paddingBottom) {
|
||||
return (paddingTop != -1 || paddingTop != content.getPaddingTop()) ||
|
||||
(paddingBottom != -1 || paddingBottom != content.getPaddingBottom());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
|
||||
if (!mEnableUpdatePaddingTop || (mOnce && mUpdated)) {
|
||||
return;
|
||||
}
|
||||
|
||||
View fitTop1 = findViewById(mFitTop1);
|
||||
View fitTop2 = findViewById(mFitTop2);
|
||||
View fitTop3 = findViewById(mFitTop3);
|
||||
View content1 = findViewById(mContentId1);
|
||||
View content2 = findViewById(mContentId2);
|
||||
View content3 = findViewById(mContentId3);
|
||||
View fitBottom1 = findViewById(mFitBottom1);
|
||||
View fitBottom2 = findViewById(mFitBottom2);
|
||||
View fitBottom3 = findViewById(mFitBottom3);
|
||||
|
||||
mContentList.clear();
|
||||
mPaddingTopList.clear();
|
||||
mPaddingBottomList.clear();
|
||||
|
||||
int[] paddings = new int[2];
|
||||
int[] newPaddings = new int[2];
|
||||
if (updatePadding(content1, fitTop1, fitBottom1, mOriginalPaddingTop1,
|
||||
mOriginalPaddingBottom1, paddings, newPaddings)) {
|
||||
mOriginalPaddingTop1 = paddings[0];
|
||||
mOriginalPaddingBottom1 = paddings[1];
|
||||
if (isNeedUpdatePadding(content1, newPaddings[0], newPaddings[1])) {
|
||||
mContentList.add(content1);
|
||||
mPaddingTopList.add(newPaddings[0]);
|
||||
mPaddingBottomList.add(newPaddings[1]);
|
||||
}
|
||||
}
|
||||
if (updatePadding(content2, fitTop2, fitBottom2, mOriginalPaddingTop2,
|
||||
mOriginalPaddingBottom2, paddings, newPaddings)) {
|
||||
mOriginalPaddingTop2 = paddings[0];
|
||||
mOriginalPaddingBottom2 = paddings[1];
|
||||
if (isNeedUpdatePadding(content2, newPaddings[0], newPaddings[1])) {
|
||||
mContentList.add(content2);
|
||||
mPaddingTopList.add(newPaddings[0]);
|
||||
mPaddingBottomList.add(newPaddings[1]);
|
||||
}
|
||||
}
|
||||
if (updatePadding(content3, fitTop3, fitBottom3, mOriginalPaddingTop3,
|
||||
mOriginalPaddingBottom3, paddings, newPaddings)) {
|
||||
mOriginalPaddingTop3 = paddings[0];
|
||||
mOriginalPaddingBottom3 = paddings[1];
|
||||
if (isNeedUpdatePadding(content3, newPaddings[0], newPaddings[1])) {
|
||||
mContentList.add(content3);
|
||||
mPaddingTopList.add(newPaddings[0]);
|
||||
mPaddingBottomList.add(newPaddings[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (mContentList.size() > 0) {
|
||||
SimpleHandler.getInstance().post(mUpdatePaddingTask);
|
||||
}
|
||||
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
private void saveContentPadding(Bundle state, int id, String topKey, String bottomKey) {
|
||||
View content = findViewByIdEx(id);
|
||||
if (content != null) {
|
||||
state.putInt(topKey, content.getPaddingTop());
|
||||
state.putInt(bottomKey, content.getPaddingBottom());
|
||||
} else {
|
||||
state.putInt(topKey, -1);
|
||||
state.putInt(bottomKey, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
final Bundle state = new Bundle();
|
||||
state.putParcelable(KEY_SUPER, super.onSaveInstanceState());
|
||||
saveContentPadding(state, mContentId1, KEY_PADDING_TOP_1, KEY_PADDING_BOTTOM_1);
|
||||
saveContentPadding(state, mContentId2, KEY_PADDING_TOP_2, KEY_PADDING_BOTTOM_2);
|
||||
saveContentPadding(state, mContentId3, KEY_PADDING_TOP_3, KEY_PADDING_BOTTOM_3);
|
||||
return state;
|
||||
}
|
||||
|
||||
private void restoreContentPadding(Bundle state, int id, String topKey, String bottomKey, int[] paddings) {
|
||||
View content = findViewByIdEx(id);
|
||||
if (content != null) {
|
||||
paddings[0] = content.getPaddingTop();
|
||||
paddings[1] = content.getPaddingBottom();
|
||||
int paddingTop = state.getInt(topKey);
|
||||
int paddingBottom = state.getInt(bottomKey);
|
||||
if (paddingTop != -1 || paddingBottom != -1) {
|
||||
content.setPadding(content.getPaddingLeft(),
|
||||
paddingTop == -1 ? content.getPaddingTop() : paddingTop,
|
||||
content.getPaddingRight(),
|
||||
paddingBottom == -1 ? content.getPaddingBottom() : paddingBottom);
|
||||
}
|
||||
} else {
|
||||
paddings[0] = -1;
|
||||
paddings[1] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (state instanceof Bundle) {
|
||||
final Bundle savedState = (Bundle) state;
|
||||
super.onRestoreInstanceState(savedState.getParcelable(KEY_SUPER));
|
||||
int[] ints = new int[2];
|
||||
restoreContentPadding(savedState, mContentId1, KEY_PADDING_TOP_1, KEY_PADDING_BOTTOM_1, ints);
|
||||
mOriginalPaddingTop1 = ints[0];
|
||||
mOriginalPaddingBottom1 = ints[1];
|
||||
restoreContentPadding(savedState, mContentId2, KEY_PADDING_TOP_2, KEY_PADDING_BOTTOM_2, ints);
|
||||
mOriginalPaddingTop2 = ints[0];
|
||||
mOriginalPaddingBottom2 = ints[1];
|
||||
restoreContentPadding(savedState, mContentId3, KEY_PADDING_TOP_3, KEY_PADDING_BOTTOM_3, ints);
|
||||
mOriginalPaddingTop3 = ints[0];
|
||||
mOriginalPaddingBottom3 = ints[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,12 +39,13 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.SimpleImageView;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
@@ -74,13 +75,12 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
private int mBaseHeight;
|
||||
private float mProgress;
|
||||
|
||||
private SimpleImageView mMenuButton;
|
||||
private ImageView mMenuButton;
|
||||
private TextView mTitleTextView;
|
||||
private SimpleImageView mActionButton;
|
||||
private ImageView mActionButton;
|
||||
private SearchEditText mEditText;
|
||||
private ListView mList;
|
||||
private View mListContainer;
|
||||
private View mListHeader;
|
||||
private boolean mHeaderAttached;
|
||||
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
@@ -117,12 +117,13 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
inflater.inflate(R.layout.widget_search_bar, this);
|
||||
mMenuButton = (SimpleImageView) findViewById(R.id.search_menu);
|
||||
mTitleTextView = (TextView) findViewById(R.id.search_title);
|
||||
mActionButton = (SimpleImageView) findViewById(R.id.search_action);
|
||||
mEditText = (SearchEditText) findViewById(R.id.search_edit_text);
|
||||
mList = (ListView) findViewById(R.id.search_bar_list);
|
||||
mListHeader = inflater.inflate(R.layout.header_suggestion_list, mList, false);
|
||||
mMenuButton = (ImageView) ViewUtils.$$(this, R.id.search_menu);
|
||||
mTitleTextView = (TextView) ViewUtils.$$(this, R.id.search_title);
|
||||
mActionButton = (ImageView) ViewUtils.$$(this, R.id.search_action);
|
||||
mEditText = (SearchEditText) ViewUtils.$$(this, R.id.search_edit_text);
|
||||
mListContainer = ViewUtils.$$(this, R.id.list_container);
|
||||
ListView list = (ListView) ViewUtils.$$(mListContainer, R.id.search_bar_list);
|
||||
mListHeader = ViewUtils.$$(mListContainer, R.id.list_header);
|
||||
|
||||
mViewTransition = new ViewTransition(mTitleTextView, mEditText);
|
||||
|
||||
@@ -139,23 +140,19 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
|
||||
mSuggestionList = new ArrayList<>();
|
||||
mSuggestionAdapter = new ArrayAdapter<>(getContext(), R.layout.item_simple_list, mSuggestionList);
|
||||
mHeaderAttached = true;
|
||||
mList.addHeaderView(mListHeader);
|
||||
mList.setAdapter(mSuggestionAdapter);
|
||||
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
list.setAdapter(mSuggestionAdapter);
|
||||
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
String suggestion = mSuggestionList.get(MathUtils.clamp(
|
||||
position - mList.getHeaderViewsCount(), 0, mSuggestionList.size() - 1));
|
||||
String suggestion = mSuggestionList.get(MathUtils.clamp(position, 0, mSuggestionList.size() - 1));
|
||||
mEditText.setText(suggestion);
|
||||
mEditText.setSelection(mEditText.getText().length());
|
||||
}
|
||||
});
|
||||
mList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
String suggestion = mSuggestionList.get(MathUtils.clamp(
|
||||
position - mList.getHeaderViewsCount(), 0, mSuggestionList.size() - 1));
|
||||
String suggestion = mSuggestionList.get(MathUtils.clamp(position, 0, mSuggestionList.size() - 1));
|
||||
mSearchDatabase.deleteQuery(suggestion);
|
||||
updateSuggestions();
|
||||
return true;
|
||||
@@ -164,17 +161,11 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
}
|
||||
|
||||
private void addListHeader() {
|
||||
if (!mHeaderAttached) {
|
||||
mHeaderAttached = true;
|
||||
mListHeader.setVisibility(VISIBLE);
|
||||
}
|
||||
mListHeader.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
private void removeListHeader() {
|
||||
if (mHeaderAttached) {
|
||||
mHeaderAttached = false;
|
||||
mListHeader.setVisibility(GONE);
|
||||
}
|
||||
mListHeader.setVisibility(GONE);
|
||||
}
|
||||
|
||||
private void updateSuggestions() {
|
||||
@@ -228,11 +219,11 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
}
|
||||
|
||||
public void setLeftDrawable(Drawable drawable) {
|
||||
mMenuButton.setDrawable(drawable);
|
||||
mMenuButton.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void setRightDrawable(Drawable drawable) {
|
||||
mActionButton.setDrawable(drawable);
|
||||
mActionButton.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void setLeftIconVisibility(int visibility) {
|
||||
@@ -348,10 +339,11 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
if (animation) {
|
||||
ObjectAnimator oa = ObjectAnimator.ofFloat(this, "progress", 1f);
|
||||
oa.setDuration(ANIMATE_TIME);
|
||||
oa.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
|
||||
oa.addListener(new SimpleAnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mList.setVisibility(View.VISIBLE);
|
||||
mListContainer.setVisibility(View.VISIBLE);
|
||||
mInAnimation = true;
|
||||
}
|
||||
|
||||
@@ -365,7 +357,7 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
}
|
||||
oa.start();
|
||||
} else {
|
||||
mList.setVisibility(View.VISIBLE);
|
||||
mListContainer.setVisibility(View.VISIBLE);
|
||||
setProgress(1f);
|
||||
}
|
||||
}
|
||||
@@ -382,6 +374,7 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
if (animation) {
|
||||
ObjectAnimator oa = ObjectAnimator.ofFloat(this, "progress", 0f);
|
||||
oa.setDuration(ANIMATE_TIME);
|
||||
oa.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
|
||||
oa.addListener(new SimpleAnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
@@ -390,7 +383,7 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mList.setVisibility(View.GONE);
|
||||
mListContainer.setVisibility(View.GONE);
|
||||
mInAnimation = false;
|
||||
}
|
||||
});
|
||||
@@ -400,14 +393,14 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
oa.start();
|
||||
} else {
|
||||
setProgress(0f);
|
||||
mList.setVisibility(View.GONE);
|
||||
mListContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (mList.getVisibility() == View.VISIBLE) {
|
||||
if (mListContainer.getVisibility() == View.VISIBLE) {
|
||||
mWidth = right - left;
|
||||
mHeight = bottom - top;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.preference;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
public class ActivityPreference extends Preference {
|
||||
|
||||
private static final String TAG = ActivityPreference.class.getSimpleName();
|
||||
|
||||
private Class<?> mActivityClazz;
|
||||
|
||||
public ActivityPreference(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0, 0);
|
||||
}
|
||||
|
||||
public ActivityPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0, 0);
|
||||
}
|
||||
|
||||
public ActivityPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public ActivityPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActivityPreference, defStyleAttr, defStyleRes);
|
||||
String clazzName = a.getString(R.styleable.ActivityPreference_activity);
|
||||
if (null != clazzName) {
|
||||
try {
|
||||
mActivityClazz = Class.forName(clazzName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e(TAG, "Can't find class " + clazzName, e);
|
||||
}
|
||||
}
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
if (null == mActivityClazz) {
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = getContext();
|
||||
Intent intent = new Intent(context, mActivityClazz);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
/*
|
||||
* 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.preference;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.Preference;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
/**
|
||||
* A base class for {@link Preference} objects that are
|
||||
* dialog-based. These preferences will, when clicked, open a dialog showing the
|
||||
* actual preference controls.
|
||||
*/
|
||||
public abstract class DialogPreference extends Preference implements
|
||||
DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
|
||||
|
||||
private static final String KEY_SUPER = "super";
|
||||
private static final String KEY_IS_DIALOG_SHOWING = "is_dialog_showing";
|
||||
private static final String KEY_DIALOG_BUNDLE = "dialog_bundle";
|
||||
|
||||
private AlertDialog.Builder mBuilder;
|
||||
|
||||
private CharSequence mDialogTitle;
|
||||
private Drawable mDialogIcon;
|
||||
private CharSequence mPositiveButtonText;
|
||||
private CharSequence mNegativeButtonText;
|
||||
private int mDialogLayoutResId;
|
||||
|
||||
/** The dialog, if it is showing. */
|
||||
private AlertDialog mDialog;
|
||||
|
||||
/** Which button was clicked. */
|
||||
private int mWhichButtonClicked;
|
||||
|
||||
public DialogPreference(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0, 0);
|
||||
}
|
||||
|
||||
public DialogPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0, 0);
|
||||
}
|
||||
|
||||
public DialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public DialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DialogPreference, defStyleAttr, defStyleRes);
|
||||
mDialogTitle = a.getString(R.styleable.DialogPreference_dialogTitle);
|
||||
if (mDialogTitle == null) {
|
||||
// Fallback on the regular title of the preference
|
||||
// (the one that is seen in the list)
|
||||
mDialogTitle = getTitle();
|
||||
}
|
||||
mDialogIcon = a.getDrawable(R.styleable.DialogPreference_dialogIcon);
|
||||
mPositiveButtonText = a.getString(R.styleable.DialogPreference_positiveButtonText);
|
||||
mNegativeButtonText = a.getString(R.styleable.DialogPreference_negativeButtonText);
|
||||
mDialogLayoutResId = a.getResourceId(R.styleable.DialogPreference_dialogLayout, mDialogLayoutResId);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title of the dialog. This will be shown on subsequent dialogs.
|
||||
*
|
||||
* @param dialogTitle The title.
|
||||
*/
|
||||
public void setDialogTitle(CharSequence dialogTitle) {
|
||||
mDialogTitle = dialogTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #setDialogTitle(CharSequence)
|
||||
* @param dialogTitleResId The dialog title as a resource.
|
||||
*/
|
||||
public void setDialogTitle(int dialogTitleResId) {
|
||||
setDialogTitle(getContext().getString(dialogTitleResId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title to be shown on subsequent dialogs.
|
||||
* @return The title.
|
||||
*/
|
||||
public CharSequence getDialogTitle() {
|
||||
return mDialogTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon of the dialog. This will be shown on subsequent dialogs.
|
||||
*
|
||||
* @param dialogIcon The icon, as a {@link Drawable}.
|
||||
*/
|
||||
public void setDialogIcon(Drawable dialogIcon) {
|
||||
mDialogIcon = dialogIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon (resource ID) of the dialog. This will be shown on
|
||||
* subsequent dialogs.
|
||||
*
|
||||
* @param dialogIconRes The icon, as a resource ID.
|
||||
*/
|
||||
public void setDialogIcon(@DrawableRes int dialogIconRes) {
|
||||
mDialogIcon = ContextCompat.getDrawable(getContext(), dialogIconRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon to be shown on subsequent dialogs.
|
||||
* @return The icon, as a {@link Drawable}.
|
||||
*/
|
||||
public Drawable getDialogIcon() {
|
||||
return mDialogIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text of the positive button of the dialog. This will be shown on
|
||||
* subsequent dialogs.
|
||||
*
|
||||
* @param positiveButtonText The text of the positive button.
|
||||
*/
|
||||
public void setPositiveButtonText(CharSequence positiveButtonText) {
|
||||
mPositiveButtonText = positiveButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #setPositiveButtonText(CharSequence)
|
||||
* @param positiveButtonTextResId The positive button text as a resource.
|
||||
*/
|
||||
public void setPositiveButtonText(@StringRes int positiveButtonTextResId) {
|
||||
setPositiveButtonText(getContext().getString(positiveButtonTextResId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text of the positive button to be shown on subsequent
|
||||
* dialogs.
|
||||
*
|
||||
* @return The text of the positive button.
|
||||
*/
|
||||
public CharSequence getPositiveButtonText() {
|
||||
return mPositiveButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text of the negative button of the dialog. This will be shown on
|
||||
* subsequent dialogs.
|
||||
*
|
||||
* @param negativeButtonText The text of the negative button.
|
||||
*/
|
||||
public void setNegativeButtonText(CharSequence negativeButtonText) {
|
||||
mNegativeButtonText = negativeButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #setNegativeButtonText(CharSequence)
|
||||
* @param negativeButtonTextResId The negative button text as a resource.
|
||||
*/
|
||||
public void setNegativeButtonText(@StringRes int negativeButtonTextResId) {
|
||||
setNegativeButtonText(getContext().getString(negativeButtonTextResId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text of the negative button to be shown on subsequent
|
||||
* dialogs.
|
||||
*
|
||||
* @return The text of the negative button.
|
||||
*/
|
||||
public CharSequence getNegativeButtonText() {
|
||||
return mNegativeButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the layout resource that is inflated as the {@link View} to be shown
|
||||
* as the content View of subsequent dialogs.
|
||||
*
|
||||
* @param dialogLayoutResId The layout resource ID to be inflated.
|
||||
*/
|
||||
public void setDialogLayoutResource(int dialogLayoutResId) {
|
||||
mDialogLayoutResId = dialogLayoutResId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the layout resource that is used as the content View for
|
||||
* subsequent dialogs.
|
||||
*
|
||||
* @return The layout resource.
|
||||
*/
|
||||
public int getDialogLayoutResource() {
|
||||
return mDialogLayoutResId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the dialog builder to be shown when the preference is clicked.
|
||||
* Use this to set custom properties on the dialog.
|
||||
* <p>
|
||||
* Do not {@link AlertDialog.Builder#create()} or
|
||||
* {@link AlertDialog.Builder#show()}.
|
||||
*/
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
if (mDialog != null && mDialog.isShowing()) return;
|
||||
|
||||
showDialog(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the dialog associated with this Preference. This is normally initiated
|
||||
* automatically on clicking on the preference. Call this method if you need to
|
||||
* show the dialog on some other event.
|
||||
*
|
||||
* @param state Optional instance state to restore on the dialog
|
||||
*/
|
||||
protected void showDialog(Bundle state) {
|
||||
Context context = getContext();
|
||||
|
||||
mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE;
|
||||
|
||||
mBuilder = new AlertDialog.Builder(context)
|
||||
.setTitle(mDialogTitle)
|
||||
.setIcon(mDialogIcon)
|
||||
.setPositiveButton(mPositiveButtonText, this)
|
||||
.setNegativeButton(mNegativeButtonText, this);
|
||||
|
||||
View contentView = onCreateDialogView();
|
||||
if (contentView != null) {
|
||||
onBindDialogView(contentView);
|
||||
mBuilder.setView(contentView);
|
||||
}
|
||||
|
||||
onPrepareDialogBuilder(mBuilder);
|
||||
|
||||
// Create the dialog
|
||||
final AlertDialog dialog = mDialog = mBuilder.create();
|
||||
if (state != null) {
|
||||
dialog.onRestoreInstanceState(state);
|
||||
}
|
||||
if (needInputMethod()) {
|
||||
requestInputMethod(dialog);
|
||||
}
|
||||
dialog.setOnDismissListener(this);
|
||||
dialog.show();
|
||||
|
||||
onDialogCreated(dialog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the preference needs to display a soft input method when the dialog
|
||||
* is displayed. Default is false. Subclasses should override this method if they need
|
||||
* the soft input method brought up automatically.
|
||||
*/
|
||||
protected boolean needInputMethod() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the required flags on the dialog window to enable input method window to show up.
|
||||
*/
|
||||
private void requestInputMethod(Dialog dialog) {
|
||||
Window window = dialog.getWindow();
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the content view for the dialog (if a custom content view is
|
||||
* required). By default, it inflates the dialog layout resource if it is
|
||||
* set.
|
||||
*
|
||||
* @return The content View for the dialog.
|
||||
* @see #setLayoutResource(int)
|
||||
*/
|
||||
protected View onCreateDialogView() {
|
||||
if (mDialogLayoutResId == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(mBuilder.getContext());
|
||||
return inflater.inflate(mDialogLayoutResId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds views in the content View of the dialog to data.
|
||||
*
|
||||
* @param view The content View of the dialog, if it is custom.
|
||||
*/
|
||||
protected void onBindDialogView(View view) {}
|
||||
|
||||
protected void onDialogCreated(AlertDialog dialog) {}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mWhichButtonClicked = which;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
mDialog = null;
|
||||
onDialogClosed(mWhichButtonClicked == DialogInterface.BUTTON_POSITIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the dialog is dismissed and should be used to save data to
|
||||
* the {@link SharedPreferences}.
|
||||
*
|
||||
* @param positiveResult Whether the positive button was clicked (true), or
|
||||
* the negative button was clicked or the dialog was canceled (false).
|
||||
*/
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dialog that is shown by this preference.
|
||||
*
|
||||
* @return The dialog, or null if a dialog is not being shown.
|
||||
*/
|
||||
public Dialog getDialog() {
|
||||
return mDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
final Parcelable superState = super.onSaveInstanceState();
|
||||
if (mDialog == null || !mDialog.isShowing()) {
|
||||
return superState;
|
||||
}
|
||||
|
||||
final Bundle myState = new Bundle();
|
||||
myState.putParcelable(KEY_SUPER, superState);
|
||||
myState.putBoolean(KEY_IS_DIALOG_SHOWING, true);
|
||||
myState.putBundle(KEY_DIALOG_BUNDLE, mDialog.onSaveInstanceState());
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (state == null || !state.getClass().equals(Bundle.class)) {
|
||||
// Didn't save state for us in onSaveInstanceState
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle myState = (Bundle) state;
|
||||
super.onRestoreInstanceState(myState.getParcelable(KEY_SUPER));
|
||||
if (myState.getBoolean(KEY_IS_DIALOG_SHOWING)) {
|
||||
showDialog(myState.getBundle(KEY_DIALOG_BUNDLE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* 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.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.ArrayRes;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
public class ListPreference extends DialogPreference {
|
||||
|
||||
private CharSequence[] mEntries;
|
||||
private CharSequence[] mEntryValues;
|
||||
private String mValue;
|
||||
private String mSummary;
|
||||
private int mClickedDialogEntryIndex;
|
||||
private boolean mValueSet;
|
||||
|
||||
public ListPreference(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0, 0);
|
||||
}
|
||||
|
||||
public ListPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0, 0);
|
||||
}
|
||||
|
||||
public ListPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
public ListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
setNegativeButtonText(android.R.string.cancel);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPreference, defStyleAttr, defStyleRes);
|
||||
mEntries = a.getTextArray(R.styleable.ListPreference_entries);
|
||||
mEntryValues = a.getTextArray(R.styleable.ListPreference_entryValues);
|
||||
a.recycle();
|
||||
|
||||
/* Retrieve the Preference summary attribute since it's private
|
||||
* in the Preference class.
|
||||
*/
|
||||
a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.summary}, defStyleAttr, defStyleRes);
|
||||
mSummary = a.getString(0);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the human-readable entries to be shown in the list. This will be
|
||||
* shown in subsequent dialogs.
|
||||
* <p>
|
||||
* Each entry must have a corresponding index in
|
||||
* {@link #setEntryValues(CharSequence[])}.
|
||||
*
|
||||
* @param entries The entries.
|
||||
* @see #setEntryValues(CharSequence[])
|
||||
*/
|
||||
public void setEntries(CharSequence[] entries) {
|
||||
mEntries = entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #setEntries(CharSequence[])
|
||||
* @param entriesResId The entries array as a resource.
|
||||
*/
|
||||
public void setEntries(@ArrayRes int entriesResId) {
|
||||
setEntries(getContext().getResources().getTextArray(entriesResId));
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of entries to be shown in the list in subsequent dialogs.
|
||||
*
|
||||
* @return The list as an array.
|
||||
*/
|
||||
public CharSequence[] getEntries() {
|
||||
return mEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* The array to find the value to save for a preference when an entry from
|
||||
* entries is selected. If a user clicks on the second item in entries, the
|
||||
* second item in this array will be saved to the preference.
|
||||
*
|
||||
* @param entryValues The array to be used as values to save for the preference.
|
||||
*/
|
||||
public void setEntryValues(CharSequence[] entryValues) {
|
||||
mEntryValues = entryValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #setEntryValues(CharSequence[])
|
||||
* @param entryValuesResId The entry values array as a resource.
|
||||
*/
|
||||
public void setEntryValues(@ArrayRes int entryValuesResId) {
|
||||
setEntryValues(getContext().getResources().getTextArray(entryValuesResId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of values to be saved for the preference.
|
||||
*
|
||||
* @return The array of values.
|
||||
*/
|
||||
public CharSequence[] getEntryValues() {
|
||||
return mEntryValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the key. This should be one of the entries in
|
||||
* {@link #getEntryValues()}.
|
||||
*
|
||||
* @param value The value to set for the key.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
// Always persist/notify the first time.
|
||||
final boolean changed = !TextUtils.equals(mValue, value);
|
||||
if (changed || !mValueSet) {
|
||||
mValue = value;
|
||||
mValueSet = true;
|
||||
persistString(value);
|
||||
if (changed) {
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the summary of this ListPreference. If the summary
|
||||
* has a {@linkplain java.lang.String#format String formatting}
|
||||
* marker in it (i.e. "%s" or "%1$s"), then the current entry
|
||||
* value will be substituted in its place.
|
||||
*
|
||||
* @return the summary with appropriate string substitution
|
||||
*/
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
final CharSequence entry = getEntry();
|
||||
if (mSummary == null) {
|
||||
return super.getSummary();
|
||||
} else {
|
||||
return String.format(mSummary, entry == null ? "" : entry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the summary for this Preference with a CharSequence.
|
||||
* If the summary has a
|
||||
* {@linkplain java.lang.String#format String formatting}
|
||||
* marker in it (i.e. "%s" or "%1$s"), then the current entry
|
||||
* value will be substituted in its place when it's retrieved.
|
||||
*
|
||||
* @param summary The summary for the preference.
|
||||
*/
|
||||
@Override
|
||||
public void setSummary(CharSequence summary) {
|
||||
super.setSummary(summary);
|
||||
if (summary == null && mSummary != null) {
|
||||
mSummary = null;
|
||||
} else if (summary != null && !summary.equals(mSummary)) {
|
||||
mSummary = summary.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value to the given index from the entry values.
|
||||
*
|
||||
* @param index The index of the value to set.
|
||||
*/
|
||||
public void setValueIndex(int index) {
|
||||
if (mEntryValues != null) {
|
||||
setValue(mEntryValues[index].toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the key. This should be one of the entries in
|
||||
* {@link #getEntryValues()}.
|
||||
*
|
||||
* @return The value of the key.
|
||||
*/
|
||||
public String getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entry corresponding to the current value.
|
||||
*
|
||||
* @return The entry corresponding to the current value, or null.
|
||||
*/
|
||||
public CharSequence getEntry() {
|
||||
int index = getValueIndex();
|
||||
return index >= 0 && mEntries != null ? mEntries[index] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the given value (in the entry values array).
|
||||
*
|
||||
* @param value The value whose index should be returned.
|
||||
* @return The index of the value, or -1 if not found.
|
||||
*/
|
||||
public int findIndexOfValue(String value) {
|
||||
if (value != null && mEntryValues != null) {
|
||||
for (int i = mEntryValues.length - 1; i >= 0; i--) {
|
||||
if (mEntryValues[i].equals(value)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int getValueIndex() {
|
||||
return findIndexOfValue(mValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
|
||||
if (mEntries == null || mEntryValues == null) {
|
||||
throw new IllegalStateException(
|
||||
"ListPreference requires an entries array and an entryValues array.");
|
||||
}
|
||||
|
||||
mClickedDialogEntryIndex = getValueIndex();
|
||||
builder.setSingleChoiceItems(mEntries, mClickedDialogEntryIndex,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mClickedDialogEntryIndex = which;
|
||||
|
||||
/*
|
||||
* Clicking on an item simulates the positive button
|
||||
* click, and dismisses the dialog.
|
||||
*/
|
||||
ListPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
super.onDialogClosed(positiveResult);
|
||||
|
||||
if (positiveResult && mClickedDialogEntryIndex >= 0 && mEntryValues != null) {
|
||||
String value = mEntryValues[mClickedDialogEntryIndex].toString();
|
||||
if (callChangeListener(value)) {
|
||||
setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||
return a.getString(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
|
||||
setValue(restoreValue ? getPersistedString(mValue) : (String) defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
final Parcelable superState = super.onSaveInstanceState();
|
||||
if (isPersistent()) {
|
||||
// No need to save instance state since it's persistent
|
||||
return superState;
|
||||
}
|
||||
|
||||
final SavedState myState = new SavedState(superState);
|
||||
myState.value = getValue();
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (state == null || !state.getClass().equals(SavedState.class)) {
|
||||
// Didn't save state for us in onSaveInstanceState
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
|
||||
SavedState myState = (SavedState) state;
|
||||
super.onRestoreInstanceState(myState.getSuperState());
|
||||
setValue(myState.value);
|
||||
}
|
||||
|
||||
private static class SavedState extends BaseSavedState {
|
||||
String value;
|
||||
|
||||
public SavedState(Parcel source) {
|
||||
super(source);
|
||||
value = source.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeString(value);
|
||||
}
|
||||
|
||||
public SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,59 +17,78 @@
|
||||
package com.hippo.preference;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.preference.DialogPreference;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.text.Html;
|
||||
|
||||
// TODO Add html attr
|
||||
// TODO Add url clickable
|
||||
public class SimpleDialogPreference extends DialogPreference {
|
||||
public class MessagePreference extends DialogPreference {
|
||||
|
||||
private CharSequence mMessage;
|
||||
private CharSequence mDialogMessage;
|
||||
private boolean mDialogMessageLinkify;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public SimpleDialogPreference(Context context) {
|
||||
public MessagePreference(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0, 0);
|
||||
}
|
||||
|
||||
public SimpleDialogPreference(Context context, AttributeSet attrs) {
|
||||
public MessagePreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0, 0);
|
||||
}
|
||||
|
||||
public SimpleDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
public MessagePreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public SimpleDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
public MessagePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SimpleDialogPreference, defStyleAttr, defStyleRes);
|
||||
setMessage(a.getString(R.styleable.SimpleDialogPreference_message));
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MessagePreference, defStyleAttr, defStyleRes);
|
||||
String message = a.getString(R.styleable.MessagePreference_dialogMessage);
|
||||
if (a.getBoolean(R.styleable.MessagePreference_dialogMessageHtml, false)) {
|
||||
mDialogMessage = Html.fromHtml(message);
|
||||
} else {
|
||||
mDialogMessage = message;
|
||||
}
|
||||
mDialogMessageLinkify = a.getBoolean(R.styleable.MessagePreference_dialogMessageLinkify, false);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
mMessage = Html.fromHtml(message);
|
||||
public void setDialogMessage(CharSequence message) {
|
||||
mDialogMessage = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
builder.setMessage(mMessage);
|
||||
builder.setMessage(mDialogMessage);
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.setNegativeButton(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogCreated(AlertDialog dialog) {
|
||||
super.onDialogCreated(dialog);
|
||||
|
||||
if (mDialogMessageLinkify) {
|
||||
final View messageView = dialog.findViewById(android.R.id.message);
|
||||
if (null != messageView && messageView instanceof TextView) {
|
||||
((TextView) messageView).setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import com.hippo.ehviewer.R;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class FixedSwitchPreference extends TwoStatePreference {
|
||||
public class SwitchPreference extends TwoStatePreference {
|
||||
|
||||
private static Method sSyncSummaryViewMethod;
|
||||
|
||||
@@ -63,38 +63,39 @@ public class FixedSwitchPreference extends TwoStatePreference {
|
||||
return;
|
||||
}
|
||||
|
||||
FixedSwitchPreference.this.setChecked(isChecked);
|
||||
SwitchPreference.this.setChecked(isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
public FixedSwitchPreference(Context context) {
|
||||
public SwitchPreference(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0, 0);
|
||||
}
|
||||
|
||||
public FixedSwitchPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
public SwitchPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs, android.R.attr.preferenceStyle);
|
||||
init(context, attrs, 0, 0);
|
||||
}
|
||||
|
||||
public FixedSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public FixedSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FixedSwitchPreference, defStyleAttr, defStyleRes);
|
||||
setSummaryOn(a.getString(R.styleable.FixedSwitchPreference_summaryOn));
|
||||
setSummaryOff(a.getString(R.styleable.FixedSwitchPreference_summaryOff));
|
||||
setSwitchTextOn(a.getString(R.styleable.FixedSwitchPreference_switchTextOn));
|
||||
setSwitchTextOff(a.getString(R.styleable.FixedSwitchPreference_switchTextOff));
|
||||
setDisableDependentsState(a.getBoolean(R.styleable.FixedSwitchPreference_disableDependentsState, false));
|
||||
setWidgetLayoutResource(R.layout.preference_widget_fixed_switch);
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwitchPreference, defStyleAttr, defStyleRes);
|
||||
setSummaryOn(a.getString(R.styleable.SwitchPreference_summaryOn));
|
||||
setSummaryOff(a.getString(R.styleable.SwitchPreference_summaryOff));
|
||||
setSwitchTextOn(a.getString(R.styleable.SwitchPreference_switchTextOn));
|
||||
setSwitchTextOff(a.getString(R.styleable.SwitchPreference_switchTextOff));
|
||||
setDisableDependentsState(a.getBoolean(R.styleable.SwitchPreference_disableDependentsState, false));
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.support.v4.app.FragmentActivity;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.yorozuya.IntList;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -87,7 +86,7 @@ public class SceneFragment extends Fragment {
|
||||
public int getStackIndex() {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof StageActivity) {
|
||||
return ((StageActivity) activity).getStackIndex(this);
|
||||
return ((StageActivity) activity).getSceneIndex(this);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -105,7 +104,7 @@ public class SceneFragment extends Fragment {
|
||||
view.setBackgroundColor(getContext().getResources().getColor(R.color.background_light));
|
||||
|
||||
// Notify
|
||||
((MainActivity) getActivity()).onSceneViewCreated(this, savedInstanceState);
|
||||
((StageActivity) getActivity()).onSceneViewCreated(this, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,7 +112,14 @@ public class SceneFragment extends Fragment {
|
||||
super.onDestroyView();
|
||||
|
||||
// Notify
|
||||
((MainActivity) getActivity()).onSceneViewDestroyed(this);
|
||||
((StageActivity) getActivity()).onSceneViewDestroyed(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
((StageActivity) getActivity()).onSceneDestroyed(this);
|
||||
}
|
||||
|
||||
void addRequest(String requestSceneTag, int requestCode) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.TrackedActivity;
|
||||
@@ -31,7 +32,10 @@ import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.IntIdGenerator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -48,11 +52,31 @@ public abstract class StageActivity extends TrackedActivity {
|
||||
private static final String KEY_SCENE_TAG_LIST = "stage_activity_scene_tag_list";
|
||||
private static final String KEY_NEXT_ID = "stage_activity_next_id";
|
||||
|
||||
private ArrayList<String> mSceneTagList = new ArrayList<>();
|
||||
private final ArrayList<String> mSceneTagList = new ArrayList<>();
|
||||
private final ArrayList<String> mDelaySceneTagList = new ArrayList<>();
|
||||
private final AtomicInteger mIdGenerator = new AtomicInteger();
|
||||
|
||||
private int mStageId = IntIdGenerator.INVALID_ID;
|
||||
|
||||
private final SceneViewComparator mSceneViewComparator = new SceneViewComparator();
|
||||
|
||||
private final class SceneViewComparator implements Comparator<View> {
|
||||
|
||||
private int getIndex(View view) {
|
||||
Object o = view.getTag(R.id.fragment_tag);
|
||||
if (o instanceof String) {
|
||||
return mDelaySceneTagList.indexOf(o);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(View lhs, View rhs) {
|
||||
return getIndex(lhs) - getIndex(rhs);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Class<?>, Integer> sLaunchModeMap = new HashMap<>();
|
||||
|
||||
public static void registerLaunchMode(Class<?> clazz, @SceneFragment.LaunchMode int launchMode) {
|
||||
@@ -138,7 +162,9 @@ public abstract class StageActivity extends TrackedActivity {
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mStageId = savedInstanceState.getInt(KEY_STAGE_ID, IntIdGenerator.INVALID_ID);
|
||||
mSceneTagList = savedInstanceState.getStringArrayList(KEY_SCENE_TAG_LIST);
|
||||
ArrayList<String> list = savedInstanceState.getStringArrayList(KEY_SCENE_TAG_LIST);
|
||||
mSceneTagList.addAll(list);
|
||||
mDelaySceneTagList.addAll(list);
|
||||
mIdGenerator.lazySet(savedInstanceState.getInt(KEY_NEXT_ID));
|
||||
}
|
||||
|
||||
@@ -193,6 +219,10 @@ public abstract class StageActivity extends TrackedActivity {
|
||||
public void onSceneViewDestroyed(SceneFragment scene) {
|
||||
}
|
||||
|
||||
void onSceneDestroyed(SceneFragment scene) {
|
||||
mDelaySceneTagList.remove(scene.getTag());
|
||||
}
|
||||
|
||||
protected void onRegister(int id) {
|
||||
mStageId = id;
|
||||
}
|
||||
@@ -321,6 +351,7 @@ public abstract class StageActivity extends TrackedActivity {
|
||||
|
||||
// Add new tag to list
|
||||
mSceneTagList.add(newTag);
|
||||
mDelaySceneTagList.add(newTag);
|
||||
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
// Animation
|
||||
@@ -420,6 +451,7 @@ public abstract class StageActivity extends TrackedActivity {
|
||||
|
||||
// Add tag to list
|
||||
mSceneTagList.add(tag);
|
||||
mDelaySceneTagList.add(tag);
|
||||
|
||||
// Add scene
|
||||
transaction.add(getContainerViewId(), scene, tag);
|
||||
@@ -434,19 +466,16 @@ public abstract class StageActivity extends TrackedActivity {
|
||||
}
|
||||
}
|
||||
|
||||
int getStackIndex(SceneFragment scene) {
|
||||
return getStackIndex(scene.getTag());
|
||||
int getSceneIndex(SceneFragment scene) {
|
||||
return getTagIndex(scene.getTag());
|
||||
}
|
||||
|
||||
int getStackIndex(String tag) {
|
||||
return mSceneTagList.indexOf(tag); // Collections.binarySearch(mSceneTagList, tag);
|
||||
int getTagIndex(String tag) {
|
||||
return mSceneTagList.indexOf(tag);
|
||||
}
|
||||
|
||||
// TODO What about id is negative
|
||||
int compareScene(String tag1, String tag2) throws NumberFormatException {
|
||||
int int1 = Integer.parseInt(tag1);
|
||||
int int2 = Integer.parseInt(tag2);
|
||||
return int1 - int2;
|
||||
void sortSceneViews(List<View> views) {
|
||||
Collections.sort(views, mSceneViewComparator);
|
||||
}
|
||||
|
||||
public void finishScene(SceneFragment scene) {
|
||||
@@ -468,7 +497,7 @@ public abstract class StageActivity extends TrackedActivity {
|
||||
}
|
||||
|
||||
// Get scene index
|
||||
int index = mSceneTagList.indexOf(tag);//Collections.binarySearch(mSceneTagList, tag);
|
||||
int index = mSceneTagList.indexOf(tag);
|
||||
if (index < 0) {
|
||||
Log.e(TAG, "finishScene: Can't find the tag in tag list: " + tag);
|
||||
return;
|
||||
|
||||
@@ -32,6 +32,7 @@ public class StageLayout extends FrameLayout {
|
||||
|
||||
private Field mDisappearingChildrenField;
|
||||
private ArrayList<View> mSuperDisappearingChildren;
|
||||
private ArrayList<View> mSortedScenes;
|
||||
private View mDumpView;
|
||||
private boolean mDoTrick;
|
||||
|
||||
@@ -77,23 +78,15 @@ public class StageLayout extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private String getViewTag(View view) {
|
||||
Object tag = view.getTag(R.id.fragment_tag);
|
||||
if (tag instanceof String) {
|
||||
return (String) tag;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean beforeDispatchDraw() {
|
||||
getSuperDisappearingChildren();
|
||||
|
||||
if (mSuperDisappearingChildren == null ||
|
||||
mSuperDisappearingChildren.size() <= 0 || getChildCount() <= 1) { // dump view
|
||||
mSuperDisappearingChildren.size() <= 0 || getChildCount() <= 1) { // only dump view
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get stage
|
||||
StageActivity stage = null;
|
||||
Context context = getContext();
|
||||
if (context instanceof StageActivity) {
|
||||
@@ -103,14 +96,34 @@ public class StageLayout extends FrameLayout {
|
||||
return false;
|
||||
}
|
||||
|
||||
View view1 = mSuperDisappearingChildren.get(0);
|
||||
View view2 = getChildAt(1); // Skip dump view
|
||||
String tag1 = getViewTag(view1);
|
||||
String tag2 = getViewTag(view2);
|
||||
try {
|
||||
return stage.compareScene(tag1, tag2) < 0;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
if (null == mSortedScenes) {
|
||||
mSortedScenes = new ArrayList<>();
|
||||
}
|
||||
|
||||
// Add all scene view to mSortedScenes
|
||||
ArrayList<View> disappearingChildren = mSuperDisappearingChildren;
|
||||
ArrayList<View> sortedScenes = mSortedScenes;
|
||||
for (int i = 1, n = getChildCount(); i < n; i++) { // Skip dump view
|
||||
View view = getChildAt(i);
|
||||
if (null != view.getTag(R.id.fragment_tag)) {
|
||||
sortedScenes.add(view);
|
||||
}
|
||||
}
|
||||
for (int i = 0, n = disappearingChildren.size(); i < n; i++) {
|
||||
View view = disappearingChildren.get(i);
|
||||
if (null != view.getTag(R.id.fragment_tag)) {
|
||||
sortedScenes.add(view);
|
||||
}
|
||||
}
|
||||
|
||||
stage.sortSceneViews(sortedScenes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void afterDispatchDraw() {
|
||||
if (null != mSortedScenes) {
|
||||
mSortedScenes.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,21 +131,21 @@ public class StageLayout extends FrameLayout {
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
mDoTrick = beforeDispatchDraw();
|
||||
super.dispatchDraw(canvas);
|
||||
afterDispatchDraw();
|
||||
mDoTrick = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
ArrayList<View> disappearingChildren = mSuperDisappearingChildren;
|
||||
|
||||
if (mDoTrick) {
|
||||
ArrayList<View> sortedScenes = mSortedScenes;
|
||||
if (child == mDumpView) {
|
||||
boolean more = false;
|
||||
for (int i = disappearingChildren.size() - 1; i >= 0; i--) {
|
||||
more |= super.drawChild(canvas, disappearingChildren.get(i), drawingTime);
|
||||
for (int i = 0, n = sortedScenes.size(); i < n; i++) {
|
||||
more |= super.drawChild(canvas, sortedScenes.get(i), drawingTime);
|
||||
}
|
||||
return more;
|
||||
} else if (disappearingChildren.contains(child)) {
|
||||
} else if (sortedScenes.contains(child)) {
|
||||
// Skip
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
|
||||
public final class LayoutUtils2 {
|
||||
|
||||
private static final Point sPoint = new Point();
|
||||
|
||||
private LayoutUtils2() {}
|
||||
|
||||
public static int calculateSpanCount(Context context, int minWidth) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
display.getSize(sPoint);
|
||||
int width = sPoint.x;
|
||||
return MathUtils.clamp(width / minWidth, 1, Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.util;
|
||||
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class LogCat {
|
||||
|
||||
private LogCat() {
|
||||
}
|
||||
|
||||
public static boolean save(File file) {
|
||||
if (!FileUtils.ensureFile(file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec("logcat -d");
|
||||
IOUtils.copy(p.getInputStream(), new FileOutputStream(file));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.hippo.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
@@ -35,6 +36,7 @@ import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.easyrecyclerview.HandlerDrawable;
|
||||
import com.hippo.easyrecyclerview.LayoutManagerUtils;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.refreshlayout.RefreshLayout;
|
||||
@@ -51,14 +53,12 @@ public class ContentLayout extends FrameLayout {
|
||||
private static final String TAG = ContentLayout.class.getSimpleName();
|
||||
|
||||
private ProgressView mProgressView;
|
||||
private ViewGroup mTipView;
|
||||
private TextView mTipView;
|
||||
private ViewGroup mContentView;
|
||||
|
||||
private RefreshLayout mRefreshLayout;
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
private FastScroller mFastScroller;
|
||||
private View mImageView;
|
||||
private TextView mTextView;
|
||||
|
||||
private ContentHelper mContentHelper;
|
||||
|
||||
@@ -84,14 +84,12 @@ public class ContentLayout extends FrameLayout {
|
||||
LayoutInflater.from(context).inflate(R.layout.widget_content_layout, this);
|
||||
|
||||
mProgressView = (ProgressView) findViewById(R.id.progress);
|
||||
mTipView = (ViewGroup) findViewById(R.id.tip);
|
||||
mTipView = (TextView) findViewById(R.id.tip);
|
||||
mContentView = (ViewGroup) findViewById(R.id.content_view);
|
||||
|
||||
mRefreshLayout = (RefreshLayout) mContentView.findViewById(R.id.refresh_layout);
|
||||
mFastScroller = (FastScroller) mContentView.findViewById(R.id.fast_scroller);
|
||||
mRecyclerView = (EasyRecyclerView) mRefreshLayout.findViewById(R.id.recycler_view);
|
||||
mImageView = mTipView.getChildAt(0);
|
||||
mTextView = (TextView) mTipView.getChildAt(1);
|
||||
|
||||
mFastScroller.attachToRecyclerView(mRecyclerView);
|
||||
HandlerDrawable drawable = new HandlerDrawable();
|
||||
@@ -124,6 +122,10 @@ public class ContentLayout extends FrameLayout {
|
||||
return mFastScroller;
|
||||
}
|
||||
|
||||
public RefreshLayout getRefreshLayout() {
|
||||
return mRefreshLayout;
|
||||
}
|
||||
|
||||
public void setHelper(ContentHelper helper) {
|
||||
mContentHelper = helper;
|
||||
helper.init(this);
|
||||
@@ -190,13 +192,11 @@ public class ContentLayout extends FrameLayout {
|
||||
public static final int REFRESH_TYPE_PROGRESS_VIEW = 2;
|
||||
|
||||
private ProgressView mProgressView;
|
||||
private ViewGroup mTipView;
|
||||
private TextView mTipView;
|
||||
private ViewGroup mContentView;
|
||||
|
||||
private RefreshLayout mRefreshLayout;
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
private View mImageView;
|
||||
private TextView mTextView;
|
||||
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
@@ -303,11 +303,12 @@ public class ContentLayout extends FrameLayout {
|
||||
|
||||
mRefreshLayout = contentLayout.mRefreshLayout;
|
||||
mRecyclerView = contentLayout.mRecyclerView;
|
||||
mImageView = contentLayout.mImageView;
|
||||
mTextView = contentLayout.mTextView;
|
||||
|
||||
Drawable drawable = DrawableManager.getDrawable(getContext(), R.drawable.big_weird_face);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
mTipView.setCompoundDrawables(null, drawable, null, null);
|
||||
|
||||
mViewTransition = new ViewTransition(mContentView, mProgressView, mTipView);
|
||||
mViewTransition.showView(2, false);
|
||||
|
||||
mRecyclerView.addOnScrollListener(mOnScrollListener);
|
||||
mRefreshLayout.setOnRefreshListener(mOnRefreshListener);
|
||||
@@ -342,6 +343,10 @@ public class ContentLayout extends FrameLayout {
|
||||
protected void onHideRecyclerView() {
|
||||
}
|
||||
|
||||
public int getShownViewIndex() {
|
||||
return mViewTransition.getShownViewIndex();
|
||||
}
|
||||
|
||||
public void setRefreshLayoutEnable(boolean enable) {
|
||||
mRefreshLayout.setEnabled(enable);
|
||||
}
|
||||
@@ -542,7 +547,7 @@ public class ContentLayout extends FrameLayout {
|
||||
mRefreshLayout.setFooterRefreshing(false);
|
||||
}
|
||||
|
||||
public void onGetExpection(int taskId, Exception e) {
|
||||
public void onGetException(int taskId, Exception e) {
|
||||
if (mCurrentTaskId == taskId) {
|
||||
mRefreshLayout.setHeaderRefreshing(false);
|
||||
mRefreshLayout.setFooterRefreshing(false);
|
||||
@@ -582,7 +587,7 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
|
||||
public void showText(CharSequence text) {
|
||||
mTextView.setText(text);
|
||||
mTipView.setText(text);
|
||||
if (mViewTransition.showView(2)) {
|
||||
onHideRecyclerView();
|
||||
}
|
||||
@@ -692,7 +697,7 @@ public class ContentLayout extends FrameLayout {
|
||||
/**
|
||||
* Check range first!
|
||||
*
|
||||
* @param page the targe page
|
||||
* @param page the target page
|
||||
* @throws IndexOutOfBoundsException
|
||||
*/
|
||||
public void goTo(int page) throws IndexOutOfBoundsException {
|
||||
@@ -737,14 +742,7 @@ public class ContentLayout extends FrameLayout {
|
||||
bundle.putParcelable(KEY_SUPER, superState);
|
||||
int shownView = mViewTransition.getShownViewIndex();
|
||||
bundle.putInt(KEY_SHOWN_VIEW, shownView);
|
||||
String tip;
|
||||
if (shownView == 2) {
|
||||
// It is progress view
|
||||
tip = getContext().getResources().getString(R.string.content_layout_restore_tip);
|
||||
} else {
|
||||
tip = mTextView.getText().toString();
|
||||
}
|
||||
bundle.putString(KEY_TIP, tip);
|
||||
bundle.putString(KEY_TIP, mTipView.getText().toString());
|
||||
// TODO What if data is large
|
||||
bundle.putParcelableArrayList(KEY_DATA, mData);
|
||||
bundle.putInt(KEY_NEXT_ID, mIdGenerator.nextId());
|
||||
@@ -758,12 +756,8 @@ public class ContentLayout extends FrameLayout {
|
||||
private Parcelable restoreInstanceState(Parcelable state) {
|
||||
if (state instanceof Bundle) {
|
||||
Bundle bundle = (Bundle) state;
|
||||
int shownView = bundle.getInt(KEY_SHOWN_VIEW);
|
||||
if (shownView != 0) {
|
||||
shownView = 2;
|
||||
}
|
||||
mViewTransition.showView(shownView, false);
|
||||
mTextView.setText(bundle.getString(KEY_TIP));
|
||||
mViewTransition.showView(bundle.getInt(KEY_SHOWN_VIEW), false);
|
||||
mTipView.setText(bundle.getString(KEY_TIP));
|
||||
mData = bundle.getParcelableArrayList(KEY_DATA);
|
||||
mIdGenerator.setNextId(bundle.getInt(KEY_NEXT_ID));
|
||||
mPageDivider = bundle.getParcelable(KEY_PAGE_DIVIDER);
|
||||
|
||||
@@ -26,13 +26,8 @@ import android.view.View;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
|
||||
/**
|
||||
* aspect is width / height
|
||||
*/
|
||||
public class FixedAspectImageView extends AppCompatImageView {
|
||||
|
||||
private static final String TAG = FixedAspectImageView.class.getSimpleName();
|
||||
|
||||
private static final int[] MIN_ATTRS = {
|
||||
android.R.attr.minWidth,
|
||||
android.R.attr.minHeight
|
||||
@@ -50,20 +45,26 @@ public class FixedAspectImageView extends AppCompatImageView {
|
||||
private int mMaxHeight = Integer.MAX_VALUE;
|
||||
private boolean mAdjustViewBounds = false;
|
||||
|
||||
// width / height
|
||||
private float mAspect = -1f;
|
||||
|
||||
public FixedAspectImageView(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0);
|
||||
}
|
||||
|
||||
public FixedAspectImageView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0);
|
||||
}
|
||||
|
||||
public FixedAspectImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResourceType")
|
||||
public FixedAspectImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyle) {
|
||||
TypedArray a;
|
||||
|
||||
// Make sure we get value from xml
|
||||
@@ -114,10 +115,6 @@ public class FixedAspectImageView extends AppCompatImageView {
|
||||
mAdjustViewBounds = adjustViewBounds;
|
||||
}
|
||||
|
||||
public boolean isAdjustViewBounds() {
|
||||
return mAdjustViewBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable aspect will set AdjustViewBounds true.
|
||||
* Any negative float to disable it,
|
||||
@@ -128,7 +125,6 @@ public class FixedAspectImageView extends AppCompatImageView {
|
||||
public void setAspect(float ratio) {
|
||||
if (ratio > 0) {
|
||||
mAspect = ratio;
|
||||
setAdjustViewBounds(true);
|
||||
} else {
|
||||
mAspect = -1f;
|
||||
}
|
||||
@@ -208,7 +204,8 @@ public class FixedAspectImageView extends AppCompatImageView {
|
||||
// If no drawable, its intrinsic size is 0.
|
||||
w = h = 0;
|
||||
|
||||
if (mAdjustViewBounds && mAspect > 0.0f) {
|
||||
// Aspect is forced set.
|
||||
if (mAspect > 0.0f) {
|
||||
resizeWidth = widthSpecMode != MeasureSpec.EXACTLY;
|
||||
resizeHeight = heightSpecMode != MeasureSpec.EXACTLY;
|
||||
desiredAspect = mAspect;
|
||||
@@ -219,20 +216,24 @@ public class FixedAspectImageView extends AppCompatImageView {
|
||||
if (w <= 0) w = 1;
|
||||
if (h <= 0) h = 1;
|
||||
|
||||
// We are supposed to adjust view bounds to match the aspect
|
||||
// ratio of our drawable. See if that is possible.
|
||||
if (mAdjustViewBounds) {
|
||||
// We are supposed to adjust view bounds to match the aspect
|
||||
// ratio of our drawable. See if that is possible.
|
||||
resizeWidth = widthSpecMode != MeasureSpec.EXACTLY;
|
||||
resizeHeight = heightSpecMode != MeasureSpec.EXACTLY;
|
||||
|
||||
desiredAspect = mAspect <= 0.0f ? ((float) w / (float) h) : mAspect;
|
||||
desiredAspect = (float) w / (float) h;
|
||||
} else if (mAspect > 0.0f) {
|
||||
// Aspect is forced set.
|
||||
resizeWidth = widthSpecMode != MeasureSpec.EXACTLY;
|
||||
resizeHeight = heightSpecMode != MeasureSpec.EXACTLY;
|
||||
desiredAspect = mAspect;
|
||||
}
|
||||
}
|
||||
|
||||
int pleft = getPaddingLeft();
|
||||
int pright = getPaddingRight();
|
||||
int ptop = getPaddingTop();
|
||||
int pbottom = getPaddingBottom();
|
||||
int pLeft = getPaddingLeft();
|
||||
int pRight = getPaddingRight();
|
||||
int pTop = getPaddingTop();
|
||||
int pBottom = getPaddingBottom();
|
||||
|
||||
int widthSize;
|
||||
int heightSize;
|
||||
@@ -243,23 +244,23 @@ public class FixedAspectImageView extends AppCompatImageView {
|
||||
// least one dimension.
|
||||
|
||||
// Get the max possible width given our constraints
|
||||
widthSize = resolveAdjustedSize(w + pleft + pright, mMinWidth, mMaxWidth, widthMeasureSpec);
|
||||
widthSize = resolveAdjustedSize(w + pLeft + pRight, mMinWidth, mMaxWidth, widthMeasureSpec);
|
||||
|
||||
// Get the max possible height given our constraints
|
||||
heightSize = resolveAdjustedSize(h + ptop + pbottom, mMinHeight, mMaxHeight, heightMeasureSpec);
|
||||
heightSize = resolveAdjustedSize(h + pTop + pBottom, mMinHeight, mMaxHeight, heightMeasureSpec);
|
||||
|
||||
if (desiredAspect != 0.0f) {
|
||||
// See what our actual aspect ratio is
|
||||
float actualAspect = (float)(widthSize - pleft - pright) /
|
||||
(heightSize - ptop - pbottom);
|
||||
float actualAspect = (float)(widthSize - pLeft - pRight) /
|
||||
(heightSize - pTop - pBottom);
|
||||
|
||||
if (Math.abs(actualAspect - desiredAspect) > 0.0000001) {
|
||||
boolean done = false;
|
||||
|
||||
// Try adjusting width to be proportional to height
|
||||
if (resizeWidth) {
|
||||
int newWidth = (int)(desiredAspect * (heightSize - ptop - pbottom)) +
|
||||
pleft + pright;
|
||||
int newWidth = (int)(desiredAspect * (heightSize - pTop - pBottom)) +
|
||||
pLeft + pRight;
|
||||
|
||||
// Allow the width to outgrow its original estimate if height is fixed.
|
||||
//if (!resizeHeight) {
|
||||
@@ -274,8 +275,8 @@ public class FixedAspectImageView extends AppCompatImageView {
|
||||
|
||||
// Try adjusting height to be proportional to width
|
||||
if (!done && resizeHeight) {
|
||||
int newHeight = (int)((widthSize - pleft - pright) / desiredAspect) +
|
||||
ptop + pbottom;
|
||||
int newHeight = (int)((widthSize - pLeft - pRight) / desiredAspect) +
|
||||
pTop + pBottom;
|
||||
|
||||
// Allow the height to outgrow its original estimate if width is fixed.
|
||||
if (!resizeWidth) {
|
||||
@@ -293,8 +294,8 @@ public class FixedAspectImageView extends AppCompatImageView {
|
||||
// We are either don't want to preserve the drawables aspect ratio,
|
||||
// or we are not allowed to change view dimensions. Just measure in
|
||||
// the normal way.
|
||||
w += pleft + pright;
|
||||
h += ptop + pbottom;
|
||||
w += pLeft + pRight;
|
||||
h += pTop + pBottom;
|
||||
|
||||
w = Math.max(w, getSuggestedMinimumWidth());
|
||||
h = Math.max(h, getSuggestedMinimumHeight());
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class SensitiveCheckBox extends AppCompatCheckBox {
|
||||
|
||||
private boolean mFromUser;
|
||||
|
||||
private OnCheckedChangeListener mOnCheckedChangeListener;
|
||||
|
||||
public SensitiveCheckBox(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SensitiveCheckBox(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SensitiveCheckBox(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performClick() {
|
||||
boolean result;
|
||||
|
||||
mFromUser = true;
|
||||
result = super.performClick();
|
||||
mFromUser = false;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setOnCheckedChangeListener(OnCheckedChangeListener listener) {
|
||||
mOnCheckedChangeListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
super.setChecked(checked);
|
||||
|
||||
if (mOnCheckedChangeListener != null) {
|
||||
mOnCheckedChangeListener.onCheckedChanged(this, checked, mFromUser);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when the checked state
|
||||
* of a compound button changed.
|
||||
*/
|
||||
public interface OnCheckedChangeListener {
|
||||
/**
|
||||
* Called when the checked state of a compound button has changed.
|
||||
*
|
||||
* @param view The sensitive check box view whose state has changed.
|
||||
* @param isChecked The new checked state of buttonView.
|
||||
* @param fromUser True if the rating change was initiated by a user's
|
||||
* touch gesture.
|
||||
*/
|
||||
void onCheckedChanged(SensitiveCheckBox view, boolean isChecked, boolean fromUser);
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* 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.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public class SimpleImageView extends View implements Drawable.Callback {
|
||||
|
||||
private Drawable mDrawable;
|
||||
|
||||
private static final int[] LAYOUT_ATTRS = new int[] {
|
||||
android.R.attr.src
|
||||
};
|
||||
|
||||
public SimpleImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public SimpleImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
|
||||
setDrawable(a.getDrawable(0));
|
||||
a.recycle();
|
||||
|
||||
// Mostly drawable is VectorDrawable, it has cache already
|
||||
setWillNotCacheDrawing(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setDrawable(@DrawableRes int resId) {
|
||||
setDrawable(getContext().getResources().getDrawable(resId));
|
||||
}
|
||||
|
||||
public void setDrawable(Drawable drawable) {
|
||||
if (mDrawable != null) {
|
||||
mDrawable.setCallback(null);
|
||||
}
|
||||
mDrawable = drawable;
|
||||
if (drawable != null) {
|
||||
drawable.setCallback(this);
|
||||
if (drawable.isStateful()) {
|
||||
drawable.setState(getDrawableState());
|
||||
}
|
||||
}
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawableStateChanged() {
|
||||
super.drawableStateChanged();
|
||||
Drawable d = mDrawable;
|
||||
if (d != null && d.isStateful()) {
|
||||
d.setState(getDrawableState());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateDrawable(@NonNull Drawable who) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSuggestedMinimumWidth() {
|
||||
int superMinWidth = super.getSuggestedMinimumWidth();
|
||||
return (mDrawable == null) ? superMinWidth :
|
||||
Math.max(superMinWidth, mDrawable.getMinimumWidth() + getPaddingLeft() + getPaddingRight());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSuggestedMinimumHeight() {
|
||||
int superMinHeight = super.getSuggestedMinimumHeight();
|
||||
return (mDrawable == null) ? superMinHeight :
|
||||
Math.max(superMinHeight, mDrawable.getMinimumHeight() + getPaddingTop() + getPaddingBottom());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(ViewUtils.getSuitableSize(getSuggestedMinimumWidth(), widthMeasureSpec),
|
||||
ViewUtils.getSuitableSize(getSuggestedMinimumHeight(), heightMeasureSpec));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
int width = right - left;
|
||||
int height = bottom - top;
|
||||
if (mDrawable != null) {
|
||||
mDrawable.setBounds(getPaddingLeft(), getPaddingTop(),
|
||||
width - getPaddingRight(), height - getPaddingBottom());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (mDrawable != null) {
|
||||
mDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -584,6 +584,10 @@ public class RefreshLayout extends ViewGroup {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
public void setHeaderTranslationY(float translationY) {
|
||||
mCircleView.setTranslationY(translationY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background color of the progress spinner disc.
|
||||
*
|
||||
|
||||
|
After Width: | Height: | Size: 114 B |
|
After Width: | Height: | Size: 116 B |
|
After Width: | Height: | Size: 100 B |
|
After Width: | Height: | Size: 102 B |
|
After Width: | Height: | Size: 127 B |
|
After Width: | Height: | Size: 129 B |
|
After Width: | Height: | Size: 155 B |
|
After Width: | Height: | Size: 156 B |
@@ -15,7 +15,15 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Avoid bitmap cache -->
|
||||
<animated-vector
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/big_download_internal"/>
|
||||
android:height="120dp"
|
||||
android:width="120dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/big_icon"
|
||||
android:pathData="@string/pd_big_download"/>
|
||||
|
||||
</vector>
|
||||
@@ -15,7 +15,15 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Avoid bitmap cache -->
|
||||
<animated-vector
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/big_history_internal"/>
|
||||
android:height="120dp"
|
||||
android:width="120dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/big_icon"
|
||||
android:pathData="@string/pd_big_history"/>
|
||||
|
||||
</vector>
|
||||
@@ -15,7 +15,15 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Avoid bitmap cache -->
|
||||
<animated-vector
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/big_label_internal"/>
|
||||
android:height="120dp"
|
||||
android:width="120dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/big_icon"
|
||||
android:pathData="@string/pd_big_label"/>
|
||||
|
||||
</vector>
|
||||
@@ -15,7 +15,15 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Avoid bitmap cache -->
|
||||
<animated-vector
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/big_search_internal"/>
|
||||
android:height="120dp"
|
||||
android:width="120dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/big_icon"
|
||||
android:pathData="@string/pd_big_search"/>
|
||||
|
||||
</vector>
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
<path
|
||||
android:fillColor="@color/big_icon"
|
||||
android:pathData="@string/pd_big_download"/>
|
||||
android:pathData="@string/pd_big_weird_face"/>
|
||||
|
||||
</vector>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2016 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="168dp"
|
||||
android:width="168dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@android:color/black"
|
||||
android:pathData="@string/pd_sad_panda"/>
|
||||
|
||||
</vector>
|
||||
@@ -15,7 +15,10 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Avoid bitmap cache -->
|
||||
<animated-vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/sad_panda_internal"/>
|
||||
<selector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_activated="true" android:drawable="@drawable/tile_background_activated"/>
|
||||
<item android:drawable="@drawable/transparent"/>
|
||||
|
||||
</selector>
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="120dp"
|
||||
android:width="120dp"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/big_icon"
|
||||
android:pathData="@string/pd_big_label"/>
|
||||
android:fillColor="?attr/colorPrimary"
|
||||
android:pathData="@string/pd_adb"/>
|
||||
|
||||
</vector>
|
||||
@@ -15,15 +15,13 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector
|
||||
<Button
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="120dp"
|
||||
android:width="120dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/big_icon"
|
||||
android:pathData="@string/pd_big_history"/>
|
||||
|
||||
</vector>
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/get_it"
|
||||
android:textStyle="bold"
|
||||
android:background="@null"
|
||||
android:textSize="@dimen/text_little_small"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@android:color/white"/>
|
||||
@@ -79,21 +79,26 @@
|
||||
android:paddingRight="8dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/start"
|
||||
<FrameLayout
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/v_play_x24"/>
|
||||
android:layout_marginRight="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/stop"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/v_pause_x24"/>
|
||||
<ImageView
|
||||
android:id="@+id/start"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/v_play_x24"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/stop"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/v_pause_x24"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete"
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColor="@color/primary_text_light"/>
|
||||
|
||||
<com.hippo.widget.SensitiveCheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<com.hippo.widget.SensitiveCheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<com.hippo.widget.SensitiveCheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:foreground="@drawable/tile_background">
|
||||
|
||||
<com.hippo.widget.LoadImageView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/thumb"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="@color/grey_300"
|
||||
app:aspect="0.67"
|
||||
app:retryType="none"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="top|right"/>
|
||||
|
||||
<TextView
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/simple_language"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|right"
|
||||
android:layout_marginRight="2dp"
|
||||
android:textSize="10dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textStyle="bold"
|
||||
tools:ignore="SpUsage"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -17,7 +17,7 @@
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/card_background">
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
android:id="@+id/thumb"
|
||||
android:layout_width="@dimen/list_thumb_width"
|
||||
android:layout_height="@dimen/list_thumb_height"
|
||||
app:retryType="click"/>
|
||||
app:retryType="none"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
||||
@@ -32,7 +32,18 @@
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/keyline_margin"/>
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginBottom="48dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/display_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textSize="@dimen/text_small"
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -15,8 +15,20 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<View
|
||||
|
||||
<com.hippo.widget.IndicatingScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/Indicating"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider"/>
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<com.hippo.ehviewer.widget.CategoryTable
|
||||
android:id="@+id/category_table"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="?attr/dialogPreferredPadding"
|
||||
android:paddingTop="@dimen/abc_dialog_padding_top_material"
|
||||
android:paddingRight="?attr/dialogPreferredPadding"/>
|
||||
|
||||
</com.hippo.widget.IndicatingScrollView>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<com.hippo.widget.IndicatingScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="@style/Indicating"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/table_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="?attr/dialogPreferredPadding"
|
||||
android:paddingTop="@dimen/abc_dialog_padding_top_material"
|
||||
android:paddingRight="?attr/dialogPreferredPadding">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_group_reclass"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="reclass"
|
||||
tools:ignore="HardcodedText"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_group_language"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="language"
|
||||
tools:ignore="HardcodedText"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_group_parody"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="parody"
|
||||
tools:ignore="HardcodedText"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_group_character"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="character"
|
||||
tools:ignore="HardcodedText"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_group_group"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="group"
|
||||
tools:ignore="HardcodedText"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_group_artist"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="artist"
|
||||
tools:ignore="HardcodedText"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_group_male"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="male"
|
||||
tools:ignore="HardcodedText"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tag_group_female"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="female"
|
||||
tools:ignore="HardcodedText"/>
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
</com.hippo.widget.IndicatingScrollView>
|
||||
@@ -28,12 +28,13 @@
|
||||
android:padding="@dimen/keyline_margin"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.hippo.widget.SimpleImageView
|
||||
<ImageView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="@dimen/keyline_margin"
|
||||
android:src="@drawable/v_cookie_brown_x48"/>
|
||||
app:srcCompat="@drawable/v_cookie_brown_x48"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<?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="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/keyline_margin"
|
||||
android:paddingRight="@dimen/keyline_margin"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cancel"
|
||||
style="@style/ButtonInCard.Accent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@android:string/cancel"/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@color/divider"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ok"
|
||||
style="@style/ButtonInCard.Accent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@android:string/ok"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/keyline_margin"
|
||||
android:paddingRight="@dimen/keyline_margin"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_all"
|
||||
style="@style/ButtonInCard"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/select_all"/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@color/divider"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/deselect_all"
|
||||
style="@style/ButtonInCard"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/deselect_all"/>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@color/divider"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/invert_selection"
|
||||
style="@style/ButtonInCard"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/invert_selection"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/keyline_margin"
|
||||
android:paddingRight="@dimen/keyline_margin"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/language"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/original"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/translated"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/rewrite"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="@dimen/keyline_margin"
|
||||
android:layout_marginRight="@dimen/keyline_margin"
|
||||
android:background="@color/divider"/>
|
||||
|
||||
<com.hippo.easyrecyclerview.EasyRecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:paddingLeft="@dimen/keyline_margin"
|
||||
android:paddingRight="@dimen/keyline_margin"
|
||||
android:paddingBottom="8dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -15,19 +15,12 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.hippo.ehviewer.widget.FitPaddingLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:content1="@+id/recycler_view"
|
||||
app:fitTop1="@+id/search_bar"
|
||||
app:content2="@+id/fast_scroller"
|
||||
app:fitTop2="@+id/search_bar"
|
||||
app:content3="@+id/search_layout"
|
||||
app:fitTop3="@+id/search_bar"
|
||||
app:once="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.hippo.widget.ContentLayout
|
||||
android:id="@+id/content_layout"
|
||||
@@ -71,4 +64,4 @@
|
||||
app:srcCompat="@drawable/v_close_dark_x24"/>
|
||||
|
||||
</com.hippo.widget.FabLayout>
|
||||
</com.hippo.ehviewer.widget.FitPaddingLayout>
|
||||
</FrameLayout>
|
||||
@@ -15,48 +15,28 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.hippo.ehviewer.widget.FitPaddingLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:content1="@+id/recycler_view"
|
||||
app:fitBottom1="@+id/fab"
|
||||
app:once="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.hippo.easyrecyclerview.EasyRecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/corner_fab_margin"
|
||||
android:clipToPadding="false"/>
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/tip"
|
||||
android:layout_width="240dp"
|
||||
android:layout_width="228dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="168dp"
|
||||
android:layout_height="168dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/sad_panda"/>
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.AppCompat.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@string/no_one_comments_gallery"/>
|
||||
|
||||
</LinearLayout>
|
||||
android:gravity="center_horizontal"
|
||||
android:drawablePadding="16dp"
|
||||
android:text="@string/no_one_comments_gallery"
|
||||
style="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/edit_panel"
|
||||
@@ -98,14 +78,19 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
style="@style/Widget.Design.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right|bottom"
|
||||
android:layout_marginRight="@dimen/corner_fab_margin"
|
||||
android:layout_marginBottom="@dimen/corner_fab_margin"
|
||||
app:srcCompat="@drawable/v_reply_dark_x24"/>
|
||||
<com.hippo.widget.FabLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingRight="@dimen/corner_fab_margin"
|
||||
android:paddingBottom="@dimen/corner_fab_margin">
|
||||
|
||||
</com.hippo.ehviewer.widget.FitPaddingLayout>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/v_reply_dark_x24"
|
||||
style="@style/Widget.Design.FloatingActionButton"/>
|
||||
|
||||
</com.hippo.widget.FabLayout>
|
||||
</FrameLayout>
|
||||
@@ -40,29 +40,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/tip"
|
||||
android:layout_width="240dp"
|
||||
android:layout_width="228dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
android:gravity="center_horizontal"
|
||||
android:drawablePadding="16dp"
|
||||
android:text="@string/no_one_comments_gallery"
|
||||
style="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
<ImageView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="168dp"
|
||||
android:layout_height="168dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/sad_panda"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tip_text"
|
||||
style="@style/TextAppearance.AppCompat.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
@@ -15,20 +15,12 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.hippo.ehviewer.widget.FitPaddingLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:content1="@+id/recycler_view"
|
||||
app:fitTop1="@+id/search_bar"
|
||||
app:content2="@+id/fast_scroller"
|
||||
app:fitTop2="@+id/search_bar"
|
||||
app:content3="@+id/search_layout"
|
||||
app:fitTop3="@+id/search_bar"
|
||||
app:fitBottom3="@+id/fab"
|
||||
app:once="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.hippo.widget.ContentLayout
|
||||
android:id="@+id/content_layout"
|
||||
@@ -48,15 +40,20 @@
|
||||
android:layout_marginRight="@dimen/list_search_bar_margin"
|
||||
android:layout_marginTop="8dp"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
style="@style/Widget.Design.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right|bottom"
|
||||
android:layout_marginRight="@dimen/corner_fab_margin"
|
||||
android:layout_marginBottom="@dimen/corner_fab_margin"
|
||||
android:visibility="invisible"
|
||||
app:srcCompat="@drawable/v_magnify_dark_x24"/>
|
||||
<com.hippo.widget.FabLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingRight="@dimen/corner_fab_margin"
|
||||
android:paddingBottom="@dimen/corner_fab_margin">
|
||||
|
||||
</com.hippo.ehviewer.widget.FitPaddingLayout>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"
|
||||
app:srcCompat="@drawable/v_magnify_dark_x24"
|
||||
style="@style/Widget.Design.FloatingActionButton"/>
|
||||
|
||||
</com.hippo.widget.FabLayout>
|
||||
</FrameLayout>
|
||||
@@ -33,7 +33,7 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/keyline_margin">
|
||||
|
||||
<com.hippo.widget.SimpleImageView
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
|
||||
@@ -27,30 +27,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/tip"
|
||||
android:layout_width="240dp"
|
||||
android:layout_width="228dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="168dp"
|
||||
android:layout_height="168dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/sad_panda"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tip_text"
|
||||
style="@style/TextAppearance.AppCompat.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
android:gravity="center_horizontal"
|
||||
android:drawablePadding="16dp"
|
||||
android:text="@string/no_one_comments_gallery"
|
||||
style="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -25,30 +25,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/tip"
|
||||
android:layout_width="240dp"
|
||||
android:layout_width="228dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="168dp"
|
||||
android:layout_height="168dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/sad_panda"/>
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.AppCompat.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
android:gravity="center_horizontal"
|
||||
android:drawablePadding="16dp"
|
||||
style="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content_view"
|
||||
|
||||