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

Commit

Permalink
Main: Simplified profile structure, fixed profile create section,
Browse files Browse the repository at this point in the history
& overall improvements

Signed-off-by: sunilpaulmathew <[email protected]>
  • Loading branch information
sunilpaulmathew committed May 25, 2020
1 parent 0d44711 commit 39ae1ad
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
helpIcon.setImageDrawable(Utils.getColoredIcon(R.drawable.ic_help, this));
Utils.snackbarIndenite(mViewPager, getString(R.string.unsupported_message));
helpIcon.setOnClickListener(v -> {
Utils.snackbarIndenite(mViewPager, "Soon");
new AlertDialog.Builder(this)
.setIcon(R.mipmap.ic_launcher)
.setTitle(getString(R.string.unsupported))
.setMessage(getString(R.string.unsupported_summary) + " " + getString(R.string.unsupported_message) +
"\n\n" + getString(R.string.unsupported_help_message))
.setPositiveButton(getString(R.string.cancel), (dialog1, id1) -> {
})
.show();
});
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ private void load(List<RecyclerViewItem> items) {
if (KP.KPFile().length() > 0 && KP.isKPProfile(kpProfiles.toString())) {
DescriptionView kpProfile = new DescriptionView();
kpProfile.setTitle(kpProfiles.getName().replace(".sh", ""));
kpProfile.setSummary(KP.getProfileDescription(kpProfiles.toString()));
String description = KP.getProfileDescription(kpProfiles.toString());
if (description == null) {
description = getString(R.string.description_unknown);
}
kpProfile.setSummary(description);
kpProfile.setFullSpan(true);
kpProfile.setChecked(kpProfiles.getName().equals(KP.getDefaultProfile()));
kpProfile.setOnCheckBoxListener((descriptionView, isChecked) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
});
}

private void closeForeground() {
mProfileTitleHint.setVisibility(View.GONE);
mDescriptionHint.setVisibility(View.GONE);
mDefaultHint.setVisibility(View.GONE);
mDeveloperHint.setVisibility(View.GONE);
mSupportHint.setVisibility(View.GONE);
mDonationsHint.setVisibility(View.GONE);
mTitle.setVisibility(View.GONE);
mProfileTitle.setVisibility(View.GONE);
mDescription.setVisibility(View.GONE);
mDefault.setVisibility(View.GONE);
mDeveloper.setVisibility(View.GONE);
mSupport.setVisibility(View.GONE);
mDonation.setVisibility(View.GONE);
super.onBackPressed();
}

@Override
public void onBackPressed() {
closeForeground();
super.onBackPressed();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mProfileDetails = findViewById(R.id.profile_details);
mTestButton = findViewById(R.id.test_button);
mTestOutput = findViewById(R.id.test_output);
mTitle.setText(getString(R.string.create_config));
mProfileDescriptionHint.setVisibility(View.VISIBLE);
mProfileDetailsHint.setVisibility(View.VISIBLE);
mTitle.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -156,21 +155,10 @@ public void run() {
}.start();
}

private void closeForeground() {
mProfileDescriptionHint.setVisibility(View.GONE);
mProfileDetailsHint.setVisibility(View.GONE);
mTitle.setVisibility(View.GONE);
mProfileDescription.setVisibility(View.GONE);
mProfileDetails.setVisibility(View.GONE);
mTestButton.setVisibility(View.GONE);
mTestOutput.setVisibility(View.GONE);
super.onBackPressed();
}

@Override
public void onBackPressed() {
if (KP.mTestingProfile) return;
closeForeground();
super.onBackPressed();
}

}
3 changes: 1 addition & 2 deletions app/src/main/java/com/smartpack/kernelprofiler/utils/KP.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ private static String readProfile(String file) {
}

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

public static boolean supported() {
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/res/layout/rv_foreground_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@
android:textIsSelectable="true"
android:textSize="15sp" />

<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:textStyle="bold"
android:gravity="center_horizontal"
android:text="@string/kernel_support"
android:textColor="?android:attr/colorAccent"
android:textIsSelectable="true"
android:textSize="18sp" />

<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:paddingTop="16dp"
android:gravity="center_horizontal"
android:text="@string/kernel_support_summary"
android:textStyle="normal"
android:lineSpacingExtra="5dp"
android:textColor="?android:attr/textColorPrimary"
android:textIsSelectable="true"
android:textSize="15sp" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/credits_title"
android:layout_width="match_parent"
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
<string name="credits">Credits</string>
<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>
<string name="dark_theme">Dark Theme</string>
<string name="description">Description (Mandatory)</string>
<string name="description">Description</string>
<string name="description_summary">Add a short description about your kernel here (single line)!</string>
<string name="description_unknown">Description for this profile is not provided by the developer.</string>
<string name="default_profile">Default Profile (Mandatory)</string>
<string name="default_profile_summary">Specify default profile name (including \'.sh\' extension) here!</string>
<string name="developer_credits">Developer Credits</string>
Expand All @@ -26,6 +27,8 @@
<string name="donation_app">Buy Donation App</string>
<string name="donations_summary">Add donation link here!</string>
<string name="kernel_about">About Kernel</string>
<string name="kernel_support">How to add support in kernel</string>
<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>
<string name="more">More</string>
<string name="name_empty">Profile name shouldn\'t be empty! Aborting.</string>
<string name="no_internet">Please check your internet connection!</string>
Expand All @@ -39,7 +42,7 @@
<string name="options">Options</string>
<string name="press_back">Press back again to exit</string>
<string name="profile_applied_success">%s applied successfully!</string>
<string name="profile_description">Profile Description (Mandatory)</string>
<string name="profile_description">Profile Description</string>
<string name="profile_description_summary">Add description here!</string>
<string name="profile_details">Profile Details</string>
<string name="profile_details_summary">Add details (only commands) here!</string>
Expand All @@ -57,7 +60,9 @@
<string name="title_summary">Add your title here! (Important: Title should contain a matching word from \'uname\')</string>
<string name="tools_developer">Developer Tools</string>
<string name="unsupported">No Kernel Support</string>
<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>
<string name="unsupported_message">Please ask your favourite kernel developer to add support to this app!</string>
<string name="unsupported_summary">It seems like you\'re kernel doesn\'t have necessary configuration file/profiles to support this app.</string>
<string name="wrong_profile">%s is not a proper profile file! Aborting.</string>
<string name="yes">Yes</string>
</resources>

0 comments on commit 39ae1ad

Please sign in to comment.