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

Commit 39ae1ad

Browse files
Main: Simplified profile structure, fixed profile create section,
& overall improvements Signed-off-by: sunilpaulmathew <[email protected]>
1 parent 0d44711 commit 39ae1ad

File tree

7 files changed

+47
-37
lines changed

7 files changed

+47
-37
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
9696
helpIcon.setImageDrawable(Utils.getColoredIcon(R.drawable.ic_help, this));
9797
Utils.snackbarIndenite(mViewPager, getString(R.string.unsupported_message));
9898
helpIcon.setOnClickListener(v -> {
99-
Utils.snackbarIndenite(mViewPager, "Soon");
99+
new AlertDialog.Builder(this)
100+
.setIcon(R.mipmap.ic_launcher)
101+
.setTitle(getString(R.string.unsupported))
102+
.setMessage(getString(R.string.unsupported_summary) + " " + getString(R.string.unsupported_message) +
103+
"\n\n" + getString(R.string.unsupported_help_message))
104+
.setPositiveButton(getString(R.string.cancel), (dialog1, id1) -> {
105+
})
106+
.show();
100107
});
101108
return;
102109
}

app/src/main/java/com/smartpack/kernelprofiler/fragments/KPFragment.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ private void load(List<RecyclerViewItem> items) {
8383
if (KP.KPFile().length() > 0 && KP.isKPProfile(kpProfiles.toString())) {
8484
DescriptionView kpProfile = new DescriptionView();
8585
kpProfile.setTitle(kpProfiles.getName().replace(".sh", ""));
86-
kpProfile.setSummary(KP.getProfileDescription(kpProfiles.toString()));
86+
String description = KP.getProfileDescription(kpProfiles.toString());
87+
if (description == null) {
88+
description = getString(R.string.description_unknown);
89+
}
90+
kpProfile.setSummary(description);
8791
kpProfile.setFullSpan(true);
8892
kpProfile.setChecked(kpProfiles.getName().equals(KP.getDefaultProfile()));
8993
kpProfile.setOnCheckBoxListener((descriptionView, isChecked) -> {

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

+1-18
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
9595
});
9696
}
9797

98-
private void closeForeground() {
99-
mProfileTitleHint.setVisibility(View.GONE);
100-
mDescriptionHint.setVisibility(View.GONE);
101-
mDefaultHint.setVisibility(View.GONE);
102-
mDeveloperHint.setVisibility(View.GONE);
103-
mSupportHint.setVisibility(View.GONE);
104-
mDonationsHint.setVisibility(View.GONE);
105-
mTitle.setVisibility(View.GONE);
106-
mProfileTitle.setVisibility(View.GONE);
107-
mDescription.setVisibility(View.GONE);
108-
mDefault.setVisibility(View.GONE);
109-
mDeveloper.setVisibility(View.GONE);
110-
mSupport.setVisibility(View.GONE);
111-
mDonation.setVisibility(View.GONE);
112-
super.onBackPressed();
113-
}
114-
11598
@Override
11699
public void onBackPressed() {
117-
closeForeground();
100+
super.onBackPressed();
118101
}
119102

120103
}

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

+1-13
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5858
mProfileDetails = findViewById(R.id.profile_details);
5959
mTestButton = findViewById(R.id.test_button);
6060
mTestOutput = findViewById(R.id.test_output);
61-
mTitle.setText(getString(R.string.create_config));
6261
mProfileDescriptionHint.setVisibility(View.VISIBLE);
6362
mProfileDetailsHint.setVisibility(View.VISIBLE);
6463
mTitle.setVisibility(View.VISIBLE);
@@ -156,21 +155,10 @@ public void run() {
156155
}.start();
157156
}
158157

159-
private void closeForeground() {
160-
mProfileDescriptionHint.setVisibility(View.GONE);
161-
mProfileDetailsHint.setVisibility(View.GONE);
162-
mTitle.setVisibility(View.GONE);
163-
mProfileDescription.setVisibility(View.GONE);
164-
mProfileDetails.setVisibility(View.GONE);
165-
mTestButton.setVisibility(View.GONE);
166-
mTestOutput.setVisibility(View.GONE);
167-
super.onBackPressed();
168-
}
169-
170158
@Override
171159
public void onBackPressed() {
172160
if (KP.mTestingProfile) return;
173-
closeForeground();
161+
super.onBackPressed();
174162
}
175163

176164
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ private static String readProfile(String file) {
128128
}
129129

130130
public static boolean isKPProfile(String file) {
131-
return getProfileDescription(file) != null && Utils.getExtension(file).equals("sh") &&
132-
readProfile(file).startsWith("#!/system/bin/sh");
131+
return Utils.getExtension(file).equals("sh") && readProfile(file).startsWith("#!/system/bin/sh");
133132
}
134133

135134
public static boolean supported() {

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

+24
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@
105105
android:textIsSelectable="true"
106106
android:textSize="15sp" />
107107

108+
<androidx.appcompat.widget.AppCompatTextView
109+
android:layout_width="match_parent"
110+
android:layout_height="wrap_content"
111+
android:layout_marginTop="25dp"
112+
android:textStyle="bold"
113+
android:gravity="center_horizontal"
114+
android:text="@string/kernel_support"
115+
android:textColor="?android:attr/colorAccent"
116+
android:textIsSelectable="true"
117+
android:textSize="18sp" />
118+
119+
<androidx.appcompat.widget.AppCompatTextView
120+
android:layout_width="match_parent"
121+
android:layout_height="wrap_content"
122+
android:paddingBottom="16dp"
123+
android:paddingTop="16dp"
124+
android:gravity="center_horizontal"
125+
android:text="@string/kernel_support_summary"
126+
android:textStyle="normal"
127+
android:lineSpacingExtra="5dp"
128+
android:textColor="?android:attr/textColorPrimary"
129+
android:textIsSelectable="true"
130+
android:textSize="15sp" />
131+
108132
<androidx.appcompat.widget.AppCompatTextView
109133
android:id="@+id/credits_title"
110134
android:layout_width="match_parent"

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
<string name="credits">Credits</string>
1717
<string name="credits_summary"><b><i>Grarak</i></b>: KernelAdiutor (Code base)\n<b><i>topjohnwu</i></b>: libsu\n<b><i>Lennoard Silva</i></b>: Code Contributions/App Icon</string>
1818
<string name="dark_theme">Dark Theme</string>
19-
<string name="description">Description (Mandatory)</string>
19+
<string name="description">Description</string>
2020
<string name="description_summary">Add a short description about your kernel here (single line)!</string>
21+
<string name="description_unknown">Description for this profile is not provided by the developer.</string>
2122
<string name="default_profile">Default Profile (Mandatory)</string>
2223
<string name="default_profile_summary">Specify default profile name (including \'.sh\' extension) here!</string>
2324
<string name="developer_credits">Developer Credits</string>
@@ -26,6 +27,8 @@
2627
<string name="donation_app">Buy Donation App</string>
2728
<string name="donations_summary">Add donation link here!</string>
2829
<string name="kernel_about">About Kernel</string>
30+
<string name="kernel_support">How to add support in kernel</string>
31+
<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>
2932
<string name="more">More</string>
3033
<string name="name_empty">Profile name shouldn\'t be empty! Aborting.</string>
3134
<string name="no_internet">Please check your internet connection!</string>
@@ -39,7 +42,7 @@
3942
<string name="options">Options</string>
4043
<string name="press_back">Press back again to exit</string>
4144
<string name="profile_applied_success">%s applied successfully!</string>
42-
<string name="profile_description">Profile Description (Mandatory)</string>
45+
<string name="profile_description">Profile Description</string>
4346
<string name="profile_description_summary">Add description here!</string>
4447
<string name="profile_details">Profile Details</string>
4548
<string name="profile_details_summary">Add details (only commands) here!</string>
@@ -57,7 +60,9 @@
5760
<string name="title_summary">Add your title here! (Important: Title should contain a matching word from \'uname\')</string>
5861
<string name="tools_developer">Developer Tools</string>
5962
<string name="unsupported">No Kernel Support</string>
63+
<string name="unsupported_help_message">Please Note: This app is also equipped with necessity tools to create its support files. Please check \'Settings -> Developer Tools\' for more information.</string>
6064
<string name="unsupported_message">Please ask your favourite kernel developer to add support to this app!</string>
65+
<string name="unsupported_summary">It seems like you\'re kernel doesn\'t have necessary configuration file/profiles to support this app.</string>
6166
<string name="wrong_profile">%s is not a proper profile file! Aborting.</string>
6267
<string name="yes">Yes</string>
6368
</resources>

0 commit comments

Comments
 (0)