Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions android-timetracker/.classpath
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
2 changes: 1 addition & 1 deletion android-timetracker/.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android-timetracker</name>
<name>ATimeTracker</name>
<comment></comment>
<projects>
</projects>
Expand Down
2 changes: 1 addition & 1 deletion android-timetracker/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
</activity>

</application>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" />
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="16" />
</manifest>
2 changes: 1 addition & 1 deletion android-timetracker/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-14
target=android-16
7 changes: 5 additions & 2 deletions android-timetracker/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">A Time Tracker</string>

<!-- -->
<string name="start">Start</string>
<string name="task_name">Task name</string>
<string name="add_task_ok">Add task</string>
<string name="task_name_required">The task name is required</string>
<string name="start_time_required">The start time is required</string>

<string name="delete_ok">Delete</string>
<string name="delete_task_title">Delete Task</string>
<string name="delete_task_message">Are you sure you want to delete \'%s\' and all of it\'s time records?</string>
Expand Down Expand Up @@ -42,6 +41,7 @@
<string name="concurrency">Multiple concurrently running tasks</string>
<string name="sound">Sound</string>
<string name="vibrate">Vibrate</string>
<string name="notification">Show Notification</string>
<!-- Settings values -->
<string name="sunday">Sunday</string>
<string name="monday">Monday</string>
Expand All @@ -56,6 +56,9 @@
<string name="sound_disabled">Sound disabled</string>
<string name="vibrate_enabled">Vibrate enabled</string>
<string name="vibrate_disabled">Vibrate disabled</string>
<string name="notification_always">Always</string>
<string name="notification_active">When 1 or more tasks are selected</string>
<string name="notification_never">Never</string>
<string name="time_display">Time display</string>
<string name="standard_time">Standard (HH:MM)</string>
<string name="decimal_time">Decimal (HH.hh)</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ListView;
Expand All @@ -45,6 +46,7 @@
*/
public class Settings extends ListActivity implements OnClickListener {

private final static String TAG = "ATimeTracker.Settings";
private static final int DAY_OF_WEEK_PREF_IDX = 0;
public static final int LARGE = 24;
public static final int MEDIUM = 20;
Expand All @@ -60,6 +62,12 @@ public class Settings extends ListActivity implements OnClickListener {
private static final String VALUETYPE = "value-type";
private static final int CHOOSE_DAY = 0;
private static final int CHOOSE_ROUNDING = 1;

// Notification preferences
private static final int NOTIFICATION_ALWAYS = 0,
NOTIFICATION_ACTIVE = 1,
NOTIFICATION_NEVER = 2;

private SharedPreferences applicationPreferences;
private List<Map<String, String>> prefs;
private SimpleAdapter adapter;
Expand All @@ -68,6 +76,7 @@ public class Settings extends ListActivity implements OnClickListener {
private static final int[] ROUND = new int[] { 0, 15, 30, 60 };
private final String[] ROUND_NAMES = new String[ROUND.length];
private HashMap<String, String> roundPref = new HashMap<String, String>();
private HashMap<String, Integer> notificationMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -110,6 +119,22 @@ protected void onCreate(Bundle savedInstanceState) {
fontMap.put(getString(R.string.medium_font), MEDIUM);
fontMap.put(getString(R.string.large_font), LARGE);

pref = new HashMap<String, String>();
pref.put(PREFERENCE, getString(R.string.notification));
final int notificationMode = applicationPreferences.getInt(
Tasks.NOTIFICATION_MODE, NOTIFICATION_ALWAYS);
updateNotificationPrefs(pref, notificationMode);
pref.put(VALUETYPE, INT);
pref.put(PREFERENCENAME, Tasks.NOTIFICATION_MODE);
prefs.add(pref);
notificationMap = new HashMap<String, Integer>(3);
notificationMap.put(getString(R.string.notification_always),
NOTIFICATION_ALWAYS);
notificationMap.put(getString(R.string.notification_active),
NOTIFICATION_ACTIVE);
notificationMap.put(getString(R.string.notification_never),
NOTIFICATION_NEVER);

addBooleanPreference(R.string.time_display, Tasks.TIMEDISPLAY,
R.string.decimal_time, R.string.standard_time);

Expand Down Expand Up @@ -160,6 +185,36 @@ private void addBooleanPreference(int prefName, String name,
prefs.add(pref);
}

private void updateNotificationPrefs(Map<String, String> pref,
int notificationMode){
final String notificationAlways = getString(R.string.notification_always);
final String notificationActive = getString(R.string.notification_active);
final String notificationNever = getString(R.string.notification_never);
switch(notificationMode){
case NOTIFICATION_ALWAYS:
pref.put(CURRENT, notificationAlways);
pref.put(DISABLED, notificationNever);
pref.put(DISABLEDVALUE, String.valueOf(NOTIFICATION_NEVER));
break;
case NOTIFICATION_ACTIVE:
pref.put(CURRENT, notificationActive);
pref.put(DISABLED, notificationAlways);
pref.put(DISABLEDVALUE, String.valueOf(NOTIFICATION_ALWAYS));
break;
case NOTIFICATION_NEVER:
pref.put(CURRENT, notificationNever);
pref.put(DISABLED, notificationActive);
pref.put(DISABLEDVALUE, String.valueOf(NOTIFICATION_ACTIVE));
break;
}
pref.put(CURRENTVALUE, String.valueOf(notificationMode));
Log.d(TAG, "Updated preferences...");
Log.d(TAG, "\tCurrent: " + pref.get(CURRENT));
Log.d(TAG, "\tDisabled: " + pref.get(DISABLED));
Log.d(TAG, "\tDisabled Value: " + pref.get(DISABLEDVALUE));
Log.d(TAG, "\tCurrent Value: " + String.valueOf(notificationMode));
}

private void updateFontPrefs(Map<String, String> pref, int fontSize) {
final String smallFont = getString(R.string.small_font);
final String mediumFont = getString(R.string.medium_font);
Expand Down Expand Up @@ -202,6 +257,10 @@ public void onListItemClick(ListView l, View v, int position, long id) {
pref.put(CURRENTVALUE, disabled_value);
pref.put(DISABLEDVALUE, current_value);

if (pref.get(PREFERENCENAME).equals(Tasks.NOTIFICATION_MODE)){
updateNotificationPrefs(pref, notificationMap.get(disabled));
}

if (pref.get(PREFERENCENAME).equals(Tasks.FONTSIZE)) {
updateFontPrefs(pref, fontMap.get(disabled)); // disabled is the new enabled!
}
Expand Down
Loading