mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 11:17:38 +00:00
Use recyclerlist for FlashActivity console
This commit is contained in:
parent
07d1a20f3d
commit
a575180475
@ -3,12 +3,9 @@ package com.topjohnwu.magisk;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
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.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.topjohnwu.core.App;
|
import com.topjohnwu.core.App;
|
||||||
@ -16,6 +13,7 @@ import com.topjohnwu.core.Const;
|
|||||||
import com.topjohnwu.core.tasks.FlashZip;
|
import com.topjohnwu.core.tasks.FlashZip;
|
||||||
import com.topjohnwu.core.tasks.MagiskInstaller;
|
import com.topjohnwu.core.tasks.MagiskInstaller;
|
||||||
import com.topjohnwu.core.utils.Utils;
|
import com.topjohnwu.core.utils.Utils;
|
||||||
|
import com.topjohnwu.magisk.adapters.StringListAdapter;
|
||||||
import com.topjohnwu.magisk.components.BaseActivity;
|
import com.topjohnwu.magisk.components.BaseActivity;
|
||||||
import com.topjohnwu.superuser.CallbackList;
|
import com.topjohnwu.superuser.CallbackList;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
@ -29,18 +27,21 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import butterknife.BindColor;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
|
||||||
public class FlashActivity extends BaseActivity {
|
public class FlashActivity extends BaseActivity {
|
||||||
|
|
||||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||||
@BindView(R.id.txtLog) TextView flashLogs;
|
@BindView(R.id.button_panel) LinearLayout buttonPanel;
|
||||||
@BindView(R.id.button_panel) public LinearLayout buttonPanel;
|
@BindView(R.id.reboot) Button reboot;
|
||||||
@BindView(R.id.reboot) public Button reboot;
|
@BindView(R.id.recyclerView) RecyclerView rv;
|
||||||
@BindView(R.id.scrollView) ScrollView sv;
|
@BindColor(android.R.color.white) int white;
|
||||||
|
|
||||||
private List<String> console, logs;
|
private List<String> console, logs;
|
||||||
|
|
||||||
@ -106,6 +107,7 @@ public class FlashActivity extends BaseActivity {
|
|||||||
|
|
||||||
logs = Collections.synchronizedList(new ArrayList<>());
|
logs = Collections.synchronizedList(new ArrayList<>());
|
||||||
console = new ConsoleList();
|
console = new ConsoleList();
|
||||||
|
rv.setAdapter(new ConsoleAdapter());
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
@ -129,6 +131,42 @@ public class FlashActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ConsoleAdapter extends StringListAdapter<ConsoleAdapter.ViewHolder> {
|
||||||
|
|
||||||
|
ConsoleAdapter() {
|
||||||
|
super(console, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
|
super.onBindViewHolder(holder, position);
|
||||||
|
holder.txt.setTextColor(white);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int itemLayoutRes() {
|
||||||
|
return R.layout.list_item_console;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ViewHolder createViewHolder(@NonNull View v) {
|
||||||
|
return new ViewHolder(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
class ViewHolder extends StringListAdapter.ViewHolder {
|
||||||
|
|
||||||
|
public ViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int textViewResId() {
|
||||||
|
return R.id.txt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class ConsoleList extends CallbackList<String> {
|
private class ConsoleList extends CallbackList<String> {
|
||||||
|
|
||||||
ConsoleList() {
|
ConsoleList() {
|
||||||
@ -136,8 +174,8 @@ public class FlashActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
flashLogs.setText(TextUtils.join("\n", this));
|
rv.getAdapter().notifyItemChanged(size() - 1);
|
||||||
sv.postDelayed(() -> sv.fullScroll(ScrollView.FOCUS_DOWN), 10);
|
rv.postDelayed(() -> rv.smoothScrollToPosition(size() - 1), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,7 +112,7 @@ public class MagiskLogFragment extends BaseFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int itemLayoutRes() {
|
protected int itemLayoutRes() {
|
||||||
return R.layout.list_item_magisk_log;
|
return R.layout.list_item_console;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -9,28 +9,22 @@
|
|||||||
|
|
||||||
<include layout="@layout/toolbar"/>
|
<include layout="@layout/toolbar"/>
|
||||||
|
|
||||||
<ScrollView
|
<HorizontalScrollView
|
||||||
android:id="@+id/scrollView"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
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">
|
||||||
|
|
||||||
<HorizontalScrollView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_height="wrap_content">
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||||
|
|
||||||
<TextView
|
</HorizontalScrollView>
|
||||||
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>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/button_panel"
|
android:id="@+id/button_panel"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user