Skip to content

Commit

Permalink
refactor(strings): change naming of strings
Browse files Browse the repository at this point in the history
- `pref_title_my_settings` -> `pref_my_settings_title`
- `pref_desc_settings_two` -> `pref_settings_two_desc`
- Everything is now sorted properly for maintainence and easier readability
- Add todos
  • Loading branch information
EdricChan03 committed Mar 7, 2018
1 parent 2288984 commit 3d9c551
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 131 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</activity>
<activity
android:name=".MyIntroActivity"
android:label="@string/app_intro"
android:label="@string/title_activity_intro"
android:theme="@style/Theme.Intro" />
<activity
android:name=".LoginActivity"
Expand Down
37 changes: 8 additions & 29 deletions app/src/main/java/com/edricchan/studybuddy/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void showOreoSettings() {
notificationPrefCategory.setTitle("Notification Channels");
preferenceScreen.addPreference(notificationPrefCategory);
Preference allNotificationsPreference = new Preference(preferenceScreen.getContext());
allNotificationsPreference.setTitle(R.string.notification_channel_all_channels_title);
allNotificationsPreference.setTitle(R.string.pref_notification_channel_all_channels_title);
allNotificationsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Expand Down Expand Up @@ -412,21 +412,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
.setChecked(sharedPreferences.getBoolean("enable_pre_oreo_explicit", false));
}
}

public void registerOnSharedPreferenceChangeListener() {
SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
boolean notifIsOn = sharedPreferences.getBoolean(getString(R.string.pref_title_new_message_notifications), true);
// TODO
// SwitchPreference notifSwitchPreference = (SwitchPreference) getFragmentManager().
if (notifIsOn) {
} else {

}
}
};
}
}

/**
Expand Down Expand Up @@ -521,27 +506,21 @@ public boolean onPreferenceClick(Preference preference) {
appSrc.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference.getKey().equals("app_src_code")) {
customTabsIntent.launchUrl(context, Uri.parse(appSrcUrl));
return true;
}
return false;
customTabsIntent.launchUrl(context, Uri.parse(appSrcUrl));
return true;
}
});
Preference appIntro = getPreferenceManager().findPreference("app_intro");
appIntro.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference.getKey().equals("app_intro")) {
Intent appIntroIntent = new Intent(context, MyIntroActivity.class);
startActivity(appIntroIntent);
return true;
}
return false;
Intent appIntroIntent = new Intent(context, MyIntroActivity.class);
startActivity(appIntroIntent);
return true;
}
});
Preference appVer = getPreferenceManager().findPreference("app_ver");
appVer.setSummary(getVersion());
Preference appVersion = getPreferenceManager().findPreference("app_ver");
appVersion.setSummary(getVersion());
bindPreferenceSummaryToValue(findPreference("updates_channel"));
}

Expand Down
147 changes: 65 additions & 82 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
<resources>
<!-- Web client ID -->
<string name="web_client_id">713563449638-sc1up855asm687s55f8qi4bdrh0u18tc.apps.googleusercontent.com </string>
<!-- For android manifest -->
<string name="app_name">Study Buddy</string>
<string name="action_settings">Settings</string>

<!-- Activity names -->
<string name="title_activity_settings">Settings</string>
<string name="title_activity_login">Sign in</string>
<string name="title_activity_intro">App Intro</string>

<!-- Web client ID -->
<string name="web_client_id">713563449638-sc1up855asm687s55f8qi4bdrh0u18tc.apps.googleusercontent.com</string>

<!-- App updater values -->
<!-- TODO: Don't use a snackbar for showing when the app is checking for updates -->
<string name="snackbar_check_updates">Checking for updates&#8230;</string>

<!-- Share bottom sheet -->
<string name="share_intent_value">Share this app via&#8230;</string>
<string name="share_content">Check out yet another open-source app by @EdricChan03! Source code available at https://github.com/Chan4077/StudyBuddy</string>

<!-- About dialog -->
<string name="about_dialog_text">This app officially started in 2017. However, not much work has been going on until fairly recently.\n---\nExpect an official release by April!</string>

<!-- Task dialog -->
<string name="custom_dialog_labels_note">Note: Please separate your labels with a comma (,).</string>
<string name="task_project">Task Project</string>
<string name="task_title">Task Title</string>
<string name="task_content">Task Content</string>
<string name="select_date">Select Date</string>
<string name="title_activity_settings">Settings</string>
<string name="due_date">Due date</string>
<string name="due_date_text">Selected due date shows here</string>

<!-- App shortcuts -->
<string name="shortcut_todo_disabled_msg">Todo is disabled</string>
<string name="shortcut_todo_long_msg">Create a new todo</string>
<string name="shortcut_todo_short_msg">New todo</string>
<!-- Strings related to Settings -->

<!-- Example General settings -->
<!-- Strings related to Settings -->
<!-- Experimental settings -->
<string name="pref_header_experimental">Experimental</string>

<string name="pref_title_experimental_ui">Experimental UI</string>
<string name="pref_desc_experimental_ui">Shows a new interface for those who would like to beta test new features.</string>
<string name="pref_title_experimental_features">Experimental Features</string>
<string name="pref_desc_experimental_features">Enables features that may or may not be eventually released to the public.</string>
<string name="pref_title_experimental_calendar">Experimental Calendar</string>
<string name="pref_desc_experimental_calendar">Enables the experimental calendar that is currently a Work In Progress and will be eventually be released to the public.</string>
<!-- Example settings for Data & Sync -->
<string name="pref_experimental_features_title">Experimental Features</string>
<string name="pref_experimental_features_desc">Enables features that are in development.</string>
<string name="pref_experimental_ui_title">Experimental UI</string>
<string name="pref_experimental_ui_desc">Shows a new and improved user interface. Requires a restart to take effect.</string>
<string name="pref_experimental_calendar_title">Experimental Calendar</string>
<string name="pref_experimental_calendar_desc">Enables a wip calendar which shows all your events. Requires a restart to take effect.</string>
<!-- Settings for Data & Sync -->
<string name="pref_header_data_sync">Data &amp; sync</string>

<string name="pref_title_sync_frequency">Sync frequency</string>
<string name="pref_sync_frequency_title">Sync frequency</string>
<string-array name="pref_sync_frequency_titles">
<item>15 minutes</item>
<item>30 minutes</item>
Expand All @@ -45,77 +63,51 @@
<item>360</item>
<item>-1</item>
</string-array>

<string-array name="pref_notification_categories">
<item>When a task is due/ overdue</item>
<item>Weekly agenda</item>
<item>Product tips and others</item>
</string-array>

<string-array name="pref_notification_categories_values">
<string name="pref_system_sync_settings_title">System sync settings</string>
<!-- Settings for Notifications -->
<string name="pref_header_notifications">Notifications</string>
<string name="pref_ringtone_silent">Silent</string>
<string name="pref_notification_channel_all_channels_title">All notification channels</string>
<!-- Notifications > For devices running pre-Android Oreo -->
<string name="pref_enable_all_notification_channels_title">Enable all notification channels</string>
<string name="pref_enable_more_options_title">Enable more options</string>
<string name="pref_enable_more_options_desc">Enables extra configuration options for notifications\nRequires a restart of the app to take effect.</string>
<!-- Settings for Versions & About -->
<string name="pref_header_version">Versions &amp; About</string>
<string name="pref_update_channel_title">Select update channel</string>
<string name="pref_app_version_title">Current app version</string>
<string name="pref_source_code_title">Source code</string>
<string name="pref_source_code_desc">View source code on Github</string>
<string name="pref_author_title">App Author</string>
<string name="pref_author_desc">View the app\'s author on Github</string>
<string name="pref_app_intro_title">App intro</string>
<string-array name="pref_updates_channels_values">
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
<string-array name="pref_notification_categories_default">
<item>1</item>
<item>2</item>
<string-array name="pref_updates_channels">
<item>Stable</item>
<item>Beta</item>
<item>Canary</item>
</string-array>
<string-array name="multi_select_list_preference_default_value" />

<string name="pref_title_system_sync_settings">System sync settings</string>

<!-- Example settings for Notifications -->
<string name="pref_header_notifications">Notifications</string>

<string name="pref_title_new_message_notifications">New message notifications</string>

<string name="pref_title_ringtone">Ringtone</string>
<string name="pref_ringtone_silent">Silent</string>

<string name="pref_title_vibrate">Vibrate</string>
<string name="pref_desc_new_message_notifications">Enable notifications when something happens (This can be configured in the \'Notification Categories\' setting)</string>
<string name="pref_updates_channel_default">1</string>

<!-- Actions (menu) -->
<string name="action_about">About</string>
<string name="action_share">Share this app</string>
<string name="action_settings">Settings</string>

<!-- Share dialog -->
<string name="share_intent_value">Share this app via&#8230;</string>
<string name="share_content">Check out yet another open-source app by @EdricChan03! Source code available at https://github.com/Chan4077/StudyBuddy</string>
<string name="about_dialog_text">This app started due to my excellent coding skills leading to developing this app which is meant for those who would like a study calendar. However, at the moment, there are not many features available.</string>
<string name="pref_title_notification_categories">Notification categories</string>
<string name="pref_desc_notification_categories">Tick list items that you want to receive notifications for.</string>
<string name="pref_title_updates_channel">Select update channel</string>
<string name="pref_title_app_ver">Current app version</string>
<string name="pref_title_src_ver">Source code</string>
<string name="pref_desc_src_ver">View source code on Github</string>
<string name="pref_title_ver">Versions &amp; About</string>
<string name="pref_title_author">App Author</string>
<string name="pref_desc_author">View the app\'s author on Github</string>
<!-- Actions > Settings activity -->
<string name="action_send_feedback">Send Feedback</string>
<string name="snackbar_check_updates">Checking for updates&#8230;</string>
<string name="app_intro">App Intro</string>
<string name="pref_desc_app_intro">Shows the app intro</string>
<string name="pref_title_app_intro">App intro</string>
<string name="action_todo_title">TODOs</string>
<string name="action_calendar_title">Calendar</string>
<string name="action_notifications_title">Notifications</string>
<string name="action_help">Help</string>
<string name="action_pre_oreo_ui">Show pre-Oreo UI</string>

<string-array name="pref_updates_channels_values">
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
<string-array name="pref_updates_channels">
<item>Stable</item>
<item>Beta</item>
<item>Canary</item>
</string-array>
<string name="pref_updates_channel_default">1</string>
<string name="title_activity_login">Sign in</string>

<!-- Sidenav -->
<string name="action_todo_title">TODOs</string>
<string name="action_calendar_title">Calendar</string>
<string name="action_notifications_title">Notifications</string>

<!-- Strings related to login -->
<string name="email_hint">Email</string>
Expand All @@ -133,11 +125,7 @@
<string name="minimum_password">The password that you entered is too short, please enter a minimum of 6 characters!</string>
<string name="auth_failed">Authentication failed, check your email and password to ensure they are correct or sign up if you haven\'t created an account.</string>
<string name="action_link_register_btn">Register for an account</string>
<string name="due_date">Due date</string>
<string name="due_date_text">Selected due date shows here</string>

<!-- For settings > Notifications -->
<string name="notification_channel_all_channels_title">All notification channels</string>
<!-- Notification channels -->
<string name="notification_channel_todo_updates_title">Todo updates</string>
<string name="notification_channel_todo_updates_desc">Shows updates on the status of todos</string>
Expand All @@ -157,9 +145,4 @@
<string name="notification_channel_uncategorised_title">Uncategorised</string>
<string name="notification_channel_uncategorised_desc">All other notifications that don\'t fit in any of the previous channels</string>
<string name="notification_channel_uncategorised_id">uncategorised</string>

<!-- For devices running pre-Android Oreo -->
<string name="pref_enable_all_notification_channels_title">Enable all notification channels</string>
<string name="pref_enable_more_options_title">Enable more options</string>
<string name="pref_enable_more_options_desc">Enables extra configuration options for notifications\nRequires a restart of the app to take effect.</string>
</resources>
4 changes: 2 additions & 2 deletions app/src/main/res/xml/pref_data_sync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
android:entries="@array/pref_sync_frequency_titles"
android:entryValues="@array/pref_sync_frequency_values"
android:key="sync_frequency"
android:title="@string/pref_title_sync_frequency" />
android:title="@string/pref_sync_frequency_title" />

<!-- This preference simply launches an intent when selected. Use this UI sparingly, per
design guidelines. -->
<Preference android:title="@string/pref_title_system_sync_settings">
<Preference android:title="@string/pref_system_sync_settings_title">
<intent android:action="android.settings.SYNC_SETTINGS" />
</Preference>

Expand Down
14 changes: 7 additions & 7 deletions app/src/main/res/xml/pref_experimental.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
<SwitchPreference
android:defaultValue="false"
android:key="experimental_features"
android:summary="@string/pref_desc_experimental_features"
android:title="@string/pref_title_experimental_features"
android:summary="@string/pref_experimental_features_desc"
android:title="@string/pref_experimental_features_title"
android:icon="@drawable/ic_flask_white_24dp"/>
<SwitchPreference
android:defaultValue="false"
android:key="experimental_ui"
android:summary="@string/pref_desc_experimental_ui"
android:title="@string/pref_title_experimental_ui"
android:summary="@string/pref_experimental_ui_desc"
android:title="@string/pref_experimental_ui_title"
android:dependency="experimental_features"
android:icon="@drawable/ic_flask_white_24dp"/>
android:icon="@drawable/ic_view_quilt_white_24dp"/>
<SwitchPreference
android:defaultValue="false"
android:key="experimental_calendar"
android:summary="@string/pref_desc_experimental_calendar"
android:title="@string/pref_title_experimental_calendar"
android:summary="@string/pref_experimental_calendar_desc"
android:title="@string/pref_experimental_calendar_title"
android:dependency="experimental_features"
android:icon="@drawable/ic_calendar_white_24dp"/>
</PreferenceScreen>
2 changes: 1 addition & 1 deletion app/src/main/res/xml/pref_headers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
android:title="@string/pref_header_data_sync" />
<header
android:fragment="com.edricchan.studybuddy.SettingsActivity$VersionPreferenceFragment"
android:title="@string/pref_title_ver"
android:title="@string/pref_header_version"
android:icon="@drawable/ic_info_white_24dp"/>
</preference-headers>
16 changes: 7 additions & 9 deletions app/src/main/res/xml/pref_versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ListPreference
android:icon="@drawable/ic_flask_white_24dp"
android:key="updates_channel"
android:title="@string/pref_title_updates_channel"
android:title="@string/pref_update_channel_title"
android:entryValues="@array/pref_updates_channels_values"
android:entries="@array/pref_updates_channels"
android:defaultValue="@string/pref_updates_channel_default"/>
Expand All @@ -14,20 +14,18 @@
</PreferenceCategory>
<PreferenceCategory android:title="About">
<Preference
android:key="app_version"
android:enabled="false"
android:key="app_ver"
android:title="@string/pref_title_app_ver" />
android:title="@string/pref_app_version_title" />
<Preference
android:key="app_src_code"
android:summary="@string/pref_desc_src_ver"
android:title="@string/pref_title_src_ver" />
android:summary="@string/pref_source_code_desc"
android:title="@string/pref_source_code_title" />
<Preference
android:key="app_author"
android:summary="@string/pref_desc_author"
android:title="@string/pref_title_author" />
android:title="@string/pref_author_title" />
<Preference
android:key="app_intro"
android:summary="@string/pref_desc_app_intro"
android:title="@string/pref_title_app_intro"/>
android:title="@string/pref_app_intro_title" />
</PreferenceCategory>
</PreferenceScreen>

0 comments on commit 3d9c551

Please sign in to comment.