Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
d39d885e
Commit
d39d885e
authored
May 10, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed repo db helper
parent
d83c7447
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3 additions
and
126 deletions
+3
-126
App.kt
app/src/main/java/com/topjohnwu/magisk/App.kt
+0
-3
RepoDatabaseHelper.java
...om/topjohnwu/magisk/data/database/RepoDatabaseHelper.java
+0
-118
DatabaseModule.kt
app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt
+0
-1
BasePreferenceFragment.kt
...va/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt
+0
-2
SettingsFragment.java
...va/com/topjohnwu/magisk/ui/settings/SettingsFragment.java
+3
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/App.kt
View file @
d39d885e
...
...
@@ -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
...
...
app/src/main/java/com/topjohnwu/magisk/data/database/RepoDatabaseHelper.java
deleted
100644 → 0
View file @
d83c7447
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
<
String
>
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
<
String
>
getRepoIDSet
()
{
HashSet
<
String
>
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
;
}
}
app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt
View file @
d39d885e
...
...
@@ -9,7 +9,6 @@ import org.koin.dsl.module
val
databaseModule
=
module
{
single
{
MagiskDB
(
get
<
App
>().
protectedContext
)
}
single
{
RepoDatabaseHelper
(
get
())
}
single
{
createDatabase
(
get
())
}
single
{
LogDao
()
}
single
{
PolicyDao
(
get
())
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/base/BasePreferenceFragment.kt
View file @
d39d885e
...
...
@@ -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
,
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java
View file @
d39d885e
...
...
@@ -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
;
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment