Add reboot fab to install terminal

pull/107/head
DerGoogler 2 years ago
parent 841e414b6e
commit 1cc6f8e771

@ -29,6 +29,7 @@ import com.fox2code.mmm.utils.Hashes;
import com.fox2code.mmm.utils.Http;
import com.fox2code.mmm.utils.IntentHelper;
import com.fox2code.mmm.utils.PropUtils;
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.topjohnwu.superuser.CallbackList;
import com.topjohnwu.superuser.Shell;
@ -47,6 +48,7 @@ import java.util.zip.ZipInputStream;
public class InstallerActivity extends CompatActivity {
private static final String TAG = "InstallerActivity";
public LinearProgressIndicator progressIndicator;
public ExtendedFloatingActionButton rebootFloatingButton;
public InstallerTerminal installerTerminal;
private File moduleCache;
private File toDelete;
@ -109,6 +111,7 @@ public class InstallerActivity extends CompatActivity {
View horizontalScroller = findViewById(R.id.install_horizontal_scroller);
RecyclerView installTerminal;
this.progressIndicator = findViewById(R.id.progress_bar);
this.rebootFloatingButton = findViewById(R.id.install_terminal_reboot_fab);
this.installerTerminal = new InstallerTerminal(
installTerminal = findViewById(R.id.install_terminal), foreground);
(horizontalScroller != null ? horizontalScroller : installTerminal)
@ -553,6 +556,11 @@ public class InstallerActivity extends CompatActivity {
this.setOnBackPressedCallback(null);
this.setDisplayHomeAsUpEnabled(true);
this.progressIndicator.setVisibility(View.GONE);
// This should be improved ?
rebootFloatingButton.setOnClickListener(_view -> Shell.cmd("/system/bin/svc power reboot || /system/bin/reboot").submit());
this.rebootFloatingButton.setVisibility(View.VISIBLE);
if (message != null && !message.isEmpty())
this.installerTerminal.addLine(message);
if (!optionalLink.isEmpty()) {

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</vector>

@ -33,4 +33,17 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/install_terminal_reboot_fab"
android:text="@string/install_terminal_reboot_now"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textColor="@android:color/white"
app:iconTint="@android:color/white"
app:icon="@drawable/ic_reboot_24"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -24,6 +24,7 @@
<string name="donate">Donate</string>
<string name="submit_modules">Submit a module</string>
<string name="require_android_6">Require Android 6.0+</string>
<string name="install_terminal_reboot_now">Reboot</string>
<!-- Module section translation -->
<string name="module_last_update">Last update:</string>

Loading…
Cancel
Save