diff --git a/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java b/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java index 27c24f986..44282b762 100644 --- a/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java @@ -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 rootShellOutput = new AdaptiveList<>(flashLogs); + AdaptiveList rootShellOutput = new AdaptiveList() { + @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 { - - private List mList; - - FlashLogAdapter(List 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); - } - } - } diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java index 05e1008e5..d1ac24d3c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java @@ -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; diff --git a/app/src/main/java/com/topjohnwu/magisk/container/AdaptiveList.java b/app/src/main/java/com/topjohnwu/magisk/container/AdaptiveList.java index f92d79511..41557b313 100644 --- a/app/src/main/java/com/topjohnwu/magisk/container/AdaptiveList.java +++ b/app/src/main/java/com/topjohnwu/magisk/container/AdaptiveList.java @@ -1,28 +1,18 @@ package com.topjohnwu.magisk.container; -import android.support.v7.widget.RecyclerView; - import java.util.ArrayList; -public class AdaptiveList extends ArrayList { +public abstract class AdaptiveList extends ArrayList { 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) { diff --git a/app/src/main/res/layout/activity_flash.xml b/app/src/main/res/layout/activity_flash.xml index 5bcd9fa0a..37680be54 100644 --- a/app/src/main/res/layout/activity_flash.xml +++ b/app/src/main/res/layout/activity_flash.xml @@ -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"> - - + - + - + + + -