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
e73497e4
Commit
e73497e4
authored
Sep 27, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update UI callback with prefs listener
parent
835ef01a
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
161 additions
and
198 deletions
+161
-198
AutoRootFragment.java
app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java
+1
-1
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+1
-1
ModulesAdapter.java
app/src/main/java/com/topjohnwu/magisk/ModulesAdapter.java
+32
-31
ModulesFragment.java
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+39
-66
ReposFragment.java
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
+57
-74
SplashActivity.java
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+6
-1
Module.java
app/src/main/java/com/topjohnwu/magisk/module/Module.java
+1
-0
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+13
-12
RepoHelper.java
app/src/main/java/com/topjohnwu/magisk/utils/RepoHelper.java
+3
-1
list_item_module.xml
app/src/main/res/layout/list_item_module.xml
+2
-2
modules_fragment.xml
app/src/main/res/layout/modules_fragment.xml
+3
-5
drawer.xml
app/src/main/res/menu/drawer.xml
+1
-1
strings.xml
app/src/main/res/values/strings.xml
+2
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java
View file @
e73497e4
...
@@ -63,7 +63,7 @@ public class AutoRootFragment extends ListFragment {
...
@@ -63,7 +63,7 @@ public class AutoRootFragment extends ListFragment {
super
.
onResume
();
super
.
onResume
();
initializeElements
();
initializeElements
();
super
.
onResume
();
super
.
onResume
();
getActivity
().
setTitle
(
R
.
string
.
auto_toggle
_apps
);
getActivity
().
setTitle
(
R
.
string
.
auto_toggle
);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
e73497e4
...
@@ -211,7 +211,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -211,7 +211,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
navFragment
=
new
RootFragment
();
navFragment
=
new
RootFragment
();
break
;
break
;
case
R
.
id
.
autoroot
:
case
R
.
id
.
autoroot
:
setTitle
(
R
.
string
.
auto_toggle
_apps
);
setTitle
(
R
.
string
.
auto_toggle
);
tag
=
"autoroot"
;
tag
=
"autoroot"
;
navFragment
=
new
AutoRootFragment
();
navFragment
=
new
AutoRootFragment
();
break
;
break
;
...
...
app/src/main/java/com/topjohnwu/magisk/ModulesAdapter.java
View file @
e73497e4
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
;
import
android.animation.Animator
;
import
android.animation.ValueAnimator
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.support.design.widget.Snackbar
;
import
android.content.SharedPreferences
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.preference.PreferenceManager
;
import
android.support.v7.app.AlertDialog
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.util.DisplayMetrics
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.view.ViewTreeObserver
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.widget.CheckBox
;
import
android.widget.CheckBox
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebWindow
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -39,28 +24,44 @@ import butterknife.ButterKnife;
...
@@ -39,28 +24,44 @@ import butterknife.ButterKnife;
public
class
ModulesAdapter
extends
RecyclerView
.
Adapter
<
ModulesAdapter
.
ViewHolder
>
{
public
class
ModulesAdapter
extends
RecyclerView
.
Adapter
<
ModulesAdapter
.
ViewHolder
>
{
//@BindView(R.id.expand_layout) LinearLayout expandedLayout;
private
final
List
<
Module
>
mList
;
private
final
List
<
Module
>
mList
;
private
View
viewMain
;
private
View
mView
;
private
Context
context
;
private
Context
context
;
private
final
Utils
.
ItemClickListener
chboxListener
;
private
final
Utils
.
ItemClickListener
deleteBtnListener
;
private
Utils
.
ItemClickListener
chboxListener
,
deleteBtnListener
,
unDeleteBtnListener
;
private
final
Utils
.
ItemClickListener
unDeleteBtnListener
;
public
ModulesAdapter
(
List
<
Module
>
list
)
{
public
ModulesAdapter
(
List
<
Module
>
list
,
Utils
.
ItemClickListener
chboxListener
,
Utils
.
ItemClickListener
deleteBtnListener
,
Utils
.
ItemClickListener
undeleteBtnListener
)
{
mList
=
list
;
this
.
mList
=
list
;
chboxListener
=
(
chk
,
position
)
->
{
this
.
chboxListener
=
chboxListener
;
// On Checkbox change listener
this
.
deleteBtnListener
=
deleteBtnListener
;
CheckBox
chbox
=
(
CheckBox
)
chk
;
this
.
unDeleteBtnListener
=
undeleteBtnListener
;
if
(!
chbox
.
isChecked
())
{
mList
.
get
(
position
).
createDisableFile
();
Snackbar
.
make
(
mView
,
R
.
string
.
disable_file_created
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
else
{
mList
.
get
(
position
).
removeDisableFile
();
Snackbar
.
make
(
mView
,
R
.
string
.
disable_file_removed
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
};
deleteBtnListener
=
(
deleteBtn
,
position
)
->
{
// On delete button click listener
mList
.
get
(
position
).
createRemoveFile
();
Snackbar
.
make
(
mView
,
R
.
string
.
remove_file_created
,
Snackbar
.
LENGTH_SHORT
).
show
();
};
unDeleteBtnListener
=
(
undeleteBtn
,
position
)
->
{
// On undelete button click listener
mList
.
get
(
position
).
deleteRemoveFile
();
Snackbar
.
make
(
mView
,
R
.
string
.
remove_file_deleted
,
Snackbar
.
LENGTH_SHORT
).
show
();
};
}
}
@Override
@Override
public
ViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
public
ViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
viewMain
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
list_item_module
,
parent
,
false
);
mView
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
list_item_module
,
parent
,
false
);
context
=
parent
.
getContext
();
context
=
parent
.
getContext
();
ButterKnife
.
bind
(
this
,
viewMain
);
ButterKnife
.
bind
(
this
,
mView
);
return
new
ViewHolder
(
viewMain
);
return
new
ViewHolder
(
mView
);
}
}
@Override
@Override
...
...
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
e73497e4
...
@@ -12,17 +12,17 @@ import android.support.design.widget.FloatingActionButton;
...
@@ -12,17 +12,17 @@ import android.support.design.widget.FloatingActionButton;
import
android.support.design.widget.Snackbar
;
import
android.support.design.widget.Snackbar
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.CheckBox
;
import
android.widget.CheckBox
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.ipaulpro.afilechooser.FileInfo
;
import
com.ipaulpro.afilechooser.utils.FileUtils
;
import
com.ipaulpro.afilechooser.utils.FileUtils
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -40,15 +40,17 @@ public class ModulesFragment extends Fragment {
...
@@ -40,15 +40,17 @@ public class ModulesFragment extends Fragment {
private
SharedPreferences
prefs
;
private
SharedPreferences
prefs
;
public
static
List
<
Module
>
listModules
=
new
ArrayList
<>();
public
static
List
<
Module
>
listModules
=
new
ArrayList
<>();
private
View
viewMain
;
private
View
mView
;
private
SharedPreferences
.
OnSharedPreferenceChangeListener
listener
;
@Nullable
@Nullable
@Override
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
viewMain
=
inflater
.
inflate
(
R
.
layout
.
modules_fragment
,
container
,
false
);
mView
=
inflater
.
inflate
(
R
.
layout
.
modules_fragment
,
container
,
false
);
ButterKnife
.
bind
(
this
,
viewMain
);
ButterKnife
.
bind
(
this
,
mView
);
mSwipeRefreshLayout
.
setRefreshing
(
true
);
mSwipeRefreshLayout
.
setRefreshing
(
true
);
fabio
.
setOnClickListener
(
v
->
{
fabio
.
setOnClickListener
(
v
->
{
Intent
getContentIntent
=
FileUtils
.
createGetContentIntent
(
null
);
Intent
getContentIntent
=
FileUtils
.
createGetContentIntent
(
null
);
getContentIntent
.
setType
(
"application/zip"
);
getContentIntent
.
setType
(
"application/zip"
);
...
@@ -60,21 +62,24 @@ public class ModulesFragment extends Fragment {
...
@@ -60,21 +62,24 @@ public class ModulesFragment extends Fragment {
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
recyclerView
.
setVisibility
(
View
.
GONE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
new
Async
.
LoadModules
(
getActivity
()).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
prefs
.
edit
().
putBoolean
(
"module_done"
,
false
).
apply
();
new
UpdateUI
().
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
LoadModules
(
getActivity
()).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
prefs
.
edit
().
putBoolean
(
"ignoreUpdateAlerts"
,
false
).
apply
();
});
});
prefs
.
registerOnSharedPreferenceChangeListener
((
sharedPreferences
,
s
)
->
{
if
(
prefs
.
getBoolean
(
"module_done"
,
false
))
{
if
(
s
.
contains
(
"updated"
))
{
updateUI
();
viewMain
.
invalidate
();
}
viewMain
.
requestLayout
();
listener
=
(
pref
,
s
)
->
{
if
(
s
.
equals
(
"module_done"
))
{
if
(
pref
.
getBoolean
(
s
,
false
))
{
Logger
.
dh
(
"ModulesFragment: UI refresh triggered"
);
updateUI
();
}
}
}
}
)
;
};
new
UpdateUI
().
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
return
mView
;
return
viewMain
;
}
}
@Override
@Override
...
@@ -82,14 +87,8 @@ public class ModulesFragment extends Fragment {
...
@@ -82,14 +87,8 @@ public class ModulesFragment extends Fragment {
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
// Get the URI of the selected file
// Get the URI of the selected file
final
Uri
uri
=
data
.
getData
();
final
Uri
uri
=
data
.
getData
();
try
{
// Get the file path from the URI
// Get the file path from the URI
new
Async
.
FlashZIP
(
getActivity
(),
uri
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
FlashZIP
(
getActivity
(),
uri
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
FileInfo
fileInfo
=
FileUtils
.
getFileInfo
(
getActivity
(),
uri
);
}
catch
(
Exception
e
)
{
Log
.
e
(
"FileSelectorTestAc..."
,
"File select error"
,
e
);
}
}
}
}
}
...
@@ -97,52 +96,26 @@ public class ModulesFragment extends Fragment {
...
@@ -97,52 +96,26 @@ public class ModulesFragment extends Fragment {
@Override
@Override
public
void
onResume
()
{
public
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
viewMain
=
this
.
getView
();
mView
=
this
.
getView
();
getActivity
().
setTitle
(
"Modules"
);
getActivity
().
setTitle
(
R
.
string
.
modules
);
prefs
.
registerOnSharedPreferenceChangeListener
(
listener
);
}
}
private
class
UpdateUI
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
@Override
public
void
onDestroy
()
{
// Just for blocking
super
.
onDestroy
();
@Override
prefs
.
unregisterOnSharedPreferenceChangeListener
(
listener
);
protected
Void
doInBackground
(
Void
...
voids
)
{
}
return
null
;
}
@Override
protected
void
onPostExecute
(
Void
v
)
{
super
.
onPostExecute
(
v
);
if
(
listModules
.
size
()
==
0
)
{
emptyTv
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
}
else
{
recyclerView
.
setVisibility
(
View
.
VISIBLE
);
}
recyclerView
.
setAdapter
(
new
ModulesAdapter
(
listModules
,
(
chk
,
position
)
->
{
// On Checkbox change listener
CheckBox
chbox
=
(
CheckBox
)
chk
;
if
(!
chbox
.
isChecked
())
{
listModules
.
get
(
position
).
createDisableFile
();
Snackbar
.
make
(
viewMain
,
R
.
string
.
disable_file_created
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
else
{
listModules
.
get
(
position
).
removeDisableFile
();
Snackbar
.
make
(
viewMain
,
R
.
string
.
disable_file_removed
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
},
(
deleteBtn
,
position
)
->
{
// On delete button click listener
listModules
.
get
(
position
).
createRemoveFile
();
Snackbar
.
make
(
viewMain
,
R
.
string
.
remove_file_created
,
Snackbar
.
LENGTH_SHORT
).
show
();
},
(
undeleteBtn
,
position
)
->
{
// On undelete button click listener
listModules
.
get
(
position
).
deleteRemoveFile
();
Snackbar
.
make
(
viewMain
,
R
.
string
.
remove_file_deleted
,
Snackbar
.
LENGTH_SHORT
).
show
();
}));
mSwipeRefreshLayout
.
setRefreshing
(
false
);
private
void
updateUI
()
{
if
(
listModules
.
size
()
==
0
)
{
emptyTv
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
}
else
{
recyclerView
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setAdapter
(
new
ModulesAdapter
(
listModules
));
}
}
mSwipeRefreshLayout
.
setRefreshing
(
false
);
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
e73497e4
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
;
import
android.app.Fragment
;
import
android.app.Fragment
;
import
android.content.
DialogInterface
;
import
android.content.
SharedPreferences
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
...
@@ -16,14 +16,10 @@ import android.view.ViewGroup;
...
@@ -16,14 +16,10 @@ import android.view.ViewGroup;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -32,37 +28,51 @@ import butterknife.ButterKnife;
...
@@ -32,37 +28,51 @@ import butterknife.ButterKnife;
public
class
ReposFragment
extends
Fragment
{
public
class
ReposFragment
extends
Fragment
{
public
static
List
<
Repo
>
mListRepos
=
new
ArrayList
<>();
public
static
List
<
Repo
>
mListRepos
=
new
ArrayList
<>();
public
static
List
<
Repo
>
mListReposToUpdate
=
new
ArrayList
<>();
@BindView
(
R
.
id
.
recyclerView
)
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
RecyclerView
recyclerView
;
@BindView
(
R
.
id
.
empty_rv
)
TextView
emptyTv
;
@BindView
(
R
.
id
.
empty_rv
)
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
TextView
emptyTv
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
swipeRefreshLayout
;
private
View
mView
;
private
View
mView
;
private
boolean
mCanUpdate
;
private
boolean
mCanUpdate
;
private
boolean
alertUpdate
;
private
boolean
alertUpdate
;
private
boolean
ignoreAlertUpdate
;
private
boolean
ignoreAlertUpdate
;
private
String
alertPackage
;
private
String
alertPackage
;
private
AlertDialog
.
Builder
builder
;
private
AlertDialog
.
Builder
builder
;
// private SharedPreferences prefs;
private
SharedPreferences
.
OnSharedPreferenceChangeListener
listener
;
private
SharedPreferences
prefs
;
@Nullable
@Nullable
@Override
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
repos_fragment
,
container
,
false
);
mView
=
inflater
.
inflate
(
R
.
layout
.
repos_fragment
,
container
,
false
);
mView
=
view
;
ButterKnife
.
bind
(
this
,
mView
);
ButterKnife
.
bind
(
this
,
view
);
swipeRefreshLayout
.
setOnRefreshListener
(()
->
{
mSwipeRefreshLayout
.
setRefreshing
(
true
);
new
Async
.
LoadRepos
(
getActivity
()).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
UpdateUI
().
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getActivity
());
ignoreAlertUpdate
=
false
;
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
recyclerView
.
setVisibility
(
View
.
GONE
);
prefs
.
edit
().
putBoolean
(
"repo_done"
,
false
).
apply
();
new
Async
.
LoadRepos
(
getActivity
()).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
});
});
if
(
prefs
.
getBoolean
(
"repo_done"
,
false
))
{
updateUI
();
}
listener
=
(
pref
,
s
)
->
{
if
(
s
.
equals
(
"repo_done"
))
{
if
(
pref
.
getBoolean
(
s
,
false
))
{
Logger
.
dh
(
"ReposFragment: UI refresh triggered"
);
updateUI
();
}
}
};
//LoadRepo(false);
//LoadRepo(false);
new
UpdateUI
().
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
setHasOptionsMenu
(
false
);
alertUpdate
=
false
;
// if (mListRepos.size() == 0) {
// if (mListRepos.size() == 0) {
// emptyTv.setVisibility(View.VISIBLE);
// emptyTv.setVisibility(View.VISIBLE);
// recyclerView.setVisibility(View.GONE);
// recyclerView.setVisibility(View.GONE);
...
@@ -71,18 +81,18 @@ public class ReposFragment extends Fragment {
...
@@ -71,18 +81,18 @@ public class ReposFragment extends Fragment {
//CheckForUpdates();
//CheckForUpdates();
//recyclerView.setAdapter(new ReposAdapter(this, mListRepos));
//recyclerView.setAdapter(new ReposAdapter(this, mListRepos));
return
v
iew
;
return
mV
iew
;
}
}
private
void
CheckForUpdates
()
{
//
private void CheckForUpdates() {
for
(
int
i
=
0
;
i
<
mListRepos
.
size
();
i
++)
{
//
for (int i = 0; i < mListRepos.size(); i++) {
if
(
mListRepos
.
get
(
i
).
canUpdate
())
{
//
if (mListRepos.get(i).canUpdate()) {
alertUpdate
=
true
;
//
alertUpdate = true;
mListReposToUpdate
.
add
(
mListRepos
.
get
(
i
));
//
mListReposToUpdate.add(mListRepos.get(i));
//
}
//
}
}
//
}
}
//
}
@Override
@Override
public
void
onAttachFragment
(
Fragment
childFragment
)
{
public
void
onAttachFragment
(
Fragment
childFragment
)
{
...
@@ -154,52 +164,25 @@ public class ReposFragment extends Fragment {
...
@@ -154,52 +164,25 @@ public class ReposFragment extends Fragment {
@Override
@Override
public
void
onResume
()
{
public
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
//LoadRepo(false);
getActivity
().
setTitle
(
R
.
string
.
downloads
);
getActivity
().
setTitle
(
"Magisk"
);
prefs
.
registerOnSharedPreferenceChangeListener
(
listener
);
}
}
private
class
UpdateUI
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
@Override
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
public
void
onDestroy
()
{
return
null
;
super
.
onDestroy
();
}
prefs
.
unregisterOnSharedPreferenceChangeListener
(
listener
);
}
@Override
protected
void
onPostExecute
(
Void
v
)
{
super
.
onPostExecute
(
v
);
if
(
mListRepos
.
size
()
==
0
)
{
emptyTv
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
}
private
void
updateUI
()
{
Log
.
d
(
"Magisk"
,
"ReposFragment: ListRepos size is "
+
mListRepos
.
size
());
if
(
mListRepos
.
size
()
==
0
)
{
emptyTv
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
}
else
{
recyclerView
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setAdapter
(
new
ReposAdapter
(
mListRepos
));
recyclerView
.
setAdapter
(
new
ReposAdapter
(
mListRepos
));
if
(
swipeRefreshLayout
.
isRefreshing
())
{
swipeRefreshLayout
.
setRefreshing
(
false
);
//CheckForUpdates();
//NotifyOfAlerts();
}
}
}
mSwipeRefreshLayout
.
setRefreshing
(
false
);
}
}
// private void UpdateUI() {
// Log.d("Magisk", "ReposFragment: UpdateUI Called, size is " + mListRepos.size());
//
// if (mListRepos.size() == 0) {
// emptyTv.setVisibility(View.VISIBLE);
// recyclerView.setVisibility(View.GONE);
//
// }
// Log.d("Magisk", "ReposFragment: ListRepos size is " + mListRepos.size());
// recyclerView.setAdapter(new ReposAdapter(this, mListRepos));
// if (swipeRefreshLayout.isRefreshing()) {
// swipeRefreshLayout.setRefreshing(false);
// CheckForUpdates();
// //NotifyOfAlerts();
// }
//
// }
}
}
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
e73497e4
...
@@ -66,8 +66,13 @@ public class SplashActivity extends AppCompatActivity {
...
@@ -66,8 +66,13 @@ public class SplashActivity extends AppCompatActivity {
// Initialize
// Initialize
Utils
.
init
(
this
);
Utils
.
init
(
this
);
defaultPrefs
.
edit
()
.
putBoolean
(
"module_done"
,
false
)
.
putBoolean
(
"repo_done"
,
false
)
.
apply
();
new
Async
.
CheckUpdates
(
this
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
CheckUpdates
(
this
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
LoadModules
(
this
).
executeOnExecutor
(
AsyncTask
.
SERIA
L_EXECUTOR
);
new
Async
.
LoadModules
(
this
).
executeOnExecutor
(
AsyncTask
.
THREAD_POO
L_EXECUTOR
);
new
Async
.
LoadRepos
(
this
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
LoadRepos
(
this
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
new
Async
.
BusyboxEnv
(
this
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
new
Async
.
BusyboxEnv
(
this
).
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
);
...
...
app/src/main/java/com/topjohnwu/magisk/module/Module.java
View file @
e73497e4
package
com
.
topjohnwu
.
magisk
.
module
;
package
com
.
topjohnwu
.
magisk
.
module
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.RepoHelper
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
Module
extends
BaseModule
{
public
class
Module
extends
BaseModule
{
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
e73497e4
package
com
.
topjohnwu
.
magisk
.
utils
;
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.app.ProgressDialog
;
import
android.app.ProgressDialog
;
import
android.content.ContentResolver
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.
DialogInterface
;
import
android.content.
SharedPreferences
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.renderscript.ScriptGroup
;
import
android.support.v7.app.AlertDialog
;
import
android.support.v7.app.AlertDialog
;
import
android.util.Log
;
import
android.util.Log
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.ipaulpro.afilechooser.FileInfo
;
import
com.ipaulpro.afilechooser.utils.FileUtils
;
import
com.topjohnwu.magisk.ModulesFragment
;
import
com.topjohnwu.magisk.ModulesFragment
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.RepoHelper
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
...
@@ -157,6 +148,11 @@ public class Async {
...
@@ -157,6 +148,11 @@ public class Async {
return
null
;
return
null
;
}
}
@Override
protected
void
onPostExecute
(
Void
v
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
);
prefs
.
edit
().
putBoolean
(
"module_done"
,
true
).
apply
();
}
}
}
public
static
class
LoadRepos
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
public
static
class
LoadRepos
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
...
@@ -176,11 +172,16 @@ public class Async {
...
@@ -176,11 +172,16 @@ public class Async {
return
null
;
return
null
;
}
}
@Override
protected
void
onPostExecute
(
Void
v
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
);
prefs
.
edit
().
putBoolean
(
"repo_done"
,
true
).
apply
();
}
}
}
public
static
class
FlashZIP
extends
AsyncTask
<
Void
,
Void
,
Boolean
>
{
public
static
class
FlashZIP
extends
AsyncTask
<
Void
,
Void
,
Boolean
>
{
private
String
m
Path
,
m
Name
;
private
String
mName
;
private
Uri
mUri
;
private
Uri
mUri
;
private
ProgressDialog
progress
;
private
ProgressDialog
progress
;
private
File
mFile
,
sdFile
;
private
File
mFile
,
sdFile
;
...
@@ -282,7 +283,7 @@ public class Async {
...
@@ -282,7 +283,7 @@ public class Async {
if
(
sdFile
==
null
)
{
if
(
sdFile
==
null
)
{
Toast
.
makeText
(
mContext
,
mContext
.
getString
(
R
.
string
.
install_error
),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
mContext
,
mContext
.
getString
(
R
.
string
.
install_error
),
Toast
.
LENGTH_LONG
).
show
();
}
else
{
}
else
{
Toast
.
makeText
(
mContext
,
mContext
.
getString
(
R
.
string
.
manual_install
,
m
Path
),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
mContext
,
mContext
.
getString
(
R
.
string
.
manual_install
,
m
File
.
getAbsolutePath
()
),
Toast
.
LENGTH_LONG
).
show
();
}
}
return
;
return
;
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/
module
/RepoHelper.java
→
app/src/main/java/com/topjohnwu/magisk/
utils
/RepoHelper.java
View file @
e73497e4
package
com
.
topjohnwu
.
magisk
.
module
;
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
...
@@ -7,6 +7,8 @@ import com.google.gson.Gson;
...
@@ -7,6 +7,8 @@ import com.google.gson.Gson;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
com.topjohnwu.magisk.ModulesFragment
;
import
com.topjohnwu.magisk.ModulesFragment
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebRequest
;
import
com.topjohnwu.magisk.utils.WebRequest
;
...
...
app/src/main/res/layout/list_item_module.xml
View file @
e73497e4
...
@@ -82,10 +82,10 @@
...
@@ -82,10 +82,10 @@
<LinearLayout
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignBaseline=
"@id/title"
android:layout_alignParentEnd=
"true"
android:layout_alignParentEnd=
"true"
android:layout_alignParentTop=
"true"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
android:
paddingTop=
"20dp
"
>
android:
gravity=
"end
"
>
<CheckBox
<CheckBox
...
...
app/src/main/res/layout/modules_fragment.xml
View file @
e73497e4
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/swipeRefreshLayout"
android:id=
"@+id/swipeRefreshLayout"
...
@@ -10,7 +9,8 @@
...
@@ -10,7 +9,8 @@
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<android.support.design.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/llayout"
android:id=
"@+id/llayout"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -47,9 +47,7 @@
...
@@ -47,9 +47,7 @@
android:baselineAlignBottom=
"false"
android:baselineAlignBottom=
"false"
android:clickable=
"true"
android:clickable=
"true"
android:src=
"@drawable/ic_add"
android:src=
"@drawable/ic_add"
app:layout_anchorGravity=
"bottom|center_horizontal"
android:layout_gravity=
"bottom|center_horizontal"
/>
app:layout_anchor=
"@+id/empty_rv"
android:layout_gravity=
"top|center_horizontal"
/>
</android.support.design.widget.CoordinatorLayout>
</android.support.design.widget.CoordinatorLayout>
...
...
app/src/main/res/menu/drawer.xml
View file @
e73497e4
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
<item
<item
android:id=
"@+id/autoroot"
android:id=
"@+id/autoroot"
android:icon=
"@drawable/ic_autoroot"
android:icon=
"@drawable/ic_autoroot"
android:title=
"@string/auto_toggle
_apps
"
/>
android:title=
"@string/auto_toggle"
/>
<item
<item
android:id=
"@+id/modules"
android:id=
"@+id/modules"
...
...
app/src/main/res/values/strings.xml
View file @
e73497e4
...
@@ -7,7 +7,9 @@
...
@@ -7,7 +7,9 @@
<string
name=
"navigation_drawer_open"
>
Open navigation drawer
</string>
<string
name=
"navigation_drawer_open"
>
Open navigation drawer
</string>
<string
name=
"navigation_drawer_close"
>
Close navigation drawer
</string>
<string
name=
"navigation_drawer_close"
>
Close navigation drawer
</string>
<string
name=
"root"
>
Root
</string>
<string
name=
"root"
>
Root
</string>
<string
name=
"auto_toggle"
>
Auto-toggle
</string>
<string
name=
"modules"
>
Modules
</string>
<string
name=
"modules"
>
Modules
</string>
<string
name=
"downloads"
>
Downloads
</string>
<string
name=
"log"
>
Log
</string>
<string
name=
"log"
>
Log
</string>
<!--Magisk Fragment-->
<!--Magisk Fragment-->
...
@@ -104,7 +106,6 @@
...
@@ -104,7 +106,6 @@
<!--Web Related-->
<!--Web Related-->
<string
name=
"pass"
>
MagiskRox666
</string>
<string
name=
"pass"
>
MagiskRox666
</string>
<string
name=
"some_string"
>
GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus
</string>
<string
name=
"some_string"
>
GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus
</string>
<string
name=
"downloads"
>
Downloads
</string>
<string
name=
"url_main"
>
https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=
</string>
<string
name=
"url_main"
>
https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=
</string>
<string
name=
"file_url"
>
https://raw.githubusercontent.com/Magisk-Modules-Repo/%1$s/master/%2$s
</string>
<string
name=
"file_url"
>
https://raw.githubusercontent.com/Magisk-Modules-Repo/%1$s/master/%2$s
</string>
<string
name=
"zip_url"
>
https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip
</string>
<string
name=
"zip_url"
>
https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip
</string>
...
@@ -124,8 +125,6 @@
...
@@ -124,8 +125,6 @@
<string
name=
"settings_hide_root_notification_title"
>
Hide auto-toggle notifications
</string>
<string
name=
"settings_hide_root_notification_title"
>
Hide auto-toggle notifications
</string>
<!--General Use -->
<!--General Use -->
<string
name=
"auto_toggle"
>
Auto-toggle
</string>
<string
name=
"auto_toggle_apps"
>
Auto-toggle List
</string>
<string
name=
"toast_error_makedir"
>
Error creating directory, could not download file.
</string>
<string
name=
"toast_error_makedir"
>
Error creating directory, could not download file.
</string>
<string
name=
"toast_error_removing_files"
>
Error removing old files, cancelled.
</string>
<string
name=
"toast_error_removing_files"
>
Error removing old files, cancelled.
</string>
<string
name=
"settings_general_title"
>
General
</string>
<string
name=
"settings_general_title"
>
General
</string>
...
...
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