diff --git a/app/build.gradle b/app/build.gradle index d637f80..7400e73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "com.JJ.hangoverclock" minSdkVersion 16 targetSdkVersion 28 - versionCode 5 - versionName "1.5" + versionCode 6 + versionName "toxic" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/release/app-release.apk b/app/release/app-release.apk index 9b2d038..6b438bd 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/output.json b/app/release/output.json index d4c660a..406d42d 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":5,"versionName":"1.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":6,"versionName":"v1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 44aa785..ba392bb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,11 +4,11 @@ package="com.JJ.hangoverclock"> diff --git a/app/src/main/java/com/JJ/hangoverclock/BootReceiver.java b/app/src/main/java/com/JJ/hangoverclock/BootReceiver.java index 402412b..6004ec5 100644 --- a/app/src/main/java/com/JJ/hangoverclock/BootReceiver.java +++ b/app/src/main/java/com/JJ/hangoverclock/BootReceiver.java @@ -1,18 +1,13 @@ package com.JJ.hangoverclock; -import android.app.AlarmManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.util.Log; - -import static android.content.ContentValues.TAG; public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - Log.i(TAG, "onReceive: BOOT COMPLETE RECEIVED"); ClockWidgetProvider clockWidgetProvider = new ClockWidgetProvider(); clockWidgetProvider.onEnabled(context); } diff --git a/app/src/main/java/com/jj/hangoverclock/ClockWidgetProvider.java b/app/src/main/java/com/jj/hangoverclock/ClockWidgetProvider.java index 08c8336..858f0e8 100644 --- a/app/src/main/java/com/jj/hangoverclock/ClockWidgetProvider.java +++ b/app/src/main/java/com/jj/hangoverclock/ClockWidgetProvider.java @@ -9,40 +9,23 @@ import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import android.support.annotation.VisibleForTesting; -import android.util.Log; import android.view.View; import android.widget.RemoteViews; import java.util.Calendar; -//import static android.content.ContentValues.TAG; - public class ClockWidgetProvider extends AppWidgetProvider { - - static String TAG = "info"; + static final int houroverhang = 1; public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { - Log.i("info", "onUpdate: i have been called"); - //int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); - //int minutes = Calendar.getInstance().get(Calendar.MINUTE); - //int seconds = Calendar.getInstance().get(Calendar.SECOND); - for (int i = 0; i=60) overhang += 60; if (overhang<60) overhang += 10; //overhang = Math.min(overhang, 60); //Limit of 1 hour //overhang = Math.min(overhang, 60*24); //Limit of a day - ComponentName thisAppWidget = new ComponentName(context.getPackageName(), getClass().getName()); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); - int[] ids = appWidgetManager.getAppWidgetIds(thisAppWidget); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); remoteViews.setTextViewText(R.id.clock, "+" + overhang); appWidgetManager.updateAppWidget(Integer.valueOf(intent.getAction().split("#")[1]), remoteViews); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putInt("overhang" + Integer.valueOf(intent.getAction().split("#")[1]), overhang); editor.apply(); - Log.i(TAG, "onReceive: new overhang " + Integer.valueOf(intent.getAction().split("#")[1]) + " value: " + overhang); } if (minusbutton.equals(intent.getAction().split("#")[0])) { - Log.i(TAG, "onReceive: minusbutton pressed"); if (overhang<=60) overhang -= 10; if (overhang>60) overhang -= 60; overhang = Math.max(overhang, 0); - ComponentName thisAppWidget = new ComponentName(context.getPackageName(), getClass().getName()); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); - int[] ids = appWidgetManager.getAppWidgetIds(thisAppWidget); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); remoteViews.setTextViewText(R.id.clock, "+" + overhang); appWidgetManager.updateAppWidget(Integer.valueOf(intent.getAction().split("#")[1]), remoteViews); SharedPreferences.Editor editor= sharedPreferences.edit(); editor.putInt("overhang" + Integer.valueOf(intent.getAction().split("#")[1]), overhang); editor.apply(); - Log.i(TAG, "onReceive: new overhang " + Integer.valueOf(intent.getAction().split("#")[1]) + " value: " + overhang); } if (CLOCK_WIDGET_UPDATE.equals(intent.getAction())) { - Log.i(TAG, "Clock update"); - // Get the widget manager and ids for this widget provider, then call the shared - // clock update method. + // Get the widget manager and ids for this widget provider, then call the shared clock update method. ComponentName thisAppWidget = new ComponentName(context.getPackageName(), getClass().getName()); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] ids = appWidgetManager.getAppWidgetIds(thisAppWidget); @@ -156,7 +124,6 @@ protected PendingIntent getPendingSelfIntent(Context context, String action) { @Override public void onDisabled(Context context) { super.onDisabled(context); - Log.i(TAG, "Widget Provider disabled. Turning off timer and deleting all values"); AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(createClockTickIntent(context)); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); @@ -168,9 +135,6 @@ public void onDisabled(Context context) { @Override public void onEnabled(Context context) { super.onEnabled(context); - //SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - //overhang = sharedPreferences.getInt("overhang", overhang); - Log.i(TAG, "Widget Provider enabled. Starting timer to update widget every minute"); AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); @@ -184,53 +148,33 @@ public void updateAppWidget(Context context, AppWidgetManager appWidgetManager, controlsvisible = sharedPreferences.getBoolean("controlsvisible" + appWidgetId, false); int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); int minutes = Calendar.getInstance().get(Calendar.MINUTE); - //int seconds = Calendar.getInstance().get(Calendar.SECOND); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); - //remoteViews.setTextViewText(R.id.clock, hour + ":" + minutes); String time = calculatetime((double)hour*60*60+minutes*60,overhang); if (controlsvisible) { remoteViews.setViewVisibility(R.id.plus, View.GONE); remoteViews.setViewVisibility(R.id.minus, View.GONE); controlsvisible = false; - Log.i(TAG, "updateAppWidget: disabled controls"); } remoteViews.setTextViewText(R.id.clock, time); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("time" + appWidgetId, time); editor.apply(); - //remoteViews.setTextViewText(R.id.clock, hour + ":" + minutes + ":" + seconds); remoteViews.setOnClickPendingIntent(R.id.controlbutton, getPendingSelfIntent(context, controlbutton + "#" + appWidgetId)); remoteViews.setOnClickPendingIntent(R.id.plus, getPendingSelfIntent(context, plusbutton + "#" + appWidgetId)); remoteViews.setOnClickPendingIntent(R.id.minus, getPendingSelfIntent(context, minusbutton + "#" + appWidgetId)); appWidgetManager.updateAppWidget(appWidgetId, remoteViews); - Log.i("info", "updateAppWidget: updated widget " + appWidgetId); } public static String calculatetime(double time, int overhang) { //inputs: double time in seconds // int overhang in seconds - //if (overhang>60) overhang = 60; int h = (int) Math.floor(time / 60 / 60); int m = (int) Math.floor(time / 60) - (h*60); - //int s = (int) Math.floor(time) - (m*60) - (h*60*60); - //int ms = (int) ((time - (h*60*60) - (m*60) - s) * 100); - //final String timetext2 = String.format(); - //final String timetext2 = String.format("%02d", h)+":"+String.format("%02d", m)+":"+String.format("%02d", s)+"."+String.format("%02d", ms); - /*if (h>0 & m=60) h--; - }/* - /*if (m>0 & s=60) m--; - }*/ while (m=60) h--; if(h - - - - - - - - - - diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 0d025f9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/mipmap-anydpi-v26/clock_c_round.xml b/app/src/main/res/mipmap-anydpi-v26/clock_c_round.xml deleted file mode 100644 index c8af41e..0000000 --- a/app/src/main/res/mipmap-anydpi-v26/clock_c_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cf..0000000 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cf..0000000 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/clock_c_round.png b/app/src/main/res/mipmap-hdpi/clock_c_round.png deleted file mode 100644 index 383e969..0000000 Binary files a/app/src/main/res/mipmap-hdpi/clock_c_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index 898f3ed..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index dffca36..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/clock_c_round.png b/app/src/main/res/mipmap-mdpi/clock_c_round.png deleted file mode 100644 index 2a57c15..0000000 Binary files a/app/src/main/res/mipmap-mdpi/clock_c_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 64ba76f..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index dae5e08..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/clock_c_round.png b/app/src/main/res/mipmap-xhdpi/clock_c_round.png deleted file mode 100644 index 7acd613..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/clock_c_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index e5ed465..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 14ed0af..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/clock_c_round.png b/app/src/main/res/mipmap-xxhdpi/clock_c_round.png deleted file mode 100644 index 3c77bf5..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/clock_c_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index b0907ca..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index d8ae031..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock_c_round.png b/app/src/main/res/mipmap-xxxhdpi/clock_c_round.png deleted file mode 100644 index dc25bf6..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/clock_c_round.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index 2c18de9..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index beed3cd..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/app/src/main/res/xml/appwidgetproviderinfo.xml b/app/src/main/res/xml/appwidgetproviderinfo.xml index 1708484..cecd834 100644 --- a/app/src/main/res/xml/appwidgetproviderinfo.xml +++ b/app/src/main/res/xml/appwidgetproviderinfo.xml @@ -4,7 +4,7 @@ android:minWidth="160dp" android:minHeight="40dp" android:updatePeriodMillis="1800000" - android:previewImage="@mipmap/clock_c" + android:previewImage="@mipmap/clock" android:initialLayout="@layout/widget" android:resizeMode="horizontal|vertical" android:widgetCategory="home_screen">