Search in sources :

Example 86 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project vlc-android by GeoffreyMetais.

the class EqualizerFragment method fillViews.

private void fillViews() {
    context = getActivity();
    if (context == null)
        return;
    allSets.clear();
    allSets = new ArrayList<>();
    allSets.addAll(Arrays.asList(getEqualizerPresets()));
    presetCount = allSets.size();
    for (Map.Entry<String, ?> entry : PreferenceManager.getDefaultSharedPreferences(context).getAll().entrySet()) {
        if (entry.getKey().startsWith("custom_equalizer_")) {
            allSets.add(entry.getKey().replace("custom_equalizer_", "").replace("_", " "));
            customCount++;
        }
    }
    allSets.add(newPresetName);
    mEqualizer = VLCOptions.getEqualizerSetFromSettings(context, true);
    // on/off
    binding.equalizerButton.setChecked(VLCOptions.getEqualizerEnabledState(context));
    binding.equalizerButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (mService != null)
                if (isChecked)
                    mService.setEqualizer(mEqualizer);
                else
                    mService.setEqualizer(null);
        }
    });
    binding.equalizerSave.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            createSaveCustomSetDialog(binding.equalizerPresets.getSelectedItemPosition(), true, false);
        }
    });
    binding.equalizerDelete.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            createDeleteCustomSetSnacker();
        }
    });
    binding.equalizerRevert.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            revertCustomSetChanges();
        }
    });
    // presets
    adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, allSets);
    binding.equalizerPresets.setAdapter(adapter);
    // Set the default selection asynchronously to prevent a layout initialization bug.
    binding.equalizerPresets.post(new Runnable() {

        @Override
        public void run() {
            binding.equalizerPresets.setOnItemSelectedListener(mSetListener);
            final int pos = allSets.indexOf(VLCOptions.getEqualizerNameFromSettings(context));
            mState.update(pos, VLCOptions.getEqualizerSavedState(context));
            updateAlreadyHandled = true;
            if (binding.equalizerButton.isChecked() || !mState.saved) {
                savePos = pos;
                revertPos = getEqualizerType(pos) == TYPE_CUSTOM ? pos : 0;
                binding.equalizerPresets.setSelection(pos);
            } else {
                updateEqualizer(0);
            }
        }
    });
    // preamp
    binding.equalizerPreamp.setMax(40);
    binding.equalizerPreamp.setProgress((int) mEqualizer.getPreAmp() + 20);
    binding.equalizerPreamp.setOnSeekBarChangeListener(mPreampListener);
    // bands
    for (int i = 0; i < BAND_COUNT; i++) {
        float band = MediaPlayer.Equalizer.getBandFrequency(i);
        EqualizerBar bar = new EqualizerBar(context, band);
        bar.setValue(mEqualizer.getAmp(i));
        bar.setListener(new BandListener(i));
        binding.equalizerBands.addView(bar);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);
        bar.setLayoutParams(params);
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) LayoutParams(android.view.ViewGroup.LayoutParams) View(android.view.View) AdapterView(android.widget.AdapterView) EqualizerBar(org.videolan.vlc.gui.view.EqualizerBar) Map(java.util.Map) CompoundButton(android.widget.CompoundButton) LinearLayout(android.widget.LinearLayout)

Example 87 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project remote-desktop-clients by iiordanov.

the class bVNC method onCreate.

@Override
public void onCreate(Bundle icicle) {
    layoutID = R.layout.main;
    super.onCreate(icicle);
    ipText = (EditText) findViewById(R.id.textIP);
    sshServer = (EditText) findViewById(R.id.sshServer);
    sshPort = (EditText) findViewById(R.id.sshPort);
    sshUser = (EditText) findViewById(R.id.sshUser);
    sshPassword = (EditText) findViewById(R.id.sshPassword);
    sshPassphrase = (EditText) findViewById(R.id.sshPassphrase);
    sshCredentials = (LinearLayout) findViewById(R.id.sshCredentials);
    sshCaption = (TextView) findViewById(R.id.sshCaption);
    layoutUseSshPubkey = (LinearLayout) findViewById(R.id.layoutUseSshPubkey);
    layoutUseX11Vnc = (LinearLayout) findViewById(R.id.layoutUseX11Vnc);
    sshServerEntry = (LinearLayout) findViewById(R.id.sshServerEntry);
    portText = (EditText) findViewById(R.id.textPORT);
    passwordText = (EditText) findViewById(R.id.textPASSWORD);
    textNickname = (EditText) findViewById(R.id.textNickname);
    textUsername = (EditText) findViewById(R.id.textUsername);
    autoXStatus = (TextView) findViewById(R.id.autoXStatus);
    // Define what happens when the Repeater button is pressed.
    repeaterButton = (Button) findViewById(R.id.buttonRepeater);
    repeaterEntry = (LinearLayout) findViewById(R.id.repeaterEntry);
    repeaterButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showDialog(R.layout.repeater_dialog);
        }
    });
    // Here we say what happens when the Pubkey Checkbox is checked/unchecked.
    checkboxUseSshPubkey = (CheckBox) findViewById(R.id.checkboxUseSshPubkey);
    // Define what happens when somebody clicks on the customize auto X session dialog.
    buttonCustomizeX11Vnc = (Button) findViewById(R.id.buttonCustomizeX11Vnc);
    buttonCustomizeX11Vnc.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            bVNC.this.updateSelectedFromView();
            showDialog(R.layout.auto_x_customize);
        }
    });
    // Define what happens when somebody selects different VNC connection types.
    connectionType = (Spinner) findViewById(R.id.connectionType);
    connectionType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> ad, View view, int itemIndex, long id) {
            selectedConnType = itemIndex;
            if (selectedConnType == Constants.CONN_TYPE_PLAIN || selectedConnType == Constants.CONN_TYPE_ANONTLS || selectedConnType == Constants.CONN_TYPE_STUNNEL) {
                setVisibilityOfSshWidgets(View.GONE);
                setVisibilityOfUltraVncWidgets(View.GONE);
                ipText.setHint(R.string.address_caption_hint);
                textUsername.setHint(R.string.username_hint_optional);
            } else if (selectedConnType == Constants.CONN_TYPE_SSH) {
                setVisibilityOfSshWidgets(View.VISIBLE);
                setVisibilityOfUltraVncWidgets(View.GONE);
                if (ipText.getText().toString().equals(""))
                    ipText.setText("localhost");
                ipText.setHint(R.string.address_caption_hint_tunneled);
                textUsername.setHint(R.string.username_hint_optional);
            } else if (selectedConnType == Constants.CONN_TYPE_ULTRAVNC) {
                setVisibilityOfSshWidgets(View.GONE);
                setVisibilityOfUltraVncWidgets(View.VISIBLE);
                ipText.setHint(R.string.address_caption_hint);
                textUsername.setHint(R.string.username_hint);
            } else if (selectedConnType == Constants.CONN_TYPE_VENCRYPT) {
                setVisibilityOfSshWidgets(View.GONE);
                textUsername.setVisibility(View.VISIBLE);
                repeaterEntry.setVisibility(View.GONE);
                if (passwordText.getText().toString().equals(""))
                    checkboxKeepPassword.setChecked(false);
                ipText.setHint(R.string.address_caption_hint);
                textUsername.setHint(R.string.username_hint_vencrypt);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> ad) {
        }
    });
    // The advanced settings button.
    toggleAdvancedSettings = (ToggleButton) findViewById(R.id.toggleAdvancedSettings);
    layoutAdvancedSettings = (LinearLayout) findViewById(R.id.layoutAdvancedSettings);
    toggleAdvancedSettings.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean checked) {
            if (checked)
                layoutAdvancedSettings.setVisibility(View.VISIBLE);
            else
                layoutAdvancedSettings.setVisibility(View.GONE);
        }
    });
    // Define what happens when the Import/Export button is pressed.
    ((Button) findViewById(R.id.buttonImportExport)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showDialog(R.layout.importexport);
        }
    });
    colorSpinner = (Spinner) findViewById(R.id.colorformat);
    COLORMODEL[] models = COLORMODEL.values();
    ArrayAdapter<COLORMODEL> colorSpinnerAdapter = new ArrayAdapter<COLORMODEL>(this, R.layout.connection_list_entry, models);
    groupForceFullScreen = (RadioGroup) findViewById(R.id.groupForceFullScreen);
    checkboxKeepPassword = (CheckBox) findViewById(R.id.checkboxKeepPassword);
    checkboxUseDpadAsArrows = (CheckBox) findViewById(R.id.checkboxUseDpadAsArrows);
    checkboxRotateDpad = (CheckBox) findViewById(R.id.checkboxRotateDpad);
    checkboxLocalCursor = (CheckBox) findViewById(R.id.checkboxUseLocalCursor);
    checkboxPreferHextile = (CheckBox) findViewById(R.id.checkboxPreferHextile);
    checkboxViewOnly = (CheckBox) findViewById(R.id.checkboxViewOnly);
    colorSpinner.setAdapter(colorSpinnerAdapter);
    colorSpinner.setSelection(0);
    goButton = (Button) findViewById(R.id.buttonGO);
    goButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (ipText.getText().length() != 0 && portText.getText().length() != 0)
                canvasStart();
            else
                Toast.makeText(view.getContext(), R.string.vnc_server_empty, Toast.LENGTH_LONG).show();
        }
    });
    spinnerVncGeometry = (Spinner) findViewById(R.id.spinnerVncGeometry);
    resWidth = (EditText) findViewById(R.id.rdpWidth);
    resHeight = (EditText) findViewById(R.id.rdpHeight);
    spinnerVncGeometry.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View view, int itemIndex, long id) {
            if (selected != null) {
                selected.setRdpResType(itemIndex);
                setRemoteWidthAndHeight();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
    repeaterText = (TextView) findViewById(R.id.textRepeaterId);
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) CompoundButton(android.widget.CompoundButton) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) ArrayAdapter(android.widget.ArrayAdapter)

Example 88 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project remote-desktop-clients by iiordanov.

the class aSPICE method onCreate.

@Override
public void onCreate(Bundle icicle) {
    layoutID = R.layout.main_spice;
    super.onCreate(icicle);
    ipText = (EditText) findViewById(R.id.textIP);
    sshServer = (EditText) findViewById(R.id.sshServer);
    sshPort = (EditText) findViewById(R.id.sshPort);
    sshUser = (EditText) findViewById(R.id.sshUser);
    sshPassword = (EditText) findViewById(R.id.sshPassword);
    sshPassphrase = (EditText) findViewById(R.id.sshPassphrase);
    sshCredentials = (LinearLayout) findViewById(R.id.sshCredentials);
    sshCaption = (TextView) findViewById(R.id.sshCaption);
    layoutUseSshPubkey = (LinearLayout) findViewById(R.id.layoutUseSshPubkey);
    sshServerEntry = (LinearLayout) findViewById(R.id.sshServerEntry);
    portText = (EditText) findViewById(R.id.textPORT);
    tlsPort = (EditText) findViewById(R.id.tlsPort);
    passwordText = (EditText) findViewById(R.id.textPASSWORD);
    textNickname = (EditText) findViewById(R.id.textNickname);
    buttonImportCa = (Button) findViewById(R.id.buttonImportCa);
    buttonImportCa.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            aSPICE.this.updateSelectedFromView();
            showDialog(R.layout.import_tls_ca_dialog);
        }
    });
    // Here we say what happens when the Pubkey Checkbox is
    // checked/unchecked.
    checkboxUseSshPubkey = (CheckBox) findViewById(R.id.checkboxUseSshPubkey);
    // Define what happens when somebody selects different VNC connection
    // types.
    connectionType = (Spinner) findViewById(R.id.connectionType);
    connectionType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> ad, View view, int itemIndex, long id) {
            selectedConnType = itemIndex;
            if (selectedConnType == Constants.CONN_TYPE_PLAIN) {
                setVisibilityOfSshWidgets(View.GONE);
            } else if (selectedConnType == Constants.CONN_TYPE_SSH) {
                setVisibilityOfSshWidgets(View.VISIBLE);
                if (ipText.getText().toString().equals(""))
                    ipText.setText("localhost");
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> ad) {
        }
    });
    checkboxKeepPassword = (CheckBox) findViewById(R.id.checkboxKeepPassword);
    checkboxUseDpadAsArrows = (CheckBox) findViewById(R.id.checkboxUseDpadAsArrows);
    checkboxRotateDpad = (CheckBox) findViewById(R.id.checkboxRotateDpad);
    checkboxLocalCursor = (CheckBox) findViewById(R.id.checkboxUseLocalCursor);
    checkboxEnableSound = (CheckBox) findViewById(R.id.checkboxEnableSound);
    goButton = (Button) findViewById(R.id.buttonGO);
    goButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (ipText.getText().length() != 0 && (portText.getText().length() != 0 || tlsPort.getText().length() != 0))
                canvasStart();
            else
                Toast.makeText(view.getContext(), R.string.spice_server_empty, Toast.LENGTH_LONG).show();
        }
    });
    // The advanced settings button.
    toggleAdvancedSettings = (ToggleButton) findViewById(R.id.toggleAdvancedSettings);
    layoutAdvancedSettings = (LinearLayout) findViewById(R.id.layoutAdvancedSettings);
    toggleAdvancedSettings.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean checked) {
            if (checked)
                layoutAdvancedSettings.setVisibility(View.VISIBLE);
            else
                layoutAdvancedSettings.setVisibility(View.GONE);
        }
    });
    // The geometry type and dimensions boxes.
    spinnerGeometry = (Spinner) findViewById(R.id.spinnerRdpGeometry);
    resWidth = (EditText) findViewById(R.id.rdpWidth);
    resHeight = (EditText) findViewById(R.id.rdpHeight);
    spinnerGeometry.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View view, int itemIndex, long id) {
            selected.setRdpResType(itemIndex);
            setRemoteWidthAndHeight();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
    // Define what happens when the Import/Export button is pressed.
    ((Button) findViewById(R.id.buttonImportExport)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            android.util.Log.e(TAG, "import/export!!");
            showDialog(R.layout.importexport);
        }
    });
    // Load list of items from asset folder and populate
    try {
        spinnerArray = listFiles("layouts");
    } catch (IOException e) {
        e.printStackTrace();
    }
    layoutMapSpinner = (Spinner) findViewById(R.id.layoutMaps);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    layoutMapSpinner.setAdapter(adapter);
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) IOException(java.io.IOException) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) CompoundButton(android.widget.CompoundButton) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) ArrayAdapter(android.widget.ArrayAdapter)

Example 89 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project wigle-wifi-wardriving by wiglenet.

the class SpeechActivity method doCheckbox.

private void doCheckbox(final SharedPreferences prefs, final int id, final String pref, final boolean defaultVal) {
    final CheckBox box = (CheckBox) findViewById(id);
    box.setChecked(prefs.getBoolean(pref, defaultVal));
    box.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            final Editor editor = prefs.edit();
            editor.putBoolean(pref, isChecked);
            editor.apply();
        }
    });
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) CheckBox(android.widget.CheckBox) Editor(android.content.SharedPreferences.Editor) CompoundButton(android.widget.CompoundButton)

Example 90 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project wigle-wifi-wardriving by wiglenet.

the class MainActivity method prefBackedCheckBox.

public static CheckBox prefBackedCheckBox(final Activity activity, final View view, final int id, final String pref, final boolean def) {
    final SharedPreferences prefs = activity.getSharedPreferences(ListFragment.SHARED_PREFS, 0);
    final Editor editor = prefs.edit();
    final CheckBox checkbox = prefSetCheckBox(prefs, view, id, pref, def);
    checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            editor.putBoolean(pref, isChecked);
            editor.apply();
        }
    });
    return checkbox;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SharedPreferences(android.content.SharedPreferences) CheckBox(android.widget.CheckBox) Editor(android.content.SharedPreferences.Editor) CompoundButton(android.widget.CompoundButton)

Aggregations

OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)101 CompoundButton (android.widget.CompoundButton)98 View (android.view.View)78 TextView (android.widget.TextView)66 ImageView (android.widget.ImageView)40 OnClickListener (android.view.View.OnClickListener)31 CheckBox (android.widget.CheckBox)30 DialogInterface (android.content.DialogInterface)27 AdapterView (android.widget.AdapterView)24 AlertDialog (android.app.AlertDialog)23 ListView (android.widget.ListView)20 Button (android.widget.Button)19 LayoutInflater (android.view.LayoutInflater)17 ArrayList (java.util.ArrayList)17 List (java.util.List)15 OnClickListener (android.content.DialogInterface.OnClickListener)12 SuppressLint (android.annotation.SuppressLint)11 Intent (android.content.Intent)11 ViewGroup (android.view.ViewGroup)10 Cursor (android.database.Cursor)9