Skip to content

Commit

Permalink
new PointerSpeedometer
Browse files Browse the repository at this point in the history
  • Loading branch information
anastr committed Nov 1, 2016
1 parent 0de54ec commit 0dea7a4
Show file tree
Hide file tree
Showing 25 changed files with 852 additions and 270 deletions.
3 changes: 0 additions & 3 deletions .idea/dictionaries/my_pc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

16 changes: 16 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Library Size ~ 12 Kb.
<img src="/images/DeluxeSpeedView.gif" width="30%" />
<img src="/images/AwesomeSpeedometer.gif" width="30%" /><br/>
<img src="/images/RaySpeedometer.gif" width="30%" />
<img src="/images/PointerSpeedometer.gif" width="30%" />

# Download

Expand All @@ -21,7 +22,7 @@ Library Size ~ 12 Kb.
```gradle
dependencies {
compile 'com.github.anastr:speedviewlib:1.0.8'
compile 'com.github.anastr:speedviewlib:1.0.9'
}
```
Expand All @@ -32,13 +33,13 @@ for **maven**
<dependency>
<groupId>com.github.anastr</groupId>
<artifactId>speedviewlib</artifactId>
<version>1.0.8</version>
<version>1.0.9</version>
<type>pom</type>
</dependency>
```

# Usage
we have 4 views :
we have 5 views :

## 1st SpeedView

Expand Down Expand Up @@ -151,7 +152,7 @@ awesomeSpeedometer.setSpeedometerColor(Color.RED);

<img src="/images/RaySpeedometer.png" width="30%" />

**add AwesomeSpeedometer to your layout**
**add RaySpeedometer to your layout**

```xml

Expand All @@ -162,13 +163,34 @@ awesomeSpeedometer.setSpeedometerColor(Color.RED);

```
the same methods in SpeedView.<br/>
special methods for AwesomeSpeedometer :
special methods for RaySpeedometer :
```java
raySpeedometer.setDegreeBetweenMark(3); //def : 5
raySpeedometer.setMarkWidth(2); //def : 3dp
raySpeedometer.setRayColor(Color.RED);
```

## 5th PointerSpeedometer

<img src="/images/PointerSpeedometer.png" width="30%" />

**add PointerSpeedometer to your layout**

```xml

<com.github.anastr.speedviewlib.PointerSpeedometer
android:id="@+id/pointerSpeedometer"
android:layout_width="300dp"
android:layout_height="wrap_content" />

```
the same methods in SpeedView.<br/>
special methods for PointerSpeedometer :
```java
pointerSpeedometer.setUnitTextSize(15); //def : 5dp
pointerSpeedometer.setPointerColor(Color.RED);
```

# Attributes

and also you can change everything in XML, see this Attributes for **all Speedometers** :
Expand Down Expand Up @@ -222,13 +244,22 @@ app:markWidth="5dp" <!-- def : 3dp -->

```

Attributes just for **PointerSpeedometer** :

```xml

app:speedometerColor="#ffb26b" <!-- def : #eeeeee -->
app:pointerColor="#ffff00" <!-- def : WHITE -->
app:unitTextSize="15dp" <!-- def : 11dp -->

```

## Coming Soon ...
i well try to draw this Speedometer.
if you have any idea, image, template please **open new issue** and give me the image , and i well try to add it to the Library.

<img src="/images/new2.png" width="30%" />
<img src="/images/new3.png" width="30%" />
<img src="/images/new4.png" width="30%" />

# LICENSE
```
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<activity android:name=".DeluxeSpeedActivity" />
<activity android:name=".SpeedViewActivity" />
<activity android:name=".AwesomeSpeedometerActivity" />
<activity android:name=".RayActivity"></activity>
<activity android:name=".RayActivity" />
<activity android:name=".PointerActivity"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import com.github.anastr.speedviewlib.DeluxeSpeedView;

import java.util.Locale;

public class DeluxeSpeedActivity extends AppCompatActivity {

DeluxeSpeedView deluxeSpeedView;
Expand Down Expand Up @@ -55,7 +57,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
textSpeed.setText(String.format("%d", progress));
textSpeed.setText(String.format(Locale.getDefault(), "%d", progress));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ public void openRaySpeedometerActivity(View view) {
Intent intent = new Intent (MainActivity.this, RayActivity.class);
startActivity(intent);
}

public void openPointerSpeedometerActivity(View view) {
Intent intent = new Intent (MainActivity.this, PointerActivity.class);
startActivity(intent);
}
}
55 changes: 55 additions & 0 deletions app/src/main/java/com/github/anastr/speedview/PointerActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.github.anastr.speedview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;

import com.github.anastr.speedviewlib.PointerSpeedometer;

import java.util.Locale;

public class PointerActivity extends AppCompatActivity {

PointerSpeedometer pointerSpeedometer;
SeekBar seekBarSpeed;
Button ok;
TextView textSpeed;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pointer);

pointerSpeedometer = (PointerSpeedometer) findViewById(R.id.pointerSpeedometer);
seekBarSpeed = (SeekBar) findViewById(R.id.seekBarSpeed);
ok = (Button) findViewById(R.id.ok);
textSpeed = (TextView) findViewById(R.id.textSpeed);

ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pointerSpeedometer.speedTo(seekBarSpeed.getProgress());
}
});

seekBarSpeed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
textSpeed.setText(String.format(Locale.getDefault(), "%d", progress));
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
});
}
}
15 changes: 7 additions & 8 deletions app/src/main/java/com/github/anastr/speedview/RayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import com.github.anastr.speedviewlib.RaySpeedometer;

import java.util.Locale;

public class RayActivity extends AppCompatActivity {

RaySpeedometer raySpeedometer;
Expand Down Expand Up @@ -40,7 +42,7 @@ public void onClick(View v) {
seekBarSpeed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
textSpeed.setText(String.format("%d", progress));
textSpeed.setText(String.format(Locale.getDefault(), "%d", progress));
}

@Override
Expand All @@ -57,7 +59,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {
seekBarDegree.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
textDegree.setText(String.format("%d", progress));
textDegree.setText(String.format(Locale.getDefault(), "%d", progress));
raySpeedometer.setDegreeBetweenMark(progress);
}

Expand All @@ -73,8 +75,9 @@ public void onStopTrackingTouch(SeekBar seekBar) {
seekBarWidth.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
textWidth.setText(String.format("%d", progress) + "dp");
raySpeedometer.setMarkWidth((int) dpTOpx(progress));
textWidth.setText(String.format(Locale.getDefault(), "%ddp", progress));

raySpeedometer.setMarkWidth((int) raySpeedometer.dpTOpx(progress));
}

@Override
Expand All @@ -86,8 +89,4 @@ public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}

float dpTOpx(float dp) {
return dp * getResources().getDisplayMetrics().density;
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@
android:text="Ray Speedometer View"
style="@style/Base.Widget.AppCompat.Button.Colored"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="openPointerSpeedometerActivity"
android:text="Pointer Speedometer"
style="@style/Base.Widget.AppCompat.Button.Colored"/>

</LinearLayout>
52 changes: 52 additions & 0 deletions app/src/main/res/layout/activity_pointer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#70ed9a"
android:orientation="vertical"
tools:context="com.github.anastr.speedview.PointerActivity">

<com.github.anastr.speedviewlib.PointerSpeedometer
android:id="@+id/pointerSpeedometer"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:backgroundCircleColor="#70ed9a"
app:speedometerColor="#ffb26b"
/>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<SeekBar
android:id="@+id/seekBarSpeed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:max="100"
android:layout_gravity="center_vertical"/>

<TextView
android:id="@+id/textSpeed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
tools:text="50" />

<Button
android:id="@+id/ok"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok" />
</LinearLayout>

</LinearLayout>
3 changes: 2 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textAllCaps" tools:targetApi="ice_cream_sandwich">false</item>
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Expand Down
Binary file added images/PointerSpeedometer.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/PointerSpeedometer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/new4.png
Binary file not shown.
6 changes: 3 additions & 3 deletions speedviewlib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

group = 'com.github.anastr'
version = '1.0.8'
version = '1.0.9'

bintray {
user = properties.getProperty("bintray.user")
Expand All @@ -59,10 +59,10 @@ bintray {
name = 'SpeedView'

version {
name = 'SpeedView_1.0.8'
name = 'SpeedView_1.0.9'
desc = 'Speedometer UI for Android'
released = new Date()
vcsTag = '1.0.8'
vcsTag = '1.0.9'
}

licenses = ['Apache-2.0']
Expand Down
Loading

0 comments on commit 0dea7a4

Please sign in to comment.