mirror of
https://github.com/seven332/EhViewer
synced 2026-12-04 12:59:01 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4faefb3f34 | ||
|
|
c48f282a2d | ||
|
|
d0ad3c158f | ||
|
|
c285562971 | ||
|
|
53ba692375 | ||
|
|
6879c5ea71 | ||
|
|
fa1348860b | ||
|
|
efe4955836 | ||
|
|
ad83f4d3ee | ||
|
|
be129a6147 | ||
|
|
89b224e397 | ||
|
|
97f82d4962 | ||
|
|
4453ddbf07 | ||
|
|
3b9d040881 | ||
|
|
b62b6c7b35 | ||
|
|
045218f8ca | ||
|
|
8b426c72d1 | ||
|
|
51eaa73b9c | ||
|
|
ad081d8192 | ||
|
|
19daaf7ee4 | ||
|
|
643412e11b | ||
|
|
389119c468 | ||
|
|
9b60cdc612 | ||
|
|
203d6134c2 | ||
|
|
87e714aff6 | ||
|
|
125fe0e691 | ||
|
|
0485d9690e | ||
|
|
d7b01d455b | ||
|
|
d7d0c4e250 | ||
|
|
231e463605 | ||
|
|
311185825e | ||
|
|
325cf311df | ||
|
|
cddb51b399 | ||
|
|
c2c98003f1 | ||
|
|
dd6f02395c | ||
|
|
f419264540 | ||
|
|
d7565ce0bb | ||
|
|
095ccf1b55 | ||
|
|
8abefdb6d4 | ||
|
|
0aad8ca1e8 | ||
|
|
0bc4569084 | ||
|
|
337c859040 | ||
|
|
e0cb0fca18 | ||
|
|
b8d5a7d80d | ||
|
|
2ddb234e72 | ||
|
|
19ebd4c28f | ||
|
|
e6367055fb | ||
|
|
ba72dbff7c | ||
|
|
df41c62269 | ||
|
|
a1cea27cdc | ||
|
|
173f01853b | ||
|
|
8568f1c7a0 |
No files matched your search
@@ -72,3 +72,5 @@ Here is the libraries
|
||||
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.
|
||||
|
||||
ic_launcher 图标为 Hippo Seven 所有,所有权利保留
|
||||
+4
-4
@@ -10,8 +10,8 @@ android {
|
||||
applicationId "com.hippo.ehviewer"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 23
|
||||
versionCode 52
|
||||
versionName "0.9.4"
|
||||
versionCode 54
|
||||
versionName "1.0.1"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ dependencies {
|
||||
compile 'com.android.support:customtabs:23.2.1'
|
||||
compile 'com.android.support:design:23.2.1'
|
||||
compile 'com.github.amlcurran.showcaseview:library:5.4.1'
|
||||
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.8.6'
|
||||
compile 'de.greenrobot:greendao:2.0.0'
|
||||
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.8.7'
|
||||
compile 'de.greenrobot:greendao:2.1.0'
|
||||
compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
||||
compile 'org.jsoup:jsoup:1.8.3'
|
||||
}
|
||||
@@ -27,30 +27,29 @@
|
||||
|
||||
<application
|
||||
android:name="com.hippo.ehviewer.EhApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/AppTheme"
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="@xml/backup_scheme"
|
||||
android:largeHeap="true">
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.MainActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:theme="@style/AppTheme.Main"
|
||||
android:launchMode="singleTask">
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="stateHidden">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="http"/>
|
||||
<data android:host="exhentai.org"/>
|
||||
<data android:host="g.e-hentai.org"/>
|
||||
@@ -58,6 +57,41 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.DumpBrowsableActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
|
||||
<intent-filter android:priority="-10">
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="http"/>
|
||||
<data android:host="exhentai.org"/>
|
||||
<data android:host="g.e-hentai.org"/>
|
||||
<data android:host="lofi.e-hentai.org"/>
|
||||
<data android:pathPrefix="/g/"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity-alias
|
||||
android:name="com.hippo.ehviewer.ui.DumpBrowsableActivity2"
|
||||
android:targetActivity="com.hippo.ehviewer.ui.DumpBrowsableActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
|
||||
<intent-filter android:priority="-10">
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="http"/>
|
||||
<data android:host="exhentai.org"/>
|
||||
<data android:host="g.e-hentai.org"/>
|
||||
<data android:host="lofi.e-hentai.org"/>
|
||||
<data android:pathPrefix="/s/"/>
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.GalleryActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
|
||||
@@ -113,4 +113,20 @@ public class AppConfig {
|
||||
public static File createExternalTempFile() {
|
||||
return FileUtils.createTempFile(getExternalTempDir(), null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File getTempDir() {
|
||||
File dir = sContext.getCacheDir();
|
||||
File file;
|
||||
if (null != dir && FileUtils.ensureDirectory(file = new File(dir, TEMP))) {
|
||||
return file;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File createTempFile() {
|
||||
return FileUtils.createTempFile(getTempDir(), null);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.LruCache;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.hippo.beerbelly.SimpleDiskCache;
|
||||
import com.hippo.conaco.Conaco;
|
||||
@@ -43,15 +42,18 @@ import com.hippo.network.StatusCodeException;
|
||||
import com.hippo.okhttp.CookieDB;
|
||||
import com.hippo.scene.SceneApplication;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.util.BitmapUtils;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.IntIdGenerator;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@@ -59,15 +61,15 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
|
||||
private static final String TAG = EhApplication.class.getSimpleName();
|
||||
|
||||
public static final boolean BETA = true;
|
||||
public static final boolean BETA = false;
|
||||
|
||||
private static final boolean DEBUG_CONACO = false;
|
||||
private static final boolean DEBUG_NATIVE_MEMORY = false;
|
||||
|
||||
private Thread.UncaughtExceptionHandler mDefaultHandler;
|
||||
|
||||
private final AtomicInteger mIdGenerator = new AtomicInteger();
|
||||
private final SparseArray<Object> mGlobalStuffMap = new SparseArray<>();
|
||||
private final IntIdGenerator mIdGenerator = new IntIdGenerator();
|
||||
private final WeakHashMap<Integer, Object> mGlobalStuffMap = new WeakHashMap<>();
|
||||
private EhCookieStore mEhCookieStore;
|
||||
private EhClient mEhClient;
|
||||
private OkHttpClient mOkHttpClient;
|
||||
@@ -97,6 +99,7 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
SpiderDen.initialize(this);
|
||||
EhDB.initialize(this);
|
||||
EhEngine.initialize();
|
||||
BitmapUtils.initialize(this);
|
||||
|
||||
if (EhDB.needMerge()) {
|
||||
EhDB.mergeOldDB(this);
|
||||
@@ -107,7 +110,7 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
}
|
||||
|
||||
CommonOperations.ensureNoMediaFile(Settings.getDownloadLocation());
|
||||
|
||||
clearTempDir();
|
||||
update();
|
||||
|
||||
// Update version code
|
||||
@@ -123,6 +126,17 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
}
|
||||
}
|
||||
|
||||
private void clearTempDir() {
|
||||
File dir = AppConfig.getTempDir();
|
||||
if (null != dir) {
|
||||
FileUtils.deleteContent(dir);
|
||||
}
|
||||
dir = AppConfig.getExternalTempDir();
|
||||
if (null != dir) {
|
||||
FileUtils.deleteContent(dir);
|
||||
}
|
||||
}
|
||||
|
||||
private void update() {
|
||||
int version = Settings.getVersionCode();
|
||||
if (version < 52) {
|
||||
@@ -160,13 +174,13 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
}
|
||||
|
||||
public int putGlobalStuff(@NonNull Object o) {
|
||||
int id = mIdGenerator.getAndDecrement();
|
||||
int id = mIdGenerator.nextId();
|
||||
mGlobalStuffMap.put(id, o);
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean containGlobalStuff(int id) {
|
||||
return mGlobalStuffMap.indexOfKey(id) >= 0;
|
||||
return mGlobalStuffMap.containsKey(id);
|
||||
}
|
||||
|
||||
public Object getGlobalStuff(int id) {
|
||||
@@ -174,24 +188,11 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
}
|
||||
|
||||
public Object removeGlobalStuff(int id) {
|
||||
int index = mGlobalStuffMap.indexOfKey(id);
|
||||
if (index >= 0) {
|
||||
Object o = mGlobalStuffMap.valueAt(index);
|
||||
mGlobalStuffMap.removeAt(index);
|
||||
return o;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return mGlobalStuffMap.remove(id);
|
||||
}
|
||||
|
||||
public boolean removeGlobalStuff(Object o) {
|
||||
int index = mGlobalStuffMap.indexOfValue(o);
|
||||
if (index >= 0) {
|
||||
mGlobalStuffMap.removeAt(index);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return mGlobalStuffMap.values().removeAll(Collections.singleton(o));
|
||||
}
|
||||
|
||||
public static EhCookieStore getEhCookieStore(@NonNull Context context) {
|
||||
|
||||
@@ -368,6 +368,17 @@ public class Settings {
|
||||
/********************
|
||||
****** Read
|
||||
********************/
|
||||
private static final String KEY_SCREEN_ROTATION = "screen_rotation";
|
||||
private static final int DEFAULT_SCREEN_ROTATION = 0;
|
||||
|
||||
public static int getScreenRotation() {
|
||||
return getIntFromStr(KEY_SCREEN_ROTATION, DEFAULT_SCREEN_ROTATION);
|
||||
}
|
||||
|
||||
public static void putScreenRotation(int value) {
|
||||
putIntToStr(KEY_SCREEN_ROTATION, value);
|
||||
}
|
||||
|
||||
private static final String KEY_READING_DIRECTION = "reading_direction";
|
||||
private static final int DEFAULT_READING_DIRECTION = GalleryView.LAYOUT_MODE_RIGHT_TO_LEFT;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.hippo.ehviewer.client.exception.CancelledException;
|
||||
import com.hippo.yorozuya.PriorityThreadFactory;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
@@ -56,6 +57,8 @@ public class EhClient {
|
||||
public static final int METHOD_GET_TORRENT_LIST = 12;
|
||||
public static final int METHOD_GET_WHATS_HOT = 13;
|
||||
public static final int METHOD_GET_PROFILE = 14;
|
||||
public static final int METHOD_VOTE_COMMENT = 15;
|
||||
public static final int METHOD_IMAGE_SEARCH = 16;
|
||||
|
||||
private final ThreadPoolExecutor mRequestThreadPool;
|
||||
private final OkHttpClient mOkHttpClient;
|
||||
@@ -158,7 +161,7 @@ public class EhClient {
|
||||
case METHOD_GET_PREVIEW_SET:
|
||||
return EhEngine.getPreviewSet(this, mOkHttpClient, (String) params[0]);
|
||||
case METHOD_GET_RATE_GALLERY:
|
||||
return EhEngine.rateGallery(this, mOkHttpClient, (Long) params[0], (String) params[1], (Float) params[2]);
|
||||
return EhEngine.rateGallery(this, mOkHttpClient, (Long) params[0], (String) params[1], (Long) params[2], (String) params[3], (Float) params[4]);
|
||||
case METHOD_GET_COMMENT_GALLERY:
|
||||
return EhEngine.commentGallery(this, mOkHttpClient, (String) params[0], (String) params[1]);
|
||||
case METHOD_GET_GALLERY_TOKEN:
|
||||
@@ -177,6 +180,10 @@ public class EhClient {
|
||||
return EhEngine.getWhatsHot(this, mOkHttpClient);
|
||||
case METHOD_GET_PROFILE:
|
||||
return EhEngine.getProfile(this, mOkHttpClient);
|
||||
case METHOD_VOTE_COMMENT:
|
||||
return EhEngine.voteComment(this, mOkHttpClient, (Long) params[0], (String) params[1], (Long) params[2], (String) params[3], (Long) params[4], (Integer) params[5]);
|
||||
case METHOD_IMAGE_SEARCH:
|
||||
return EhEngine.imageSearch(this, mOkHttpClient, (File) params[0], (Boolean) params[1], (Boolean) params[2], (Boolean) params[3]);
|
||||
default:
|
||||
return new IllegalStateException("Can't detect method " + mMethod);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.hippo.ehviewer.client.parser.ProfileParser;
|
||||
import com.hippo.ehviewer.client.parser.RateGalleryParser;
|
||||
import com.hippo.ehviewer.client.parser.SignInParser;
|
||||
import com.hippo.ehviewer.client.parser.TorrentParser;
|
||||
import com.hippo.ehviewer.client.parser.VoteCommentParser;
|
||||
import com.hippo.ehviewer.client.parser.WhatsHotParser;
|
||||
import com.hippo.network.StatusCodeException;
|
||||
import com.hippo.util.ReadableTime;
|
||||
@@ -63,6 +64,7 @@ import okhttp3.Call;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
@@ -76,10 +78,8 @@ public class EhEngine {
|
||||
private static final String SAD_PANDA_TYPE = "image/gif";
|
||||
private static final String SAD_PANDA_LENGTH = "9615";
|
||||
|
||||
public static final long APIUID = 1363542;
|
||||
public static final String APIKEY = "f4b5407ab1727b9d08d7";
|
||||
|
||||
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
public static final MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
private static final MediaType MEDIA_TYPE_JPEG = MediaType.parse("image/jpeg");
|
||||
|
||||
public static EhFilter sEhFilter;
|
||||
|
||||
@@ -143,7 +143,7 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static String signIn(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static String signIn(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
String username, String password) throws Exception {
|
||||
FormBody.Builder builder = new FormBody.Builder()
|
||||
.add("UserName", username)
|
||||
@@ -153,13 +153,15 @@ public class EhEngine {
|
||||
.add("temporary_https", "off");
|
||||
String url = EhUrl.API_SIGN_IN;
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig())
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(builder.build())
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -176,14 +178,16 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static GalleryListParser.Result getGalleryList(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static GalleryListParser.Result getGalleryList(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
String url) throws Exception {
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -230,7 +234,7 @@ public class EhEngine {
|
||||
}
|
||||
|
||||
// At least, GalleryInfo contain valid gid and token
|
||||
public static List<GalleryInfo> fillGalleryListByApi(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static List<GalleryInfo> fillGalleryListByApi(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
List<GalleryInfo> galleryInfoList) throws Exception {
|
||||
// We can only request 25 items one time at most
|
||||
final int MAX_REQUEST_SIZE = 25;
|
||||
@@ -245,7 +249,7 @@ public class EhEngine {
|
||||
return galleryInfoList;
|
||||
}
|
||||
|
||||
private static void doFillGalleryListByApi(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
private static void doFillGalleryListByApi(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
List<GalleryInfo> galleryInfoList) throws Exception {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("method", "gdata");
|
||||
@@ -262,12 +266,14 @@ public class EhEngine {
|
||||
String url = EhUrl.getApiUrl();
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url)
|
||||
.post(RequestBody.create(JSON, json.toString()))
|
||||
.post(RequestBody.create(MEDIA_TYPE_JSON, json.toString()))
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -284,14 +290,16 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static GalleryDetail getGalleryDetail(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static GalleryDetail getGalleryDetail(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
String url) throws Exception {
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -310,13 +318,15 @@ public class EhEngine {
|
||||
|
||||
|
||||
public static Pair<PreviewSet, Integer> getPreviewSet(
|
||||
EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
|
||||
@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -334,25 +344,28 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static RateGalleryParser.Result rateGallery(EhClient.Task task,
|
||||
OkHttpClient okHttpClient, long gid, String token, float rating) throws Exception {
|
||||
public static RateGalleryParser.Result rateGallery(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient, long apiUid, String apiKey, long gid,
|
||||
String token, float rating) throws Exception {
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("method", "rategallery");
|
||||
json.put("apiuid", APIUID);
|
||||
json.put("apikey", APIKEY);
|
||||
json.put("apiuid", apiUid);
|
||||
json.put("apikey", apiKey);
|
||||
json.put("gid", gid);
|
||||
json.put("token", token);
|
||||
json.put("rating", (int) Math.ceil(rating * 2));
|
||||
final RequestBody requestBody = RequestBody.create(JSON, json.toString());
|
||||
final RequestBody requestBody = RequestBody.create(MEDIA_TYPE_JSON, json.toString());
|
||||
String url = EhUrl.getApiUrl();
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig())
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(requestBody)
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -369,19 +382,21 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static GalleryComment[] commentGallery(EhClient.Task task,
|
||||
public static GalleryComment[] commentGallery(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient, String url, String comment) throws Exception {
|
||||
FormBody.Builder builder = new FormBody.Builder()
|
||||
.add("commenttext", comment)
|
||||
.add("postcomment", "Post New");
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig())
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(builder.build())
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -399,22 +414,24 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getGalleryToken(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static String getGalleryToken(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
long gid, String gtoken, int page) throws Exception {
|
||||
JSONObject json = new JSONObject()
|
||||
.put("method", "gtoken")
|
||||
.put("pagelist", new JSONArray().put(
|
||||
new JSONArray().put(gid).put(gtoken).put(page + 1)));
|
||||
final RequestBody requestBody = RequestBody.create(JSON, json.toString());
|
||||
final RequestBody requestBody = RequestBody.create(MEDIA_TYPE_JSON, json.toString());
|
||||
String url = EhUrl.getApiUrl();
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig())
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(requestBody)
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -431,14 +448,16 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static FavoritesParser.Result getFavorites(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static FavoritesParser.Result getFavorites(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
String url, boolean callApi) throws Exception {
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -466,7 +485,7 @@ public class EhEngine {
|
||||
* @param dstCat -1 for delete, 0 - 9 for cloud favorite, others throw Exception
|
||||
* @param note max 250 characters
|
||||
*/
|
||||
public static Void addFavorites(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static Void addFavorites(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
long gid, String token, int dstCat, String note) throws Exception {
|
||||
String catStr;
|
||||
if (dstCat == -1) {
|
||||
@@ -483,13 +502,15 @@ public class EhEngine {
|
||||
builder.add("submit", "Apply Changes");
|
||||
String url = EhUrl.getAddFavorites(gid, token);
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig())
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(builder.build())
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -508,7 +529,7 @@ public class EhEngine {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Void addFavoritesRange(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static Void addFavoritesRange(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
long[] gidArray, String[] tokenArray, int dstCat) throws Exception {
|
||||
AssertUtils.assertEqualsEx(gidArray.length, tokenArray.length);
|
||||
for (int i = 0, n = gidArray.length; i < n; i++) {
|
||||
@@ -517,7 +538,7 @@ public class EhEngine {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FavoritesParser.Result modifyFavorites(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static FavoritesParser.Result modifyFavorites(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
String url, long[] gidArray, int dstCat, boolean callApi) throws Exception {
|
||||
String catStr;
|
||||
if (dstCat == -1) {
|
||||
@@ -534,13 +555,15 @@ public class EhEngine {
|
||||
}
|
||||
builder.add("apply", "Apply");
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig())
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(builder.build())
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -564,14 +587,16 @@ public class EhEngine {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Pair<String, String>[] getTorrentList(EhClient.Task task, OkHttpClient okHttpClient,
|
||||
public static Pair<String, String>[] getTorrentList(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
String url) throws Exception {
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -591,15 +616,17 @@ public class EhEngine {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<GalleryInfo> getWhatsHot(EhClient.Task task,
|
||||
public static List<GalleryInfo> getWhatsHot(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient) throws Exception {
|
||||
String url = EhUrl.HOST_G;
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -624,14 +651,16 @@ public class EhEngine {
|
||||
return list;
|
||||
}
|
||||
|
||||
private static ProfileParser.Result getProfileInternal(EhClient.Task task,
|
||||
private static ProfileParser.Result getProfileInternal(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient, String url) throws Exception {
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -648,15 +677,17 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static ProfileParser.Result getProfile(EhClient.Task task,
|
||||
public static ProfileParser.Result getProfile(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient) throws Exception {
|
||||
String url = EhUrl.URL_FORUMS;
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
task.setCall(call);
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
@@ -672,4 +703,134 @@ public class EhEngine {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static VoteCommentParser.Result voteComment(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
long apiUid, String apiKey, long gid, String token, long commentId, int commentVote) throws Exception {
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("method", "votecomment");
|
||||
json.put("apiuid", apiUid);
|
||||
json.put("apikey", apiKey);
|
||||
json.put("gid", gid);
|
||||
json.put("token", token);
|
||||
json.put("comment_id", commentId);
|
||||
json.put("comment_vote", commentVote);
|
||||
final RequestBody requestBody = RequestBody.create(MEDIA_TYPE_JSON, json.toString());
|
||||
String url = EhUrl.getApiUrl();
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(requestBody)
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
int code = -1;
|
||||
try {
|
||||
Response response = call.execute();
|
||||
code = response.code();
|
||||
headers = response.headers();
|
||||
body = response.body().string();
|
||||
return VoteCommentParser.parse(body, commentVote);
|
||||
} catch (Exception e) {
|
||||
throwException(call, code, headers, body, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param image Must be jpeg
|
||||
*/
|
||||
public static GalleryListParser.Result imageSearch(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
File image, boolean uss, boolean osc, boolean se) throws Exception {
|
||||
MultipartBody.Builder builder = new MultipartBody.Builder();
|
||||
builder.setType(MultipartBody.FORM);
|
||||
builder.addPart(
|
||||
Headers.of("Content-Disposition", "form-data; name=\"sfile\"; filename=\"a.jpg\""),
|
||||
RequestBody.create(MEDIA_TYPE_JPEG, image)
|
||||
);
|
||||
if (uss) {
|
||||
builder.addPart(
|
||||
Headers.of("Content-Disposition", "form-data; name=\"fs_similar\""),
|
||||
RequestBody.create(null, "on")
|
||||
);
|
||||
}
|
||||
if (osc) {
|
||||
builder.addPart(
|
||||
Headers.of("Content-Disposition", "form-data; name=\"fs_covers\""),
|
||||
RequestBody.create(null, "on")
|
||||
);
|
||||
}
|
||||
if (se) {
|
||||
builder.addPart(
|
||||
Headers.of("Content-Disposition", "form-data; name=\"fs_exp\""),
|
||||
RequestBody.create(null, "on")
|
||||
);
|
||||
}
|
||||
builder.addPart(
|
||||
Headers.of("Content-Disposition", "form-data; name=\"f_sfile\""),
|
||||
RequestBody.create(null, "File Search")
|
||||
);
|
||||
String url = EhUrl.getImageSearchUrl();
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
|
||||
.post(builder.build())
|
||||
.build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
GalleryListParser.Result result;
|
||||
int code = -1;
|
||||
try {
|
||||
Response response = call.execute();
|
||||
|
||||
Log.d(TAG, "" + response.request().url().toString());
|
||||
|
||||
code = response.code();
|
||||
headers = response.headers();
|
||||
body = response.body().string();
|
||||
result = GalleryListParser.parse(body);
|
||||
} catch (Exception e) {
|
||||
throwException(call, code, headers, body, e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// Filter title and uploader
|
||||
List<GalleryInfo> list = result.galleryInfoList;
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
if (!sEhFilter.filterTitle(info) || !sEhFilter.filterUploader(info)) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
if (list.size() > 0 && (Settings.getShowJpnTitle() || sEhFilter.needCallApi())) {
|
||||
// Fill by api
|
||||
fillGalleryListByApi(task, okHttpClient, list);
|
||||
|
||||
// Filter tag
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
if (!sEhFilter.filterTag(info) || !sEhFilter.filterTagNamespace(info)) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.hippo.ehviewer.client;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.network.UrlBuilder;
|
||||
|
||||
@@ -99,4 +101,15 @@ public class EhUrl {
|
||||
public static String getTagDefinitionUrl(String tag) {
|
||||
return "https://ehwiki.org/wiki/" + tag.replace(' ', '_');
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getImageSearchUrl() {
|
||||
switch (Settings.getGallerySite()) {
|
||||
default:
|
||||
case SITE_G:
|
||||
return "http://ul.e-hentai.org/image_lookup.php";
|
||||
case SITE_EX:
|
||||
return "http://ul.exhentai.org/image_lookup.php";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,12 @@ import android.os.Parcelable;
|
||||
|
||||
public class GalleryComment implements Parcelable {
|
||||
|
||||
// 0 for uploader comment. can't vote
|
||||
public long id;
|
||||
public int score;
|
||||
public boolean voteUp;
|
||||
public boolean voteDown;
|
||||
public String voteState;
|
||||
public long time;
|
||||
public String user;
|
||||
public String comment;
|
||||
@@ -32,6 +38,11 @@ public class GalleryComment implements Parcelable {
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(this.id);
|
||||
dest.writeInt(this.score);
|
||||
dest.writeByte(voteUp ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(voteDown ? (byte) 1 : (byte) 0);
|
||||
dest.writeString(this.voteState);
|
||||
dest.writeLong(this.time);
|
||||
dest.writeString(this.user);
|
||||
dest.writeString(this.comment);
|
||||
@@ -41,16 +52,23 @@ public class GalleryComment implements Parcelable {
|
||||
}
|
||||
|
||||
protected GalleryComment(Parcel in) {
|
||||
this.id = in.readLong();
|
||||
this.score = in.readInt();
|
||||
this.voteUp = in.readByte() != 0;
|
||||
this.voteDown = in.readByte() != 0;
|
||||
this.voteState = in.readString();
|
||||
this.time = in.readLong();
|
||||
this.user = in.readString();
|
||||
this.comment = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<GalleryComment> CREATOR = new Creator<GalleryComment>() {
|
||||
@Override
|
||||
public GalleryComment createFromParcel(Parcel source) {
|
||||
return new GalleryComment(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GalleryComment[] newArray(int size) {
|
||||
return new GalleryComment[size];
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.Arrays;
|
||||
|
||||
public class GalleryDetail extends GalleryInfo {
|
||||
|
||||
public long apiUid = -1L;
|
||||
public String apiKey;
|
||||
public int torrentCount;
|
||||
public String torrentUrl;
|
||||
public String parent;
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.hippo.ehviewer.client.data;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.hippo.ehviewer.client.EhConfig;
|
||||
@@ -62,6 +63,11 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
private int mAdvanceSearch = -1;
|
||||
private int mMinRating = -1;
|
||||
|
||||
private String mImagePath;
|
||||
private boolean mUseSimilarityScan;
|
||||
private boolean mOnlySearchCovers;
|
||||
private boolean mShowExpunged;
|
||||
|
||||
/**
|
||||
* Make this ListUrlBuilder point to homepage
|
||||
*/
|
||||
@@ -72,6 +78,10 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mKeyword = null;
|
||||
mAdvanceSearch = -1;
|
||||
mMinRating = -1;
|
||||
mImagePath = null;
|
||||
mUseSimilarityScan = false;
|
||||
mOnlySearchCovers = false;
|
||||
mShowExpunged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,6 +142,39 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mMinRating = minRating;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getImagePath() {
|
||||
return mImagePath;
|
||||
}
|
||||
|
||||
public void setImagePath(String imagePath) {
|
||||
mImagePath = imagePath;
|
||||
}
|
||||
|
||||
public boolean isUseSimilarityScan() {
|
||||
return mUseSimilarityScan;
|
||||
}
|
||||
|
||||
public void setUseSimilarityScan(boolean useSimilarityScan) {
|
||||
mUseSimilarityScan = useSimilarityScan;
|
||||
}
|
||||
|
||||
public boolean isOnlySearchCovers() {
|
||||
return mOnlySearchCovers;
|
||||
}
|
||||
|
||||
public void setOnlySearchCovers(boolean onlySearchCovers) {
|
||||
mOnlySearchCovers = onlySearchCovers;
|
||||
}
|
||||
|
||||
public boolean isShowExpunged() {
|
||||
return mShowExpunged;
|
||||
}
|
||||
|
||||
public void setShowExpunged(boolean showExpunged) {
|
||||
mShowExpunged = showExpunged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make them the same
|
||||
* @param lub The template
|
||||
@@ -143,6 +186,10 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mKeyword = lub.mKeyword;
|
||||
mAdvanceSearch = lub.mAdvanceSearch;
|
||||
mMinRating = lub.mMinRating;
|
||||
mImagePath = lub.mImagePath;
|
||||
mUseSimilarityScan = lub.mUseSimilarityScan;
|
||||
mOnlySearchCovers = lub.mOnlySearchCovers;
|
||||
mShowExpunged = lub.mShowExpunged;
|
||||
}
|
||||
|
||||
public void set(QuickSearch q) {
|
||||
@@ -151,6 +198,10 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mKeyword = q.keyword;
|
||||
mAdvanceSearch = q.advanceSearch;
|
||||
mMinRating = q.minRating;
|
||||
mImagePath = null;
|
||||
mUseSimilarityScan = false;
|
||||
mOnlySearchCovers = false;
|
||||
mShowExpunged = false;
|
||||
}
|
||||
|
||||
public QuickSearch toQuickSearch() {
|
||||
@@ -413,6 +464,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
case MODE_IMAGE_SEARCH:
|
||||
return EhUrl.getImageSearchUrl();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,22 +482,30 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
dest.writeString(this.mKeyword);
|
||||
dest.writeInt(this.mAdvanceSearch);
|
||||
dest.writeInt(this.mMinRating);
|
||||
dest.writeString(this.mImagePath);
|
||||
dest.writeByte(mUseSimilarityScan ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(mOnlySearchCovers ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(mShowExpunged ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
public ListUrlBuilder() {}
|
||||
public ListUrlBuilder() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("WrongConstant")
|
||||
protected ListUrlBuilder(Parcel in) {
|
||||
mMode = in.readInt();
|
||||
mPageIndex = in.readInt();
|
||||
mCategory = in.readInt();
|
||||
mKeyword = in.readString();
|
||||
mAdvanceSearch = in.readInt();
|
||||
mMinRating = in.readInt();
|
||||
this.mMode = in.readInt();
|
||||
this.mPageIndex = in.readInt();
|
||||
this.mCategory = in.readInt();
|
||||
this.mKeyword = in.readString();
|
||||
this.mAdvanceSearch = in.readInt();
|
||||
this.mMinRating = in.readInt();
|
||||
this.mImagePath = in.readString();
|
||||
this.mUseSimilarityScan = in.readByte() != 0;
|
||||
this.mOnlySearchCovers = in.readByte() != 0;
|
||||
this.mShowExpunged = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<ListUrlBuilder> CREATOR = new Parcelable.Creator<ListUrlBuilder>() {
|
||||
|
||||
public static final Creator<ListUrlBuilder> CREATOR = new Creator<ListUrlBuilder>() {
|
||||
@Override
|
||||
public ListUrlBuilder createFromParcel(Parcel source) {
|
||||
return new ListUrlBuilder(source);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
@@ -53,7 +54,7 @@ import java.util.regex.Pattern;
|
||||
public class GalleryDetailParser {
|
||||
|
||||
private static final Pattern PATTERN_ERROR = Pattern.compile("<div class=\"d\">\n<p>([^<]+)</p>");
|
||||
private static final Pattern PATTERN_DETAIL = Pattern.compile("var gid = (\\d+).+?var token = \"([a-f0-9]+)\"", Pattern.DOTALL);
|
||||
private static final Pattern PATTERN_DETAIL = Pattern.compile("var gid = (\\d+);.+?var token = \"([a-f0-9]+)\";.+?var apiuid = ([\\-\\d]+);.+?var apikey = \"([a-f0-9]+)\";", Pattern.DOTALL);
|
||||
private static final Pattern PATTERN_TORRENT = Pattern.compile("<a[^<>]*onclick=\"return popUp\\('([^']+)'[^)]+\\)\">Torrent Download \\( (\\d+) \\)</a>");
|
||||
private static final Pattern PATTERN_TAG_GROUP = Pattern.compile("<tr><td[^<>]+>([\\w\\s]+):</td><td>(?:<div[^<>]+><a[^<>]+>[\\w\\s]+</a></div>)+</td></tr>");
|
||||
private static final Pattern PATTERN_TAG = Pattern.compile("<div[^<>]+><a[^<>]+>([\\w\\s]+)</a></div>");
|
||||
@@ -108,6 +109,8 @@ public class GalleryDetailParser {
|
||||
if (matcher.find()) {
|
||||
gd.gid = Long.parseLong(matcher.group(1));
|
||||
gd.token = matcher.group(2);
|
||||
gd.apiUid = NumberUtils.parseLongSafely(matcher.group(3), -1L);
|
||||
gd.apiKey = matcher.group(4);
|
||||
} else {
|
||||
throw new ParseException("Can't parse gallery detail", body);
|
||||
}
|
||||
@@ -342,11 +345,40 @@ public class GalleryDetailParser {
|
||||
public static GalleryComment parseComment(Element element) {
|
||||
try {
|
||||
GalleryComment comment = new GalleryComment();
|
||||
// Id
|
||||
Element a = element.previousElementSibling();
|
||||
String name = a.attr("name");
|
||||
comment.id = Integer.parseInt(StringUtils.trim(name).substring(1));
|
||||
// Vote up and vote down
|
||||
Element c4 = JsoupUtils.getElementByClass(element, "c4");
|
||||
if (null != c4) {
|
||||
Elements es = c4.children();
|
||||
if (2 == es.size()) {
|
||||
comment.voteUp = !TextUtils.isEmpty(StringUtils.trim(es.get(0).attr("style")));
|
||||
comment.voteDown = !TextUtils.isEmpty(StringUtils.trim(es.get(1).attr("style")));
|
||||
}
|
||||
}
|
||||
// Vote state
|
||||
Element c7 = JsoupUtils.getElementByClass(element, "c7");
|
||||
if (null != c7) {
|
||||
comment.voteState = StringUtils.trim(c7.text());
|
||||
}
|
||||
// Score
|
||||
Element c5 = JsoupUtils.getElementByClass(element, "c5");
|
||||
if (null != c5) {
|
||||
Elements es = c5.children();
|
||||
if (!es.isEmpty()) {
|
||||
comment.score = NumberUtils.parseIntSafely(StringUtils.trim(es.get(0).text()), 0);
|
||||
}
|
||||
}
|
||||
// time
|
||||
Element c3 = JsoupUtils.getElementByClass(element, "c3");
|
||||
String temp = c3.ownText();
|
||||
temp = temp.substring("Posted on ".length(), temp.length() - " by: ".length());
|
||||
comment.time = WEB_COMMENT_DATE_FORMAT.parse(temp).getTime();
|
||||
// user
|
||||
comment.user = c3.child(0).text();
|
||||
// comment
|
||||
comment.comment = JsoupUtils.getElementByClass(element, "c6").html();
|
||||
return comment;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.client.parser;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class VoteCommentParser {
|
||||
|
||||
public static class Result {
|
||||
public long id;
|
||||
public int score;
|
||||
public int vote;
|
||||
public int expectVote;
|
||||
}
|
||||
|
||||
// {"comment_id":1253922,"comment_score":-19,"comment_vote":0}
|
||||
public static Result parse(String body, int vote) throws JSONException {
|
||||
Result result = new Result();
|
||||
JSONObject jo = new JSONObject(body);
|
||||
result.id = jo.getLong("comment_id");
|
||||
result.score = jo.getInt("comment_score");
|
||||
result.vote = jo.getInt("comment_vote");
|
||||
result.expectVote = vote;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,6 @@ import com.hippo.yorozuya.sparse.SparseJLArray;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
// TODO Stop and delete action should not pass through DownloadService
|
||||
public class DownloadService extends Service implements DownloadManager.DownloadListener {
|
||||
|
||||
public static final String ACTION_START = "start";
|
||||
|
||||
@@ -47,6 +47,7 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
private String mErrorStr;
|
||||
private GLTextureView mErrorView;
|
||||
private final LinkedList<GalleryPageView> mPages = new LinkedList<>();
|
||||
private final LinkedList<GalleryPageView> mTempPages = new LinkedList<>();
|
||||
|
||||
private int mOffset;
|
||||
private int mDeltaX;
|
||||
@@ -152,127 +153,198 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
return page;
|
||||
}
|
||||
|
||||
private void fillPages() {
|
||||
GalleryView.Adapter adapter = mAdapter;
|
||||
GalleryView galleryView = mGalleryView;
|
||||
int width = galleryView.getWidth();
|
||||
int height = galleryView.getHeight();
|
||||
int size = adapter.size();
|
||||
|
||||
int minY = (int) (-height * RESERVATIONS);
|
||||
|
||||
// Remove useless top view
|
||||
Iterator<GalleryPageView> pages = mPages.iterator();
|
||||
int nextTop = mOffset;
|
||||
while (pages.hasNext()) {
|
||||
GalleryPageView page = pages.next();
|
||||
nextTop += page.getHeight() + mInterval;
|
||||
if (nextTop < minY) {
|
||||
removePage(page);
|
||||
pages.remove();
|
||||
// Update offset
|
||||
mOffset = nextTop;
|
||||
if (mIndex < size - 1) {
|
||||
mIndex++;
|
||||
} else {
|
||||
Log.e(TAG, "The page is out of show range, but it has no next page");
|
||||
private GalleryPageView getPageForIndex(List<GalleryPageView> pages, int index, boolean remove) {
|
||||
for (Iterator<GalleryPageView> iterator = pages.iterator(); iterator.hasNext();) {
|
||||
GalleryPageView page = iterator.next();
|
||||
if (index == page.getIndex()) {
|
||||
if (remove) {
|
||||
iterator.remove();
|
||||
}
|
||||
return page;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void fillPages(int startIndex, int startOffset) {
|
||||
final GalleryView.Adapter adapter = mAdapter;
|
||||
final GalleryView galleryView = mGalleryView;
|
||||
final LinkedList<GalleryPageView> pages = mPages;
|
||||
final LinkedList<GalleryPageView> tempPages = mTempPages;
|
||||
final int width = galleryView.getWidth();
|
||||
final int height = galleryView.getHeight();
|
||||
final int size = adapter.size();
|
||||
final int interval = mInterval;
|
||||
final int minY = (int) (-height * RESERVATIONS);
|
||||
final int maxY = (int) (height * (1 + RESERVATIONS));
|
||||
final int widthSpec = GLView.MeasureSpec.makeMeasureSpec(width, GLView.MeasureSpec.EXACTLY);
|
||||
final int heightSpec = GLView.MeasureSpec.makeMeasureSpec(height, GLView.MeasureSpec.UNSPECIFIED);
|
||||
|
||||
// Fix start index and start offset
|
||||
if (startIndex < 0) {
|
||||
startIndex = 0;
|
||||
startOffset = 0;
|
||||
} else if (startIndex >= size) {
|
||||
startIndex = size - 1;
|
||||
startOffset = 0;
|
||||
} else if (startOffset < minY) {
|
||||
while (true) {
|
||||
GalleryPageView page = getPageForIndex(pages, startIndex, false);
|
||||
if (null == page) {
|
||||
startOffset = minY;
|
||||
break;
|
||||
} else {
|
||||
page.measure(widthSpec, heightSpec);
|
||||
if (startOffset + page.getHeight() > minY) {
|
||||
break;
|
||||
} else if (size - 1 == startIndex) {
|
||||
startOffset = 0;
|
||||
break;
|
||||
} else {
|
||||
++startIndex;
|
||||
startOffset += page.getHeight() + interval;
|
||||
if (startOffset >= minY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (startOffset >= maxY) {
|
||||
if (0 == startIndex) {
|
||||
startOffset = 0;
|
||||
} else {
|
||||
break;
|
||||
--startIndex;
|
||||
int startBottomOffset = startOffset - interval;
|
||||
while (true) {
|
||||
GalleryPageView page = getPageForIndex(pages, startIndex, false);
|
||||
if (null == page) {
|
||||
startOffset = maxY - 1;
|
||||
break;
|
||||
} else {
|
||||
page.measure(widthSpec, heightSpec);
|
||||
startOffset = startBottomOffset - page.getHeight();
|
||||
if (startOffset < maxY) {
|
||||
break;
|
||||
} else if (0 == startIndex) {
|
||||
startOffset = 0;
|
||||
break;
|
||||
} else {
|
||||
--startIndex;
|
||||
startBottomOffset = startOffset - interval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fill missing top
|
||||
int oldOffset = mOffset;
|
||||
int y = oldOffset;
|
||||
int widthSpec = GLView.MeasureSpec.makeMeasureSpec(width, GLView.MeasureSpec.EXACTLY);
|
||||
int heightSpec = GLView.MeasureSpec.makeMeasureSpec(height, GLView.MeasureSpec.UNSPECIFIED);
|
||||
int pageSize = 0;
|
||||
while (y >= minY && mIndex > 0) {
|
||||
mIndex--;
|
||||
// Put page to temp list
|
||||
tempPages.addAll(pages);
|
||||
pages.clear();
|
||||
|
||||
GalleryPageView page = obtainPage();
|
||||
// Layout start page
|
||||
GalleryPageView page = getPageForIndex(tempPages, startIndex, true);
|
||||
if (null == page) {
|
||||
page = obtainPage();
|
||||
galleryView.addComponent(page);
|
||||
mAdapter.bind(page, mIndex);
|
||||
mPages.add(0, page);
|
||||
|
||||
// Add interval
|
||||
y -= mInterval;
|
||||
|
||||
// Measure and layout
|
||||
page.measure(widthSpec, heightSpec);
|
||||
page.layout(0, y - page.getMeasuredHeight(), width, y);
|
||||
|
||||
// Update y
|
||||
y -= page.getMeasuredHeight();
|
||||
|
||||
// size increase
|
||||
pageSize++;
|
||||
adapter.bind(page, startIndex);
|
||||
}
|
||||
mOffset = y;
|
||||
pages.add(page);
|
||||
page.measure(widthSpec, heightSpec);
|
||||
page.layout(0, startOffset, width, startOffset + page.getMeasuredHeight());
|
||||
|
||||
// Fix offset, ensure it is not positive
|
||||
if (mOffset > 0) {
|
||||
int offset = mOffset;
|
||||
// Update offset
|
||||
mOffset = 0;
|
||||
oldOffset -= offset;
|
||||
// Translate pages
|
||||
pages = mPages.iterator();
|
||||
for (int i = 0; i < pageSize; i++) {
|
||||
pages.next().offsetTopAndBottom(-offset);
|
||||
}
|
||||
}
|
||||
// Prepare for check up and down
|
||||
int bottomOffset = startOffset - interval;
|
||||
int topOffset = startOffset + page.getMeasuredHeight() + interval;
|
||||
|
||||
// Fill from oldOffset
|
||||
int maxY = (int) (height * (1 + RESERVATIONS));
|
||||
y = oldOffset;
|
||||
pages = mPages.iterator();
|
||||
for (int i = 0; i < pageSize; i++) {
|
||||
pages.next();
|
||||
}
|
||||
int index = mIndex + pageSize;
|
||||
// Do fill
|
||||
while (true) {
|
||||
GalleryPageView page;
|
||||
if (pages == null || !pages.hasNext()) {
|
||||
pages = null;
|
||||
// New page
|
||||
// Check up
|
||||
int index = startIndex - 1;
|
||||
while (bottomOffset > minY && index >= 0) {
|
||||
page = getPageForIndex(tempPages, index, true);
|
||||
if (null == page) {
|
||||
page = obtainPage();
|
||||
galleryView.addComponent(page);
|
||||
mAdapter.bind(page, index);
|
||||
mPages.add(page);
|
||||
} else {
|
||||
page = pages.next();
|
||||
adapter.bind(page, index);
|
||||
}
|
||||
|
||||
// Measure and layout
|
||||
pages.addFirst(page);
|
||||
page.measure(widthSpec, heightSpec);
|
||||
page.layout(0, y, width, y + page.getMeasuredHeight());
|
||||
page.layout(0, bottomOffset - page.getMeasuredHeight(), width, bottomOffset);
|
||||
// Update
|
||||
bottomOffset -= page.getMeasuredHeight() + interval;
|
||||
index--;
|
||||
}
|
||||
|
||||
// size increase
|
||||
pageSize++;
|
||||
|
||||
// Update y and check out of range
|
||||
y += page.getMeasuredHeight();
|
||||
if (y > maxY) {
|
||||
break;
|
||||
// Avoid space in top
|
||||
page = pages.getFirst();
|
||||
if (0 == page.getIndex() && page.bounds().top > 0) {
|
||||
int offset = -page.bounds().top;
|
||||
for (GalleryPageView p: pages) {
|
||||
p.offsetTopAndBottom(offset);
|
||||
}
|
||||
topOffset += offset;
|
||||
}
|
||||
|
||||
y += mInterval;
|
||||
|
||||
// Check has next
|
||||
if (index >= size - 1) {
|
||||
break;
|
||||
// Check down
|
||||
index = startIndex + 1;
|
||||
while (topOffset < maxY && index < size) {
|
||||
page = getPageForIndex(tempPages, index, true);
|
||||
if (null == page) {
|
||||
page = obtainPage();
|
||||
galleryView.addComponent(page);
|
||||
adapter.bind(page, index);
|
||||
}
|
||||
|
||||
pages.addLast(page);
|
||||
page.measure(widthSpec, heightSpec);
|
||||
page.layout(0, topOffset, width, topOffset + page.getMeasuredHeight());
|
||||
// Update
|
||||
topOffset += page.getMeasuredHeight() + interval;
|
||||
index++;
|
||||
}
|
||||
|
||||
// Remove useless page
|
||||
while (mPages.size() > pageSize) {
|
||||
GalleryPageView page = mPages.removeLast();
|
||||
removePage(page);
|
||||
// Avoid space in bottom
|
||||
if (size - 1 == pages.getLast().getIndex()) {
|
||||
while (true) {
|
||||
page = pages.getLast();
|
||||
int pagesBottom = page.bounds().bottom;
|
||||
if (pagesBottom >= height) {
|
||||
break;
|
||||
}
|
||||
page = pages.getFirst();
|
||||
index = page.getIndex();
|
||||
if (0 == index) {
|
||||
break;
|
||||
}
|
||||
--index;
|
||||
int pagesTop = page.bounds().top;
|
||||
|
||||
page = getPageForIndex(tempPages, index, true);
|
||||
if (null == page) {
|
||||
page = obtainPage();
|
||||
galleryView.addComponent(page);
|
||||
adapter.bind(page, index);
|
||||
}
|
||||
pages.addFirst(page);
|
||||
page.measure(widthSpec, heightSpec);
|
||||
|
||||
int offset = Math.min(height - pagesBottom, page.getMeasuredHeight());
|
||||
for (GalleryPageView p: pages) {
|
||||
p.offsetTopAndBottom(offset);
|
||||
}
|
||||
int bottom = pagesTop - interval + offset;
|
||||
page.layout(0, bottom - page.getMeasuredHeight(), width, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove remain page
|
||||
for (GalleryPageView p : tempPages) {
|
||||
removePage(p);
|
||||
}
|
||||
tempPages.clear();
|
||||
|
||||
// Update state
|
||||
if (!pages.isEmpty()) {
|
||||
page = pages.getFirst();
|
||||
mIndex = page.getIndex();
|
||||
mOffset = page.bounds().top;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,56 +432,30 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
}
|
||||
}
|
||||
|
||||
fillPages();
|
||||
|
||||
// Ensure first shown loaded page top is the same
|
||||
if (firstShownLoadedPage != null && mFirstShownLoadedPageIndex == firstShownLoadedPage.getIndex()) {
|
||||
int newTop = firstShownLoadedPage.bounds().top;
|
||||
if (firstShownLoadedPageTop != newTop) {
|
||||
mOffset += firstShownLoadedPageTop - newTop;
|
||||
fillPages();
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid page not fill bottom, but has previous
|
||||
while (true) {
|
||||
int bottomDist = height - pages.getLast().bounds().bottom;
|
||||
int topDist = 0 - pages.getFirst().bounds().top;
|
||||
if (bottomDist > 0 && topDist > 0) {
|
||||
int translate = Math.min(bottomDist, topDist);
|
||||
// Update offset
|
||||
mOffset += translate;
|
||||
// Translate pages
|
||||
for (GalleryPageView page : pages) {
|
||||
page.offsetTopAndBottom(-translate);
|
||||
}
|
||||
// Break if no previous
|
||||
if (mIndex <= 0) {
|
||||
break;
|
||||
}
|
||||
// Refill pages
|
||||
fillPages();
|
||||
// Break if last page bottom fit gallery view bottom
|
||||
if (bottomDist <= topDist) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
int startIndex;
|
||||
int startOffset;
|
||||
if (null != firstShownLoadedPage) {
|
||||
startIndex = mFirstShownLoadedPageIndex;
|
||||
startOffset = firstShownLoadedPageTop;
|
||||
} else {
|
||||
startIndex = mIndex;
|
||||
startOffset = mOffset;
|
||||
}
|
||||
fillPages(startIndex, startOffset);
|
||||
|
||||
// Get first shown loaded image
|
||||
mFirstShownLoadedPageIndex = GalleryPageView.INVALID_INDEX;
|
||||
for (GalleryPageView page : mPages) {
|
||||
// Check first shown loaded page
|
||||
if (mScrollUp && !page.isLoaded()) {
|
||||
if (!page.isLoaded()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Rect bound = page.bounds();
|
||||
int pageTop = bound.top;
|
||||
int pageBottom = bound.bottom;
|
||||
if ((pageTop > 0 && pageTop < height) || (pageBottom > 0 && pageBottom < height)) {
|
||||
if ((pageTop >= 0 && pageTop < height) || (pageBottom > 0 && pageBottom <= height) ||
|
||||
(pageTop < 0 && pageBottom > height)) {
|
||||
mFirstShownLoadedPageIndex = page.getIndex();
|
||||
break;
|
||||
}
|
||||
@@ -506,12 +552,12 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
if (remainY < 0) { // Try to show top
|
||||
int limit;
|
||||
if (mIndex > 0) {
|
||||
limit = (int) (-height * RESERVATIONS);
|
||||
limit = (int) (-height * RESERVATIONS) + mInterval;
|
||||
} else {
|
||||
limit = 0;
|
||||
}
|
||||
|
||||
if (mOffset - remainY < limit) {
|
||||
if (mOffset - remainY <= limit) {
|
||||
mOffset -= remainY;
|
||||
remainY = 0;
|
||||
requestFill = true;
|
||||
@@ -521,6 +567,9 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
if (mIndex > 0) {
|
||||
mOffset = limit;
|
||||
remainY = remainY + limit - mOffset;
|
||||
// Offset one pixel to avoid infinite loop
|
||||
++mOffset;
|
||||
++remainY;
|
||||
galleryView.forceFill();
|
||||
requestFill = false;
|
||||
mDeltaX = 0;
|
||||
@@ -544,14 +593,14 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
|
||||
int limit;
|
||||
if (hasNext) {
|
||||
limit = (int) (height * (1 + RESERVATIONS));
|
||||
limit = (int) (height * (1 + RESERVATIONS)) - mInterval;
|
||||
} else {
|
||||
limit = height;
|
||||
}
|
||||
// Fix limit for page not fill screen
|
||||
limit = Math.min(bottom, limit);
|
||||
|
||||
if (bottom - remainY > limit) {
|
||||
if (bottom - remainY >= limit) {
|
||||
mOffset -= remainY;
|
||||
remainY = 0;
|
||||
requestFill = true;
|
||||
@@ -561,6 +610,9 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
if (hasNext) {
|
||||
mOffset -= bottom - limit;
|
||||
remainY = remainY + limit - bottom;
|
||||
// Offset one pixel to avoid infinite loop
|
||||
--mOffset;
|
||||
--remainY;
|
||||
galleryView.forceFill();
|
||||
requestFill = false;
|
||||
mDeltaX = 0;
|
||||
@@ -749,7 +801,8 @@ public class ScrollLayoutManager extends GalleryView.LayoutManager {
|
||||
Rect bound = page.bounds();
|
||||
int pageTop = bound.top;
|
||||
int pageBottom = bound.bottom;
|
||||
if ((pageTop > 0 && pageTop < height) || (pageBottom > 0 && pageBottom < height)) {
|
||||
if ((pageTop >= 0 && pageTop < height) || (pageBottom > 0 && pageBottom <= height) ||
|
||||
(pageTop < 0 && pageBottom > height)) {
|
||||
return page.getIndex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.preference;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.preference.Preference;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhEngine;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.spider.SpiderQueen;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class RestoreDownloadPreference extends TaskPreference {
|
||||
|
||||
public RestoreDownloadPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public RestoreDownloadPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public RestoreDownloadPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Task onCreateTask() {
|
||||
return new RestoreTask(getContext());
|
||||
}
|
||||
|
||||
private static class RestoreTask extends Task {
|
||||
|
||||
private final EhApplication mApplication;
|
||||
private final DownloadManager mManager;
|
||||
private final OkHttpClient mHttpClient;
|
||||
|
||||
public RestoreTask(@NonNull Context context) {
|
||||
super(context);
|
||||
mApplication = (EhApplication) context.getApplicationContext();
|
||||
mManager = EhApplication.getDownloadManager(mApplication);
|
||||
mHttpClient = EhApplication.getOkHttpClient(mApplication);
|
||||
}
|
||||
|
||||
private RestoreItem getRestoreItem(UniFile file) {
|
||||
if (null == file || !file.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
UniFile siFile = file.findFile(SpiderQueen.SPIDER_INFO_FILENAME);
|
||||
if (null == siFile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = siFile.openInputStream();
|
||||
// Skip start page
|
||||
IOUtils.readAsciiLine(is);
|
||||
long gid = Long.parseLong(IOUtils.readAsciiLine(is));
|
||||
if (mManager.containDownloadInfo(gid)) {
|
||||
return null;
|
||||
}
|
||||
String token = IOUtils.readAsciiLine(is);
|
||||
RestoreItem restoreItem = new RestoreItem();
|
||||
restoreItem.gid = gid;
|
||||
restoreItem.token = token;
|
||||
restoreItem.dirname = file.getName();
|
||||
return restoreItem;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doInBackground(Void... params) {
|
||||
UniFile dir = Settings.getDownloadLocation();
|
||||
if (null == dir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<RestoreItem> restoreItemList = new ArrayList<>();
|
||||
|
||||
UniFile[] files = dir.listFiles();
|
||||
for (UniFile file: files) {
|
||||
RestoreItem restoreItem = getRestoreItem(file);
|
||||
if (null != restoreItem) {
|
||||
restoreItemList.add(restoreItem);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == restoreItemList.size()) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
try {
|
||||
return EhEngine.fillGalleryListByApi(null, mHttpClient, new ArrayList<GalleryInfo>(restoreItemList));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void onPostExecute(Object o) {
|
||||
if (!(o instanceof List)) {
|
||||
Toast.makeText(mApplication, R.string.settings_download_restore_failed, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
List<RestoreItem> list = (List<RestoreItem>) o;
|
||||
if (list.isEmpty()) {
|
||||
Toast.makeText(mApplication, R.string.settings_download_restore_not_found, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
int count = 0;
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
RestoreItem item = list.get(i);
|
||||
// Avoid failed gallery info
|
||||
if (null != item.title) {
|
||||
// Put to download
|
||||
mManager.addDownload(item, null);
|
||||
// Put download dir to DB
|
||||
EhDB.putDownloadDirname(item.gid, item.dirname);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
Toast.makeText(mApplication,
|
||||
mApplication.getString(R.string.settings_download_restore_successfully, count),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
Preference preference = getPreference();
|
||||
if (null != preference) {
|
||||
Context context = preference.getContext();
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).setResult(Activity.RESULT_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onPostExecute(o);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RestoreItem extends GalleryInfo {
|
||||
|
||||
public String dirname;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeString(this.dirname);
|
||||
}
|
||||
|
||||
public RestoreItem() {
|
||||
}
|
||||
|
||||
protected RestoreItem(Parcel in) {
|
||||
super(in);
|
||||
this.dirname = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<RestoreItem> CREATOR = new Creator<RestoreItem>() {
|
||||
@Override
|
||||
public RestoreItem createFromParcel(Parcel source) {
|
||||
return new RestoreItem(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestoreItem[] newArray(int size) {
|
||||
return new RestoreItem[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.preference;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.preference.DialogPreference;
|
||||
import com.hippo.yorozuya.IntIdGenerator;
|
||||
|
||||
public abstract class TaskPreference extends DialogPreference {
|
||||
|
||||
private Task mTask;
|
||||
private int mTaskId = IntIdGenerator.INVALID_ID;
|
||||
|
||||
public TaskPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public TaskPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public TaskPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
builder.setTitle(null);
|
||||
builder.setView(R.layout.preference_dialog_task);
|
||||
builder.setCancelable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogCreated(AlertDialog dialog) {
|
||||
if (null == mTask) {
|
||||
mTask = onCreateTask();
|
||||
mTask.setPreference(this);
|
||||
mTaskId = ((EhApplication) getContext().getApplicationContext()).putGlobalStuff(mTask);
|
||||
mTask.execute();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onTaskEnd() {
|
||||
// Dismiss dialog
|
||||
Dialog dialog = getDialog();
|
||||
if (null != dialog) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
// Clear async
|
||||
mTask = null;
|
||||
mTaskId = IntIdGenerator.INVALID_ID;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected abstract Task onCreateTask();
|
||||
|
||||
@Override
|
||||
public void onActivityDestroy() {
|
||||
super.onActivityDestroy();
|
||||
|
||||
if (null != mTask) {
|
||||
mTask.setPreference(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
final Parcelable superState = super.onSaveInstanceState();
|
||||
final SavedState myState = new SavedState(superState);
|
||||
myState.asyncTaskId = mTaskId;
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (state == null || !state.getClass().equals(SavedState.class)) {
|
||||
// Didn't save state for us in onSaveInstanceState
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
|
||||
SavedState myState = (SavedState) state;
|
||||
mTaskId = myState.asyncTaskId;
|
||||
if (IntIdGenerator.INVALID_ID != mTaskId) {
|
||||
Object o = ((EhApplication) getContext().getApplicationContext()).getGlobalStuff(mTaskId);
|
||||
if (o instanceof Task) {
|
||||
mTask = (Task) o;
|
||||
mTask.setPreference(this);
|
||||
}
|
||||
}
|
||||
if (null == mTask) {
|
||||
mTaskId = IntIdGenerator.INVALID_ID;
|
||||
}
|
||||
|
||||
// TODO if not task, show not reopen dialog
|
||||
|
||||
super.onRestoreInstanceState(myState.getSuperState());
|
||||
}
|
||||
|
||||
private static class SavedState extends BaseSavedState {
|
||||
int asyncTaskId;
|
||||
|
||||
public SavedState(Parcel source) {
|
||||
super(source);
|
||||
asyncTaskId = source.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(asyncTaskId);
|
||||
}
|
||||
|
||||
public SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<SavedState> CREATOR =
|
||||
new Parcelable.Creator<SavedState>() {
|
||||
@Override
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedState[] newArray(int size) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public abstract static class Task extends AsyncTask<Void, Void, Object> {
|
||||
|
||||
private final EhApplication mApplication;
|
||||
@Nullable
|
||||
private TaskPreference mPreference;
|
||||
|
||||
public Task(@NonNull Context context) {
|
||||
mApplication = (EhApplication) context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TaskPreference getPreference() {
|
||||
return mPreference;
|
||||
}
|
||||
|
||||
public void setPreference(@Nullable TaskPreference preference) {
|
||||
mPreference = preference;
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
protected void onPostExecute(Object o) {
|
||||
mApplication.removeGlobalStuff(this);
|
||||
if (null != mPreference) {
|
||||
mPreference.onTaskEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,11 @@ public final class SpiderDen {
|
||||
if (dir != null) {
|
||||
// Read from DB
|
||||
String dirname = EhDB.getDownloadDirname(galleryInfo.gid);
|
||||
if (null != dirname) {
|
||||
// Some dirname may be invalid in some version
|
||||
dirname = FileUtils.sanitizeFilename(dirname);
|
||||
EhDB.putDownloadDirname(galleryInfo.gid, dirname);
|
||||
}
|
||||
|
||||
// Find it
|
||||
if (null == dirname) {
|
||||
@@ -128,6 +133,17 @@ public final class SpiderDen {
|
||||
return mDownloadDir != null && mDownloadDir.ensureDir();
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
switch (mMode) {
|
||||
case SpiderQueen.MODE_READ:
|
||||
return sCache != null;
|
||||
case SpiderQueen.MODE_DOWNLOAD:
|
||||
return mDownloadDir != null && mDownloadDir.isDirectory();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UniFile getDownloadDir() {
|
||||
return mDownloadDir != null && mDownloadDir.isDirectory() ? mDownloadDir : null;
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.hippo.ehviewer.gallery.gl.GalleryPageView;
|
||||
import com.hippo.image.Image;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.OSUtils;
|
||||
import com.hippo.yorozuya.PriorityThread;
|
||||
import com.hippo.yorozuya.PriorityThreadFactory;
|
||||
@@ -71,7 +72,9 @@ import java.util.Queue;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import okhttp3.Call;
|
||||
@@ -129,16 +132,15 @@ public class SpiderQueen implements Runnable {
|
||||
@Nullable
|
||||
private volatile Thread mQueenThread;
|
||||
private final Object mQueenLock = new Object();
|
||||
private final ThreadFactory mThreadFactory = new PriorityThreadFactory(
|
||||
SpiderWorker.class.getSimpleName(), Process.THREAD_PRIORITY_BACKGROUND);
|
||||
|
||||
@Nullable
|
||||
private Thread mDecoderThread;
|
||||
private final Stack<Integer> mDecodeRequestStack = new Stack<>();
|
||||
private final AtomicInteger mDecodingIndex = new AtomicInteger(GalleryPageView.INVALID_INDEX);
|
||||
|
||||
private volatile Thread[] mWorkers;
|
||||
private final Object mWorkerLock = new Object();
|
||||
private ThreadPoolExecutor mWorkerPoolExecutor;
|
||||
private int mWorkerCount;
|
||||
|
||||
private final Object mPTokenLock = new Object();
|
||||
private volatile SpiderInfo mSpiderInfo;
|
||||
@@ -166,7 +168,7 @@ public class SpiderQueen implements Runnable {
|
||||
|
||||
private final List<OnSpiderListener> mSpiderListeners = new ArrayList<>();
|
||||
|
||||
private final int mSpiderWorkerNumber;
|
||||
private final int mWorkerMaxCount;
|
||||
private final int mPreloadNumber;
|
||||
|
||||
private SpiderQueen(EhApplication application, @NonNull GalleryInfo galleryInfo) {
|
||||
@@ -175,8 +177,12 @@ public class SpiderQueen implements Runnable {
|
||||
mGalleryInfo = galleryInfo;
|
||||
mSpiderDen = new SpiderDen(mGalleryInfo);
|
||||
|
||||
mSpiderWorkerNumber = Settings.getMultiThreadDownload();
|
||||
mPreloadNumber = Settings.getPreloadImage();
|
||||
mWorkerMaxCount = MathUtils.clamp(Settings.getMultiThreadDownload(), 1, 10);
|
||||
mPreloadNumber = MathUtils.clamp(Settings.getPreloadImage(), 0, 100);
|
||||
|
||||
mWorkerPoolExecutor = new ThreadPoolExecutor(mWorkerMaxCount, mWorkerMaxCount,
|
||||
0, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>(),
|
||||
new PriorityThreadFactory(SpiderWorker.class.getSimpleName(), Process.THREAD_PRIORITY_BACKGROUND));
|
||||
}
|
||||
|
||||
public void addOnSpiderListener(OnSpiderListener listener) {
|
||||
@@ -541,17 +547,13 @@ public class SpiderQueen implements Runnable {
|
||||
|
||||
private void ensureWorkers() {
|
||||
synchronized (mWorkerLock) {
|
||||
if (mWorkers == null) {
|
||||
mWorkers = new Thread[mSpiderWorkerNumber];
|
||||
if (null == mWorkerPoolExecutor) {
|
||||
Log.e(TAG, "Try to start worker after stopped");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0, n = mWorkers.length; i < n; i++) {
|
||||
if (mWorkers[i] == null) {
|
||||
SpiderWorker worker = new SpiderWorker(i);
|
||||
Thread thread = mThreadFactory.newThread(worker);
|
||||
mWorkers[i] = thread;
|
||||
thread.start();
|
||||
}
|
||||
for (; mWorkerCount < mWorkerMaxCount; mWorkerCount++) {
|
||||
mWorkerPoolExecutor.execute(new SpiderWorker());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -687,7 +689,9 @@ public class SpiderQueen implements Runnable {
|
||||
for (int i = 0, n = previewSet.size(); i < n; i++) {
|
||||
GalleryPageUrlParser.Result result = GalleryPageUrlParser.parse(previewSet.getPageUrlAt(i));
|
||||
if (result != null) {
|
||||
spiderInfo.pTokenMap.put(result.page, result.pToken);
|
||||
synchronized (mPTokenLock) {
|
||||
spiderInfo.pTokenMap.put(result.page, result.pToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -732,7 +736,11 @@ public class SpiderQueen implements Runnable {
|
||||
// Save to local
|
||||
writeSpiderInfoToLocal(mSpiderInfo);
|
||||
|
||||
return mSpiderInfo.pTokenMap.get(index);
|
||||
String pToken;
|
||||
synchronized (mPTokenLock) {
|
||||
pToken = mSpiderInfo.pTokenMap.get(index);
|
||||
}
|
||||
return pToken;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
@@ -887,18 +895,9 @@ public class SpiderQueen implements Runnable {
|
||||
|
||||
// Interrupt all workers
|
||||
synchronized (mWorkerLock) {
|
||||
if (mWorkers != null) {
|
||||
for (int i = 0, n = mWorkers.length; i < n; i++) {
|
||||
Thread thread = mWorkers[i];
|
||||
if (thread != null) {
|
||||
thread.interrupt();
|
||||
mWorkers[i] = null;
|
||||
}
|
||||
}
|
||||
mWorkers = null;
|
||||
}
|
||||
mWorkerPoolExecutor.shutdownNow();
|
||||
mWorkerPoolExecutor = null;
|
||||
}
|
||||
|
||||
notifyFinish();
|
||||
|
||||
if (DEBUG_LOG) {
|
||||
@@ -908,11 +907,9 @@ public class SpiderQueen implements Runnable {
|
||||
|
||||
private class SpiderWorker implements Runnable {
|
||||
|
||||
private final int mWorkerIndex;
|
||||
private final long mGid;
|
||||
|
||||
public SpiderWorker(int workerIndex) {
|
||||
mWorkerIndex = workerIndex;
|
||||
public SpiderWorker() {
|
||||
mGid = mGalleryInfo.gid;
|
||||
}
|
||||
|
||||
@@ -1046,7 +1043,7 @@ public class SpiderQueen implements Runnable {
|
||||
Response response = call.execute();
|
||||
if (response.code() >= 400) {
|
||||
// Maybe 404
|
||||
call.cancel();
|
||||
response.body().close();
|
||||
continue;
|
||||
}
|
||||
ResponseBody responseBody = response.body();
|
||||
@@ -1064,7 +1061,7 @@ public class SpiderQueen implements Runnable {
|
||||
if (null == pipe) {
|
||||
// Can't get pipe
|
||||
error = GetText.getString(R.string.error_write_failed);
|
||||
call.cancel();
|
||||
response.body().close();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1079,7 +1076,7 @@ public class SpiderQueen implements Runnable {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
int bytesRead = is.read(data);
|
||||
if (bytesRead == -1) {
|
||||
call.cancel();
|
||||
response.body().close();
|
||||
break;
|
||||
}
|
||||
os.write(data, 0, bytesRead);
|
||||
@@ -1240,27 +1237,17 @@ public class SpiderQueen implements Runnable {
|
||||
Log.i(TAG, Thread.currentThread().getName() + ": start");
|
||||
}
|
||||
|
||||
while (!Thread.currentThread().isInterrupted() && runInternal());
|
||||
while (mSpiderDen.isReady() && !Thread.currentThread().isInterrupted() && runInternal());
|
||||
|
||||
|
||||
boolean finish = true;
|
||||
boolean finish;
|
||||
// Clear in spider worker array
|
||||
synchronized (mWorkerLock) {
|
||||
if (mWorkers != null && mWorkerIndex < mWorkers.length &&
|
||||
mWorkers[mWorkerIndex] == Thread.currentThread()) {
|
||||
mWorkers[mWorkerIndex] = null;
|
||||
}
|
||||
if (mWorkers != null) {
|
||||
for (Thread mWorker : mWorkers) {
|
||||
if (null != mWorker) {
|
||||
finish = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (finish) {
|
||||
mWorkers = null;
|
||||
mWorkerCount--;
|
||||
if (mWorkerCount < 0) {
|
||||
Log.e(TAG, "WTF, mWorkerCount < 0, not thread safe or something wrong");
|
||||
mWorkerCount = 0;
|
||||
}
|
||||
finish = mWorkerCount <= 0;
|
||||
}
|
||||
|
||||
if (finish) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
// It is a dump activity to make Chrome or maybe other browser to send implicit intent when open eh url.
|
||||
// Take a look at AndroidManifest to know how it works.
|
||||
public class DumpBrowsableActivity extends EhActivity {}
|
||||
@@ -23,6 +23,7 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@@ -283,6 +284,22 @@ public class GalleryActivity extends EhActivity
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
// Orientation
|
||||
int orientation;
|
||||
switch (Settings.getScreenRotation()) {
|
||||
default:
|
||||
case 0:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
break;
|
||||
case 1:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
|
||||
break;
|
||||
case 2:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
||||
break;
|
||||
}
|
||||
setRequestedOrientation(orientation);
|
||||
|
||||
if (Settings.getGuideGallery()) {
|
||||
FrameLayout mainLayout = (FrameLayout) ViewUtils.$$(this, R.id.main);
|
||||
mainLayout.addView(new GalleryGuideView(this));
|
||||
@@ -653,6 +670,7 @@ public class GalleryActivity extends EhActivity
|
||||
private class GalleryMenuHelper implements DialogInterface.OnClickListener {
|
||||
|
||||
private final View mView;
|
||||
private final Spinner mScreenRotation;
|
||||
private final Spinner mReadingDirection;
|
||||
private final Spinner mScaleMode;
|
||||
private final Spinner mStartPosition;
|
||||
@@ -664,6 +682,7 @@ public class GalleryActivity extends EhActivity
|
||||
@SuppressLint("InflateParams")
|
||||
public GalleryMenuHelper(Context context) {
|
||||
mView = LayoutInflater.from(context).inflate(R.layout.dialog_gallery_menu, null);
|
||||
mScreenRotation = (Spinner) mView.findViewById(R.id.screen_rotation);
|
||||
mReadingDirection = (Spinner) mView.findViewById(R.id.reading_direction);
|
||||
mScaleMode = (Spinner) mView.findViewById(R.id.page_scaling);
|
||||
mStartPosition = (Spinner) mView.findViewById(R.id.start_position);
|
||||
@@ -672,6 +691,7 @@ public class GalleryActivity extends EhActivity
|
||||
mShowBattery = (SwitchCompat) mView.findViewById(R.id.show_battery);
|
||||
mVolumePage = (SwitchCompat) mView.findViewById(R.id.volume_page);
|
||||
|
||||
mScreenRotation.setSelection(Settings.getScreenRotation());
|
||||
mReadingDirection.setSelection(Settings.getReadingDirection());
|
||||
mScaleMode.setSelection(Settings.getPageScaling());
|
||||
mStartPosition.setSelection(Settings.getStartPosition());
|
||||
@@ -687,6 +707,7 @@ public class GalleryActivity extends EhActivity
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int screenRotation = mScreenRotation.getSelectedItemPosition();
|
||||
int layoutMode = GalleryView.sanitizeLayoutMode(mReadingDirection.getSelectedItemPosition());
|
||||
int scaleMode = ImageView.sanitizeScaleMode(mScaleMode.getSelectedItemPosition());
|
||||
int startPosition = ImageView.sanitizeStartPosition(mStartPosition.getSelectedItemPosition());
|
||||
@@ -695,6 +716,7 @@ public class GalleryActivity extends EhActivity
|
||||
boolean showBattery = mShowBattery.isChecked();
|
||||
boolean volumePage = mVolumePage.isChecked();
|
||||
|
||||
Settings.putScreenRotation(screenRotation);
|
||||
Settings.putReadingDirection(layoutMode);
|
||||
Settings.putPageScaling(scaleMode);
|
||||
Settings.putStartPosition(startPosition);
|
||||
@@ -703,6 +725,20 @@ public class GalleryActivity extends EhActivity
|
||||
Settings.putShowBattery(showBattery);
|
||||
Settings.putVolumePage(volumePage);
|
||||
|
||||
int orientation;
|
||||
switch (screenRotation) {
|
||||
default:
|
||||
case 0:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
break;
|
||||
case 1:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
|
||||
break;
|
||||
case 2:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
||||
break;
|
||||
}
|
||||
setRequestedOrientation(orientation);
|
||||
if (mGalleryView != null) {
|
||||
mGalleryView.setLayoutMode(layoutMode);
|
||||
mGalleryView.setScaleMode(scaleMode);
|
||||
|
||||
@@ -70,6 +70,8 @@ import com.hippo.scene.StageActivity;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.PermissionRequester;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout;
|
||||
import com.hippo.yorozuya.ResourcesUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public final class MainActivity extends StageActivity
|
||||
@@ -97,7 +99,7 @@ public final class MainActivity extends StageActivity
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private SlidingDrawerLayout mDrawerLayout;
|
||||
@Nullable
|
||||
private NavigationView mNavView;
|
||||
@Nullable
|
||||
@@ -290,13 +292,14 @@ 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 = (SlidingDrawerLayout) 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);
|
||||
mAvatar = (LoadImageView) ViewUtils.$$(headerLayout, R.id.avatar);
|
||||
mDisplayName = (TextView) ViewUtils.$$(headerLayout, R.id.display_name);
|
||||
|
||||
mDrawerLayout.setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
|
||||
// Pre-L need shadow drawable
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_left, Gravity.LEFT);
|
||||
@@ -387,9 +390,9 @@ public final class MainActivity extends StageActivity
|
||||
baseScene.getLayoutInflater2(), mRightDrawer, savedInstanceState);
|
||||
if (drawerView != null) {
|
||||
mRightDrawer.addView(drawerView);
|
||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
|
||||
mDrawerLayout.setDrawerLockMode(SlidingDrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
|
||||
} else {
|
||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
|
||||
mDrawerLayout.setDrawerLockMode(SlidingDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.UrlOpener;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.util.ActivityHelper;
|
||||
|
||||
@@ -34,11 +33,6 @@ public class AboutFragment extends PreferenceFragment
|
||||
Preference.OnPreferenceClickListener {
|
||||
|
||||
private static final String KEY_AUTHOR = "author";
|
||||
private static final String KEY_GOOGLE_PLUS = "google_plus";
|
||||
private static final String KEY_WEBSITE = "website";
|
||||
private static final String KEY_SOURCE = "source";
|
||||
private static final String KEY_CHANGELOG = "changelog";
|
||||
private static final String KEY_LICENSE = "license";
|
||||
private static final String KEY_DONATE = "donate";
|
||||
private static final String KEY_CHECK_FOR_UPDATES = "check_for_updates";
|
||||
|
||||
@@ -48,11 +42,7 @@ public class AboutFragment extends PreferenceFragment
|
||||
addPreferencesFromResource(R.xml.about_settings);
|
||||
|
||||
Preference author = findPreference(KEY_AUTHOR);
|
||||
Preference googlePlus = findPreference(KEY_GOOGLE_PLUS);
|
||||
Preference enableAnalytics = findPreference(Settings.KEY_ENABLE_ANALYTICS);
|
||||
Preference website = findPreference(KEY_WEBSITE);
|
||||
Preference source = findPreference(KEY_SOURCE);
|
||||
Preference changelog = findPreference(KEY_CHANGELOG);
|
||||
Preference donate = findPreference(KEY_DONATE);
|
||||
Preference checkForUpdate = findPreference(KEY_CHECK_FOR_UPDATES);
|
||||
|
||||
@@ -60,10 +50,6 @@ public class AboutFragment extends PreferenceFragment
|
||||
donate.setSummary(getString(R.string.settings_about_donate_summary).replace('$', '@'));
|
||||
|
||||
author.setOnPreferenceClickListener(this);
|
||||
googlePlus.setOnPreferenceClickListener(this);
|
||||
website.setOnPreferenceClickListener(this);
|
||||
source.setOnPreferenceClickListener(this);
|
||||
changelog.setOnPreferenceClickListener(this);
|
||||
donate.setOnPreferenceClickListener(this);
|
||||
checkForUpdate.setOnPreferenceClickListener(this);
|
||||
|
||||
@@ -88,18 +74,6 @@ public class AboutFragment extends PreferenceFragment
|
||||
if (KEY_AUTHOR.equals(key)) {
|
||||
ActivityHelper.sendEmail(getActivity(), EhApplication.getDeveloperEmail(),
|
||||
"About EhViewer", null);
|
||||
} else if (KEY_GOOGLE_PLUS.equals(key)) {
|
||||
UrlOpener.openUrl(getActivity(), "https://plus.google.com/communities/103823982034655188459",
|
||||
false, true);
|
||||
} else if (KEY_WEBSITE.equals(key)) {
|
||||
UrlOpener.openUrl(getActivity(), "http://www.ehviewer.com",
|
||||
false, true);
|
||||
} else if (KEY_SOURCE.equals(key)) {
|
||||
UrlOpener.openUrl(getActivity(), "https://github.com/seven332/EhViewer",
|
||||
false, true);
|
||||
} else if (KEY_CHANGELOG.equals(key)) {
|
||||
UrlOpener.openUrl(getActivity(), "http://www.ehviewer.com/changlog",
|
||||
false, true);
|
||||
} else if (KEY_DONATE.equals(key)) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.settings_about_donate)
|
||||
|
||||
@@ -22,45 +22,25 @@ import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hippo.app.ProgressDialog;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.spider.SpiderQueen;
|
||||
import com.hippo.ehviewer.ui.DirPickerActivity;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DownloadFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
|
||||
|
||||
private static final String TAG = DownloadFragment.class.getSimpleName();
|
||||
|
||||
public static final int REQUEST_CODE_PICK_IMAGE_DIR = 0;
|
||||
public static final int REQUEST_CODE_PICK_IMAGE_DIR_L = 1;
|
||||
|
||||
public static final String KEY_DOWNLOAD_LOCATION = "download_location";
|
||||
public static final String KEY_RESTORE_DOWNLOAD_ITEMS = "restore_download_items";
|
||||
|
||||
@Nullable
|
||||
private Preference mDownloadLocation;
|
||||
@@ -71,14 +51,12 @@ public class DownloadFragment extends PreferenceFragment implements Preference.O
|
||||
addPreferencesFromResource(R.xml.download_settings);
|
||||
|
||||
mDownloadLocation = findPreference(KEY_DOWNLOAD_LOCATION);
|
||||
Preference restoreDownloadItems = findPreference(KEY_RESTORE_DOWNLOAD_ITEMS);
|
||||
|
||||
onUpdateDownloadLocation();
|
||||
|
||||
if (mDownloadLocation != null) {
|
||||
mDownloadLocation.setOnPreferenceClickListener(this);
|
||||
}
|
||||
restoreDownloadItems.setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,18 +89,13 @@ public class DownloadFragment extends PreferenceFragment implements Preference.O
|
||||
showDirPickerDialogL();
|
||||
}
|
||||
return true;
|
||||
} else if (KEY_RESTORE_DOWNLOAD_ITEMS.equals(key)) {
|
||||
ProgressDialog dialog = ProgressDialog.show(getActivity(), null,
|
||||
getString(R.string.settings_download_restoring), true, false);
|
||||
new RestoreTask(dialog).execute();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void showDirPickerDialogKK() {
|
||||
new AlertDialog.Builder(getActivity()).setMessage(R.string.settings_download_pick_dir_kk)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
.setPositiveButton(R.string.settings_download_continue, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
openDirPicker();
|
||||
@@ -146,7 +119,7 @@ public class DownloadFragment extends PreferenceFragment implements Preference.O
|
||||
};
|
||||
|
||||
new AlertDialog.Builder(getActivity()).setMessage(R.string.settings_download_pick_dir_l)
|
||||
.setPositiveButton(android.R.string.ok, listener)
|
||||
.setPositiveButton(R.string.settings_download_continue, listener)
|
||||
.setNeutralButton(R.string.settings_download_document, listener)
|
||||
.show();
|
||||
}
|
||||
@@ -208,167 +181,4 @@ public class DownloadFragment extends PreferenceFragment implements Preference.O
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class RestoreTask extends AsyncTask<Void, Void, List<RestoreItem>> {
|
||||
|
||||
private final ProgressDialog mDialog;
|
||||
private final DownloadManager mManager;
|
||||
|
||||
public RestoreTask(ProgressDialog dialog) {
|
||||
mDialog = dialog;
|
||||
mManager = EhApplication.getDownloadManager(getActivity());
|
||||
}
|
||||
|
||||
private RestoreItem getRestoreItem(UniFile file) {
|
||||
if (null == file || !file.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
UniFile siFile = file.findFile(SpiderQueen.SPIDER_INFO_FILENAME);
|
||||
if (null == siFile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = siFile.openInputStream();
|
||||
// Skip start page
|
||||
IOUtils.readAsciiLine(is);
|
||||
long gid = Long.parseLong(IOUtils.readAsciiLine(is));
|
||||
if (mManager.containDownloadInfo(gid)) {
|
||||
return null;
|
||||
}
|
||||
String token = IOUtils.readAsciiLine(is);
|
||||
RestoreItem restoreItem = new RestoreItem();
|
||||
restoreItem.gid = gid;
|
||||
restoreItem.token = token;
|
||||
restoreItem.dirname = file.getName();
|
||||
return restoreItem;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<RestoreItem> doInBackground(Void... params) {
|
||||
UniFile dir = Settings.getDownloadLocation();
|
||||
if (null == dir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<RestoreItem> restoreItemList = new ArrayList<>();
|
||||
|
||||
UniFile[] files = dir.listFiles();
|
||||
for (UniFile file: files) {
|
||||
RestoreItem restoreItem = getRestoreItem(file);
|
||||
if (null != restoreItem) {
|
||||
restoreItemList.add(restoreItem);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == restoreItemList.size()) {
|
||||
return null;
|
||||
} else {
|
||||
return restoreItemList;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<RestoreItem> restoreItemList) {
|
||||
if (null == restoreItemList) {
|
||||
Toast.makeText(getActivity(), R.string.settings_download_restore_not_found,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
mDialog.dismiss();
|
||||
return;
|
||||
}
|
||||
|
||||
EhRequest request = new EhRequest();
|
||||
request.setMethod(EhClient.METHOD_FILL_GALLERY_LIST_BY_API);
|
||||
request.setArgs(new ArrayList<GalleryInfo>(restoreItemList));
|
||||
request.setCallback(new EhClient.Callback<List<GalleryInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(List<GalleryInfo> galleryInfoList) {
|
||||
DownloadManager downloadManager = EhApplication.getDownloadManager(getActivity());
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0, n = galleryInfoList.size(); i < n; i++) {
|
||||
GalleryInfo galleryInfo = galleryInfoList.get(i);
|
||||
// Avoid failed gallery info
|
||||
if (null != galleryInfo.title) {
|
||||
// Put to download
|
||||
downloadManager.addDownload(galleryInfo, null);
|
||||
// Put download dir to DB
|
||||
if (galleryInfo instanceof RestoreItem) {
|
||||
EhDB.putDownloadDirname(galleryInfo.gid, ((RestoreItem) galleryInfo).dirname);
|
||||
} else {
|
||||
Log.w(TAG, "The GalleryInfo is not RestoreItem");
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Toast.makeText(getActivity(),
|
||||
getString(R.string.settings_download_restore_successfully, count),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
mDialog.dismiss();
|
||||
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
Toast.makeText(getActivity(), R.string.settings_download_restore_failed,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
mDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
EhClient client = EhApplication.getEhClient(getActivity());
|
||||
client.execute(request);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RestoreItem extends GalleryInfo {
|
||||
|
||||
public String dirname;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeString(this.dirname);
|
||||
}
|
||||
|
||||
public RestoreItem() {
|
||||
}
|
||||
|
||||
protected RestoreItem(Parcel in) {
|
||||
super(in);
|
||||
this.dirname = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<RestoreItem> CREATOR = new Creator<RestoreItem>() {
|
||||
@Override
|
||||
public RestoreItem createFromParcel(Parcel source) {
|
||||
return new RestoreItem(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestoreItem[] newArray(int size) {
|
||||
return new RestoreItem[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
@@ -79,6 +80,25 @@ public class CookieSignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
|
||||
mOk.setOnClickListener(this);
|
||||
|
||||
// Try to get old version cookie info
|
||||
Context context = getContext2();
|
||||
AssertUtils.assertNotNull(context);
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("eh_info", 0);
|
||||
String ipbMemberId = sharedPreferences.getString("ipb_member_id", null);
|
||||
String ipbPassHash = sharedPreferences.getString("ipb_pass_hash", null);
|
||||
boolean getIt = false;
|
||||
if (!TextUtils.isEmpty(ipbMemberId)) {
|
||||
mIpbMemberId.setText(ipbMemberId);
|
||||
getIt = true;
|
||||
}
|
||||
if (!TextUtils.isEmpty(ipbPassHash)) {
|
||||
mIpbPassHash.setText(ipbPassHash);
|
||||
getIt = true;
|
||||
}
|
||||
if (getIt) {
|
||||
showTip(R.string.found_cookies, LENGTH_SHORT);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -476,7 +476,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
context = builder.getContext();
|
||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||
EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_favorite_info, null);
|
||||
EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_recycler_view, null);
|
||||
rv.setAdapter(new InfoAdapter(inflater));
|
||||
rv.setLayoutManager(new LinearLayoutManager(context));
|
||||
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
|
||||
|
||||
@@ -17,25 +17,36 @@
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
@@ -50,7 +61,9 @@ import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
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.scene.SceneFragment;
|
||||
import com.hippo.text.Html;
|
||||
@@ -62,29 +75,48 @@ import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.LinkifyTextView;
|
||||
import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.IntList;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.ResourcesUtils;
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener;
|
||||
import com.hippo.yorozuya.StringUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class GalleryCommentsScene extends ToolbarScene
|
||||
implements EasyRecyclerView.OnItemClickListener,
|
||||
EasyRecyclerView.OnItemLongClickListener, View.OnClickListener {
|
||||
View.OnClickListener {
|
||||
|
||||
public static final String TAG = GalleryCommentsScene.class.getSimpleName();
|
||||
|
||||
public static final String KEY_API_UID = "api_uid";
|
||||
public static final String KEY_API_KEY = "api_key";
|
||||
public static final String KEY_GID = "gid";
|
||||
public static final String KEY_TOKEN = "token";
|
||||
public static final String KEY_COMMENTS = "comments";
|
||||
|
||||
private long mApiUid;
|
||||
private String mApiKey;
|
||||
private long mGid;
|
||||
private String mToken;
|
||||
@Nullable
|
||||
private GalleryComment[] mComments;
|
||||
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private FloatingActionButton mFab;
|
||||
@Nullable
|
||||
private View mEditPanel;
|
||||
@Nullable
|
||||
private ImageView mSendImage;
|
||||
@Nullable
|
||||
private EditText mEditText;
|
||||
|
||||
@Nullable
|
||||
private CommentAdapter mAdapter;
|
||||
@Nullable
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
private boolean mInAnimation = false;
|
||||
@@ -105,7 +137,9 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
return;
|
||||
}
|
||||
|
||||
mGid = args.getLong(KEY_GID, -1);
|
||||
mApiUid = args.getLong(KEY_API_UID, -1L);
|
||||
mApiKey = args.getString(KEY_API_KEY);
|
||||
mGid = args.getLong(KEY_GID, -1L);
|
||||
mToken = args.getString(KEY_TOKEN, null);
|
||||
Parcelable[] parcelables = args.getParcelableArray(KEY_COMMENTS);
|
||||
if (parcelables instanceof GalleryComment[]) {
|
||||
@@ -118,7 +152,9 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
private void onRestore(@NonNull Bundle savedInstanceState) {
|
||||
mGid = savedInstanceState.getLong(KEY_GID, -1);
|
||||
mApiUid = savedInstanceState.getLong(KEY_API_UID, -1L);
|
||||
mApiKey = savedInstanceState.getString(KEY_API_KEY);
|
||||
mGid = savedInstanceState.getLong(KEY_GID, -1L);
|
||||
mToken = savedInstanceState.getString(KEY_TOKEN, null);
|
||||
Parcelable[] parcelables = savedInstanceState.getParcelableArray(KEY_COMMENTS);
|
||||
if (parcelables instanceof GalleryComment[]) {
|
||||
@@ -129,6 +165,8 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putLong(KEY_API_UID, mApiUid);
|
||||
outState.putString(KEY_API_KEY, mApiKey);
|
||||
outState.putLong(KEY_GID, mGid);
|
||||
outState.putString(KEY_TOKEN, mToken);
|
||||
outState.putParcelableArray(KEY_COMMENTS, mComments);
|
||||
@@ -139,7 +177,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
public View onCreateView3(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.scene_gallery_comments, container, false);
|
||||
mRecyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view);
|
||||
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
|
||||
TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
|
||||
mEditPanel = ViewUtils.$$(view, R.id.edit_panel);
|
||||
mSendImage = (ImageView) ViewUtils.$$(mEditPanel, R.id.send);
|
||||
@@ -167,20 +205,20 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
mRecyclerView.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(),
|
||||
mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom() + paddingBottomFab);
|
||||
// Cancel change animator
|
||||
RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
|
||||
if (itemAnimator instanceof DefaultItemAnimator) {
|
||||
((DefaultItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
|
||||
}
|
||||
|
||||
mSendImage.setOnClickListener(this);
|
||||
mFab.setOnClickListener(this);
|
||||
|
||||
mViewTransition = new ViewTransition(mRecyclerView, tip);
|
||||
|
||||
if (mComments == null || mComments.length <= 0) {
|
||||
mViewTransition.showView(1);
|
||||
} else {
|
||||
mViewTransition.showView(0);
|
||||
}
|
||||
updateView(false);
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -194,6 +232,10 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
mRecyclerView = null;
|
||||
}
|
||||
|
||||
mFab = null;
|
||||
mEditPanel = null;
|
||||
mSendImage = null;
|
||||
mEditText = null;
|
||||
mAdapter = null;
|
||||
mViewTransition = null;
|
||||
}
|
||||
@@ -210,6 +252,140 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
private void voteComment(long id, int vote) {
|
||||
Context context = getContext2();
|
||||
MainActivity activity = getActivity2();
|
||||
if (null == context || null == activity) {
|
||||
return;
|
||||
}
|
||||
|
||||
EhRequest request = new EhRequest()
|
||||
.setMethod(EhClient.METHOD_VOTE_COMMENT)
|
||||
.setArgs(mApiUid, mApiKey, mGid, mToken, id, vote)
|
||||
.setCallback(new VoteCommentListener(context,
|
||||
activity.getStageId(), getTag()));
|
||||
EhApplication.getEhClient(context).execute(request);
|
||||
}
|
||||
|
||||
private class InfoHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView key;
|
||||
private final TextView value;
|
||||
|
||||
public InfoHolder(View itemView) {
|
||||
super(itemView);
|
||||
key = (TextView) ViewUtils.$$(itemView, R.id.key);
|
||||
value = (TextView) ViewUtils.$$(itemView, R.id.value);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
public void showVoteStatusDialog(Context context, String voteStatus) {
|
||||
String[] temp = StringUtils.split(voteStatus, ',');
|
||||
final int length = temp.length;
|
||||
final String[] userArray = new String[length];
|
||||
final String[] voteArray = new String[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
String str = StringUtils.trim(temp[i]);
|
||||
int index = str.lastIndexOf(' ');
|
||||
if (index < 0) {
|
||||
Log.d(TAG, "Something wrong happened about vote state");
|
||||
userArray[i] = str;
|
||||
voteArray[i] = "";
|
||||
} else {
|
||||
userArray[i] = StringUtils.trim(str.substring(0, index));
|
||||
voteArray[i] = StringUtils.trim(str.substring(index + 1));
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
context = builder.getContext();
|
||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||
EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_recycler_view, null);
|
||||
rv.setAdapter(new RecyclerView.Adapter<InfoHolder>() {
|
||||
@Override
|
||||
public InfoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new InfoHolder(inflater.inflate(R.layout.item_favorite_info_data, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(InfoHolder holder, int position) {
|
||||
holder.key.setText(userArray[position]);
|
||||
holder.value.setText(voteArray[position]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return length;
|
||||
}
|
||||
});
|
||||
rv.setLayoutManager(new LinearLayoutManager(context));
|
||||
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
|
||||
LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider),
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
|
||||
rv.addItemDecoration(decoration);
|
||||
rv.setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
rv.setClipToPadding(false);
|
||||
builder.setView(rv).show();
|
||||
}
|
||||
|
||||
private void showCommentDialog(int position) {
|
||||
final Context context = getContext2();
|
||||
if (null == context || null == mComments || position >= mComments.length || position < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final GalleryComment comment = mComments[position];
|
||||
List<String> menu = new ArrayList<>();
|
||||
final IntList menuId = new IntList();
|
||||
Resources resources = context.getResources();
|
||||
if (0 == comment.id || mApiUid < 0) {
|
||||
// 0 id is uploader comment, can't vote
|
||||
// Not sign in, can't vote
|
||||
menu.add(resources.getString(R.string.copy_comment_text));
|
||||
menuId.add(R.id.copy);
|
||||
} else {
|
||||
menu.add(resources.getString(R.string.copy_comment_text));
|
||||
menuId.add(R.id.copy);
|
||||
menu.add(resources.getString(comment.voteUp ? R.string.cancel_vote_up : R.string.vote_up));
|
||||
menuId.add(R.id.vote_up);
|
||||
menu.add(resources.getString(comment.voteDown ? R.string.cancel_vote_down : R.string.vote_down));
|
||||
menuId.add(R.id.vote_down);
|
||||
}
|
||||
if (!TextUtils.isEmpty(comment.voteState)) {
|
||||
menu.add(resources.getString(R.string.check_vote_status));
|
||||
menuId.add(R.id.check_vote_status);
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setItems(menu.toArray(new String[menu.size()]), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which < 0 || which >= menuId.size()) {
|
||||
return;
|
||||
}
|
||||
int id = menuId.get(which);
|
||||
switch (id) {
|
||||
case R.id.copy:
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setPrimaryClip(ClipData.newPlainText(null, comment.comment));
|
||||
showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
|
||||
break;
|
||||
case R.id.vote_up:
|
||||
voteComment(comment.id, 1);
|
||||
break;
|
||||
case R.id.vote_down:
|
||||
voteComment(comment.id, -1);
|
||||
break;
|
||||
case R.id.check_vote_status:
|
||||
showVoteStatusDialog(context, comment.voteState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
Activity activity = getActivity2();
|
||||
@@ -228,16 +404,29 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
showCommentDialog(position);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
return false;
|
||||
private void updateView(boolean animation) {
|
||||
if (null == mViewTransition) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mComments == null || mComments.length <= 0) {
|
||||
mViewTransition.showView(1, animation);
|
||||
} else {
|
||||
mViewTransition.showView(0, animation);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void showEditPanelWithAnimationL() {
|
||||
private void showEditPanelWithAnimation() {
|
||||
if (null == mFab || null == mEditPanel) {
|
||||
return;
|
||||
}
|
||||
|
||||
mInAnimation = true;
|
||||
mFab.setTranslationX(0.0f);
|
||||
mFab.setTranslationY(0.0f);
|
||||
@@ -255,10 +444,10 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
int halfW = mEditPanel.getWidth() / 2;
|
||||
int halfH = mEditPanel.getHeight() / 2;
|
||||
Animator animator = ViewAnimationUtils.createCircularReveal(mEditPanel, halfW, halfH, 0,
|
||||
(float) Math.hypot(halfW, halfH)).setDuration(300);
|
||||
(float) Math.hypot(halfW, halfH)).setDuration(300L);
|
||||
animator.addListener(new SimpleAnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(Animator a) {
|
||||
mInAnimation = false;
|
||||
}
|
||||
});
|
||||
@@ -269,21 +458,22 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
private void showEditPanel(boolean animation) {
|
||||
if (animation) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
showEditPanelWithAnimationL();
|
||||
} else {
|
||||
// TODO Add animation for pre-L
|
||||
mFab.setVisibility(View.INVISIBLE);
|
||||
mEditPanel.setVisibility(View.VISIBLE);
|
||||
}
|
||||
showEditPanelWithAnimation();
|
||||
} else {
|
||||
if (null == mFab || null == mEditPanel) {
|
||||
return;
|
||||
}
|
||||
|
||||
mFab.setVisibility(View.INVISIBLE);
|
||||
mEditPanel.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void hideEditPanelWithAnimationL() {
|
||||
private void hideEditPanelWithAnimation() {
|
||||
if (null == mFab || null == mEditPanel) {
|
||||
return;
|
||||
}
|
||||
|
||||
mInAnimation = true;
|
||||
int halfW = mEditPanel.getWidth() / 2;
|
||||
int halfH = mEditPanel.getHeight() / 2;
|
||||
@@ -291,7 +481,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
(float) Math.hypot(halfW, halfH), 0.0f).setDuration(300L);
|
||||
animator.addListener(new SimpleAnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(Animator a) {
|
||||
mEditPanel.setVisibility(View.GONE);
|
||||
mFab.setVisibility(View.VISIBLE);
|
||||
int fabStartX = mEditPanel.getLeft() + (mEditPanel.getWidth() / 2) - (mFab.getWidth() / 2);
|
||||
@@ -315,14 +505,12 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
private void hideEditPanel(boolean animation) {
|
||||
if (animation) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
hideEditPanelWithAnimationL();
|
||||
} else {
|
||||
// TODO Add animation for pre-L
|
||||
mFab.setVisibility(View.VISIBLE);
|
||||
mEditPanel.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
hideEditPanelWithAnimation();
|
||||
} else {
|
||||
if (null == mFab || null == mEditPanel) {
|
||||
return;
|
||||
}
|
||||
|
||||
mFab.setVisibility(View.VISIBLE);
|
||||
mEditPanel.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
@@ -331,7 +519,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
@Nullable
|
||||
private String getGalleryDetailUrl() {
|
||||
if (mGid != -1 && mToken != null) {
|
||||
return EhUrl.getGalleryDetailUrl(mGid, mToken, 0, true);
|
||||
return EhUrl.getGalleryDetailUrl(mGid, mToken, 0, false);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -341,7 +529,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
public void onClick(View v) {
|
||||
Context context = getContext2();
|
||||
MainActivity activity = getActivity2();
|
||||
if (null == context || null == activity) {
|
||||
if (null == context || null == activity || null == mEditText) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -378,7 +566,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
if (mInAnimation) {
|
||||
return;
|
||||
}
|
||||
if (mEditPanel.getVisibility() == View.VISIBLE) {
|
||||
if (null != mEditPanel && mEditPanel.getVisibility() == View.VISIBLE) {
|
||||
hideEditPanel(true);
|
||||
} else {
|
||||
finish();
|
||||
@@ -387,9 +575,9 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
private class CommentHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TextView user;
|
||||
public TextView time;
|
||||
public LinkifyTextView comment;
|
||||
public final TextView user;
|
||||
public final TextView time;
|
||||
public final LinkifyTextView comment;
|
||||
|
||||
public CommentHolder(View itemView) {
|
||||
super(itemView);
|
||||
@@ -413,18 +601,35 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
return new CommentHolder(mInflater.inflate(R.layout.item_gallery_comment, parent, false));
|
||||
}
|
||||
|
||||
public CharSequence generateComment(Context context, TextView textView, GalleryComment comment) {
|
||||
SpannableStringBuilder ssb = Html.fromHtml(comment.comment, new URLImageGetter(textView,
|
||||
EhApplication.getConaco(context)), null);
|
||||
|
||||
if (0 != comment.id && 0 != comment.score) {
|
||||
int score = comment.score;
|
||||
String scoreString = score > 0 ? "+" + score : Integer.toString(score);
|
||||
SpannableString ss = new SpannableString(scoreString);
|
||||
ss.setSpan(new RelativeSizeSpan(0.8f), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.secondary_text_default_light))
|
||||
, 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ssb.append(" ").append(ss);
|
||||
}
|
||||
|
||||
return TextUrl.handleTextUrl(ssb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(CommentHolder holder, int position) {
|
||||
Context context = getContext2();
|
||||
if (null == context) {
|
||||
if (null == context || null == mComments) {
|
||||
return;
|
||||
}
|
||||
|
||||
GalleryComment comment = mComments[position];
|
||||
holder.user.setText(comment.user);
|
||||
holder.time.setText(ReadableTime.getTimeAgo(comment.time));
|
||||
holder.comment.setText(TextUrl.handleTextUrl(Html.fromHtml(comment.comment,
|
||||
new URLImageGetter(holder.comment, EhApplication.getConaco(context)), null)));
|
||||
holder.comment.setText(generateComment(context, holder.comment, comment));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -434,6 +639,10 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
private void onCommentGallerySuccess(GalleryComment[] result) {
|
||||
if (null == mAdapter) {
|
||||
return;
|
||||
}
|
||||
|
||||
mComments = result;
|
||||
mAdapter.notifyDataSetChanged();
|
||||
Bundle re = new Bundle();
|
||||
@@ -444,6 +653,45 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
if (mEditText != null) {
|
||||
mEditText.setText("");
|
||||
}
|
||||
|
||||
updateView(true);
|
||||
}
|
||||
|
||||
private void onVoteCommentSuccess(VoteCommentParser.Result result) {
|
||||
if (null == mAdapter || null == mComments) {
|
||||
return;
|
||||
}
|
||||
|
||||
int position = -1;
|
||||
for (int i = 0, n = mComments.length; i < n; i++) {
|
||||
GalleryComment comment = mComments[i];
|
||||
if (comment.id == result.id) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (-1 == position) {
|
||||
Log.d(TAG, "Can't find comment with id " + result.id);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update comment
|
||||
GalleryComment comment = mComments[position];
|
||||
comment.score = result.score;
|
||||
if (result.expectVote > 0) {
|
||||
comment.voteUp = 0 != result.vote;
|
||||
comment.voteDown = false;
|
||||
} else {
|
||||
comment.voteDown = 0 != result.vote;
|
||||
comment.voteUp = false;
|
||||
}
|
||||
|
||||
mAdapter.notifyItemChanged(position);
|
||||
|
||||
Bundle re = new Bundle();
|
||||
re.putParcelableArray(KEY_COMMENTS, mComments);
|
||||
setResult(SceneFragment.RESULT_OK, re);
|
||||
}
|
||||
|
||||
private static class CommentGalleryListener extends EhCallback<GalleryCommentsScene, GalleryComment[]> {
|
||||
@@ -476,4 +724,37 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
return scene instanceof GalleryCommentsScene;
|
||||
}
|
||||
}
|
||||
|
||||
private static class VoteCommentListener extends EhCallback<GalleryCommentsScene, VoteCommentParser.Result> {
|
||||
|
||||
public VoteCommentListener(Context context, int stageId, String sceneTag) {
|
||||
super(context, stageId, sceneTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(VoteCommentParser.Result result) {
|
||||
showTip(result.expectVote > 0 ?
|
||||
(0 != result.vote ? R.string.vote_up_successfully : R.string.cancel_vote_up_successfully) :
|
||||
(0 != result.vote ? R.string.vote_down_successfully : R.string.cancel_vote_down_successfully),
|
||||
LENGTH_SHORT);
|
||||
|
||||
GalleryCommentsScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onVoteCommentSuccess(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
showTip(R.string.vote_failed, LENGTH_SHORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(SceneFragment scene) {
|
||||
return scene instanceof GalleryCommentsScene;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.text.TextUtils;
|
||||
@@ -45,7 +46,6 @@ import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
@@ -55,7 +55,9 @@ import android.widget.ListView;
|
||||
import android.widget.RatingBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.beerbelly.BeerBelly;
|
||||
import com.hippo.drawable.RoundSideRectDrawable;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -79,6 +81,7 @@ import com.hippo.ehviewer.ui.CommonOperations;
|
||||
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.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
@@ -97,9 +100,14 @@ import com.hippo.widget.ProgressView;
|
||||
import com.hippo.widget.ProgressiveRatingBar;
|
||||
import com.hippo.widget.SimpleGridAutoSpanLayout;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.List;
|
||||
@@ -197,6 +205,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private TextView mRate;
|
||||
@Nullable
|
||||
private TextView mSimilar;
|
||||
@Nullable
|
||||
private TextView mSearchCover;
|
||||
// Tags
|
||||
@Nullable
|
||||
private LinearLayout mTags;
|
||||
@@ -455,16 +465,19 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mShare = (TextView) ViewUtils.$$(mActions, R.id.share);
|
||||
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);
|
||||
mHeartGroup.setOnClickListener(this);
|
||||
mTorrent.setOnClickListener(this);
|
||||
mShare.setOnClickListener(this);
|
||||
mRate.setOnClickListener(this);
|
||||
mSimilar.setOnClickListener(this);
|
||||
mSearchCover.setOnClickListener(this);
|
||||
ensureActionDrawable(context);
|
||||
|
||||
mTags = (LinearLayout) ViewUtils.$$(belowHeader, R.id.tags);
|
||||
@@ -552,6 +565,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mShare = null;
|
||||
mRate = null;
|
||||
mSimilar = null;
|
||||
mSearchCover = null;
|
||||
|
||||
mTags = null;
|
||||
mNoTags = null;
|
||||
@@ -602,7 +616,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private boolean request() {
|
||||
Context context = getContext2();
|
||||
MainActivity activity = getActivity2();
|
||||
String url = getGalleryDetailUrl(true);
|
||||
String url = getGalleryDetailUrl(false);
|
||||
if (null == context || null == activity || null == url) {
|
||||
return false;
|
||||
}
|
||||
@@ -637,9 +651,10 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
setActionDrawable(mRate, rate);
|
||||
Drawable similar = DrawableManager.getDrawable(context, R.drawable.v_similar_primary_x48);
|
||||
setActionDrawable(mSimilar, similar);
|
||||
Drawable searchCover = DrawableManager.getDrawable(context, R.drawable.v_file_find_primary_x48);
|
||||
setActionDrawable(mSearchCover, searchCover);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private boolean createCircularReveal() {
|
||||
if (mColorBg == null) {
|
||||
return false;
|
||||
@@ -647,7 +662,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
int w = mColorBg.getWidth();
|
||||
int h = mColorBg.getHeight();
|
||||
if (mColorBg.isAttachedToWindow() && w != 0 && h != 0) {
|
||||
if (ViewCompat.isAttachedToWindow(mColorBg) && w != 0 && h != 0) {
|
||||
ViewAnimationUtils.createCircularReveal(mColorBg, w / 2, h / 2, 0,
|
||||
(float) Math.hypot(w / 2, h / 2)).setDuration(300).start();
|
||||
return true;
|
||||
@@ -692,8 +707,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
break;
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP &&
|
||||
(oldState == STATE_INIT || oldState == STATE_FAILED || oldState == STATE_REFRESH) &&
|
||||
if ((oldState == STATE_INIT || oldState == STATE_FAILED || oldState == STATE_REFRESH) &&
|
||||
(state == STATE_NORMAL || state == STATE_REFRESH_HEADER)) {
|
||||
if (!createCircularReveal()) {
|
||||
SimpleHandler.getInstance().post(new Runnable() {
|
||||
@@ -1030,6 +1044,39 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
private void showCoverGalleryList() {
|
||||
Context context = getContext2();
|
||||
if (null == context) {
|
||||
return;
|
||||
}
|
||||
long gid = getGid();
|
||||
if (-1L == gid) {
|
||||
return;
|
||||
}
|
||||
File temp = AppConfig.createTempFile();
|
||||
if (null == temp) {
|
||||
return;
|
||||
}
|
||||
BeerBelly beerBelly = EhApplication.getConaco(context).getBeerBelly();
|
||||
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(temp);
|
||||
if (beerBelly.pullFromDiskCache(EhCacheKeyFactory.getThumbKey(gid), os)) {
|
||||
ListUrlBuilder lub = new ListUrlBuilder();
|
||||
lub.setMode(ListUrlBuilder.MODE_IMAGE_SEARCH);
|
||||
lub.setImagePath(temp.getPath());
|
||||
lub.setUseSimilarityScan(true);
|
||||
lub.setShowExpunged(true);
|
||||
GalleryListScene.startScene(this, lub);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
// Ignore
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Context context = getContext2();
|
||||
@@ -1128,6 +1175,10 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
if (mGalleryDetail == null) {
|
||||
return;
|
||||
}
|
||||
if (mGalleryDetail.apiUid < 0) {
|
||||
showTip(R.string.sign_in_first, LENGTH_SHORT);
|
||||
return;
|
||||
}
|
||||
RateDialogHelper helper = new RateDialogHelper();
|
||||
Dialog dialog = new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.rate)
|
||||
@@ -1138,11 +1189,15 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
helper.setDialog(dialog, mGalleryDetail.rating);
|
||||
} else if (mSimilar == v) {
|
||||
showSimilarGalleryList();
|
||||
} else if (mSearchCover == v) {
|
||||
showCoverGalleryList();
|
||||
} else if (mComments == v) {
|
||||
if (mGalleryDetail == null) {
|
||||
return;
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putLong(GalleryCommentsScene.KEY_API_UID, mGalleryDetail.apiUid);
|
||||
args.putString(GalleryCommentsScene.KEY_API_KEY, mGalleryDetail.apiKey);
|
||||
args.putLong(GalleryCommentsScene.KEY_GID, mGalleryDetail.gid);
|
||||
args.putString(GalleryCommentsScene.KEY_TOKEN, mGalleryDetail.token);
|
||||
args.putParcelableArray(GalleryCommentsScene.KEY_COMMENTS, mGalleryDetail.comments);
|
||||
@@ -1690,7 +1745,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
EhRequest request = new EhRequest()
|
||||
.setMethod(EhClient.METHOD_GET_RATE_GALLERY)
|
||||
.setArgs(mGalleryDetail.gid, mGalleryDetail.token, mRatingBar.getRating())
|
||||
.setArgs(mGalleryDetail.apiUid, mGalleryDetail.apiKey,
|
||||
mGalleryDetail.gid, mGalleryDetail.token, mRatingBar.getRating())
|
||||
.setCallback(new RateGalleryListener(context,
|
||||
activity.getStageId(), getTag(), mGalleryDetail.gid));
|
||||
EhApplication.getEhClient(context).execute(request);
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.animation.Animator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -68,6 +69,7 @@ import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.ehviewer.client.parser.GalleryListParser;
|
||||
import com.hippo.ehviewer.dao.QuickSearch;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
@@ -88,8 +90,10 @@ import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener;
|
||||
import com.hippo.yorozuya.StringUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.List;
|
||||
@@ -106,6 +110,8 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
private static final int BACK_PRESSED_INTERVAL = 2000;
|
||||
|
||||
public final static int REQUEST_CODE_SELECT_IMAGE = 0;
|
||||
|
||||
public final static String KEY_ACTION = "action";
|
||||
public final static String ACTION_HOMEPAGE = "action_homepage";
|
||||
public final static String ACTION_WHATS_HOT = "action_whats_hot";
|
||||
@@ -557,6 +563,12 @@ public final class GalleryListScene extends BaseScene
|
||||
return;
|
||||
}
|
||||
|
||||
// Can't add image search as quick search
|
||||
if (ListUrlBuilder.MODE_IMAGE_SEARCH == urlBuilder.getMode()) {
|
||||
showTip(R.string.image_search_not_quick_search, LENGTH_SHORT);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check duplicate
|
||||
for (QuickSearch q: list) {
|
||||
if (urlBuilder.equalsQuickSearch(q)) {
|
||||
@@ -915,7 +927,7 @@ public final class GalleryListScene extends BaseScene
|
||||
fab.setScaleY(0.0f);
|
||||
mSearchFab.setVisibility(View.VISIBLE);
|
||||
mSearchFab.setScaleX(1.0f);
|
||||
mSearchFab.setScaleX(1.0f);
|
||||
mSearchFab.setScaleY(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -950,7 +962,7 @@ public final class GalleryListScene extends BaseScene
|
||||
fab.setScaleY(1.0f);
|
||||
mSearchFab.setVisibility(View.INVISIBLE);
|
||||
mSearchFab.setScaleX(0.0f);
|
||||
mSearchFab.setScaleX(0.0f);
|
||||
mSearchFab.setScaleY(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,7 +1123,12 @@ public final class GalleryListScene extends BaseScene
|
||||
startScene(new Announcer(GalleryDetailScene.class).setArgs(args));
|
||||
return;
|
||||
} else {
|
||||
mSearchLayout.formatListUrlBuilder(mUrlBuilder, query);
|
||||
try {
|
||||
mSearchLayout.formatListUrlBuilder(mUrlBuilder, query);
|
||||
} catch (EhException e) {
|
||||
showTip(e.getMessage(), LENGTH_LONG);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mUrlBuilder.reset();
|
||||
@@ -1177,6 +1194,15 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelectImage() {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent,
|
||||
getString(R.string.select_image)), REQUEST_CODE_SELECT_IMAGE);
|
||||
}
|
||||
|
||||
// SearchBarMover.Helper
|
||||
@Override
|
||||
public boolean isValidView(RecyclerView recyclerView) {
|
||||
@@ -1207,6 +1233,17 @@ public final class GalleryListScene extends BaseScene
|
||||
scene.startScene(new Announcer(GalleryListScene.class).setArgs(args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (REQUEST_CODE_SELECT_IMAGE == requestCode) {
|
||||
if (Activity.RESULT_OK == resultCode && null != mSearchLayout && null != data) {
|
||||
mSearchLayout.setImageUri(data.getData());
|
||||
}
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private class GalleryListAdapter extends GalleryAdapter {
|
||||
|
||||
public GalleryListAdapter(@NonNull LayoutInflater inflater,
|
||||
@@ -1243,6 +1280,15 @@ public final class GalleryListScene extends BaseScene
|
||||
activity.getStageId(), getTag(), taskId));
|
||||
request.setArgs();
|
||||
mClient.execute(request);
|
||||
} else if (ListUrlBuilder.MODE_IMAGE_SEARCH == mUrlBuilder.getMode()) {
|
||||
EhRequest request = new EhRequest();
|
||||
request.setMethod(EhClient.METHOD_IMAGE_SEARCH);
|
||||
request.setCallback(new GetGalleryListListener(getContext(),
|
||||
activity.getStageId(), getTag(), taskId));
|
||||
request.setArgs(new File(StringUtils.avoidNull(mUrlBuilder.getImagePath())),
|
||||
mUrlBuilder.isUseSimilarityScan(),
|
||||
mUrlBuilder.isOnlySearchCovers(), mUrlBuilder.isShowExpunged());
|
||||
mClient.execute(request);
|
||||
} else {
|
||||
String url = mUrlBuilder.build();
|
||||
EhRequest request = new EhRequest();
|
||||
|
||||
@@ -144,7 +144,7 @@ public final class SignInScene extends BaseScene implements EditText.OnEditorAct
|
||||
mSkipSigningIn.setOnClickListener(this);
|
||||
|
||||
Context context = getContext2();
|
||||
AssertUtils.assertNotNull(container);
|
||||
AssertUtils.assertNotNull(context);
|
||||
EhApplication application = (EhApplication) context.getApplicationContext();
|
||||
if (application.containGlobalStuff(mRequestId)) {
|
||||
mSigningIn = true;
|
||||
|
||||
@@ -18,12 +18,14 @@ package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
@@ -63,7 +65,21 @@ public class WebViewSignInScene extends BaseScene {
|
||||
AssertUtils.assertNotNull(context);
|
||||
|
||||
EhUtils.signOut(context);
|
||||
CookieManager.getInstance().removeAllCookie();
|
||||
|
||||
// http://stackoverflow.com/questions/32284642/how-to-handle-an-uncatched-exception
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
cookieManager.flush();
|
||||
cookieManager.removeAllCookies(null);
|
||||
cookieManager.removeSessionCookies(null);
|
||||
} else {
|
||||
CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(context);
|
||||
cookieSyncManager.startSync();
|
||||
cookieManager.removeAllCookie();
|
||||
cookieManager.removeSessionCookie();
|
||||
cookieSyncManager.stopSync();
|
||||
}
|
||||
|
||||
mWebView = new WebView(context);
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.setWebViewClient(new LoginWebViewClient());
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.widget.DrawerView;
|
||||
import com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayoutChild;
|
||||
|
||||
public class EhDrawerView extends DrawerView implements SlidingDrawerLayoutChild {
|
||||
|
||||
private int mFitPaddingTop;
|
||||
|
||||
public EhDrawerView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public EhDrawerView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public EhDrawerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFitPadding(int top, int bottom) {
|
||||
mFitPaddingTop = top;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutPaddingTop() {
|
||||
return mFitPaddingTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutPaddingBottom() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.scene.StageLayout;
|
||||
import com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayoutChild;
|
||||
|
||||
public class EhStageLayout extends StageLayout implements SlidingDrawerLayoutChild {
|
||||
|
||||
private int mFitPaddingTop;
|
||||
|
||||
public EhStageLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public EhStageLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public EhStageLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFitPadding(int top, int bottom) {
|
||||
mFitPaddingTop = top;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutPaddingTop() {
|
||||
return mFitPaddingTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutPaddingBottom() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.AbsSavedState;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.io.UniFileInputStreamPipe;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.BitmapUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public final class ImageSearchLayout extends LinearLayout implements View.OnClickListener {
|
||||
|
||||
private static final String TAG = ImageSearchLayout.class.getSimpleName();
|
||||
|
||||
private ImageView mPreview;
|
||||
private View mSelectImage;
|
||||
private CheckBox mSearchUSS;
|
||||
private CheckBox mSearchOSC;
|
||||
private CheckBox mSearchSE;
|
||||
|
||||
private Helper mHelper;
|
||||
|
||||
@Nullable
|
||||
private String mImagePath;
|
||||
|
||||
public ImageSearchLayout(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public ImageSearchLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public ImageSearchLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void init(Context context) {
|
||||
setOrientation(VERTICAL);
|
||||
setDividerDrawable(context.getResources().getDrawable(R.drawable.spacer_keyline));
|
||||
setShowDividers(SHOW_DIVIDER_MIDDLE);
|
||||
LayoutInflater.from(context).inflate(R.layout.widget_image_search, this);
|
||||
|
||||
mPreview = (ImageView) ViewUtils.$$(this, R.id.preview);
|
||||
mSelectImage = ViewUtils.$$(this, R.id.select_image);
|
||||
mSearchUSS = (CheckBox) ViewUtils.$$(this, R.id.search_uss);
|
||||
mSearchOSC = (CheckBox) ViewUtils.$$(this, R.id.search_osc);
|
||||
mSearchSE = (CheckBox) ViewUtils.$$(this, R.id.search_se);
|
||||
|
||||
mSelectImage.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void setHelper(Helper helper) {
|
||||
mHelper = helper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == mSelectImage) {
|
||||
if (null != mHelper) {
|
||||
mHelper.onSelectImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setImageUri(@Nullable Uri imageUri) {
|
||||
if (null == imageUri) {
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = getContext();
|
||||
UniFile file = UniFile.fromUri(context, imageUri);
|
||||
if (null == file) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
int maxSize = context.getResources().getDimensionPixelOffset(R.dimen.image_search_max_size);
|
||||
Bitmap bitmap = BitmapUtils.decodeStream(new UniFileInputStreamPipe(file), maxSize, maxSize);
|
||||
if (null == bitmap) {
|
||||
return;
|
||||
}
|
||||
File temp = AppConfig.createTempFile();
|
||||
if (null == temp) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO ehentai image search is bad when I'm writing this line.
|
||||
// Re-compress image will make image search failed.
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(temp);
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
|
||||
mImagePath = temp.getPath();
|
||||
mPreview.setImageBitmap(bitmap);
|
||||
mPreview.setVisibility(VISIBLE);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
Log.e(TAG, "Out of memory");
|
||||
}
|
||||
}
|
||||
|
||||
private void setImagePath(@Nullable String imagePath) {
|
||||
if (null == imagePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream(imagePath);
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
if (null == bitmap) {
|
||||
return;
|
||||
}
|
||||
mImagePath = imagePath;
|
||||
mPreview.setImageBitmap(bitmap);
|
||||
mPreview.setVisibility(VISIBLE);
|
||||
} catch (FileNotFoundException e) {
|
||||
// Ignore
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
|
||||
public void formatListUrlBuilder(ListUrlBuilder builder) throws EhException {
|
||||
if (null == mImagePath) {
|
||||
throw new EhException(getContext().getString(R.string.select_image_first));
|
||||
}
|
||||
|
||||
builder.setImagePath(mImagePath);
|
||||
builder.setUseSimilarityScan(mSearchUSS.isChecked());
|
||||
builder.setOnlySearchCovers(mSearchOSC.isChecked());
|
||||
builder.setShowExpunged(mSearchSE.isChecked());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
Parcelable superState = super.onSaveInstanceState();
|
||||
SavedState ss = new SavedState(superState);
|
||||
ss.imagePath = mImagePath;
|
||||
return ss;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
SavedState ss = (SavedState) state;
|
||||
super.onRestoreInstanceState(ss.getSuperState());
|
||||
setImagePath(ss.imagePath);
|
||||
}
|
||||
|
||||
private static class SavedState extends AbsSavedState {
|
||||
|
||||
String imagePath;
|
||||
|
||||
/**
|
||||
* Constructor called from {@link ImageSearchLayout#onSaveInstanceState()}
|
||||
*/
|
||||
protected SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor called from {@link #CREATOR}
|
||||
*/
|
||||
protected SavedState(Parcel source) {
|
||||
super(source);
|
||||
imagePath = source.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
super.writeToParcel(out, flags);
|
||||
out.writeString(imagePath);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<SavedState> CREATOR
|
||||
= new Parcelable.Creator<SavedState>() {
|
||||
@Override
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedState[] newArray(int size) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface Helper {
|
||||
void onSelectImage();
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.IntDef;
|
||||
@@ -39,6 +41,7 @@ import android.widget.TextView;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
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.widget.RadioGridGroup;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
@@ -47,9 +50,9 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnCheckedChangeListener,
|
||||
View.OnClickListener {
|
||||
View.OnClickListener, ImageSearchLayout.Helper {
|
||||
|
||||
@IntDef({SEARCH_MODE_NORMAL, SEARCH_MODE_IMAGE, SEARCH_MODE_SPECIFY})
|
||||
@IntDef({SEARCH_MODE_NORMAL, SEARCH_MODE_IMAGE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
private @interface SearchMode {}
|
||||
|
||||
@@ -59,22 +62,19 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
|
||||
public static final int SEARCH_MODE_NORMAL = 0;
|
||||
public static final int SEARCH_MODE_IMAGE = 1;
|
||||
public static final int SEARCH_MODE_SPECIFY = 2;
|
||||
|
||||
private static final int ITEM_TYPE_NORMAL = 0;
|
||||
private static final int ITEM_TYPE_NORMAL_ADVANCE = 1;
|
||||
private static final int ITEM_TYPE_IMAGE = 2;
|
||||
private static final int ITEM_TYPE_SPECIFY = 3;
|
||||
private static final int ITEM_TYPE_ACTION = 4;
|
||||
private static final int ITEM_TYPE_ACTION = 3;
|
||||
|
||||
private static final int[] SEARCH_ITEM_COUNT_ARRAY = {
|
||||
3, 2, 2
|
||||
3, 2
|
||||
};
|
||||
|
||||
private static final int[][] SEARCH_ITEM_TYPE = {
|
||||
{ITEM_TYPE_NORMAL, ITEM_TYPE_NORMAL_ADVANCE, ITEM_TYPE_ACTION}, // SEARCH_MODE_NORMAL
|
||||
{ITEM_TYPE_IMAGE, ITEM_TYPE_ACTION}, // SEARCH_MODE_IMAGE
|
||||
{ITEM_TYPE_SPECIFY, ITEM_TYPE_ACTION} // SEARCH_MODE_SPECIFY
|
||||
};
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
@@ -86,13 +86,15 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
private CategoryTable mCategoryTable;
|
||||
private RadioGridGroup mNormalSearchMode;
|
||||
private ImageView mNormalSearchModeHelp;
|
||||
private View mSearchTagHelp;
|
||||
private SwitchCompat mEnableAdvanceSwitch;
|
||||
|
||||
private View mAdvanceView;
|
||||
private AdvanceSearchTable mTableAdvanceSearch;
|
||||
|
||||
private ImageSearchLayout mImageView;
|
||||
|
||||
private View mActionView;
|
||||
private TextView mAction;
|
||||
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private SearchAdapter mAdapter;
|
||||
@@ -109,26 +111,23 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
init(context);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
private void init(Context context) {
|
||||
Resources resources = context.getResources();
|
||||
mInflater = LayoutInflater.from(context);
|
||||
|
||||
mLayoutManager = new LinearLayoutManager(context);
|
||||
mAdapter = new SearchAdapter();
|
||||
//mAnimator = new SearchItemAnimator(this);
|
||||
setLayoutManager(mLayoutManager);
|
||||
setAdapter(mAdapter);
|
||||
setHasFixedSize(true);
|
||||
setClipToPadding(false);
|
||||
//setItemAnimator(mAnimator);
|
||||
int paddingH = resources.getDimensionPixelOffset(R.dimen.list_content_margin_h);
|
||||
int paddingV = resources.getDimensionPixelOffset(R.dimen.list_content_margin_v);
|
||||
setPadding(paddingV, paddingH, paddingV, paddingH);
|
||||
|
||||
FrameLayout frameLayout = new FrameLayout(context);
|
||||
|
||||
// Create normal view
|
||||
View normalView = mInflater.inflate(R.layout.search_normal, frameLayout, false);
|
||||
View normalView = mInflater.inflate(R.layout.search_normal, null);
|
||||
mNormalView = normalView;
|
||||
mCategoryTable = (CategoryTable) normalView.findViewById(R.id.search_category_table);
|
||||
mNormalSearchMode = (RadioGridGroup) normalView.findViewById(R.id.normal_search_mode);
|
||||
@@ -140,11 +139,17 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
mEnableAdvanceSwitch.setSwitchPadding(resources.getDimensionPixelSize(R.dimen.switch_padding));
|
||||
|
||||
// Create advance view
|
||||
mAdvanceView = mInflater.inflate(R.layout.search_advance, frameLayout, false);
|
||||
mAdvanceView = mInflater.inflate(R.layout.search_advance, null);
|
||||
mTableAdvanceSearch = (AdvanceSearchTable) mAdvanceView.findViewById(R.id.search_advance_search_table);
|
||||
|
||||
// Create image view
|
||||
mImageView = (ImageSearchLayout) mInflater.inflate(R.layout.search_image, null);
|
||||
mImageView.setHelper(this);
|
||||
|
||||
// Create action view
|
||||
mActionView = new View(context);// TODO mInflater.inflate(R.layout.search_action, frameLayout, false);
|
||||
mActionView = mInflater.inflate(R.layout.search_action, null);
|
||||
mAction = (TextView) mActionView.findViewById(R.id.action);
|
||||
mAction.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void setHelper(Helper helper) {
|
||||
@@ -155,12 +160,24 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
mLayoutManager.scrollToPositionWithOffset(0, 0);
|
||||
}
|
||||
|
||||
public void setImageUri(Uri imageUri) {
|
||||
mImageView.setImageUri(imageUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelectImage() {
|
||||
if (mHelper != null) {
|
||||
mHelper.onSelectImage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchSaveInstanceState(@NonNull SparseArray<Parcelable> container) {
|
||||
super.dispatchSaveInstanceState(container);
|
||||
|
||||
mNormalView.saveHierarchyState(container);
|
||||
mAdvanceView.saveHierarchyState(container);
|
||||
mImageView.saveHierarchyState(container);
|
||||
mActionView.saveHierarchyState(container);
|
||||
}
|
||||
|
||||
@@ -170,6 +187,7 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
|
||||
mNormalView.restoreHierarchyState(container);
|
||||
mAdvanceView.restoreHierarchyState(container);
|
||||
mImageView.restoreHierarchyState(container);
|
||||
mActionView.restoreHierarchyState(container);
|
||||
}
|
||||
|
||||
@@ -214,29 +232,35 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
return R.id.search_specify_gallery == mNormalSearchMode.getCheckedRadioButtonId();
|
||||
}
|
||||
|
||||
// TODO image search
|
||||
public void formatListUrlBuilder(ListUrlBuilder urlBuilder, String query) {
|
||||
public void formatListUrlBuilder(ListUrlBuilder urlBuilder, String query) throws EhException {
|
||||
urlBuilder.reset();
|
||||
|
||||
int nsMode = mNormalSearchMode.getCheckedRadioButtonId();
|
||||
switch (nsMode) {
|
||||
default:
|
||||
case R.id.search_normal_search:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_NORMAL);
|
||||
switch (mSearchMode) {
|
||||
case SEARCH_MODE_NORMAL:
|
||||
int nsMode = mNormalSearchMode.getCheckedRadioButtonId();
|
||||
switch (nsMode) {
|
||||
default:
|
||||
case R.id.search_normal_search:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_NORMAL);
|
||||
break;
|
||||
case R.id.search_specify_uploader:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_UPLOADER);
|
||||
break;
|
||||
case R.id.search_specify_tag:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_TAG);
|
||||
break;
|
||||
}
|
||||
urlBuilder.setKeyword(query);
|
||||
urlBuilder.setCategory(mCategoryTable.getCategory());
|
||||
if (mEnableAdvance) {
|
||||
urlBuilder.setAdvanceSearch(mTableAdvanceSearch.getAdvanceSearch());
|
||||
urlBuilder.setMinRating(mTableAdvanceSearch.getMinRating());
|
||||
}
|
||||
break;
|
||||
case R.id.search_specify_uploader:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_UPLOADER);
|
||||
case SEARCH_MODE_IMAGE:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_IMAGE_SEARCH);
|
||||
mImageView.formatListUrlBuilder(urlBuilder);
|
||||
break;
|
||||
case R.id.search_specify_tag:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_TAG);
|
||||
break;
|
||||
}
|
||||
|
||||
urlBuilder.setKeyword(query);
|
||||
urlBuilder.setCategory(mCategoryTable.getCategory());
|
||||
if (mEnableAdvance) {
|
||||
urlBuilder.setAdvanceSearch(mTableAdvanceSearch.getAdvanceSearch());
|
||||
urlBuilder.setMinRating(mTableAdvanceSearch.getMinRating());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +287,7 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
int oldItemCount = mAdapter.getItemCount();
|
||||
|
||||
mSearchMode++;
|
||||
if (mSearchMode > SEARCH_MODE_SPECIFY) {
|
||||
if (mSearchMode > SEARCH_MODE_IMAGE) {
|
||||
mSearchMode = SEARCH_MODE_NORMAL;
|
||||
}
|
||||
|
||||
@@ -272,6 +296,19 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
mAdapter.notifyItemRangeRemoved(0, oldItemCount - 1);
|
||||
mAdapter.notifyItemRangeInserted(0, newItemCount - 1);
|
||||
|
||||
// Update action text
|
||||
int resId;
|
||||
switch (mSearchMode) {
|
||||
default:
|
||||
case SEARCH_MODE_NORMAL:
|
||||
resId = R.string.image_search;
|
||||
break;
|
||||
case SEARCH_MODE_IMAGE:
|
||||
resId = R.string.keyword_search;
|
||||
break;
|
||||
}
|
||||
mAction.setText(resId);
|
||||
|
||||
if (mHelper != null) {
|
||||
mHelper.onChangeSearchMode();
|
||||
}
|
||||
@@ -283,6 +320,8 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setMessage(R.string.search_tip)
|
||||
.show();
|
||||
} else if (mAction == v) {
|
||||
toggleSearchMode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +360,17 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
mActionView.setLayoutParams(new RecyclerView.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
int resId;
|
||||
switch (mSearchMode) {
|
||||
default:
|
||||
case SEARCH_MODE_NORMAL:
|
||||
resId = R.string.image_search;
|
||||
break;
|
||||
case SEARCH_MODE_IMAGE:
|
||||
resId = R.string.keyword_search;
|
||||
break;
|
||||
}
|
||||
mAction.setText(resId);
|
||||
view = mActionView;
|
||||
} else {
|
||||
view = mInflater.inflate(R.layout.search_category, parent, false);
|
||||
@@ -337,6 +387,11 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
ViewUtils.removeFromParent(mAdvanceView);
|
||||
content.addView(mAdvanceView);
|
||||
break;
|
||||
case ITEM_TYPE_IMAGE:
|
||||
title.setText(R.string.search_image);
|
||||
ViewUtils.removeFromParent(mImageView);
|
||||
content.addView(mImageView);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,5 +406,6 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
|
||||
public interface Helper {
|
||||
void onChangeSearchMode();
|
||||
void onSelectImage();
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,10 @@ 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;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
@@ -45,11 +47,8 @@ import com.hippo.ehviewer.R;
|
||||
* actual preference controls.
|
||||
*/
|
||||
public abstract class DialogPreference extends Preference implements
|
||||
DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
|
||||
|
||||
private static final String KEY_SUPER = "super";
|
||||
private static final String KEY_IS_DIALOG_SHOWING = "is_dialog_showing";
|
||||
private static final String KEY_DIALOG_BUNDLE = "dialog_bundle";
|
||||
DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
|
||||
PreferenceManager.OnActivityDestroyListener {
|
||||
|
||||
private AlertDialog.Builder mBuilder;
|
||||
|
||||
@@ -272,6 +271,8 @@ public abstract class DialogPreference extends Preference implements
|
||||
|
||||
onPrepareDialogBuilder(mBuilder);
|
||||
|
||||
PreferenceUtils.registerOnActivityDestroyListener(this, this);
|
||||
|
||||
// Create the dialog
|
||||
final AlertDialog dialog = mDialog = mBuilder.create();
|
||||
if (state != null) {
|
||||
@@ -336,6 +337,8 @@ public abstract class DialogPreference extends Preference implements
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
PreferenceUtils.unregisterOnActivityDestroyListener(this, this);
|
||||
|
||||
mDialog = null;
|
||||
onDialogClosed(mWhichButtonClicked == DialogInterface.BUTTON_POSITIVE);
|
||||
}
|
||||
@@ -359,6 +362,15 @@ public abstract class DialogPreference extends Preference implements
|
||||
return mDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroy() {
|
||||
if (mDialog == null || !mDialog.isShowing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
final Parcelable superState = super.onSaveInstanceState();
|
||||
@@ -366,25 +378,59 @@ public abstract class DialogPreference extends Preference implements
|
||||
return superState;
|
||||
}
|
||||
|
||||
final Bundle myState = new Bundle();
|
||||
myState.putParcelable(KEY_SUPER, superState);
|
||||
myState.putBoolean(KEY_IS_DIALOG_SHOWING, true);
|
||||
myState.putBundle(KEY_DIALOG_BUNDLE, mDialog.onSaveInstanceState());
|
||||
final SavedState myState = new SavedState(superState);
|
||||
myState.isDialogShowing = true;
|
||||
myState.dialogBundle = mDialog.onSaveInstanceState();
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (state == null || !state.getClass().equals(Bundle.class)) {
|
||||
if (state == null || !state.getClass().equals(SavedState.class)) {
|
||||
// Didn't save state for us in onSaveInstanceState
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle myState = (Bundle) state;
|
||||
super.onRestoreInstanceState(myState.getParcelable(KEY_SUPER));
|
||||
if (myState.getBoolean(KEY_IS_DIALOG_SHOWING)) {
|
||||
showDialog(myState.getBundle(KEY_DIALOG_BUNDLE));
|
||||
SavedState myState = (SavedState) state;
|
||||
super.onRestoreInstanceState(myState.getSuperState());
|
||||
if (myState.isDialogShowing) {
|
||||
showDialog(myState.dialogBundle);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SavedState extends BaseSavedState {
|
||||
boolean isDialogShowing;
|
||||
Bundle dialogBundle;
|
||||
|
||||
public SavedState(Parcel source) {
|
||||
super(source);
|
||||
isDialogShowing = source.readInt() == 1;
|
||||
dialogBundle = source.readBundle(DialogPreference.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(isDialogShowing ? 1 : 0);
|
||||
dest.writeBundle(dialogBundle);
|
||||
}
|
||||
|
||||
public SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<SavedState> CREATOR =
|
||||
new Parcelable.Creator<SavedState>() {
|
||||
@Override
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedState[] newArray(int size) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.preference;
|
||||
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class PreferenceUtils {
|
||||
private PreferenceUtils() {}
|
||||
|
||||
private static final Method mRegisterOnActivityDestroyListener;
|
||||
private static final Method mUnregisterOnActivityDestroyListener;
|
||||
|
||||
static {
|
||||
Method method;
|
||||
Class<?> clazz = PreferenceManager.class;
|
||||
|
||||
method = null;
|
||||
try {
|
||||
method = clazz.getDeclaredMethod("registerOnActivityDestroyListener",
|
||||
PreferenceManager.OnActivityDestroyListener.class);
|
||||
if (null != method) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mRegisterOnActivityDestroyListener = method;
|
||||
|
||||
method = null;
|
||||
try {
|
||||
method = clazz.getDeclaredMethod("unregisterOnActivityDestroyListener",
|
||||
PreferenceManager.OnActivityDestroyListener.class);
|
||||
if (null != method) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mUnregisterOnActivityDestroyListener = method;
|
||||
}
|
||||
|
||||
@SuppressWarnings("TryWithIdenticalCatches")
|
||||
public static void registerOnActivityDestroyListener(Preference preference,
|
||||
PreferenceManager.OnActivityDestroyListener listener) {
|
||||
if (null == mRegisterOnActivityDestroyListener || null == preference || null == listener) {
|
||||
return;
|
||||
}
|
||||
PreferenceManager preferenceManager = preference.getPreferenceManager();
|
||||
if (null == preferenceManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
mRegisterOnActivityDestroyListener.invoke(preferenceManager, listener);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("TryWithIdenticalCatches")
|
||||
public static void unregisterOnActivityDestroyListener(Preference preference,
|
||||
PreferenceManager.OnActivityDestroyListener listener) {
|
||||
if (null == mUnregisterOnActivityDestroyListener || null == preference || null == listener) {
|
||||
return;
|
||||
}
|
||||
PreferenceManager preferenceManager = preference.getPreferenceManager();
|
||||
if (null == preferenceManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
mUnregisterOnActivityDestroyListener.invoke(preferenceManager, listener);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.UrlOpener;
|
||||
|
||||
public class UrlPreference extends Preference {
|
||||
|
||||
private String mUrl;
|
||||
|
||||
public UrlPreference(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0, 0);
|
||||
}
|
||||
|
||||
public UrlPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0, 0);
|
||||
}
|
||||
|
||||
public UrlPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UrlPreference, defStyleAttr, defStyleRes);
|
||||
mUrl = a.getString(R.styleable.UrlPreference_url);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
if (null != mUrl) {
|
||||
return mUrl;
|
||||
} else {
|
||||
return super.getSummary();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
UrlOpener.openUrl(getContext(), mUrl, true, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.reveal;
|
||||
|
||||
public interface Reveal {
|
||||
|
||||
void setRevealEnable(boolean enable);
|
||||
|
||||
void setReveal(int centerX, int centerY, float radius);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.reveal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
public class RevealLinearLayout extends LinearLayout implements Reveal {
|
||||
|
||||
private final Path mRevealPath = new Path();
|
||||
private boolean mReveal;
|
||||
private int mCenterX;
|
||||
private int mCenterY;
|
||||
private float mRadius;
|
||||
|
||||
public RevealLinearLayout(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public RevealLinearLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public RevealLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (!ViewAnimationUtils.API_SUPPORT_CIRCULAR_REVEAL) {
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRevealEnable(boolean enable) {
|
||||
mReveal = enable;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReveal(int centerX, int centerY, float radius) {
|
||||
mCenterX = centerX;
|
||||
mCenterY = centerY;
|
||||
mRadius = radius;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
boolean reveal = mReveal;
|
||||
int saveCount = 0;
|
||||
|
||||
if (reveal) {
|
||||
saveCount = canvas.save();
|
||||
Path path = mRevealPath;
|
||||
path.reset();
|
||||
path.addCircle(mCenterX, mCenterY, mRadius, Path.Direction.CW);
|
||||
canvas.clipPath(path);
|
||||
}
|
||||
|
||||
super.draw(canvas);
|
||||
|
||||
if (reveal) {
|
||||
canvas.restoreToCount(saveCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.reveal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class RevealView extends View implements Reveal {
|
||||
|
||||
private final Path mRevealPath = new Path();
|
||||
private boolean mReveal;
|
||||
private int mCenterX;
|
||||
private int mCenterY;
|
||||
private float mRadius;
|
||||
|
||||
public RevealView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public RevealView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public RevealView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRevealEnable(boolean enable) {
|
||||
mReveal = enable;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReveal(int centerX, int centerY, float radius) {
|
||||
mCenterX = centerX;
|
||||
mCenterY = centerY;
|
||||
mRadius = radius;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
boolean reveal = mReveal;
|
||||
int saveCount = 0;
|
||||
|
||||
if (reveal) {
|
||||
saveCount = canvas.save();
|
||||
Path path = mRevealPath;
|
||||
path.reset();
|
||||
path.addCircle(mCenterX, mCenterY, mRadius, Path.Direction.CW);
|
||||
canvas.clipPath(path);
|
||||
}
|
||||
|
||||
super.draw(canvas);
|
||||
|
||||
if (reveal) {
|
||||
canvas.restoreToCount(saveCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.reveal;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener;
|
||||
|
||||
public final class ViewAnimationUtils {
|
||||
private ViewAnimationUtils() {}
|
||||
|
||||
public static final boolean API_SUPPORT_CIRCULAR_REVEAL =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
// http://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported
|
||||
public static final boolean API_SUPPORT_CANVAS_CLIP_PATH =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public static Animator createCircularReveal(View view,
|
||||
int centerX, int centerY, float startRadius, float endRadius) {
|
||||
if (API_SUPPORT_CIRCULAR_REVEAL) {
|
||||
return android.view.ViewAnimationUtils.createCircularReveal(
|
||||
view, centerX, centerY, startRadius, endRadius);
|
||||
} else if (view instanceof Reveal){
|
||||
return createRevealAnimator((Reveal) view, centerX, centerY,
|
||||
startRadius, endRadius);
|
||||
} else {
|
||||
throw new IllegalStateException("Only View implements CircularReveal or" +
|
||||
" api >= 21 can create circular reveal");
|
||||
}
|
||||
}
|
||||
|
||||
private static Animator createRevealAnimator(Reveal reveal, int centerX, int centerY,
|
||||
float startRadius, float endRadius) {
|
||||
ValueAnimator animator = ValueAnimator.ofFloat(startRadius, endRadius);
|
||||
animator.addUpdateListener(new RevealAnimatorUpdateListener(reveal, centerX, centerY));
|
||||
animator.addListener(new RevealAnimatorListener(reveal));
|
||||
return animator;
|
||||
}
|
||||
|
||||
private static class RevealAnimatorUpdateListener
|
||||
implements ValueAnimator.AnimatorUpdateListener {
|
||||
|
||||
private final Reveal mReveal;
|
||||
private final int mCenterX;
|
||||
private final int mCenterY;
|
||||
|
||||
public RevealAnimatorUpdateListener(Reveal reveal, int centerX, int centerY) {
|
||||
mReveal = reveal;
|
||||
mCenterX = centerX;
|
||||
mCenterY = centerY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
Object value = animation.getAnimatedValue();
|
||||
if (value instanceof Float) {
|
||||
mReveal.setReveal(mCenterX, mCenterY, (Float) value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class RevealAnimatorListener extends SimpleAnimatorListener {
|
||||
|
||||
private final Reveal mReveal;
|
||||
private final View mView;
|
||||
|
||||
public RevealAnimatorListener(Reveal reveal) {
|
||||
mReveal = reveal;
|
||||
mView = (View) reveal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
if (!API_SUPPORT_CANVAS_CLIP_PATH) {
|
||||
mView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
mReveal.setRevealEnable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mReveal.setRevealEnable(false);
|
||||
if (!API_SUPPORT_CANVAS_CLIP_PATH) {
|
||||
mView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class Html {
|
||||
*
|
||||
* <p>This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
|
||||
*/
|
||||
public static Spanned fromHtml(String source, ImageGetter imageGetter,
|
||||
public static SpannableStringBuilder fromHtml(String source, ImageGetter imageGetter,
|
||||
TagHandler tagHandler) {
|
||||
Parser parser = new Parser();
|
||||
try {
|
||||
@@ -462,7 +462,7 @@ class HtmlToSpannedConverter implements ContentHandler {
|
||||
mReader = parser;
|
||||
}
|
||||
|
||||
public Spanned convert() {
|
||||
public SpannableStringBuilder convert() {
|
||||
|
||||
mReader.setContentHandler(this);
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.util;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.io.InputStreamPipe;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class BitmapUtils {
|
||||
|
||||
public static Context sContext;
|
||||
|
||||
public static void initialize(Context context) {
|
||||
sContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static long availableMemory() {
|
||||
final Runtime runtime = Runtime.getRuntime();
|
||||
final long used = runtime.totalMemory() - runtime.freeMemory();
|
||||
|
||||
final ActivityManager activityManager = (ActivityManager) sContext.
|
||||
getSystemService(Context.ACTIVITY_SERVICE);
|
||||
final long total = activityManager.getMemoryClass() * 1024 * 1024;
|
||||
|
||||
return total - used;
|
||||
}
|
||||
|
||||
public static Bitmap decodeStream(@NonNull InputStreamPipe isp, int maxWidth, int maxHeight,
|
||||
int pixels, boolean checkMemory, boolean justCalc, int[] sampleSize) {
|
||||
try {
|
||||
isp.obtain();
|
||||
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeStream(isp.open(), null, options);
|
||||
isp.close();
|
||||
|
||||
int width = options.outWidth;
|
||||
int height = options.outHeight;
|
||||
if (width <= 0 || height <= 0) {
|
||||
if (sampleSize != null && sampleSize.length >= 1) {
|
||||
sampleSize[0] = -1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int scaleW = 1;
|
||||
int scaleH = 1;
|
||||
int scaleP = 1;
|
||||
int scaleM = 1;
|
||||
if (maxWidth > 0 && width > maxWidth) {
|
||||
scaleW = MathUtils.ceilDivide(width, maxWidth);
|
||||
}
|
||||
if (maxHeight > 0 && height > maxHeight) {
|
||||
scaleH = MathUtils.ceilDivide(height, maxHeight);
|
||||
}
|
||||
if (pixels > 0 && width * height > pixels) {
|
||||
scaleP = (int) Math.ceil(Math.sqrt(width * height / (float) pixels));
|
||||
}
|
||||
if (checkMemory) {
|
||||
long m = availableMemory() - 5 * 1024 * 1024; // Leave 5m
|
||||
if (m < 0) {
|
||||
if (sampleSize != null && sampleSize.length >= 1) {
|
||||
sampleSize[0] = -1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (width * height * 3 > m) {
|
||||
scaleM = (int) Math.ceil(Math.sqrt(width * height * 3 / (float) m));
|
||||
}
|
||||
}
|
||||
options.inSampleSize = MathUtils.nextPowerOf2(MathUtils.max(scaleW, scaleH, scaleP, scaleM, 1));
|
||||
if (sampleSize != null && sampleSize.length >= 1) {
|
||||
sampleSize[0] = options.inSampleSize;
|
||||
}
|
||||
|
||||
options.inJustDecodeBounds = false;
|
||||
|
||||
if (justCalc) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return BitmapFactory.decodeStream(isp.open(), null, options);
|
||||
} catch (OutOfMemoryError e) {
|
||||
if (sampleSize != null && sampleSize.length >= 1) {
|
||||
sampleSize[0] = -1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (sampleSize != null && sampleSize.length >= 1) {
|
||||
sampleSize[0] = -1;
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
isp.close();
|
||||
isp.release();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null or the bitmap
|
||||
*/
|
||||
public static Bitmap decodeStream(@NonNull InputStreamPipe isp, int maxWidth, int maxHeight) {
|
||||
return decodeStream(isp, maxWidth, maxHeight, -1, false, false, null);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.ResourcesUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
@@ -78,7 +77,7 @@ public class DirExplorer extends EasyRecyclerView implements EasyRecyclerView.On
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setShowLastDivider(true);
|
||||
addItemDecoration(decoration);
|
||||
setSelector(RippleSalon.generateRippleDrawable(ResourcesUtils.getAttrBoolean(context, R.attr.dark)));
|
||||
setSelector(RippleSalon.generateRippleDrawable(false));
|
||||
setOnItemClickListener(this);
|
||||
|
||||
mCurrentFile = Environment.getExternalStorageDirectory();
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ import android.widget.FrameLayout;
|
||||
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
|
||||
public class DrawView extends FrameLayout {
|
||||
public class DrawerView extends FrameLayout {
|
||||
|
||||
private static final int DEFAULT_MAX_WIDTH = 280;
|
||||
|
||||
@@ -33,17 +33,17 @@ public class DrawView extends FrameLayout {
|
||||
|
||||
private int mMaxWidth;
|
||||
|
||||
public DrawView(Context context) {
|
||||
public DrawerView(Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public DrawView(Context context, AttributeSet attrs) {
|
||||
public DrawerView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public DrawView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
public DrawerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
@@ -72,13 +72,15 @@ public class LinkifyTextView extends TextView {
|
||||
y += getScrollY();
|
||||
|
||||
Layout layout = getLayout();
|
||||
int line = layout.getLineForVertical(y);
|
||||
int off = layout.getOffsetForHorizontal(line, x);
|
||||
if (null != layout) {
|
||||
int line = layout.getLineForVertical(y);
|
||||
int off = layout.getOffsetForHorizontal(line, x);
|
||||
|
||||
ClickableSpan[] spans = ((Spanned)getText()).getSpans(off, off, ClickableSpan.class);
|
||||
ClickableSpan[] spans = ((Spanned)getText()).getSpans(off, off, ClickableSpan.class);
|
||||
|
||||
if (spans.length > 0) {
|
||||
mCurrentSpan = spans[0];
|
||||
if (spans.length > 0) {
|
||||
mCurrentSpan = spans[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.slidingdrawerlayout;
|
||||
|
||||
public interface SlidingDrawerLayoutChild {
|
||||
|
||||
void setFitPadding(int top, int bottom);
|
||||
|
||||
int getLayoutPaddingTop();
|
||||
|
||||
int getLayoutPaddingBottom();
|
||||
}
|
||||
@@ -117,6 +117,7 @@ void* GIF_decode(JNIEnv* env, PatchHeadInputStream* patch_head_input_stream, boo
|
||||
GIF* gif = NULL;
|
||||
GifFileType* gif_file = NULL;
|
||||
void* buffer = NULL;
|
||||
void*shown_buffer = NULL;
|
||||
GIF_FRAME_INFO* frame_info_array = NULL;
|
||||
int i;
|
||||
|
||||
@@ -140,8 +141,11 @@ void* GIF_decode(JNIEnv* env, PatchHeadInputStream* patch_head_input_stream, boo
|
||||
|
||||
// Buffer
|
||||
buffer = malloc(gif_file->SWidth * gif_file->SHeight * sizeof(RGBA));
|
||||
if (buffer == NULL) {
|
||||
shown_buffer = malloc(gif_file->SWidth * gif_file->SHeight * sizeof(RGBA));
|
||||
if (buffer == NULL || shown_buffer == NULL) {
|
||||
WTF_OM;
|
||||
free(buffer);
|
||||
free(shown_buffer);
|
||||
DGifCloseFile(gif_file, &error_code);
|
||||
free(gif);
|
||||
close_patch_head_input_stream(get_env(), patch_head_input_stream);
|
||||
@@ -226,6 +230,7 @@ void* GIF_decode(JNIEnv* env, PatchHeadInputStream* patch_head_input_stream, boo
|
||||
gif->buffer = buffer;
|
||||
gif->buffer_index = -1;
|
||||
gif->backup = NULL;
|
||||
gif->shown_buffer = shown_buffer;
|
||||
|
||||
GIF_advance(gif);
|
||||
|
||||
@@ -293,7 +298,7 @@ void GIF_render(GIF* gif, int src_x, int src_y,
|
||||
void* dst, int dst_w, int dst_h, int dst_x, int dst_y,
|
||||
int width, int height, bool fill_blank, int default_color)
|
||||
{
|
||||
copy_pixels(gif->buffer, gif->gif_file->SWidth, gif->gif_file->SHeight, src_x, src_y,
|
||||
copy_pixels(gif->shown_buffer, gif->gif_file->SWidth, gif->gif_file->SHeight, src_x, src_y,
|
||||
dst, dst_w, dst_h, dst_x, dst_y,
|
||||
width, height, fill_blank, default_color);
|
||||
}
|
||||
@@ -454,6 +459,9 @@ void GIF_advance(GIF* gif)
|
||||
|
||||
blend(gif->gif_file, index, gif->buffer, frame_info.tran);
|
||||
|
||||
// Copy to shown buffer
|
||||
memcpy(gif->shown_buffer, gif->buffer, (size_t) (gif->gif_file->SWidth * gif->gif_file->SHeight * 4));
|
||||
|
||||
gif->buffer_index = index;
|
||||
}
|
||||
|
||||
@@ -490,6 +498,9 @@ void GIF_recycle(GIF* gif)
|
||||
free(gif->backup);
|
||||
gif->backup = NULL;
|
||||
|
||||
free(gif->shown_buffer);
|
||||
gif->shown_buffer = NULL;
|
||||
|
||||
if (gif->patch_head_input_stream != NULL) {
|
||||
close_patch_head_input_stream(get_env(), gif->patch_head_input_stream);
|
||||
destroy_patch_head_input_stream(get_env(), &gif->patch_head_input_stream);
|
||||
|
||||
@@ -53,6 +53,8 @@ typedef struct
|
||||
int buffer_index;
|
||||
void* backup;
|
||||
bool partially;
|
||||
// Use extra buffer to avoid blink
|
||||
void* shown_buffer;
|
||||
PatchHeadInputStream* patch_head_input_stream;
|
||||
} GIF;
|
||||
|
||||
|
||||
@@ -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:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="?attr/colorPrimary"
|
||||
android:pathData="@string/pd_file_find"/>
|
||||
|
||||
</vector>
|
||||
@@ -21,14 +21,14 @@
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
<com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/draw_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.hippo.scene.StageLayout
|
||||
<com.hippo.ehviewer.widget.EhStageLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -45,7 +45,7 @@
|
||||
app:headerLayout="@layout/nav_header_main"
|
||||
app:menu="@menu/nav_drawer_main"/>
|
||||
|
||||
<com.hippo.widget.DrawView
|
||||
<com.hippo.ehviewer.widget.EhDrawerView
|
||||
android:id="@+id/right_drawer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
@@ -54,5 +54,5 @@
|
||||
android:background="@color/background_light"
|
||||
android:clickable="true"/>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
</com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout>
|
||||
</com.hippo.widget.SafeCoordinatorLayout>
|
||||
@@ -40,7 +40,30 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/settings_read_reading_direction_title"
|
||||
android:text="@string/settings_read_screen_rotation"
|
||||
android:textColor="@color/primary_text_dark"/>
|
||||
|
||||
<com.hippo.widget.CuteSpinner
|
||||
android:id="@+id/screen_rotation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:entries="@array/screen_rotation_entries"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/settings_read_reading_direction"
|
||||
android:textColor="@color/primary_text_dark"/>
|
||||
|
||||
<com.hippo.widget.CuteSpinner
|
||||
|
||||
File renamed without changes.
@@ -101,6 +101,15 @@
|
||||
android:drawablePadding="8dp"
|
||||
android:textColor="@color/primary_text_light"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/search_cover"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/search_cover"
|
||||
android:drawablePadding="8dp"
|
||||
android:textColor="@color/primary_text_light"/>
|
||||
|
||||
</LinearLayout>
|
||||
</HorizontalScrollView>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
<com.hippo.reveal.RevealView
|
||||
android:id="@+id/color_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
||||
@@ -47,14 +47,6 @@
|
||||
android:layout_below="@id/title"
|
||||
android:layout_marginTop="2dp"/>
|
||||
|
||||
<com.hippo.ehviewer.widget.SimpleRatingView
|
||||
android:id="@+id/rating"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/title"
|
||||
android:layout_below="@id/uploader"
|
||||
android:layout_marginTop="2dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category"
|
||||
style="@style/CardMessage"
|
||||
@@ -70,6 +62,14 @@
|
||||
android:textColor="@android:color/white"
|
||||
android:textAllCaps="true"/>
|
||||
|
||||
<com.hippo.ehviewer.widget.SimpleRatingView
|
||||
android:id="@+id/rating"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/title"
|
||||
android:layout_above="@id/category"
|
||||
android:layout_marginBottom="4dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/posted"
|
||||
style="@style/CardMessage"
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2016 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="?attr/dialogPreferredPadding"
|
||||
android:paddingTop="@dimen/abc_dialog_padding_top_material"
|
||||
android:paddingBottom="@dimen/abc_dialog_padding_top_material"
|
||||
android:paddingRight="?attr/dialogPreferredPadding">
|
||||
|
||||
<com.hippo.widget.ProgressView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
style="@style/ProgressView"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/please_wait"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -38,7 +38,7 @@
|
||||
android:text="@string/no_one_comments_gallery"
|
||||
style="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
<LinearLayout
|
||||
<com.hippo.reveal.RevealLinearLayout
|
||||
android:id="@+id/edit_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -79,7 +79,7 @@
|
||||
app:srcCompat="@drawable/v_send_dark_x24"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</com.hippo.reveal.RevealLinearLayout>
|
||||
|
||||
<com.hippo.widget.FabLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -13,27 +13,26 @@
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<LinearLayout
|
||||
|
||||
<android.support.v7.widget.ButtonBarLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
style="?attr/buttonBarStyle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/search_action_1"
|
||||
android:layout_width="wrap_content"
|
||||
<Button
|
||||
android:id="@+id/action"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="1"/>
|
||||
android:textColor="?attr/colorPrimary"
|
||||
android:textStyle="bold"
|
||||
style="?attr/buttonBarPositiveButtonStyle"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/search_action_2"
|
||||
android:layout_width="wrap_content"
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="2"/>
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.ButtonBarLayout>
|
||||
@@ -13,8 +13,9 @@
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.hippo.ehviewer.widget.AdvanceSearchTable
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/search_advance_search_table"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2016 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.hippo.ehviewer.widget.ImageSearchLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/search_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<com.hippo.widget.FixedAspectImageView
|
||||
android:id="@+id/preview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:maxWidth="@dimen/image_search_max_size"
|
||||
android:maxHeight="@dimen/image_search_max_size"
|
||||
android:adjustViewBounds="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/select_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/select_image"
|
||||
style="?attr/buttonBarButtonStyle"/>
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TableRow>
|
||||
<CheckBox
|
||||
android:id="@+id/search_uss"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:checked="true"
|
||||
android:text="@string/search_uss"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/search_osc"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:checked="false"
|
||||
android:text="@string/search_osc"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
<CheckBox
|
||||
android:id="@+id/search_se"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:checked="false"
|
||||
android:text="@string/search_se"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:checked="false"/>
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
</merge>
|
||||
@@ -23,4 +23,10 @@
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Main" parent="AppTheme.NoActionBar">
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="android:windowTranslucentNavigation">false</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -36,6 +36,7 @@
|
||||
<string name="display_name_dialog_title">输入昵称</string>
|
||||
<string name="display_name">昵称</string>
|
||||
<string name="display_name_is_empty">昵称为空</string>
|
||||
<string name="sign_in_first">请先登录</string>
|
||||
|
||||
<string name="default_display_name">Little Hippo</string>
|
||||
|
||||
@@ -45,6 +46,7 @@
|
||||
<string name="wrong_cookie_warning">看起来您输入的 Cookie 是错误的,最好检查一下。</string>
|
||||
<string name="i_will_check_it">好的</string>
|
||||
<string name="i_dont_think_so">我没输错</string>
|
||||
<string name="found_cookies">找到旧版 Cookie</string>
|
||||
|
||||
<string name="invalid_download_location">似乎下载路径不可用。请到重新设置下载路径。</string>
|
||||
|
||||
@@ -79,7 +81,7 @@
|
||||
<string name="error_password_cannot_empty">密码不可为空</string>
|
||||
<string name="skip_signing_in">跳过登陆</string>
|
||||
<string name="sign_in_failed">登陆失败</string>
|
||||
<string name="sign_in_failed_plain">这可能是网站更新导致的,也有可能是发生了奇怪的事情。您可以选择在登陆按钮下方通过网页登陆或者输入 cookie,或者跳过登陆。跳过登陆可能导致无法正常使用应用。</string>
|
||||
<string name="sign_in_failed_plain">这可能是网站更新导致的,也有可能是发生了奇怪的事情。您可以选择在登陆按钮下方通过网页登陆或者输入 cookie,或者跳过登陆。跳过登陆可能导致无法正常使用应用。如果你已经在 0.6.x 版登陆过了,请优先尝试选择“通过 Cookie 登陆”。</string>
|
||||
<string name="press_twice_exit">再按一次退出</string>
|
||||
<string name="content_layout_restore_tip">点击重试</string>
|
||||
<string name="write_rationale">EhViewer 将申请设备存储空间访问权限以便下载画廊。您愿意授权吗?</string>
|
||||
@@ -110,6 +112,9 @@
|
||||
|
||||
<string name="search">搜索</string>
|
||||
|
||||
<string name="keyword_search">关键字搜索</string>
|
||||
<string name="image_search">图片搜索</string>
|
||||
|
||||
<string name="search_normal">普通搜索</string>
|
||||
<string name="search_advance">高级选项</string>
|
||||
<string name="search_image">图片搜索</string>
|
||||
@@ -131,6 +136,12 @@
|
||||
<string name="search_sh">显示被删除的画廊</string>
|
||||
<string name="search_sr">最低评分:</string>
|
||||
|
||||
<string name="select_image">选择图片</string>
|
||||
<string name="search_uss">使用相似搜索</string>
|
||||
<string name="search_osc">只搜索封面</string>
|
||||
<string name="search_se">显示被删除的画廊</string>
|
||||
<string name="select_image_first">请先选择图片</string>
|
||||
|
||||
<string name="add_to_favourites">收藏</string>
|
||||
|
||||
<string name="quick_search">快速搜索</string>
|
||||
@@ -143,6 +154,7 @@
|
||||
<string name="no_quick_search">这里是快速搜索</string>
|
||||
<string name="add_quick_search_tip">画廊列表的状态将被保存为快速搜索。如果你想保存搜索面板的状态,请先执行搜索。</string>
|
||||
<string name="readme">读我</string>
|
||||
<string name="image_search_not_quick_search">无法添加图片搜索为快速搜索</string>
|
||||
<string name="duplicate_quick_search">已存在相同的快速搜索,名称为“%s”。</string>
|
||||
<string name="duplicate_name">已存在相同名称</string>
|
||||
|
||||
@@ -169,6 +181,7 @@
|
||||
<string name="share">分享</string>
|
||||
<string name="rate">评分</string>
|
||||
<string name="similar_gallery">相似画廊</string>
|
||||
<string name="search_cover">搜索封面</string>
|
||||
<string name="no_tags">暂无标签</string>
|
||||
<string name="no_comments">暂无评论</string>
|
||||
<string name="no_more_comments">已显示所有评论</string>
|
||||
@@ -237,6 +250,17 @@
|
||||
<string name="no_one_comments_gallery">暂时没有评论</string>
|
||||
<string name="comment_successfully">评论成功</string>
|
||||
<string name="comment_failed">评论失败</string>
|
||||
<string name="copy_comment_text">复制评论文字</string>
|
||||
<string name="vote_up">深表赞同</string>
|
||||
<string name="cancel_vote_up">不再深表赞同</string>
|
||||
<string name="vote_down">垃圾评论</string>
|
||||
<string name="cancel_vote_down">不是垃圾评论</string>
|
||||
<string name="vote_up_successfully">已深表赞同</string>
|
||||
<string name="cancel_vote_up_successfully">已不再深表赞同</string>
|
||||
<string name="vote_down_successfully">已钦定为垃圾评论</string>
|
||||
<string name="cancel_vote_down_successfully">已不再钦定为垃圾评论</string>
|
||||
<string name="vote_failed">投票失败</string>
|
||||
<string name="check_vote_status">查看投票情况</string>
|
||||
|
||||
<!-- Gallery Previews -->
|
||||
<string name="gallery_previews">画廊预览</string>
|
||||
@@ -353,7 +377,11 @@
|
||||
<string name="settings_eh_filter_summary">过滤标题,上传者,标签和标签组</string>
|
||||
|
||||
<string name="settings_read">阅读</string>
|
||||
<string name="settings_read_reading_direction_title">阅读方向</string>
|
||||
<string name="settings_read_screen_rotation">屏幕方向</string>
|
||||
<string name="settings_read_screen_rotation_default">系统默认</string>
|
||||
<string name="settings_read_screen_rotation_portrait">竖屏</string>
|
||||
<string name="settings_read_screen_rotation_landscape">横屏</string>
|
||||
<string name="settings_read_reading_direction">阅读方向</string>
|
||||
<string name="settings_read_reading_direction_left_to_right">从左至右</string>
|
||||
<string name="settings_read_reading_direction_right_to_Left">从右至左</string>
|
||||
<string name="settings_read_reading_direction_top_to_bottom">从上至下</string>
|
||||
@@ -378,9 +406,10 @@
|
||||
<string name="settings_download_download_location">下载路径</string>
|
||||
<string name="settings_download_invalid_download_location">无效的下载路径</string>
|
||||
<string name="settings_download_cant_get_download_location">无法获取下载路径</string>
|
||||
<string name="settings_download_pick_dir_kk">在 KitKat 中您无法把数据写入外置 SD 卡,除非您做了奇怪的事情</string>
|
||||
<string name="settings_download_pick_dir_kk">在 KitKat 中您无法把数据写入外置 SD 卡,除非您做了奇怪的事情。不过 <SD card>/Android/data/com.hippo.ehviewer 这个路径比较特殊,是可以写入的。</string>
|
||||
<string name="settings_download_pick_dir_l">Lollipop 提供了新的写入外置 SD 卡的 API。如果您想把下载路径设置到外置 SD 卡上,点击“文档”按钮</string>
|
||||
<string name="settings_download_document">文档</string>
|
||||
<string name="settings_download_continue">继续</string>
|
||||
<string name="settings_download_restore_download_items">恢复下载项</string>
|
||||
<string name="settings_download_restore_download_items_summary">恢复下载目录里的所有下载项</string>
|
||||
<string name="settings_download_multi_thread_download">下载线程数</string>
|
||||
@@ -423,6 +452,7 @@
|
||||
<string name="settings_about_website">网站</string>
|
||||
<string name="settings_about_source">源码</string>
|
||||
<string name="settings_about_changelog">更新日志</string>
|
||||
<string name="settings_about_help">帮助</string>
|
||||
<string name="settings_about_license">开源许可</string>
|
||||
<string name="settings_about_license_summary">EhViewer 的诞生离不开许多开源项目</string>
|
||||
<string name="settings_about_donate">捐赠</string>
|
||||
@@ -461,6 +491,8 @@
|
||||
<string name="language_na">N/A</string>
|
||||
<string name="language_other">其他</string>
|
||||
|
||||
<string name="please_wait">请稍候</string>
|
||||
|
||||
<string name="enable">启用</string>
|
||||
<string name="enabled">已启用</string>
|
||||
<string name="disabled">未启用</string>
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<string name="display_name_dialog_title">輸入暱稱</string>
|
||||
<string name="display_name">暱稱</string>
|
||||
<string name="display_name_is_empty">暱稱為空</string>
|
||||
<string name="sign_in_first">請先登錄</string>
|
||||
|
||||
<string name="default_display_name">Little Hippo</string>
|
||||
|
||||
@@ -45,6 +46,7 @@
|
||||
<string name="wrong_cookie_warning">看起來您輸入的 Cookie 是錯誤的,最好檢查一下。</string>
|
||||
<string name="i_will_check_it">好的</string>
|
||||
<string name="i_dont_think_so">我沒輸錯</string>
|
||||
<string name="found_cookies">找到舊版 Cookie</string>
|
||||
|
||||
<string name="invalid_download_location">似乎下載路徑不可用。請到重新設置下載路徑。</string>
|
||||
|
||||
@@ -79,7 +81,7 @@
|
||||
<string name="error_password_cannot_empty">密碼不可為空</string>
|
||||
<string name="skip_signing_in">跳過登陸</string>
|
||||
<string name="sign_in_failed">登陸失敗</string>
|
||||
<string name="sign_in_failed_plain">這可能是網站更新導致的,也有可能是發生了奇怪的事情。您可以選擇在登陸按鈕下方通過網頁登陸或者輸入 cookie,或者跳過登陸。跳過登陸可能導致無法正常使用應用。</string>
|
||||
<string name="sign_in_failed_plain">這可能是網站更新導致的,也有可能是發生了奇怪的事情。您可以選擇在登陸按鈕下方通過網頁登陸或者輸入 cookie,或者跳過登陸。跳過登陸可能導致無法正常使用應用。如果你已經在 0.6.x 版登陸過了,請優先嚐試選擇“通過 Cookie 登陸”。</string>
|
||||
<string name="press_twice_exit">再按一次退出</string>
|
||||
<string name="content_layout_restore_tip">點擊重試</string>
|
||||
<string name="write_rationale">EhViewer 將申請設備存儲空間訪問權限以便下載畫廊。您願意授權嗎?</string>
|
||||
@@ -110,6 +112,9 @@
|
||||
|
||||
<string name="search">搜索</string>
|
||||
|
||||
<string name="keyword_search">關鍵字搜索</string>
|
||||
<string name="image_search">圖片搜索</string>
|
||||
|
||||
<string name="search_normal">普通搜索</string>
|
||||
<string name="search_advance">高級選項</string>
|
||||
<string name="search_image">圖片搜索</string>
|
||||
@@ -131,6 +136,12 @@
|
||||
<string name="search_sh">顯示被刪除的畫廊</string>
|
||||
<string name="search_sr">最低評分:</string>
|
||||
|
||||
<string name="select_image">選擇圖片</string>
|
||||
<string name="search_uss">使用相似搜索</string>
|
||||
<string name="search_osc">只搜索封面</string>
|
||||
<string name="search_se">顯示被刪除的畫廊</string>
|
||||
<string name="select_image_first">請先選擇圖片</string>
|
||||
|
||||
<string name="add_to_favourites">收藏</string>
|
||||
|
||||
<string name="quick_search">快速搜索</string>
|
||||
@@ -143,6 +154,7 @@
|
||||
<string name="no_quick_search">這裏是快速搜索</string>
|
||||
<string name="add_quick_search_tip">畫廊列表的狀態將被保存為快速搜索。如果你想保存搜索面板的狀態,請先執行搜索。</string>
|
||||
<string name="readme">讀我</string>
|
||||
<string name="image_search_not_quick_search">無法添加圖片搜索為快速搜索</string>
|
||||
<string name="duplicate_quick_search">已存在相同的快速搜索,名稱為“%s”。</string>
|
||||
<string name="duplicate_name">已存在相同名稱</string>
|
||||
|
||||
@@ -169,6 +181,7 @@
|
||||
<string name="share">分享</string>
|
||||
<string name="rate">評分</string>
|
||||
<string name="similar_gallery">相似畫廊</string>
|
||||
<string name="search_cover">搜索封面</string>
|
||||
<string name="no_tags">暫無標籤</string>
|
||||
<string name="no_comments">暫無評論</string>
|
||||
<string name="no_more_comments">已顯示所有評論</string>
|
||||
@@ -237,6 +250,17 @@
|
||||
<string name="no_one_comments_gallery">暫時沒有評論</string>
|
||||
<string name="comment_successfully">評論成功</string>
|
||||
<string name="comment_failed">評論失敗</string>
|
||||
<string name="copy_comment_text">複製評論文字</string>
|
||||
<string name="vote_up">深表贊同</string>
|
||||
<string name="cancel_vote_up">不再深表贊同</string>
|
||||
<string name="vote_down">垃圾評論</string>
|
||||
<string name="cancel_vote_down">不是垃圾評論</string>
|
||||
<string name="vote_up_successfully">已深表贊同</string>
|
||||
<string name="cancel_vote_up_successfully">已不再深表贊同</string>
|
||||
<string name="vote_down_successfully">已欽定為垃圾評論</string>
|
||||
<string name="cancel_vote_down_successfully">已不再欽定為垃圾評論</string>
|
||||
<string name="vote_failed">投票失敗</string>
|
||||
<string name="check_vote_status">查看投票情況</string>
|
||||
|
||||
<!-- Gallery Previews -->
|
||||
<string name="gallery_previews">畫廊預覽</string>
|
||||
@@ -353,7 +377,11 @@
|
||||
<string name="settings_eh_filter_summary">過濾標題,上傳者,標籤和標籤組</string>
|
||||
|
||||
<string name="settings_read">閲讀</string>
|
||||
<string name="settings_read_reading_direction_title">閲讀方向</string>
|
||||
<string name="settings_read_screen_rotation">屏幕方向</string>
|
||||
<string name="settings_read_screen_rotation_default">系統默認</string>
|
||||
<string name="settings_read_screen_rotation_portrait">豎屏</string>
|
||||
<string name="settings_read_screen_rotation_landscape">橫屏</string>
|
||||
<string name="settings_read_reading_direction">閲讀方向</string>
|
||||
<string name="settings_read_reading_direction_left_to_right">從左至右</string>
|
||||
<string name="settings_read_reading_direction_right_to_Left">從右至左</string>
|
||||
<string name="settings_read_reading_direction_top_to_bottom">從上至下</string>
|
||||
@@ -378,9 +406,10 @@
|
||||
<string name="settings_download_download_location">下載路徑</string>
|
||||
<string name="settings_download_invalid_download_location">無效的下載路徑</string>
|
||||
<string name="settings_download_cant_get_download_location">無法獲取下載路徑</string>
|
||||
<string name="settings_download_pick_dir_kk">在 KitKat 中您無法把數據寫入外置 SD 卡,除非您做了奇怪的事情</string>
|
||||
<string name="settings_download_pick_dir_kk">在 KitKat 中您無法把數據寫入外置 SD 卡,除非您做了奇怪的事情。不過 <SD card>/Android/data/com.hippo.ehviewer 這個路徑比較特殊,是可以寫入的。</string>
|
||||
<string name="settings_download_pick_dir_l">Lollipop 提供了新的寫入外置 SD 卡的 API。如果您想把下載路徑設置到外置 SD 卡上,點擊“文檔”按鈕</string>
|
||||
<string name="settings_download_document">文檔</string>
|
||||
<string name="settings_download_continue">繼續</string>
|
||||
<string name="settings_download_restore_download_items">恢復下載項</string>
|
||||
<string name="settings_download_restore_download_items_summary">恢復下載目錄裏的所有下載項</string>
|
||||
<string name="settings_download_multi_thread_download">下載線程數</string>
|
||||
@@ -423,6 +452,7 @@
|
||||
<string name="settings_about_website">網站</string>
|
||||
<string name="settings_about_source">源碼</string>
|
||||
<string name="settings_about_changelog">更新日誌</string>
|
||||
<string name="settings_about_help">幫助</string>
|
||||
<string name="settings_about_license">開源許可</string>
|
||||
<string name="settings_about_license_summary">EhViewer 的誕生離不開許多開源項目</string>
|
||||
<string name="settings_about_donate">捐贈</string>
|
||||
@@ -461,6 +491,8 @@
|
||||
<string name="language_na">N/A</string>
|
||||
<string name="language_other">其他</string>
|
||||
|
||||
<string name="please_wait">請稍候</string>
|
||||
|
||||
<string name="enable">啟用</string>
|
||||
<string name="enabled">已啟用</string>
|
||||
<string name="disabled">未啟用</string>
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<string name="display_name_dialog_title">輸入暱稱</string>
|
||||
<string name="display_name">暱稱</string>
|
||||
<string name="display_name_is_empty">暱稱為空</string>
|
||||
<string name="sign_in_first">請先登入</string>
|
||||
|
||||
<string name="default_display_name">Little Hippo</string>
|
||||
|
||||
@@ -45,6 +46,7 @@
|
||||
<string name="wrong_cookie_warning">看起來您輸入的 Cookie 是錯誤的,最好檢查一下。</string>
|
||||
<string name="i_will_check_it">好的</string>
|
||||
<string name="i_dont_think_so">我沒輸錯</string>
|
||||
<string name="found_cookies">找到舊版 Cookie</string>
|
||||
|
||||
<string name="invalid_download_location">似乎下載路徑不可用。請到重新設定下載路徑。</string>
|
||||
|
||||
@@ -79,7 +81,7 @@
|
||||
<string name="error_password_cannot_empty">密碼不可為空</string>
|
||||
<string name="skip_signing_in">跳過登陸</string>
|
||||
<string name="sign_in_failed">登陸失敗</string>
|
||||
<string name="sign_in_failed_plain">這可能是網站更新導致的,也有可能是發生了奇怪的事情。您可以選擇在登陸按鈕下方通過網頁登陸或者輸入 cookie,或者跳過登陸。跳過登陸可能導致無法正常使用應用。</string>
|
||||
<string name="sign_in_failed_plain">這可能是網站更新導致的,也有可能是發生了奇怪的事情。您可以選擇在登陸按鈕下方通過網頁登陸或者輸入 cookie,或者跳過登陸。跳過登陸可能導致無法正常使用應用。如果你已經在 0.6.x 版登陸過了,請優先嚐試選擇“通過 Cookie 登陸”。</string>
|
||||
<string name="press_twice_exit">再按一次退出</string>
|
||||
<string name="content_layout_restore_tip">點選重試</string>
|
||||
<string name="write_rationale">EhViewer 將申請裝置儲存空間訪問許可權以便下載畫廊。您願意授權嗎?</string>
|
||||
@@ -110,6 +112,9 @@
|
||||
|
||||
<string name="search">搜尋</string>
|
||||
|
||||
<string name="keyword_search">關鍵字搜尋</string>
|
||||
<string name="image_search">圖片搜尋</string>
|
||||
|
||||
<string name="search_normal">普通搜尋</string>
|
||||
<string name="search_advance">高階選項</string>
|
||||
<string name="search_image">圖片搜尋</string>
|
||||
@@ -131,6 +136,12 @@
|
||||
<string name="search_sh">顯示被刪除的畫廊</string>
|
||||
<string name="search_sr">最低評分:</string>
|
||||
|
||||
<string name="select_image">選擇圖片</string>
|
||||
<string name="search_uss">使用相似搜尋</string>
|
||||
<string name="search_osc">只搜尋封面</string>
|
||||
<string name="search_se">顯示被刪除的畫廊</string>
|
||||
<string name="select_image_first">請先選擇圖片</string>
|
||||
|
||||
<string name="add_to_favourites">收藏</string>
|
||||
|
||||
<string name="quick_search">快速搜尋</string>
|
||||
@@ -143,6 +154,7 @@
|
||||
<string name="no_quick_search">這裡是快速搜尋</string>
|
||||
<string name="add_quick_search_tip">畫廊列表的狀態將被儲存為快速搜尋。如果你想儲存搜尋面板的狀態,請先執行搜尋。</string>
|
||||
<string name="readme">讀我</string>
|
||||
<string name="image_search_not_quick_search">無法新增圖片搜尋為快速搜尋</string>
|
||||
<string name="duplicate_quick_search">已存在相同的快速搜尋,名稱為“%s”。</string>
|
||||
<string name="duplicate_name">已存在相同名稱</string>
|
||||
|
||||
@@ -169,6 +181,7 @@
|
||||
<string name="share">分享</string>
|
||||
<string name="rate">評分</string>
|
||||
<string name="similar_gallery">相似畫廊</string>
|
||||
<string name="search_cover">搜尋封面</string>
|
||||
<string name="no_tags">暫無標籤</string>
|
||||
<string name="no_comments">暫無評論</string>
|
||||
<string name="no_more_comments">已顯示所有評論</string>
|
||||
@@ -237,6 +250,17 @@
|
||||
<string name="no_one_comments_gallery">暫時沒有評論</string>
|
||||
<string name="comment_successfully">評論成功</string>
|
||||
<string name="comment_failed">評論失敗</string>
|
||||
<string name="copy_comment_text">複製評論文字</string>
|
||||
<string name="vote_up">深表贊同</string>
|
||||
<string name="cancel_vote_up">不再深表贊同</string>
|
||||
<string name="vote_down">垃圾評論</string>
|
||||
<string name="cancel_vote_down">不是垃圾評論</string>
|
||||
<string name="vote_up_successfully">已深表贊同</string>
|
||||
<string name="cancel_vote_up_successfully">已不再深表贊同</string>
|
||||
<string name="vote_down_successfully">已欽定為垃圾評論</string>
|
||||
<string name="cancel_vote_down_successfully">已不再欽定為垃圾評論</string>
|
||||
<string name="vote_failed">投票失敗</string>
|
||||
<string name="check_vote_status">檢視投票情況</string>
|
||||
|
||||
<!-- Gallery Previews -->
|
||||
<string name="gallery_previews">畫廊預覽</string>
|
||||
@@ -353,7 +377,11 @@
|
||||
<string name="settings_eh_filter_summary">過濾標題,上傳者,標籤和標籤組</string>
|
||||
|
||||
<string name="settings_read">閱讀</string>
|
||||
<string name="settings_read_reading_direction_title">閱讀方向</string>
|
||||
<string name="settings_read_screen_rotation">螢幕方向</string>
|
||||
<string name="settings_read_screen_rotation_default">系統預設</string>
|
||||
<string name="settings_read_screen_rotation_portrait">豎屏</string>
|
||||
<string name="settings_read_screen_rotation_landscape">橫屏</string>
|
||||
<string name="settings_read_reading_direction">閱讀方向</string>
|
||||
<string name="settings_read_reading_direction_left_to_right">從左至右</string>
|
||||
<string name="settings_read_reading_direction_right_to_Left">從右至左</string>
|
||||
<string name="settings_read_reading_direction_top_to_bottom">從上至下</string>
|
||||
@@ -378,9 +406,10 @@
|
||||
<string name="settings_download_download_location">下載路徑</string>
|
||||
<string name="settings_download_invalid_download_location">無效的下載路徑</string>
|
||||
<string name="settings_download_cant_get_download_location">無法獲取下載路徑</string>
|
||||
<string name="settings_download_pick_dir_kk">在 KitKat 中您無法把資料寫入外接 SD 卡,除非您做了奇怪的事情</string>
|
||||
<string name="settings_download_pick_dir_kk">在 KitKat 中您無法把資料寫入外接 SD 卡,除非您做了奇怪的事情。不過 <SD card>/Android/data/com.hippo.ehviewer 這個路徑比較特殊,是可以寫入的。</string>
|
||||
<string name="settings_download_pick_dir_l">Lollipop 提供了新的寫入外接 SD 卡的 API。如果您想把下載路徑設定到外接 SD 卡上,點選“文件”按鈕</string>
|
||||
<string name="settings_download_document">文件</string>
|
||||
<string name="settings_download_continue">繼續</string>
|
||||
<string name="settings_download_restore_download_items">恢復下載項</string>
|
||||
<string name="settings_download_restore_download_items_summary">恢復下載目錄裡的所有下載項</string>
|
||||
<string name="settings_download_multi_thread_download">下載執行緒數</string>
|
||||
@@ -423,6 +452,7 @@
|
||||
<string name="settings_about_website">網站</string>
|
||||
<string name="settings_about_source">原始碼</string>
|
||||
<string name="settings_about_changelog">更新日誌</string>
|
||||
<string name="settings_about_help">幫助</string>
|
||||
<string name="settings_about_license">開源許可</string>
|
||||
<string name="settings_about_license_summary">EhViewer 的誕生離不開許多開源專案</string>
|
||||
<string name="settings_about_donate">捐贈</string>
|
||||
@@ -461,6 +491,8 @@
|
||||
<string name="language_na">N/A</string>
|
||||
<string name="language_other">其他</string>
|
||||
|
||||
<string name="please_wait">請稍候</string>
|
||||
|
||||
<string name="enable">啟用</string>
|
||||
<string name="enabled">已啟用</string>
|
||||
<string name="disabled">未啟用</string>
|
||||
|
||||
@@ -76,6 +76,18 @@
|
||||
<item>17</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="screen_rotation_entries">
|
||||
<item>@string/settings_read_screen_rotation_default</item>
|
||||
<item>@string/settings_read_screen_rotation_portrait</item>
|
||||
<item>@string/settings_read_screen_rotation_landscape</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="screen_rotation_entry_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="reading_direction_entries">
|
||||
<item>@string/settings_read_reading_direction_left_to_right</item>
|
||||
<item>@string/settings_read_reading_direction_right_to_Left</item>
|
||||
@@ -119,12 +131,11 @@
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="page_menu_entries">
|
||||
<item>@string/page_menu_refresh</item>
|
||||
<item>@string/page_menu_share</item>
|
||||
<item>@string/page_menu_save</item>
|
||||
<item>@string/page_menu_add_bookmark</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="gallery_list_menu_entries">
|
||||
|
||||
@@ -133,4 +133,8 @@
|
||||
<attr name="activity" format="string"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="UrlPreference">
|
||||
<attr name="url" format="string"/>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<resources>
|
||||
|
||||
<bool name="beta">true</bool>
|
||||
<bool name="beta">false</bool>
|
||||
<bool name="dad_spin_bars">true</bool>
|
||||
|
||||
</resources>
|
||||
@@ -78,6 +78,8 @@
|
||||
<dimen name="search_category_padding_v">16dp</dimen>
|
||||
<dimen name="search_category_title_height">48dp</dimen>
|
||||
|
||||
<dimen name="image_search_max_size">240dp</dimen>
|
||||
|
||||
<!-- Switch padding -->
|
||||
<dimen name="switch_padding">8dp</dimen>
|
||||
|
||||
|
||||
@@ -22,4 +22,9 @@
|
||||
|
||||
<item name="fragment_tag" type="id"/>
|
||||
|
||||
<item name="copy" type="id"/>
|
||||
<item name="vote_up" type="id"/>
|
||||
<item name="vote_down" type="id"/>
|
||||
<item name="check_vote_status" type="id"/>
|
||||
|
||||
</resources>
|
||||
@@ -59,6 +59,7 @@
|
||||
<string name="pd_clear_all" translatable="false">M5,13H19V11H5M3,17H17V15H3M7,7V9H21V7</string>
|
||||
<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_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>
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
<string name="display_name_dialog_title">Enter Display Name</string>
|
||||
<string name="display_name">Display name</string>
|
||||
<string name="display_name_is_empty">Display name is empty</string>
|
||||
<string name="sign_in_first">Please sign in first</string>
|
||||
|
||||
<string name="default_display_name">Little Hippo</string>
|
||||
|
||||
@@ -61,6 +62,7 @@
|
||||
<string name="wrong_cookie_warning">It seems that the cookies you entered are wrong. You\'d better check them.</string>
|
||||
<string name="i_will_check_it">I will check it</string>
|
||||
<string name="i_dont_think_so">I don\'t think so</string>
|
||||
<string name="found_cookies">Found cookies!</string>
|
||||
|
||||
<string name="invalid_download_location">It seems download location is not available. Please set it in Settings.</string>
|
||||
|
||||
@@ -121,7 +123,7 @@
|
||||
<string name="error_password_cannot_empty">Password cannot be an empty string</string>
|
||||
<string name="skip_signing_in">Skip signing in</string>
|
||||
<string name="sign_in_failed">Sign in failed</string>
|
||||
<string name="sign_in_failed_plain">Perhaps it is a mistake due to website update or something wrong happened. You may try sign in via WebView or enter cookie or skip signing in under sign in button. But you may be a "Sad Panda" after skipping signing in.</string>
|
||||
<string name="sign_in_failed_plain">Perhaps it is a mistake due to website update or something wrong happened. You may try sign in via WebView or enter cookie or skip signing in under sign in button. But you may be a "Sad Panda" after skipping signing in. Try "Sign in via cookies" first if you had signed in on 0.6.x version.</string>
|
||||
<string name="press_twice_exit">Press twice to exit</string>
|
||||
<string name="content_layout_restore_tip">Click to retry</string>
|
||||
<string name="write_rationale">EhViewer will request WRITE_EXTERNAL_STORAGE permission for downloading gallery. Do you want to grant the permission?</string>
|
||||
@@ -152,6 +154,9 @@
|
||||
|
||||
<string name="search">Search</string>
|
||||
|
||||
<string name="keyword_search">Keyword Search</string>
|
||||
<string name="image_search">Image Search</string>
|
||||
|
||||
<string name="search_normal">Normal Search</string>
|
||||
<string name="search_advance">Advance Options</string>
|
||||
<string name="search_image">Image Search</string>
|
||||
@@ -173,6 +178,12 @@
|
||||
<string name="search_sh">Show Expunged Galleries</string>
|
||||
<string name="search_sr">Minimum Rating:</string>
|
||||
|
||||
<string name="select_image">Select image</string>
|
||||
<string name="search_uss">Use similarity scan</string>
|
||||
<string name="search_osc">Only search covers</string>
|
||||
<string name="search_se">Show expunged</string>
|
||||
<string name="select_image_first">Please select image first</string>
|
||||
|
||||
<string name="add_to_favourites">Add to favourites</string>
|
||||
|
||||
<string name="quick_search">Quick search</string>
|
||||
@@ -185,6 +196,7 @@
|
||||
<string name="no_quick_search">Quick search will be shown here</string>
|
||||
<string name="add_quick_search_tip">The state of gallery list will be saved as quick search. Apply search first if you want to save the state of search panel.</string>
|
||||
<string name="readme">README</string>
|
||||
<string name="image_search_not_quick_search">Can\'t add image search as quick search</string>
|
||||
<string name="duplicate_quick_search">A duplicate quick search exists. The name is \"%s\".</string>
|
||||
<string name="duplicate_name">A duplicate name exists</string>
|
||||
|
||||
@@ -212,6 +224,7 @@
|
||||
<string name="share">Share</string>
|
||||
<string name="rate">Rate</string>
|
||||
<string name="similar_gallery">Similar</string>
|
||||
<string name="search_cover">Search Cover</string>
|
||||
<string name="no_tags">No tags</string>
|
||||
<string name="no_comments">No comments</string>
|
||||
<string name="no_more_comments">No more comments</string>
|
||||
@@ -280,6 +293,17 @@
|
||||
<string name="no_one_comments_gallery">No one comments on this gallery</string>
|
||||
<string name="comment_successfully">Comment successfully</string>
|
||||
<string name="comment_failed">Comment failed</string>
|
||||
<string name="copy_comment_text">Copy comment text</string>
|
||||
<string name="vote_up">Vote up</string>
|
||||
<string name="cancel_vote_up">Cancel up-vote</string>
|
||||
<string name="vote_down">Vote down</string>
|
||||
<string name="cancel_vote_down">Cancel down-vote</string>
|
||||
<string name="vote_up_successfully">Vote up successfully</string>
|
||||
<string name="cancel_vote_up_successfully">Cancel up-vote successfully</string>
|
||||
<string name="vote_down_successfully">Vote down successfully</string>
|
||||
<string name="cancel_vote_down_successfully">Cancel down-vote successfully</string>
|
||||
<string name="vote_failed">Vote failed</string>
|
||||
<string name="check_vote_status">Check vote status</string>
|
||||
|
||||
<!-- Gallery Previews -->
|
||||
<string name="gallery_previews">Gallery Previews</string>
|
||||
@@ -395,7 +419,11 @@
|
||||
<string name="settings_eh_filter_summary">Filter by title, uploader, tag and tag namespace</string>
|
||||
|
||||
<string name="settings_read">Read</string>
|
||||
<string name="settings_read_reading_direction_title">Reading direction</string>
|
||||
<string name="settings_read_screen_rotation">Screen orientation</string>
|
||||
<string name="settings_read_screen_rotation_default">Default</string>
|
||||
<string name="settings_read_screen_rotation_portrait">Portrait</string>
|
||||
<string name="settings_read_screen_rotation_landscape">Landscape</string>
|
||||
<string name="settings_read_reading_direction">Reading direction</string>
|
||||
<string name="settings_read_reading_direction_left_to_right">Left to right</string>
|
||||
<string name="settings_read_reading_direction_right_to_Left">Right to left</string>
|
||||
<string name="settings_read_reading_direction_top_to_bottom">Top to bottom</string>
|
||||
@@ -420,9 +448,10 @@
|
||||
<string name="settings_download_download_location">Download location</string>
|
||||
<string name="settings_download_invalid_download_location">Invalid download location</string>
|
||||
<string name="settings_download_cant_get_download_location">Can\'t get download location</string>
|
||||
<string name="settings_download_pick_dir_kk">You can\'t write any kind of data on your external SD card in Android 4.4+ unless you have hacked it</string>
|
||||
<string name="settings_download_pick_dir_kk">You can\'t write any kind of data on your external SD card in Android 4.4+ unless you have hacked it. But <SD card>/Android/data/com.hippo.ehviewer is a special, it is writable.</string>
|
||||
<string name="settings_download_pick_dir_l">Android 5.0+ provides new API to write on external SD card. Click the \"DOCUMENT\" button if you want to set download location to SD card</string>
|
||||
<string name="settings_download_document">Document</string>
|
||||
<string name="settings_download_continue">Continue</string>
|
||||
<string name="settings_download_multi_thread_download">Multi thread download</string>
|
||||
<string name="settings_download_multi_thread_download_summary">Up to %s images</string>
|
||||
<string name="settings_download_preload_image">Preload image</string>
|
||||
@@ -463,13 +492,10 @@
|
||||
<string name="settings_about_author">Author</string>
|
||||
<string name="settings_about_author_summary" translatable="false">Hippo <ehviewersu$gmail.com></string>
|
||||
<string name="settings_about_google_plus">Google+ Community</string>
|
||||
<string name="settings_about_google_plus_summary" translatable="false">https://plus.google.com/communities/103823982034655188459</string>
|
||||
<string name="settings_about_website">Website</string>
|
||||
<string name="settings_about_website_summary" translatable="false">http://www.ehviewer.com</string>
|
||||
<string name="settings_about_source">Source</string>
|
||||
<string name="settings_about_source_summary" translatable="false">https://github.com/seven332/EhViewer</string>
|
||||
<string name="settings_about_changelog">Changelog</string>
|
||||
<string name="settings_about_changelog_summary" translatable="false">http://www.ehviewer.com/changlog</string>
|
||||
<string name="settings_about_help">Help</string>
|
||||
<string name="settings_about_license">License</string>
|
||||
<string name="settings_about_license_summary">EhViewer is made possible by many open source projects</string>
|
||||
<string name="settings_about_donate">Donate</string>
|
||||
@@ -521,6 +547,8 @@
|
||||
<string name="language_na">N/A</string>
|
||||
<string name="language_other">Other</string>
|
||||
|
||||
<string name="please_wait">Pleas wait</string>
|
||||
|
||||
<!-- License -->
|
||||
<string name="license">License</string>
|
||||
|
||||
|
||||
@@ -23,25 +23,30 @@
|
||||
android:key="author"
|
||||
android:title="@string/settings_about_author"/>
|
||||
|
||||
<Preference
|
||||
<com.hippo.preference.UrlPreference
|
||||
android:key="google_plus"
|
||||
android:title="@string/settings_about_google_plus"
|
||||
android:summary="@string/settings_about_google_plus_summary"/>
|
||||
app:url="https://plus.google.com/communities/103823982034655188459"/>
|
||||
|
||||
<Preference
|
||||
<com.hippo.preference.UrlPreference
|
||||
android:key="website"
|
||||
android:title="@string/settings_about_website"
|
||||
android:summary="@string/settings_about_website_summary"/>
|
||||
app:url="http://www.ehviewer.com"/>
|
||||
|
||||
<Preference
|
||||
<com.hippo.preference.UrlPreference
|
||||
android:key="source"
|
||||
android:title="@string/settings_about_source"
|
||||
android:summary="@string/settings_about_source_summary"/>
|
||||
app:url="https://github.com/seven332/EhViewer"/>
|
||||
|
||||
<Preference
|
||||
<com.hippo.preference.UrlPreference
|
||||
android:key="changelog"
|
||||
android:title="@string/settings_about_changelog"
|
||||
android:summary="@string/settings_about_changelog_summary"/>
|
||||
app:url="http://www.ehviewer.com/changelog"/>
|
||||
|
||||
<com.hippo.preference.UrlPreference
|
||||
android:key="help"
|
||||
android:title="@string/settings_about_help"
|
||||
app:url="http://www.ehviewer.com/help"/>
|
||||
|
||||
<com.hippo.preference.ActivityPreference
|
||||
android:key="license"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<full-backup-content>
|
||||
|
||||
<include domain="database" path="eh.db"/>
|
||||
<include domain="database" path="search_database.db"/>
|
||||
|
||||
</full-backup-content>
|
||||
@@ -45,7 +45,7 @@
|
||||
android:summary="@string/settings_download_download_origin_image_summary"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
<Preference
|
||||
<com.hippo.ehviewer.preference.RestoreDownloadPreference
|
||||
android:key="restore_download_items"
|
||||
android:title="@string/settings_download_restore_download_items"
|
||||
android:summary="@string/settings_download_restore_download_items_summary"/>
|
||||
|
||||
@@ -19,9 +19,17 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.hippo.preference.ListPreference
|
||||
android:key="screen_rotation"
|
||||
android:title="@string/settings_read_screen_rotation"
|
||||
android:summary="%s"
|
||||
app:entries="@array/screen_rotation_entries"
|
||||
app:entryValues="@array/screen_rotation_entry_values"
|
||||
android:defaultValue="0"/>
|
||||
|
||||
<com.hippo.preference.ListPreference
|
||||
android:key="reading_direction"
|
||||
android:title="@string/settings_read_reading_direction_title"
|
||||
android:title="@string/settings_read_reading_direction"
|
||||
android:summary="%s"
|
||||
app:entries="@array/reading_direction_entries"
|
||||
app:entryValues="@array/reading_direction_entry_values"
|
||||
|
||||
@@ -23,7 +23,7 @@ task executeDaoGenerator(type:JavaExec) {
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile('de.greenrobot:greendao-generator:2.0.0')
|
||||
compile('de.greenrobot:greendao-generator:2.1.0')
|
||||
compile('org.jboss.forge.roaster:roaster-api:2.18.2.Final')
|
||||
compile('org.jboss.forge.roaster:roaster-jdt:2.18.2.Final')
|
||||
}
|
||||
+1
-1
Submodule unifile updated: 704956a6f5...e020c4cb33.
+1
-1
Submodule yorozuya updated: 2e64e10ea3...f33ccd94c2.
Reference in new issue
Block a user