Coder Social home page Coder Social logo

androidwidgets's Introduction

Build Status Maven Central AndroidWidgets

Custom Android widgets used in cardiomood.com projects.

Import to your project

The library is available in maven repository.

You can include your library in your build.gradle:

compile 'com.cardiomood.android:android-widgets:0.1.1'

If you are using Maven, add the following dependency to pom.xml:

<dependency>
  <groupId>com.cardiomood.android</groupId>
  <artifactId>android-widgets</artifactId>
  <version>0.1.1</version>
  <type>aar</type>
</dependency>

Widgets

At the moment, the library includes the following components:

  • SpeedometerGauge - a simple needle gauge that looks like speedometer
  • BatteryIndicatorGauge - an iPhone like pseudo-3d battery indicator
  • CircularProgressBar - a siple circular progress bar with a text inside
  • CircledTextView - a TextView that has a circle around it

SpeedometerGauge

This was moved from the previous repository: https://github.com/ntoskrnl/SpeedometerView

Simple speedometer-like gauge with needle for Android.

speedometerview-v1

Usage

Import the library to your project.

In your layout xml-file add SpeedometerGauge as shown:

<com.cardiomood.android.controls.gauge.SpeedometerGauge
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:padding="8dp"
    android:id="@+id/speedometer" />

Configure SpeedometerGuge:

  private SpeedometerGauge speedometer;

  // Customize SpeedometerGauge
  speedometer = (SpeedometerGauge) v.findViewById(R.id.speedometer);
  
  // Add label converter
  speedometer.setLabelConverter(new SpeedometerView.LabelConverter() {
      @Override
      public String getLabelFor(double progress, double maxProgress) {
          return String.valueOf((int) Math.round(progress));
      }
  });
  
  // configure value range and ticks
  speedometer.setMaxSpeed(300);
  speedometer.setMajorTickStep(30);
  speedometer.setMinorTicks(2);
  
  // Configure value range colors
  speedometer.addColoredRange(30, 140, Color.GREEN);
  speedometer.addColoredRange(140, 180, Color.YELLOW);
  speedometer.addColoredRange(180, 400, Color.RED);

androidwidgets's People

Contributors

godfreyduke avatar ntoskrnl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidwidgets's Issues

Line witdth

How to increase the line width?
The color lines which displays in red or green color. I want to increase its width.

README doc nit-pick

First of all - thank you for putting this custom view together and for sharing the JAR!

Nit picking bug in doc: In the README - it still uses the old name for the Speedometer (SpeedometerView):

// Add label converter
speedometer.setLabelConverter(new SpeedometerView.LabelConverter() {

should be:

// Add label converter
speedometer.setLabelConverter(new SpeedometerGauge.LabelConverter() {

Upgrade to latest version of gradle

Having issues building due to the old version of gradle. Please upgrade to latest version as the current version of gradle being used in the app is deprecated and will soon be removed.

Thanks.

Negative values

Hello I want to use gauge to signal strenght of WIFI so your code can accept negative values?

onMeasure() in SpeedometerGauge.java was not compensating for the 2.0 to 1.0 aspect ratio

In the SpeedometerGauge.java file - the width was being set too narrowly for the allocated space in onMeasure(). My fix for this is shown below.

    /*
     * BUG: below as follows:
     *     Aspect ratio for speedometer is always width = 2 * height
     *     Therefore width and height should not treated equally as
     *     there is an implied aspect ratio (width / height) of 2.
     */
    if (height >= 0 && width >= 0) {
        // width = Math.min(height, width);
        width = Math.min(height * 2, width);
        /*
         * two cases : there isn't enough height for the width, and
         *   there is.
         */
        if (width / 2 > height) {
            width = height * 2;  // clip based on aspect ratio
        }

    }

Out of Memory on Android 7

Run the app on Android 7 and device Samsung Galaxy S6. Give below errors. Please suggest solution.

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 2822700 byte allocation with 556160 free bytes and 543KB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java)
at android.graphics.Bitmap.nativeCreate(Bitmap.java)
at android.graphics.Bitmap.createBitmap(Bitmap.java:977)
at android.graphics.Bitmap.createBitmap(Bitmap.java:948)
at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:755)
at com.cardiomood.android.controls.gauge.SpeedometerGauge.drawBackground(SpeedometerGauge.java:372)
at com.cardiomood.android.controls.gauge.SpeedometerGauge.onDraw(SpeedometerGauge.java:218)

How To Create Needle as Triangle Shape.

Hi @ntoskrnl
I used your library which is very useful to my requirement, But i am stucking how to draw needle as a triangle shape.
How to convert needle draw line method to draw bitmap or draw like a triangle shape needle.

Please Help.

I want to draw this image in place of needle line and rotate on around arc.
speed_arrow

setLabelTextSize needs to be called manually

After the commit: e63762d#diff-5aae92e37f96f604ba3d3bf15aeefcd7 setLabelTextSize() has to be called manually for the text to show up correctly.

I suspect it was because:

setLabelTextSize(attributes.getDimensionPixelSize(R.styleable.SpeedometerGauge_labelTextSize, Math.round(DEFAULT_LABEL_TEXT_SIZE_DP * density)));

Was replaced with:

setLabelTextSize(Math.round(DEFAULT_LABEL_TEXT_SIZE_DP * density));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.