Coder Social home page Coder Social logo

daycounter's Introduction

The original single-counter version (1.1) is still available in this branch and in this release.

DayCounter

A simple Android app counting remaining days until a given date. It was origianlly meant to give you a precise idea of how many days you have left until you reach a certain age (eg. 60 years), but you can use it for any sort of day counting.

I have been told that the code is a mess and it is hard to understand how it works (the fact that I already forgot it underlines that I guess), so I decided to make a small docs here.

Features

  • Unlimited number of counters (RAM is the limit)
  • Notification service displaying the amount of remaining days for any counter you choose
  • Homescreen widgets displaying the amount of remaining days for any counter you choose
  • Starts on boot
  • Supports complete translations (except for some error displaying and logging), currently available for ๐Ÿ‡จ๐Ÿ‡ฟ Czech and ๐Ÿ‡ซ๐Ÿ‡ท French.

Notes

  • The app is tested to work on Android 10 when the user uses the app as intended, there may be bugs and undesired features which I will appreciate in Issues (and won't ever fix)
  • The UI sucks

โš ๏ธ Saved data protection

The application stores the counters as a serialized data stream. Thus if you change the version of the Counter class (update/downgrade), it will be no longer possible for the application to load the data (the counters).

You can use the export and import functions to overcome this shortcoming by exporting the data in JSON format. Keep in mind that the byte format (the serialized data) can not be imported if the application uses a differnet version of the Counter class.

The JSON import/export option should be always prefered over bytes.

Items For Mental Consultation

How to build

Seriously, I have no idea

Build in Sketchware

See Releases and pick the file with .swb extension. It is a Sketchware backup file and you can use it to import this application as a Sketchware project. Be sure to use Sketchware Pro as I used several features the original Sketchware app does not offer.

Credits

I stole the icon from Icons8

Examples

Example 1: How many days until I reach 60?

When the app asks you for your birth date, be sure to enter the birth date and in the age box type '60'. dc_timer_until_sixty_years

Example 2: How many days until it is 2 years from now?

Into the birth date form you enter today's date and into the age box you type '2'. Screenshot_20220401-104700

Screenshots

dc_app_preview dc_settings_preview dc_homescreen_widget dc_notification_counter

daycounter's People

Contributors

attiliathehun avatar

Stargazers

Andrew Lalis avatar

Watchers

 avatar

daycounter's Issues

Error with launching on boot

An excerpt from the log:

BOOT_COMPLETED received

startService()

java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.content.Context.getSharedPreferences(java.lang.String, int)' on a null object reference

Problem: the app lacks a Context when booted outside the MainActivity

File ServiceLauncher.java #onRecieve()

Problematic code

case "android.intent.action.BOOT_COMPLETED" :
			         Util.log("BOOT_COMPLETED received");
			         Util.startService(context);
					 break;

Because Util#startService() uses other contextless methods of Util, but it is not it's duty to set the default context.

Changes to be made

case "android.intent.action.BOOT_COMPLETED" :
			         Util.log("BOOT_COMPLETED received");
			         Util.setContextIfNull(context);
			         Util.startService();
					 break;

Ik I can do it since I am literally the owner/only contributor but since I can't PC now, lemme just not this here.

The app does not take in account leap years

The algorithm uses a fixed length of the year of 365 days, while in reality every fourth year is counted as a 366 days year, also called a leap year. This inconsideration leads to decreased precision of the counter.

Widget does not show new data immediately

When you reset the counter and set a new one, the homescreen widget continues showing the old data.

This has to be something with Android, because the WidgetProvider#updateAppWidget() uses the same method as NotificationService#createNotification(), but the notification refreshes while the widget does not.

NotificationService.java

int daysLeft = Counter.getDaysRemaining();

WidgetProvider.java

int daysRemaining = Counter.getDaysRemaining();

Perhaps some sort of hard refreshing for the widget?

The Broadcasts are ignored

The app doesn't start on boot and the notification does not get refreshed on its own, only when you start MainActivity, which implies that there is a problem with handling broadcasts.

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.