Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 1cc6f8e

Browse files
committed
Add reboot fab to install terminal
1 parent 841e414 commit 1cc6f8e

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.fox2code.mmm.utils.Http;
3030
import com.fox2code.mmm.utils.IntentHelper;
3131
import com.fox2code.mmm.utils.PropUtils;
32+
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
3233
import com.google.android.material.progressindicator.LinearProgressIndicator;
3334
import com.topjohnwu.superuser.CallbackList;
3435
import com.topjohnwu.superuser.Shell;
@@ -47,6 +48,7 @@
4748
public class InstallerActivity extends CompatActivity {
4849
private static final String TAG = "InstallerActivity";
4950
public LinearProgressIndicator progressIndicator;
51+
public ExtendedFloatingActionButton rebootFloatingButton;
5052
public InstallerTerminal installerTerminal;
5153
private File moduleCache;
5254
private File toDelete;
@@ -109,6 +111,7 @@ protected void onCreate(Bundle savedInstanceState) {
109111
View horizontalScroller = findViewById(R.id.install_horizontal_scroller);
110112
RecyclerView installTerminal;
111113
this.progressIndicator = findViewById(R.id.progress_bar);
114+
this.rebootFloatingButton = findViewById(R.id.install_terminal_reboot_fab);
112115
this.installerTerminal = new InstallerTerminal(
113116
installTerminal = findViewById(R.id.install_terminal), foreground);
114117
(horizontalScroller != null ? horizontalScroller : installTerminal)
@@ -553,6 +556,11 @@ private void setInstallStateFinished(boolean success, String message,String opti
553556
this.setOnBackPressedCallback(null);
554557
this.setDisplayHomeAsUpEnabled(true);
555558
this.progressIndicator.setVisibility(View.GONE);
559+
560+
// This should be improved ?
561+
rebootFloatingButton.setOnClickListener(_view -> Shell.cmd("/system/bin/svc power reboot || /system/bin/reboot").submit());
562+
this.rebootFloatingButton.setVisibility(View.VISIBLE);
563+
556564
if (message != null && !message.isEmpty())
557565
this.installerTerminal.addLine(message);
558566
if (!optionalLink.isEmpty()) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
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"/>
10+
</vector>

app/src/main/res/layout/installer.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,17 @@
3333
app:layout_constraintEnd_toEndOf="parent"
3434
app:layout_constraintStart_toStartOf="parent"
3535
app:layout_constraintTop_toTopOf="parent" />
36+
37+
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
38+
android:id="@+id/install_terminal_reboot_fab"
39+
android:text="@string/install_terminal_reboot_now"
40+
android:visibility="gone"
41+
android:layout_width="wrap_content"
42+
android:layout_height="wrap_content"
43+
android:layout_margin="16dp"
44+
android:textColor="@android:color/white"
45+
app:iconTint="@android:color/white"
46+
app:icon="@drawable/ic_reboot_24"
47+
app:layout_constraintRight_toRightOf="parent"
48+
app:layout_constraintBottom_toBottomOf="parent" />
3649
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<string name="donate">Donate</string>
2525
<string name="submit_modules">Submit a module</string>
2626
<string name="require_android_6">Require Android 6.0+</string>
27+
<string name="install_terminal_reboot_now">Reboot</string>
2728

2829
<!-- Module section translation -->
2930
<string name="module_last_update">Last update:</string>

0 commit comments

Comments
 (0)