Skip to content

Commit

Permalink
Merge pull request #10 from yashovardhan99/master
Browse files Browse the repository at this point in the history
Timer release
  • Loading branch information
yashovardhan99 authored Jun 30, 2019
2 parents 98371f9 + 10f9f99 commit 2c051af
Show file tree
Hide file tree
Showing 18 changed files with 580 additions and 122 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: paypal.me/yashovardhan99 # Replace with a single custom sponsorship URL
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

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

37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# How to Contribute
Firstly, thanks for reading this! This means you are here to help me improve this project and make it better for other developers!
## How to contribute
To get started, first fork this repository's main branch (see [Fork a repo](https://help.github.com/articles/fork-a-repo/)). Forking a repo makes a local copy of this repository in your github account. Now, you can freely make any changes you want and then submit a pull request to allow us to merge your changes back here. (Learn more [About pull requests](https://help.github.com/articles/about-pull-requests/)).

Now, there are many different ways you can contribute to this project and you don't need to be a programmer for all of them! You can help:
* Improve the documentation
* Create new issues. [Guide](https://help.github.com/articles/creating-an-issue/)
* Fix simple issues; and,
* Add new features!

## Documentation
The documentation mainly consists of the [Readme.md file](https://github.com/yashovardhan99/TimeIt/blob/master/README.md) and a [set of JavaDocs](https://github.com/yashovardhan99/TimeIt/tree/gh-pages/JavaDocs). The website is published using the `gh-pages` branch.

1. Please do not make any direct modification to the JavaDocs folder. It is generated automatically for every new release using the javadoc comments in the `.java` files of the `timeit` module. Instead, make any changes in the commented javadocs of the appropriate class.
2. Do not make any changes to any branch except the `master` branch. The master branch is the active development branch. For important changes, they will be merged in other branches as and when required. For the website, any changes in the readme will be merged from time to time depending on the severity of the fix.
3. Do not change the writing style or make major changes in the readme. Instead, you can write your own helping documentation which can later be integrated into the project (possibly via GitHub wiki).

## Opening an issuee
Before opening an issue, make sure that a similar issue is not already open (or has been recently closed). If you are working on a fix already, indicate so when opening the issue. Do not open issues for very small issues like spelling errors, missing punctuations etc. Instead, consider fixing them yourself and submit a single pull request with all such changes.

## Fixing issues
If you want to fix an issue with the library, consider indicating so in the issue discussion. If no issue exists, consider opening one. Do not open issues for very minor fixes.

## Adding new features
If you are working on expanding the project, consider opening an issue with the enhancement tag and indicate that you are working on it. This helps prevent duplication of effort. If an issue already exists requesting such a feature, comment there instead stating that you wish to work on it.

## License
Any changes you make to this project should be in compliance with the license requirements.

Copyright 2018 Yashovardhan Dhanania

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
49 changes: 41 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# TimeIt
**Now with Timer support!**

[![](https://jitpack.io/v/yashovardhan99/TimeIt.svg)](https://jitpack.io/#yashovardhan99/TimeIt)
[ ![Download](https://api.bintray.com/packages/yashovardhan99/TimeIt/TimeIt/images/download.svg) ](https://bintray.com/yashovardhan99/TimeIt/TimeIt/_latestVersion)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-TimeIt-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/7369)

A simple and easy to use stopwatch library for android
A simple and easy to use stopwatch and timer library for android
## Introduction
A stopwatch can be a very important widget in an app and yet creating it has been very difficult. Creating a stopwatch requires you to create a seperate thread to keep track of the time and then post the updates on the UI thread. This process becomes complicated very quickly. Especially if you plan on adding features like pause and split.
A stopwatch can be a very important widget in an app and yet creating it has been very difficult. Creating a stopwatch requires you to create a separate thread to keep track of the time and then post the updates on the UI thread. This process becomes complicated very quickly. Especially if you plan on adding features like pause and split.

With TimeIt, you can create a stopwatch app with very few lines of code!
Similarly, a timer is another important addon an app may need without going through all the hassle of running threads or handlers.

With TimeIt, you can create a stopwatch or a timer app with very few lines of code!

For example, to create and start a stopwatch and display it with a textView :

Expand All @@ -20,9 +24,20 @@ Pausing a stopwatch and resuming it is as simple as calling `stopwatch.pause();`

TimeIt also allows you to keep track of splits with the stopwatch by simply calling `stopwatch.split();`

Similarly, to set a timer:
```
Timer timer = new Timer(time_in_ms);
timer.setTextView(myTextView);
timer.start();
```
The timer provides utility functions to check the current time and current status (running, paused, stopped etc.). Please check the current status of the timer before actually starting/pausing/resuming the timer.

The Timer class provides an `OnTickListener` interface which you can register to, to listen for updates every clock cycle and receive a callback when the timer completes.

## Features
* **NEW** : Create Timers with pause and resume support!
* Easy to use stopwatch library
* No need to use seperate threads. Multithreading is handled by the library itself
* No need to use separate threads. Multithreading is handled by the library itself
* Supports pause/resume and split methods.
* Supports an `OnTickListener` to listen for updates in clock.
* Set the TextView directly with TimeIt (Automatically formats the time).
Expand All @@ -33,7 +48,25 @@ TimeIt also allows you to keep track of splits with the stopwatch by simply call
TimeIt is very easy to use. If you face any trouble, you can see the javadocs [available here](https://yashovardhan99.github.io/TimeIt/JavaDocs/). A demo app is included [here](https://github.com/yashovardhan99/TimeIt/tree/master/timeit-demo) for your reference. It implements the basic features of the library.

## Download
TimeIt is available on jitpack and bintray. (pending approval for jcenter). To download, use the badges above or follow these instructions:
TimeIt is available on jcenter, jitpack and bintray. To download, use the badges above or follow these instructions:

### Jcenter
Step 1. Add the JCenter repository to your root build.gradle at the end of repositories:
```gradle
allprojects {
repositories {
...
maven { url 'https://jcenter.bintray.com' }
}
}
```

Step 2 : Add the dependency in your app level build.gradle

```gradle
implementation 'com.yashovardhan99.timeit:timeit:1.2.0'
```

### Jitpack
Step 1. Add the JitPack repository to your root build.gradle at the end of repositories:
```gradle
Expand All @@ -47,7 +80,7 @@ Step 1. Add the JitPack repository to your root build.gradle at the end of repos
Step 2 : Add the dependency in your app level build.gradle
```gradle
dependencies {
implementation 'com.github.yashovardhan99:TimeIt:1.0.0'
implementation 'com.github.yashovardhan99:TimeIt:1.2.0'
}
```
### Bintray
Expand All @@ -64,12 +97,12 @@ repositories {
Step 2 : Add the dependency in your app level build.gradle

```gradle
implementation 'com.yashovardhan99.timeit:timeit:1.0.0'
implementation 'com.yashovardhan99.timeit:timeit:1.2.0'
```


## Contributing
Contributing guidelines will be available soon. Feel free to report any issues or make new pull requests! TimeIt is an open source project and is free for all to use and improve!
Contributing guidelines are available [here](https://github.com/yashovardhan99/TimeIt/blob/master/CONTRIBUTING.md). Feel free to report any issues or make new pull requests! TimeIt is an open source project and is free for all to use and improve!

## License
Copyright 2018 Yashovardhan Dhanania
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

Expand Down
19 changes: 2 additions & 17 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
#
# Copyright 2018 Yashovardhan Dhanania
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#Sun Jun 30 13:56:33 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
11 changes: 8 additions & 3 deletions timeit-demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,20 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1-beta01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1-beta01'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation project(':timeit')
}
11 changes: 5 additions & 6 deletions timeit-demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2018 Yashovardhan Dhanania
~
~ Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,8 +12,7 @@
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yashovardhan99.stopwatch">

Expand All @@ -27,11 +25,12 @@
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />

<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name=".TimerDemo"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

package com.yashovardhan99.stopwatch;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ScrollView;
import android.widget.TextView;

import com.yashovardhan99.timeit.OnTickListener;
import com.yashovardhan99.timeit.Split;
import com.yashovardhan99.timeit.Stopwatch;

import java.util.LinkedList;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, OnTickListener {
public class MainActivity extends AppCompatActivity implements View.OnClickListener, Stopwatch.OnTickListener {

TextView time, splitLog;
Stopwatch stopwatch;
Expand All @@ -51,37 +51,41 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
Log.d("ONCLICK", v.toString());
switch (v.getId()){
switch (v.getId()) {
case R.id.start:
if(!stopwatch.isStarted()) {
if (!stopwatch.isStarted()) {
stopwatch.start();
splitLog.setText(null);
}
break;
case R.id.stop:
if(stopwatch.isStarted())
if (stopwatch.isStarted())
stopwatch.stop();
break;
case R.id.pause:
if(stopwatch.isStarted() && !stopwatch.isPaused())
if (stopwatch.isStarted() && !stopwatch.isPaused())
stopwatch.pause();
break;
case R.id.resume:
if(stopwatch.isPaused())
if (stopwatch.isPaused())
stopwatch.resume();
break;
case R.id.split:
if(stopwatch.isStarted())
if (stopwatch.isStarted())
stopwatch.split();
StringBuilder stringBuilder = new StringBuilder();
LinkedList<Split> splits = stopwatch.getSplits();
for(Split split : splits){
for (Split split : splits) {
long lapTime = split.getLapTime();
long splitTime = split.getSplitTime();
stringBuilder.append(lapTime).append(" <- Lap ").append(splits.indexOf(split)).append(" Split -> ").append(splitTime).append("\n");
}
splitLog.setText(stringBuilder.toString());
((ScrollView)(findViewById(R.id.split_scroller))).fullScroll(View.FOCUS_DOWN);
((ScrollView) (findViewById(R.id.split_scroller))).fullScroll(View.FOCUS_DOWN);
break;
case R.id.switch_to_timer:
Intent intent = new Intent(this,TimerDemo.class);
startActivity(intent);
}
}

Expand Down
Loading

0 comments on commit 2c051af

Please sign in to comment.