Update logs
This commit is contained in:
parent
586015c2ed
commit
49e546919a
@ -103,9 +103,6 @@ public class MagiskLogFragment extends Fragment {
|
|||||||
case R.id.menu_refresh:
|
case R.id.menu_refresh:
|
||||||
new LogManager().read();
|
new LogManager().read();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_send:
|
|
||||||
new LogManager().send();
|
|
||||||
return true;
|
|
||||||
case R.id.menu_save:
|
case R.id.menu_save:
|
||||||
new LogManager().save();
|
new LogManager().save();
|
||||||
return true;
|
return true;
|
||||||
|
@ -77,6 +77,8 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
private PreferenceScreen prefScreen;
|
private PreferenceScreen prefScreen;
|
||||||
|
|
||||||
|
private ListPreference suAccess, autoRes, suNotification, requestTimeout;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -87,19 +89,12 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
PreferenceCategory magiskCategory = (PreferenceCategory) findPreference("magisk");
|
PreferenceCategory magiskCategory = (PreferenceCategory) findPreference("magisk");
|
||||||
PreferenceCategory suCategory = (PreferenceCategory) findPreference("superuser");
|
PreferenceCategory suCategory = (PreferenceCategory) findPreference("superuser");
|
||||||
|
|
||||||
ListPreference suAccess = (ListPreference) findPreference("su_access");
|
suAccess = (ListPreference) findPreference("su_access");
|
||||||
ListPreference autoRes = (ListPreference) findPreference("su_auto_response");
|
autoRes = (ListPreference) findPreference("su_auto_response");
|
||||||
ListPreference requestTimeout = (ListPreference) findPreference("su_request_timeout");
|
requestTimeout = (ListPreference) findPreference("su_request_timeout");
|
||||||
ListPreference suNotification = (ListPreference) findPreference("su_notification");
|
suNotification = (ListPreference) findPreference("su_notification");
|
||||||
|
|
||||||
suAccess.setSummary(getResources()
|
setSummary();
|
||||||
.getStringArray(R.array.su_access)[Utils.getPrefsInt(prefs, "su_access", 3)]);
|
|
||||||
autoRes.setSummary(getResources()
|
|
||||||
.getStringArray(R.array.auto_response)[Utils.getPrefsInt(prefs, "su_auto_response", 0)]);
|
|
||||||
suNotification.setSummary(getResources()
|
|
||||||
.getStringArray(R.array.su_notification)[Utils.getPrefsInt(prefs, "su_notification", 1)]);
|
|
||||||
requestTimeout.setSummary(
|
|
||||||
getString(R.string.request_timeout_summary, prefs.getString("su_request_timeout", "10")));
|
|
||||||
|
|
||||||
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
||||||
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
|
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
|
||||||
@ -206,6 +201,8 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
case "su_access":
|
case "su_access":
|
||||||
Global.Configs.suAccessState = Utils.getPrefsInt(prefs, "su_access", 0);
|
Global.Configs.suAccessState = Utils.getPrefsInt(prefs, "su_access", 0);
|
||||||
Shell.su("setprop persist.sys.root_access " + Global.Configs.suAccessState);
|
Shell.su("setprop persist.sys.root_access " + Global.Configs.suAccessState);
|
||||||
|
suAccess.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.su_access)[Global.Configs.suAccessState]);
|
||||||
break;
|
break;
|
||||||
case "su_request_timeout":
|
case "su_request_timeout":
|
||||||
Global.Configs.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10);
|
Global.Configs.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10);
|
||||||
@ -223,6 +220,18 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
Global.Configs.shellLogging = prefs.getBoolean("shell_logging", false);
|
Global.Configs.shellLogging = prefs.getBoolean("shell_logging", false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
setSummary();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSummary() {
|
||||||
|
suAccess.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.su_access)[Global.Configs.suAccessState]);
|
||||||
|
autoRes.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.auto_response)[Global.Configs.suResponseType]);
|
||||||
|
suNotification.setSummary(getResources()
|
||||||
|
.getStringArray(R.array.su_notification)[Global.Configs.suNotificationType]);
|
||||||
|
requestTimeout.setSummary(
|
||||||
|
getString(R.string.request_timeout_summary, prefs.getString("su_request_timeout", "10")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -24,6 +28,19 @@ public class SuLogFragment extends Fragment {
|
|||||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||||
|
|
||||||
private Unbinder unbinder;
|
private Unbinder unbinder;
|
||||||
|
private SuLogDatabaseHelper dbHelper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.menu_log, menu);
|
||||||
|
menu.findItem(R.id.menu_save).setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
@ -32,7 +49,14 @@ public class SuLogFragment extends Fragment {
|
|||||||
View v = inflater.inflate(R.layout.fragment_su_log, container, false);
|
View v = inflater.inflate(R.layout.fragment_su_log, container, false);
|
||||||
unbinder = ButterKnife.bind(this, v);
|
unbinder = ButterKnife.bind(this, v);
|
||||||
|
|
||||||
SuLogDatabaseHelper dbHelper = new SuLogDatabaseHelper(getActivity());
|
dbHelper = new SuLogDatabaseHelper(getActivity());
|
||||||
|
|
||||||
|
updateList();
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateList() {
|
||||||
List<SuLogEntry> logs = dbHelper.getLogList();
|
List<SuLogEntry> logs = dbHelper.getLogList();
|
||||||
|
|
||||||
if (logs.size() == 0) {
|
if (logs.size() == 0) {
|
||||||
@ -43,8 +67,21 @@ public class SuLogFragment extends Fragment {
|
|||||||
emptyRv.setVisibility(View.GONE);
|
emptyRv.setVisibility(View.GONE);
|
||||||
recyclerView.setVisibility(View.VISIBLE);
|
recyclerView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return v;
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_refresh:
|
||||||
|
updateList();
|
||||||
|
return true;
|
||||||
|
case R.id.menu_clear:
|
||||||
|
dbHelper.clearLogs();
|
||||||
|
updateList();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,6 +108,7 @@ public class SuLogAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void onBindGroupViewHolder(LogGroupViewHolder holder, int flatPosition, ExpandableGroup group) {
|
public void onBindGroupViewHolder(LogGroupViewHolder holder, int flatPosition, ExpandableGroup group) {
|
||||||
holder.date.setText(group.getTitle());
|
holder.date.setText(group.getTitle());
|
||||||
|
if (isGroupExpanded(flatPosition)) holder.expand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,12 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
|
|||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearLogs() {
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
db.delete(TABLE_NAME, null, null);
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
|
||||||
public List<SuLogEntry> getLogList() {
|
public List<SuLogEntry> getLogList() {
|
||||||
return getLogList(null);
|
return getLogList(null);
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,6 @@
|
|||||||
android:title="@string/menuSaveToSd"
|
android:title="@string/menuSaveToSd"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_send"
|
|
||||||
android:icon="@drawable/ic_send"
|
|
||||||
android:title="@string/menuSend"
|
|
||||||
app:showAsAction="ifRoom"/>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_clear"
|
android:id="@+id/menu_clear"
|
||||||
android:icon="@drawable/ic_delete"
|
android:icon="@drawable/ic_delete"
|
||||||
|
Loading…
Reference in New Issue
Block a user