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
6a148b5d
Commit
6a148b5d
authored
Dec 26, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sorting repo by update time
parent
0e109ef9
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
139 additions
and
69 deletions
+139
-69
MagiskManager.java
src/main/java/com/topjohnwu/magisk/MagiskManager.java
+24
-0
ReposFragment.java
src/main/java/com/topjohnwu/magisk/ReposFragment.java
+19
-0
SplashActivity.java
src/main/java/com/topjohnwu/magisk/SplashActivity.java
+1
-18
ApplicationAdapter.java
...ava/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
+1
-1
ReposAdapter.java
...main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
+2
-0
Repo.java
src/main/java/com/topjohnwu/magisk/container/Repo.java
+7
-0
RepoDatabaseHelper.java
...ava/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
+9
-1
Const.java
src/main/java/com/topjohnwu/magisk/utils/Const.java
+3
-0
ic_sort.xml
src/main/res/drawable/ic_sort.xml
+9
-0
list_item_app.xml
src/main/res/layout/list_item_app.xml
+38
-46
list_item_policy.xml
src/main/res/layout/list_item_policy.xml
+0
-1
list_item_repo.xml
src/main/res/layout/list_item_repo.xml
+9
-0
menu_repo.xml
src/main/res/menu/menu_repo.xml
+6
-0
arrays.xml
src/main/res/values/arrays.xml
+5
-0
strings.xml
src/main/res/values/strings.xml
+4
-0
styles.xml
src/main/res/values/styles.xml
+2
-2
No files found.
src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
6a148b5d
...
...
@@ -75,6 +75,7 @@ public class MagiskManager extends Application {
public
int
updateChannel
;
public
String
bootFormat
;
public
String
customChannelUrl
;
public
int
repoOrder
;
// Global resources
public
SharedPreferences
prefs
;
...
...
@@ -145,6 +146,29 @@ public class MagiskManager extends Application {
updateChannel
=
Utils
.
getPrefsInt
(
prefs
,
Const
.
Key
.
UPDATE_CHANNEL
,
Const
.
Value
.
STABLE_CHANNEL
);
bootFormat
=
prefs
.
getString
(
Const
.
Key
.
BOOT_FORMAT
,
".img"
);
customChannelUrl
=
prefs
.
getString
(
Const
.
Key
.
CUSTOM_CHANNEL
,
""
);
repoOrder
=
prefs
.
getInt
(
Const
.
Key
.
REPO_ORDER
,
Const
.
Value
.
ORDER_NAME
);
}
public
void
writeConfig
()
{
prefs
.
edit
()
.
putBoolean
(
Const
.
Key
.
DARK_THEME
,
isDarkTheme
)
.
putBoolean
(
Const
.
Key
.
MAGISKHIDE
,
magiskHide
)
.
putBoolean
(
Const
.
Key
.
UPDATE_NOTIFICATION
,
updateNotification
)
.
putBoolean
(
Const
.
Key
.
HOSTS
,
Utils
.
itemExist
(
Const
.
MAGISK_HOST_FILE
()))
.
putBoolean
(
Const
.
Key
.
COREONLY
,
Utils
.
itemExist
(
Const
.
MAGISK_DISABLE_FILE
))
.
putBoolean
(
Const
.
Key
.
SU_REAUTH
,
suReauth
)
.
putString
(
Const
.
Key
.
SU_REQUEST_TIMEOUT
,
String
.
valueOf
(
suRequestTimeout
))
.
putString
(
Const
.
Key
.
SU_AUTO_RESPONSE
,
String
.
valueOf
(
suResponseType
))
.
putString
(
Const
.
Key
.
SU_NOTIFICATION
,
String
.
valueOf
(
suNotificationType
))
.
putString
(
Const
.
Key
.
ROOT_ACCESS
,
String
.
valueOf
(
suAccessState
))
.
putString
(
Const
.
Key
.
SU_MULTIUSER_MODE
,
String
.
valueOf
(
multiuserMode
))
.
putString
(
Const
.
Key
.
SU_MNT_NS
,
String
.
valueOf
(
suNamespaceMode
))
.
putString
(
Const
.
Key
.
UPDATE_CHANNEL
,
String
.
valueOf
(
updateChannel
))
.
putString
(
Const
.
Key
.
LOCALE
,
localeConfig
)
.
putString
(
Const
.
Key
.
BOOT_FORMAT
,
bootFormat
)
.
putInt
(
Const
.
Key
.
UPDATE_SERVICE_VER
,
Const
.
UPDATE_SERVICE_VER
)
.
putInt
(
Const
.
Key
.
REPO_ORDER
,
repoOrder
)
.
apply
();
}
public
static
void
toast
(
String
msg
,
int
duration
)
{
...
...
src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
6a148b5d
package
com
.
topjohnwu
.
magisk
;
import
android.app.AlertDialog
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.v4.widget.SwipeRefreshLayout
;
...
...
@@ -7,6 +8,7 @@ import android.support.v7.widget.RecyclerView;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.SearchView
;
...
...
@@ -15,6 +17,7 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.adapters.ReposAdapter
;
import
com.topjohnwu.magisk.asyncs.UpdateRepos
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Topic
;
import
butterknife.BindView
;
...
...
@@ -98,6 +101,22 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
});
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
MagiskManager
mm
=
getApplication
();
if
(
item
.
getItemId
()
==
R
.
id
.
repo_sort
)
{
new
AlertDialog
.
Builder
(
getActivity
())
.
setTitle
(
R
.
string
.
sorting_order
)
.
setSingleChoiceItems
(
R
.
array
.
sorting_orders
,
mm
.
repoOrder
,
(
d
,
which
)
->
{
mm
.
repoOrder
=
which
;
mm
.
prefs
.
edit
().
putInt
(
Const
.
Key
.
REPO_ORDER
,
mm
.
repoOrder
).
apply
();
adapter
.
notifyDBChanged
();
d
.
dismiss
();
}).
show
();
}
return
true
;
}
@Override
public
void
onDestroyView
()
{
super
.
onDestroyView
();
...
...
src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
6a148b5d
...
...
@@ -79,24 +79,7 @@ public class SplashActivity extends Activity {
}
// Write back default values
mm
.
prefs
.
edit
()
.
putBoolean
(
Const
.
Key
.
DARK_THEME
,
mm
.
isDarkTheme
)
.
putBoolean
(
Const
.
Key
.
MAGISKHIDE
,
mm
.
magiskHide
)
.
putBoolean
(
Const
.
Key
.
UPDATE_NOTIFICATION
,
mm
.
updateNotification
)
.
putBoolean
(
Const
.
Key
.
HOSTS
,
Utils
.
itemExist
(
Const
.
MAGISK_HOST_FILE
()))
.
putBoolean
(
Const
.
Key
.
COREONLY
,
Utils
.
itemExist
(
Const
.
MAGISK_DISABLE_FILE
))
.
putBoolean
(
Const
.
Key
.
SU_REAUTH
,
mm
.
suReauth
)
.
putString
(
Const
.
Key
.
SU_REQUEST_TIMEOUT
,
String
.
valueOf
(
mm
.
suRequestTimeout
))
.
putString
(
Const
.
Key
.
SU_AUTO_RESPONSE
,
String
.
valueOf
(
mm
.
suResponseType
))
.
putString
(
Const
.
Key
.
SU_NOTIFICATION
,
String
.
valueOf
(
mm
.
suNotificationType
))
.
putString
(
Const
.
Key
.
ROOT_ACCESS
,
String
.
valueOf
(
mm
.
suAccessState
))
.
putString
(
Const
.
Key
.
SU_MULTIUSER_MODE
,
String
.
valueOf
(
mm
.
multiuserMode
))
.
putString
(
Const
.
Key
.
SU_MNT_NS
,
String
.
valueOf
(
mm
.
suNamespaceMode
))
.
putString
(
Const
.
Key
.
UPDATE_CHANNEL
,
String
.
valueOf
(
mm
.
updateChannel
))
.
putString
(
Const
.
Key
.
LOCALE
,
mm
.
localeConfig
)
.
putString
(
Const
.
Key
.
BOOT_FORMAT
,
mm
.
bootFormat
)
.
putInt
(
Const
.
Key
.
UPDATE_SERVICE_VER
,
Const
.
UPDATE_SERVICE_VER
)
.
apply
();
mm
.
writeConfig
();
mm
.
hasInit
=
true
;
...
...
src/main/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
View file @
6a148b5d
...
...
@@ -108,7 +108,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
@BindView
(
R
.
id
.
app_icon
)
ImageView
appIcon
;
@BindView
(
R
.
id
.
app_name
)
TextView
appName
;
@BindView
(
R
.
id
.
app_packag
e
)
TextView
appPackage
;
@BindView
(
R
.
id
.
package_nam
e
)
TextView
appPackage
;
@BindView
(
R
.
id
.
checkbox
)
CheckBox
checkBox
;
ViewHolder
(
View
itemView
)
{
...
...
src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
View file @
6a148b5d
...
...
@@ -95,6 +95,7 @@ public class ReposAdapter extends SectionedAdapter<ReposAdapter.SectionHolder, R
String
author
=
repo
.
getAuthor
();
holder
.
author
.
setText
(
TextUtils
.
isEmpty
(
author
)
?
null
:
context
.
getString
(
R
.
string
.
author
,
author
));
holder
.
description
.
setText
(
repo
.
getDescription
());
holder
.
updateTime
.
setText
(
context
.
getString
(
R
.
string
.
updated_on
,
repo
.
getLastUpdateString
()));
holder
.
infoLayout
.
setOnClickListener
(
v
->
new
MarkDownWindow
((
Activity
)
context
,
null
,
repo
.
getDetailUrl
()).
exec
());
...
...
@@ -180,6 +181,7 @@ public class ReposAdapter extends SectionedAdapter<ReposAdapter.SectionHolder, R
@BindView
(
R
.
id
.
author
)
TextView
author
;
@BindView
(
R
.
id
.
info_layout
)
LinearLayout
infoLayout
;
@BindView
(
R
.
id
.
download
)
ImageView
downloadImage
;
@BindView
(
R
.
id
.
update_time
)
TextView
updateTime
;
RepoHolder
(
View
itemView
)
{
super
(
itemView
);
...
...
src/main/java/com/topjohnwu/magisk/container/Repo.java
View file @
6a148b5d
...
...
@@ -3,9 +3,11 @@ package com.topjohnwu.magisk.container;
import
android.content.ContentValues
;
import
android.database.Cursor
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.WebService
;
import
java.text.DateFormat
;
import
java.util.Date
;
public
class
Repo
extends
BaseModule
{
...
...
@@ -78,6 +80,11 @@ public class Repo extends BaseModule {
return
String
.
format
(
Const
.
Url
.
FILE_URL
,
repoName
,
"README.md"
);
}
public
String
getLastUpdateString
()
{
return
DateFormat
.
getDateTimeInstance
(
DateFormat
.
MEDIUM
,
DateFormat
.
MEDIUM
,
MagiskManager
.
locale
).
format
(
mLastUpdate
);
}
public
Date
getLastUpdate
()
{
return
mLastUpdate
;
}
...
...
src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
View file @
6a148b5d
...
...
@@ -95,9 +95,17 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
}
public
Cursor
getRepoCursor
()
{
String
orderBy
=
null
;
switch
(
mm
.
repoOrder
)
{
case
Const
.
Value
.
ORDER_NAME
:
orderBy
=
"name COLLATE NOCASE"
;
break
;
case
Const
.
Value
.
ORDER_DATE
:
orderBy
=
"last_update DESC"
;
}
return
mDb
.
query
(
TABLE_NAME
,
null
,
"minMagisk<=?"
,
new
String
[]
{
String
.
valueOf
(
mm
.
magiskVersionCode
)
},
null
,
null
,
"name COLLATE NOCASE"
);
null
,
null
,
orderBy
);
}
public
List
<
String
>
getRepoIDList
()
{
...
...
src/main/java/com/topjohnwu/magisk/utils/Const.java
View file @
6a148b5d
...
...
@@ -133,6 +133,7 @@ public class Const {
public
static
final
String
ETAG_KEY
=
"ETag"
;
public
static
final
String
LINK_KEY
=
"Link"
;
public
static
final
String
IF_NONE_MATCH
=
"If-None-Match"
;
public
static
final
String
REPO_ORDER
=
"repo_order"
;
}
...
...
@@ -162,5 +163,7 @@ public class Const {
public
static
final
String
PATCH_BOOT
=
"patch"
;
public
static
final
String
FLASH_MAGISK
=
"magisk"
;
public
static
final
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
public
static
final
int
ORDER_NAME
=
0
;
public
static
final
int
ORDER_DATE
=
1
;
}
}
src/main/res/drawable/ic_sort.xml
0 → 100644
View file @
6a148b5d
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24.0"
android:viewportHeight=
"24.0"
>
<path
android:fillColor=
"?attr/imageColorTint"
android:pathData=
"M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z"
/>
</vector>
src/main/res/layout/list_item_app.xml
View file @
6a148b5d
...
...
@@ -15,71 +15,63 @@
card_view:cardCornerRadius=
"@dimen/card_corner_radius"
card_view:cardElevation=
"@dimen/card_elevation"
>
<RelativeLayout
<LinearLayout
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"fill_parent"
android:layout_gravity=
"center_vertical"
android:padding=
"@dimen/card_layout_padding"
>
android:layout_height=
"wrap_content"
android:id=
"@+id/info_layout"
android:paddingStart=
"10dp"
android:paddingEnd=
"10dp"
android:paddingTop=
"5dp"
android:paddingBottom=
"5dp"
>
<ImageView
android:id=
"@+id/app_icon"
android:layout_width=
"
@dimen/card_appicon_size
"
android:layout_height=
"
@dimen/card_appicon_size
"
android:layout_
centerVertical=
"true
"
android:
scaleType=
"centerCrop"
/>
android:layout_width=
"
50dp
"
android:layout_height=
"
50dp
"
android:layout_
gravity=
"center_vertical
"
android:
gravity=
"end"
/>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:layout_alignBottom=
"@+id/app_icon"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
android:paddingEnd=
"@dimen/card_appicon_size"
android:paddingStart=
"65dp"
android:weightSum=
"1"
>
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"5dp"
>
<TextView
android:id=
"@+id/app_name"
android:layout_width=
"
fill
_parent"
android:layout_width=
"
match
_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:maxLines=
"1"
android:
paddingEnd=
"3dp
"
android:
paddingStart=
"3dp
"
android:text
Style=
"bold
"
/>
android:
ellipsize=
"end
"
android:
textAppearance=
"?android:attr/textAppearanceMedium
"
android:text
IsSelectable=
"false
"
/>
<TextView
android:id=
"@+id/app_package"
android:layout_width=
"fill_parent"
android:layout_height=
"25dp"
android:ellipsize=
"marquee"
android:gravity=
"center_vertical"
android:marqueeRepeatLimit=
"marquee_forever"
android:paddingEnd=
"3dp"
android:paddingStart=
"3dp"
android:singleLine=
"true"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
>
<CheckBox
android:id=
"@+id/checkbox"
android:layout_width=
"wrap_content"
android:id=
"@+id/package_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:focusable=
"false"
android:gravity=
"center"
android:src=
"@drawable/ic_menu_overflow_material"
android:checked=
"false"
/>
android:maxLines=
"1"
android:ellipsize=
"end"
android:textAppearance=
"?android:attr/textAppearanceSmall"
android:textColor=
"@android:color/tertiary_text_dark"
android:textIsSelectable=
"false"
/>
</LinearLayout>
</RelativeLayout>
<CheckBox
android:id=
"@+id/checkbox"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:focusable=
"false"
android:layout_gravity=
"center_vertical"
android:src=
"@drawable/ic_menu_overflow_material"
android:checked=
"false"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
...
...
src/main/res/layout/list_item_policy.xml
View file @
6a148b5d
...
...
@@ -52,7 +52,6 @@
android:maxLines=
"1"
android:ellipsize=
"end"
android:textAppearance=
"?android:attr/textAppearanceMedium"
android:textColor=
"?android:attr/textColorPrimary"
android:textIsSelectable=
"false"
/>
<TextView
...
...
src/main/res/layout/list_item_repo.xml
View file @
6a148b5d
...
...
@@ -67,6 +67,15 @@
android:textAppearance=
"?android:attr/textAppearanceSmall"
android:textIsSelectable=
"false"
/>
<TextView
android:id=
"@+id/update_time"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textAppearance=
"?android:attr/textAppearanceSmall"
android:textColor=
"@android:color/tertiary_text_dark"
android:textIsSelectable=
"false"
android:textStyle=
"bold|italic"
/>
</LinearLayout>
<ImageView
...
...
src/main/res/menu/menu_repo.xml
View file @
6a148b5d
...
...
@@ -2,9 +2,15 @@
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/repo_sort"
android:icon=
"@drawable/ic_sort"
app:showAsAction=
"always"
/>
<item
android:id=
"@+id/repo_search"
android:title=
""
app:actionViewClass=
"android.widget.SearchView"
app:showAsAction=
"always"
/>
</menu>
\ No newline at end of file
src/main/res/values/arrays.xml
View file @
6a148b5d
...
...
@@ -83,4 +83,9 @@
<item>
.img.tar
</item>
</string-array>
<string-array
name=
"sorting_orders"
>
<item>
@string/sort_by_name
</item>
<item>
@string/sort_by_update
</item>
</string-array>
</resources>
\ No newline at end of file
src/main/res/values/strings.xml
View file @
6a148b5d
...
...
@@ -53,6 +53,10 @@
<string
name=
"update_available"
>
Update Available
</string>
<string
name=
"installed"
>
Installed
</string>
<string
name=
"not_installed"
>
Not Installed
</string>
<string
name=
"updated_on"
>
Updated on: %1$s
</string>
<string
name=
"sorting_order"
>
Sorting Order
</string>
<string
name=
"sort_by_name"
>
Sort by name
</string>
<string
name=
"sort_by_update"
>
Sort by last update
</string>
<!--Log Fragment-->
<string
name=
"menuSaveLog"
>
Save log
</string>
...
...
src/main/res/values/styles.xml
View file @
6a148b5d
...
...
@@ -12,7 +12,7 @@
<item
name=
"windowActionBar"
>
false
</item>
<item
name=
"windowNoTitle"
>
true
</item>
<item
name=
"android:statusBarColor"
>
@android:color/transparent
</item>
<item
name=
"imageColorTint"
>
@android:color/
background_dark
</item>
<item
name=
"imageColorTint"
>
@android:color/
secondary_text_light
</item>
</style>
<style
name=
"AppTheme.Dark"
parent=
"Theme.AppCompat.NoActionBar"
>
...
...
@@ -25,7 +25,7 @@
<item
name=
"windowNoTitle"
>
true
</item>
<item
name=
"android:statusBarColor"
>
@android:color/transparent
</item>
<item
name=
"android:textColorSecondary"
>
@color/dark_secondary_text
</item>
<item
name=
"imageColorTint"
>
@
android:color/background_ligh
t
</item>
<item
name=
"imageColorTint"
>
@
color/dark_secondary_tex
t
</item>
</style>
<style
name=
"CardViewStyle.Dark"
parent=
"CardView"
>
...
...
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