diff options
author | Arne Schwabe <arne@rfc2549.org> | 2013-12-11 10:18:06 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2013-12-11 10:18:06 +0100 |
commit | 49653f7c3811a29afc92b3def7430e962a39fe0b (patch) | |
tree | 74460916357ae9f0dd1849290d29881f3a4f423b /src/de/blinkt/openvpn/views/SeekBarTicks.java | |
parent | ce1dba9a001049264449eadd138a9b1d93eccba3 (diff) |
Move activities and views into packages
--HG--
rename : src/de/blinkt/openvpn/ConfigConverter.java => src/de/blinkt/openvpn/activities/ConfigConverter.java
rename : src/de/blinkt/openvpn/app/CreateShortcuts.java => src/de/blinkt/openvpn/activities/CreateShortcuts.java
rename : src/de/blinkt/openvpn/DisconnectVPN.java => src/de/blinkt/openvpn/activities/DisconnectVPN.java
rename : src/de/blinkt/openvpn/FileSelect.java => src/de/blinkt/openvpn/activities/FileSelect.java
rename : src/de/blinkt/openvpn/LogWindow.java => src/de/blinkt/openvpn/activities/LogWindow.java
rename : src/de/blinkt/openvpn/MainActivity.java => src/de/blinkt/openvpn/activities/MainActivity.java
rename : src/de/blinkt/openvpn/FileSelectLayout.java => src/de/blinkt/openvpn/views/FileSelectLayout.java
rename : src/de/blinkt/openvpn/RemoteCNPreference.java => src/de/blinkt/openvpn/views/RemoteCNPreference.java
rename : src/de/blinkt/openvpn/fragments/SeekBarTicks.java => src/de/blinkt/openvpn/views/SeekBarTicks.java
extra : rebase_source : fccff1bc269dbc0ae33b96a4947b8a6e2924efeb
Diffstat (limited to 'src/de/blinkt/openvpn/views/SeekBarTicks.java')
-rw-r--r-- | src/de/blinkt/openvpn/views/SeekBarTicks.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/views/SeekBarTicks.java b/src/de/blinkt/openvpn/views/SeekBarTicks.java new file mode 100644 index 00000000..88e8e164 --- /dev/null +++ b/src/de/blinkt/openvpn/views/SeekBarTicks.java @@ -0,0 +1,69 @@ +package de.blinkt.openvpn.views; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.ViewConfiguration; +import android.widget.SeekBar; + +public class SeekBarTicks extends SeekBar { + private Paint mTickPaint; + private float mTickHeight; + + private float tickHeightRatio = 0.6f; + + public SeekBarTicks(Context context, AttributeSet attrs) { + super (context, attrs); + + initTicks (context, attrs, android.R.attr.seekBarStyle); + } + + + public SeekBarTicks(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + initTicks (context, attrs, defStyle); + + /*mTickHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + tickHeightDP, + ctx.getResources().getDisplayMetrics()); */ + } + + private void initTicks(Context context, AttributeSet attrs, int defStyle) { + TypedArray a = context.obtainStyledAttributes(attrs, + new int[] { android.R.attr.secondaryProgress }, defStyle, 0); + + + int tickColor = a.getColor(0, android.R.color.black); + mTickPaint = new Paint(); + mTickPaint.setColor( context.getResources().getColor(tickColor)); + a.recycle(); + } + + + @Override + protected synchronized void onDraw(Canvas canvas) { + drawTicks(canvas); + super.onDraw(canvas); + } + + private void drawTicks(Canvas canvas) { + + final int available = getWidth() - getPaddingLeft() - getPaddingRight(); + final int availableHeight = getHeight() - getPaddingBottom() - getPaddingTop(); + + int extrapadding = (int) ((availableHeight- (availableHeight * tickHeightRatio))/2); + + int tickSpacing = available / (getMax() ); + + for (int i = 1; i < getMax(); i++) { + final float x = getPaddingLeft() + i * tickSpacing; + + canvas.drawLine(x, getPaddingTop()+extrapadding, x, getHeight()-getPaddingBottom()-extrapadding, mTickPaint); + } + } +} |