Java Code Examples for androidx.preference.EditTextPreference#setText()

The following examples show how to use androidx.preference.EditTextPreference#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RtspPreferenceActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    setPreferencesFromResource(R.xml.preferences, rootKey);

    EditTextPreference url = findPreference(getString(R.string.key_server_url));
    if (url != null) {
        url.setText(getServerUrl());
    }

    ListPreference videoResolution = findPreference(getString(R.string.key_video_resolution));
    if (videoResolution != null) {
        String[] entries = createCameraResolutions(getContext());
        videoResolution.setEntries(entries);
        videoResolution.setEntryValues(entries);
    }

    setInputTypeNumber(R.string.key_server_port);
    setInputTypeNumber(R.string.key_video_bit_rate);
    setInputTypeNumber(R.string.key_video_frame_rate);
    setInputTypeNumber(R.string.key_video_iframe_interval);
    setInputTypeNumber(R.string.key_audio_bit_rate);
}
 
Example 2
Source File: SettingsPreferenceActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
private void createEncoderBitRatePreference() {
    EditTextPreference pref = findPreference("encoder_bit_rate");
    if (pref != null) {
        pref.setSummaryProvider((Preference preference) ->
                pref.getText() + " Mbps"
        );
        // 0以上の実数値以外の入力を禁止する
        pref.setOnBindEditTextListener((@NonNull EditText editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER
                        | InputType.TYPE_NUMBER_FLAG_DECIMAL));
        String value = pref.getText();
        if (value == null) {
            pref.setText(Settings.DEFAULT_ENCODER_BITRATE_BASE);
        }
    }
}
 
Example 3
Source File: SettingsPreferenceActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void createEncoderFrameRatePreference() {
    EditTextPreference pref = findPreference("encoder_frame_rate");
    if (pref != null) {
        pref.setSummaryProvider((Preference preference) ->
                pref.getText() + " fps"
        );
        // 0以上の整数値以外の入力を禁止する
        pref.setOnBindEditTextListener((@NonNull EditText editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER));
        String value = pref.getText();
        if (value == null) {
            pref.setText(Integer.toString(Settings.DEFAULT_ENCODER_FPS));
        }
    }
}
 
Example 4
Source File: DnsServerConfigFragment.java    From Daedalus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    EditTextPreference serverName = findPreference("serverName");
    serverName.setOnPreferenceChangeListener((preference, newValue) -> {
        preference.setSummary((String) newValue);
        return true;
    });

    EditTextPreference serverAddress = findPreference("serverAddress");
    serverAddress.setOnPreferenceChangeListener((preference, newValue) -> {
        preference.setSummary((String) newValue);
        return true;
    });

    EditTextPreference serverPort = findPreference("serverPort");
    serverPort.setOnPreferenceChangeListener((preference, newValue) -> {
        preference.setSummary((String) newValue);
        return true;
    });


    index = intent.getIntExtra(ConfigActivity.LAUNCH_ACTION_ID, ConfigActivity.ID_NONE);
    if (index != ConfigActivity.ID_NONE) {
        CustomDnsServer server = Daedalus.configurations.getCustomDNSServers().get(index);
        serverName.setText(server.getName());
        serverName.setSummary(server.getName());
        serverAddress.setText(server.getAddress());
        serverAddress.setSummary(server.getAddress());
        serverPort.setText(String.valueOf(server.getPort()));
        serverPort.setSummary(String.valueOf(server.getPort()));
    } else {
        serverName.setText("");
        serverAddress.setText("");
        String port = String.valueOf(DnsServer.DNS_SERVER_DEFAULT_PORT);
        serverPort.setText(port);
        serverPort.setSummary(port);
    }
    return view;
}
 
Example 5
Source File: SettingsPreferenceActivity.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
private void createSrtServerPreference() {
    EditTextPreference pref = findPreference("server_url");
    if (pref != null) {
        pref.setText("srt://" + getIpAddress() + ":12345");
    }
}