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
4692ed4b
Commit
4692ed4b
authored
Aug 17, 2016
by
dvdandroid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load modules in a listview
parent
615bbcae
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
333 additions
and
73 deletions
+333
-73
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+6
-4
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+3
-0
Module.java
app/src/main/java/com/topjohnwu/magisk/Module.java
+83
-0
ModulesActivity.java
app/src/main/java/com/topjohnwu/magisk/ModulesActivity.java
+132
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+62
-58
activity_modules.xml
app/src/main/res/layout/activity_modules.xml
+14
-0
row.xml
app/src/main/res/layout/row.xml
+32
-0
dimens.xml
app/src/main/res/values-w820dp/dimens.xml
+0
-6
dimens.xml
app/src/main/res/values/dimens.xml
+0
-5
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
4692ed4b
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android
"
<manifest
package=
"com.topjohnwu.magisk
"
package=
"com.topjohnwu.magisk
"
>
xmlns:android=
"http://schemas.android.com/apk/res/android
"
>
<application
<application
android:allowBackup=
"true"
android:allowBackup=
"true"
...
@@ -10,11 +10,13 @@
...
@@ -10,11 +10,13 @@
android:theme=
"@style/AppTheme"
>
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".MainActivity"
>
<activity
android:name=
".MainActivity"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".ModulesActivity"
>
</activity>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
4692ed4b
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
@@ -53,6 +54,8 @@ public class MainActivity extends Activity {
...
@@ -53,6 +54,8 @@ public class MainActivity extends Activity {
new
SU
().
execute
(
"setenforce 0"
);
new
SU
().
execute
(
"setenforce 0"
);
}
}
});
});
findViewById
(
R
.
id
.
modules
).
setOnClickListener
(
view
->
startActivity
(
new
Intent
(
this
,
ModulesActivity
.
class
)));
}
}
private
String
execute
(
String
command
)
{
private
String
execute
(
String
command
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/Module.java
0 → 100644
View file @
4692ed4b
package
com
.
topjohnwu
.
magisk
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileReader
;
public
class
Module
{
private
final
boolean
isValid
;
private
final
boolean
isCache
;
private
File
mPropFile
;
private
String
mName
;
private
String
mVersion
;
private
int
mVersionCode
;
private
String
mDescription
;
public
Module
(
File
file
)
{
this
.
isCache
=
file
.
getPath
().
contains
(
"cache"
);
this
.
isValid
=
new
File
(
file
+
"/module.prop"
).
exists
();
if
(
isValid
)
{
mPropFile
=
new
File
(
file
+
"/module.prop"
);
}
}
public
boolean
isValid
()
{
return
isValid
&&
mPropFile
!=
null
;
}
public
boolean
isCache
()
{
return
isCache
;
}
public
String
getName
()
{
return
mName
;
}
public
int
getVersionCode
()
{
return
mVersionCode
;
}
public
String
getVersion
()
{
return
mVersion
;
}
public
String
getDescription
()
{
return
mDescription
;
}
public
void
parse
()
throws
Exception
{
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
mPropFile
));
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
String
[]
parts
=
line
.
split
(
"="
,
2
);
if
(
parts
.
length
!=
2
)
{
continue
;
}
String
key
=
parts
[
0
].
trim
();
if
(
key
.
charAt
(
0
)
==
'#'
)
{
continue
;
}
String
value
=
parts
[
1
].
trim
();
switch
(
key
)
{
case
"name"
:
mName
=
value
;
break
;
case
"version"
:
mVersion
=
value
;
break
;
case
"versionCode"
:
mVersionCode
=
Integer
.
parseInt
(
value
);
break
;
case
"description"
:
mDescription
=
value
;
break
;
}
}
reader
.
close
();
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/ModulesActivity.java
0 → 100644
View file @
4692ed4b
package
com
.
topjohnwu
.
magisk
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ArrayAdapter
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ModulesActivity
extends
Activity
{
private
static
final
String
MAGISK_PATH
=
"/magisk"
;
private
static
final
String
MAGISK_CACHE_PATH
=
"/cache/magisk"
;
private
List
<
Module
>
listModules
=
new
ArrayList
<>();
private
ListView
mListView
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_modules
);
mListView
=
(
ListView
)
findViewById
(
android
.
R
.
id
.
list
);
new
CheckFolders
().
execute
();
}
private
class
CheckFolders
extends
AsyncTask
<
Void
,
Integer
,
Boolean
>
{
private
ProgressDialog
progress
;
@Override
protected
void
onPreExecute
()
{
super
.
onPreExecute
();
progress
=
ProgressDialog
.
show
(
ModulesActivity
.
this
,
null
,
getString
(
R
.
string
.
loading
),
true
,
false
);
}
@Override
protected
Boolean
doInBackground
(
Void
...
voids
)
{
File
[]
magisk
=
new
File
(
MAGISK_PATH
).
listFiles
(
File:
:
isDirectory
);
File
[]
magiskCache
=
new
File
(
MAGISK_CACHE_PATH
).
listFiles
(
File:
:
isDirectory
);
if
(
magisk
!=
null
)
{
for
(
File
mod
:
magisk
)
{
listModules
.
add
(
new
Module
(
mod
));
}
}
if
(
magiskCache
!=
null
)
{
for
(
File
mod
:
magiskCache
)
{
listModules
.
add
(
new
Module
(
mod
));
}
}
//noinspection Convert2streamapi
for
(
Module
module
:
listModules
)
{
if
(
module
.
isValid
())
try
{
module
.
parse
();
}
catch
(
Exception
ignored
)
{
}
}
return
true
;
}
@Override
protected
void
onPostExecute
(
Boolean
aBoolean
)
{
super
.
onPostExecute
(
aBoolean
);
progress
.
dismiss
();
mListView
.
setAdapter
(
new
ModulesAdapter
(
ModulesActivity
.
this
,
R
.
layout
.
row
));
}
}
private
class
ModulesAdapter
extends
ArrayAdapter
<
Module
>
{
public
ModulesAdapter
(
Context
context
,
int
resource
)
{
super
(
context
,
resource
);
}
@SuppressLint
(
"SetTextI18n"
)
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
ViewHolder
vh
;
if
(
convertView
==
null
)
{
LayoutInflater
inflater
=
(
LayoutInflater
)
getContext
().
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
convertView
=
inflater
.
inflate
(
R
.
layout
.
row
,
null
);
vh
=
new
ViewHolder
();
vh
.
name
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
name
);
vh
.
version
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
version
);
vh
.
versionCode
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
versionCode
);
vh
.
description
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
description
);
vh
.
cache
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
cache
);
convertView
.
setTag
(
vh
);
}
else
{
vh
=
(
ViewHolder
)
convertView
.
getTag
();
}
Module
module
=
getItem
(
position
);
vh
.
name
.
setText
(
"name= "
+
module
.
getName
());
vh
.
version
.
setText
(
"version= "
+
module
.
getVersion
());
vh
.
versionCode
.
setText
(
"versioncode= "
+
module
.
getVersionCode
());
vh
.
description
.
setText
(
"description= "
+
module
.
getDescription
());
vh
.
cache
.
setText
(
"is from cache= "
+
module
.
isCache
());
return
convertView
;
}
private
class
ViewHolder
{
public
TextView
name
;
public
TextView
version
;
public
TextView
versionCode
;
public
TextView
description
;
public
TextView
cache
;
}
}
}
app/src/main/res/layout/activity_main.xml
View file @
4692ed4b
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:focusableInTouchMode=
"true"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:focusableInTouchMode=
"true"
android:paddingBottom=
"@dimen/activity_vertical_margin"
tools:context=
"com.topjohnwu.magisk.MainActivity"
>
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:paddingTop=
"@dimen/activity_vertical_margin"
tools:context=
"com.topjohnwu.magisk.MainActivity"
>
<TextView
<TextView
android:id=
"@+id/magisk_label"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/magisk_label"
android:id=
"@+id/magisk_label"
android:layout_alignParentStart=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentTop=
"true"
android:layout_alignParentTop=
"true"
android:textSize=
"20sp"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
android:layout_marginTop=
"10dp"
/>
android:layout_marginTop=
"10dp"
android:text=
"@string/magisk_label"
android:textSize=
"20sp"
/>
<TextView
<TextView
android:id=
"@+id/magisk_version"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignTop=
"@+id/magisk_label"
android:layout_marginLeft=
"10dp"
android:layout_toEndOf=
"@+id/magisk_label"
android:text=
"@string/unavailable"
android:text=
"@string/unavailable"
android:id=
"@+id/magisk_version"
android:textStyle=
"bold"
android:textSize=
"20sp"
android:textSize=
"20sp"
android:layout_marginLeft=
"10dp"
android:textStyle=
"bold"
/>
android:layout_alignTop=
"@+id/magisk_label"
android:layout_toEndOf=
"@+id/magisk_label"
/>
<TextView
<TextView
android:id=
"@+id/root_label"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/root_label"
android:id=
"@+id/root_label"
android:layout_below=
"@+id/magisk_label"
android:layout_alignParentStart=
"true"
android:layout_alignParentStart=
"true"
android:
textSize=
"20sp
"
android:
layout_below=
"@+id/magisk_label
"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
android:layout_marginTop=
"10dp"
/>
android:layout_marginTop=
"10dp"
android:text=
"@string/root_label"
android:textSize=
"20sp"
/>
<TextView
<TextView
android:id=
"@+id/root_status"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignTop=
"@+id/root_label"
android:layout_marginLeft=
"10dp"
android:layout_toEndOf=
"@+id/root_label"
android:text=
"@string/unavailable"
android:text=
"@string/unavailable"
android:id=
"@+id/root_status"
android:textStyle=
"bold"
android:textSize=
"20sp"
android:textSize=
"20sp"
android:layout_marginLeft=
"10dp"
android:textStyle=
"bold"
/>
android:layout_alignTop=
"@+id/root_label"
android:layout_toEndOf=
"@+id/root_label"
/>
<TextView
<TextView
android:id=
"@+id/selinux_label"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/selinux_label"
android:id=
"@+id/selinux_label"
android:layout_alignParentStart=
"true"
android:layout_alignParentStart=
"true"
android:layout_below=
"@+id/root_label"
android:layout_below=
"@+id/root_label"
android:
textSize=
"20s
p"
android:
layout_marginLeft=
"10d
p"
android:layout_marginTop=
"10dp"
android:layout_marginTop=
"10dp"
android:layout_marginLeft=
"10dp"
/>
android:text=
"@string/selinux_label"
android:textSize=
"20sp"
/>
<TextView
<TextView
android:id=
"@+id/selinux_status"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignTop=
"@+id/selinux_label"
android:layout_marginLeft=
"10dp"
android:layout_toEndOf=
"@+id/selinux_label"
android:text=
"@string/unavailable"
android:text=
"@string/unavailable"
android:id=
"@+id/selinux_status"
android:textStyle=
"bold"
android:textSize=
"20sp"
android:textSize=
"20sp"
android:layout_marginLeft=
"10dp"
android:textStyle=
"bold"
/>
android:layout_alignTop=
"@+id/selinux_label"
android:layout_toEndOf=
"@+id/selinux_label"
/>
<TextView
<TextView
android:id=
"@+id/safety_net"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/unavailable"
android:id=
"@+id/safety_net"
android:layout_below=
"@+id/selinux_label"
android:layout_alignParentStart=
"true"
android:layout_alignParentStart=
"true"
android:layout_
marginTop=
"10dp
"
android:layout_
below=
"@+id/selinux_label
"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
android:layout_marginTop=
"10dp"
android:text=
"@string/unavailable"
android:textSize=
"15sp"
/>
android:textSize=
"15sp"
/>
<TextView
<TextView
android:id=
"@+id/permissive"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/unavailable"
android:id=
"@+id/permissive"
android:layout_below=
"@+id/safety_net"
android:layout_alignParentStart=
"true"
android:layout_alignParentStart=
"true"
android:layout_
marginTop=
"5dp
"
android:layout_
below=
"@+id/safety_net
"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
android:layout_marginTop=
"5dp"
android:text=
"@string/unavailable"
android:textSize=
"15sp"
/>
android:textSize=
"15sp"
/>
<Switch
<Switch
android:id=
"@+id/root_toggle"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/root_toggle"
android:id=
"@+id/root_toggle"
android:layout_marginTop=
"10dp"
android:textSize=
"20sp"
android:switchPadding=
"20dp"
android:layout_below=
"@+id/permissive"
android:layout_alignParentStart=
"true"
android:layout_alignParentStart=
"true"
android:layout_below=
"@+id/permissive"
android:layout_marginLeft=
"10dp"
android:layout_marginLeft=
"10dp"
android:checked=
"false"
/>
android:layout_marginTop=
"10dp"
android:checked=
"false"
android:switchPadding=
"20dp"
android:text=
"@string/root_toggle"
android:textSize=
"20sp"
/>
<Switch
<Switch
android:id=
"@+id/selinux_toggle"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/selinux_toggle"
android:layout_alignParentStart=
"true"
android:id=
"@+id/selinux_toggle"
android:layout_below=
"@+id/root_toggle"
android:layout_marginLeft=
"10dp"
android:layout_marginTop=
"20dp"
android:layout_marginTop=
"20dp"
android:
textSize=
"20sp
"
android:
checked=
"false
"
android:switchPadding=
"20dp"
android:switchPadding=
"20dp"
android:layout_below=
"@+id/root_toggle"
android:text=
"@string/selinux_toggle"
android:textSize=
"20sp"
/>
<Button
android:id=
"@+id/modules"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentStart=
"true"
android:layout_marginLeft=
"10dp"
android:text=
"modules activity"
/>
android:checked=
"false"
/>
</RelativeLayout>
</RelativeLayout>
app/src/main/res/layout/activity_modules.xml
0 → 100644
View file @
4692ed4b
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"com.topjohnwu.magisk.ModulesActivity"
>
<ListView
android:id=
"@android:id/list"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</RelativeLayout>
app/src/main/res/layout/row.xml
0 → 100644
View file @
4692ed4b
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/version"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/versionCode"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/description"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/cache"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values-w820dp/dimens.xml
deleted
100644 → 0
View file @
615bbcae
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen
name=
"activity_horizontal_margin"
>
64dp
</dimen>
</resources>
app/src/main/res/values/dimens.xml
deleted
100644 → 0
View file @
615bbcae
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen
name=
"activity_horizontal_margin"
>
16dp
</dimen>
<dimen
name=
"activity_vertical_margin"
>
16dp
</dimen>
</resources>
app/src/main/res/values/strings.xml
View file @
4692ed4b
...
@@ -18,4 +18,5 @@
...
@@ -18,4 +18,5 @@
<string
name=
"root_none_info"
>
Safety Net (Android Pay) should work
</string>
<string
name=
"root_none_info"
>
Safety Net (Android Pay) should work
</string>
<string
name=
"magisk_version"
>
Magisk v%1$s
</string>
<string
name=
"magisk_version"
>
Magisk v%1$s
</string>
<string
name=
"selinux_samsung"
>
Samsung do not support switching SELinux status!
</string>
<string
name=
"selinux_samsung"
>
Samsung do not support switching SELinux status!
</string>
<string
name=
"loading"
>
Loading...
</string>
</resources>
</resources>
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