diff --git a/app/src/main/java/com/topjohnwu/magisk/App.kt b/app/src/main/java/com/topjohnwu/magisk/App.kt index 84150191e..712b85a8e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/App.kt +++ b/app/src/main/java/com/topjohnwu/magisk/App.kt @@ -13,7 +13,6 @@ import androidx.appcompat.app.AppCompatDelegate import androidx.multidex.MultiDex import com.chibatching.kotpref.Kotpref import com.topjohnwu.magisk.data.database.MagiskDB -import com.topjohnwu.magisk.data.database.RepoDatabaseHelper import com.topjohnwu.magisk.di.koinModules import com.topjohnwu.magisk.utils.LocaleManager import com.topjohnwu.magisk.utils.RootUtils @@ -34,8 +33,6 @@ open class App : Application(), Application.ActivityLifecycleCallbacks { val prefs: SharedPreferences by inject() @Deprecated("Use dependency injection") val DB: MagiskDB by inject() - @Deprecated("Use dependency injection") - val repoDB: RepoDatabaseHelper by inject() @Volatile private var foreground: Activity? = null diff --git a/app/src/main/java/com/topjohnwu/magisk/data/database/RepoDatabaseHelper.java b/app/src/main/java/com/topjohnwu/magisk/data/database/RepoDatabaseHelper.java deleted file mode 100644 index d216169d0..000000000 --- a/app/src/main/java/com/topjohnwu/magisk/data/database/RepoDatabaseHelper.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.topjohnwu.magisk.data.database; - -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; - -import com.topjohnwu.magisk.Config; -import com.topjohnwu.magisk.model.entity.Repo; - -import java.util.HashSet; -import java.util.Set; - -@Deprecated -public class RepoDatabaseHelper extends SQLiteOpenHelper { - - private static final int DATABASE_VER = 5; - private static final String TABLE_NAME = "repos"; - - private final SQLiteDatabase mDb; - - @Deprecated - public RepoDatabaseHelper(Context context) { - super(context, "repo.db", null, DATABASE_VER); - mDb = getWritableDatabase(); - } - - @Override - public void onCreate(SQLiteDatabase db) { - onUpgrade(db, 0, DATABASE_VER); - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - if (oldVersion != newVersion) { - // Nuke old DB and create new table - db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); - db.execSQL( - "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " " + - "(id TEXT, name TEXT, version TEXT, versionCode INT, " + - "author TEXT, description TEXT, last_update INT, PRIMARY KEY(id))"); - Config.remove(Config.Key.ETAG_KEY); - } - } - - @Override - public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { - onUpgrade(db, 0, DATABASE_VER); - } - - @Deprecated - public void clearRepo() { - mDb.delete(TABLE_NAME, null, null); - } - - - @Deprecated - public void removeRepo(String id) { - mDb.delete(TABLE_NAME, "id=?", new String[] { id }); - } - - @Deprecated - public void removeRepo(Repo repo) { - removeRepo(repo.getId()); - } - - @Deprecated - public void removeRepo(Iterable list) { - for (String id : list) { - if (id == null) continue; - mDb.delete(TABLE_NAME, "id=?", new String[] { id }); - } - } - - @Deprecated - public void addRepo(Repo repo) { - mDb.replace(TABLE_NAME, null, repo.getContentValues()); - } - - @Deprecated - public Repo getRepo(String id) { - try (Cursor c = mDb.query(TABLE_NAME, null, "id=?", new String[] { id }, null, null, null)) { - if (c.moveToNext()) { - return new Repo(c); - } - } - return null; - } - - @Deprecated - public Cursor getRawCursor() { - return mDb.query(TABLE_NAME, null, null, null, null, null, null); - } - - @Deprecated - public Cursor getRepoCursor() { - String orderBy = null; - switch ((int) Config.get(Config.Key.REPO_ORDER)) { - case Config.Value.ORDER_NAME: - orderBy = "name COLLATE NOCASE"; - break; - case Config.Value.ORDER_DATE: - orderBy = "last_update DESC"; - } - return mDb.query(TABLE_NAME, null, null, null, null, null, orderBy); - } - - @Deprecated - public Set getRepoIDSet() { - HashSet set = new HashSet<>(300); - try (Cursor c = mDb.query(TABLE_NAME, null, null, null, null, null, null)) { - while (c.moveToNext()) { - set.add(c.getString(c.getColumnIndex("id"))); - } - } - return set; - } -} diff --git a/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt b/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt index 92d68d2b4..29b5dedaa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt @@ -9,7 +9,6 @@ import org.koin.dsl.module val databaseModule = module { single { MagiskDB(get().protectedContext) } - single { RepoDatabaseHelper(get()) } single { createDatabase(get()) } single { LogDao() } single { PolicyDao(get()) } diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt b/app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt index f0df3eee7..5c0b6e593 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt @@ -14,7 +14,6 @@ import androidx.recyclerview.widget.RecyclerView import com.topjohnwu.magisk.App import com.topjohnwu.magisk.R import com.topjohnwu.magisk.data.database.MagiskDB -import com.topjohnwu.magisk.data.database.RepoDatabaseHelper import org.koin.android.ext.android.inject abstract class BasePreferenceFragment : PreferenceFragmentCompat(), @@ -23,7 +22,6 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(), protected val prefs: SharedPreferences by inject() protected val app: App by inject() protected val database: MagiskDB by inject() - protected val repoDB: RepoDatabaseHelper by inject() override fun onCreateView( inflater: LayoutInflater, diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java index d9bed6f63..eeb335a08 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java @@ -105,9 +105,10 @@ public final class SettingsFragment extends BasePreferenceFragment { DownloadApp.restore(); return true; }); - findPreference("clear").setOnPreferenceClickListener(pref -> { + Preference clear = findPreference("clear"); + clear.setEnabled(false); // temporarily disable clearing cache as repos are not cached atm + clear.setOnPreferenceClickListener(pref -> { getPrefs().edit().remove(Config.Key.ETAG_KEY).apply(); - getRepoDB().clearRepo(); Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT); return true; });