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

Commit 4eb8f30

Browse files
Main: Also show a page when no kernel support found
Signed-off-by: sunilpaulmathew <sunil.kde@gmail.com>
1 parent fc32308 commit 4eb8f30

4 files changed

Lines changed: 29 additions & 20 deletions

File tree

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

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
114114
settingsMenu();
115115
});
116116

117-
if (!RootUtils.rootAccess()) {
118-
Intent noRoot = new Intent(this, NoRootActivity.class);
119-
startActivity(noRoot);
120-
finish();
121-
return;
122-
}
123-
124-
if (!KP.supported()) {
117+
if (!RootUtils.rootAccess() || !KP.supported()) {
118+
unsupported();
119+
if (!RootUtils.rootAccess()) finish();
125120
textView.setText(getString(R.string.unsupported));
126121
helpIcon.setImageDrawable(Utils.getColoredIcon(R.drawable.ic_help, this));
127-
Utils.snackbarIndenite(mViewPager, getString(R.string.unsupported_message));
128-
helpIcon.setOnClickListener(v -> {
129-
new AlertDialog.Builder(this)
130-
.setIcon(R.mipmap.ic_launcher)
131-
.setTitle(getString(R.string.unsupported))
132-
.setMessage(getString(R.string.unsupported_summary) + " " + getString(R.string.unsupported_message) +
133-
"\n\n" + getString(R.string.unsupported_help_message))
134-
.setPositiveButton(getString(R.string.cancel), (dialog1, id1) -> {
135-
})
136-
.show();
137-
});
122+
helpIcon.setOnClickListener(v -> unsupported());
138123
return;
139124
}
140125

@@ -174,6 +159,11 @@ public void onAdFailedToLoad(LoadAdError adError) {
174159
mViewPager.setAdapter(adapter);
175160
}
176161

162+
private void unsupported() {
163+
Intent noRoot = new Intent(this, NoRootActivity.class);
164+
startActivity(noRoot);
165+
}
166+
177167
private void settingsMenu() {
178168
PopupMenu popupMenu = new PopupMenu(this, mSettings);
179169
Menu menu = popupMenu.getMenu();

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.smartpack.kernelprofiler.utils;
22

3+
import android.annotation.SuppressLint;
34
import android.os.Bundle;
45

56
import androidx.annotation.Nullable;
@@ -8,20 +9,34 @@
89
import androidx.appcompat.widget.AppCompatTextView;
910

1011
import com.smartpack.kernelprofiler.R;
12+
import com.smartpack.kernelprofiler.utils.root.RootUtils;
1113

1214
/**
1315
* Created by sunilpaulmathew <sunil.kde@gmail.com> on September 16, 2020
1416
*/
1517

1618
public class NoRootActivity extends AppCompatActivity {
1719

20+
@SuppressLint("SetTextI18n")
1821
@Override
1922
protected void onCreate(@Nullable Bundle savedInstanceState) {
2023
super.onCreate(savedInstanceState);
2124
setContentView(R.layout.activity_noroot);
2225

2326
AppCompatImageButton mBack = findViewById(R.id.back_button);
27+
AppCompatTextView mainTitle = findViewById(R.id.main_title);
28+
AppCompatTextView mainText = findViewById(R.id.main_text);
2429
AppCompatTextView mCancel = findViewById(R.id.cancel_button);
30+
if (!RootUtils.rootAccess()) {
31+
mainTitle.setText(R.string.no_root);
32+
mainText.setText(R.string.no_root_message);
33+
} else {
34+
mainTitle.setText(R.string.unsupported);
35+
mainText.setText(getString(R.string.unsupported_reason) + "\n\n" + getString(R.string.unsupported_summary) +
36+
"\n\n\n" + getString(R.string.unsupported_solution) + "\n\n" + getString(R.string.unsupported_message) +
37+
"\n\n\n" + getString(R.string.kernel_support) + "\n\n" + getString(R.string.kernel_support_summary) +
38+
"\n\n\n" + getString(R.string.unsupported_help_message));
39+
}
2540
mBack.setOnClickListener(v -> onBackPressed());
2641
mCancel.setOnClickListener(v -> super.onBackPressed());
2742
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
android:tint="?android:attr/colorAccent"/>
2929

3030
<androidx.appcompat.widget.AppCompatTextView
31+
android:id="@+id/main_title"
3132
android:layout_width="wrap_content"
3233
android:layout_height="50dp"
3334
android:layout_marginStart="50dp"
@@ -62,6 +63,7 @@
6263
android:tint="?android:attr/colorAccent"/>
6364

6465
<androidx.appcompat.widget.AppCompatTextView
66+
android:id="@+id/main_text"
6567
android:layout_width="match_parent"
6668
android:layout_height="wrap_content"
6769
android:layout_gravity="top"

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<string name="edit_config_saved">Configuration file is updated! The changes will be applied on next app launch.</string>
3737
<string name="failed_message">Unfortunately, \'%s\' is NOT a supported string! Please try another one!</string>
3838
<string name="kernel_about">About Kernel</string>
39-
<string name="kernel_support">How to add support in kernel</string>
39+
<string name="kernel_support">How to add support in kernel?</string>
4040
<string name="kernel_support_summary">Kernel Profiler expects a configuration file (<b><i>kernelprofiler.json</i></b>) and one or more \'<b><i>profiles</i></b>\' (basically shell scripts) in certain specific structure placed inside <b>\'<i>/data/kernel_profiler</i>\'</b>. Please check \'<b>Settings -> Developer Tools</b>\' for more information.</string>
4141
<string name="language">Language (%s)</string>
4242
<string name="language_el">Greek</string>
@@ -90,6 +90,8 @@
9090
<string name="unsupported">No Kernel Support</string>
9191
<string name="unsupported_help_message">Please Note: This app is also equipped with necessary tools to create its support files. Please check \'Settings -> Developer Tools\' for more information.</string>
9292
<string name="unsupported_message">Please ask your favourite kernel developer to add support to this app!</string>
93+
<string name="unsupported_reason">Why this issue happened?</string>
94+
<string name="unsupported_solution">How to solve this issue?</string>
9395
<string name="unsupported_summary">It seems like your kernel doesn\'t have the necessary configuration file/profiles to support this app.</string>
9496
<string name="wrong_profile">%s is not a proper profile file! Aborting.</string>
9597
<string name="yes">Yes</string>

0 commit comments

Comments
 (0)