Skip to content

Commit 019fb0a

Browse files
Use snackbar as much as possible
Signed-off-by: sunilpaulmathew <sunil.kde@gmail.com>
1 parent 380f9b9 commit 019fb0a

20 files changed

+54
-52
lines changed

app/src/main/java/com/smartpack/kernelmanager/activities/BannerResizerActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class BannerResizerActivity extends BaseActivity {
4848
protected void onCreate(@Nullable Bundle savedInstanceState) {
4949
super.onCreate(savedInstanceState);
5050
if (!Utils.isDonated(this)) {
51-
Utils.toast("nice try", this);
51+
Utils.snackbar(findViewById(android.R.id.content), "nice try");
5252
return;
5353
}
5454
setContentView(R.layout.activity_fragments);

app/src/main/java/com/smartpack/kernelmanager/activities/FlashingActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5757
mSaveButton.setOnClickListener(v -> {
5858
Utils.create("## Flasher log created by SmartPack-Kernel Manager\n\n" + SmartPack.mFlashingResult.toString(),
5959
Utils.getInternalDataStorage() + "/flasher_log-" + SmartPack.mZipName.replace(".zip", ""));
60-
Utils.toast(getString(R.string.flash_log_summary, Utils.getInternalDataStorage() + "/flasher_log-" +
61-
SmartPack.mZipName.replace(".zip", "")), this);
60+
Utils.snackbar(mFlashingHeading, getString(R.string.flash_log_summary, Utils.getInternalDataStorage() + "/flasher_log-" +
61+
SmartPack.mZipName.replace(".zip", "")));
6262
});
6363
mCancelButton.setOnClickListener(v -> {
6464
onBackPressed();

app/src/main/java/com/smartpack/kernelmanager/activities/NavigationActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public void onBackPressed() {
415415
mExit = false;
416416
super.onBackPressed();
417417
} else {
418-
Utils.toast(R.string.press_back_again_exit, this);
418+
Utils.snackbar(findViewById(android.R.id.content), getString(R.string.press_back_again_exit));
419419
mExit = true;
420420
mHandler.postDelayed(() -> mExit = false, 2000);
421421
}

app/src/main/java/com/smartpack/kernelmanager/activities/NoRootActivity.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
4646
LinearLayout bbi = findViewById(R.id.bbi);
4747
AppCompatTextView mainTitle = findViewById(R.id.title_main);
4848
AppCompatTextView mainMessage = findViewById(R.id.message_main);
49-
bbi.setOnClickListener(v -> launchBBI());
49+
bbi.setOnClickListener(v -> Utils.launchUrl(bbi, "https://play.google.com/store/apps/details?id=com.smartpack.busyboxinstaller", this));
5050
if (Utils.mHasRoot && !Utils.mHasBusybox) {
5151
bbi.setVisibility(View.VISIBLE);
5252
mainTitle.setText(getString(R.string.no_busybox));
@@ -60,8 +60,4 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
6060
AppCompatTextView mCancel = findViewById(R.id.cancel_button);
6161
mCancel.setOnClickListener(v -> super.onBackPressed());
6262
}
63-
64-
private void launchBBI() {
65-
Utils.launchUrl("https://play.google.com/store/apps/details?id=com.smartpack.busyboxinstaller", this);
66-
}
6763
}

app/src/main/java/com/smartpack/kernelmanager/activities/TextActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5050
findViewById(R.id.help_fab).setOnClickListener(new View.OnClickListener() {
5151
@Override
5252
public void onClick(View v) {
53-
Utils.launchUrl(url, TextActivity.this);
53+
Utils.launchUrl(findViewById(android.R.id.content), url, TextActivity.this);
5454
}
5555
});
5656
}

app/src/main/java/com/smartpack/kernelmanager/activities/tools/profile/ProfileActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected void onCreate(final @Nullable Bundle savedInstanceState) {
9191
mItems.remove("Performance Tweaks");
9292

9393
if (mItems.size() < 1) {
94-
Utils.toast(R.string.sections_disabled, this);
94+
Utils.snackbar(findViewById(android.R.id.content), getString(R.string.sections_disabled));
9595
finish();
9696
return;
9797
}
@@ -189,7 +189,7 @@ private void returnIntent(LinkedHashMap<String, String> commandsList) {
189189
setResult(0, intent);
190190
finish();
191191
} else {
192-
Utils.toast(R.string.no_changes, ProfileActivity.this);
192+
Utils.snackbar(findViewById(android.R.id.content), getString(R.string.no_changes));
193193
}
194194
}
195195

@@ -295,7 +295,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
295295
}
296296
}
297297
if (categories.size() < 1) {
298-
Utils.toast(R.string.nothing_selected, getActivity());
298+
Utils.snackbar(getView(), getString(R.string.nothing_selected));
299299
return;
300300
}
301301

app/src/main/java/com/smartpack/kernelmanager/activities/tools/profile/ProfileEditActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected void init() {
122122
mItem = mProfiles.getAllProfiles().get(getArguments()
123123
.getInt(POSITION_INTENT));
124124
if (mItem.getCommands().size() < 1) {
125-
Utils.toast(R.string.profile_empty, getActivity());
125+
Utils.snackbar(getRootView(), getString(R.string.profile_empty));
126126
requireActivity().finish();
127127
}
128128
}

app/src/main/java/com/smartpack/kernelmanager/fragments/kernel/CPUFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ private void refreshCores(SparseArray<SwitchView> array, int[] freqs) {
697697
switchView.setSummary(getString(R.string.core, core + 1) + " - " + freqText);
698698
switchView.addOnSwitchListener((switchView1, isChecked) -> {
699699
if (core == 0) {
700-
Utils.toast(R.string.no_offline_core, getActivity());
700+
Utils.snackbar(getRootView(), getString(R.string.no_offline_core));
701701
} else {
702702
mCPUFreq.onlineCpu(core, isChecked, true, getActivity());
703703
}

app/src/main/java/com/smartpack/kernelmanager/fragments/kernel/KLapseFragment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
468468
protected void onTopFabClick() {
469469
super.onTopFabClick();
470470
if (mPermissionDenied) {
471-
Utils.toast(R.string.permission_denied_write_storage, getActivity());
471+
Utils.snackbar(getRootView(), getString(R.string.permission_denied_write_storage));
472472
return;
473473
}
474474

@@ -485,7 +485,7 @@ private void showCreateDialog() {
485485
@Override
486486
public void onClick(String text) {
487487
if (text.isEmpty()) {
488-
Utils.toast(R.string.name_empty, getActivity());
488+
Utils.snackbar(getRootView(), getString(R.string.name_empty));
489489
return;
490490
}
491491
if (!text.endsWith(".sh")) {
@@ -495,7 +495,7 @@ public void onClick(String text) {
495495
text = text.replace(" ", "_");
496496
}
497497
if (Utils.existFile(KLapse.profileFolder().toString() + "/" + text)) {
498-
Utils.toast(getString(R.string.profile_exists, text), getActivity());
498+
Utils.snackbar(getRootView(), getString(R.string.profile_exists, text));
499499
return;
500500
}
501501
final String path = text;
@@ -545,7 +545,7 @@ public void onPermissionDenied(int request) {
545545
super.onPermissionDenied(request);
546546
if (request == 0) {
547547
mPermissionDenied = true;
548-
Utils.toast(R.string.permission_denied_write_storage, getActivity());
548+
Utils.snackbar(getRootView(), getString(R.string.permission_denied_write_storage));
549549
}
550550
}
551551

app/src/main/java/com/smartpack/kernelmanager/fragments/kernel/ScreenFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package com.smartpack.kernelmanager.fragments.kernel;
2121

22+
import android.annotation.SuppressLint;
2223
import android.os.Bundle;
2324
import android.view.LayoutInflater;
2425
import android.view.View;
@@ -98,6 +99,7 @@ protected void init() {
9899
addViewPagerFragment(new ColorTableFragment());
99100
}
100101

102+
@SuppressLint("UseCompatLoadingForDrawables")
101103
@Override
102104
protected void addItems(List<RecyclerViewItem> items) {
103105
if (Misc.haskcalRed() || Misc.haskcalGreen() || Misc.haskcalBlue()) {
@@ -114,7 +116,7 @@ protected void addItems(List<RecyclerViewItem> items) {
114116
scc.setDrawable(getResources().getDrawable(R.drawable.ic_playstore));
115117
scc.setSummary(getString(R.string.scc_messgae));
116118
scc.setOnItemClickListener(item -> {
117-
Utils.launchUrl("https://play.google.com/store/apps/details?id=com.smartpack.colorcontrol", getActivity());
119+
Utils.launchUrl(getRootView(), "https://play.google.com/store/apps/details?id=com.smartpack.colorcontrol", getActivity());
118120
});
119121
items.add(scc);
120122
}

0 commit comments

Comments
 (0)