Widget, clock and settings fixes

Widgets shows now from beginning the right time and name Widgets have
now a propper preview image
Clock works again
Settings bugfix with change profile and exercises
Small Changes in String.xml
Deletion of unused Images
This commit is contained in:
Jannik 2016-08-26 09:00:41 +02:00
commit 6cde0722e2
14 changed files with 36 additions and 16 deletions

View file

@ -18,6 +18,7 @@ public class AppWidget extends AppWidgetProvider {
static String time = "";
static RemoteViews views = null;
//int[] appWidgetIds;
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
@ -25,6 +26,13 @@ public class AppWidget extends AppWidgetProvider {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
CharSequence widgetText = prefs.getString("name_text", "Help");
int workTime = prefs.getInt("work_value", 0);
String clockTime = "";
if(workTime<10)
clockTime = "0" + workTime + ":00";
else
clockTime = workTime + ":00";
// Construct the RemoteViews object
if (views == null)
@ -32,7 +40,7 @@ public class AppWidget extends AppWidgetProvider {
views.setTextViewText(R.id.appwidget_text, widgetText);
if (time.equals(""))
views.setTextViewText(R.id.time, "00:00");
views.setTextViewText(R.id.time, clockTime);
else
views.setTextViewText(R.id.time, time);
@ -50,6 +58,8 @@ public class AppWidget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// There may be multiple widgets active, so update all of them
//this.appWidgetIds = appWidgetIds;
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
@ -101,10 +111,11 @@ public class AppWidget extends AppWidgetProvider {
views.setOnClickPendingIntent(R.id.appwidget_text, pendingIntent);
views.setOnClickPendingIntent(R.id.time, pendingIntent);
// Obtain appropriate widget and update it.
appWidgetManager.updateAppWidget(appWidgetId, views);
updateAppWidget(context,appWidgetManager,appWidgetId);
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
}

View file

@ -3,7 +3,6 @@ package orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder;
import android.app.Activity;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.appwidget.AppWidgetManager;
@ -73,6 +72,8 @@ public class BreakReminder extends AppCompatActivity
String allProfiles = sharedPrefs.getString("profiles", "");
if (allProfiles.equals("")) {
allProfiles = this.getResources().getText(R.string.standard_profile).toString();
String exercises = this.getResources().getText(R.string.all_exercises).toString();
editor.putString("exercise_value", exercises);
editor.putString("profiles", allProfiles);
editor.apply();
@ -142,7 +143,7 @@ public class BreakReminder extends AppCompatActivity
String currentProfile = sharedPrefs.getString("name_text", "") + "," + sharedPrefs.getInt("work_value", -1) + "," + sharedPrefs.getInt("break_value", -1) + "," + sharedPrefs.getBoolean("cont_value", false) + "," + sharedPrefs.getString("exercise_value", "-1");
if (!allProfiles.contains(currentProfile) && profileSelected.equals(sharedPrefs.getString("name_text", ""))) {
if (!(allProfiles.contains(currentProfile) && profileSelected.equals(sharedPrefs.getString("name_text", "")))) {
if (ct != null) {
ct.cancel();
isRunning = false;

View file

@ -94,12 +94,14 @@ public class ExerciseListPreference extends ListPreference implements DialogInte
}
if (exs.equals(""))
if (exs.equals("") && positiveResult)
exs = "-1";
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("exercise_value", exs);
editor.apply();
if(positiveResult) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("exercise_value", exs);
editor.apply();
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View file

@ -66,7 +66,7 @@
<string name="settings_summary">Derzeitiger Wert ist $1</string>
<string name="settings_unit">Minuten</string>
<string name="skip_the_break">Überspringen</string>
<string name="standard_profile">Zufall,90,5,false,Arme.Beine.Kopf.Nacken.Becken.Wirbelsaeule.Rumpf;Oberkoerper,90,15,true,Arme.Nacken.Kopf.;Rumpf,30,5,true,Wirbelsauele.Rumpf.;Unterkoerper,30,5,true,Beine.Becken.;</string>
<string name="standard_profile">Zufall,90,5,false,Arme.Beine.Kopf.Nacken.Becken.Wirbelsäule.Rumpf.;Oberkoerper,90,15,true,Arme.Nacken.Kopf.;Rumpf,30,5,true,Wirbelsäule.Rumpf.;Unterkoerper,30,5,true,Beine.Becken.;</string>
<string name="take_the_break">Pause nehmen</string>
<string name="title_activity_settings">Einstellungen</string>
<string name="tutorial_clock">Starten/Anhalten der Uhr</string>
@ -81,9 +81,11 @@
<item>Nacken</item>
<item>Arme</item>
<item>Rumpf</item>
<item>Wirbelsauele</item>
<item>Wirbelsäule</item>
<item>Becken</item>
<item>Beine</item>
</string-array>
<string name="new_profile">Neues Profil...</string>
<string name="statistics">Statistik</string>
<string name="all_exercises">Arme.Beine.Kopf.Nacken.Becken.Wirbelsäule.Rumpf.</string>
</resources>

View file

@ -104,7 +104,7 @@
<!-- settings for BreakActivity -->
<string name="_10_00" translatable="false">10:00</string>
<string name="break_next">Next</string>
<string name="break_next" translatable="false">Next</string>
<string name="break_description">Description:</string>
<string name="break_explanation">Description of the Exercise</string>
<string name="break_ex">Execution of the Exercise</string>
@ -139,5 +139,9 @@
<string name="tutorial_profile_description">By clicking on the current profile (\'Random\'), you will see all the currently available profiles. \nYou can add new profiles by clicking on \'New Profiles...\' and edit the current ones in the settings</string>
<string name="tutorial_clock">Start/Stop the clock</string>
<string name="tutorial_description">Welcome to the Privacy Friendly Break Reminder</string>
<string name="pref_current_profile_value" translatable="false">0</string>
<string name="all_exercises">Legs.Arms.Pelvis.Spinal Column.Torso.Neck.Head.</string>
</resources>

View file

@ -4,7 +4,7 @@
android:initialLayout="@layout/app_widget2x2"
android:minHeight="40dp"
android:minWidth="110dp"
android:previewImage="@drawable/example_appwidget_preview"
android:previewImage="@drawable/widget"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen"></appwidget-provider>

View file

@ -4,7 +4,7 @@
android:initialLayout="@layout/app_widget2x2"
android:minHeight="110dp"
android:minWidth="110dp"
android:previewImage="@drawable/example_appwidget_preview"
android:previewImage="@drawable/widget"
android:resizeMode="none"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen"></appwidget-provider>

View file

@ -4,7 +4,7 @@
android:initialLayout="@layout/app_widget3x3"
android:minHeight="180dp"
android:minWidth="180dp"
android:previewImage="@drawable/example_appwidget_preview"
android:previewImage="@drawable/widget"
android:resizeMode="none"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen"></appwidget-provider>

View file

@ -4,7 +4,7 @@
android:initialLayout="@layout/app_widget4x4"
android:minHeight="250dp"
android:minWidth="250dp"
android:previewImage="@drawable/example_appwidget_preview"
android:previewImage="@drawable/widget"
android:resizeMode="none"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen"></appwidget-provider>

View file

@ -2,7 +2,7 @@
<orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder.DynamicListPreference
android:defaultValue="@string/pref_current_profile"
android:defaultValue="@string/pref_current_profile_value"
android:key="current_profile"
android:title="@string/pref_current_profile" />