Skip to content

Commit

Permalink
Fix even more hard coded string
Browse files Browse the repository at this point in the history
  • Loading branch information
ClassicOldSong committed Jul 17, 2024
1 parent 5c6c098 commit 06d30d9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 82 deletions.
20 changes: 0 additions & 20 deletions app/src/main/assets/config/月光阿西西更新说明.txt

This file was deleted.

79 changes: 28 additions & 51 deletions app/src/main/java/com/limelight/preferences/StreamSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -757,98 +757,75 @@ public boolean onPreferenceClick(Preference preference) {

editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);

// editText.setKeyListener(new NumberKeyListener() {
// @Override
// public int getInputType() {
// return InputType.TYPE_MASK_VARIATION;
// }
// @Override
// protected char[] getAcceptedChars() {/*这里实现字符串过滤,把你允许输入的字母添加到下面的数组即可!*/
// return new char[]{'0', '1', '2', '3', '4', '5','6','7', '8', '9', '.'};
// }
// });
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(5)/*这里限制输入的长度为5个字母*/});

bitrateEditPre.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value= (String) newValue;
if(TextUtils.isEmpty(value)){
Toast.makeText(getActivity(),"请输入0-9999的数值。",Toast.LENGTH_SHORT).show();
String value = (String) newValue;
if (TextUtils.isEmpty(value)) {
Toast.makeText(getActivity(), getString(R.string.pref_enter_value_0_9999), Toast.LENGTH_SHORT).show();
return false;
}
float bitrateValue=Float.valueOf(value)*1000;
LimeLog.info("axi-bitrateValue:"+bitrateValue);
int bitrate= (int) bitrateValue;
LimeLog.info("axi-bitrate:"+bitrate);
float bitrateValue = Float.valueOf(value) * 1000;
LimeLog.info("axi-bitrateValue:" + bitrateValue);
int bitrate = (int) bitrateValue;
LimeLog.info("axi-bitrate:" + bitrate);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SettingsFragment.this.getActivity());
prefs.edit().putInt(PreferenceConfiguration.BITRATE_PREF_STRING,bitrate).apply();
Toast.makeText(getActivity(),"设置成功!",Toast.LENGTH_SHORT).show();
prefs.edit().putInt(PreferenceConfiguration.BITRATE_PREF_STRING, bitrate).apply();
Toast.makeText(getActivity(), getString(R.string.pref_set_success), Toast.LENGTH_SHORT).show();
return true;
}
});


// findPreference("checkbox_multi_touch_screen").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
// @Override
// public boolean onPreferenceChange(Preference preference, Object newValue) {
//
// if(((Boolean) newValue)){
// CheckBoxPreference checkBoxPreference= (CheckBoxPreference) findPreference(PreferenceConfiguration.TOUCHSCREEN_TRACKPAD_PREF_STRING);
// checkBoxPreference.setChecked(false);
// }
//
// return true;
// }
// });
}
int READ_REQUEST_CODE=1001;
int READ_REQUEST_SPECIAL_CODE=1002;
int READ_REQUEST_CODE = 1001;
int READ_REQUEST_SPECIAL_CODE = 1002;

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK &&data.getData()!=null) {
if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK && data.getData() != null) {
try {
Uri uri = data.getData();
String json=FileUriUtils.openUriForRead(getActivity(),uri);
if(TextUtils.isEmpty(json)){
Toast.makeText(getActivity(),"空文件~",Toast.LENGTH_SHORT).show();
String json = FileUriUtils.openUriForRead(getActivity(), uri);
if (TextUtils.isEmpty(json)) {
Toast.makeText(getActivity(), getString(R.string.pref_empty_file), Toast.LENGTH_SHORT).show();
return;
}
String name = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString(KeyBoardControllerConfigurationLoader.OSC_PREFERENCE, KeyBoardControllerConfigurationLoader.OSC_PREFERENCE_VALUE);
SharedPreferences.Editor prefEditor = getActivity().getSharedPreferences(name, Activity.MODE_PRIVATE).edit();
JSONObject object=new JSONObject(json);
JSONObject object = new JSONObject(json);
Iterator it = object.keys();
prefEditor.clear();
while(it.hasNext()) {
while (it.hasNext()) {
String key = (String) it.next();// 获得key
String value = object.getString(key);// 获得value
prefEditor.putString(key,value);
prefEditor.putString(key, value);
}
prefEditor.apply();
Toast.makeText(getActivity(),"导入成功!",Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.pref_import_success), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getActivity(),"出错啦~"+e.getMessage(),Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.pref_error_occurred) + e.getMessage(), Toast.LENGTH_SHORT).show();
}
return;
}

if (requestCode == READ_REQUEST_SPECIAL_CODE && resultCode == Activity.RESULT_OK &&data.getData()!=null) {
if (requestCode == READ_REQUEST_SPECIAL_CODE && resultCode == Activity.RESULT_OK && data.getData() != null) {
try {
Uri uri = data.getData();
String json=FileUriUtils.openUriForRead(getActivity(),uri);
if(TextUtils.isEmpty(json)){
Toast.makeText(getActivity(),"空文件~",Toast.LENGTH_SHORT).show();
String json = FileUriUtils.openUriForRead(getActivity(), uri);
if (TextUtils.isEmpty(json)) {
Toast.makeText(getActivity(), getString(R.string.pref_empty_file), Toast.LENGTH_SHORT).show();
return;
}
SharedPreferences.Editor prefEditor = getActivity().getSharedPreferences(GameMenu.PREF_NAME, Activity.MODE_PRIVATE).edit();
prefEditor.putString(GameMenu.KEY_NAME,json);
prefEditor.putString(GameMenu.KEY_NAME, json);
prefEditor.apply();
Toast.makeText(getActivity(),"导入成功!",Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.pref_import_success), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getActivity(),"出错啦~"+e.getMessage(),Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.pref_error_occurred) + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@
<string name="debug_info_please_choose">请选择</string>
<string name="debug_info_no_gamepad_detected">目前没有检测到手柄,请连接手柄,点击刷新按钮,再尝试!</string>
<string name="debug_info_no_vibrator">手柄没有识别到震动马达!</string>
<string name="debug_info_set_amplitude">设置振幅0-255【HD震动生效】</string>
<string name="debug_info_set_amplitude">设置振幅0-255(只对HD震动生效)</string>
<string name="debug_info_name">名称:</string>
<string name="debug_info_sensors">传感器:</string>
<string name="debug_info_no_relevant_driver">无(没有相关驱动或者手柄不支持)</string>
Expand All @@ -448,4 +448,9 @@
<string name="debug_info_refresh_gamepad_info">点击刷新手柄信息</string>
<string name="debug_info_refresh_gamepad_list">刷新手柄列表</string>
<string name="debug_info_test_gamepad_rumble">测试手柄震动</string>
<string name="pref_enter_value_0_9999">请输入0-9999的数值。</string>
<string name="pref_set_success">设置成功!</string>
<string name="pref_empty_file">文件为空!</string>
<string name="pref_import_success">导入成功!</string>
<string name="pref_error_occurred">出错啦~</string>
</resources>
23 changes: 13 additions & 10 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -455,25 +455,28 @@
<string name="debug_info_simple_vibration">Simple Vibration for 1 Second</string>
<string name="debug_info_continuous_hd_vibration">Continuous HD Vibration</string>
<string name="debug_info_please_choose">Please Choose</string>
<string name="debug_info_no_gamepad_detected">No gamepad detected, please connect a gamepad, click the refresh button, and try again!</string>
<string name="debug_info_no_gamepad_detected">No gamepad detected, please connect a gamepad, tap refresh, and try again!</string>
<string name="debug_info_no_vibrator">No vibrator detected on the gamepad!</string>
<string name="debug_info_set_amplitude">Set Amplitude 0-255 [Effective for HD Vibration]</string>
<string name="debug_info_name">Name:</string>
<string name="debug_info_sensors">Sensors:</string>
<string name="debug_info_set_amplitude">Set Amplitude 0-255 (Effective only for HD Vibration)</string>
<string name="debug_info_name">Name: </string>
<string name="debug_info_sensors">Sensors: </string>
<string name="debug_info_no_relevant_driver">None (no relevant driver or gamepad not supported)</string>
<string name="debug_info_no_api_below_android12">No corresponding API below Android 12</string>
<string name="debug_info_vid_pid">VID_PID:</string>
<string name="debug_info_vibration">Vibration:</string>
<string name="debug_info_vid_pid">VID_PID: </string>
<string name="debug_info_vibration">Vibration: </string>
<string name="debug_info_supported">Supported</string>
<string name="debug_info_not_supported">Not Supported</string>
<string name="debug_info_details">Details:</string>
<string name="debug_info_number_of_gamepads">Number of Gamepads:</string>
<string name="debug_info_details">Details: </string>
<string name="debug_info_number_of_gamepads">Number of Gamepads: </string>
<string name="debug_info_accelerometer">+Accelerometer</string>
<string name="debug_info_gyroscope">+Gyroscope</string>
<string name="debug_info_stop_vibration">Stop Vibration</string>
<string name="debug_info_refresh_gamepad_info">Tap to refresh gamepad info</string>
<string name="debug_info_refresh_gamepad_list">Refresh gamepad list</string>
<string name="debug_info_test_gamepad_rumble">Test gamepad rumble</string>

<string name="pref_enter_value_0_9999">Please enter a value between 0 and 9999.</string>
<string name="pref_set_success">Settings saved successfully!</string>
<string name="pref_empty_file">Empty file!</string>
<string name="pref_import_success">Import successful!</string>
<string name="pref_error_occurred">An error occurred: </string>
</resources>

0 comments on commit 06d30d9

Please sign in to comment.