mirror of
https://github.com/seven332/EhViewer
synced 2026-11-30 11:08:04 +08:00
Compare commits
54
Commits
1.0.6
...
feature/dict
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1cac3c1ac | ||
|
|
fbeaf3d5ea | ||
|
|
b4d8168457 | ||
|
|
9561fcf662 | ||
|
|
453a56aa23 | ||
|
|
df108f9678 | ||
|
|
a835ca9547 | ||
|
|
3f4cc46bc1 | ||
|
|
27bc38ae8b | ||
|
|
fd1aca48d6 | ||
|
|
adbb1f11a5 | ||
|
|
4b8e46d220 | ||
|
|
1c45c4b042 | ||
|
|
d33e3c27fc | ||
|
|
189a95e49c | ||
|
|
4e3717fa69 | ||
|
|
97d51b1fc3 | ||
|
|
ba5a554ca8 | ||
|
|
b4095449c1 | ||
|
|
05f9ce59f3 | ||
|
|
793dca3674 | ||
|
|
e10172c09c | ||
|
|
2d65b71fff | ||
|
|
7693275967 | ||
|
|
9d4eadffac | ||
|
|
1bf826a923 | ||
|
|
3924de80b7 | ||
|
|
dc1e327caa | ||
|
|
84808429cf | ||
|
|
766c265cd6 | ||
|
|
4cce07e0aa | ||
|
|
e56467dd4d | ||
|
|
90c0d832d7 | ||
|
|
729bef38fb | ||
|
|
59aab0498e | ||
|
|
863170e013 | ||
|
|
e62b86bf7d | ||
|
|
0e018581a0 | ||
|
|
a19f1e2d6d | ||
|
|
987ef9ecf4 | ||
|
|
3de272ae5e | ||
|
|
247bbec87d | ||
|
|
e839c1e9b5 | ||
|
|
d756b0e451 | ||
|
|
663cb2b5b6 | ||
|
|
3e16c02e50 | ||
|
|
80ca110702 | ||
|
|
5f6a589dd8 | ||
|
|
342028eef1 | ||
|
|
0e96ee7eeb | ||
|
|
3bd52e00d9 | ||
|
|
f612c912a7 | ||
|
|
5dee677ce3 | ||
|
|
19ab3adc9a |
No files matched your search
@@ -1,9 +1,6 @@
|
||||
[submodule "yorozuya"]
|
||||
path = yorozuya
|
||||
url = https://github.com/seven332/Yorozuya
|
||||
[submodule "hotspot"]
|
||||
path = hotspot
|
||||
url = https://github.com/seven332/Hotspot
|
||||
[submodule "easyrecyclerview"]
|
||||
path = easyrecyclerview
|
||||
url = https://github.com/seven332/EasyRecyclerView
|
||||
@@ -13,9 +10,3 @@
|
||||
[submodule "conaco"]
|
||||
path = conaco
|
||||
url = https://github.com/seven332/Conaco
|
||||
[submodule "rippleold"]
|
||||
path = rippleold
|
||||
url = https://github.com/seven332/RippleOld
|
||||
[submodule "unifile"]
|
||||
path = unifile
|
||||
url = https://github.com/seven332/UniFile
|
||||
@@ -14,12 +14,23 @@ An E-Hentai Application for Android.
|
||||
|
||||
# Build
|
||||
|
||||
Windows
|
||||
|
||||
> git clone https://github.com/seven332/EhViewer
|
||||
> cd EhViewer
|
||||
> git submodule update --init
|
||||
> gradlew app:copyNotice
|
||||
> gradlew daogenerator:executeDaoGenerator
|
||||
> gradlew app:assembleDebug
|
||||
|
||||
Linux
|
||||
|
||||
$ git clone https://github.com/seven332/EhViewer
|
||||
$ cd EhViewer
|
||||
$ git submodule update --init
|
||||
$ gradlew app:copyNotice
|
||||
$ gradlew daogenerator:executeDaoGenerator
|
||||
$ gradlew app:assembleDebug
|
||||
$ ./gradlew app:copyNotice
|
||||
$ ./gradlew daogenerator:executeDaoGenerator
|
||||
$ ./gradlew app:assembleDebug
|
||||
|
||||
生成的 apk 文件在 app\build\outputs\apk 目录下
|
||||
|
||||
|
||||
+6
-4
@@ -50,7 +50,7 @@ android {
|
||||
} else {
|
||||
ndkBuilder = 'ndk-build'
|
||||
}
|
||||
commandLine "$ndkDir\\$ndkBuilder",
|
||||
commandLine "$ndkDir/$ndkBuilder",
|
||||
'-C', file('src/main/jni').absolutePath,
|
||||
'-j', Runtime.runtime.availableProcessors()
|
||||
}
|
||||
@@ -74,16 +74,18 @@ dependencies {
|
||||
compile project(':beerbelly')
|
||||
compile project(':conaco')
|
||||
compile project(':easyrecyclerview')
|
||||
compile project(':hotspot')
|
||||
compile project(':okhttp3')
|
||||
compile project(':rippleold')
|
||||
compile project(':unifile')
|
||||
compile project(':yorozuya')
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.3.0'
|
||||
compile 'com.android.support:design:23.3.0'
|
||||
compile 'com.github.amlcurran.showcaseview:library:5.4.1'
|
||||
compile 'com.github.anrwatchdog:anrwatchdog:1.2.0'
|
||||
compile 'com.github.seven332:unifile:0.1.2'
|
||||
compile 'com.github.seven332:drawerLayout:0.1.0'
|
||||
compile 'com.github.seven332:refreshlayout:0.1.0'
|
||||
compile 'com.github.seven332:ripple:0.1.0'
|
||||
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.8.7'
|
||||
compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
||||
compile 'org.jsoup:jsoup:1.8.3'
|
||||
|
||||
@@ -105,6 +105,32 @@
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.DictImportActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/dict_import"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/AppTheme.Dialog">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:scheme="file"/>
|
||||
<data android:host="*"/>
|
||||
<data android:pathPattern=".*\\.ehdict"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:scheme="file"/>
|
||||
<data android:host="*"/>
|
||||
<data android:mimeType="*/*"/>
|
||||
<data android:pathPattern=".*\\.ehdict"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.GalleryActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
@@ -152,6 +178,12 @@
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:label="@string/license"/>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.DictActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:label="@string/dict"/>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.FilterActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
@@ -169,5 +201,10 @@
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/download_service_label"/>
|
||||
|
||||
<service
|
||||
android:name="com.hippo.dict.DictImportService"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/import_dict_service">
|
||||
</service>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,240 @@
|
||||
package com.hippo.dict;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.JsonReader;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.util.SqlUtils;
|
||||
import com.hippo.yorozuya.ArrayUtils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class DictDatabase {
|
||||
|
||||
private static final String TAG = DictDatabase.class.getSimpleName();
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
public static final String COLUMN_PARENT = "parent";
|
||||
public static final String COLUMN_DATA = "data";
|
||||
public static final String COLUMN_DICT = "dict_name";
|
||||
|
||||
private static final String DATABASE_NAME = "dict_database.db";
|
||||
private static final String TABLE_DICT = "dictionary";
|
||||
private static final String SEPARATOR = "@@@";
|
||||
private final SQLiteDatabase mDatabase;
|
||||
private static DictDatabase sInstance;
|
||||
|
||||
private String mDictName;
|
||||
private boolean mAbortFlag = false;
|
||||
|
||||
private final AtomicBoolean mBusyFlag = new AtomicBoolean();
|
||||
|
||||
public static DictDatabase getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new DictDatabase(context.getApplicationContext());
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private DictDatabase(Context context) {
|
||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
||||
mDatabase = databaseHelper.getWritableDatabase();
|
||||
}
|
||||
|
||||
public String[] getSuggestions(String prefix) {
|
||||
if (TextUtils.isEmpty(prefix) || mBusyFlag.get()) {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
String command = "SELECT * FROM " + TABLE_DICT + " WHERE " + COLUMN_DATA +
|
||||
" MATCH '" + SqlUtils.sqlEscapeString(prefix) + "' LIMIT 5;";
|
||||
Cursor cursor = mDatabase.rawQuery(command, null);
|
||||
Set<String> queryList = new HashSet<>();
|
||||
int queryIndex = cursor.getColumnIndex(COLUMN_DATA);
|
||||
if (cursor.moveToFirst()) {
|
||||
while (!cursor.isAfterLast()) {
|
||||
String datum = cursor.getString(queryIndex);
|
||||
String data[] = datum.split(SEPARATOR);
|
||||
for (String item : data) {
|
||||
if (TextUtils.isEmpty(item) || datum.equals(prefix)) {
|
||||
continue;
|
||||
}
|
||||
queryList.add(item);
|
||||
}
|
||||
cursor.moveToNext();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
return queryList.toArray(new String[queryList.size()]);
|
||||
}
|
||||
|
||||
public void importDict(Context context, final Uri dictUri, final DictImportService.ProcessListener listener) throws IOException, URISyntaxException {
|
||||
mAbortFlag = false;
|
||||
int itemNum = -1;
|
||||
InputStream inputStream = context.getContentResolver().openInputStream(dictUri);
|
||||
if (null == inputStream) {
|
||||
throw new FileNotFoundException("Can't find " + dictUri);
|
||||
}
|
||||
JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String field = jsonReader.nextName();
|
||||
if (field.equals("dict")) {
|
||||
mDictName = jsonReader.nextString();
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[importDict] parse the dict name -- " + mDictName);
|
||||
}
|
||||
} else if (field.equals("num")) {
|
||||
if (TextUtils.isEmpty(mDictName)) {
|
||||
break;
|
||||
}
|
||||
itemNum = jsonReader.nextInt();
|
||||
listener.processTotal(itemNum);
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[importDict] parse the item number -- " + itemNum);
|
||||
}
|
||||
} else if (field.equals("data")) {
|
||||
if (TextUtils.isEmpty(mDictName) || itemNum <= 0) {
|
||||
break;
|
||||
}
|
||||
deleteDict(mDictName);
|
||||
parseData(jsonReader, listener);
|
||||
}
|
||||
}
|
||||
jsonReader.endObject();
|
||||
jsonReader.close();
|
||||
listener.processComplete();
|
||||
}
|
||||
|
||||
public void deleteDict(String dict) {
|
||||
if (mBusyFlag.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[deleteDict] dict:" + dict);
|
||||
}
|
||||
mDatabase.delete(TABLE_DICT, COLUMN_DICT + "=?", new String[]{dict});
|
||||
}
|
||||
|
||||
public void importAbort() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[importAbort] set mAbortFlag true");
|
||||
}
|
||||
mAbortFlag = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the database. This version has extra support for using the version field
|
||||
* as a mode flags field, and configures the database columns depending on the mode bits
|
||||
* (features) requested by the extending class.
|
||||
*/
|
||||
private static class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
public DatabaseHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL("CREATE VIRTUAL TABLE " + TABLE_DICT + " USING fts4 (" +
|
||||
COLUMN_DATA +
|
||||
", " + COLUMN_PARENT +
|
||||
", " + COLUMN_DICT +
|
||||
", tokenize=icu th_ZH" +
|
||||
");");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_DICT);
|
||||
onCreate(db);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseData(JsonReader jsonReader, final DictImportService.ProcessListener listener) throws IOException {
|
||||
mBusyFlag.lazySet(true);
|
||||
int process = 1;
|
||||
SQLiteStatement insStmt = mDatabase.compileStatement("INSERT INTO " + TABLE_DICT + " VALUES (?, ?, ?);");
|
||||
mDatabase.beginTransaction();
|
||||
jsonReader.beginArray();
|
||||
try {
|
||||
while (jsonReader.hasNext()) {
|
||||
synchronized (this) {
|
||||
if (mAbortFlag) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[parseData] import abort, delete the dict -- " + mDictName);
|
||||
}
|
||||
deleteDict(mDictName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
parseSingleData(jsonReader, insStmt);
|
||||
listener.process(process);
|
||||
process++;
|
||||
}
|
||||
jsonReader.endArray();
|
||||
mDatabase.setTransactionSuccessful();
|
||||
} finally {
|
||||
mDatabase.endTransaction();
|
||||
mBusyFlag.lazySet(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseSingleData(JsonReader jsonReader, SQLiteStatement insStmt) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String parent = "";
|
||||
sb.append(SEPARATOR);
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
String content = jsonReader.nextString();
|
||||
if (name.equals("parent")) {
|
||||
parent = content;
|
||||
} else {
|
||||
sb.append(content);
|
||||
sb.append(SEPARATOR);
|
||||
}
|
||||
}
|
||||
jsonReader.endObject();
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[parseSingleData] item:" + parent + " " + sb.toString());
|
||||
}
|
||||
insStmt.bindString(1, sb.toString());
|
||||
insStmt.bindString(2, parent);
|
||||
insStmt.bindString(3, mDictName);
|
||||
insStmt.executeInsert();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.hippo.dict;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.util.TextUrl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DictImportService extends Service {
|
||||
private static final String TAG = "DictImportService";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private DictManager mDictManager;
|
||||
private final List<ProcessListener> mListeners = new ArrayList<>();
|
||||
private ProcessListener mDictProcessListener;
|
||||
private AsyncTask mImportAsyncTask;
|
||||
private DictNotification mDictNotification;
|
||||
|
||||
// current task information
|
||||
private int mItemNum;
|
||||
private Uri mDictUri;
|
||||
private boolean mRunningFlag = false;
|
||||
|
||||
public DictImportService() {}
|
||||
|
||||
private final Binder serviceBinder = new DictImportServiceBinder();
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return serviceBinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mDictManager = new DictManager(this);
|
||||
mDictNotification = new DictNotification(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
public interface ProcessListener {
|
||||
void process(int progress);
|
||||
|
||||
void processTotal(int total);
|
||||
|
||||
void processComplete();
|
||||
}
|
||||
|
||||
public class DictImportServiceBinder extends Binder {
|
||||
public DictImportService getService() {
|
||||
return DictImportService.this;
|
||||
}
|
||||
}
|
||||
|
||||
public void importDict(Uri dictUri) {
|
||||
if (dictUri == null) {
|
||||
// TODO error tip
|
||||
if (DEBUG) {
|
||||
Log.e(TAG, "[importDict] dictUri is null");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[importDict] start import async task");
|
||||
}
|
||||
mImportAsyncTask = new ImportAsyncTask(dictUri).execute();
|
||||
}
|
||||
|
||||
public void abortImport() {
|
||||
if (mImportAsyncTask == null) {
|
||||
if (DEBUG) {
|
||||
Log.e(TAG, "[abortImport] mImportAsyncTask is null");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[abortImport] import abort");
|
||||
}
|
||||
|
||||
// fixme
|
||||
// this i just set a flag to abort the parse thread,it may cause a exception
|
||||
// it there may be a elegant way to shut the worker thread down
|
||||
mDictManager.importAbort();
|
||||
|
||||
// just for service go die
|
||||
mImportAsyncTask.cancel(true);
|
||||
}
|
||||
|
||||
public Uri getUri() {
|
||||
return mDictUri;
|
||||
}
|
||||
|
||||
public int getItemNum() {
|
||||
return mItemNum;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return mRunningFlag;
|
||||
}
|
||||
|
||||
public void setOnProgressListener(ProcessListener onProgressListener) {
|
||||
if (onProgressListener != null) {
|
||||
mListeners.add(onProgressListener);
|
||||
mListeners.remove(mDictNotification.mNotificationListener);
|
||||
mDictNotification.stopNotify();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeOnProgressListener(ProcessListener onProgressListener) {
|
||||
if (onProgressListener != null) {
|
||||
mListeners.remove(onProgressListener);
|
||||
}
|
||||
|
||||
// if there is no listener in listener list,we is in the background mostly
|
||||
// we post the process progress information to a notification
|
||||
if (mListeners.size() == 0 && null != mDictUri) {
|
||||
mDictNotification.setMax(mItemNum);
|
||||
mDictNotification.setFileName(TextUrl.getFileName(mDictUri.toString()));
|
||||
mListeners.add(mDictNotification.mNotificationListener);
|
||||
}
|
||||
}
|
||||
|
||||
class ImportAsyncTask extends AsyncTask<Void, Integer, Void> {
|
||||
|
||||
public ImportAsyncTask(Uri dictUri) {
|
||||
mDictUri = dictUri;
|
||||
mRunningFlag = true;
|
||||
mDictProcessListener = new ProcessListener() {
|
||||
@Override
|
||||
public void process(int progress) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[process] progress:" + progress);
|
||||
}
|
||||
publishProgress(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTotal(int total) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "process total " + total);
|
||||
}
|
||||
mItemNum = total;
|
||||
for (ProcessListener listener : mListeners) {
|
||||
listener.processTotal(total);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processComplete() {
|
||||
// we don't do any thing here,let async task handle this
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "processComplete");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
try {
|
||||
mDictManager.importDict(DictImportService.this, mDictUri, mDictProcessListener);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Integer... progress) {
|
||||
super.onProgressUpdate(progress);
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[onProgressUpdate] process item " + progress[0]);
|
||||
}
|
||||
for (ProcessListener listener : mListeners) {
|
||||
listener.process(progress[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
for (ProcessListener listener : mListeners) {
|
||||
listener.processComplete();
|
||||
}
|
||||
mRunningFlag = false;
|
||||
DictImportService.this.goDie();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
super.onCancelled();
|
||||
DictImportService.this.goDie();
|
||||
}
|
||||
}
|
||||
|
||||
public void goDie() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[goDie] task done or abort,go to die");
|
||||
}
|
||||
this.stopSelf();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.hippo.dict;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
// TODO Singleton
|
||||
// TODO Add add-dict callback for DictActivity
|
||||
public class DictManager {
|
||||
|
||||
// pattern for language
|
||||
private static final String enRegEx = "^[0-9a-zA-Z_\\s]+$";
|
||||
// private static final String zhRegEx = "";
|
||||
|
||||
private final DictDatabase mDictDatabase;
|
||||
|
||||
public DictManager(Context context) {
|
||||
mDictDatabase = DictDatabase.getInstance(context);
|
||||
}
|
||||
|
||||
public void importDict(Context context, final Uri dictUri, final DictImportService.ProcessListener listener)
|
||||
throws IOException, URISyntaxException {
|
||||
mDictDatabase.importDict(context, dictUri, listener);
|
||||
}
|
||||
|
||||
public void deletDict(String dict) {
|
||||
mDictDatabase.deleteDict(dict);
|
||||
}
|
||||
|
||||
public String[] getSuggestions(String prefix) {
|
||||
List<String> result = new ArrayList<>();
|
||||
String databaseResult[] = mDictDatabase.getSuggestions(prefix);
|
||||
for (String s : databaseResult) {
|
||||
if (filter(s)) {
|
||||
result.add(s);
|
||||
}
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
|
||||
public void importAbort() {
|
||||
mDictDatabase.importAbort();
|
||||
}
|
||||
|
||||
public boolean filter(String item) {
|
||||
// return true;
|
||||
Pattern en = Pattern.compile(enRegEx);
|
||||
Matcher m = en.matcher(item);
|
||||
return m.matches();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.hippo.dict;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.SystemClock;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.DictImportActivity;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
|
||||
|
||||
public class DictNotification {
|
||||
|
||||
private final Context mContext;
|
||||
private final NotificationManager mNotifyManager;
|
||||
private final NotificationCompat.Builder mBuilder;
|
||||
private int mMax = 100;
|
||||
private final int mId = 1;
|
||||
private long mLastUpdateTime;
|
||||
|
||||
private final PendingIntent mImportIntent;
|
||||
private final PendingIntent mDoneIntent;
|
||||
|
||||
public DictNotification(Context context) {
|
||||
|
||||
mContext = context;
|
||||
mNotifyManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mBuilder = new NotificationCompat.Builder(mContext);
|
||||
|
||||
mImportIntent = PendingIntent.getActivity(context, 0, new Intent(context, DictImportActivity.class), 0);
|
||||
Intent intent = new Intent(context, MainActivity.class);
|
||||
intent.setAction(Intent.ACTION_MAIN);
|
||||
mDoneIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
||||
|
||||
mBuilder.setContentTitle(mContext.getResources().getString(R.string.dict_import))
|
||||
.setContentText("0/" + mMax)
|
||||
.setSmallIcon(R.drawable.ic_stat_import)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.ic_launcher))
|
||||
.setContentIntent(mImportIntent)
|
||||
.setOngoing(true);
|
||||
}
|
||||
|
||||
public DictImportService.ProcessListener mNotificationListener = new DictImportService.ProcessListener() {
|
||||
@Override
|
||||
public void process(int progress) {
|
||||
DictNotification.this.notify(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTotal(int total) {
|
||||
// this may useless
|
||||
mMax = total;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processComplete() {
|
||||
DictNotification.this.notifyDone();
|
||||
}
|
||||
};
|
||||
|
||||
public void setMax(int max) {
|
||||
mMax = max;
|
||||
mBuilder.setContentText("0/" + mMax);
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
mBuilder.setContentTitle(mContext.getString(R.string.dict_import) + " " + fileName);
|
||||
}
|
||||
|
||||
public void notify(int progress) {
|
||||
// Avoid update frequently
|
||||
long now = SystemClock.currentThreadTimeMillis();
|
||||
if (now - mLastUpdateTime < 500L) {
|
||||
return;
|
||||
}
|
||||
mLastUpdateTime = now;
|
||||
mBuilder.setContentIntent(mImportIntent);
|
||||
mBuilder.setProgress(mMax, progress, false);
|
||||
mBuilder.setContentText(progress + "/" + mMax);
|
||||
mNotifyManager.notify(mId, mBuilder.build());
|
||||
}
|
||||
|
||||
public void notifyDone() {
|
||||
mBuilder.setContentIntent(mDoneIntent);
|
||||
mBuilder.setContentTitle(mContext.getString(R.string.dict_import_successfully));
|
||||
mBuilder.setContentText(mMax + "/" + mMax);
|
||||
mBuilder.setProgress(0, 0, false);
|
||||
mBuilder.setOngoing(false);
|
||||
mBuilder.setAutoCancel(true);
|
||||
mNotifyManager.notify(mId, mBuilder.build());
|
||||
}
|
||||
|
||||
public void stopNotify() {
|
||||
mNotifyManager.cancel(mId);
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ public class BatteryDrawable extends Drawable {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
int width = bounds.width();
|
||||
int height = bounds.height();
|
||||
@@ -89,8 +90,9 @@ public class BatteryDrawable extends Drawable {
|
||||
*/
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (mElect == -1)
|
||||
if (mElect == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
mElectRect.right = MathUtils.lerp(mStart, mStop, mElect / 100.0f);
|
||||
|
||||
@@ -152,21 +154,22 @@ public class BatteryDrawable extends Drawable {
|
||||
}
|
||||
|
||||
private void updatePaint(boolean warn) {
|
||||
if (warn)
|
||||
if (warn) {
|
||||
mPaint.setColor(mWarningColor);
|
||||
else
|
||||
} else {
|
||||
mPaint.setColor(mColor);
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
// Empty
|
||||
mPaint.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
// Empty
|
||||
mPaint.setColorFilter(cf);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class DrawerArrowDrawable extends Drawable {
|
||||
|
||||
private final Paint mPaint = new Paint();
|
||||
|
||||
// The angle in degress that the arrow head is inclined at.
|
||||
// The angle in degrees that the arrow head is inclined at.
|
||||
private static final float ARROW_HEAD_ANGLE = (float) Math.toRadians(45);
|
||||
private final float mBarThickness;
|
||||
// The length of top and bottom bars when they merge into an arrow
|
||||
@@ -61,7 +61,7 @@ public class DrawerArrowDrawable extends Drawable {
|
||||
// The interpolated version of the original progress
|
||||
private float mProgress;
|
||||
// the amount that overlaps w/ bar size when rotation is max
|
||||
private float mMaxCutForBarSize;
|
||||
private final float mMaxCutForBarSize;
|
||||
|
||||
/**
|
||||
* @param context used to get the configuration for the drawable from
|
||||
|
||||
@@ -29,6 +29,8 @@ import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.LruCache;
|
||||
import android.util.Log;
|
||||
|
||||
import com.github.anrwatchdog.ANRError;
|
||||
import com.github.anrwatchdog.ANRWatchDog;
|
||||
import com.hippo.beerbelly.SimpleDiskCache;
|
||||
import com.hippo.conaco.Conaco;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
@@ -91,6 +93,15 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
Thread.setDefaultUncaughtExceptionHandler(this);
|
||||
|
||||
// Start anr watch dog
|
||||
new ANRWatchDog().setANRListener(new ANRWatchDog.ANRListener() {
|
||||
@Override
|
||||
public void onAppNotResponding(ANRError error) {
|
||||
// Throw RuntimeException, let crash handler do it
|
||||
throw new RuntimeException(error.getCause());
|
||||
}
|
||||
}).start();
|
||||
|
||||
super.onCreate();
|
||||
|
||||
GetText.initialize(this);
|
||||
@@ -344,6 +355,12 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
if (!handleException(ex) && mDefaultHandler != null) {
|
||||
mDefaultHandler.uncaughtException(thread, ex);
|
||||
}
|
||||
|
||||
Activity activity = getTopActivity();
|
||||
if (activity != null) {
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Settings {
|
||||
|
||||
private static EhConfig loadEhConfig() {
|
||||
EhConfig ehConfig= new EhConfig();
|
||||
ehConfig.imageSize = getImageSize();
|
||||
ehConfig.imageSize = getImageResolution();
|
||||
ehConfig.excludedLanguages = getExcludedLanguages();
|
||||
ehConfig.defaultCategories = getDefaultCategories();
|
||||
ehConfig.excludedNamespaces = getExcludedTagNamespaces();
|
||||
@@ -275,6 +275,13 @@ public class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String KEY_THUMB_RESOLUTION = "thumb_resolution";
|
||||
private static final int DEFAULT_THUMB_RESOLUTION = 0;
|
||||
|
||||
public static int getThumbResolution() {
|
||||
return getIntFromStr(KEY_THUMB_RESOLUTION, DEFAULT_THUMB_RESOLUTION);
|
||||
}
|
||||
|
||||
private static final String KEY_SHOW_JPN_TITLE = "show_jpn_title";
|
||||
private static final boolean DEFAULT_SHOW_JPN_TITLE = false;
|
||||
|
||||
@@ -628,17 +635,17 @@ public class Settings {
|
||||
putIntToStr(KEY_PRELOAD_IMAGE, value);
|
||||
}
|
||||
|
||||
public static final String KEY_IMAGE_SIZE = "image_size";
|
||||
public static final String DEFAULT_IMAGE_SIZE = EhConfig.IMAGE_SIZE_AUTO;
|
||||
public static final String KEY_IMAGE_RESOLUTION = "image_size";
|
||||
public static final String DEFAULT_IMAGE_RESOLUTION = EhConfig.IMAGE_SIZE_AUTO;
|
||||
|
||||
public static String getImageSize() {
|
||||
return getString(KEY_IMAGE_SIZE, DEFAULT_IMAGE_SIZE);
|
||||
public static String getImageResolution() {
|
||||
return getString(KEY_IMAGE_RESOLUTION, DEFAULT_IMAGE_RESOLUTION);
|
||||
}
|
||||
|
||||
public static void putImageSize(String value) {
|
||||
public static void putImageResolution(String value) {
|
||||
sEhConfig.imageSize = value;
|
||||
sEhConfig.setDirty();
|
||||
putString(KEY_IMAGE_SIZE, value);
|
||||
putString(KEY_IMAGE_RESOLUTION, value);
|
||||
}
|
||||
|
||||
private static final String KEY_DOWNLOAD_ORIGIN_IMAGE = "download_origin_image";
|
||||
|
||||
@@ -168,4 +168,31 @@ public class EhUtils {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
public static String handleThumbUrlResolution(String url) {
|
||||
if (null == url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String resolution;
|
||||
switch (Settings.getThumbResolution()) {
|
||||
default:
|
||||
case 0: // Auto
|
||||
return url;
|
||||
case 1: // 250
|
||||
resolution = "250";
|
||||
break;
|
||||
case 2: // 300
|
||||
resolution = "300";
|
||||
break;
|
||||
}
|
||||
|
||||
int index1 = url.lastIndexOf('_');
|
||||
int index2 = url.lastIndexOf('.');
|
||||
if (index1 >= 0 && index2 >= 0 && index1 < index2) {
|
||||
return url.substring(0, index1 + 1) + resolution + url.substring(index2);
|
||||
} else {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class GalleryApiParser {
|
||||
gi.title = ParserUtils.trim(g.getString("title"));
|
||||
gi.titleJpn = ParserUtils.trim(g.getString("title_jpn"));
|
||||
gi.category = EhUtils.getCategory(g.getString("category"));
|
||||
gi.thumb = g.getString("thumb");
|
||||
gi.thumb = EhUtils.handleThumbUrlResolution(g.getString("thumb"));
|
||||
gi.uploader = g.getString("uploader");
|
||||
gi.posted = ParserUtils.formatDate(ParserUtils.parseLong(g.getString("posted")) * 1000);
|
||||
gi.rating = Float.parseFloat(g.getString("rating"));
|
||||
|
||||
@@ -130,7 +130,7 @@ public class GalleryDetailParser {
|
||||
// Thumb url
|
||||
Element gd1 = gm.getElementById("gd1");
|
||||
try {
|
||||
gd.thumb = StringUtils.trim(gd1.child(0).attr("src"));
|
||||
gd.thumb = EhUtils.handleThumbUrlResolution(StringUtils.trim(gd1.child(0).attr("src")));
|
||||
} catch (Exception e) {
|
||||
gd.thumb = "";
|
||||
}
|
||||
|
||||
@@ -121,13 +121,14 @@ public class GalleryListParser {
|
||||
// Thumb url
|
||||
Elements es = it2.children();
|
||||
if (null != es && es.size() >= 1) {
|
||||
gi.thumb = es.get(0).attr("src");
|
||||
gi.thumb = EhUtils.handleThumbUrlResolution(es.get(0).attr("src"));
|
||||
} else {
|
||||
String html = it2.html();
|
||||
int index1 = html.indexOf('~');
|
||||
int index2 = StringUtils.ordinalIndexOf(html, '~', 2);
|
||||
if (index1 < index2) {
|
||||
gi.thumb = "http://" +StringUtils.replace(html.substring(index1 + 1, index2), "~", "/");
|
||||
gi.thumb = EhUtils.handleThumbUrlResolution(
|
||||
"http://" +StringUtils.replace(html.substring(index1 + 1, index2), "~", "/"));
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb url");
|
||||
gi.thumb = "";
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.util.JsoupUtils;
|
||||
@@ -47,7 +48,7 @@ public class WhatsHotParser {
|
||||
galleryInfo.gid = result.gid;
|
||||
galleryInfo.token = result.token;
|
||||
temp = JsoupUtils.getElementByTag(temp, "img");
|
||||
galleryInfo.thumb = temp.attr("src");
|
||||
galleryInfo.thumb = EhUtils.handleThumbUrlResolution(temp.attr("src"));
|
||||
galleryInfo.title = temp.attr("title");
|
||||
galleryInfo.generateSLang();
|
||||
galleryInfoList.add(galleryInfo);
|
||||
|
||||
@@ -345,7 +345,9 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
return;
|
||||
}
|
||||
|
||||
mDownloadingDelay.cancel();
|
||||
if (null != mDownloadingDelay) {
|
||||
mDownloadingDelay.cancel();
|
||||
}
|
||||
|
||||
ensureDownloadedBuilder();
|
||||
|
||||
@@ -443,7 +445,10 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
return;
|
||||
}
|
||||
|
||||
mDownloadingDelay.cancel();
|
||||
if (null != mDownloadingDelay) {
|
||||
mDownloadingDelay.cancel();
|
||||
}
|
||||
|
||||
checkStopSelf();
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,8 @@ public class GalleryPageView extends GLFrameLayout {
|
||||
}
|
||||
|
||||
public void showInfo() {
|
||||
mImage.setVisibility(GONE);
|
||||
// For image valid rect
|
||||
mImage.setVisibility(INVISIBLE);
|
||||
mInfo.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,9 @@ public class ImageView extends GLView implements ImageTexture.Callback {
|
||||
mImageTexture.setCallback(null);
|
||||
}
|
||||
|
||||
int oldTextureWidth = mTextureWidth;
|
||||
int oldTextureHeight = mTextureHeight;
|
||||
|
||||
mImageTexture = imageTexture;
|
||||
|
||||
if (imageTexture != null) {
|
||||
@@ -222,8 +225,9 @@ public class ImageView extends GLView implements ImageTexture.Callback {
|
||||
mTextureHeight = 1;
|
||||
}
|
||||
|
||||
// Start alpha animation
|
||||
if (isAttachedToRoot()) {
|
||||
// Start alpha animation, do not show animation for image has no valid rect
|
||||
getValidRect(mValidRect);
|
||||
if (!mValidRect.isEmpty()) {
|
||||
startAnimation(mAlphaAnimation, true);
|
||||
}
|
||||
} else {
|
||||
@@ -233,6 +237,10 @@ public class ImageView extends GLView implements ImageTexture.Callback {
|
||||
|
||||
mScaleOffsetDirty = true;
|
||||
mPositionInRootDirty = true;
|
||||
|
||||
if (oldTextureWidth != mTextureWidth || oldTextureHeight != mTextureHeight) {
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public ImageTexture getImageTexture() {
|
||||
|
||||
@@ -42,12 +42,6 @@ public class ClearDownloadPathCachePreference extends MessagePreference {
|
||||
init(context);
|
||||
}
|
||||
|
||||
public ClearDownloadPathCachePreference(Context context,
|
||||
AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public void init(Context context) {
|
||||
setDialogMessage(context.getString(R.string.settings_advanced_clear_download_path_cache_message));
|
||||
}
|
||||
|
||||
@@ -47,11 +47,6 @@ public class DefaultCategoryPreference extends DialogPreference {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -69,11 +69,6 @@ public class ExcludedTagNamespacesPreference extends DialogPreference {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -66,11 +66,6 @@ public class HatHProxyPreference extends DialogPreference implements View.OnClic
|
||||
init();
|
||||
}
|
||||
|
||||
public HatHProxyPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setDialogLayoutResource(R.layout.preference_dialog_hath_proxy);
|
||||
updateSummary(Settings.getHathProxy(), Settings.getHathIp(), Settings.getHathPort());
|
||||
|
||||
@@ -42,11 +42,6 @@ public class SignOutPreference extends MessagePreference {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.hippo.ehviewer.spider;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
@@ -114,7 +115,9 @@ public class SpiderInfo {
|
||||
if (pos > 0 || pos < line.length() - 1) {
|
||||
int index = Integer.parseInt(line.substring(0, pos));
|
||||
String pToken = line.substring(pos + 1);
|
||||
spiderInfo.pTokenMap.put(index, pToken);
|
||||
if (!TextUtils.isEmpty(pToken)) {
|
||||
spiderInfo.pTokenMap.put(index, pToken);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Can't parse index and pToken, index = " + pos);
|
||||
}
|
||||
@@ -151,12 +154,14 @@ public class SpiderInfo {
|
||||
writer.write(Integer.toString(pages));
|
||||
writer.write("\n");
|
||||
for (int i = 0; i < pTokenMap.size(); i++) {
|
||||
if (TOKEN_FAILED.equals(pTokenMap.valueAt(i))) {
|
||||
Integer key = pTokenMap.keyAt(i);
|
||||
String value = pTokenMap.valueAt(i);
|
||||
if (TOKEN_FAILED.equals(value) || TextUtils.isEmpty(value)) {
|
||||
continue;
|
||||
}
|
||||
writer.write(Integer.toString(pTokenMap.keyAt(i)));
|
||||
writer.write(Integer.toString(key));
|
||||
writer.write(" ");
|
||||
writer.write(pTokenMap.valueAt(i));
|
||||
writer.write(value);
|
||||
writer.write("\n");
|
||||
}
|
||||
writer.flush();
|
||||
|
||||
@@ -1177,7 +1177,7 @@ public class SpiderQueen implements Runnable {
|
||||
int i = mSpiderInfo.pTokenMap.indexOfKey(index);
|
||||
String pToken = mSpiderInfo.pTokenMap.valueAt(i);
|
||||
if (SpiderInfo.TOKEN_FAILED.equals(pToken)) {
|
||||
mSpiderInfo.pTokenMap.setValueAt(i, null);
|
||||
mSpiderInfo.pTokenMap.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public class DictActivity extends ToolbarActivity {
|
||||
|
||||
private static final int REQUEST_CODE_SELECT_DICT_FILE = 0;
|
||||
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_dict);
|
||||
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
|
||||
|
||||
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view);
|
||||
TextView tip = (TextView) ViewUtils.$$(this, R.id.tip);
|
||||
mViewTransition = new ViewTransition(mRecyclerView, tip);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
mRecyclerView = null;
|
||||
mViewTransition = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
getMenuInflater().inflate(R.menu.activity_dict, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
case R.id.action_import:
|
||||
Intent intent = new Intent();
|
||||
intent.setType("application/octet-stream");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent,
|
||||
getString(R.string.select_dict_file)), REQUEST_CODE_SELECT_DICT_FILE);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (REQUEST_CODE_SELECT_DICT_FILE == requestCode) {
|
||||
if (Activity.RESULT_OK != resultCode) {
|
||||
return;
|
||||
}
|
||||
Uri uri = data.getData();
|
||||
if (null == uri) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(this, DictImportActivity.class);
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.dict.DictImportService;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.util.TextUrl;
|
||||
|
||||
public class DictImportActivity extends EhActivity {
|
||||
|
||||
private final static String TAG = "DictImportActivity";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private DictImportService serviceBinder;
|
||||
private int mItemNum = 0;
|
||||
|
||||
private Button mConfirmBtn;
|
||||
private Button mCancelBtn;
|
||||
private Button mHideBtn;
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private TextView mProgressTipView;
|
||||
private TextView mTipView;
|
||||
private Uri mDictUri;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_dict_improt);
|
||||
|
||||
Intent intent = new Intent(DictImportActivity.this, DictImportService.class);
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[onCreate] bind service");
|
||||
}
|
||||
bindService(intent, conn, Context.BIND_AUTO_CREATE);
|
||||
startService(intent);
|
||||
|
||||
|
||||
mConfirmBtn = (Button) findViewById(R.id.btn_confirm);
|
||||
mCancelBtn = (Button) findViewById(R.id.btn_cancel);
|
||||
mHideBtn = (Button) findViewById(R.id.btn_hide);
|
||||
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.bar_import);
|
||||
mProgressTipView = (TextView) findViewById(R.id.tv_progress);
|
||||
mTipView = (TextView) findViewById(R.id.tv_tip);
|
||||
|
||||
mConfirmBtn.setOnClickListener(confirmListener);
|
||||
mCancelBtn.setOnClickListener(cancelListener);
|
||||
mHideBtn.setOnClickListener(hideListener);
|
||||
}
|
||||
|
||||
private final ServiceConnection conn = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, "[onServiceConnected] disconnect to service");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
serviceBinder = ((DictImportService.DictImportServiceBinder) service).getService();
|
||||
serviceBinder.setOnProgressListener(importListener);
|
||||
|
||||
// if we are doing a task,we load improt infomation from service
|
||||
// and ignore the newer import task
|
||||
if (serviceBinder.isRunning()) {
|
||||
initFromService();
|
||||
} else {
|
||||
initFromIntent();
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[onServiceConnected] connect to service");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final DictImportService.ProcessListener importListener = new DictImportService.ProcessListener() {
|
||||
@Override
|
||||
public void process(int progress) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "[process] " + progress);
|
||||
}
|
||||
mProgressBar.setProgress(progress);
|
||||
mProgressTipView.setText(progress + "/" + mItemNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTotal(int total) {
|
||||
mItemNum = total;
|
||||
mProgressBar.setMax(mItemNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processComplete() {
|
||||
mCancelBtn.setText(getResources().getString(R.string.done));
|
||||
mHideBtn.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private final View.OnClickListener cancelListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
DictImportActivity.this.finish();
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener abortListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[onClick] abort");
|
||||
}
|
||||
if (serviceBinder != null) {
|
||||
serviceBinder.abortImport();
|
||||
}
|
||||
DictImportActivity.this.finish();
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener confirmListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[onClick] confirm");
|
||||
}
|
||||
if (serviceBinder == null) {
|
||||
// todo error tip
|
||||
if (DEBUG) {
|
||||
Log.e(TAG, "[onClick] service is not connected");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mDictUri == null) {
|
||||
// todo error tip
|
||||
if (DEBUG) {
|
||||
Log.e(TAG, "[onClick] mDictUri is not be init");
|
||||
}
|
||||
return;
|
||||
}
|
||||
serviceBinder.importDict(mDictUri);
|
||||
|
||||
view.setVisibility(View.GONE);
|
||||
mCancelBtn.setOnClickListener(abortListener);
|
||||
mHideBtn.setVisibility(View.VISIBLE);
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnClickListener hideListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[onClick] hide");
|
||||
}
|
||||
DictImportActivity.this.finish();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
serviceBinder.removeOnProgressListener(importListener);
|
||||
unbindService(conn);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
private void initFromService() {
|
||||
mDictUri = serviceBinder.getUri();
|
||||
if (mDictUri == null) {
|
||||
if (DEBUG) {
|
||||
Log.e(TAG, "[initFromService] error use of initFromService,you may use initFromIntent instead");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[initFromService] " + mDictUri.toString());
|
||||
}
|
||||
|
||||
mItemNum = serviceBinder.getItemNum();
|
||||
mProgressBar.setMax(mItemNum);
|
||||
mConfirmBtn.setVisibility(View.GONE);
|
||||
mHideBtn.setVisibility(View.VISIBLE);
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
mTipView.setText(TextUrl.getFileName(mDictUri.toString()));
|
||||
mCancelBtn.setOnClickListener(abortListener);
|
||||
}
|
||||
|
||||
private void initFromIntent() {
|
||||
mDictUri = getIntent().getData();
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "[initFromIntent] " + mDictUri.toString());
|
||||
}
|
||||
mTipView.setText(TextUrl.getFileName(mDictUri.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -29,7 +27,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.widget.DirExplorer;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
@@ -52,7 +50,6 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
@Nullable
|
||||
private View mOk;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -73,7 +70,7 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
mDirExplorer.setCurrentFile(file);
|
||||
mDirExplorer.setOnChangeDirListener(this);
|
||||
|
||||
RippleSalon.addRipple(mOk, false);
|
||||
Ripple.addRipple(mOk, false);
|
||||
|
||||
mOk.setOnClickListener(this);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ 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.ripple.Ripple;
|
||||
import com.hippo.widget.SensitiveCheckBox;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
@@ -163,11 +163,11 @@ public class ExcludedLanguagesActivity extends ToolbarActivity
|
||||
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);
|
||||
Ripple.addRipple(mCancel, false);
|
||||
Ripple.addRipple(mOk, false);
|
||||
Ripple.addRipple(mSelectAll, false);
|
||||
Ripple.addRipple(mDeselectAll, false);
|
||||
Ripple.addRipple(mInvertSelection, false);
|
||||
}
|
||||
|
||||
private boolean isDecimal(String str) {
|
||||
|
||||
@@ -40,6 +40,7 @@ import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.drawerlayout.DrawerLayout;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.Crash;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -67,6 +68,7 @@ import com.hippo.ehviewer.ui.scene.SelectSiteScene;
|
||||
import com.hippo.ehviewer.ui.scene.SignInScene;
|
||||
import com.hippo.ehviewer.ui.scene.WarningScene;
|
||||
import com.hippo.ehviewer.ui.scene.WebViewSignInScene;
|
||||
import com.hippo.ehviewer.widget.EhDrawerLayout;
|
||||
import com.hippo.io.UniFileInputStreamPipe;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
@@ -75,7 +77,6 @@ import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.BitmapUtils;
|
||||
import com.hippo.util.PermissionRequester;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.widget.drawerlayout.DrawerLayout;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.ResourcesUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
@@ -110,7 +111,7 @@ public final class MainActivity extends StageActivity
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private EhDrawerLayout mDrawerLayout;
|
||||
@Nullable
|
||||
private NavigationView mNavView;
|
||||
@Nullable
|
||||
@@ -339,11 +340,20 @@ public final class MainActivity extends StageActivity
|
||||
@Override
|
||||
protected void onUnrecognizedIntent(@Nullable Intent intent) {
|
||||
if (!handleIntent(intent)) {
|
||||
boolean handleUrl = false;
|
||||
if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||
handleUrl = true;
|
||||
Toast.makeText(this, R.string.error_cannot_parse_the_url, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
if (0 == getSceneCount()) {
|
||||
finish();
|
||||
if (handleUrl) {
|
||||
finish();
|
||||
} else {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_HOMEPAGE);
|
||||
startScene(processAnnouncer(new Announcer(GalleryListScene.class).setArgs(args)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,7 +368,7 @@ public final class MainActivity extends StageActivity
|
||||
protected void onCreate2(@Nullable Bundle savedInstanceState) {
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
mDrawerLayout = (DrawerLayout) ViewUtils.$$(this, R.id.draw_view);
|
||||
mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(this, R.id.draw_view);
|
||||
mNavView = (NavigationView) ViewUtils.$$(this, R.id.nav_view);
|
||||
mRightDrawer = (FrameLayout) ViewUtils.$$(this, R.id.right_drawer);
|
||||
View headerLayout = mNavView.getHeaderView(0);
|
||||
@@ -493,6 +503,18 @@ public final class MainActivity extends StageActivity
|
||||
mDisplayName.setText(displayName);
|
||||
}
|
||||
|
||||
public void addAboveSnackView(View view) {
|
||||
if (mDrawerLayout != null) {
|
||||
mDrawerLayout.addAboveSnackView(view);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAboveSnackView(View view) {
|
||||
if (mDrawerLayout != null) {
|
||||
mDrawerLayout.removeAboveSnackView(view);
|
||||
}
|
||||
}
|
||||
|
||||
public int getDrawerLockMode(int edgeGravity) {
|
||||
if (mDrawerLayout != null) {
|
||||
return mDrawerLayout.getDrawerLockMode(edgeGravity);
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.util.ActivityHelper;
|
||||
import com.hippo.util.AppHelper;
|
||||
|
||||
public class AboutFragment extends PreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener,
|
||||
@@ -72,7 +72,7 @@ public class AboutFragment extends PreferenceFragment
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String key = preference.getKey();
|
||||
if (KEY_AUTHOR.equals(key)) {
|
||||
ActivityHelper.sendEmail(getActivity(), EhApplication.getDeveloperEmail(),
|
||||
AppHelper.sendEmail(getActivity(), EhApplication.getDeveloperEmail(),
|
||||
"About EhViewer", null);
|
||||
} else if (KEY_DONATE.equals(key)) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.fragment;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
@@ -54,13 +53,13 @@ public class DownloadFragment extends PreferenceFragment implements
|
||||
addPreferencesFromResource(R.xml.download_settings);
|
||||
|
||||
Preference mediaScan = findPreference(Settings.KEY_MEDIA_SCAN);
|
||||
Preference imageSize = findPreference(Settings.KEY_IMAGE_SIZE);
|
||||
Preference imageResolution = findPreference(Settings.KEY_IMAGE_RESOLUTION);
|
||||
mDownloadLocation = findPreference(KEY_DOWNLOAD_LOCATION);
|
||||
|
||||
onUpdateDownloadLocation();
|
||||
|
||||
mediaScan.setOnPreferenceChangeListener(this);
|
||||
imageSize.setOnPreferenceChangeListener(this);
|
||||
imageResolution.setOnPreferenceChangeListener(this);
|
||||
|
||||
if (mDownloadLocation != null) {
|
||||
mDownloadLocation.setOnPreferenceClickListener(this);
|
||||
@@ -141,18 +140,18 @@ public class DownloadFragment extends PreferenceFragment implements
|
||||
startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE_DIR);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void openDirPickerL() {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
try {
|
||||
startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE_DIR_L);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getActivity(), R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
try {
|
||||
startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE_DIR_L);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getActivity(), R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case REQUEST_CODE_PICK_IMAGE_DIR: {
|
||||
@@ -169,7 +168,7 @@ public class DownloadFragment extends PreferenceFragment implements
|
||||
break;
|
||||
}
|
||||
case REQUEST_CODE_PICK_IMAGE_DIR_L: {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (resultCode == Activity.RESULT_OK && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Uri treeUri = data.getData();
|
||||
getActivity().getContentResolver().takePersistableUriPermission(
|
||||
treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
@@ -203,9 +202,9 @@ public class DownloadFragment extends PreferenceFragment implements
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (Settings.KEY_IMAGE_SIZE.equals(key)) {
|
||||
} else if (Settings.KEY_IMAGE_RESOLUTION.equals(key)) {
|
||||
if (newValue instanceof String) {
|
||||
Settings.putImageSize((String) newValue);
|
||||
Settings.putImageResolution((String) newValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ActivityHelper;
|
||||
import com.hippo.util.AppHelper;
|
||||
|
||||
public abstract class BaseScene extends SceneFragment {
|
||||
|
||||
@@ -49,6 +49,20 @@ public abstract class BaseScene extends SceneFragment {
|
||||
}
|
||||
}
|
||||
|
||||
public void addAboveSnackView(View view) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof MainActivity) {
|
||||
((MainActivity) activity).addAboveSnackView(view);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAboveSnackView(View view) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof MainActivity) {
|
||||
((MainActivity) activity).removeAboveSnackView(view);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDrawerLockMode(int lockMode, int edgeGravity) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof MainActivity) {
|
||||
@@ -154,7 +168,7 @@ public abstract class BaseScene extends SceneFragment {
|
||||
setNavCheckedItem(getNavCheckedItem());
|
||||
|
||||
// Hide soft ime
|
||||
ActivityHelper.hideSoftInput(getActivity());
|
||||
AppHelper.hideSoftInput(getActivity());
|
||||
}
|
||||
|
||||
public void createThemeContext(@StyleRes int style) {
|
||||
@@ -198,14 +212,14 @@ public abstract class BaseScene extends SceneFragment {
|
||||
public void hideSoftInput() {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (null != activity) {
|
||||
ActivityHelper.hideSoftInput(activity);
|
||||
AppHelper.hideSoftInput(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public void showSoftInput(@Nullable View view) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (null != activity && null != view) {
|
||||
ActivityHelper.showSoftInput(activity, view);
|
||||
AppHelper.showSoftInput(activity, view);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,8 @@ import com.hippo.ehviewer.Crash;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.util.ActivityHelper;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.util.AppHelper;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public class CrashScene extends BaseScene implements View.OnClickListener {
|
||||
@@ -70,8 +70,8 @@ public class CrashScene extends BaseScene implements View.OnClickListener {
|
||||
mCancel.setOnClickListener(this);
|
||||
mSend.setOnClickListener(this);
|
||||
|
||||
RippleSalon.addRipple(mCancel, true);
|
||||
RippleSalon.addRipple(mSend, true);
|
||||
Ripple.addRipple(mCancel, true);
|
||||
Ripple.addRipple(mSend, true);
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class CrashScene extends BaseScene implements View.OnClickListener {
|
||||
MainActivity activity = getActivity2();
|
||||
|
||||
if (mSend == v && null != mCrash && null != activity) {
|
||||
ActivityHelper.sendEmail(activity, EhApplication.getDeveloperEmail(),
|
||||
AppHelper.sendEmail(activity, EhApplication.getDeveloperEmail(),
|
||||
"I found a bug in EhViewer !", mCrash);
|
||||
}
|
||||
Crash.resetCrashFile();
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@@ -76,7 +75,7 @@ import com.hippo.ehviewer.spider.SpiderDen;
|
||||
import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.widget.SimpleRatingView;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.ApiHelper;
|
||||
@@ -293,7 +292,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(R.dimen.gallery_list_column_width));
|
||||
mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
@@ -327,6 +326,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
mFabLayout.setHidePrimaryFab(true);
|
||||
mFabLayout.setAutoCancel(false);
|
||||
mFabLayout.setOnClickFabListener(this);
|
||||
addAboveSnackView(mFabLayout);
|
||||
|
||||
updateView();
|
||||
|
||||
@@ -437,9 +437,12 @@ public class DownloadsScene extends ToolbarScene
|
||||
mRecyclerView.stopScroll();
|
||||
mRecyclerView = null;
|
||||
}
|
||||
if (null != mFabLayout) {
|
||||
removeAboveSnackView(mFabLayout);
|
||||
mFabLayout = null;
|
||||
}
|
||||
|
||||
mRecyclerView = null;
|
||||
mFabLayout = null;
|
||||
mViewTransition = null;
|
||||
mAdapter = null;
|
||||
mLayoutManager = null;
|
||||
@@ -1062,8 +1065,8 @@ public class DownloadsScene extends ToolbarScene
|
||||
thumb.setOnClickListener(this);
|
||||
start.setOnClickListener(this);
|
||||
stop.setOnClickListener(this);
|
||||
RippleSalon.addRipple(start, false);
|
||||
RippleSalon.addRipple(stop, false);
|
||||
Ripple.addRipple(start, false);
|
||||
Ripple.addRipple(stop, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1128,7 +1131,6 @@ public class DownloadsScene extends ToolbarScene
|
||||
return new DownloadHolder(mInflater.inflate(R.layout.item_download, parent, false));
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onBindViewHolder(DownloadHolder holder, int position) {
|
||||
if (mList == null) {
|
||||
@@ -1148,7 +1150,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
bindForState(holder, info);
|
||||
|
||||
// Update transition name
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
long gid = info.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.Fragment;
|
||||
@@ -27,7 +26,6 @@ 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;
|
||||
@@ -43,15 +41,17 @@ class EnterGalleryDetailTransaction implements TransitionHelper {
|
||||
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());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,8 @@ 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.rippleold.RippleSalon;
|
||||
import com.hippo.refreshlayout.RefreshLayout;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ApiHelper;
|
||||
@@ -79,7 +80,6 @@ import com.hippo.util.DrawableManager;
|
||||
import com.hippo.widget.ContentLayout;
|
||||
import com.hippo.widget.FabLayout;
|
||||
import com.hippo.widget.SearchBarMover;
|
||||
import com.hippo.widget.refreshlayout.RefreshLayout;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.ObjectUtils;
|
||||
@@ -252,7 +252,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
contentLayout.getFastScroller().setOnDragHandlerListener(this);
|
||||
|
||||
mAdapter = new FavoritesAdapter(inflater, resources, mRecyclerView, Settings.getListMode());
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
@@ -278,6 +278,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
mFabLayout.setAutoCancel(false);
|
||||
mFabLayout.setHidePrimaryFab(true);
|
||||
mFabLayout.setOnClickFabListener(this);
|
||||
addAboveSnackView(mFabLayout);
|
||||
|
||||
// Restore search mode
|
||||
if (mSearchMode) {
|
||||
@@ -393,11 +394,14 @@ public class FavoritesScene extends BaseScene implements
|
||||
mRecyclerView.stopScroll();
|
||||
mRecyclerView = null;
|
||||
}
|
||||
if (null != mFabLayout) {
|
||||
removeAboveSnackView(mFabLayout);
|
||||
mFabLayout = null;
|
||||
}
|
||||
|
||||
mAdapter = null;
|
||||
|
||||
mSearchBar = null;
|
||||
mFabLayout = null;
|
||||
|
||||
mSearchBarMover = null;
|
||||
mLeftDrawable = null;
|
||||
@@ -482,7 +486,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
|
||||
rv.addItemDecoration(decoration);
|
||||
rv.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
rv.setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
rv.setClipToPadding(false);
|
||||
builder.setView(rv).show();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
@@ -38,7 +37,6 @@ import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.widget.TileThumb;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -161,7 +159,6 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
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) {
|
||||
@@ -193,7 +190,7 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
int color = EhUtils.getCategoryColor(gi.category);
|
||||
if (!(drawable instanceof TriangleDrawable)) {
|
||||
drawable = new TriangleDrawable(color);
|
||||
category.setBackground(drawable);
|
||||
category.setBackgroundDrawable(drawable);
|
||||
} else {
|
||||
((TriangleDrawable) drawable).setColor(color);
|
||||
}
|
||||
@@ -203,7 +200,7 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
}
|
||||
|
||||
// Update transition name
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.parser.VoteCommentParser;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.reveal.ViewAnimationUtils;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.text.URLImageGetter;
|
||||
@@ -72,6 +72,7 @@ import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.util.TextUrl;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.FabLayout;
|
||||
import com.hippo.widget.LinkifyTextView;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
@@ -107,6 +108,8 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private FabLayout mFabLayout;
|
||||
@Nullable
|
||||
private FloatingActionButton mFab;
|
||||
@Nullable
|
||||
private View mEditPanel;
|
||||
@@ -182,6 +185,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
mEditPanel = ViewUtils.$$(view, R.id.edit_panel);
|
||||
mSendImage = (ImageView) ViewUtils.$$(mEditPanel, R.id.send);
|
||||
mEditText = (EditText) ViewUtils.$$(mEditPanel, R.id.edit_text);
|
||||
mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
|
||||
mFab = (FloatingActionButton) ViewUtils.$$(view, R.id.fab);
|
||||
|
||||
Context context = getContext2();
|
||||
@@ -202,7 +206,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setShowLastDivider(true);
|
||||
mRecyclerView.addItemDecoration(decoration);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(),
|
||||
@@ -216,6 +220,9 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
mSendImage.setOnClickListener(this);
|
||||
mFab.setOnClickListener(this);
|
||||
|
||||
addAboveSnackView(mEditPanel);
|
||||
addAboveSnackView(mFabLayout);
|
||||
|
||||
mViewTransition = new ViewTransition(mRecyclerView, tip);
|
||||
|
||||
updateView(false);
|
||||
@@ -231,9 +238,16 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
mRecyclerView.stopScroll();
|
||||
mRecyclerView = null;
|
||||
}
|
||||
if (null != mEditPanel) {
|
||||
removeAboveSnackView(mEditPanel);
|
||||
mEditPanel = null;
|
||||
}
|
||||
if (null != mFabLayout) {
|
||||
removeAboveSnackView(mFabLayout);
|
||||
mFabLayout = null;
|
||||
}
|
||||
|
||||
mFab = null;
|
||||
mEditPanel = null;
|
||||
mSendImage = null;
|
||||
mEditText = null;
|
||||
mAdapter = null;
|
||||
@@ -325,7 +339,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
|
||||
rv.addItemDecoration(decoration);
|
||||
rv.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
rv.setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
rv.setClipToPadding(false);
|
||||
builder.setView(rv).show();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.DownloadManager;
|
||||
@@ -83,14 +82,14 @@ import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.ui.annotation.WholeLifeCircle;
|
||||
import com.hippo.reveal.ViewAnimationUtils;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.text.URLImageGetter;
|
||||
import com.hippo.util.ActivityHelper;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.AppHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.ReadableTime;
|
||||
@@ -432,9 +431,9 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mActionGroup = (ViewGroup) ViewUtils.$$(mHeader, R.id.action_card);
|
||||
mDownload = (TextView) ViewUtils.$$(mActionGroup, R.id.download);
|
||||
mRead = ViewUtils.$$(mActionGroup, R.id.read);
|
||||
RippleSalon.addRipple(mOtherActions, false);
|
||||
RippleSalon.addRipple(mDownload, false);
|
||||
RippleSalon.addRipple(mRead, false);
|
||||
Ripple.addRipple(mOtherActions, false);
|
||||
Ripple.addRipple(mDownload, false);
|
||||
Ripple.addRipple(mRead, false);
|
||||
mUploader.setOnClickListener(this);
|
||||
mCategory.setOnClickListener(this);
|
||||
mOtherActions.setOnClickListener(this);
|
||||
@@ -453,7 +452,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mSize = (TextView) ViewUtils.$$(mInfo, R.id.size);
|
||||
mPosted = (TextView) ViewUtils.$$(mInfo, R.id.posted);
|
||||
mFavoredTimes = (TextView) ViewUtils.$$(mInfo, R.id.favoredTimes);
|
||||
RippleSalon.addRipple(mInfo, false);
|
||||
Ripple.addRipple(mInfo, false);
|
||||
mInfo.setOnClickListener(this);
|
||||
|
||||
mActions = ViewUtils.$$(belowHeader, R.id.actions);
|
||||
@@ -467,12 +466,12 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mRate = (TextView) ViewUtils.$$(mActions, R.id.rate);
|
||||
mSimilar = (TextView) ViewUtils.$$(mActions, R.id.similar);
|
||||
mSearchCover = (TextView) ViewUtils.$$(mActions, R.id.search_cover);
|
||||
RippleSalon.addRipple(mHeartGroup, false);
|
||||
RippleSalon.addRipple(mTorrent, false);
|
||||
RippleSalon.addRipple(mShare, false);
|
||||
RippleSalon.addRipple(mRate, false);
|
||||
RippleSalon.addRipple(mSimilar, false);
|
||||
RippleSalon.addRipple(mSearchCover, false);
|
||||
Ripple.addRipple(mHeartGroup, false);
|
||||
Ripple.addRipple(mTorrent, false);
|
||||
Ripple.addRipple(mShare, false);
|
||||
Ripple.addRipple(mRate, false);
|
||||
Ripple.addRipple(mSimilar, false);
|
||||
Ripple.addRipple(mSearchCover, false);
|
||||
mHeartGroup.setOnClickListener(this);
|
||||
mTorrent.setOnClickListener(this);
|
||||
mShare.setOnClickListener(this);
|
||||
@@ -486,13 +485,13 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
mComments = (LinearLayout) ViewUtils.$$(belowHeader, R.id.comments);
|
||||
mCommentsText = (TextView) ViewUtils.$$(mComments, R.id.comments_text);
|
||||
RippleSalon.addRipple(mComments, false);
|
||||
Ripple.addRipple(mComments, false);
|
||||
mComments.setOnClickListener(this);
|
||||
|
||||
mPreviews = ViewUtils.$$(belowHeader, R.id.previews);
|
||||
mGridLayout = (SimpleGridAutoSpanLayout) ViewUtils.$$(mPreviews, R.id.grid_layout);
|
||||
mPreviewText = (TextView) ViewUtils.$$(mPreviews, R.id.preview_text);
|
||||
RippleSalon.addRipple(mPreviews, false);
|
||||
Ripple.addRipple(mPreviews, false);
|
||||
mPreviews.setOnClickListener(this);
|
||||
|
||||
mProgress = ViewUtils.$$(mainView, R.id.progress);
|
||||
@@ -957,12 +956,12 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
return resources.getString(R.string.rating_text, getRatingText(rating, resources), rating, ratingCount);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void setTransitionName() {
|
||||
long gid = getGid();
|
||||
|
||||
if (gid != -1 && ApiHelper.SUPPORT_TRANSITION && mThumb != null &&
|
||||
mTitle != null && mUploader != null && mCategory != null) {
|
||||
mTitle != null && mUploader != null && mCategory != null &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mThumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
mTitle.setTransitionName(TransitionNameFactory.getTitleTransitionName(gid));
|
||||
mUploader.setTransitionName(TransitionNameFactory.getUploaderTransitionName(gid));
|
||||
@@ -1160,7 +1159,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
} else if (mShare == v) {
|
||||
String url = getGalleryDetailUrl(false);
|
||||
if (url != null) {
|
||||
ActivityHelper.share(activity, url);
|
||||
AppHelper.share(activity, url);
|
||||
}
|
||||
} else if (mTorrent == v) {
|
||||
if (mGalleryDetail != null) {
|
||||
@@ -1455,7 +1454,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public boolean onTransition(Context context,
|
||||
FragmentTransaction transaction, Fragment exit, Fragment enter) {
|
||||
if (!(enter instanceof GalleryListScene) && !(enter instanceof DownloadsScene) &&
|
||||
@@ -1463,15 +1461,17 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
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());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
@@ -166,7 +166,7 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
|
||||
mRecyclerView.addItemDecoration(decoration);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
|
||||
@@ -76,16 +76,17 @@ import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.widget.SearchBar;
|
||||
import com.hippo.ehviewer.widget.SearchLayout;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.refreshlayout.RefreshLayout;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.AppHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.ContentLayout;
|
||||
import com.hippo.widget.FabLayout;
|
||||
import com.hippo.widget.SearchBarMover;
|
||||
import com.hippo.widget.refreshlayout.RefreshLayout;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
@@ -412,7 +413,7 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
mAdapter = new GalleryListAdapter(inflater, resources,
|
||||
mRecyclerView, Settings.getListMode());
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
@@ -442,6 +443,7 @@ public final class GalleryListScene extends BaseScene
|
||||
mFabLayout.setHidePrimaryFab(false);
|
||||
mFabLayout.setOnClickFabListener(this);
|
||||
mFabLayout.setOnExpandListener(this);
|
||||
addAboveSnackView(mFabLayout);
|
||||
|
||||
mActionFabDrawable = new AddDeleteDrawable(context);
|
||||
mActionFabDrawable.setColor(resources.getColor(R.color.primary_drawable_dark));
|
||||
@@ -521,11 +523,14 @@ public final class GalleryListScene extends BaseScene
|
||||
mRecyclerView.stopScroll();
|
||||
mRecyclerView = null;
|
||||
}
|
||||
if (null != mFabLayout) {
|
||||
removeAboveSnackView(mFabLayout);
|
||||
mFabLayout = null;
|
||||
}
|
||||
|
||||
mAdapter = null;
|
||||
mSearchLayout = null;
|
||||
mSearchBar = null;
|
||||
mFabLayout = null;
|
||||
mSearchFab = null;
|
||||
mViewTransition = null;
|
||||
mLeftDrawable = null;
|
||||
@@ -803,6 +808,7 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
builder.setError(null);
|
||||
mHelper.goTo(goTo);
|
||||
AppHelper.hideSoftInput(dialog);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
@@ -56,7 +55,7 @@ import com.hippo.ehviewer.dao.HistoryInfo;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.widget.SimpleRatingView;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ApiHelper;
|
||||
@@ -126,7 +125,7 @@ public class HistoryScene extends ToolbarScene
|
||||
layoutManager.setColumnSize(resources.getDimensionPixelOffset(R.dimen.gallery_list_column_width));
|
||||
layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
@@ -342,7 +341,6 @@ public class HistoryScene extends ToolbarScene
|
||||
}
|
||||
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void onBindViewHolder(HistoryHolder holder, int position) {
|
||||
if (null == mLazyList) {
|
||||
return;
|
||||
@@ -363,7 +361,7 @@ public class HistoryScene extends ToolbarScene
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
|
||||
// Update transition name
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* 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.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.drawerlayout.DrawerLayout;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@CoordinatorLayout.DefaultBehavior(EhDrawerLayout.Behavior.class)
|
||||
public class EhDrawerLayout extends DrawerLayout {
|
||||
|
||||
private List<View> mAboveSnackViewList;
|
||||
|
||||
public EhDrawerLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public EhDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public void addAboveSnackView(View view) {
|
||||
if (null == mAboveSnackViewList) {
|
||||
mAboveSnackViewList = new ArrayList<>();
|
||||
}
|
||||
mAboveSnackViewList.add(view);
|
||||
}
|
||||
|
||||
public void removeAboveSnackView(View view) {
|
||||
if (null == mAboveSnackViewList) {
|
||||
return;
|
||||
}
|
||||
mAboveSnackViewList.remove(view);
|
||||
}
|
||||
|
||||
public int getAboveSnackViewCount() {
|
||||
return null == mAboveSnackViewList ? 0 : mAboveSnackViewList.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public View getAboveSnackViewAt(int index) {
|
||||
if (null == mAboveSnackViewList || index < 0 || index >= mAboveSnackViewList.size()) {
|
||||
return null;
|
||||
} else {
|
||||
return mAboveSnackViewList.get(index);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Behavior extends CoordinatorLayout.Behavior<EhDrawerLayout> {
|
||||
// We only support the FAB <> Snackbar shift movement on Honeycomb and above. This is
|
||||
// because we can use view translation properties which greatly simplifies the code.
|
||||
private static final boolean SNACKBAR_BEHAVIOR_ENABLED = Build.VERSION.SDK_INT >= 11;
|
||||
|
||||
@Override
|
||||
public boolean layoutDependsOn(CoordinatorLayout parent,
|
||||
EhDrawerLayout child, View dependency) {
|
||||
// We're dependent on all SnackbarLayouts (if enabled)
|
||||
return SNACKBAR_BEHAVIOR_ENABLED && dependency instanceof Snackbar.SnackbarLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDependentViewChanged(CoordinatorLayout parent, EhDrawerLayout child,
|
||||
View dependency) {
|
||||
if (dependency instanceof Snackbar.SnackbarLayout) {
|
||||
for (int i = 0, n = child.getAboveSnackViewCount(); i < n; i++) {
|
||||
View view = child.getAboveSnackViewAt(i);
|
||||
updateChildTranslationForSnackbar(parent, child, view);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateChildTranslationForSnackbar(CoordinatorLayout parent,
|
||||
EhDrawerLayout view, final View child) {
|
||||
final float targetTransY = getChildTranslationYForSnackbar(parent, view);
|
||||
float childTranslationY = 0.0f;
|
||||
Object obj = child.getTag(R.id.fab_translation_y);
|
||||
if (obj instanceof Float) {
|
||||
childTranslationY = (Float) obj;
|
||||
}
|
||||
if (childTranslationY == targetTransY) {
|
||||
// We're already at (or currently animating to) the target value, return...
|
||||
return;
|
||||
}
|
||||
|
||||
ValueAnimator fabTranslationYAnimator = null;
|
||||
obj = child.getTag(R.id.fab_translation_y_animator);
|
||||
if (obj instanceof ValueAnimator) {
|
||||
fabTranslationYAnimator = (ValueAnimator) obj;
|
||||
}
|
||||
// Make sure that any current animation is cancelled
|
||||
if (fabTranslationYAnimator != null && fabTranslationYAnimator.isRunning()) {
|
||||
fabTranslationYAnimator.cancel();
|
||||
}
|
||||
|
||||
final float currentTransY = ViewCompat.getTranslationY(child);
|
||||
|
||||
if (child.isShown()
|
||||
&& Math.abs(currentTransY - targetTransY) > (child.getHeight() * 0.667f)) {
|
||||
// If the FAB will be travelling by more than 2/3 of it's height, let's animate
|
||||
// it instead
|
||||
if (fabTranslationYAnimator == null) {
|
||||
fabTranslationYAnimator = ValueAnimator.ofFloat();
|
||||
fabTranslationYAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
|
||||
fabTranslationYAnimator.addUpdateListener(
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
ViewCompat.setTranslationY(child, (Float) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
child.setTag(R.id.fab_translation_y_animator, fabTranslationYAnimator);
|
||||
}
|
||||
fabTranslationYAnimator.setFloatValues(currentTransY, targetTransY);
|
||||
fabTranslationYAnimator.start();
|
||||
} else {
|
||||
// Now update the translation Y
|
||||
ViewCompat.setTranslationY(child, targetTransY);
|
||||
}
|
||||
|
||||
child.setTag(R.id.fab_translation_y, targetTransY);
|
||||
}
|
||||
|
||||
private float getChildTranslationYForSnackbar(CoordinatorLayout parent,
|
||||
EhDrawerLayout child) {
|
||||
float minOffset = 0;
|
||||
final List<View> dependencies = parent.getDependencies(child);
|
||||
for (int i = 0, z = dependencies.size(); i < z; i++) {
|
||||
final View view = dependencies.get(i);
|
||||
if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(child, view)) {
|
||||
minOffset = Math.min(minOffset,
|
||||
ViewCompat.getTranslationY(view) - view.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
return minOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ package com.hippo.ehviewer.widget;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.drawerlayout.DrawerLayoutChild;
|
||||
import com.hippo.widget.DrawerView;
|
||||
import com.hippo.widget.drawerlayout.DrawerLayoutChild;
|
||||
|
||||
public class EhDrawerView extends DrawerView implements DrawerLayoutChild {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.widget.drawerlayout.DrawerLayoutChild;
|
||||
import com.hippo.drawerlayout.DrawerLayoutChild;
|
||||
|
||||
public class EhNavigationView extends NavigationView implements DrawerLayoutChild {
|
||||
|
||||
@@ -49,7 +49,9 @@ public class EhNavigationView extends NavigationView implements DrawerLayoutChil
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setWillNotDraw(false);
|
||||
if (DRAW_SCRIM) {
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,8 +19,8 @@ package com.hippo.ehviewer.widget;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.drawerlayout.DrawerLayoutChild;
|
||||
import com.hippo.scene.StageLayout;
|
||||
import com.hippo.widget.drawerlayout.DrawerLayoutChild;
|
||||
|
||||
public class EhStageLayout extends StageLayout implements DrawerLayoutChild {
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Build;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -60,15 +59,8 @@ public class GalleryGuideView extends ViewGroup implements View.OnClickListener
|
||||
init(context);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public GalleryGuideView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void init(Context context) {
|
||||
mBgColor = context.getResources().getColor(R.color.guide_bg);
|
||||
mBgColor = ContextCompat.getColor(context, R.color.guide_bg);
|
||||
mPaint = new Paint();
|
||||
mPaint.setColor(Color.WHITE);
|
||||
mPaint.setStyle(Paint.Style.STROKE);
|
||||
|
||||
@@ -43,6 +43,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.dict.DictManager;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
@@ -85,6 +86,7 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
private SearchDatabase mSearchDatabase;
|
||||
private DictManager mDictManager;
|
||||
private List<String> mSuggestionList;
|
||||
private ArrayAdapter mSuggestionAdapter;
|
||||
|
||||
@@ -114,6 +116,7 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
setBackgroundResource(R.drawable.card_white_no_padding_2dp);
|
||||
|
||||
mSearchDatabase = SearchDatabase.getInstance(getContext());
|
||||
mDictManager = new DictManager(getContext());
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
inflater.inflate(R.layout.widget_search_bar, this);
|
||||
@@ -170,8 +173,11 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
|
||||
private void updateSuggestions() {
|
||||
String prefix = mEditText.getText().toString();
|
||||
String[] dictSuggestions = mDictManager.getSuggestions(prefix);
|
||||
String[] suggestions = mSearchDatabase.getSuggestions(prefix);
|
||||
|
||||
mSuggestionList.clear();
|
||||
Collections.addAll(mSuggestionList, dictSuggestions);
|
||||
Collections.addAll(mSuggestionList, suggestions);
|
||||
if (mSuggestionList.size() == 0) {
|
||||
removeListHeader();
|
||||
@@ -479,10 +485,15 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
|
||||
|
||||
public interface Helper {
|
||||
void onClickTitle();
|
||||
|
||||
void onClickLeftIcon();
|
||||
|
||||
void onClickRightIcon();
|
||||
|
||||
void onSearchEditTextClick();
|
||||
|
||||
void onApplySearch(String query);
|
||||
|
||||
void onSearchEditTextBackPressed();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ public class SearchDatabase {
|
||||
public String[] getSuggestions(String prefix) {
|
||||
List<String> queryList = new LinkedList<>();
|
||||
|
||||
// TODO add limit
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("SELECT * FROM ").append(TABLE_SUGGESTIONS);
|
||||
if (!TextUtils.isEmpty(prefix)) {
|
||||
|
||||
@@ -43,7 +43,7 @@ import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.widget.RadioGridGroup;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
@@ -139,7 +139,7 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
mNormalSearchModeHelp = (ImageView) normalView.findViewById(R.id.normal_search_mode_help);
|
||||
mEnableAdvanceSwitch = (SwitchCompat) normalView.findViewById(R.id.search_enable_advance);
|
||||
mNormalSearchModeHelp.setOnClickListener(this);
|
||||
RippleSalon.addRipple(mNormalSearchModeHelp, false);
|
||||
Ripple.addRipple(mNormalSearchModeHelp, false);
|
||||
mEnableAdvanceSwitch.setOnCheckedChangeListener(SearchLayout.this);
|
||||
mEnableAdvanceSwitch.setSwitchPadding(resources.getDimensionPixelSize(R.dimen.switch_padding));
|
||||
|
||||
|
||||
@@ -240,7 +240,8 @@ public class ImageTexture implements Texture, Animatable {
|
||||
private class AnimateRunnable implements Runnable {
|
||||
|
||||
public void doRun() {
|
||||
long lastTime = SystemClock.currentThreadTimeMillis();
|
||||
long lastTime = SystemClock.elapsedRealtime();
|
||||
long lastDelay = -1L;
|
||||
|
||||
synchronized (mImage) {
|
||||
// Check recycled
|
||||
@@ -309,9 +310,12 @@ public class ImageTexture implements Texture, Animatable {
|
||||
|
||||
mImage.advance();
|
||||
long delay = mImage.getDelay();
|
||||
long time = System.currentTimeMillis();
|
||||
delay -= time - lastTime;
|
||||
long time = SystemClock.elapsedRealtime();
|
||||
if (-1L != lastDelay) {
|
||||
delay -= (time - lastTime) - lastDelay;
|
||||
}
|
||||
lastTime = time;
|
||||
lastDelay = delay;
|
||||
mFrameDirty.lazySet(true);
|
||||
invalidateSelf();
|
||||
|
||||
|
||||
@@ -16,11 +16,9 @@
|
||||
|
||||
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;
|
||||
@@ -48,12 +46,6 @@ public class ActivityPreference extends Preference {
|
||||
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);
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
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.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -79,12 +77,6 @@ public abstract class DialogPreference extends Preference implements
|
||||
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);
|
||||
|
||||
@@ -52,11 +52,6 @@ public class ListPreference extends DialogPreference {
|
||||
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);
|
||||
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package com.hippo.preference;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.AttributeSet;
|
||||
@@ -34,7 +32,6 @@ public class MessagePreference extends DialogPreference {
|
||||
private CharSequence mDialogMessage;
|
||||
private boolean mDialogMessageLinkify;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public MessagePreference(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0, 0);
|
||||
@@ -50,12 +47,6 @@ public class MessagePreference extends DialogPreference {
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
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.MessagePreference, defStyleAttr, defStyleRes);
|
||||
String message = a.getString(R.styleable.MessagePreference_dialogMessage);
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package com.hippo.preference;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.preference.TwoStatePreference;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
@@ -82,12 +80,6 @@ public class SwitchPreference extends TwoStatePreference {
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
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) {
|
||||
setWidgetLayoutResource(R.layout.preference_widget_fixed_switch);
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwitchPreference, defStyleAttr, defStyleRes);
|
||||
|
||||
+10
-1
@@ -17,6 +17,7 @@
|
||||
package com.hippo.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.Service;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
@@ -30,7 +31,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
public class ActivityHelper {
|
||||
public class AppHelper {
|
||||
|
||||
public static boolean sendEmail(@NonNull Activity from, @NonNull String address,
|
||||
@Nullable String subject, @Nullable String text) {
|
||||
@@ -86,4 +87,12 @@ public class ActivityHelper {
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideSoftInput(Dialog dialog) {
|
||||
View view = dialog.getCurrentFocus();
|
||||
if (view != null) {
|
||||
InputMethodManager imm = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,4 +56,13 @@ public final class TextUrl {
|
||||
|
||||
return spannable == null ? content : spannable;
|
||||
}
|
||||
|
||||
public static String getFileName(String path) {
|
||||
if (path == null) {
|
||||
return path;
|
||||
}
|
||||
|
||||
int start = path.lastIndexOf("/");
|
||||
return start == -1 ? path : path.substring(start + 1);
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ import android.view.animation.Interpolator;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.hotspot.HotspotTouchHelper;
|
||||
import com.hippo.hotspot.Hotspot;
|
||||
import com.hippo.hotspot.Hotspotable;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
@@ -81,7 +81,7 @@ public class CheckTextView extends TextView implements OnClickListener, Hotspota
|
||||
|
||||
setOnClickListener(this);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
HotspotTouchHelper.setHotspotTouchHelper(this, new HotspotTouchHelper(this));
|
||||
Hotspot.addHotspotable(this, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class CheckTextView extends TextView implements OnClickListener, Hotspota
|
||||
return mRadius;
|
||||
}
|
||||
|
||||
private Animator.AnimatorListener mAnimatorListener = new SimpleAnimatorListener() {
|
||||
private final Animator.AnimatorListener mAnimatorListener = new SimpleAnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mAnimator = null;
|
||||
|
||||
@@ -36,10 +36,10 @@ import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.easyrecyclerview.HandlerDrawable;
|
||||
import com.hippo.easyrecyclerview.LayoutManagerUtils;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.refreshlayout.RefreshLayout;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.refreshlayout.RefreshLayout;
|
||||
import com.hippo.yorozuya.IntIdGenerator;
|
||||
import com.hippo.yorozuya.IntList;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
|
||||
@@ -28,7 +28,7 @@ import android.widget.TextView;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -77,7 +77,7 @@ public class DirExplorer extends EasyRecyclerView implements EasyRecyclerView.On
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setShowLastDivider(true);
|
||||
addItemDecoration(decoration);
|
||||
setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
setSelector(Ripple.generateRippleDrawable(context, false));
|
||||
setOnItemClickListener(this);
|
||||
|
||||
mCurrentFile = Environment.getExternalStorageDirectory();
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,26 +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.widget.drawerlayout;
|
||||
|
||||
public interface DrawerLayoutChild {
|
||||
|
||||
void setFitPadding(int top, int bottom);
|
||||
|
||||
int getLayoutPaddingTop();
|
||||
|
||||
int getLayoutPaddingBottom();
|
||||
}
|
||||
@@ -1,23 +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.widget.drawerlayout;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public interface DrawerLayoutInsetsHelper {
|
||||
void setupForWindowInsets(View view);
|
||||
}
|
||||
@@ -1,32 +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.widget.drawerlayout;
|
||||
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.view.View;
|
||||
|
||||
public class DrawerLayoutInsetsHelperL implements DrawerLayoutInsetsHelper {
|
||||
|
||||
@Override
|
||||
public void setupForWindowInsets(View view) {
|
||||
if (ViewCompat.getFitsSystemWindows(view)) {
|
||||
// Now set the sys ui flags to enable us to lay out in the window insets
|
||||
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* 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.refreshlayout;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RadialGradient;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.view.animation.Animation;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/**
|
||||
* Private class created to work around issues with AnimationListeners being
|
||||
* called before the animation is actually complete and support shadows on older
|
||||
* platforms.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
class CircleImageView extends ImageView {
|
||||
|
||||
private static final int KEY_SHADOW_COLOR = 0x1E000000;
|
||||
private static final int FILL_SHADOW_COLOR = 0x3D000000;
|
||||
// PX
|
||||
private static final float X_OFFSET = 0f;
|
||||
private static final float Y_OFFSET = 1.75f;
|
||||
private static final float SHADOW_RADIUS = 3.5f;
|
||||
private static final int SHADOW_ELEVATION = 4;
|
||||
|
||||
private Animation.AnimationListener mListener;
|
||||
private int mShadowRadius;
|
||||
|
||||
public CircleImageView(Context context, int color, final float radius) {
|
||||
super(context);
|
||||
final float density = getContext().getResources().getDisplayMetrics().density;
|
||||
final int diameter = (int) (radius * density * 2);
|
||||
final int shadowYOffset = (int) (density * Y_OFFSET);
|
||||
final int shadowXOffset = (int) (density * X_OFFSET);
|
||||
|
||||
mShadowRadius = (int) (density * SHADOW_RADIUS);
|
||||
|
||||
ShapeDrawable circle;
|
||||
if (elevationSupported()) {
|
||||
circle = new ShapeDrawable(new OvalShape());
|
||||
ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
|
||||
} else {
|
||||
OvalShape oval = new OvalShadow(mShadowRadius, diameter);
|
||||
circle = new ShapeDrawable(oval);
|
||||
ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
|
||||
circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset,
|
||||
KEY_SHADOW_COLOR);
|
||||
final int padding = mShadowRadius;
|
||||
// set padding so the inner image sits correctly within the shadow.
|
||||
setPadding(padding, padding, padding, padding);
|
||||
}
|
||||
circle.getPaint().setColor(color);
|
||||
setBackgroundDrawable(circle);
|
||||
}
|
||||
|
||||
private boolean elevationSupported() {
|
||||
return android.os.Build.VERSION.SDK_INT >= 21;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
if (!elevationSupported()) {
|
||||
setMeasuredDimension(getMeasuredWidth() + mShadowRadius*2, getMeasuredHeight()
|
||||
+ mShadowRadius*2);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAnimationListener(Animation.AnimationListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart() {
|
||||
super.onAnimationStart();
|
||||
if (mListener != null) {
|
||||
mListener.onAnimationStart(getAnimation());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd() {
|
||||
super.onAnimationEnd();
|
||||
if (mListener != null) {
|
||||
mListener.onAnimationEnd(getAnimation());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the background color of the circle image view.
|
||||
*
|
||||
* @param colorRes Id of a color resource.
|
||||
*/
|
||||
public void setBackgroundColorRes(int colorRes) {
|
||||
setBackgroundColor(getContext().getResources().getColor(colorRes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(int color) {
|
||||
if (getBackground() instanceof ShapeDrawable) {
|
||||
((ShapeDrawable) getBackground()).getPaint().setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
private class OvalShadow extends OvalShape {
|
||||
private RadialGradient mRadialGradient;
|
||||
private Paint mShadowPaint;
|
||||
private int mCircleDiameter;
|
||||
|
||||
public OvalShadow(int shadowRadius, int circleDiameter) {
|
||||
super();
|
||||
mShadowPaint = new Paint();
|
||||
mShadowRadius = shadowRadius;
|
||||
mCircleDiameter = circleDiameter;
|
||||
mRadialGradient = new RadialGradient(mCircleDiameter / 2, mCircleDiameter / 2,
|
||||
mShadowRadius, new int[] {
|
||||
FILL_SHADOW_COLOR, Color.TRANSPARENT
|
||||
}, null, Shader.TileMode.CLAMP);
|
||||
mShadowPaint.setShader(mRadialGradient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, Paint paint) {
|
||||
final int viewWidth = CircleImageView.this.getWidth();
|
||||
final int viewHeight = CircleImageView.this.getHeight();
|
||||
canvas.drawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2 + mShadowRadius),
|
||||
mShadowPaint);
|
||||
canvas.drawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2), paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,791 +0,0 @@
|
||||
/*
|
||||
* 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.refreshlayout;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.animation.FastOutSlowInInterpolator;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Fancy progress indicator for Material theme.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
class MaterialProgressDrawable extends Drawable implements Animatable {
|
||||
private static final Interpolator LINEAR_INTERPOLATOR = new LinearInterpolator();
|
||||
private static final Interpolator MATERIAL_INTERPOLATOR = new FastOutSlowInInterpolator();
|
||||
|
||||
private static final float FULL_ROTATION = 1080.0f;
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@IntDef({LARGE, DEFAULT})
|
||||
public @interface ProgressDrawableSize {}
|
||||
// Maps to ProgressBar.Large style
|
||||
static final int LARGE = 0;
|
||||
// Maps to ProgressBar default style
|
||||
static final int DEFAULT = 1;
|
||||
|
||||
// Maps to ProgressBar default style
|
||||
private static final int CIRCLE_DIAMETER = 40;
|
||||
private static final float CENTER_RADIUS = 8.75f; //should add up to 10 when + stroke_width
|
||||
private static final float STROKE_WIDTH = 2.5f;
|
||||
|
||||
// Maps to ProgressBar.Large style
|
||||
private static final int CIRCLE_DIAMETER_LARGE = 56;
|
||||
private static final float CENTER_RADIUS_LARGE = 12.5f;
|
||||
private static final float STROKE_WIDTH_LARGE = 3f;
|
||||
|
||||
private final int[] COLORS = new int[] {
|
||||
Color.BLACK
|
||||
};
|
||||
|
||||
/**
|
||||
* The value in the linear interpolator for animating the drawable at which
|
||||
* the color transition should start
|
||||
*/
|
||||
private static final float COLOR_START_DELAY_OFFSET = 0.75f;
|
||||
private static final float END_TRIM_START_DELAY_OFFSET = 0.5f;
|
||||
private static final float START_TRIM_DURATION_OFFSET = 0.5f;
|
||||
|
||||
/** The duration of a single progress spin in milliseconds. */
|
||||
private static final int ANIMATION_DURATION = 1332;
|
||||
|
||||
/** The number of points in the progress "star". */
|
||||
private static final float NUM_POINTS = 5f;
|
||||
/** The list of animators operating on this drawable. */
|
||||
private final ArrayList<Animation> mAnimators = new ArrayList<Animation>();
|
||||
|
||||
/** The indicator ring, used to manage animation state. */
|
||||
private final Ring mRing;
|
||||
|
||||
/** Canvas rotation in degrees. */
|
||||
private float mRotation;
|
||||
|
||||
/** Layout info for the arrowhead in dp */
|
||||
private static final int ARROW_WIDTH = 10;
|
||||
private static final int ARROW_HEIGHT = 5;
|
||||
private static final float ARROW_OFFSET_ANGLE = 5;
|
||||
|
||||
/** Layout info for the arrowhead for the large spinner in dp */
|
||||
private static final int ARROW_WIDTH_LARGE = 12;
|
||||
private static final int ARROW_HEIGHT_LARGE = 6;
|
||||
private static final float MAX_PROGRESS_ARC = .8f;
|
||||
|
||||
private Resources mResources;
|
||||
private View mParent;
|
||||
private Animation mAnimation;
|
||||
private float mRotationCount;
|
||||
private double mWidth;
|
||||
private double mHeight;
|
||||
boolean mFinishing;
|
||||
|
||||
public MaterialProgressDrawable(Context context, View parent) {
|
||||
mParent = parent;
|
||||
mResources = context.getResources();
|
||||
|
||||
mRing = new Ring(mCallback);
|
||||
mRing.setColors(COLORS);
|
||||
|
||||
updateSizes(DEFAULT);
|
||||
setupAnimators();
|
||||
}
|
||||
|
||||
private void setSizeParameters(double progressCircleWidth, double progressCircleHeight,
|
||||
double centerRadius, double strokeWidth, float arrowWidth, float arrowHeight) {
|
||||
final Ring ring = mRing;
|
||||
final DisplayMetrics metrics = mResources.getDisplayMetrics();
|
||||
final float screenDensity = metrics.density;
|
||||
|
||||
mWidth = progressCircleWidth * screenDensity;
|
||||
mHeight = progressCircleHeight * screenDensity;
|
||||
ring.setStrokeWidth((float) strokeWidth * screenDensity);
|
||||
ring.setCenterRadius(centerRadius * screenDensity);
|
||||
ring.setColorIndex(0);
|
||||
ring.setArrowDimensions(arrowWidth * screenDensity, arrowHeight * screenDensity);
|
||||
ring.setInsets((int) mWidth, (int) mHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the overall size for the progress spinner. This updates the radius
|
||||
* and stroke width of the ring.
|
||||
*
|
||||
* @param size One of {@link #LARGE} or
|
||||
* {@link #DEFAULT}
|
||||
*/
|
||||
public void updateSizes(@ProgressDrawableSize int size) {
|
||||
if (size == LARGE) {
|
||||
setSizeParameters(CIRCLE_DIAMETER_LARGE, CIRCLE_DIAMETER_LARGE, CENTER_RADIUS_LARGE,
|
||||
STROKE_WIDTH_LARGE, ARROW_WIDTH_LARGE, ARROW_HEIGHT_LARGE);
|
||||
} else {
|
||||
setSizeParameters(CIRCLE_DIAMETER, CIRCLE_DIAMETER, CENTER_RADIUS, STROKE_WIDTH,
|
||||
ARROW_WIDTH, ARROW_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param show Set to true to display the arrowhead on the progress spinner.
|
||||
*/
|
||||
public void showArrow(boolean show) {
|
||||
mRing.setShowArrow(show);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scale Set the scale of the arrowhead for the spinner.
|
||||
*/
|
||||
public void setArrowScale(float scale) {
|
||||
mRing.setArrowScale(scale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start and end trim for the progress spinner arc.
|
||||
*
|
||||
* @param startAngle start angle
|
||||
* @param endAngle end angle
|
||||
*/
|
||||
public void setStartEndTrim(float startAngle, float endAngle) {
|
||||
mRing.setStartTrim(startAngle);
|
||||
mRing.setEndTrim(endAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the amount of rotation to apply to the progress spinner.
|
||||
*
|
||||
* @param rotation Rotation is from [0..1]
|
||||
*/
|
||||
public void setProgressRotation(float rotation) {
|
||||
mRing.setRotation(rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the background color of the circle image view.
|
||||
*/
|
||||
public void setBackgroundColor(int color) {
|
||||
mRing.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the colors used in the progress animation from color resources.
|
||||
* The first color will also be the color of the bar that grows in response
|
||||
* to a user swipe gesture.
|
||||
*
|
||||
* @param colors
|
||||
*/
|
||||
public void setColorSchemeColors(int... colors) {
|
||||
mRing.setColors(colors);
|
||||
mRing.setColorIndex(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return (int) mHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return (int) mWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas c) {
|
||||
final Rect bounds = getBounds();
|
||||
final int saveCount = c.save();
|
||||
c.rotate(mRotation, bounds.exactCenterX(), bounds.exactCenterY());
|
||||
mRing.draw(c, bounds);
|
||||
c.restoreToCount(saveCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
mRing.setAlpha(alpha);
|
||||
}
|
||||
|
||||
public int getAlpha() {
|
||||
return mRing.getAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
mRing.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
void setRotation(float rotation) {
|
||||
mRotation = rotation;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private float getRotation() {
|
||||
return mRotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
final ArrayList<Animation> animators = mAnimators;
|
||||
final int N = animators.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
final Animation animator = animators.get(i);
|
||||
if (animator.hasStarted() && !animator.hasEnded()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
mAnimation.reset();
|
||||
mRing.storeOriginals();
|
||||
// Already showing some part of the ring
|
||||
if (mRing.getEndTrim() != mRing.getStartTrim()) {
|
||||
mFinishing = true;
|
||||
mAnimation.setDuration(ANIMATION_DURATION/2);
|
||||
mParent.startAnimation(mAnimation);
|
||||
} else {
|
||||
mRing.setColorIndex(0);
|
||||
mRing.resetOriginals();
|
||||
mAnimation.setDuration(ANIMATION_DURATION);
|
||||
mParent.startAnimation(mAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
mParent.clearAnimation();
|
||||
setRotation(0);
|
||||
mRing.setShowArrow(false);
|
||||
mRing.setColorIndex(0);
|
||||
mRing.resetOriginals();
|
||||
}
|
||||
|
||||
private float getMinProgressArc(Ring ring) {
|
||||
return (float) Math.toRadians(
|
||||
ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius()));
|
||||
}
|
||||
|
||||
// Adapted from ArgbEvaluator.java
|
||||
private int evaluateColorChange(float fraction, int startValue, int endValue) {
|
||||
int startInt = (Integer) startValue;
|
||||
int startA = (startInt >> 24) & 0xff;
|
||||
int startR = (startInt >> 16) & 0xff;
|
||||
int startG = (startInt >> 8) & 0xff;
|
||||
int startB = startInt & 0xff;
|
||||
|
||||
int endInt = (Integer) endValue;
|
||||
int endA = (endInt >> 24) & 0xff;
|
||||
int endR = (endInt >> 16) & 0xff;
|
||||
int endG = (endInt >> 8) & 0xff;
|
||||
int endB = endInt & 0xff;
|
||||
|
||||
return (int)((startA + (int)(fraction * (endA - startA))) << 24) |
|
||||
(int)((startR + (int)(fraction * (endR - startR))) << 16) |
|
||||
(int)((startG + (int)(fraction * (endG - startG))) << 8) |
|
||||
(int)((startB + (int)(fraction * (endB - startB))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ring color if this is within the last 25% of the animation.
|
||||
* The new ring color will be a translation from the starting ring color to
|
||||
* the next color.
|
||||
*/
|
||||
private void updateRingColor(float interpolatedTime, Ring ring) {
|
||||
if (interpolatedTime > COLOR_START_DELAY_OFFSET) {
|
||||
// scale the interpolatedTime so that the full
|
||||
// transformation from 0 - 1 takes place in the
|
||||
// remaining time
|
||||
ring.setColor(evaluateColorChange((interpolatedTime - COLOR_START_DELAY_OFFSET)
|
||||
/ (1.0f - COLOR_START_DELAY_OFFSET), ring.getStartingColor(),
|
||||
ring.getNextColor()));
|
||||
}
|
||||
}
|
||||
|
||||
private void applyFinishTranslation(float interpolatedTime, Ring ring) {
|
||||
// shrink back down and complete a full rotation before
|
||||
// starting other circles
|
||||
// Rotation goes between [0..1].
|
||||
updateRingColor(interpolatedTime, ring);
|
||||
float targetRotation = (float) (Math.floor(ring.getStartingRotation() / MAX_PROGRESS_ARC)
|
||||
+ 1f);
|
||||
final float minProgressArc = getMinProgressArc(ring);
|
||||
final float startTrim = ring.getStartingStartTrim()
|
||||
+ (ring.getStartingEndTrim() - minProgressArc - ring.getStartingStartTrim())
|
||||
* interpolatedTime;
|
||||
ring.setStartTrim(startTrim);
|
||||
ring.setEndTrim(ring.getStartingEndTrim());
|
||||
final float rotation = ring.getStartingRotation()
|
||||
+ ((targetRotation - ring.getStartingRotation()) * interpolatedTime);
|
||||
ring.setRotation(rotation);
|
||||
}
|
||||
|
||||
private void setupAnimators() {
|
||||
final Ring ring = mRing;
|
||||
final Animation animation = new Animation() {
|
||||
@Override
|
||||
public void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
if (mFinishing) {
|
||||
applyFinishTranslation(interpolatedTime, ring);
|
||||
} else {
|
||||
// The minProgressArc is calculated from 0 to create an
|
||||
// angle that matches the stroke width.
|
||||
final float minProgressArc = getMinProgressArc(ring);
|
||||
final float startingEndTrim = ring.getStartingEndTrim();
|
||||
final float startingTrim = ring.getStartingStartTrim();
|
||||
final float startingRotation = ring.getStartingRotation();
|
||||
|
||||
updateRingColor(interpolatedTime, ring);
|
||||
|
||||
// Moving the start trim only occurs in the first 50% of a
|
||||
// single ring animation
|
||||
if (interpolatedTime <= START_TRIM_DURATION_OFFSET) {
|
||||
// scale the interpolatedTime so that the full
|
||||
// transformation from 0 - 1 takes place in the
|
||||
// remaining time
|
||||
final float scaledTime = (interpolatedTime)
|
||||
/ (1.0f - START_TRIM_DURATION_OFFSET);
|
||||
final float startTrim = startingTrim
|
||||
+ ((MAX_PROGRESS_ARC - minProgressArc) * MATERIAL_INTERPOLATOR
|
||||
.getInterpolation(scaledTime));
|
||||
ring.setStartTrim(startTrim);
|
||||
}
|
||||
|
||||
// Moving the end trim starts after 50% of a single ring
|
||||
// animation completes
|
||||
if (interpolatedTime > END_TRIM_START_DELAY_OFFSET) {
|
||||
// scale the interpolatedTime so that the full
|
||||
// transformation from 0 - 1 takes place in the
|
||||
// remaining time
|
||||
final float minArc = MAX_PROGRESS_ARC - minProgressArc;
|
||||
float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET)
|
||||
/ (1.0f - START_TRIM_DURATION_OFFSET);
|
||||
final float endTrim = startingEndTrim
|
||||
+ (minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime));
|
||||
ring.setEndTrim(endTrim);
|
||||
}
|
||||
|
||||
final float rotation = startingRotation + (0.25f * interpolatedTime);
|
||||
ring.setRotation(rotation);
|
||||
|
||||
float groupRotation = ((FULL_ROTATION / NUM_POINTS) * interpolatedTime)
|
||||
+ (FULL_ROTATION * (mRotationCount / NUM_POINTS));
|
||||
setRotation(groupRotation);
|
||||
}
|
||||
}
|
||||
};
|
||||
animation.setRepeatCount(Animation.INFINITE);
|
||||
animation.setRepeatMode(Animation.RESTART);
|
||||
animation.setInterpolator(LINEAR_INTERPOLATOR);
|
||||
animation.setAnimationListener(new Animation.AnimationListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
mRotationCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
ring.storeOriginals();
|
||||
ring.goToNextColor();
|
||||
ring.setStartTrim(ring.getEndTrim());
|
||||
if (mFinishing) {
|
||||
// finished closing the last ring from the swipe gesture; go
|
||||
// into progress mode
|
||||
mFinishing = false;
|
||||
animation.setDuration(ANIMATION_DURATION);
|
||||
ring.setShowArrow(false);
|
||||
} else {
|
||||
mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
|
||||
}
|
||||
}
|
||||
});
|
||||
mAnimation = animation;
|
||||
}
|
||||
|
||||
private final Callback mCallback = new Callback() {
|
||||
@Override
|
||||
public void invalidateDrawable(Drawable d) {
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleDrawable(Drawable d, Runnable what, long when) {
|
||||
scheduleSelf(what, when);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unscheduleDrawable(Drawable d, Runnable what) {
|
||||
unscheduleSelf(what);
|
||||
}
|
||||
};
|
||||
|
||||
private static class Ring {
|
||||
private final RectF mTempBounds = new RectF();
|
||||
private final Paint mPaint = new Paint();
|
||||
private final Paint mArrowPaint = new Paint();
|
||||
|
||||
private final Callback mCallback;
|
||||
|
||||
private float mStartTrim = 0.0f;
|
||||
private float mEndTrim = 0.0f;
|
||||
private float mRotation = 0.0f;
|
||||
private float mStrokeWidth = 5.0f;
|
||||
private float mStrokeInset = 2.5f;
|
||||
|
||||
private int[] mColors;
|
||||
// mColorIndex represents the offset into the available mColors that the
|
||||
// progress circle should currently display. As the progress circle is
|
||||
// animating, the mColorIndex moves by one to the next available color.
|
||||
private int mColorIndex;
|
||||
private float mStartingStartTrim;
|
||||
private float mStartingEndTrim;
|
||||
private float mStartingRotation;
|
||||
private boolean mShowArrow;
|
||||
private Path mArrow;
|
||||
private float mArrowScale;
|
||||
private double mRingCenterRadius;
|
||||
private int mArrowWidth;
|
||||
private int mArrowHeight;
|
||||
private int mAlpha;
|
||||
private final Paint mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private int mBackgroundColor;
|
||||
private int mCurrentColor;
|
||||
|
||||
public Ring(Callback callback) {
|
||||
mCallback = callback;
|
||||
|
||||
mPaint.setStrokeCap(Paint.Cap.SQUARE);
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setStyle(Style.STROKE);
|
||||
|
||||
mArrowPaint.setStyle(Style.FILL);
|
||||
mArrowPaint.setAntiAlias(true);
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int color) {
|
||||
mBackgroundColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dimensions of the arrowhead.
|
||||
*
|
||||
* @param width Width of the hypotenuse of the arrow head
|
||||
* @param height Height of the arrow point
|
||||
*/
|
||||
public void setArrowDimensions(float width, float height) {
|
||||
mArrowWidth = (int) width;
|
||||
mArrowHeight = (int) height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the progress spinner
|
||||
*/
|
||||
public void draw(Canvas c, Rect bounds) {
|
||||
final RectF arcBounds = mTempBounds;
|
||||
arcBounds.set(bounds);
|
||||
arcBounds.inset(mStrokeInset, mStrokeInset);
|
||||
|
||||
final float startAngle = (mStartTrim + mRotation) * 360;
|
||||
final float endAngle = (mEndTrim + mRotation) * 360;
|
||||
float sweepAngle = endAngle - startAngle;
|
||||
|
||||
mPaint.setColor(mCurrentColor);
|
||||
c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint);
|
||||
|
||||
drawTriangle(c, startAngle, sweepAngle, bounds);
|
||||
|
||||
if (mAlpha < 255) {
|
||||
mCirclePaint.setColor(mBackgroundColor);
|
||||
mCirclePaint.setAlpha(255 - mAlpha);
|
||||
c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2,
|
||||
mCirclePaint);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) {
|
||||
if (mShowArrow) {
|
||||
if (mArrow == null) {
|
||||
mArrow = new Path();
|
||||
mArrow.setFillType(Path.FillType.EVEN_ODD);
|
||||
} else {
|
||||
mArrow.reset();
|
||||
}
|
||||
|
||||
// Adjust the position of the triangle so that it is inset as
|
||||
// much as the arc, but also centered on the arc.
|
||||
float inset = (int) mStrokeInset / 2 * mArrowScale;
|
||||
float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX());
|
||||
float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY());
|
||||
|
||||
// Update the path each time. This works around an issue in SKIA
|
||||
// where concatenating a rotation matrix to a scale matrix
|
||||
// ignored a starting negative rotation. This appears to have
|
||||
// been fixed as of API 21.
|
||||
mArrow.moveTo(0, 0);
|
||||
mArrow.lineTo(mArrowWidth * mArrowScale, 0);
|
||||
mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight
|
||||
* mArrowScale));
|
||||
mArrow.offset(x - inset, y);
|
||||
mArrow.close();
|
||||
// draw a triangle
|
||||
mArrowPaint.setColor(mCurrentColor);
|
||||
c.rotate(startAngle + sweepAngle - ARROW_OFFSET_ANGLE, bounds.exactCenterX(),
|
||||
bounds.exactCenterY());
|
||||
c.drawPath(mArrow, mArrowPaint);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the colors the progress spinner alternates between.
|
||||
*
|
||||
* @param colors Array of integers describing the colors. Must be non-<code>null</code>.
|
||||
*/
|
||||
public void setColors(@NonNull int[] colors) {
|
||||
mColors = colors;
|
||||
// if colors are reset, make sure to reset the color index as well
|
||||
setColorIndex(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the absolute color of the progress spinner. This is should only
|
||||
* be used when animating between current and next color when the
|
||||
* spinner is rotating.
|
||||
*
|
||||
* @param color int describing the color.
|
||||
*/
|
||||
public void setColor(int color) {
|
||||
mCurrentColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param index Index into the color array of the color to display in
|
||||
* the progress spinner.
|
||||
*/
|
||||
public void setColorIndex(int index) {
|
||||
mColorIndex = index;
|
||||
mCurrentColor = mColors[mColorIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int describing the next color the progress spinner should use when drawing.
|
||||
*/
|
||||
public int getNextColor() {
|
||||
return mColors[getNextColorIndex()];
|
||||
}
|
||||
|
||||
private int getNextColorIndex() {
|
||||
return (mColorIndex + 1) % (mColors.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proceed to the next available ring color. This will automatically
|
||||
* wrap back to the beginning of colors.
|
||||
*/
|
||||
public void goToNextColor() {
|
||||
setColorIndex(getNextColorIndex());
|
||||
}
|
||||
|
||||
public void setColorFilter(ColorFilter filter) {
|
||||
mPaint.setColorFilter(filter);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param alpha Set the alpha of the progress spinner and associated arrowhead.
|
||||
*/
|
||||
public void setAlpha(int alpha) {
|
||||
mAlpha = alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Current alpha of the progress spinner and arrowhead.
|
||||
*/
|
||||
public int getAlpha() {
|
||||
return mAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strokeWidth Set the stroke width of the progress spinner in pixels.
|
||||
*/
|
||||
public void setStrokeWidth(float strokeWidth) {
|
||||
mStrokeWidth = strokeWidth;
|
||||
mPaint.setStrokeWidth(strokeWidth);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public float getStrokeWidth() {
|
||||
return mStrokeWidth;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setStartTrim(float startTrim) {
|
||||
mStartTrim = startTrim;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public float getStartTrim() {
|
||||
return mStartTrim;
|
||||
}
|
||||
|
||||
public float getStartingStartTrim() {
|
||||
return mStartingStartTrim;
|
||||
}
|
||||
|
||||
public float getStartingEndTrim() {
|
||||
return mStartingEndTrim;
|
||||
}
|
||||
|
||||
public int getStartingColor() {
|
||||
return mColors[mColorIndex];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setEndTrim(float endTrim) {
|
||||
mEndTrim = endTrim;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public float getEndTrim() {
|
||||
return mEndTrim;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setRotation(float rotation) {
|
||||
mRotation = rotation;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public float getRotation() {
|
||||
return mRotation;
|
||||
}
|
||||
|
||||
public void setInsets(int width, int height) {
|
||||
final float minEdge = (float) Math.min(width, height);
|
||||
float insets;
|
||||
if (mRingCenterRadius <= 0 || minEdge < 0) {
|
||||
insets = (float) Math.ceil(mStrokeWidth / 2.0f);
|
||||
} else {
|
||||
insets = (float) (minEdge / 2.0f - mRingCenterRadius);
|
||||
}
|
||||
mStrokeInset = insets;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public float getInsets() {
|
||||
return mStrokeInset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param centerRadius Inner radius in px of the circle the progress
|
||||
* spinner arc traces.
|
||||
*/
|
||||
public void setCenterRadius(double centerRadius) {
|
||||
mRingCenterRadius = centerRadius;
|
||||
}
|
||||
|
||||
public double getCenterRadius() {
|
||||
return mRingCenterRadius;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param show Set to true to show the arrow head on the progress spinner.
|
||||
*/
|
||||
public void setShowArrow(boolean show) {
|
||||
if (mShowArrow != show) {
|
||||
mShowArrow = show;
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scale Set the scale of the arrowhead for the spinner.
|
||||
*/
|
||||
public void setArrowScale(float scale) {
|
||||
if (scale != mArrowScale) {
|
||||
mArrowScale = scale;
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The amount the progress spinner is currently rotated, between [0..1].
|
||||
*/
|
||||
public float getStartingRotation() {
|
||||
return mStartingRotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the start / end trim are offset to begin with, store them so that
|
||||
* animation starts from that offset.
|
||||
*/
|
||||
public void storeOriginals() {
|
||||
mStartingStartTrim = mStartTrim;
|
||||
mStartingEndTrim = mEndTrim;
|
||||
mStartingRotation = mRotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the progress spinner to default rotation, start and end angles.
|
||||
*/
|
||||
public void resetOriginals() {
|
||||
mStartingStartTrim = 0;
|
||||
mStartingEndTrim = 0;
|
||||
mStartingRotation = 0;
|
||||
setStartTrim(0);
|
||||
setEndTrim(0);
|
||||
setRotation(0);
|
||||
}
|
||||
|
||||
private void invalidateSelf() {
|
||||
mCallback.invalidateDrawable(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,303 +0,0 @@
|
||||
/*
|
||||
* 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.refreshlayout;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.os.Build;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.view.animation.FastOutSlowInInterpolator;
|
||||
import android.view.View;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
|
||||
/**
|
||||
* Custom progress bar that shows a cycle of colors as widening circles that
|
||||
* overdraw each other. When finished, the bar is cleared from the inside out as
|
||||
* the main cycle continues. Before running, this can also indicate how close
|
||||
* the user is to triggering something (e.g. how far they need to pull down to
|
||||
* trigger a refresh).
|
||||
*/
|
||||
final class SwipeProgressBar {
|
||||
|
||||
private static final boolean SUPPORT_CLIPRECT_DIFFERENCE =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
|
||||
|
||||
// Default progress animation colors are grays.
|
||||
private final static int COLOR1 = 0xB3000000;
|
||||
private final static int COLOR2 = 0x80000000;
|
||||
private final static int COLOR3 = 0x4d000000;
|
||||
private final static int COLOR4 = 0x1a000000;
|
||||
|
||||
// The duration of the animation cycle.
|
||||
private static final int ANIMATION_DURATION_MS = 2000;
|
||||
|
||||
// The duration of the animation to clear the bar.
|
||||
private static final int FINISH_ANIMATION_DURATION_MS = 1000;
|
||||
|
||||
// Interpolator for varying the speed of the animation.
|
||||
private static final Interpolator INTERPOLATOR = new FastOutSlowInInterpolator();
|
||||
|
||||
private final Paint mPaint = new Paint();
|
||||
private final RectF mClipRect = new RectF();
|
||||
private float mTriggerPercentage;
|
||||
private long mStartTime;
|
||||
private long mFinishTime;
|
||||
private boolean mRunning;
|
||||
|
||||
// Colors used when rendering the animation,
|
||||
private int mColor1;
|
||||
private int mColor2;
|
||||
private int mColor3;
|
||||
private int mColor4;
|
||||
private View mParent;
|
||||
|
||||
private Rect mBounds = new Rect();
|
||||
|
||||
public SwipeProgressBar(View parent) {
|
||||
mParent = parent;
|
||||
mColor1 = COLOR1;
|
||||
mColor2 = COLOR2;
|
||||
mColor3 = COLOR3;
|
||||
mColor4 = COLOR4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the four colors used in the progress animation. The first color will
|
||||
* also be the color of the bar that grows in response to a user swipe
|
||||
* gesture.
|
||||
*
|
||||
* @param color1 Integer representation of a color.
|
||||
* @param color2 Integer representation of a color.
|
||||
* @param color3 Integer representation of a color.
|
||||
* @param color4 Integer representation of a color.
|
||||
*/
|
||||
void setColorScheme(int color1, int color2, int color3, int color4) {
|
||||
mColor1 = color1;
|
||||
mColor2 = color2;
|
||||
mColor3 = color3;
|
||||
mColor4 = color4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the progress the user has made toward triggering the swipe
|
||||
* gesture. and use this value to update the percentage of the trigger that
|
||||
* is shown.
|
||||
*/
|
||||
void setTriggerPercentage(float triggerPercentage) {
|
||||
mTriggerPercentage = triggerPercentage;
|
||||
mStartTime = 0;
|
||||
ViewCompat.postInvalidateOnAnimation(
|
||||
mParent, mBounds.left, mBounds.top, mBounds.right, mBounds.bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start showing the progress animation.
|
||||
*/
|
||||
void start() {
|
||||
if (!mRunning) {
|
||||
mTriggerPercentage = 0;
|
||||
mStartTime = AnimationUtils.currentAnimationTimeMillis();
|
||||
mRunning = true;
|
||||
mParent.postInvalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop showing the progress animation.
|
||||
*/
|
||||
void stop() {
|
||||
if (mRunning) {
|
||||
mTriggerPercentage = 0;
|
||||
mFinishTime = AnimationUtils.currentAnimationTimeMillis();
|
||||
mRunning = false;
|
||||
mParent.postInvalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return whether the progress animation is currently running.
|
||||
*/
|
||||
boolean isRunning() {
|
||||
return mRunning || mFinishTime > 0;
|
||||
}
|
||||
|
||||
void draw(Canvas canvas) {
|
||||
// API < 18 do not support clipRect(Region.Op.DIFFERENCE).
|
||||
// So draw twice for finish animation
|
||||
if (draw(canvas, true)) {
|
||||
draw(canvas, false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean draw(Canvas canvas, boolean first) {
|
||||
Rect bounds = mBounds;
|
||||
final int width = bounds.width();
|
||||
final int cx = bounds.centerX();
|
||||
final int cy = bounds.centerY();
|
||||
boolean drawTriggerWhileFinishing = false;
|
||||
boolean drawAgain = false;
|
||||
int restoreCount = canvas.save();
|
||||
canvas.clipRect(bounds);
|
||||
|
||||
if (mRunning || (mFinishTime > 0)) {
|
||||
long now = AnimationUtils.currentAnimationTimeMillis();
|
||||
long elapsed = (now - mStartTime) % ANIMATION_DURATION_MS;
|
||||
long iterations = (now - mStartTime) / ANIMATION_DURATION_MS;
|
||||
float rawProgress = (elapsed / (ANIMATION_DURATION_MS / 100f));
|
||||
|
||||
// If we're not running anymore, that means we're running through
|
||||
// the finish animation.
|
||||
if (!mRunning) {
|
||||
// If the finish animation is done, don't draw anything, and
|
||||
// don't repost.
|
||||
if ((now - mFinishTime) >= FINISH_ANIMATION_DURATION_MS) {
|
||||
mFinishTime = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, use a 0 opacity alpha layer to clear the animation
|
||||
// from the inside out. This layer will prevent the circles from
|
||||
// drawing within its bounds.
|
||||
long finishElapsed = (now - mFinishTime) % FINISH_ANIMATION_DURATION_MS;
|
||||
float finishProgress = (finishElapsed / (FINISH_ANIMATION_DURATION_MS / 100f));
|
||||
float pct = (finishProgress / 100f);
|
||||
// Radius of the circle is half of the screen.
|
||||
float clearRadius = width / 2 * INTERPOLATOR.getInterpolation(pct);
|
||||
if (SUPPORT_CLIPRECT_DIFFERENCE) {
|
||||
mClipRect.set(cx - clearRadius, bounds.top, cx + clearRadius, bounds.bottom);
|
||||
canvas.clipRect(mClipRect, Region.Op.DIFFERENCE);
|
||||
} else {
|
||||
if (first) {
|
||||
// First time left
|
||||
drawAgain = true;
|
||||
mClipRect.set(bounds.left, bounds.top, cx - clearRadius, bounds.bottom);
|
||||
} else {
|
||||
// Second time right
|
||||
mClipRect.set(cx + clearRadius, bounds.top, bounds.right, bounds.bottom);
|
||||
}
|
||||
canvas.clipRect(mClipRect);
|
||||
}
|
||||
// Only draw the trigger if there is a space in the center of
|
||||
// this refreshing view that needs to be filled in by the
|
||||
// trigger. If the progress view is just still animating, let it
|
||||
// continue animating.
|
||||
drawTriggerWhileFinishing = true;
|
||||
}
|
||||
|
||||
// First fill in with the last color that would have finished drawing.
|
||||
if (iterations == 0) {
|
||||
canvas.drawColor(mColor1);
|
||||
} else {
|
||||
if (rawProgress >= 0 && rawProgress < 25) {
|
||||
canvas.drawColor(mColor4);
|
||||
} else if (rawProgress >= 25 && rawProgress < 50) {
|
||||
canvas.drawColor(mColor1);
|
||||
} else if (rawProgress >= 50 && rawProgress < 75) {
|
||||
canvas.drawColor(mColor2);
|
||||
} else {
|
||||
canvas.drawColor(mColor3);
|
||||
}
|
||||
}
|
||||
|
||||
// Then draw up to 4 overlapping concentric circles of varying radii, based on how far
|
||||
// along we are in the cycle.
|
||||
// progress 0-50 draw mColor2
|
||||
// progress 25-75 draw mColor3
|
||||
// progress 50-100 draw mColor4
|
||||
// progress 75 (wrap to 25) draw mColor1
|
||||
if ((rawProgress >= 0 && rawProgress <= 25)) {
|
||||
float pct = (((rawProgress + 25) * 2) / 100f);
|
||||
drawCircle(canvas, cx, cy, mColor1, pct);
|
||||
}
|
||||
if (rawProgress >= 0 && rawProgress <= 50) {
|
||||
float pct = ((rawProgress * 2) / 100f);
|
||||
drawCircle(canvas, cx, cy, mColor2, pct);
|
||||
}
|
||||
if (rawProgress >= 25 && rawProgress <= 75) {
|
||||
float pct = (((rawProgress - 25) * 2) / 100f);
|
||||
drawCircle(canvas, cx, cy, mColor3, pct);
|
||||
}
|
||||
if (rawProgress >= 50 && rawProgress <= 100) {
|
||||
float pct = (((rawProgress - 50) * 2) / 100f);
|
||||
drawCircle(canvas, cx, cy, mColor4, pct);
|
||||
}
|
||||
if ((rawProgress >= 75 && rawProgress <= 100)) {
|
||||
float pct = (((rawProgress - 75) * 2) / 100f);
|
||||
drawCircle(canvas, cx, cy, mColor1, pct);
|
||||
}
|
||||
if (mTriggerPercentage > 0 && drawTriggerWhileFinishing) {
|
||||
// There is some portion of trigger to draw. Restore the canvas,
|
||||
// then draw the trigger. Otherwise, the trigger does not appear
|
||||
// until after the bar has finished animating and appears to
|
||||
// just jump in at a larger width than expected.
|
||||
canvas.restoreToCount(restoreCount);
|
||||
restoreCount = canvas.save();
|
||||
canvas.clipRect(bounds);
|
||||
drawTrigger(canvas, cx, cy);
|
||||
}
|
||||
// Keep running until we finish out the last cycle.
|
||||
ViewCompat.postInvalidateOnAnimation(
|
||||
mParent, bounds.left, bounds.top, bounds.right, bounds.bottom);
|
||||
} else {
|
||||
// Otherwise if we're in the middle of a trigger, draw that.
|
||||
if (mTriggerPercentage > 0 && mTriggerPercentage <= 1.0) {
|
||||
drawTrigger(canvas, cx, cy);
|
||||
}
|
||||
}
|
||||
canvas.restoreToCount(restoreCount);
|
||||
return drawAgain;
|
||||
}
|
||||
|
||||
private void drawTrigger(Canvas canvas, int cx, int cy) {
|
||||
mPaint.setColor(mColor1);
|
||||
canvas.drawCircle(cx, cy, cx * mTriggerPercentage, mPaint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a circle centered in the view.
|
||||
*
|
||||
* @param canvas the canvas to draw on
|
||||
* @param cx the center x coordinate
|
||||
* @param cy the center y coordinate
|
||||
* @param color the color to draw
|
||||
* @param pct the percentage of the view that the circle should cover
|
||||
*/
|
||||
private void drawCircle(Canvas canvas, float cx, float cy, int color, float pct) {
|
||||
mPaint.setColor(color);
|
||||
canvas.save();
|
||||
canvas.translate(cx, cy);
|
||||
float radiusScale = INTERPOLATOR.getInterpolation(pct);
|
||||
canvas.scale(radiusScale, radiusScale);
|
||||
canvas.drawCircle(0, 0, cx, mPaint);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the drawing bounds of this SwipeProgressBar.
|
||||
*/
|
||||
void setBounds(int left, int top, int right, int bottom) {
|
||||
mBounds.left = left;
|
||||
mBounds.top = top;
|
||||
mBounds.right = right;
|
||||
mBounds.bottom = bottom;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
APP_ABI := all
|
||||
APP_PLATFORM := android-15
|
||||
APP_PLATFORM := android-14
|
||||
APP_OPTIM := release
|
||||
|
||||
APP_CFLAGS += -ffunction-sections -fdata-sections -fPIC
|
||||
|
||||
@@ -89,7 +89,7 @@ DGifOpenFileHandle(int FileHandle, int *Error)
|
||||
GifFile->SavedImages = NULL;
|
||||
GifFile->SColorMap = NULL;
|
||||
|
||||
Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType));
|
||||
Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
|
||||
if (Private == NULL) {
|
||||
if (Error != NULL)
|
||||
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
|
||||
@@ -175,7 +175,7 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error)
|
||||
GifFile->SavedImages = NULL;
|
||||
GifFile->SColorMap = NULL;
|
||||
|
||||
Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType));
|
||||
Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
|
||||
if (!Private) {
|
||||
if (Error != NULL)
|
||||
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
|
||||
|
||||
@@ -13,7 +13,7 @@ extern "C" {
|
||||
|
||||
#define GIFLIB_MAJOR 5
|
||||
#define GIFLIB_MINOR 1
|
||||
#define GIFLIB_RELEASE 3
|
||||
#define GIFLIB_RELEASE 4
|
||||
|
||||
#define GIF_ERROR 0
|
||||
#define GIF_OK 1
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 165 B |
Binary file not shown.
|
After Width: | Height: | Size: 127 B |
Binary file not shown.
|
After Width: | Height: | Size: 176 B |
Binary file not shown.
|
After Width: | Height: | Size: 220 B |
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2016 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/primary_drawable_dark"
|
||||
android:pathData="@string/pd_import"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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:layout_width="match_parent"
|
||||
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:padding="@dimen/keyline_margin"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tip"
|
||||
android:layout_width="228dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_horizontal"
|
||||
android:drawablePadding="16dp"
|
||||
android:text="@string/no_dict"
|
||||
style="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="?attr/dialogPreferredPadding"
|
||||
android:paddingTop="@dimen/abc_dialog_padding_top_material"
|
||||
android:paddingRight="?attr/dialogPreferredPadding">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layout_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/bar_import"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_tip"
|
||||
android:max="100"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/tv_tip"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/bar_import"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<android.support.v7.widget.ButtonBarLayout
|
||||
android:id="@+id/buttonPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:gravity="bottom"
|
||||
style="?attr/buttonBarStyle">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_cancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@android:string/cancel"
|
||||
style="?attr/buttonBarPositiveButtonStyle"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_hide"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/hide"
|
||||
android:visibility="gone"
|
||||
style="?attr/buttonBarPositiveButtonStyle"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_confirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/_import"
|
||||
style="?attr/buttonBarPositiveButtonStyle"/>
|
||||
|
||||
</android.support.v7.widget.ButtonBarLayout>
|
||||
</LinearLayout>
|
||||
@@ -20,7 +20,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.hippo.widget.drawerlayout.DrawerLayout
|
||||
<com.hippo.ehviewer.widget.EhDrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/draw_view"
|
||||
android:layout_width="match_parent"
|
||||
@@ -51,5 +51,5 @@
|
||||
android:background="@color/background_light"
|
||||
android:clickable="true"/>
|
||||
|
||||
</com.hippo.widget.drawerlayout.DrawerLayout>
|
||||
</com.hippo.ehviewer.widget.EhDrawerLayout>
|
||||
</com.hippo.widget.SafeCoordinatorLayout>
|
||||
@@ -17,10 +17,9 @@
|
||||
|
||||
<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">
|
||||
android:background="@drawable/card_grey_no_padding_2dp">
|
||||
|
||||
<com.hippo.ehviewer.widget.TileThumb
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
@@ -28,7 +27,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="@color/grey_300"
|
||||
android:foreground="@drawable/tile_background"
|
||||
app:retryType="none"/>
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
</com.hippo.reveal.RevealLinearLayout>
|
||||
|
||||
<com.hippo.widget.FabLayout
|
||||
android:id="@+id/fab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingRight="@dimen/corner_fab_margin"
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.hippo.widget.refreshlayout.RefreshLayout
|
||||
<com.hippo.refreshlayout.RefreshLayout
|
||||
android:id="@+id/refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
@@ -50,7 +50,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"/>
|
||||
|
||||
</com.hippo.widget.refreshlayout.RefreshLayout>
|
||||
</com.hippo.refreshlayout.RefreshLayout>
|
||||
|
||||
<com.hippo.easyrecyclerview.FastScroller
|
||||
android:id="@+id/fast_scroller"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_import"
|
||||
android:icon="@drawable/v_import_dark_x24"
|
||||
android:title="@string/_import"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
</menu>
|
||||
@@ -24,7 +24,8 @@
|
||||
<dimen name="gallery_list_interval">4dp</dimen>
|
||||
<!-- 24dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_list_margin_h">20dp</dimen>
|
||||
<dimen name="gallery_grid_margin_h">24dp</dimen>
|
||||
<!-- 24dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_grid_margin_h">20dp</dimen>
|
||||
|
||||
<!-- 24dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_search_bar_margin_h">20dp</dimen>
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
<!-- 80dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_list_margin_h">76dp</dimen>
|
||||
<dimen name="gallery_grid_margin_h">80dp</dimen>
|
||||
<!-- 80dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_grid_margin_h">76dp</dimen>
|
||||
|
||||
<!-- 80dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_search_bar_margin_h">76dp</dimen>
|
||||
|
||||
@@ -365,6 +365,9 @@
|
||||
<string name="settings_eh_thumb_size_large">大</string>
|
||||
<string name="settings_eh_thumb_size_middle">中</string>
|
||||
<string name="settings_eh_thumb_size_small">小</string>
|
||||
<string name="settings_eh_thumb_resolution">缩略图分辨率</string>
|
||||
<string name="settings_eh_thumb_resolution_summary">%s,指定分辨率可能使获取缩略图失败</string>
|
||||
<string name="settings_eh_thumb_resolution_auto">自动</string>
|
||||
<string name="settings_eh_default_categories">主页分类显示</string>
|
||||
<string name="settings_eh_default_categories_summary">默认在主页所显示的分类</string>
|
||||
<string name="settings_eh_excluded_tag_namespaces">排除标签组</string>
|
||||
@@ -379,6 +382,8 @@
|
||||
<string name="settings_eh_show_jpn_title_summary_off">显示默认标题。一般是英文标题</string>
|
||||
<string name="settings_eh_filter">过滤</string>
|
||||
<string name="settings_eh_filter_summary">过滤标题,上传者,标签和标签组</string>
|
||||
<string name="settings_eh_dict">字典</string>
|
||||
<string name="settings_eh_dict_summary">搜索关键字字典</string>
|
||||
|
||||
<string name="settings_read">阅读</string>
|
||||
<string name="settings_read_screen_rotation">屏幕方向</string>
|
||||
@@ -422,9 +427,9 @@
|
||||
<string name="settings_download_multi_thread_download_summary">最多同时下载 %s 张图片</string>
|
||||
<string name="settings_download_preload_image">预载图片</string>
|
||||
<string name="settings_download_preload_image_summary">向后预载 %s 张图片</string>
|
||||
<string name="settings_download_image_size">图片大小</string>
|
||||
<string name="settings_download_image_size_summary">%s,大于 1280x 的分辨率可能不好使</string>
|
||||
<string name="settings_download_image_size_auto">自动</string>
|
||||
<string name="settings_download_image_resolution">图片分辨率</string>
|
||||
<string name="settings_download_image_resolution_summary">%s,大于 1280x 的分辨率可能不好使</string>
|
||||
<string name="settings_download_image_resolution_auto">自动</string>
|
||||
<string name="settings_download_download_origin_image">下载原图</string>
|
||||
<string name="settings_download_download_origin_image_summary">这很危险!勾选此项会导致下载配额迅速流失</string>
|
||||
<string name="settings_download_media_scan">允许媒体扫描</string>
|
||||
@@ -528,6 +533,20 @@
|
||||
<!-- License -->
|
||||
<string name="license">开源许可</string>
|
||||
|
||||
<!-- Dict -->
|
||||
<string name="dict">字典</string>
|
||||
<string name="no_dict">这里是字典</string>
|
||||
<string name="select_dict_file">选择字典文件</string>
|
||||
|
||||
<!-- Import Dict -->
|
||||
<string name="import_dict_service">导入字典服务</string>
|
||||
<string name="dict_import">导入字典</string>
|
||||
<string name="dict_import_successfully">导入字典成功</string>
|
||||
<string name="_import">导入</string>
|
||||
<string name="abort">中止</string>
|
||||
<string name="hide">隐藏</string>
|
||||
<string name="done">完成</string>
|
||||
|
||||
<!-- Dir Picker-->
|
||||
<string name="dir_picker">选择文件夹</string>
|
||||
<string name="directory_not_writable">该文件夹不可写</string>
|
||||
|
||||
@@ -365,6 +365,9 @@
|
||||
<string name="settings_eh_thumb_size_large">大</string>
|
||||
<string name="settings_eh_thumb_size_middle">中</string>
|
||||
<string name="settings_eh_thumb_size_small">小</string>
|
||||
<string name="settings_eh_thumb_resolution">縮略圖分辨率</string>
|
||||
<string name="settings_eh_thumb_resolution_summary">%s,指定分辨率可能使獲取縮略圖失敗</string>
|
||||
<string name="settings_eh_thumb_resolution_auto">自動</string>
|
||||
<string name="settings_eh_default_categories">主頁分類顯示</string>
|
||||
<string name="settings_eh_default_categories_summary">默認在主頁所顯示的分類</string>
|
||||
<string name="settings_eh_excluded_tag_namespaces">排除標籤組</string>
|
||||
@@ -379,6 +382,8 @@
|
||||
<string name="settings_eh_show_jpn_title_summary_off">顯示默認標題。一般是英文標題</string>
|
||||
<string name="settings_eh_filter">過濾</string>
|
||||
<string name="settings_eh_filter_summary">過濾標題,上傳者,標籤和標籤組</string>
|
||||
<string name="settings_eh_dict">字典</string>
|
||||
<string name="settings_eh_dict_summary">搜索關鍵字字典</string>
|
||||
|
||||
<string name="settings_read">閲讀</string>
|
||||
<string name="settings_read_screen_rotation">屏幕方向</string>
|
||||
@@ -422,9 +427,9 @@
|
||||
<string name="settings_download_multi_thread_download_summary">最多同時下載 %s 張圖片</string>
|
||||
<string name="settings_download_preload_image">預載圖片</string>
|
||||
<string name="settings_download_preload_image_summary">向後預載 %s 張圖片</string>
|
||||
<string name="settings_download_image_size">圖片大小</string>
|
||||
<string name="settings_download_image_size_summary">%s,大於 1280x 的分辨率可能不好使</string>
|
||||
<string name="settings_download_image_size_auto">自動</string>
|
||||
<string name="settings_download_image_resolution">圖片分辨率</string>
|
||||
<string name="settings_download_image_resolution_summary">%s,大於 1280x 的分辨率可能不好使</string>
|
||||
<string name="settings_download_image_resolution_auto">自動</string>
|
||||
<string name="settings_download_download_origin_image">下載原圖</string>
|
||||
<string name="settings_download_download_origin_image_summary">這很危險!勾選此項會導致下載配額迅速流失</string>
|
||||
<string name="settings_download_media_scan">允許媒體掃描</string>
|
||||
@@ -528,6 +533,20 @@
|
||||
<!-- License -->
|
||||
<string name="license">開源許可</string>
|
||||
|
||||
<!-- Dict -->
|
||||
<string name="dict">字典</string>
|
||||
<string name="no_dict">這裏是字典</string>
|
||||
<string name="select_dict_file">選擇字典文件</string>
|
||||
|
||||
<!-- Import Dict -->
|
||||
<string name="import_dict_service">導入字典服務</string>
|
||||
<string name="dict_import">導入字典</string>
|
||||
<string name="dict_import_successfully">導入字典成功</string>
|
||||
<string name="_import">導入</string>
|
||||
<string name="abort">中止</string>
|
||||
<string name="hide">隱藏</string>
|
||||
<string name="done">完成</string>
|
||||
|
||||
<!-- Dir Picker-->
|
||||
<string name="dir_picker">選擇文件夾</string>
|
||||
<string name="directory_not_writable">該文件夾不可寫</string>
|
||||
|
||||
@@ -365,6 +365,9 @@
|
||||
<string name="settings_eh_thumb_size_large">大</string>
|
||||
<string name="settings_eh_thumb_size_middle">中</string>
|
||||
<string name="settings_eh_thumb_size_small">小</string>
|
||||
<string name="settings_eh_thumb_resolution">縮圖解析度</string>
|
||||
<string name="settings_eh_thumb_resolution_summary">%s,指定解析度可能使獲取縮圖失敗</string>
|
||||
<string name="settings_eh_thumb_resolution_auto">自動</string>
|
||||
<string name="settings_eh_default_categories">主頁分類顯示</string>
|
||||
<string name="settings_eh_default_categories_summary">預設在主頁所顯示的分類</string>
|
||||
<string name="settings_eh_excluded_tag_namespaces">排除標籤組</string>
|
||||
@@ -379,6 +382,8 @@
|
||||
<string name="settings_eh_show_jpn_title_summary_off">顯示預設標題。一般是英文標題</string>
|
||||
<string name="settings_eh_filter">過濾</string>
|
||||
<string name="settings_eh_filter_summary">過濾標題,上傳者,標籤和標籤組</string>
|
||||
<string name="settings_eh_dict">字典</string>
|
||||
<string name="settings_eh_dict_summary">搜尋關鍵字字典</string>
|
||||
|
||||
<string name="settings_read">閱讀</string>
|
||||
<string name="settings_read_screen_rotation">螢幕方向</string>
|
||||
@@ -422,9 +427,9 @@
|
||||
<string name="settings_download_multi_thread_download_summary">最多同時下載 %s 張圖片</string>
|
||||
<string name="settings_download_preload_image">預載圖片</string>
|
||||
<string name="settings_download_preload_image_summary">向後預載 %s 張圖片</string>
|
||||
<string name="settings_download_image_size">圖片大小</string>
|
||||
<string name="settings_download_image_size_summary">%s,大於 1280x 的解析度可能不好使</string>
|
||||
<string name="settings_download_image_size_auto">自動</string>
|
||||
<string name="settings_download_image_resolution">圖片解析度</string>
|
||||
<string name="settings_download_image_resolution_summary">%s,大於 1280x 的解析度可能不好使</string>
|
||||
<string name="settings_download_image_resolution_auto">自動</string>
|
||||
<string name="settings_download_download_origin_image">下載原圖</string>
|
||||
<string name="settings_download_download_origin_image_summary">這很危險!勾選此項會導致下載配額迅速流失</string>
|
||||
<string name="settings_download_media_scan">允許媒體掃描</string>
|
||||
@@ -528,6 +533,20 @@
|
||||
<!-- License -->
|
||||
<string name="license">開源許可</string>
|
||||
|
||||
<!-- Dict -->
|
||||
<string name="dict">字典</string>
|
||||
<string name="no_dict">這裡是字典</string>
|
||||
<string name="select_dict_file">選擇字典檔案</string>
|
||||
|
||||
<!-- Import Dict -->
|
||||
<string name="import_dict_service">匯入字典服務</string>
|
||||
<string name="dict_import">匯入字典</string>
|
||||
<string name="dict_import_successfully">匯入字典成功</string>
|
||||
<string name="_import">匯入</string>
|
||||
<string name="abort">中止</string>
|
||||
<string name="hide">隱藏</string>
|
||||
<string name="done">完成</string>
|
||||
|
||||
<!-- Dir Picker-->
|
||||
<string name="dir_picker">選擇資料夾</string>
|
||||
<string name="directory_not_writable">該資料夾不可寫</string>
|
||||
|
||||
@@ -43,6 +43,18 @@
|
||||
<item>@string/settings_eh_thumb_size_small</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="thumb_resolution_entries" translatable="false">
|
||||
<item>@string/settings_eh_thumb_resolution_auto</item>
|
||||
<item>250x</item>
|
||||
<item>300x</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="thumb_resolution_entry_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="thumb_size_entry_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
@@ -88,8 +100,8 @@
|
||||
<item>17</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="image_size_entries" translatable="false">
|
||||
<item>@string/settings_download_image_size_auto</item>
|
||||
<string-array name="image_resolution_entries" translatable="false">
|
||||
<item>@string/settings_download_image_resolution_auto</item>
|
||||
<item>780x</item>
|
||||
<item>980x</item>
|
||||
<item>1280x</item>
|
||||
@@ -97,7 +109,7 @@
|
||||
<item>2400x</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="image_size_entry_values" translatable="false">
|
||||
<string-array name="image_resolution_entry_values" translatable="false">
|
||||
<item>a</item>
|
||||
<item>780</item>
|
||||
<item>980</item>
|
||||
|
||||
@@ -44,9 +44,12 @@
|
||||
<!-- 8dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_list_margin_v">4dp</dimen>
|
||||
|
||||
<dimen name="gallery_grid_interval">8dp</dimen>
|
||||
<dimen name="gallery_grid_margin_h">8dp</dimen>
|
||||
<dimen name="gallery_grid_margin_v">8dp</dimen>
|
||||
<!-- 4dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_grid_interval">0dp</dimen>
|
||||
<!-- 8dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_grid_margin_h">4dp</dimen>
|
||||
<!-- 8dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_grid_margin_v">4dp</dimen>
|
||||
|
||||
<!-- 8dp - 4dp, 4dp for card padding -->
|
||||
<dimen name="gallery_search_bar_margin_h">4dp</dimen>
|
||||
|
||||
@@ -27,4 +27,7 @@
|
||||
<item name="vote_down" type="id"/>
|
||||
<item name="check_vote_status" type="id"/>
|
||||
|
||||
<item name="fab_translation_y" type="id"/>
|
||||
<item name="fab_translation_y_animator" type="id"/>
|
||||
|
||||
</resources>
|
||||
@@ -60,6 +60,7 @@
|
||||
<string name="pd_similar" translatable="false">M2,20L17,10L22,22M14,9L2,8L11,2Z</string>
|
||||
<string name="pd_refresh" translatable="false">M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z</string>
|
||||
<string name="pd_file_find" translatable="false">M9,13A3,3 0 0,0 12,16A3,3 0 0,0 15,13A3,3 0 0,0 12,10A3,3 0 0,0 9,13M20,19.59V8L14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18C18.45,22 18.85,21.85 19.19,21.6L14.76,17.17C13.96,17.69 13,18 12,18A5,5 0 0,1 7,13A5,5 0 0,1 12,8A5,5 0 0,1 17,13C17,14 16.69,14.96 16.17,15.75L20,19.59Z</string>
|
||||
<string name="pd_import" translatable="false">M14,12L10,8V11H2V13H10V16M20,18V6C20,4.89 19.1,4 18,4H6A2,2 0 0,0 4,6V9H6V6H18V18H6V15H4V18A2,2 0 0,0 6,20H18A2,2 0 0,0 20,18Z</string>
|
||||
|
||||
<string name="pd_big_label" translatable="false">M12.88,2H4V11L14.97,22.14L24,13.1L12.88,2ZM7.26,5.26C7.96,4.58,9.06,4.58,9.74,5.26C10.42,5.96,10.42,7.06,9.74,7.74S7.94,8.42,7.26,7.74S6.58,5.94,7.26,5.26ZM14.98,19.3L8.76,12.95L14.88,6.83L21.18,13.11L14.98,19.31ZM11.6,21.56L10.23,23L0,12.74V5H2V11.9L11.6,21.56Z</string>
|
||||
<string name="pd_big_search" translatable="false">M20.46,14.65C21.86,16.15,20.31,18.6,18.32,17.87C19.78,17.57,20.79,16.37,20.46,14.65ZM4.32,17.87C6.32,18.6,7.86,16.17,6.46,14.65C6.79,16.38,5.78,17.55,4.32,17.87ZM16.87,4.3C16.6,3.56,15.87,3,15,3C13.7,3,12.7,4.24,13.1,5.58C14.2,5.18,15.44,4.48,16.87,4.31ZM24,16C24,18.76,21.76,21,19,21C14.96,21,14.84,16.88,12,16.88S9.04,21,5,21C2.24,21,0,18.76,0,16C0,13.87,1.53,11.43,3.94,7.18C5.84,3.81,8.69,5.92,10.76,6.58C11.54,6.85,12.41,6.88,13.24,6.58C15.3,5.92,18.14,3.81,20.06,7.18C22.46,11.43,24,13.88,24,16ZM8,16C8,14.35,6.65,13,5,13S2,14.35,2,16S3.35,19,5,19S8,17.65,8,16ZM13,14C13,13.45,12.55,13,12,13S11,13.45,11,14S11.45,15,12,15S13,14.55,13,14ZM22,16C22,14.35,20.65,13,19,13S16,14.35,16,16S17.35,19,19,19S22,17.65,22,16ZM9,3C8.14,3,7.4,3.55,7.13,4.3C8.56,4.48,9.79,5.2,10.9,5.58C11.3,4.24,10.3,3,9,3Z</string>
|
||||
|
||||
@@ -407,6 +407,9 @@
|
||||
<string name="settings_eh_thumb_size_large">Large</string>
|
||||
<string name="settings_eh_thumb_size_middle">Middle</string>
|
||||
<string name="settings_eh_thumb_size_small">Small</string>
|
||||
<string name="settings_eh_thumb_resolution">Thumb resolution</string>
|
||||
<string name="settings_eh_thumb_resolution_summary">%s, special resolutions might cause getting thumb failed</string>
|
||||
<string name="settings_eh_thumb_resolution_auto">Auto</string>
|
||||
<string name="settings_eh_default_categories">Categories on Homepage</string>
|
||||
<string name="settings_eh_default_categories_summary">The categories shown as default on Homepage</string>
|
||||
<string name="settings_eh_excluded_languages">Excluded languages</string>
|
||||
@@ -421,6 +424,8 @@
|
||||
<string name="settings_eh_show_jpn_title_summary_off">Show default title. It is usually English title</string>
|
||||
<string name="settings_eh_filter">Filter</string>
|
||||
<string name="settings_eh_filter_summary">Filter by title, uploader, tag and tag namespace</string>
|
||||
<string name="settings_eh_dict">Dictionary</string>
|
||||
<string name="settings_eh_dict_summary">Search keyword dictionary</string>
|
||||
|
||||
<string name="settings_read">Read</string>
|
||||
<string name="settings_read_screen_rotation">Screen orientation</string>
|
||||
@@ -467,9 +472,9 @@
|
||||
<string name="settings_download_multi_thread_download_summary">Up to %s images</string>
|
||||
<string name="settings_download_preload_image">Preload image</string>
|
||||
<string name="settings_download_preload_image_summary">Preload next %s image</string>
|
||||
<string name="settings_download_image_size">Image size</string>
|
||||
<string name="settings_download_image_size_summary">%s, resolutions above 1280x may not work</string>
|
||||
<string name="settings_download_image_size_auto">Auto</string>
|
||||
<string name="settings_download_image_resolution">Image resolution</string>
|
||||
<string name="settings_download_image_resolution_summary">%s, resolutions above 1280x may not work</string>
|
||||
<string name="settings_download_image_resolution_auto">Auto</string>
|
||||
<string name="settings_download_download_origin_image">Download original image</string>
|
||||
<string name="settings_download_download_origin_image_summary">It is dangerous! You may get 509 error</string>
|
||||
<string name="settings_download_restore_download_items">Restore download items</string>
|
||||
@@ -571,6 +576,20 @@
|
||||
<!-- License -->
|
||||
<string name="license">License</string>
|
||||
|
||||
<!-- Dict -->
|
||||
<string name="dict">Dictionary</string>
|
||||
<string name="no_dict">Dictionaries will be shown here</string>
|
||||
<string name="select_dict_file">Select dictionary file</string>
|
||||
|
||||
<!-- Import Dict -->
|
||||
<string name="import_dict_service">Import dictionary service</string>
|
||||
<string name="dict_import">Import dictionary</string>
|
||||
<string name="dict_import_successfully">Import dictionary successfully</string>
|
||||
<string name="_import">Import</string>
|
||||
<string name="abort">Abort</string>
|
||||
<string name="hide">Hide</string>
|
||||
<string name="done">Done</string>
|
||||
|
||||
<!-- Dir Picker-->
|
||||
<string name="dir_picker">Dir picker</string>
|
||||
<string name="directory_not_writable">The directory is not writable</string>
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Dialog" parent="Theme.AppCompat.Light.Dialog">
|
||||
<item name="android:windowCloseOnTouchOutside">false</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Translucent">
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||
|
||||
@@ -48,10 +48,10 @@
|
||||
|
||||
<com.hippo.preference.ListPreference
|
||||
android:key="image_size"
|
||||
android:title="@string/settings_download_image_size"
|
||||
android:summary="@string/settings_download_image_size_summary"
|
||||
app:entries="@array/image_size_entries"
|
||||
app:entryValues="@array/image_size_entry_values"
|
||||
android:title="@string/settings_download_image_resolution"
|
||||
android:summary="@string/settings_download_image_resolution_summary"
|
||||
app:entries="@array/image_resolution_entries"
|
||||
app:entryValues="@array/image_resolution_entry_values"
|
||||
android:defaultValue="a"/>
|
||||
|
||||
<com.hippo.preference.SwitchPreference
|
||||
|
||||
@@ -48,6 +48,14 @@
|
||||
app:entryValues="@array/thumb_size_entry_values"
|
||||
android:defaultValue="1"/>
|
||||
|
||||
<com.hippo.preference.ListPreference
|
||||
android:key="thumb_resolution"
|
||||
android:title="@string/settings_eh_thumb_resolution"
|
||||
android:summary="@string/settings_eh_thumb_resolution_summary"
|
||||
app:entries="@array/thumb_resolution_entries"
|
||||
app:entryValues="@array/thumb_resolution_entry_values"
|
||||
android:defaultValue="0"/>
|
||||
|
||||
<com.hippo.ehviewer.preference.DefaultCategoryPreference
|
||||
android:key="default_categories"
|
||||
android:title="@string/settings_eh_default_categories"
|
||||
@@ -81,4 +89,10 @@
|
||||
android:summary="@string/settings_eh_filter_summary"
|
||||
app:activity="com.hippo.ehviewer.ui.FilterActivity"/>
|
||||
|
||||
<com.hippo.preference.ActivityPreference
|
||||
android:key="dict"
|
||||
android:title="@string/settings_eh_dict"
|
||||
android:summary="@string/settings_eh_dict_summary"
|
||||
app:activity="com.hippo.ehviewer.ui.DictActivity"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
Loaded 100 of 107 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user