mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-11 02:34:31 +00:00
Simplify flash log screen
This commit is contained in:
parent
e6e04cc5b3
commit
9ebe372a9a
@ -4,13 +4,12 @@ import android.content.Intent;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.LayoutInflater;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.asyncs.FlashZip;
|
import com.topjohnwu.magisk.asyncs.FlashZip;
|
||||||
@ -19,8 +18,6 @@ import com.topjohnwu.magisk.components.Activity;
|
|||||||
import com.topjohnwu.magisk.container.AdaptiveList;
|
import com.topjohnwu.magisk.container.AdaptiveList;
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
@ -37,9 +34,10 @@ public class FlashActivity extends Activity {
|
|||||||
public static final String FLASH_MAGISK = "magisk";
|
public static final String FLASH_MAGISK = "magisk";
|
||||||
|
|
||||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||||
@BindView(R.id.flash_logs) RecyclerView flashLogs;
|
@BindView(R.id.txtLog) TextView flashLogs;
|
||||||
@BindView(R.id.button_panel) LinearLayout buttonPanel;
|
@BindView(R.id.button_panel) LinearLayout buttonPanel;
|
||||||
@BindView(R.id.reboot) Button reboot;
|
@BindView(R.id.reboot) Button reboot;
|
||||||
|
@BindView(R.id.scrollView) ScrollView sv;
|
||||||
|
|
||||||
@OnClick(R.id.no_thanks)
|
@OnClick(R.id.no_thanks)
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
@ -56,7 +54,13 @@ public class FlashActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_flash);
|
setContentView(R.layout.activity_flash);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
AdaptiveList<String> rootShellOutput = new AdaptiveList<>(flashLogs);
|
AdaptiveList<String> rootShellOutput = new AdaptiveList<String>() {
|
||||||
|
@Override
|
||||||
|
public synchronized void updateView() {
|
||||||
|
flashLogs.setText(TextUtils.join("\n", this));
|
||||||
|
sv.postDelayed(() -> sv.fullScroll(ScrollView.FOCUS_DOWN), 10);
|
||||||
|
}
|
||||||
|
};
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
ActionBar ab = getSupportActionBar();
|
ActionBar ab = getSupportActionBar();
|
||||||
if (ab != null) {
|
if (ab != null) {
|
||||||
@ -67,8 +71,6 @@ public class FlashActivity extends Activity {
|
|||||||
if (!Shell.rootAccess())
|
if (!Shell.rootAccess())
|
||||||
reboot.setVisibility(View.GONE);
|
reboot.setVisibility(View.GONE);
|
||||||
|
|
||||||
flashLogs.setAdapter(new FlashLogAdapter(rootShellOutput));
|
|
||||||
|
|
||||||
// We must receive a Uri of the target zip
|
// We must receive a Uri of the target zip
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
@ -113,41 +115,4 @@ public class FlashActivity extends Activity {
|
|||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
// Prevent user accidentally press back button
|
// Prevent user accidentally press back button
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FlashLogAdapter extends RecyclerView.Adapter<ViewHolder> {
|
|
||||||
|
|
||||||
private List<String> mList;
|
|
||||||
|
|
||||||
FlashLogAdapter(List<String> list) {
|
|
||||||
mList = list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.list_item_flashlog, parent, false);
|
|
||||||
return new ViewHolder(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
|
||||||
holder.text.setText(mList.get(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return mList.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
@BindView(R.id.textView) TextView text;
|
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
ButterKnife.bind(this, itemView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class MagiskLogFragment extends Fragment {
|
|||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0:
|
case 0:
|
||||||
StringBuildingList logList = new StringBuildingList();
|
StringBuildingList logList = new StringBuildingList();
|
||||||
Shell.su(logList, "cat " + MAGISK_LOG);
|
Shell.su(logList, "cat " + MAGISK_LOG + " | tail -n 1000");
|
||||||
return logList.toString();
|
return logList.toString();
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
@ -164,8 +164,8 @@ public class MagiskLogFragment extends Fragment {
|
|||||||
txtLog.setText(R.string.log_is_empty);
|
txtLog.setText(R.string.log_is_empty);
|
||||||
else
|
else
|
||||||
txtLog.setText(llog);
|
txtLog.setText(llog);
|
||||||
svLog.post(() -> svLog.scrollTo(0, txtLog.getHeight()));
|
svLog.postDelayed(() -> svLog.fullScroll(ScrollView.FOCUS_DOWN), 100);
|
||||||
hsvLog.post(() -> hsvLog.scrollTo(0, 0));
|
hsvLog.postDelayed(() -> hsvLog.fullScroll(ScrollView.FOCUS_LEFT), 100);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
boolean bool = (boolean) o;
|
boolean bool = (boolean) o;
|
||||||
|
@ -1,28 +1,18 @@
|
|||||||
package com.topjohnwu.magisk.container;
|
package com.topjohnwu.magisk.container;
|
||||||
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class AdaptiveList<E> extends ArrayList<E> {
|
public abstract class AdaptiveList<E> extends ArrayList<E> {
|
||||||
|
|
||||||
private Runnable callback;
|
private Runnable callback;
|
||||||
private RecyclerView mView;
|
|
||||||
|
|
||||||
public AdaptiveList(RecyclerView v) {
|
public abstract void updateView();
|
||||||
mView = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateView() {
|
|
||||||
mView.getAdapter().notifyDataSetChanged();
|
|
||||||
mView.scrollToPosition(mView.getAdapter().getItemCount() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCallback(Runnable cb) {
|
public void setCallback(Runnable cb) {
|
||||||
callback = cb;
|
callback = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(E e) {
|
public synchronized boolean add(E e) {
|
||||||
boolean ret = super.add(e);
|
boolean ret = super.add(e);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
@ -3,28 +3,35 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@android:color/black"
|
android:background="@android:color/black"
|
||||||
tools:context="com.topjohnwu.magisk.FlashActivity">
|
tools:context="com.topjohnwu.magisk.FlashActivity">
|
||||||
|
|
||||||
<include layout="@layout/toolbar"/>
|
<include layout="@layout/toolbar"/>
|
||||||
|
|
||||||
<HorizontalScrollView
|
<ScrollView
|
||||||
|
android:id="@+id/scrollView"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp">
|
android:layout_height="0dp">
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<HorizontalScrollView
|
||||||
android:id="@+id/flash_logs"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager">
|
|
||||||
|
|
||||||
</android.support.v7.widget.RecyclerView>
|
<TextView
|
||||||
|
android:id="@+id/txtLog"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="monospace"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="10sp" />
|
||||||
|
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/button_panel"
|
android:id="@+id/button_panel"
|
||||||
style="?android:buttonStyle"
|
style="?android:buttonStyle"
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<TextView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/textView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:fontFamily="monospace"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="10sp" />
|
|
Loading…
Reference in New Issue
Block a user