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

Commit 2d3c14a

Browse files
Updated ap pto use more material elements
Signed-off-by: sunilpaulmathew <sunil.kde@gmail.com>
1 parent fb2c52a commit 2d3c14a

15 files changed

Lines changed: 94 additions & 94 deletions

app/src/main/java/com/smartpack/kernelprofiler/MainActivity.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
import android.view.View;
1212
import android.widget.LinearLayout;
1313

14-
import androidx.appcompat.app.AlertDialog;
1514
import androidx.appcompat.app.AppCompatActivity;
1615
import androidx.appcompat.widget.AppCompatImageButton;
1716
import androidx.appcompat.widget.AppCompatImageView;
18-
import androidx.appcompat.widget.AppCompatTextView;
1917
import androidx.appcompat.widget.PopupMenu;
2018
import androidx.recyclerview.widget.LinearLayoutManager;
2119
import androidx.recyclerview.widget.RecyclerView;
2220

21+
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
22+
import com.google.android.material.textview.MaterialTextView;
2323
import com.smartpack.kernelprofiler.utils.AboutActivity;
2424
import com.smartpack.kernelprofiler.utils.CreateConfigActivity;
2525
import com.smartpack.kernelprofiler.utils.CreateProfileActivity;
@@ -40,7 +40,7 @@
4040
public class MainActivity extends AppCompatActivity {
4141

4242
private AppCompatImageButton mSettings;
43-
private AppCompatTextView mProgressMessage;
43+
private MaterialTextView mProgressMessage;
4444
private boolean mExit;
4545
private Handler mHandler = new Handler();
4646
private LinearLayout mProgressLayout;
@@ -60,11 +60,11 @@ protected void onCreate(Bundle savedInstanceState) {
6060
mProgressMessage = findViewById(R.id.progress_message);
6161
mSettings = findViewById(R.id.settings_menu);
6262
mRecyclerView = findViewById(R.id.recycler_view);
63-
AppCompatTextView textView = findViewById(R.id.unsupported_Text);
63+
MaterialTextView textView = findViewById(R.id.unsupported_Text);
6464
AppCompatImageView helpIcon = findViewById(R.id.help_Image);
65-
AppCompatTextView copyRightText = findViewById(R.id.copyright_Text);
66-
AppCompatTextView customTitle = findViewById(R.id.customTitle);
67-
AppCompatTextView customDescription = findViewById(R.id.customDescription);
65+
MaterialTextView copyRightText = findViewById(R.id.copyright_Text);
66+
MaterialTextView customTitle = findViewById(R.id.customTitle);
67+
MaterialTextView customDescription = findViewById(R.id.customDescription);
6868
customTitle.setText(KP.supported() && KP.getCustomTitle() != null ? KP.getCustomTitle() : getString(R.string.app_name));
6969
customDescription.setText(KP.supported() && KP.getCustomDescription() != null ? KP.getCustomDescription() : getString(R.string.app_name_summary));
7070
mSettings.setOnClickListener(v -> {
@@ -115,7 +115,7 @@ private List<String> getData() {
115115
private void applyProfile(String profile, Activity activity) {
116116
String profileName = profile + ".sh";
117117
String profilePath = KP.KPFile() + "/" + profileName;
118-
new AlertDialog.Builder(activity)
118+
new MaterialAlertDialogBuilder(activity)
119119
.setMessage(getString(R.string.apply_question, profile))
120120
.setNegativeButton(getString(R.string.cancel), (dialogInterface, i) -> {
121121
})
@@ -143,9 +143,8 @@ protected void onPostExecute(Void aVoid) {
143143
super.onPostExecute(aVoid);
144144
mProgressMessage.setVisibility(View.GONE);
145145
mProgressLayout.setVisibility(View.GONE);
146-
new AlertDialog.Builder(activity)
147-
.setTitle(profile)
148-
.setMessage(getString(R.string.profile_applied_success))
146+
new MaterialAlertDialogBuilder(activity)
147+
.setMessage(getString(R.string.profile_applied_success, profile))
149148
.setPositiveButton(getString(R.string.cancel), (dialog, id) -> {
150149
})
151150
.show();
@@ -266,7 +265,7 @@ private void settingsMenu(Activity activity) {
266265
startActivity(about);
267266
break;
268267
case 14:
269-
new AlertDialog.Builder(activity)
268+
new MaterialAlertDialogBuilder(activity)
270269
.setIcon(R.mipmap.ic_launcher)
271270
.setTitle(getString(R.string.support_developer))
272271
.setMessage(getString(R.string.support_developer_message))

app/src/main/java/com/smartpack/kernelprofiler/utils/AboutActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import androidx.appcompat.app.AppCompatActivity;
88
import androidx.appcompat.widget.AppCompatImageButton;
99
import androidx.appcompat.widget.AppCompatImageView;
10-
import androidx.appcompat.widget.AppCompatTextView;
1110

11+
import com.google.android.material.textview.MaterialTextView;
1212
import com.smartpack.kernelprofiler.BuildConfig;
1313
import com.smartpack.kernelprofiler.R;
1414

@@ -33,9 +33,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3333

3434
AppCompatImageButton mBack = findViewById(R.id.back);
3535
AppCompatImageView mDeveloper = findViewById(R.id.developer);
36-
AppCompatTextView mAppTitle = findViewById(R.id.app_title);
37-
AppCompatTextView mChangeLog = findViewById(R.id.change_log);
38-
AppCompatTextView mCancel = findViewById(R.id.cancel_button);
36+
MaterialTextView mAppTitle = findViewById(R.id.app_title);
37+
MaterialTextView mChangeLog = findViewById(R.id.change_log);
38+
MaterialTextView mCancel = findViewById(R.id.cancel_button);
3939
mAppTitle.setText(getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME);
4040
mBack.setOnClickListener(v -> onBackPressed());
4141
mDeveloper.setOnClickListener(v -> {

app/src/main/java/com/smartpack/kernelprofiler/utils/CreateConfigActivity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import android.os.Environment;
66

77
import androidx.annotation.Nullable;
8-
import androidx.appcompat.app.AlertDialog;
98
import androidx.appcompat.app.AppCompatActivity;
109
import androidx.appcompat.widget.AppCompatEditText;
1110
import androidx.appcompat.widget.AppCompatImageButton;
12-
import androidx.appcompat.widget.AppCompatTextView;
1311
import androidx.core.app.ActivityCompat;
1412

13+
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
14+
import com.google.android.material.textview.MaterialTextView;
1515
import com.smartpack.kernelprofiler.R;
1616

1717
import org.json.JSONException;
@@ -29,7 +29,7 @@ public class CreateConfigActivity extends AppCompatActivity {
2929
private AppCompatEditText mDeveloperHint;
3030
private AppCompatEditText mSupportHint;
3131
private AppCompatEditText mDonationsHint;
32-
private AppCompatTextView mTitle;
32+
private MaterialTextView mTitle;
3333

3434
@Override
3535
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -51,7 +51,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5151
mSave.setOnClickListener(v -> {
5252
if (Utils.checkWriteStoragePermission(this)) {
5353
if (mConfigTitleHint.getText() != null && !mConfigTitleHint.getText().toString().equals("")) {
54-
new AlertDialog.Builder(this)
54+
new MaterialAlertDialogBuilder(this)
5555
.setIcon(R.mipmap.ic_launcher)
5656
.setTitle(getString(R.string.save_config_title))
5757
.setMessage(Utils.existFile(
@@ -77,7 +77,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7777
Utils.snackbar(mTitle, getString(R.string.title_empty_message));
7878
return;
7979
}
80-
new AlertDialog.Builder(this)
80+
new MaterialAlertDialogBuilder(this)
8181
.setMessage(getString(R.string.title_check))
8282
.setNegativeButton(getString(R.string.cancel), (dialog1, id1) -> {
8383
})
@@ -119,7 +119,7 @@ private boolean isTextEntered() {
119119
@Override
120120
public void onBackPressed() {
121121
if (isTextEntered()) {
122-
new AlertDialog.Builder(this)
122+
new MaterialAlertDialogBuilder(this)
123123
.setMessage(getString(R.string.data_lose_warning))
124124
.setNegativeButton(getString(R.string.cancel), (dialog1, id1) -> {
125125
})

app/src/main/java/com/smartpack/kernelprofiler/utils/CreateProfileActivity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import android.view.View;
1010

1111
import androidx.annotation.Nullable;
12-
import androidx.appcompat.app.AlertDialog;
1312
import androidx.appcompat.app.AppCompatActivity;
1413
import androidx.appcompat.widget.AppCompatEditText;
1514
import androidx.appcompat.widget.AppCompatImageButton;
16-
import androidx.appcompat.widget.AppCompatTextView;
1715
import androidx.core.app.ActivityCompat;
1816
import androidx.core.widget.NestedScrollView;
1917

18+
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
19+
import com.google.android.material.textview.MaterialTextView;
2020
import com.smartpack.kernelprofiler.R;
2121

2222
import java.util.ArrayList;
@@ -32,8 +32,8 @@ public class CreateProfileActivity extends AppCompatActivity {
3232

3333
private AppCompatEditText mProfileDescriptionHint;
3434
private AppCompatEditText mProfileDetailsHint;
35-
private AppCompatTextView mTitle;
36-
private AppCompatTextView mTestOutput;
35+
private MaterialTextView mTitle;
36+
private MaterialTextView mTestOutput;
3737
private NestedScrollView mScrollView;
3838

3939
private List<String> mOutput = null;
@@ -52,7 +52,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5252
mProfileDetailsHint = findViewById(R.id.profile_details_hint);
5353
mTitle = findViewById(R.id.title);
5454
mTitle.setText(getString(R.string.create_profile));
55-
AppCompatTextView mTestButton = findViewById(R.id.test_button);
55+
MaterialTextView mTestButton = findViewById(R.id.test_button);
5656
mTestOutput = findViewById(R.id.test_output);
5757
mScrollView = findViewById(R.id.scroll_view);
5858

@@ -107,7 +107,7 @@ private void createProfile() {
107107
}
108108
Utils.create("#!/system/bin/sh\n\n# Description=" + mProfileDescriptionHint.getText() + "\n\n" +
109109
mProfileDetailsHint.getText(), Environment.getExternalStorageDirectory().toString() + "/" + text);
110-
new AlertDialog.Builder(this)
110+
new MaterialAlertDialogBuilder(this)
111111
.setMessage(getString(R.string.create_profile_message, text) + " '" +
112112
Environment.getExternalStorageDirectory().toString() + "'")
113113
.setCancelable(false)
@@ -187,7 +187,7 @@ public void onBackPressed() {
187187
return;
188188
}
189189
if (isTextEntered()) {
190-
new AlertDialog.Builder(this)
190+
new MaterialAlertDialogBuilder(this)
191191
.setMessage(getString(R.string.data_lose_warning))
192192
.setNegativeButton(getString(R.string.cancel), (dialog1, id1) -> {
193193
})

app/src/main/java/com/smartpack/kernelprofiler/utils/EditConfigActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import android.os.Environment;
66

77
import androidx.annotation.Nullable;
8-
import androidx.appcompat.app.AlertDialog;
98
import androidx.appcompat.app.AppCompatActivity;
109
import androidx.appcompat.widget.AppCompatEditText;
1110
import androidx.appcompat.widget.AppCompatImageButton;
1211
import androidx.appcompat.widget.AppCompatTextView;
1312
import androidx.core.app.ActivityCompat;
1413

14+
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
1515
import com.smartpack.kernelprofiler.R;
1616

1717
import org.json.JSONException;
@@ -69,7 +69,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
6969
mSave.setOnClickListener(v -> {
7070
if (Utils.checkWriteStoragePermission(this)) {
7171
if (mConfigTitleHint.getText() != null && !mConfigTitleHint.getText().toString().equals("")) {
72-
new AlertDialog.Builder(this)
72+
new MaterialAlertDialogBuilder(this)
7373
.setMessage(getString(R.string.edit_config_message))
7474
.setNegativeButton(getString(R.string.cancel), (dialog1, id1) -> {
7575
})
@@ -110,7 +110,7 @@ private void createConfig() {
110110
obj.put("support", mSupportHint.getText());
111111
obj.put("donations", mDonationsHint.getText());
112112
Utils.create(obj.toString(), "/data/kernel_profiler/kernelprofiler.json");
113-
new AlertDialog.Builder(this)
113+
new MaterialAlertDialogBuilder(this)
114114
.setMessage(getString(R.string.edit_config_saved))
115115
.setCancelable(false)
116116
.setPositiveButton(getString(R.string.cancel), (dialog1, id1) -> {
@@ -133,7 +133,7 @@ private boolean isTextEntered() {
133133
@Override
134134
public void onBackPressed() {
135135
if (isTextEntered()) {
136-
new AlertDialog.Builder(this)
136+
new MaterialAlertDialogBuilder(this)
137137
.setMessage(getString(R.string.data_lose_warning))
138138
.setNegativeButton(getString(R.string.cancel), (dialog1, id1) -> {
139139
})

app/src/main/java/com/smartpack/kernelprofiler/utils/NoRootActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import androidx.annotation.Nullable;
77
import androidx.appcompat.app.AppCompatActivity;
88
import androidx.appcompat.widget.AppCompatImageButton;
9-
import androidx.appcompat.widget.AppCompatTextView;
109

10+
import com.google.android.material.textview.MaterialTextView;
1111
import com.smartpack.kernelprofiler.R;
1212

1313
/*
@@ -23,9 +23,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
2323
setContentView(R.layout.activity_noroot);
2424

2525
AppCompatImageButton mBack = findViewById(R.id.back_button);
26-
AppCompatTextView mainTitle = findViewById(R.id.main_title);
27-
AppCompatTextView mainText = findViewById(R.id.main_text);
28-
AppCompatTextView mCancel = findViewById(R.id.cancel_button);
26+
MaterialTextView mainTitle = findViewById(R.id.main_title);
27+
MaterialTextView mainText = findViewById(R.id.main_text);
28+
MaterialTextView mCancel = findViewById(R.id.cancel_button);
2929
if (!Utils.rootAccess()) {
3030
mainTitle.setText(R.string.no_root);
3131
mainText.setText(R.string.no_root_message);

app/src/main/java/com/smartpack/kernelprofiler/utils/RecycleViewAdapter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import android.view.LayoutInflater;
1212
import android.view.View;
1313
import android.view.ViewGroup;
14-
import android.widget.CheckBox;
1514

1615
import androidx.annotation.NonNull;
17-
import androidx.appcompat.widget.AppCompatTextView;
1816
import androidx.recyclerview.widget.RecyclerView;
1917

18+
import com.google.android.material.checkbox.MaterialCheckBox;
19+
import com.google.android.material.textview.MaterialTextView;
2020
import com.smartpack.kernelprofiler.R;
2121

2222
import java.io.File;
@@ -82,9 +82,9 @@ public int getItemCount() {
8282
}
8383

8484
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
85-
private AppCompatTextView mTitle;
86-
private AppCompatTextView mDescription;
87-
private CheckBox mCheckBox;
85+
private MaterialTextView mTitle;
86+
private MaterialTextView mDescription;
87+
private MaterialCheckBox mCheckBox;
8888

8989
public ViewHolder(View view) {
9090
super(view);

app/src/main/java/com/smartpack/kernelprofiler/utils/Utils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import android.annotation.SuppressLint;
1212
import android.app.Activity;
13-
import android.app.AlertDialog;
1413
import android.content.ActivityNotFoundException;
1514
import android.content.Context;
1615
import android.content.DialogInterface;
@@ -35,6 +34,7 @@
3534
import androidx.appcompat.app.AppCompatDelegate;
3635
import androidx.appcompat.widget.AppCompatEditText;
3736

37+
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
3838
import com.google.android.material.snackbar.Snackbar;
3939
import com.smartpack.kernelprofiler.BuildConfig;
4040
import com.smartpack.kernelprofiler.MainActivity;
@@ -134,13 +134,13 @@ public interface OnDialogEditTextListener {
134134
void onClick(String text);
135135
}
136136

137-
public static AlertDialog.Builder dialogEditText(String text, final DialogInterface.OnClickListener negativeListener,
138-
final OnDialogEditTextListener onDialogEditTextListener,
139-
Context context) {
137+
public static MaterialAlertDialogBuilder dialogEditText(String text, final DialogInterface.OnClickListener negativeListener,
138+
final OnDialogEditTextListener onDialogEditTextListener,
139+
Context context) {
140140
return dialogEditText(text, negativeListener, onDialogEditTextListener, -1, context);
141141
}
142142

143-
public static AlertDialog.Builder dialogEditText(String text, final DialogInterface.OnClickListener negativeListener,
143+
public static MaterialAlertDialogBuilder dialogEditText(String text, final DialogInterface.OnClickListener negativeListener,
144144
final OnDialogEditTextListener onDialogEditTextListener, int inputType,
145145
Context context) {
146146
LinearLayout layout = new LinearLayout(context);
@@ -160,7 +160,7 @@ public static AlertDialog.Builder dialogEditText(String text, final DialogInterf
160160

161161
layout.addView(editText);
162162

163-
AlertDialog.Builder dialog = new AlertDialog.Builder(context).setView(layout);
163+
MaterialAlertDialogBuilder dialog = new MaterialAlertDialogBuilder(context).setView(layout);
164164
if (negativeListener != null) {
165165
dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener);
166166
}

0 commit comments

Comments
 (0)