♻️ refactor(onboarding): use static arrays for tutorial step data, update string resources to reduce memory footprint
This commit is contained in:
3 files changed
+33
-41
No files matched your search
@@ -28,35 +28,27 @@ public class OnboardingTutorialDialog extends Dialog implements View.OnClickList
|
|||||||
|
|
||||||
private final LauncherActivity launcherActivity;
|
private final LauncherActivity launcherActivity;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
private TextView titleView;
|
private TextView titleView;
|
||||||
private TextView stepIndicatorView;
|
private TextView stepIndicatorView;
|
||||||
private TextView contentView;
|
private TextView contentView;
|
||||||
private TextView skipButton;
|
private TextView skipButton;
|
||||||
private TextView previousButton;
|
private TextView previousButton;
|
||||||
private TextView nextButton;
|
private TextView nextButton;
|
||||||
|
|
||||||
private int currentStep = 1;
|
private int currentStep = 1;
|
||||||
private static final int TOTAL_STEPS = 7;
|
private static final int TOTAL_STEPS = 7;
|
||||||
|
|
||||||
// Tutorial step data
|
// Tutorial step data - using static arrays to reduce memory footprint
|
||||||
private final int[] stepTitles = {
|
private static final int[] STEP_TITLES = {
|
||||||
R.string.tutorial_step_1_title,
|
R.string.tutorial_step_1_title, R.string.tutorial_step_2_title, R.string.tutorial_step_3_title,
|
||||||
R.string.tutorial_step_2_title,
|
R.string.tutorial_step_4_title, R.string.tutorial_step_5_title, R.string.tutorial_step_6_title,
|
||||||
R.string.tutorial_step_3_title,
|
|
||||||
R.string.tutorial_step_4_title,
|
|
||||||
R.string.tutorial_step_5_title,
|
|
||||||
R.string.tutorial_step_6_title,
|
|
||||||
R.string.tutorial_step_7_title
|
R.string.tutorial_step_7_title
|
||||||
};
|
};
|
||||||
|
|
||||||
private final int[] stepContents = {
|
private static final int[] STEP_CONTENTS = {
|
||||||
R.string.tutorial_step_1_content,
|
R.string.tutorial_step_1_content, R.string.tutorial_step_2_content, R.string.tutorial_step_3_content,
|
||||||
R.string.tutorial_step_2_content,
|
R.string.tutorial_step_4_content, R.string.tutorial_step_5_content, R.string.tutorial_step_6_content,
|
||||||
R.string.tutorial_step_3_content,
|
|
||||||
R.string.tutorial_step_4_content,
|
|
||||||
R.string.tutorial_step_5_content,
|
|
||||||
R.string.tutorial_step_6_content,
|
|
||||||
R.string.tutorial_step_7_content
|
R.string.tutorial_step_7_content
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,7 +84,7 @@ public class OnboardingTutorialDialog extends Dialog implements View.OnClickList
|
|||||||
|
|
||||||
// Update content for first step
|
// Update content for first step
|
||||||
updateStepContent();
|
updateStepContent();
|
||||||
|
|
||||||
// Prevent dismissing by tapping outside
|
// Prevent dismissing by tapping outside
|
||||||
setCancelable(false);
|
setCancelable(false);
|
||||||
}
|
}
|
||||||
@@ -120,21 +112,21 @@ public class OnboardingTutorialDialog extends Dialog implements View.OnClickList
|
|||||||
|
|
||||||
private void updateStepContent() {
|
private void updateStepContent() {
|
||||||
// Update title
|
// Update title
|
||||||
titleView.setText(stepTitles[currentStep - 1]);
|
titleView.setText(STEP_TITLES[currentStep - 1]);
|
||||||
|
|
||||||
// Update step indicator
|
// Update step indicator
|
||||||
stepIndicatorView.setText(currentStep + " / " + TOTAL_STEPS);
|
stepIndicatorView.setText(currentStep + "/" + TOTAL_STEPS);
|
||||||
|
|
||||||
// Update content
|
// Update content
|
||||||
contentView.setText(stepContents[currentStep - 1]);
|
contentView.setText(STEP_CONTENTS[currentStep - 1]);
|
||||||
|
|
||||||
// Update button visibility and text
|
// Update button visibility and text
|
||||||
if (currentStep == 1) {
|
if (currentStep == 1) {
|
||||||
previousButton.setVisibility(View.GONE);
|
previousButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
previousButton.setVisibility(View.VISIBLE);
|
previousButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentStep == TOTAL_STEPS) {
|
if (currentStep == TOTAL_STEPS) {
|
||||||
nextButton.setText(R.string.onboarding_finish);
|
nextButton.setText(R.string.onboarding_finish);
|
||||||
skipButton.setVisibility(View.GONE);
|
skipButton.setVisibility(View.GONE);
|
||||||
@@ -148,7 +140,7 @@ public class OnboardingTutorialDialog extends Dialog implements View.OnClickList
|
|||||||
// Mark tutorial as completed
|
// Mark tutorial as completed
|
||||||
DbUtils.setTutorialCompleted(true);
|
DbUtils.setTutorialCompleted(true);
|
||||||
DbUtils.setFirstTimeUser(false);
|
DbUtils.setFirstTimeUser(false);
|
||||||
|
|
||||||
// Dismiss dialog
|
// Dismiss dialog
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="1 / 7"
|
android:text="1/7"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="14sp"
|
android:textSize="12sp"
|
||||||
android:alpha="0.7" />
|
android:alpha="0.7" />
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
|
|||||||
@@ -116,26 +116,26 @@
|
|||||||
<string name="onboarding_close">Close</string>
|
<string name="onboarding_close">Close</string>
|
||||||
|
|
||||||
<!-- Tutorial Steps -->
|
<!-- Tutorial Steps -->
|
||||||
<string name="tutorial_step_1_title">Welcome to Lunox Launcher</string>
|
<string name="tutorial_step_1_title">Welcome to Lunox</string>
|
||||||
<string name="tutorial_step_1_content">Lunox is a minimalist text-based launcher that puts simplicity first. All your apps are displayed as text in a clean, distraction-free interface.</string>
|
<string name="tutorial_step_1_content">A minimalist text-based launcher. Apps are displayed as text in a clean interface.</string>
|
||||||
|
|
||||||
<string name="tutorial_step_2_title">Opening Apps</string>
|
<string name="tutorial_step_2_title">Opening Apps</string>
|
||||||
<string name="tutorial_step_2_content">Simply tap on any app name to open it. Apps are sorted alphabetically by default, but you can change the sorting in settings.</string>
|
<string name="tutorial_step_2_content">Tap any app name to open it. Apps are sorted alphabetically by default.</string>
|
||||||
|
|
||||||
<string name="tutorial_step_3_title">Search Functionality</string>
|
<string name="tutorial_step_3_title">Search</string>
|
||||||
<string name="tutorial_step_3_content">Swipe down to up anywhere on the screen to open the search bar. Start typing to quickly find and launch any app.</string>
|
<string name="tutorial_step_3_content">Swipe down to up to open search. Start typing to find apps quickly.</string>
|
||||||
|
|
||||||
<string name="tutorial_step_4_title">App Options</string>
|
<string name="tutorial_step_4_title">App Options</string>
|
||||||
<string name="tutorial_step_4_content">Long press on any app to access options like rename, hide, uninstall, change colors, and more customization features.</string>
|
<string name="tutorial_step_4_content">Long press any app for options: rename, hide, colors, and more.</string>
|
||||||
|
|
||||||
<string name="tutorial_step_5_title">Launcher Settings</string>
|
<string name="tutorial_step_5_title">Settings</string>
|
||||||
<string name="tutorial_step_5_content">Long press on empty space to access launcher settings. Here you can change themes, fonts, sorting options, and other preferences.</string>
|
<string name="tutorial_step_5_content">Long press empty space for launcher settings: themes, fonts, sorting.</string>
|
||||||
|
|
||||||
<string name="tutorial_step_6_title">Customization</string>
|
<string name="tutorial_step_6_title">Customization</string>
|
||||||
<string name="tutorial_step_6_content">Personalize your launcher with different themes, custom colors for apps, font options, and various sorting methods to make it truly yours.</string>
|
<string name="tutorial_step_6_content">Personalize with themes, colors, fonts, and sorting methods.</string>
|
||||||
|
|
||||||
<string name="tutorial_step_7_title">You\'re All Set!</string>
|
<string name="tutorial_step_7_title">Ready!</string>
|
||||||
<string name="tutorial_step_7_content">That\'s all you need to know to get started with Lunox. Enjoy your clean, minimalist launcher experience!</string>
|
<string name="tutorial_step_7_content">You\'re all set. Enjoy your minimalist launcher!</string>
|
||||||
|
|
||||||
<string name="tutorial_replay">Show Tutorial</string>
|
<string name="tutorial_replay">Show Tutorial</string>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user