Organize constants

This commit is contained in:
topjohnwu
2017-11-06 04:41:23 +08:00
parent fd19fbf300
commit c39170c42e
33 changed files with 380 additions and 339 deletions
@@ -22,6 +22,7 @@ import android.widget.Toast;
import com.topjohnwu.magisk.asyncs.ParallelTask;
import com.topjohnwu.magisk.components.Fragment;
import com.topjohnwu.magisk.components.SnackbarMaker;
import com.topjohnwu.magisk.utils.Const;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils;
@@ -36,8 +37,6 @@ import butterknife.Unbinder;
public class MagiskLogFragment extends Fragment {
private static final String MAGISK_LOG = "/cache/magisk.log";
private Unbinder unbinder;
@BindView(R.id.txtLog) TextView txtLog;
@@ -117,11 +116,11 @@ public class MagiskLogFragment extends Fragment {
switch (mode) {
case 0:
StringBuildingList logList = new StringBuildingList();
Shell.su(logList, "cat " + MAGISK_LOG + " | tail -n 1000");
return logList.toString();
Shell.su(logList, "cat " + Const.MAGISK_LOG + " | tail -n 1000");
return logList.getCharSequence();
case 1:
Shell.su_raw("echo -n > " + MAGISK_LOG);
Shell.su_raw("echo -n > " + Const.MAGISK_LOG);
SnackbarMaker.make(txtLog, R.string.logs_cleared, Snackbar.LENGTH_SHORT).show();
return "";
@@ -142,7 +141,7 @@ public class MagiskLogFragment extends Fragment {
try (FileWriter out = new FileWriter(targetFile)) {
FileWritingList fileWritingList = new FileWritingList(out);
Shell.su(fileWritingList, "cat " + MAGISK_LOG);
Shell.su(fileWritingList, "cat " + Const.MAGISK_LOG);
} catch (IOException e) {
e.printStackTrace();
return false;
@@ -158,7 +157,7 @@ public class MagiskLogFragment extends Fragment {
switch (mode) {
case 0:
case 1:
String llog = (String) o;
CharSequence llog = (CharSequence) o;
progressBar.setVisibility(View.GONE);
if (TextUtils.isEmpty(llog))
txtLog.setText(R.string.log_is_empty);
@@ -170,7 +169,7 @@ public class MagiskLogFragment extends Fragment {
case 2:
boolean bool = (boolean) o;
if (bool) {
MagiskManager.toast(targetFile.toString(), Toast.LENGTH_LONG);
MagiskManager.toast(targetFile.getPath(), Toast.LENGTH_LONG);
} else {
MagiskManager.toast(R.string.logs_save_failed, Toast.LENGTH_LONG);
}
@@ -205,9 +204,8 @@ public class MagiskLogFragment extends Fragment {
return true;
}
@Override
public String toString() {
return builder.toString();
public CharSequence getCharSequence() {
return builder;
}
}