mirror of
https://github.com/seven332/EhViewer
synced 2026-11-28 01:58:06 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba6d41b91f | ||
|
|
6a9e0198a2 | ||
|
|
92f716170c | ||
|
|
d72f686d5a | ||
|
|
28eade9451 | ||
|
|
7b95bc804a | ||
|
|
47c9d48787 | ||
|
|
8a7adbe838 | ||
|
|
0248fd4e02 | ||
|
|
1cd5f7bbf7 | ||
|
|
db893b899d |
No files matched your search
@@ -1,3 +1,5 @@
|
||||
# DEPRECATED
|
||||
|
||||
[](https://t.me/ehviewer)
|
||||
|
||||
# EhViewer
|
||||
|
||||
+3
-3
@@ -12,8 +12,8 @@ android {
|
||||
applicationId "com.hippo.ehviewer"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 103
|
||||
versionName "1.7.2"
|
||||
versionCode 104
|
||||
versionName "1.7.3"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW",
|
||||
"es", "ja", "ko", "fr", "de", "th"
|
||||
@@ -101,7 +101,7 @@ dependencies {
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.3'
|
||||
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
||||
implementation 'org.greenrobot:greendao:2.2.1'
|
||||
implementation 'org.jsoup:jsoup:1.11.3'
|
||||
implementation 'org.jsoup:jsoup:1.12.1'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.robolectric:robolectric:4.2.1'
|
||||
testImplementation 'org.jooq:joor:0.9.6'
|
||||
|
||||
@@ -44,10 +44,11 @@ import com.hippo.ehviewer.dao.QuickSearchDao;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.SqlUtils;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.ObjectUtils;
|
||||
import com.hippo.yorozuya.collect.SparseJLArray;
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.query.CloseableListIterator;
|
||||
import de.greenrobot.dao.query.LazyList;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -645,30 +646,64 @@ public class EhDB {
|
||||
sDaoSession.getFilterDao().update(filter);
|
||||
}
|
||||
|
||||
public static synchronized boolean exportDB(Context context, File file) {
|
||||
File dbFile = context.getDatabasePath("eh.db");
|
||||
if (null == dbFile || !dbFile.isFile()) {
|
||||
return false;
|
||||
}
|
||||
if (null == file || !FileUtils.ensureFile(file)) {
|
||||
return false;
|
||||
}
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
is = new FileInputStream(dbFile);
|
||||
os = new FileOutputStream(file);
|
||||
IOUtils.copy(is, os);
|
||||
return true;
|
||||
private static <T> boolean copyDao(AbstractDao<T, ?> from, AbstractDao<T, ?> to) {
|
||||
try (CloseableListIterator<T> iterator = from.queryBuilder().listIterator()) {
|
||||
while (iterator.hasNext()) {
|
||||
to.insert(iterator.next());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static synchronized boolean exportDB(Context context, File file) {
|
||||
final String ehExportName = "eh.export.db";
|
||||
|
||||
// Delete old export db
|
||||
context.deleteDatabase(ehExportName);
|
||||
|
||||
DBOpenHelper helper = new DBOpenHelper(context.getApplicationContext(), ehExportName, null);
|
||||
|
||||
try {
|
||||
// Copy data to a export db
|
||||
try (SQLiteDatabase db = helper.getWritableDatabase()) {
|
||||
DaoMaster daoMaster = new DaoMaster(db);
|
||||
DaoSession exportSession = daoMaster.newSession();
|
||||
if (!copyDao(sDaoSession.getDownloadsDao(), exportSession.getDownloadsDao())) return false;
|
||||
if (!copyDao(sDaoSession.getDownloadLabelDao(), exportSession.getDownloadLabelDao())) return false;
|
||||
if (!copyDao(sDaoSession.getDownloadDirnameDao(), exportSession.getDownloadDirnameDao())) return false;
|
||||
if (!copyDao(sDaoSession.getHistoryDao(), exportSession.getHistoryDao())) return false;
|
||||
if (!copyDao(sDaoSession.getQuickSearchDao(), exportSession.getQuickSearchDao())) return false;
|
||||
if (!copyDao(sDaoSession.getLocalFavoritesDao(), exportSession.getLocalFavoritesDao())) return false;
|
||||
if (!copyDao(sDaoSession.getBookmarksBao(), exportSession.getBookmarksBao())) return false;
|
||||
if (!copyDao(sDaoSession.getFilterDao(), exportSession.getFilterDao())) return false;
|
||||
}
|
||||
|
||||
// Copy export db to data dir
|
||||
File dbFile = context.getDatabasePath(ehExportName);
|
||||
if (dbFile == null || !dbFile.isFile()) {
|
||||
return false;
|
||||
}
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
is = new FileInputStream(dbFile);
|
||||
os = new FileOutputStream(file);
|
||||
IOUtils.copy(is, os);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
// Delete failed file
|
||||
file.delete();
|
||||
return false;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
IOUtils.closeQuietly(os);
|
||||
context.deleteDatabase(ehExportName);
|
||||
}
|
||||
// Delete failed file
|
||||
file.delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,6 +77,8 @@ public class EhEngine {
|
||||
private static final String SAD_PANDA_TYPE = "image/gif";
|
||||
private static final String SAD_PANDA_LENGTH = "9615";
|
||||
|
||||
private static final String KOKOMADE_URL = "https://exhentai.org/img/kokomade.jpg";
|
||||
|
||||
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");
|
||||
|
||||
@@ -101,6 +103,11 @@ public class EhEngine {
|
||||
throw new EhException("Sad Panda");
|
||||
}
|
||||
|
||||
// Check kokomade
|
||||
if (body != null && body.contains(KOKOMADE_URL)) {
|
||||
throw new EhException("今回はここまで\n\n" + GetText.getString(R.string.kokomade_tip));
|
||||
}
|
||||
|
||||
if (e instanceof ParseException) {
|
||||
if (body != null && !body.contains("<")) {
|
||||
throw new EhException(body);
|
||||
|
||||
@@ -272,7 +272,10 @@ public class GalleryDetailParser {
|
||||
if (key.startsWith("Posted")) {
|
||||
gd.posted = value;
|
||||
} else if (key.startsWith("Parent")) {
|
||||
gd.parent = value;
|
||||
Element a = es.get(1).children().first();
|
||||
if (a != null) {
|
||||
gd.parent = a.attr("href");
|
||||
}
|
||||
} else if (key.startsWith("Visible")) {
|
||||
gd.visible = value;
|
||||
} else if (key.startsWith("Language")) {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2019 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.preference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.GetText;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import java.io.File;
|
||||
|
||||
public class ExportDataPreference extends TaskPreference {
|
||||
|
||||
public ExportDataPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ExportDataPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ExportDataPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Task onCreateTask() {
|
||||
return new ExportDataTask(getContext());
|
||||
}
|
||||
|
||||
private static class ExportDataTask extends Task {
|
||||
|
||||
public ExportDataTask(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doInBackground(Void... voids) {
|
||||
File dir = AppConfig.getExternalDataDir();
|
||||
if (dir != null) {
|
||||
File file = new File(dir, ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".db");
|
||||
if (EhDB.exportDB(getApplication(), file)) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Object o) {
|
||||
Toast.makeText(getApplication(),
|
||||
(o instanceof File)
|
||||
? GetText.getString(R.string.settings_advanced_export_data_to, ((File) o).getPath())
|
||||
: GetText.getString(R.string.settings_advanced_export_data_failed),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
super.onPostExecute(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,10 @@ public abstract class TaskPreference extends DialogPreference {
|
||||
mApplication = (EhApplication) context.getApplicationContext();
|
||||
}
|
||||
|
||||
public EhApplication getApplication() {
|
||||
return mApplication;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TaskPreference getPreference() {
|
||||
return mPreference;
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.hippo.yorozuya.Utilities;
|
||||
import com.hippo.yorozuya.collect.SparseJLArray;
|
||||
import com.hippo.yorozuya.thread.PriorityThread;
|
||||
import com.hippo.yorozuya.thread.PriorityThreadFactory;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -1172,7 +1173,6 @@ public final class SpiderQueen implements Runnable {
|
||||
}
|
||||
|
||||
// Download image
|
||||
OutputStreamPipe pipe = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
if (DEBUG_LOG) {
|
||||
@@ -1208,49 +1208,93 @@ public final class SpiderQueen implements Runnable {
|
||||
extension = GalleryProvider2.SUPPORT_IMAGE_EXTENSIONS[0];
|
||||
}
|
||||
|
||||
// Get out put pipe
|
||||
pipe = mSpiderDen.openOutputStreamPipe(index, extension);
|
||||
if (null == pipe) {
|
||||
// Can't get pipe
|
||||
error = GetText.getString(R.string.error_write_failed);
|
||||
response.close();
|
||||
break;
|
||||
}
|
||||
|
||||
long contentLength = responseBody.contentLength();
|
||||
is = responseBody.byteStream();
|
||||
pipe.obtain();
|
||||
OutputStream os = pipe.open();
|
||||
|
||||
final byte data[] = new byte[1024 * 4];
|
||||
long receivedSize = 0;
|
||||
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
int bytesRead = is.read(data);
|
||||
if (bytesRead == -1) {
|
||||
OutputStreamPipe osPipe = null;
|
||||
try {
|
||||
// Get out put pipe
|
||||
osPipe = mSpiderDen.openOutputStreamPipe(index, extension);
|
||||
if (osPipe == null) {
|
||||
// Can't get pipe
|
||||
error = GetText.getString(R.string.error_write_failed);
|
||||
response.close();
|
||||
break;
|
||||
}
|
||||
os.write(data, 0, bytesRead);
|
||||
receivedSize += bytesRead;
|
||||
// Update page percent
|
||||
if (contentLength > 0) {
|
||||
mPagePercentMap.put(index, (float) receivedSize / contentLength);
|
||||
}
|
||||
// Notify listener
|
||||
notifyPageDownload(index, contentLength, receivedSize, bytesRead);
|
||||
}
|
||||
os.flush();
|
||||
|
||||
// check download size
|
||||
if (contentLength >= 0) {
|
||||
if (receivedSize < contentLength) {
|
||||
Log.e(TAG, "Can't download all of image data");
|
||||
error = "Incomplete";
|
||||
long contentLength = responseBody.contentLength();
|
||||
is = responseBody.byteStream();
|
||||
osPipe.obtain();
|
||||
OutputStream os = osPipe.open();
|
||||
|
||||
final byte[] data = new byte[1024 * 4];
|
||||
long receivedSize = 0;
|
||||
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
int bytesRead = is.read(data);
|
||||
if (bytesRead == -1) {
|
||||
response.close();
|
||||
break;
|
||||
}
|
||||
os.write(data, 0, bytesRead);
|
||||
receivedSize += bytesRead;
|
||||
// Update page percent
|
||||
if (contentLength > 0) {
|
||||
mPagePercentMap.put(index, (float) receivedSize / contentLength);
|
||||
}
|
||||
// Notify listener
|
||||
notifyPageDownload(index, contentLength, receivedSize, bytesRead);
|
||||
}
|
||||
os.flush();
|
||||
|
||||
// check download size
|
||||
if (contentLength >= 0) {
|
||||
if (receivedSize < contentLength) {
|
||||
Log.e(TAG, "Can't download all of image data");
|
||||
error = "Incomplete";
|
||||
forceHtml = true;
|
||||
continue;
|
||||
} else if (receivedSize > contentLength) {
|
||||
Log.w(TAG, "Received data is more than contentLength");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (osPipe != null) {
|
||||
osPipe.close();
|
||||
osPipe.release();
|
||||
}
|
||||
}
|
||||
|
||||
InputStreamPipe isPipe = null;
|
||||
try {
|
||||
// Get InputStreamPipe
|
||||
isPipe = mSpiderDen.openInputStreamPipe(index);
|
||||
if (isPipe == null) {
|
||||
// Can't get pipe
|
||||
error = GetText.getString(R.string.error_reading_failed);
|
||||
break;
|
||||
}
|
||||
|
||||
// Check plain txt
|
||||
isPipe.obtain();
|
||||
InputStream inputStream = new BufferedInputStream(isPipe.open());
|
||||
boolean isPlainTxt = true;
|
||||
for (;;) {
|
||||
int b = inputStream.read();
|
||||
if (b == -1) {
|
||||
break;
|
||||
}
|
||||
if (b > 126) {
|
||||
isPlainTxt = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isPlainTxt) {
|
||||
error = GetText.getString(R.string.error_reading_failed);
|
||||
forceHtml = true;
|
||||
continue;
|
||||
} else if (receivedSize > contentLength) {
|
||||
Log.w(TAG, "Received data is more than contentLength");
|
||||
}
|
||||
} finally {
|
||||
if (isPipe != null) {
|
||||
isPipe.close();
|
||||
isPipe.release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1274,10 +1318,6 @@ public final class SpiderQueen implements Runnable {
|
||||
forceHtml = true;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
if (null != pipe) {
|
||||
pipe.close();
|
||||
pipe.release();
|
||||
}
|
||||
|
||||
if (DEBUG_LOG) {
|
||||
Log.d(TAG, "End download image " + index);
|
||||
|
||||
@@ -25,11 +25,14 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.hippo.android.resource.AttrResources;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.widget.DirExplorer;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import java.io.File;
|
||||
|
||||
public class DirPickerActivity extends ToolbarActivity
|
||||
@@ -46,6 +49,7 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
private TextView mPath;
|
||||
@Nullable
|
||||
private DirExplorer mDirExplorer;
|
||||
private View mDefault;
|
||||
@Nullable
|
||||
private View mOk;
|
||||
|
||||
@@ -55,9 +59,10 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
setContentView(R.layout.activity_dir_picker);
|
||||
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
|
||||
|
||||
mPath = (TextView) ViewUtils.$$(this, R.id.path);
|
||||
mDirExplorer = (DirExplorer) ViewUtils.$$(this, R.id.dir_explorer);
|
||||
mOk = ViewUtils.$$(this, R.id.ok);
|
||||
mPath = findViewById(R.id.path);
|
||||
mDirExplorer = findViewById(R.id.dir_explorer);
|
||||
mDefault = findViewById(R.id.preset);
|
||||
mOk = findViewById(R.id.ok);
|
||||
|
||||
File file;
|
||||
if (null == savedInstanceState) {
|
||||
@@ -71,6 +76,7 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
|
||||
Ripple.addRipple(mOk, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme));
|
||||
|
||||
mDefault.setOnClickListener(this);
|
||||
mOk.setOnClickListener(this);
|
||||
|
||||
mPath.setText(mDirExplorer.getCurrentFile().getPath());
|
||||
@@ -126,7 +132,31 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View v) {
|
||||
if (mOk == v) {
|
||||
if (mDefault == v) {
|
||||
File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(this, null);
|
||||
File[] dirs = new File[externalFilesDirs.length + 1];
|
||||
dirs[0] = AppConfig.getDefaultDownloadDir();
|
||||
for (int i = 0; i < externalFilesDirs.length; i++) {
|
||||
dirs[i + 1] = new File(externalFilesDirs[i], "download");
|
||||
}
|
||||
|
||||
CharSequence[] items = new CharSequence[dirs.length];
|
||||
items[0] = getString(R.string.default_directory);
|
||||
for (int i = 1; i < items.length; i++) {
|
||||
items[i] = getString(R.string.application_file_directory, i);
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(this).setItems(items, (dialog, which) -> {
|
||||
File dir = dirs[which];
|
||||
if (!FileUtils.ensureDirectory(dir)) {
|
||||
Toast.makeText(DirPickerActivity.this, R.string.directory_not_writable, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (mDirExplorer != null) {
|
||||
mDirExplorer.setCurrentFile(dir);
|
||||
}
|
||||
}).show();
|
||||
} else if (mOk == v) {
|
||||
if (null == mDirExplorer) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ public class AdvancedFragment extends PreferenceFragment
|
||||
private static final String KEY_DUMP_LOGCAT = "dump_logcat";
|
||||
private static final String KEY_CLEAR_MEMORY_CACHE = "clear_memory_cache";
|
||||
private static final String KEY_APP_LANGUAGE = "app_language";
|
||||
private static final String KEY_EXPORT_DATA = "export_data";
|
||||
private static final String KEY_IMPORT_DATA = "import_data";
|
||||
|
||||
@Override
|
||||
@@ -51,12 +50,10 @@ public class AdvancedFragment extends PreferenceFragment
|
||||
Preference dumpLogcat = findPreference(KEY_DUMP_LOGCAT);
|
||||
Preference clearMemoryCache = findPreference(KEY_CLEAR_MEMORY_CACHE);
|
||||
Preference appLanguage = findPreference(KEY_APP_LANGUAGE);
|
||||
Preference exportData = findPreference(KEY_EXPORT_DATA);
|
||||
Preference importData = findPreference(KEY_IMPORT_DATA);
|
||||
|
||||
dumpLogcat.setOnPreferenceClickListener(this);
|
||||
clearMemoryCache.setOnPreferenceClickListener(this);
|
||||
exportData.setOnPreferenceClickListener(this);
|
||||
importData.setOnPreferenceClickListener(this);
|
||||
|
||||
appLanguage.setOnPreferenceChangeListener(this);
|
||||
@@ -88,18 +85,6 @@ public class AdvancedFragment extends PreferenceFragment
|
||||
} else if (KEY_CLEAR_MEMORY_CACHE.equals(key)) {
|
||||
((EhApplication) getActivity().getApplication()).clearMemoryCache();
|
||||
Runtime.getRuntime().gc();
|
||||
} else if (KEY_EXPORT_DATA.equals(key)) {
|
||||
File dir = AppConfig.getExternalDataDir();
|
||||
if (dir != null) {
|
||||
File file = new File(dir, ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".db");
|
||||
if (EhDB.exportDB(getActivity(), file)) {
|
||||
Toast.makeText(getActivity(),
|
||||
getString(R.string.settings_advanced_export_data_to, file.getPath()), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Toast.makeText(getActivity(),R.string.settings_advanced_export_data_failed, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
} else if (KEY_IMPORT_DATA.equals(key)) {
|
||||
importData(getActivity());
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
|
||||
@@ -116,6 +116,7 @@ import java.io.OutputStream;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.List;
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
public class GalleryDetailScene extends BaseScene implements View.OnClickListener,
|
||||
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener,
|
||||
@@ -1875,6 +1876,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
FileUtils.sanitizeFilename(name + ".torrent"));
|
||||
r.allowScanningByMediaScanner();
|
||||
r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
r.addRequestHeader("Cookie", EhApplication.getEhCookieStore(context).getCookieHeader(HttpUrl.get(url)));
|
||||
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
if (dm != null) {
|
||||
try {
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.UrlOpener;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
@@ -51,6 +52,9 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
public static final String KEY_KEYS = "keys";
|
||||
public static final String KEY_VALUES = "values";
|
||||
|
||||
private static final int INDEX_URL = 3;
|
||||
private static final int INDEX_PARENT = 10;
|
||||
|
||||
/*---------------
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@@ -199,15 +203,19 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
Context context = getContext2();
|
||||
if (null != context && 0 != position && null != mValues) {
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setPrimaryClip(ClipData.newPlainText(null, mValues.get(position)));
|
||||
if (position == INDEX_PARENT) {
|
||||
UrlOpener.openUrl(context, mValues.get(position), true);
|
||||
} else {
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setPrimaryClip(ClipData.newPlainText(null, mValues.get(position)));
|
||||
|
||||
if (position == 3) {
|
||||
// Save it to avoid detect the gallery
|
||||
Settings.putClipboardTextHashCode(mValues.get(position).hashCode());
|
||||
if (position == INDEX_URL) {
|
||||
// Save it to avoid detect the gallery
|
||||
Settings.putClipboardTextHashCode(mValues.get(position).hashCode());
|
||||
}
|
||||
|
||||
showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
|
||||
}
|
||||
|
||||
showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -85,6 +85,19 @@ public class CookieRepository implements CookieJar {
|
||||
}
|
||||
}
|
||||
|
||||
public String getCookieHeader(HttpUrl url) {
|
||||
List<Cookie> cookies = getCookies(url);
|
||||
StringBuilder cookieHeader = new StringBuilder();
|
||||
for (int i = 0, size = cookies.size(); i < size; i++) {
|
||||
if (i > 0) {
|
||||
cookieHeader.append("; ");
|
||||
}
|
||||
Cookie cookie = cookies.get(i);
|
||||
cookieHeader.append(cookie.name()).append('=').append(cookie.value());
|
||||
}
|
||||
return cookieHeader.toString();
|
||||
}
|
||||
|
||||
public synchronized List<Cookie> getCookies(HttpUrl url) {
|
||||
List<Cookie> accepted = new ArrayList<>();
|
||||
List<Cookie> expired = new ArrayList<>();
|
||||
|
||||
@@ -38,13 +38,27 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ok"
|
||||
style="?attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:text="@android:string/ok"
|
||||
android:textColor="?attr/colorPrimary"/>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/preset"
|
||||
style="?attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:text="@string/preset"
|
||||
android:textColor="?attr/colorAccent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ok"
|
||||
style="?attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:text="@android:string/ok"
|
||||
android:textColor="?attr/colorPrimary"/>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
@@ -92,6 +92,9 @@
|
||||
<string name="error_invalid_number">非法数字</string>
|
||||
<string name="error_please_login_first">请先登陆</string>
|
||||
<string name="error_empty_html">页面内容为空</string>
|
||||
<string name="error_cant_get_image">无法获取图片</string>
|
||||
|
||||
<string name="kokomade_tip">设置->Eh->画廊站点->e-hentai</string>
|
||||
|
||||
<string name="app_waring">本应用中内容来自互联网,部分内容可能对您的生理及心理造成难以恢复的伤害。本应用作者不会对由本应用造成的任何后果负责。\n\n未成年人应在监护人指导下使用本应用。</string>
|
||||
<string name="error_username_cannot_empty">用户名不可为空</string>
|
||||
@@ -396,6 +399,11 @@
|
||||
<string name="invalid_host">无效的 host</string>
|
||||
<string name="invalid_ip">无效的 IP</string>
|
||||
|
||||
<!-- DirPickerActivity -->
|
||||
<string name="preset">预设</string>
|
||||
<string name="default_directory">默认目录</string>
|
||||
<string name="application_file_directory">应用文件目录 %d (应用卸载后会被删除)</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">第 %d 页</string>
|
||||
<string name="page_menu_refresh">@string/refresh</string>
|
||||
|
||||
@@ -92,6 +92,9 @@
|
||||
<string name="error_invalid_number">非法數字</string>
|
||||
<string name="error_please_login_first">請先登陸</string>
|
||||
<string name="error_empty_html">頁面內容為空</string>
|
||||
<string name="error_cant_get_image">無法獲取圖片</string>
|
||||
|
||||
<string name="kokomade_tip">設置->Eh->畫廊站點->e-hentai</string>
|
||||
|
||||
<string name="app_waring">本應用中內容來自互聯網,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用作者不會對由本應用造成的任何後果負責。\n\n未成年人應在監護人指導下使用本應用。</string>
|
||||
<string name="error_username_cannot_empty">用户名不可為空</string>
|
||||
@@ -396,6 +399,11 @@
|
||||
<string name="invalid_host">無效的 host</string>
|
||||
<string name="invalid_ip">無效的 IP</string>
|
||||
|
||||
<!-- DirPickerActivity -->
|
||||
<string name="preset">預設</string>
|
||||
<string name="default_directory">默認目錄</string>
|
||||
<string name="application_file_directory">應用文件目錄 %d (應用卸載後會被刪除)</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">第 %d 頁</string>
|
||||
<string name="page_menu_refresh">@string/refresh</string>
|
||||
|
||||
@@ -92,6 +92,9 @@
|
||||
<string name="error_invalid_number">無效的數字</string>
|
||||
<string name="error_please_login_first">請先登陸</string>
|
||||
<string name="error_empty_html">頁面內容為空</string>
|
||||
<string name="error_cant_get_image">無法獲取圖片</string>
|
||||
|
||||
<string name="kokomade_tip">設定->Eh->圖庫站台->e-hentai</string>
|
||||
|
||||
<string name="app_waring">本應用程式中內容來自網際網路,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用程式的作者不會對由其所造成的任何影響負責。\n\n未成年人應在監護人指導下使用本應用程式。</string>
|
||||
<string name="error_username_cannot_empty">使用者名稱欄位不能為空</string>
|
||||
@@ -395,6 +398,11 @@
|
||||
<string name="invalid_host">無效的 host</string>
|
||||
<string name="invalid_ip">無效的 IP</string>
|
||||
|
||||
<!-- DirPickerActivity -->
|
||||
<string name="preset">預設</string>
|
||||
<string name="default_directory">預設目錄</string>
|
||||
<string name="application_file_directory">應用檔案目錄 %d (應用解除安裝後會被刪除)</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">第 %d 頁</string>
|
||||
<string name="page_menu_refresh">@string/refresh</string>
|
||||
|
||||
@@ -134,6 +134,9 @@
|
||||
<string name="error_invalid_number">Invalid number</string>
|
||||
<string name="error_please_login_first">Please login first</string>
|
||||
<string name="error_empty_html">Empty page</string>
|
||||
<string name="error_cant_get_image">Can\'t get image</string>
|
||||
|
||||
<string name="kokomade_tip">Settings->Eh->Gallery Site->e-hentai</string>
|
||||
|
||||
<string name="app_waring">The content of this application is from the Internet. Some of it may do physical or mental harm to you. You have learnt the risks above and would like to undertake them.</string>
|
||||
<string name="error_username_cannot_empty">Username cannot be an empty string</string>
|
||||
@@ -442,6 +445,11 @@
|
||||
<string name="invalid_host">Invalid host</string>
|
||||
<string name="invalid_ip">Invalid IP</string>
|
||||
|
||||
<!-- DirPickerActivity -->
|
||||
<string name="preset">Preset</string>
|
||||
<string name="default_directory">Default directory</string>
|
||||
<string name="application_file_directory">App file directory %d (it will be remove after uninstalling the app)</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">Page %d</string>
|
||||
<string name="page_menu_refresh">@string/refresh</string>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
android:summary="@string/settings_advanced_custom_hosts_summary"
|
||||
app:activity="com.hippo.ehviewer.ui.HostsActivity"/>
|
||||
|
||||
<Preference
|
||||
<com.hippo.ehviewer.preference.ExportDataPreference
|
||||
android:key="export_data"
|
||||
android:title="@string/settings_advanced_export_data"
|
||||
android:summary="@string/settings_advanced_export_data_summary"/>
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ buildscript {
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||
classpath 'com.google.gms:google-services:4.2.0'
|
||||
classpath 'com.android.tools.build:gradle:3.4.2'
|
||||
classpath 'com.google.gms:google-services:4.3.0'
|
||||
classpath 'io.fabric.tools:gradle:1.27.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
|
||||
Reference in new issue
Block a user