diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.kt b/app/src/main/java/com/hippo/ehviewer/EhApplication.kt index 2411dd0cb..3930b0ed4 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhApplication.kt +++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.kt @@ -195,8 +195,6 @@ class EhApplication : Application(), DefaultLifecycleObserver, ImageLoaderFactor } } - val hosts by lazy { Hosts(application, "hosts.db") } - val favouriteStatusRouter by lazy { FavouriteStatusRouter() } val readerPreferences by lazy { ReaderPreferences(AndroidPreferenceStore(application)) } diff --git a/app/src/main/java/com/hippo/ehviewer/Hosts.java b/app/src/main/java/com/hippo/ehviewer/Hosts.java index 45463e409..a581b83b2 100644 --- a/app/src/main/java/com/hippo/ehviewer/Hosts.java +++ b/app/src/main/java/com/hippo/ehviewer/Hosts.java @@ -20,44 +20,13 @@ package com.hippo.ehviewer; * Created by Hippo on 2018/3/21. */ -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.util.Pair; - import androidx.annotation.Nullable; -import com.hippo.ehviewer.database.MSQLiteBuilder; -import com.hippo.ehviewer.util.SqlUtils; - import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; public class Hosts { - private static final int VERSION_1 = 1; - private static final String TABLE_HOSTS = "HOSTS"; - private static final String COLUMN_HOST = "HOST"; - private static final String COLUMN_IP = "IP"; - - private static final int DB_VERSION = VERSION_1; - - private final SQLiteDatabase db; - - public Hosts(Context context, String name) { - SQLiteOpenHelper helper = new MSQLiteBuilder() - .version(VERSION_1) - .createTable(TABLE_HOSTS) - .insertColumn(TABLE_HOSTS, COLUMN_HOST, String.class) - .insertColumn(TABLE_HOSTS, COLUMN_IP, String.class) - .build(context, name, DB_VERSION); - db = helper.getWritableDatabase(); - } - @Nullable public static InetAddress toInetAddress(String host, String ip) { if (!isValidHost(host)) { @@ -116,22 +85,6 @@ public class Hosts { return labelLength >= 1 && labelLength <= 63; } - /** - * Returns true if ips are valid. - */ - public static boolean isValidIp(String ips) { - if (ips == null) { - return false; - } - String[] list = ips.split("\\+"); - for (String ip : list) { - if (parseV4(ip) == null && parseV6(ip) == null) { - return false; - } - } - return true; - } - // org.xbill.DNS.Address.parseV4 @Nullable private static byte[] parseV4(String s) { @@ -268,76 +221,4 @@ public class Hosts { return data; } - - /** - * Gets a InetAddress with the host. - */ - @Nullable - public List get(String host) { - if (!isValidHost(host)) { - return null; - } - try (Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_HOSTS + " WHERE " + COLUMN_HOST + " = ?;", new String[]{host})) { - if (cursor.moveToNext()) { - String[] ips = SqlUtils.getString(cursor, COLUMN_IP, null).split("\\+"); - List addresses = new ArrayList<>(); - for (String ip : ips) { - addresses.add(toInetAddress(host, ip)); - } - return addresses; - } else { - return null; - } - } - } - - public boolean contains(String host) { - try (Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_HOSTS + " WHERE " + COLUMN_HOST + " = ?;", new String[]{host})) { - return cursor.moveToNext(); - } - } - - /** - * Puts the host-ip pair into this hosts. - */ - public boolean put(String host, String ip) { - if (!isValidHost(host) || !isValidIp(ip)) { - return false; - } - - ContentValues values = new ContentValues(); - values.put(COLUMN_HOST, host); - values.put(COLUMN_IP, ip); - - if (contains(host)) { - db.update(TABLE_HOSTS, values, COLUMN_HOST + " = ?", new String[]{host}); - } else { - db.insert(TABLE_HOSTS, null, values); - } - - return true; - } - - /** - * Puts delete the entry with the host. - */ - public void delete(String host) { - db.delete(TABLE_HOSTS, COLUMN_HOST + " = ?", new String[]{host}); - } - - /** - * Get all data from this host. - */ - public List> getAll() { - List> result = new ArrayList<>(); - - try (Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_HOSTS + ";", null)) { - while (cursor.moveToNext()) { - String host = SqlUtils.getString(cursor, COLUMN_HOST, null); - String ip = SqlUtils.getString(cursor, COLUMN_IP, null); - result.add(new Pair<>(host, ip)); - } - } - return result; - } } diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhDns.kt b/app/src/main/java/com/hippo/ehviewer/client/EhDns.kt index 5e84fbb28..ebd800246 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhDns.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhDns.kt @@ -15,7 +15,6 @@ */ package com.hippo.ehviewer.client -import com.hippo.ehviewer.EhApplication import com.hippo.ehviewer.Hosts import com.hippo.ehviewer.Settings import okhttp3.Dns @@ -23,7 +22,6 @@ import java.net.InetAddress import java.net.UnknownHostException object EhDns : Dns { - private val hosts = EhApplication.hosts private val builtInHosts: MutableMap> = mutableMapOf() init { @@ -127,11 +125,10 @@ object EhDns : Dns { @Throws(UnknownHostException::class) override fun lookup(hostname: String): List { - return hosts[hostname] ?: builtInHosts[hostname].takeIf { Settings.builtInHosts } - ?: Dns.SYSTEM.lookup(hostname) + return builtInHosts[hostname].takeIf { Settings.builtInHosts } ?: Dns.SYSTEM.lookup(hostname) } fun isInHosts(hostname: String): Boolean { - return hosts.contains(hostname) || (builtInHosts.contains(hostname) && Settings.builtInHosts) + return builtInHosts.contains(hostname) && Settings.builtInHosts } } diff --git a/app/src/main/java/com/hippo/ehviewer/database/MSQLiteBuilder.kt b/app/src/main/java/com/hippo/ehviewer/database/MSQLiteBuilder.kt deleted file mode 100644 index 7cab67806..000000000 --- a/app/src/main/java/com/hippo/ehviewer/database/MSQLiteBuilder.kt +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2017 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.database - -import android.content.Context -import android.database.sqlite.SQLiteOpenHelper -import android.util.SparseArray - -class MSQLiteBuilder { - companion object { - const val COLUMN_ID = "_id" - private val JAVA_TYPE_TO_SQLITE_TYPE: MutableMap?, String> = HashMap() - private fun javaTypeToSQLiteType(clazz: Class<*>?): String { - return JAVA_TYPE_TO_SQLITE_TYPE[clazz] - ?: throw IllegalStateException("Unknown type: $clazz") - } - - init { - JAVA_TYPE_TO_SQLITE_TYPE[Boolean::class.javaPrimitiveType] = - "INTEGER NOT NULL DEFAULT 0" - JAVA_TYPE_TO_SQLITE_TYPE[Byte::class.javaPrimitiveType] = - "INTEGER NOT NULL DEFAULT 0" - JAVA_TYPE_TO_SQLITE_TYPE[Short::class.javaPrimitiveType] = - "INTEGER NOT NULL DEFAULT 0" - JAVA_TYPE_TO_SQLITE_TYPE[Int::class.javaPrimitiveType] = "INTEGER NOT NULL DEFAULT 0" - JAVA_TYPE_TO_SQLITE_TYPE[Long::class.javaPrimitiveType] = - "INTEGER NOT NULL DEFAULT 0" - JAVA_TYPE_TO_SQLITE_TYPE[Float::class.javaPrimitiveType] = - "REAL NOT NULL DEFAULT 0" - JAVA_TYPE_TO_SQLITE_TYPE[Double::class.javaPrimitiveType] = "REAL NOT NULL DEFAULT 0" - JAVA_TYPE_TO_SQLITE_TYPE[String::class.java] = "TEXT" - } - } - - private val statementsMap = SparseArray?>() - private var version = 0 - private var statements: MutableList? = null - - /** - * Bump database version. - */ - fun version(version: Int): MSQLiteBuilder { - check(version > this.version) { - ( - "New version must be bigger than current version. " + - "current version: " + this.version + ", new version: " + version + "." - ) - } - this.version = version - statements = ArrayList() - statementsMap.put(version, statements) - return this - } - - /** - * Creates a table. - */ - @JvmOverloads - fun createTable( - table: String, - column: String = COLUMN_ID, - clazz: Class<*>? = Int::class.javaPrimitiveType, - ): MSQLiteBuilder { - return statement("CREATE TABLE " + table + " (" + column + " " + javaTypeToSQLiteType(clazz) + " PRIMARY KEY);") - } - - /** - * Drops a table. - */ - fun dropTable(table: String): MSQLiteBuilder { - return statement("DROP TABLE $table;") - } - - /** - * Inserts a column to the table. - */ - fun insertColumn(table: String, column: String, clazz: Class<*>?): MSQLiteBuilder { - return statement( - "ALTER TABLE $table ADD COLUMN $column " + javaTypeToSQLiteType( - clazz, - ) + ";", - ) - } - - /** - * Add a statement. - */ - fun statement(statement: String): MSQLiteBuilder { - check(!(version == 0 || statements == null)) { "Call version() first!" } - statements!!.add(statement) - return this - } - - /** - * Build a SQLiteOpenHelper from it. - */ - fun build(context: Context?, name: String?, version: Int): SQLiteOpenHelper { - return MSQLiteOpenHelper(context, name, version, this) - } - - fun getStatements(oldVersion: Int, newVersion: Int): List { - val result: MutableList = ArrayList() - for (i in oldVersion + 1..newVersion) { - val list = statementsMap[i] - if (list != null) { - result.addAll(list) - } - } - return result - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/database/MSQLiteOpenHelper.kt b/app/src/main/java/com/hippo/ehviewer/database/MSQLiteOpenHelper.kt deleted file mode 100644 index 37bc06e80..000000000 --- a/app/src/main/java/com/hippo/ehviewer/database/MSQLiteOpenHelper.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2017 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.database - -import android.content.Context -import android.database.sqlite.SQLiteDatabase -import android.database.sqlite.SQLiteOpenHelper -import com.hippo.ehviewer.util.SqlUtils - -internal class MSQLiteOpenHelper( - context: Context?, - name: String?, - private val version: Int, - private val builder: MSQLiteBuilder, -) : SQLiteOpenHelper(context, name, null, version) { - override fun onCreate(db: SQLiteDatabase) { - onUpgrade(db, 0, version) - } - - override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { - for (command in builder.getStatements(oldVersion, newVersion)) { - db.execSQL(command) - } - } - - override fun onDowngrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { - SqlUtils.dropAllTable(db) - onCreate(db) - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/BasePreferenceFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/BasePreferenceFragment.kt index 61699463f..2d74d2460 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/BasePreferenceFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/BasePreferenceFragment.kt @@ -58,7 +58,6 @@ open class BasePreferenceFragment : "filter" -> FilterFragment() "mytags" -> MyTagsFragment() "uconfig" -> UConfigFragment() - "hosts" -> HostsFragment() "license" -> LicenseFragment() else -> null } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/HostsFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/HostsFragment.kt deleted file mode 100644 index 048b793a1..000000000 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/HostsFragment.kt +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2022 Tarsin Norbin - * - * This file is part of EhViewer - * - * EhViewer is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * EhViewer is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with EhViewer. - * If not, see . - */ -package com.hippo.ehviewer.ui.fragment - -import android.app.Dialog -import android.content.DialogInterface -import android.os.Bundle -import android.util.Pair -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.TextView -import androidx.appcompat.app.AlertDialog -import androidx.fragment.app.DialogFragment -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.textfield.TextInputLayout -import com.hippo.ehviewer.EhApplication -import com.hippo.ehviewer.Hosts -import com.hippo.ehviewer.R -import com.hippo.ehviewer.ui.legacy.BaseDialogBuilder -import com.hippo.ehviewer.ui.legacy.ViewTransition - -class HostsFragment : BaseFragment(), View.OnClickListener { - private var hosts: Hosts? = null - private var data: List>? = null - private var mViewTransition: ViewTransition? = null - private var adapter: HostsAdapter? = null - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - EhApplication.hosts.apply { - hosts = this - data = all - } - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle?, - ): View { - val recyclerView = inflater.inflate(R.layout.rv_layout, container, false) as RecyclerView - val tip = getTipView(R.string.hosts) - mViewTransition = - ViewTransition(recyclerView, tip) - val fab = getFabViewAndShow() - adapter = HostsAdapter() - recyclerView.adapter = adapter - recyclerView.layoutManager = - LinearLayoutManager(requireActivity(), RecyclerView.VERTICAL, false) - recyclerView.setHasFixedSize(true) - fab.setOnClickListener(this) - return recyclerView - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - updateView(false) - } - - fun onItemClick(position: Int): Boolean { - val pair = data!![position] - val args = Bundle() - args.putString(KEY_HOST, pair.first) - args.putString(KEY_IP, pair.second) - val fragment: DialogFragment = EditHostDialogFragment() - fragment.arguments = args - fragment.show(childFragmentManager, DIALOG_TAG_EDIT_HOST) - return true - } - - override fun onClick(v: View) { - AddHostDialogFragment().show(childFragmentManager, DIALOG_TAG_ADD_HOST) - } - - private fun updateView(animation: Boolean) { - if (null == mViewTransition) { - return - } - data = hosts!!.all - if ((data as MutableList>?)?.isEmpty() == true) { - mViewTransition!!.showView(1, animation) - } else { - mViewTransition!!.showView(0, animation) - } - adapter!!.notifyDataSetChanged() - } - - override fun getFragmentTitle(): Int { - return R.string.hosts - } - - abstract class HostDialogFragment : DialogFragment() { - private var hostsFragment: HostsFragment? = null - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - hostsFragment = parentFragment as HostsFragment? - val view = layoutInflater.inflate(R.layout.dialog_hosts, null, false) - val host = view.findViewById(R.id.host) - val ip = view.findViewById(R.id.ip) - val arguments = arguments - if (savedInstanceState == null && arguments != null) { - host.text = arguments.getString(KEY_HOST) - ip.text = arguments.getString(KEY_IP) - } - val builder = BaseDialogBuilder(requireContext()) - builder.setView(view) - onCreateDialogBuilder(builder) - val dialog = builder.create() - dialog.setOnShowListener { d: DialogInterface -> onCreateDialog(d as AlertDialog) } - return dialog - } - - protected abstract fun onCreateDialogBuilder(builder: AlertDialog.Builder) - protected abstract fun onCreateDialog(dialog: AlertDialog) - protected fun put(dialog: AlertDialog) { - val host = dialog.findViewById(R.id.host) - val ip = dialog.findViewById(R.id.ip) - if (host == null || ip == null) { - return - } - val hostString = host.text.toString().trim { it <= ' ' }.lowercase() - val ipString = ip.text.toString().trim { it <= ' ' } - if (!Hosts.isValidHost(hostString)) { - val hostInputLayout = - dialog.findViewById(R.id.host_input_layout) ?: return - hostInputLayout.error = getString(R.string.invalid_host) - return - } - if (!Hosts.isValidIp(ipString)) { - val ipInputLayout = - dialog.findViewById(R.id.ip_input_layout) ?: return - ipInputLayout.error = getString(R.string.invalid_ip) - return - } - hostsFragment!!.hosts!!.put(hostString, ipString) - hostsFragment!!.updateView(true) - dialog.dismiss() - } - - protected fun delete(dialog: AlertDialog) { - val host = dialog.findViewById(R.id.host) ?: return - val hostString = host.text.toString().trim { it <= ' ' }.lowercase() - hostsFragment!!.hosts!!.delete(hostString) - hostsFragment!!.updateView(true) - dialog.dismiss() - } - } - - class AddHostDialogFragment : HostDialogFragment() { - override fun onCreateDialogBuilder(builder: AlertDialog.Builder) { - builder.setTitle(R.string.add_host) - builder.setPositiveButton(R.string.add_host_add, null) - builder.setNegativeButton(android.R.string.cancel, null) - } - - override fun onCreateDialog(dialog: AlertDialog) { - dialog.getButton(DialogInterface.BUTTON_POSITIVE) - .setOnClickListener { put(dialog) } - } - } - - class EditHostDialogFragment : HostDialogFragment() { - override fun onCreateDialogBuilder(builder: AlertDialog.Builder) { - builder.setTitle(R.string.edit_host) - builder.setPositiveButton(R.string.edit_host_confirm, null) - builder.setNegativeButton(R.string.edit_host_delete, null) - } - - override fun onCreateDialog(dialog: AlertDialog) { - val hostInputLayout = - dialog.findViewById(R.id.host_input_layout) ?: return - hostInputLayout.isEnabled = false - dialog.getButton(DialogInterface.BUTTON_POSITIVE) - .setOnClickListener { put(dialog) } - dialog.getButton(DialogInterface.BUTTON_NEGATIVE) - .setOnClickListener { delete(dialog) } - } - } - - private class HostsHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - val host: TextView - val ip: TextView - - init { - host = itemView.findViewById(R.id.host) - ip = itemView.findViewById(R.id.ip) - } - } - - private inner class HostsAdapter : RecyclerView.Adapter() { - private val inflater = layoutInflater - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HostsHolder { - return HostsHolder(inflater.inflate(R.layout.item_hosts, parent, false)) - } - - override fun onBindViewHolder(holder: HostsHolder, position: Int) { - val pair = data!![position] - holder.host.text = pair.first - holder.ip.text = pair.second - holder.itemView.setOnClickListener { onItemClick(position) } - } - - override fun getItemCount(): Int { - return data!!.size - } - } - - companion object { - private val DIALOG_TAG_ADD_HOST = AddHostDialogFragment::class.java.name - private val DIALOG_TAG_EDIT_HOST = EditHostDialogFragment::class.java.name - private const val KEY_HOST = "com.hippo.ehviewer.ui.fragment.HostsFragment.HOST" - private const val KEY_IP = "com.hippo.ehviewer.ui.fragment.HostsFragment.IP" - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/util/SqlUtils.java b/app/src/main/java/com/hippo/ehviewer/util/SqlUtils.java deleted file mode 100644 index 089f409fc..000000000 --- a/app/src/main/java/com/hippo/ehviewer/util/SqlUtils.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2016 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hippo.ehviewer.util; - -import android.database.Cursor; -import android.database.SQLException; -import android.database.sqlite.SQLiteDatabase; - -import java.util.ArrayList; -import java.util.List; - -public class SqlUtils { - - public static void exeSQLSafely(SQLiteDatabase db, String sql) { - try { - db.execSQL(sql); - } catch (SQLException e) { - // Ignore - } - } - - public static void dropTable(SQLiteDatabase db, String tableName) { - exeSQLSafely(db, "DROP TABLE IF EXISTS " + tableName); - } - - public static void dropAllTable(SQLiteDatabase db) { - List tables = new ArrayList<>(); - Cursor cursor = db.rawQuery("SELECT * FROM sqlite_master WHERE type='table';", null); - cursor.moveToFirst(); - while (!cursor.isAfterLast()) { - String tableName = cursor.getString(1); - if (!tableName.equals("android_metadata") && - !tableName.equals("sqlite_sequence")) - tables.add(tableName); - cursor.moveToNext(); - } - cursor.close(); - - for (String tableName : tables) { - dropTable(db, tableName); - } - } - - public static String sqlEscapeString(String value) { - StringBuilder sb = new StringBuilder(); - - int length = value.length(); - for (int i = 0; i < length; i++) { - char c = value.charAt(i); - if (c == '\'') { - sb.append('\''); - } - sb.append(c); - } - - return sb.toString(); - } - - public static boolean getBoolean(Cursor cursor, String column, boolean defValue) { - try { - int index = cursor.getColumnIndex(column); - if (index != -1) { - return cursor.getInt(index) != 0; - } - } catch (Throwable e) { /* Ignore */ } - return defValue; - } - - public static int getInt(Cursor cursor, String column, int defValue) { - try { - int index = cursor.getColumnIndex(column); - if (index != -1) { - return cursor.getInt(index); - } - } catch (Throwable e) { /* Ignore */ } - return defValue; - } - - public static long getLong(Cursor cursor, String column, long defValue) { - try { - int index = cursor.getColumnIndex(column); - if (index != -1) { - return cursor.getLong(index); - } - } catch (Throwable e) { /* Ignore */ } - return defValue; - } - - public static float getFloat(Cursor cursor, String column, float defValue) { - try { - int index = cursor.getColumnIndex(column); - if (index != -1) { - return cursor.getFloat(index); - } - } catch (Throwable e) { /* Ignore */ } - return defValue; - } - - public static String getString(Cursor cursor, String column, String defValue) { - try { - int index = cursor.getColumnIndex(column); - if (index != -1) { - return cursor.getString(index); - } - } catch (Throwable e) { /* Ignore */ } - return defValue; - } -} diff --git a/app/src/main/res/layout/dialog_hosts.xml b/app/src/main/res/layout/dialog_hosts.xml deleted file mode 100644 index 2ac06040a..000000000 --- a/app/src/main/res/layout/dialog_hosts.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/item_hosts.xml b/app/src/main/res/layout/item_hosts.xml deleted file mode 100644 index 2482c70a0..000000000 --- a/app/src/main/res/layout/item_hosts.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ccf3b23cf..871d88bbf 100755 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -239,16 +239,6 @@ EHentai-Einstellungen Übernehmen Zum Speichern der Einstellungen auf Häkchen tippen - Angepasstes hosts.txt - Host - IP1(+IP2+IP3…) - Host hinzufügen - Hinzufügen - Host bearbeiten - Übernehmen - Entfernen - Ungültiger Host - Ungültige IP Das Bild teilen Das Bild wurde zu %s gespeichert EH @@ -367,8 +357,6 @@ Entwickler Aktuelle Version Host auf die IP, die nach die App festgelegt werden, umstellen\nKann von angepasstem hosts.txt überschrieben werden - Angepasstes hosts.txt - Hostname auf die angepassten IP umstellen\nDie Regeln können die von der App festgelegt überschreiben Lesefortschritte zurücksetzen Lesefortschritte aus allen heruntergeladenen Galerie zurücksetzen? Wenn jemand die folgenden Informationen hat, kann er sich als du anmelden. <br><b>ALSO GEHEIM HALTEN!</b><br><br>%s diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index b60ec9213..16f7e84a1 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -446,15 +446,5 @@ Ajustes EHentai Aplicar Toca la marca de verificación para guardar los cambios - hosts.txt personalizado - Anfitrión - IP1(+IP2+IP3…) - Añadir una anfitrión - Añadir - Anfitrión - Aplicar - Borrar - Anfitrión inválida - IP inválida diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d64c145b9..b5027a6a7 100755 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -461,24 +461,12 @@ Confidentialité Empêcher les captures d\'ecran Quand cette option est activée, vous ne pouvez prendre aucune capture d\'écran de l\'application, et le systéme n\'affiche pas le contenu d\'écran dans le sélecteur de tâches.\n\nRedémarrage de l\'application est nécessaire pour appliquer le changement - Personnalisé hosts.txt - Hôte - IP1(+IP2+IP3…) - Ajouter hôte - Ajouter - Modifier hôte - Appliquer - Supprimer - Hôte invalide - IP invalide Langue de l\'app (Language) hosts.txt integré Serveur proxy %1$s %2$s:%3$d %1$s Mapper l\'hôte à l\'adresse IP selon les règles de l\'app\nIls pouvent être redéfinits par hosts.txt personnalisé - hosts.txt personalisé - Mapper l\'hôte à l\'adresse IP\nIls pouvent redéfinir l\'hosts.txt de l\'app Langue du système (défaut) Tout le monde peut utiliser les cookies de ce compte pour s\'y connecter.<br><b>GARDEZ-LES BIEN !</b><br><br>%s Vous ne vous êtes pas connecté. diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index b0d0e13b7..1ba8aa2c6 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -461,22 +461,10 @@ プロキシ %1$s %2$s:%3$d %1$s - カスタムhosts.txt - ホスト - IP1(+IP2+IP3…) - ホストを追加 - 追加 - ホストを編集 - 適用 - 削除 - 無効なホストです - 無効なIPです 既定hosts.txt システム言語(既定) ダウンロードサービス ホストをアプリ既定のIPにマッピング\nカスタムhosts.txtに上書きされます。 - カスタムhosts.txt - ホスト名をIPにマッピング\n既定のhosts.txtを上書きできます。 下記の情報を持つ誰でもこのアカウントにログインできますので<br><b>絶対に他人に渡さないように!</b><br><br>%s まだログインしていません diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 81607762b..a2f1be6da 100755 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -271,16 +271,6 @@ 설정을 저장하려면 체크 표시를 누르세요. - 사용자 지정 hosts.txt - 호스트 - IP1(+IP2+IP3…) - 호스트 추가 - 추가 - 호스트 편집 - 확인 - 삭제 - 잘못된 호스트 - 잘못된 IP 이미지 공유 @@ -354,8 +344,6 @@ %1$s 앱 내장 hosts.txt 앱에 내장된 호스트-IP 지정 규칙을 사용합니다.\n대신 사용자 지정 hosts.txt 파일을 사용할 수도 있습니다. - 사용자 지정 hosts.txt - 호스트 이름을 IP 주소에 지정합니다.\n앱에 내장된 규칙은 무시됩니다. 데이터 내보내기 다운로드 목록, 빠른 검색 목록 등의 데이터를 외부 저장소에 저장 %s 경로에 데이터를 내보냈습니다. diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 422ed642f..34a4d1cef 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -96,7 +96,6 @@ OK Pinlig Sider - Ugyldig IP Del bilde Logg ut Turistmodus @@ -119,7 +118,6 @@ Utolererbar Katastrofe Galleri-info - Legg til en vert Listemodus Kopiert til utklippstavlen Navn @@ -153,15 +151,10 @@ Nedlastet Ferdig Slett bildefiler - Legg til Galleriside Stopp alle - Ugyldig vert Bilde lagret i %s Last ned opprinnelig bilde - Rediger verten - Bekreft - Slett Forhindre skjermavbildninger Nedlastingstjeneste Mellomtjenertype diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index 7451b7aae..81f6895f8 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -286,16 +286,6 @@ แตะเครื่องหมายถูกเพื่อบันทึกการตั้งค่าแล้ว - ปรับแต่ง hosts.txt เอง - โฮสต์ - ไอพี - เพิ่มโฮสต์ - เพิ่ม - แก้ไขโฮสต์ - ยืนยัน - ลบ - โฮสต์ไม่ถูกต้อง - ไอพีไม่ถูกต้อง แชร์รูปภาพ @@ -369,8 +359,6 @@ %1$s ใช้ hosts.txt ของตัวแอป ใช้ host-to-IP mapping แบบภายในที่จัดทำโดยตัวแอปเอง\nมันอาจจะเกิดการทับซ้อนกันจากการปรับแต่งไฟล์ hosts.txt เอง - ปรับแต่งไฟล์ hosts.txt เอง - ทำแผนผัง hostnames ถึง ที่อยู่ของ IP\nมันอาจจะเกิดการทับซ้อนกันกับการใช้ hosts.txt ของตัวแอป สำเนาข้อมูล บันทึกข้อมูลต่างๆเช่นรายการดาวน์โหลด และค้นหาอย่างด่วนลงพื้นที่จัดเก็บภายนอก ได้สำเนาข้อมูลแล้วจัดเก็บที่ %s diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index f2f146986..a1ef5e85e 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -300,16 +300,6 @@ 我的标签 - 自定义 hosts.txt - Host - IP1(+IP2+IP3…) - 添加 host - 添加 - 编辑 host - 确认 - 删除 - 无效的 host - 无效的 IP 分享图片 图片已保存至 %s @@ -390,8 +380,6 @@ %1$s 内置 hosts.txt 应用提供的主机到IP的映射\n可被自定义 hosts.txt 覆盖 - 自定义 hosts.txt - 将主机名称映射到相应的IP地址\n可覆盖内置 hosts.txt 域名前置(重启应用后生效) 绕过 SNI 封锁\n启用时会禁用代理设置 绕过VPN diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index e243e946a..56dc3bd29 100755 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -318,16 +318,6 @@ 我的標籤 - 自定義 hosts.txt - Host - IP1(+IP2+IP3…) - 添加 host - 添加 - 編輯 host - 確認 - 刪除 - 無效的 host - 無效的 IP 分享圖片 @@ -408,8 +398,6 @@ App 界面語言 內置 hosts.txt 應用提供的主機到IP的映射\n可被自定義 hosts.txt 覆蓋 - 自定義 hosts.txt - 將主機名稱映射到相應的IP地址\n可覆蓋內置 hosts.txt 導出數據 保存數據至外置存儲器,例如下載列表,快速搜索列表 已導出數據至 %s diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 333b42fb3..c7175f4f7 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -300,16 +300,6 @@ 我的標籤 - 自訂 hosts.txt - Host - IP1(+IP2+IP3…) - 加入 host - 加入 - 編輯 host - 確認 - 刪除 - 無效的 host - 無效的 IP 分享圖片 已將圖片儲存至 %s @@ -390,8 +380,6 @@ %1$s 內建 hosts.txt 應用程式提供的主機到 IP 的對映\n可覆蓋自訂 hosts.txt - 自訂 hosts.txt - 將主機名稱對映到相應的 IP 位址\n可覆蓋內建 hosts.txt 域名前綴 繞過 SNI 封鎖 繞過 VPN diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 91a8e5348..02daad691 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -343,16 +343,6 @@ My tags - Custom hosts.txt - Host - IP1(+IP2+IP3…) - Add a host - Add - Edit the host - Confirm - Delete - Invalid host - Invalid IP Share image Image saved to %s @@ -438,8 +428,6 @@ Bypass SNI blocking. Bypass VPN Try to bypass VPN when domain fronting is enabled - Custom hosts.txt - Map hostnames to IP addresses.\nIt can override built-in hosts.txt. Export data Save data like download list, quick search list, to external storage Exported data to %s diff --git a/app/src/main/res/xml/advanced_settings.xml b/app/src/main/res/xml/advanced_settings.xml index e6ebebfb3..18d7c82e4 100644 --- a/app/src/main/res/xml/advanced_settings.xml +++ b/app/src/main/res/xml/advanced_settings.xml @@ -67,12 +67,6 @@ android:title="@string/settings_advanced_built_in_hosts_title" app:iconSpaceReserved="false" /> - -