mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-29 05:07:38 +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.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
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.utils.Shell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
@ -37,9 +34,10 @@ public class FlashActivity extends Activity {
|
||||
public static final String FLASH_MAGISK = "magisk";
|
||||
|
||||
@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.reboot) Button reboot;
|
||||
@BindView(R.id.scrollView) ScrollView sv;
|
||||
|
||||
@OnClick(R.id.no_thanks)
|
||||
public void dismiss() {
|
||||
@ -56,7 +54,13 @@ public class FlashActivity extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_flash);
|
||||
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);
|
||||
ActionBar ab = getSupportActionBar();
|
||||
if (ab != null) {
|
||||
@ -67,8 +71,6 @@ public class FlashActivity extends Activity {
|
||||
if (!Shell.rootAccess())
|
||||
reboot.setVisibility(View.GONE);
|
||||
|
||||
flashLogs.setAdapter(new FlashLogAdapter(rootShellOutput));
|
||||
|
||||
// We must receive a Uri of the target zip
|
||||
Intent intent = getIntent();
|
||||
Uri uri = intent.getData();
|
||||
@ -113,41 +115,4 @@ public class FlashActivity extends Activity {
|
||||
public void onBackPressed() {
|
||||
// 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) {
|
||||
case 0:
|
||||
StringBuildingList logList = new StringBuildingList();
|
||||
Shell.su(logList, "cat " + MAGISK_LOG);
|
||||
Shell.su(logList, "cat " + MAGISK_LOG + " | tail -n 1000");
|
||||
return logList.toString();
|
||||
|
||||
case 1:
|
||||
@ -164,8 +164,8 @@ public class MagiskLogFragment extends Fragment {
|
||||
txtLog.setText(R.string.log_is_empty);
|
||||
else
|
||||
txtLog.setText(llog);
|
||||
svLog.post(() -> svLog.scrollTo(0, txtLog.getHeight()));
|
||||
hsvLog.post(() -> hsvLog.scrollTo(0, 0));
|
||||
svLog.postDelayed(() -> svLog.fullScroll(ScrollView.FOCUS_DOWN), 100);
|
||||
hsvLog.postDelayed(() -> hsvLog.fullScroll(ScrollView.FOCUS_LEFT), 100);
|
||||
break;
|
||||
case 2:
|
||||
boolean bool = (boolean) o;
|
||||
|
@ -1,28 +1,18 @@
|
||||
package com.topjohnwu.magisk.container;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AdaptiveList<E> extends ArrayList<E> {
|
||||
public abstract class AdaptiveList<E> extends ArrayList<E> {
|
||||
|
||||
private Runnable callback;
|
||||
private RecyclerView mView;
|
||||
|
||||
public AdaptiveList(RecyclerView v) {
|
||||
mView = v;
|
||||
}
|
||||
|
||||
public void updateView() {
|
||||
mView.getAdapter().notifyDataSetChanged();
|
||||
mView.scrollToPosition(mView.getAdapter().getItemCount() - 1);
|
||||
}
|
||||
public abstract void updateView();
|
||||
|
||||
public void setCallback(Runnable cb) {
|
||||
callback = cb;
|
||||
}
|
||||
|
||||
public boolean add(E e) {
|
||||
public synchronized boolean add(E e) {
|
||||
boolean ret = super.add(e);
|
||||
if (ret) {
|
||||
if (callback == null) {
|
||||
|
@ -3,27 +3,34 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:background="@android:color/black"
|
||||
tools:context="com.topjohnwu.magisk.FlashActivity">
|
||||
|
||||
<include layout="@layout/toolbar"/>
|
||||
|
||||
<HorizontalScrollView
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/flash_logs"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager">
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</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
|
||||
android:id="@+id/button_panel"
|
||||
|
@ -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…
x
Reference in New Issue
Block a user