Skip to content

Commit

Permalink
Don't use the deprecated ProgressDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Feb 11, 2021
1 parent b32129e commit 27f020a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .idea/modules/app/AndroidBootManager.app.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions app/src/main/java/org/androidbootmanager/app/util/MiscUtils.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.androidbootmanager.app.util;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.topjohnwu.superuser.Shell;

import org.androidbootmanager.app.R;

public class MiscUtils {
public static ProgressDialog prog;
public static AlertDialog prog;
public static void sure(Context c, DialogInterface d, String msg, DialogInterface.OnClickListener v) {
d.dismiss();
new AlertDialog.Builder(c)
Expand All @@ -27,14 +29,13 @@ public static void sure(Context c, DialogInterface d, int msg, DialogInterface.O
}

public static void w(Context c, String msg, Runnable r) {
//TODO: no more deprecated ProgressDialog
prog = new ProgressDialog(c);
prog.setIndeterminate(true);
prog.setCanceledOnTouchOutside(false);
prog.setCancelable(false);
prog.setTitle(R.string.wait);
prog.setMessage(msg);
prog.show();
View v = LayoutInflater.from(c).inflate(R.layout.progressdialog, null);
((TextView) v.findViewById(R.id.prog_message)).setText(msg);
prog = new AlertDialog.Builder(c)
.setCancelable(false)
.setTitle(R.string.wait)
.setView(v)
.show();
r.run();
}

Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/layout/progressdialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="20dp">
<ProgressBar
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:id="@+id/prog_message" />
</LinearLayout>

0 comments on commit 27f020a

Please sign in to comment.