Giter VIP home page Giter VIP logo

jumman04 / analogue-watch Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 3.0 717 KB

Analog Clock Library is a customizable Android library that displays time in a traditional analog format. Easily integrate a stylish analog clock into your app with adjustable colors, markers, hand styles, ticking sound effects, and more.

License: MIT License

Kotlin 100.00%
analog-clock android android-development android-library clock-widget custom-view customizable customizable-ui java kotlin

analogue-watch's Introduction

App Icon
API Level 17 and above JitPack Version GitHub Forks GitHub Stars GitHub License

Analog Clock Library

Analog Clock Library is a customizable Android library for displaying time in a traditional analog format. It provides developers with a range of customization options to adjust various aspects such as hour markers, minute markers, hour indicator text, and clock hands (hour, minute, second) to suit their application's design.


Features

  • Display time in a traditional analog format
  • Customize background color, marker colors, and hand colors
  • Adjust heights and widths of minute markers, hour markers, and hands
  • Enable/disable minute markers, hour markers, and hour indicator text
  • Ticking sound effects with adjustable volume
  • Customize text size, font family, text color, and text style for hour indicator text

Installation

Add JitPack repository to your root build.gradle file: Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        // Other repositories...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

    dependencies {
    implementation 'com.github.Jumman04:Analogue-Watch:4.2'
}

Usage in XML Layouts

<com.jummania.AnalogClock 
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Usage in Programmatic

AnalogClock analogClock = new AnalogClock(this);

Customization Attributes

Customize the appearance of the AnalogClock view by using the following XML attributes:

Color Attributes

  • background_color: Background color of the clock face
  • minute_marker_color: Color of minute markers
  • hour_marker_color: Color of hour markers
  • second_hand_color: Color of the second hand
  • minute_hand_color: Color of the minute hand
  • hour_hand_color: Color of the hour hand
  • textColor: Text color for hour indicator text

Dimension Attributes

  • minute_marker_height: Height of minute markers
  • hour_marker_height: Height of hour markers
  • textSize: Text size for hour indicator text

Boolean Attributes

  • minute_marker: Enable/disable display of minute markers
  • hour_marker: Enable/disable display of hour markers
  • enable_sound: Enable/disable ticking sound effects
  • enable_hour_text: Enable/disable display of hour indicator text

Text Attributes

  • fontFamily: Font family for hour indicator text

Example XML usage with attributes:

<com.jummania.AnalogClock 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    app:background_color="@color/white" 
    app:minute_marker_color="@color/gray"
    app:hour_marker_color="@color/black"
    app:textColor="@color/black"
    app:second_hand_color="@color/red"
    app:minute_hand_color="@color/blue" 
    app:hour_hand_color="@color/green"

    app:minute_marker_height="0.1" 
    app:hour_marker_height="0.15" 
    app:second_hand_height="0.9"
    app:minute_hand_height="0.8"
    app:hour_hand_height="0.7"
    app:second_hand_width="0.02"
    app:minute_hand_width="0.03"
    app:hour_hand_width="0.04"
    
    app:minute_marker="true" 
    app:hour_marker="true"
    app:enable_hour_text="true"
    app:enable_second_hand="true"
    app:enable_minute_hand="true"
    app:enable_hour_hand="true"
    app:enable_sound="true"

    app:volume="0.5"
    app:clock_sound="@raw/ticking_sound"
    app:textSize="14sp"
    app:fontFamily="sans-serif" 
    app:textStyle="normal"
/>

Programmatic Customization

You can also customize the AnalogClock view programmatically:

analogClock.setBackgroundColor(Color.WHITE)
analogClock.setMarkerColor(minuteMarkerColor = Color.GRAY, hourMarkerColor = Color.BLACK)
analogClock.setHandColor(secondHandColor = Color.RED, minuteHandColor = Color.BLUE, hourHandColor = Color.GREEN)
analogClock.setTextColor(Color.BLACK)

analogClock.setMarkerHeight(minuteMarkerHeight = 0.1f, hourMarkerHeight = 0.15f)
analogClock.setHandHeight(secondHandHeight = 0.8f, minuteHandHeight = 0.7f, hourHandHeight = 0.6f)
analogClock.setHandWidth(secondHandWidth = 0.02f, minuteHandWidth = 0.03f, hourHandWidth = 0.04f)
analogClock.setTextSize(14f)

analogClock.enableHourText(true)
analogClock.enableSound(true)
analogClock.enableMarkers(minuteMarker = true, hourMarker = true)
analogClock.enableHands(secondHand = true, minuteHand = true, hourHand = true)

analogClock.setVolume(0.5f)
analogClock.setMediaPlayer(R.raw.clock_tick)

analogClock.setTypeface(Typeface.SANS_SERIF)

Feature Requests

If you have a feature request or a suggestion for improving this library, please feel free to open an issue and let us know! We appreciate your feedback and are always looking to make our library better.

How to Request a Feature

  1. Click on the Issues tab.
  2. Click the green "New Issue" button.
  3. Fill in the requested information and submit the issue.

Thank you for using and contributing to the improvement of our library!

analogue-watch's People

Contributors

jumman04 avatar sharif-uddin-jumman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

analogue-watch's Issues

NullPointerException in MediaPlayer

A NullPointerException is thrown in the AnalogClock class when attempting to invoke the setVolume method on a null MediaPlayer object. This occurs when the getMediaPlayer method is called.

Crash Log

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.setVolume(float, float)' on a null object reference
at com.jummania.AnalogClock.getMediaPlayer(AnalogClock.kt:573)
at com.jummania.AnalogClock.<init>(AnalogClock.kt:109)
at com.jummania.AnalogClock.<init>(AnalogClock.kt:55)

Additional Information

  • Library Version: 1ebba4a
  • Android Version: 11

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.