Un-hardcode strings

This commit is contained in:
SerpentSpirale 2021-11-06 22:10:22 +01:00
parent ed9810aecf
commit 7d4fbfaaa9
5 changed files with 48 additions and 22 deletions

View File

@ -20,7 +20,7 @@ public class BackButtonPreference extends Preference {
private void init(){
if(getTitle() == null){
setTitle("Back to the last screen");
setTitle(R.string.preference_back_title);
}
if(getIcon() == null){
setIcon(R.drawable.ic_arrow_back_white);

View File

@ -38,7 +38,7 @@ public class ControlOffsetPreference extends Preference {
private void init(){
// Setup visual values
if(getTitle() == null){
setTitle("Control side offsets");
setTitle(R.string.preference_back_title);
}
if(getIcon() == null){
setIcon(android.R.drawable.radiobutton_off_background);
@ -47,7 +47,7 @@ public class ControlOffsetPreference extends Preference {
// Prepare Alert dialog
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext());
dialogBuilder.setView(R.layout.control_offset_preference_dialog);
dialogBuilder.setTitle("Control offset");
dialogBuilder.setTitle(getContext().getString(R.string.control_offset_title));
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.setNegativeButton(android.R.string.cancel, null);
@ -75,19 +75,23 @@ public class ControlOffsetPreference extends Preference {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if(seekBar == topOffsetSeekbar){
topOffsetTextView.setText("Top offset: " + i);
String text = String.format("%s%d", getContext().getString(R.string.control_top_offset), i);
topOffsetTextView.setText(text);
return;
}
if(seekBar == rightOffsetSeekbar){
rightOffsetTextView.setText("Right offset: " + i);
String text = String.format("%s%d", getContext().getString(R.string.control_right_offset), i);
rightOffsetTextView.setText(text);
return;
}
if(seekBar == bottomOffsetSeekbar){
bottomOffsetTextView.setText("Bottom offset: " + i);
String text = String.format("%s%d", getContext().getString(R.string.control_bottom_offset), i);
bottomOffsetTextView.setText(text);
return;
}
if(seekBar == leftOffsetSeekbar){
leftOffsetTextView.setText("Left offset: " + i);
String text = String.format("%s%d", getContext().getString(R.string.control_left_offset), i);
leftOffsetTextView.setText(text);
return;
}
}

View File

@ -5,7 +5,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginHorizontal="15dp">
@ -13,7 +13,7 @@
android:id="@+id/control_offset_top_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Top offset:"
android:text="@string/control_top_offset"
/>
<SeekBar
@ -26,7 +26,7 @@
android:id="@+id/control_offset_right_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Right offset:"
android:text="@string/control_right_offset"
/>
<SeekBar
@ -39,7 +39,7 @@
android:id="@+id/control_offset_bottom_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bottom offset:"
android:text="@string/control_bottom_offset"
/>
<SeekBar
@ -51,7 +51,7 @@
android:id="@+id/control_offset_left_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Left offset:"
android:text="@string/control_left_offset"
/>
<SeekBar

View File

@ -255,4 +255,26 @@
<string name="pvc_title">Per-version settings</string>
<string name="storage_warning_title">Storage changes</string>
<string name="storage_warning_text"> <![CDATA[Due to Google\'s new scoped storage enforcements added in Android 10 and higher, we are required to move the game directory into an app-private folder.<br /> The new folder for Pojav files is <b>Android/data/%s/files/</b> (also accessible using a storage provider in your file explorer).<br /> If you need to copy your game files, please copy everything from the original folder at <b>games/PojavLauncher</b> manually.]]></string>
<string name="control_offset_title">Control offset</string>
<string name="control_top_offset">Top offset: </string>
<string name="control_right_offset">right offset: </string>
<string name="control_bottom_offset">bottom offset: </string>
<string name="control_left_offset">left offset: </string>
<string name="preference_control_offset_title">Control side offsets</string>
<string name="preference_control_offset_description">Set a custom offset to each side of the screen</string>
<string name="preference_video_title">Video and renderer</string>
<string name="preference_video_description">Resolution, scaling type, and renderer</string>
<string name="preference_control_title">Control customization</string>
<string name="preference_control_description">Gestures types, triggers, and scaling</string>
<string name="preference_java_title">Java Tweaks</string>
<string name="preference_java_description">Java versions, JVM Arguments, and RAM amount</string>
<string name="preference_misc_title">Miscellaneous settings</string>
<string name="preference_misc_description">Version list, and libs checks</string>
<string name="preference_experimental_title">Experimental Stuff</string>
<string name="preference_experimental_description">Use things there with consideration, no support.</string>
<string name="preference_back_title">Back to the last screen</string>
</resources>

View File

@ -3,36 +3,36 @@
<Preference
android:key="video_screen_setting"
android:title="Video and renderer"
android:summary="Resolution, scaling type, and renderer"
android:title="@string/preference_video_title"
android:summary="@string/preference_video_description"
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceVideoFragment"
/>
<Preference
android:key="control_screen_setting"
android:title="Control customization"
android:summary="Gestures types, triggers, and scaling"
android:title="@string/preference_control_title"
android:summary="@string/preference_control_description"
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceControlFragment"
/>
<Preference
android:key="java_screen_setting"
android:title="Java Tweaks"
android:summary="Java versions, JVM Arguments, and RAM amount"
android:title="@string/preference_java_title"
android:summary="@string/preference_java_description"
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceJavaFragment"
/>
<Preference
android:key="misc_screen_setting"
android:title="Miscellaneous settings"
android:summary="Version list, and libs checks"
android:title="@string/preference_misc_title"
android:summary="@string/preference_misc_description"
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceMiscellaneousFragment"
/>
<Preference
android:key="experimental_screen_setting"
android:title="Experimental Stuff"
android:summary="Use things there with consideration, no support."
android:title="@string/preference_experimental_title"
android:summary="@string/preference_experimental_description"
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceExperimentalFragment"
/>