Search in sources :

Example 6 with ToggleButton

use of android.widget.ToggleButton in project WordPress-Android by wordpress-mobile.

the class EditorFragment method updateFormatBarEnabledState.

void updateFormatBarEnabledState(boolean enabled) {
    float alpha = (enabled ? TOOLBAR_ALPHA_ENABLED : TOOLBAR_ALPHA_DISABLED);
    for (ToggleButton button : mTagToggleButtonMap.values()) {
        button.setEnabled(enabled);
        button.setAlpha(alpha);
    }
    mIsFormatBarDisabled = !enabled;
}
Also used : ToggleButton(android.widget.ToggleButton)

Example 7 with ToggleButton

use of android.widget.ToggleButton in project WordPress-Android by wordpress-mobile.

the class EditorFragment method setupFormatBarButtonMap.

private void setupFormatBarButtonMap(View view) {
    ToggleButton boldButton = (ToggleButton) view.findViewById(R.id.format_bar_button_bold);
    mTagToggleButtonMap.put(getString(R.string.format_bar_tag_bold), boldButton);
    ToggleButton italicButton = (ToggleButton) view.findViewById(R.id.format_bar_button_italic);
    mTagToggleButtonMap.put(getString(R.string.format_bar_tag_italic), italicButton);
    ToggleButton quoteButton = (ToggleButton) view.findViewById(R.id.format_bar_button_quote);
    mTagToggleButtonMap.put(getString(R.string.format_bar_tag_blockquote), quoteButton);
    ToggleButton ulButton = (ToggleButton) view.findViewById(R.id.format_bar_button_ul);
    mTagToggleButtonMap.put(getString(R.string.format_bar_tag_unorderedList), ulButton);
    ToggleButton olButton = (ToggleButton) view.findViewById(R.id.format_bar_button_ol);
    mTagToggleButtonMap.put(getString(R.string.format_bar_tag_orderedList), olButton);
    // Tablet-only
    ToggleButton strikethroughButton = (ToggleButton) view.findViewById(R.id.format_bar_button_strikethrough);
    if (strikethroughButton != null) {
        mTagToggleButtonMap.put(getString(R.string.format_bar_tag_strikethrough), strikethroughButton);
    }
    ToggleButton mediaButton = (ToggleButton) view.findViewById(R.id.format_bar_button_media);
    mTagToggleButtonMap.put(TAG_FORMAT_BAR_BUTTON_MEDIA, mediaButton);
    registerForContextMenu(mediaButton);
    ToggleButton linkButton = (ToggleButton) view.findViewById(R.id.format_bar_button_link);
    mTagToggleButtonMap.put(TAG_FORMAT_BAR_BUTTON_LINK, linkButton);
    ToggleButton htmlButton = (ToggleButton) view.findViewById(R.id.format_bar_button_html);
    htmlButton.setOnClickListener(this);
    for (ToggleButton button : mTagToggleButtonMap.values()) {
        button.setOnClickListener(this);
    }
}
Also used : ToggleButton(android.widget.ToggleButton)

Example 8 with ToggleButton

use of android.widget.ToggleButton in project WordPress-Android by wordpress-mobile.

the class EditorFragmentTest method testHtmlModeToggleTextTransfer.

public void testHtmlModeToggleTextTransfer() throws InterruptedException, IllegalEditorStateException {
    waitForOnDomLoaded();
    final View view = mFragment.getView();
    if (view == null) {
        throw (new IllegalStateException("Fragment view is empty"));
    }
    final ToggleButton htmlButton = (ToggleButton) view.findViewById(R.id.format_bar_button_html);
    String content = mFragment.getContent().toString();
    final SourceViewEditText titleText = (SourceViewEditText) view.findViewById(R.id.sourceview_title);
    final SourceViewEditText contentText = (SourceViewEditText) view.findViewById(R.id.sourceview_content);
    // -- Check that title and content text is properly loaded into the EditTexts when switching to HTML mode
    final CountDownLatch uiThreadLatch1 = new CountDownLatch(1);
    mActivity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            // Turn on HTML mode
            htmlButton.performClick();
            uiThreadLatch1.countDown();
        }
    });
    uiThreadLatch1.await();
    waitFor(500);
    // The HTML mode fields should be populated with the raw HTML loaded into the WebView on load
    // (see MockEditorActivity)
    assertEquals("A title", titleText.getText().toString());
    assertEquals(content, contentText.getText().toString());
    // -- Check that the title and content text is updated in the WebView when switching back from HTML mode
    final CountDownLatch uiThreadLatch2 = new CountDownLatch(1);
    mActivity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            titleText.setText("new title");
            contentText.setText("new <b>content</b>");
            // Check that getTitle() and getContent() return latest version even in HTML mode
            try {
                assertEquals("new title", mFragment.getTitle());
                assertEquals("new <b>content</b>", mFragment.getContent());
            } catch (IllegalEditorStateException e) {
                throw new RuntimeException();
            }
            // Turn off HTML mode
            htmlButton.performClick();
            uiThreadLatch2.countDown();
        }
    });
    uiThreadLatch2.await();
    // Wait for JS to update the title/content
    waitFor(300);
    assertEquals("new title", mFragment.getTitle());
    assertEquals("new <b>content</b>", mFragment.getContent());
}
Also used : ToggleButton(android.widget.ToggleButton) IllegalEditorStateException(org.wordpress.android.editor.EditorFragment.IllegalEditorStateException) CountDownLatch(java.util.concurrent.CountDownLatch) View(android.view.View)

Example 9 with ToggleButton

use of android.widget.ToggleButton in project cropper by edmodo.

the class MainActivity method onCreate.

// Activity Methods ////////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
    // Initialize Views.
    final ToggleButton fixedAspectRatioToggleButton = (ToggleButton) findViewById(R.id.fixedAspectRatioToggle);
    final TextView aspectRatioXTextView = (TextView) findViewById(R.id.aspectRatioX);
    final SeekBar aspectRatioXSeekBar = (SeekBar) findViewById(R.id.aspectRatioXSeek);
    final TextView aspectRatioYTextView = (TextView) findViewById(R.id.aspectRatioY);
    final SeekBar aspectRatioYSeekBar = (SeekBar) findViewById(R.id.aspectRatioYSeek);
    final Spinner guidelinesSpinner = (Spinner) findViewById(R.id.showGuidelinesSpin);
    final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
    final ImageView croppedImageView = (ImageView) findViewById(R.id.croppedImageView);
    final Button cropButton = (Button) findViewById(R.id.Button_crop);
    // Initializes fixedAspectRatio toggle button.
    fixedAspectRatioToggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            cropImageView.setFixedAspectRatio(isChecked);
            cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
            aspectRatioXSeekBar.setEnabled(isChecked);
            aspectRatioYSeekBar.setEnabled(isChecked);
        }
    });
    // Set seek bars to be disabled until toggle button is checked.
    aspectRatioXSeekBar.setEnabled(false);
    aspectRatioYSeekBar.setEnabled(false);
    aspectRatioXTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));
    aspectRatioYTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));
    // Initialize aspect ratio X SeekBar.
    aspectRatioXSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar aspectRatioXSeekBar, int progress, boolean fromUser) {
            if (progress < 1) {
                aspectRatioXSeekBar.setProgress(1);
            }
            cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
            aspectRatioXTextView.setText(String.valueOf(aspectRatioXSeekBar.getProgress()));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        // Do nothing.
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        // Do nothing.
        }
    });
    // Initialize aspect ratio Y SeekBar.
    aspectRatioYSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar aspectRatioYSeekBar, int progress, boolean fromUser) {
            if (progress < 1) {
                aspectRatioYSeekBar.setProgress(1);
            }
            cropImageView.setAspectRatio(aspectRatioXSeekBar.getProgress(), aspectRatioYSeekBar.getProgress());
            aspectRatioYTextView.setText(String.valueOf(aspectRatioYSeekBar.getProgress()));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        // Do nothing.
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        // Do nothing.
        }
    });
    // Set up the Guidelines Spinner.
    guidelinesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            cropImageView.setGuidelines(i);
        }

        public void onNothingSelected(AdapterView<?> adapterView) {
        // Do nothing.
        }
    });
    guidelinesSpinner.setSelection(GUIDELINES_ON_TOUCH);
    // Initialize the Crop button.
    cropButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final Bitmap croppedImage = cropImageView.getCroppedImage();
            croppedImageView.setImageBitmap(croppedImage);
        }
    });
}
Also used : ToggleButton(android.widget.ToggleButton) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SeekBar(android.widget.SeekBar) Spinner(android.widget.Spinner) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) CropImageView(com.edmodo.cropper.CropImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) Bitmap(android.graphics.Bitmap) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) CropImageView(com.edmodo.cropper.CropImageView) ImageView(android.widget.ImageView) CropImageView(com.edmodo.cropper.CropImageView) CompoundButton(android.widget.CompoundButton)

Example 10 with ToggleButton

use of android.widget.ToggleButton in project android_frameworks_base by ResurrectionRemix.

the class EnvReverbTest method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Log.d(TAG, "onCreate");
    SeekBar seekBar;
    TextView textView;
    ToggleButton button;
    setContentView(R.layout.envreverbtest);
    ImageView playPause = (ImageView) findViewById(R.id.playPause1);
    ImageView stop = (ImageView) findViewById(R.id.stop1);
    textView = (TextView) findViewById(R.id.sessionText);
    if (sPlayerController == null) {
        sPlayerController = new SimplePlayer(this, R.id.playPause1, playPause, R.id.stop1, stop, textView, R.raw.mp3_sample, AudioManager.STREAM_MUSIC, 0);
    } else {
        sPlayerController.set(this, R.id.playPause1, playPause, R.id.stop1, stop, textView, AudioManager.STREAM_MUSIC, 0);
    }
    // send level
    mSendLevelSeekBar = (SeekBar) findViewById(R.id.sendLevelSeekBar);
    mSendLevelDisplay = (TextView) findViewById(R.id.sendLevelValue);
    mSendLevelSeekBar.setMax(100);
    mSendLevelSeekBar.setOnSeekBarChangeListener(this);
    mSendLevelSeekBar.setProgress(expToLin(sSendLevel, 100));
    sPlayerController.setAuxEffectSendLevel(sSendLevel);
    mOnOffButton = (ToggleButton) findViewById(R.id.rvbOnOff);
    mReleaseButton = (ToggleButton) findViewById(R.id.rvbReleaseButton);
    mAttachButton = (ToggleButton) findViewById(R.id.attachButton);
    getEffect(0);
    if (mReverb != null) {
        mOnOffButton.setOnCheckedChangeListener(this);
        mReleaseButton.setOnCheckedChangeListener(this);
        mAttachButton.setOnCheckedChangeListener(this);
        //            button = (ToggleButton)findViewById(R.id.rvbBypass);
        //            button.setChecked(false);
        //            button.setOnCheckedChangeListener(this);
        // Room level
        seekBar = (SeekBar) findViewById(R.id.rvbParam1SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam1Value);
        mParameters[0] = new RoomLevelParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[0]);
        // Room HF level
        seekBar = (SeekBar) findViewById(R.id.rvbParam2SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam2Value);
        mParameters[1] = new RoomHFLevelParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[1]);
        // Decay time
        seekBar = (SeekBar) findViewById(R.id.rvbParam3SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam3Value);
        mParameters[2] = new DecayTimeParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[2]);
        // Decay HF ratio
        seekBar = (SeekBar) findViewById(R.id.rvbParam4SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam4Value);
        mParameters[3] = new DecayHFRatioParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[3]);
        // Reflections level
        seekBar = (SeekBar) findViewById(R.id.rvbParam5SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam5Value);
        mParameters[4] = new ReflectionsLevelParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[4]);
        // Reflections delay
        seekBar = (SeekBar) findViewById(R.id.rvbParam6SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam6Value);
        mParameters[5] = new ReflectionsDelayParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[5]);
        // Reverb level
        seekBar = (SeekBar) findViewById(R.id.rvbParam7SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam7Value);
        mParameters[6] = new ReverbLevelParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[6]);
        // Reverb delay
        seekBar = (SeekBar) findViewById(R.id.rvbParam8SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam8Value);
        mParameters[7] = new ReverbDelayParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[7]);
        // Diffusion
        seekBar = (SeekBar) findViewById(R.id.rvbParam9SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam9Value);
        mParameters[8] = new DiffusionParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[8]);
        // Density
        seekBar = (SeekBar) findViewById(R.id.rvbParam10SeekBar);
        textView = (TextView) findViewById(R.id.rvbParam10Value);
        mParameters[9] = new DensityParam(mReverb, seekBar, textView);
        seekBar.setOnSeekBarChangeListener(mParameters[9]);
    }
}
Also used : ToggleButton(android.widget.ToggleButton) SeekBar(android.widget.SeekBar) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Aggregations

ToggleButton (android.widget.ToggleButton)35 View (android.view.View)16 TextView (android.widget.TextView)16 ImageView (android.widget.ImageView)12 SeekBar (android.widget.SeekBar)10 Button (android.widget.Button)8 CompoundButton (android.widget.CompoundButton)7 ViewGroup (android.view.ViewGroup)4 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)4 OnClickListener (android.view.View.OnClickListener)3 AdapterView (android.widget.AdapterView)3 LinearLayout (android.widget.LinearLayout)3 SuppressLint (android.annotation.SuppressLint)2 RecyclerView (android.support.v7.widget.RecyclerView)2 KeyEvent (android.view.KeyEvent)2 EditText (android.widget.EditText)2 RadioButton (android.widget.RadioButton)2 RelativeLayout (android.widget.RelativeLayout)2 OnSeekBarChangeListener (android.widget.SeekBar.OnSeekBarChangeListener)2 Spinner (android.widget.Spinner)2