Example usage for android.graphics.drawable ShapeDrawable getPaint

List of usage examples for android.graphics.drawable ShapeDrawable getPaint

Introduction

In this page you can find the example usage for android.graphics.drawable ShapeDrawable getPaint.

Prototype

public Paint getPaint() 

Source Link

Document

Returns the Paint used to draw the shape.

Usage

From source file:io.puzzlebox.bloom.ui.BloomFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    View v = inflater.inflate(R.layout.fragment_bloom, container, false);

    //      requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    //      setContentView(R.layout.main);
    //      getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);

    progressBarAttention = (ProgressBar) v.findViewById(R.id.progressBarAttention);
    final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
    ShapeDrawable progressBarAttentionDrawable = new ShapeDrawable(
            new RoundRectShape(roundedCorners, null, null));
    String progressBarAttentionColor = "#FF0000";
    progressBarAttentionDrawable.getPaint().setColor(Color.parseColor(progressBarAttentionColor));
    ClipDrawable progressAttention = new ClipDrawable(progressBarAttentionDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);/*from  ww  w  . jav  a 2s. c o m*/
    progressBarAttention.setProgressDrawable(progressAttention);
    progressBarAttention
            .setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));

    progressBarMeditation = (ProgressBar) v.findViewById(R.id.progressBarMeditation);
    ShapeDrawable progressBarMeditationDrawable = new ShapeDrawable(
            new RoundRectShape(roundedCorners, null, null));
    String progressBarMeditationColor = "#0000FF";
    progressBarMeditationDrawable.getPaint().setColor(Color.parseColor(progressBarMeditationColor));
    ClipDrawable progressMeditation = new ClipDrawable(progressBarMeditationDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);
    progressBarMeditation.setProgressDrawable(progressMeditation);
    progressBarMeditation
            .setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));

    progressBarSignal = (ProgressBar) v.findViewById(R.id.progressBarSignal);
    ShapeDrawable progressBarSignalDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));
    String progressBarSignalColor = "#00FF00";
    progressBarSignalDrawable.getPaint().setColor(Color.parseColor(progressBarSignalColor));
    ClipDrawable progressSignal = new ClipDrawable(progressBarSignalDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);
    progressBarSignal.setProgressDrawable(progressSignal);
    progressBarSignal.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));
    //      progressBarSignal.setProgress(tgSignal);

    progressBarPower = (ProgressBar) v.findViewById(R.id.progressBarPower);
    ShapeDrawable progressBarPowerDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));
    String progressBarPowerColor = "#FFFF00";
    progressBarPowerDrawable.getPaint().setColor(Color.parseColor(progressBarPowerColor));
    ClipDrawable progressPower = new ClipDrawable(progressBarPowerDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);
    progressBarPower.setProgressDrawable(progressPower);
    progressBarPower.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));

    //      progressBarRange = (ProgressBar) v.findViewById(R.id.progressBarRange);
    ////      ShapeDrawable progressBarRangeDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null,null));
    //      ShapeDrawable progressBarRangeDrawable = new ShapeDrawable();
    ////      String progressBarRangeColor = "#FF00FF";
    //      String progressBarRangeColor = "#990099";
    //      progressBarRangeDrawable.getPaint().setColor(Color.parseColor(progressBarRangeColor));
    //      ClipDrawable progressRange = new ClipDrawable(progressBarRangeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    //      progressBarRange.setProgressDrawable(progressRange);
    //      progressBarRange.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));
    //
    ////      progressBarRange.setMax(128 + 127);
    //      progressBarRange.setMax(bloomRangeMax);

    //      progressBarBloom = (ProgressBar) v.findViewById(R.id.progressBarBloom);
    //      ShapeDrawable progressBarBloomDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null,null));
    //      String progressBarBloomColor = "#7F0000";
    //      progressBarBloomDrawable.getPaint().setColor(Color.parseColor(progressBarBloomColor));
    //      ClipDrawable progressBloom = new ClipDrawable(progressBarBloomDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    //      progressBarBloom.setProgressDrawable(progressBloom);
    //      progressBarBloom.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));

    seekBarAttention = (SeekBar) v.findViewById(R.id.seekBarAttention);
    seekBarAttention.setOnSeekBarChangeListener(this);
    seekBarMeditation = (SeekBar) v.findViewById(R.id.seekBarMeditation);
    seekBarMeditation.setOnSeekBarChangeListener(this);

    //      imageViewStatus = (ImageView) v.findViewById(R.id.imageViewStatus);

    servoSeekBar = (SeekBar) v.findViewById(R.id.ServoSeekBar);
    servoSeekBar.setEnabled(false);
    //      servoSeekBar.setMax(180);
    servoSeekBar.setMax(100);
    servoSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            byte[] buf = new byte[] { (byte) 0x03, (byte) 0x00, (byte) 0x00 };

            buf[1] = (byte) servoSeekBar.getProgress();

            BloomSingleton.getInstance().characteristicTx.setValue(buf);
            BloomSingleton.getInstance().mBluetoothLeService
                    .writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
        }
    });

    //      rssiValue = (TextView) v.findViewById(R.id.rssiValue);

    connectBloom = (Button) v.findViewById(R.id.connectBloom);

    connectBloom.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                if (!BloomSingleton.getInstance().scanFlag) {
                    scanLeDevice();

                    Timer mTimer = new Timer();
                    mTimer.schedule(new TimerTask() {

                        @Override
                        public void run() {
                            if ((BloomSingleton.getInstance().mDevice != null)
                                    && (BloomSingleton.getInstance().mDevice.getAddress() != null)
                                    && (BloomSingleton.getInstance().mBluetoothLeService != null)) {
                                BloomSingleton
                                        .getInstance().mDeviceAddress = BloomSingleton.getInstance().mDevice
                                                .getAddress();
                                if (BloomSingleton.getInstance().mDeviceAddress != null)
                                    BloomSingleton.getInstance().mBluetoothLeService
                                            .connect(BloomSingleton.getInstance().mDeviceAddress);
                                else {
                                    Toast toast = Toast.makeText(getActivity(),
                                            "Error connecting to Puzzlebox Bloom", Toast.LENGTH_SHORT);
                                    toast.setGravity(0, 0, Gravity.CENTER | Gravity.BOTTOM);
                                    toast.show();
                                }
                                BloomSingleton.getInstance().scanFlag = true;
                            } else {
                                getActivity().runOnUiThread(new Runnable() {
                                    public void run() {
                                        Toast toast = Toast.makeText(getActivity(),
                                                "Error connecting to Puzzlebox Bloom", Toast.LENGTH_SHORT);
                                        toast.setGravity(0, 0, Gravity.CENTER | Gravity.BOTTOM);
                                        toast.show();
                                    }
                                });
                            }
                        }
                    }, BloomSingleton.getInstance().SCAN_PERIOD);
                }
            } catch (Exception e) {
                Log.e(TAG, "Exception connecting to Bloom: " + e);
                Toast toast = Toast.makeText(getActivity(), "Exception connecting to Puzzlebox Bloom",
                        Toast.LENGTH_SHORT);
                toast.setGravity(0, 0, Gravity.CENTER | Gravity.BOTTOM);
                toast.show();
            }

            System.out.println(BloomSingleton.getInstance().connState);
            //            Log.e(TAG, connState);
            //            if (connState == false) {
            if (!BloomSingleton.getInstance().connState
                    && BloomSingleton.getInstance().mDeviceAddress != null) {
                BloomSingleton.getInstance().mBluetoothLeService
                        .connect(BloomSingleton.getInstance().mDeviceAddress);
            } else {
                if (BloomSingleton.getInstance().mBluetoothLeService != null) {
                    setBloomRGBOff();
                    BloomSingleton.getInstance().mBluetoothLeService.disconnect();
                    BloomSingleton.getInstance().mBluetoothLeService.close();
                    setButtonDisable();
                }
            }
        }
    });

    //      Button buttonOpen = (Button) v.findViewById(R.id.buttonOpen);
    //      buttonOpen.setOnClickListener(new View.OnClickListener() {
    //         @Override
    //         public void onClick(View v) {
    //            byte[] buf = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    //            BloomSingleton.getInstance().characteristicTx.setValue(buf);
    //            BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    //         }
    //      });
    //      buttonOpen.setVisibility(View.GONE);
    //
    //      Button buttonClose = (Button) v.findViewById(R.id.buttonClose);
    //      buttonClose.setOnClickListener(new View.OnClickListener() {
    //         @Override
    //         public void onClick(View v) {
    //            byte[] buf = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00 };
    //            BloomSingleton.getInstance().characteristicTx.setValue(buf);
    //            BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    //         }
    //      });
    //      buttonClose.setVisibility(View.GONE);

    //      buttonDemo = (Button) v.findViewById(R.id.buttonDemo);
    //      buttonDemo.setOnClickListener(new View.OnClickListener() {
    //         @Override
    //         public void onClick(View v) {
    //            byte[] buf;
    ////            if (! BloomSingleton.getInstance().demoActive) {
    //            BloomSingleton.getInstance().demoActive = true;
    //
    //            // bloomOpen()
    ////            buf = new byte[]{(byte) 0x01, (byte) 0x00, (byte) 0x00};
    ////            BloomSingleton.getInstance().characteristicTx.setValue(buf);
    ////            BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    //
    //            // loopRGB()
    //            buf = new byte[]{(byte) 0x06, (byte) 0x00, (byte) 0x00};
    //            BloomSingleton.getInstance().characteristicTx.setValue(buf);
    //            BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    //
    //            // Set Red to 0
    //            buf = new byte[]{(byte) 0x0A, (byte) 0x00, (byte) 0x00}; // R = 0
    //            BloomSingleton.getInstance().characteristicTx.setValue(buf);
    //            BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    //
    //            // bloomClose()
    ////            buf = new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00};
    ////            BloomSingleton.getInstance().characteristicTx.setValue(buf);
    ////            BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    //
    //
    ////            } else {
    ////               BloomSingleton.getInstance().demoActive = false;
    //////               buf = new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00};
    //////               BloomSingleton.getInstance().characteristicTx.setValue(buf);
    //////               BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    ////               buf = new byte[]{(byte) 0x0A, (byte) 0x00, (byte) 0x00}; // R = 0
    ////               BloomSingleton.getInstance().characteristicTx.setValue(buf);
    ////               BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    //////               buf = new byte[]{(byte) 0x0A, (byte) 0x01, (byte) 0x00}; // G = 0
    //////               BloomSingleton.getInstance().characteristicTx.setValue(buf);
    //////               BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    //////               buf = new byte[]{(byte) 0x0A, (byte) 0x02, (byte) 0x00}; // B = 0
    //////               BloomSingleton.getInstance().characteristicTx.setValue(buf);
    //////               BloomSingleton.getInstance().mBluetoothLeService.writeCharacteristic(BloomSingleton.getInstance().characteristicTx);
    ////            }
    //         }
    //      });

    if (!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
        Toast.makeText(getActivity(), "Bluetooth LE not supported", Toast.LENGTH_SHORT).show();
        getActivity().finish();
    }

    final BluetoothManager mBluetoothManager = (BluetoothManager) getActivity()
            .getSystemService(Context.BLUETOOTH_SERVICE);
    BloomSingleton.getInstance().mBluetoothAdapter = mBluetoothManager.getAdapter();
    if (BloomSingleton.getInstance().mBluetoothAdapter == null) {
        Toast.makeText(getActivity(), "Bluetooth LE not supported", Toast.LENGTH_SHORT).show();
        getActivity().finish();
        return v;
    }

    Intent gattServiceIntent = new Intent(getActivity(), RBLService.class);
    //      bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
    getActivity().bindService(gattServiceIntent, mServiceConnection, getActivity().BIND_AUTO_CREATE);

    /**
     * Update settings according to default UI
     */

    updateScreenLayout();

    //      updatePowerThresholds();
    //      updatePower();

    if (BloomSingleton.getInstance().connState)
        setButtonEnable();

    return v;

}

From source file:com.skytree.epubtest.BookViewActivity.java

public void makeControls() {
    this.removeControls();
    Theme theme = getCurrentTheme();//from w w  w  .j  a v a  2s.c o  m

    int bs = 38;
    if (this.isRotationLocked)
        rotationButton = this.makeImageButton(9000, R.drawable.rotationlocked2x, ps(42), ps(42));
    else
        rotationButton = this.makeImageButton(9000, R.drawable.rotation2x, ps(42), ps(42));
    listButton = this.makeImageButton(9001, R.drawable.list2x, getPS(bs), getPS(bs));
    fontButton = this.makeImageButton(9002, R.drawable.font2x, getPS(bs), getPS(bs));
    searchButton = this.makeImageButton(9003, R.drawable.search2x, getPS(bs), getPS(bs));
    rotationButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(rotationButton));
    listButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(listButton));
    fontButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(fontButton));
    searchButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(searchButton));

    titleLabel = this.makeLabel(3000, title, Gravity.CENTER_HORIZONTAL, 17, Color.argb(240, 94, 61, 35)); // setTextSize in android uses sp (Scaled Pixel) as default, they say that sp guarantees the device dependent size, but as usual in android it can't be 100% sure.    
    authorLabel = this.makeLabel(3000, author, Gravity.CENTER_HORIZONTAL, 17, Color.argb(240, 94, 61, 35));
    pageIndexLabel = this.makeLabel(3000, "......", Gravity.CENTER_HORIZONTAL, 13, Color.argb(240, 94, 61, 35));
    secondaryIndexLabel = this.makeLabel(3000, "......", Gravity.CENTER_HORIZONTAL, 13,
            Color.argb(240, 94, 61, 35));

    //      rv.customView.addView(rotationButton);
    //      rv.customView.addView(listButton);
    //      rv.customView.addView(fontButton);
    //      rv.customView.addView(searchButton);      
    rv.customView.addView(titleLabel);
    rv.customView.addView(authorLabel);

    ePubView.addView(rotationButton);
    ePubView.addView(listButton);
    ePubView.addView(fontButton);
    if (!rv.isScrollMode())
        ePubView.addView(searchButton);
    //      ePubView.addView(titleLabel);
    //      ePubView.addView(authorLabel);

    ePubView.addView(pageIndexLabel);
    ePubView.addView(secondaryIndexLabel);

    seekBar = new SkySeekBar(this);
    seekBar.setMax(999);
    seekBar.setId(999);
    RectShape rectShape = new RectShape();
    ShapeDrawable thumb = new ShapeDrawable(rectShape);

    thumb.getPaint().setColor(theme.seekThumbColor);
    thumb.setIntrinsicHeight(getPS(28));
    thumb.setIntrinsicWidth(getPS(28));
    seekBar.setThumb(thumb);
    seekBar.setBackgroundColor(Color.TRANSPARENT);
    seekBar.setOnSeekBarChangeListener(new SeekBarDelegate());
    seekBar.setProgressDrawable(new DottedDrawable(theme.seekBarColor));
    seekBar.setThumbOffset(-3);
    seekBar.setMinimumHeight(24);

    int filterColor = theme.controlColor;
    rotationButton.setColorFilter(filterColor);
    listButton.setColorFilter(filterColor);
    fontButton.setColorFilter(filterColor);
    searchButton.setColorFilter(filterColor);

    authorLabel.setTextColor(filterColor);
    titleLabel.setTextColor(filterColor);
    pageIndexLabel.setTextColor(filterColor);
    secondaryIndexLabel.setTextColor(filterColor);

    ePubView.addView(seekBar);
}