Material icons for timer

pull/384/head
Alex Baker 9 years ago
parent f966e4c9cd
commit c2918d1722

@ -680,7 +680,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
// abandon editing in this case
if (title.getText().toString().trim().length() == 0 || TextUtils.isEmpty(model.getTitle())) {
if (isNewTask) {
TimerPlugin.updateTimer(notificationManager, taskService, getActivity(), model, false);
TimerPlugin.stopTimer(notificationManager, taskService, getActivity(), model);
taskDeleter.delete(model);
if (getActivity() instanceof TaskListActivity) {
TaskListActivity tla = (TaskListActivity) getActivity();
@ -698,7 +698,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TimerPlugin.updateTimer(notificationManager, taskService, getActivity(), model, false);
TimerPlugin.stopTimer(notificationManager, taskService, getActivity(), model);
taskDeleter.delete(model);
shouldSaveState = false;

@ -795,7 +795,7 @@ public class TaskListFragment extends InjectingListFragment implements SwipeRefr
}
}
}
TimerPlugin.updateTimer(notificationManager, taskService, context, task, false);
TimerPlugin.stopTimer(notificationManager, taskService, context, task);
}
public void refreshFilterCount() {
@ -853,7 +853,7 @@ public class TaskListFragment extends InjectingListFragment implements SwipeRefr
itemId = item.getGroupId();
Task task = new Task();
task.setId(itemId);
TimerPlugin.updateTimer(notificationManager, taskService, getActivity(), task, false);
TimerPlugin.stopTimer(notificationManager, taskService, getActivity(), task);
taskDeleter.purge(itemId);
loadTaskListContent();
return true;

@ -6,7 +6,9 @@
package com.todoroo.astrid.timers;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.text.format.DateFormat;
import android.view.View;
import android.view.View.OnClickListener;
@ -42,14 +44,14 @@ public class TimerActionControlSet extends TaskEditControlSetBase {
@Override
public void onClick(View v) {
if (timerActive) {
TimerPlugin.updateTimer(notificationManager, taskService, activity, model, false);
TimerPlugin.stopTimer(notificationManager, taskService, activity, model);
for (TimerActionListener listener : listeners) {
listener.timerStopped(model);
}
chronometer.stop();
} else {
TimerPlugin.updateTimer(notificationManager, taskService, activity, model, true);
TimerPlugin.startTimer(notificationManager, taskService, activity, model);
for (TimerActionListener listener : listeners) {
listener.timerStarted(model);
}
@ -81,14 +83,10 @@ public class TimerActionControlSet extends TaskEditControlSetBase {
}
private void updateDisplay() {
final int drawable;
if(timerActive) {
drawable = R.drawable.icn_timer_stop;
} else {
drawable = R.drawable.icn_edit_timer;
}
timerButton.setImageResource(drawable);
int drawableRes = timerActive ? R.drawable.ic_pause_24dp : R.drawable.ic_play_arrow_24dp;
final Drawable drawable = DrawableCompat.wrap(activity.getResources().getDrawable(drawableRes));
DrawableCompat.setTint(drawable, activity.getResources().getColor(android.R.color.white));
timerButton.setImageDrawable(drawable);
long elapsed = model.getElapsedSeconds() * 1000L;
if (timerActive) {

@ -27,16 +27,19 @@ import static org.tasks.time.DateTimeUtils.currentTimeMillis;
public class TimerPlugin {
public static void startTimer(NotificationManager notificationManager, TaskService taskService, Context context, Task task) {
updateTimer(notificationManager, taskService, context, task, true);
}
public static void stopTimer(NotificationManager notificationManager, TaskService taskService, Context context, Task task) {
updateTimer(notificationManager, taskService, context, task, false);
}
/**
* toggles timer and updates elapsed time.
* @param start if true, start timer. else, stop it
*/
public static void updateTimer(NotificationManager notificationManager, TaskService taskService, Context context, Task task, boolean start) {
// if this call comes from tasklist, then we need to fill in the gaps to handle this correctly
// this is needed just for stopping a task
if (!task.containsNonNullValue(Task.TIMER_START)) {
task = taskService.fetchById(task.getId(), Task.ID, Task.TIMER_START, Task.ELAPSED_SECONDS);
}
private static void updateTimer(NotificationManager notificationManager, TaskService taskService, Context context, Task task, boolean start) {
if (task == null) {
return;
}
@ -46,6 +49,15 @@ public class TimerPlugin {
task.setTimerStart(DateUtilities.now());
}
} else {
// if this call comes from tasklist, then we need to fill in the gaps to handle this correctly
// this is needed just for stopping a task
if (!task.containsNonNullValue(Task.TIMER_START)) {
task = taskService.fetchById(task.getId(), Task.ID, Task.TIMER_START, Task.ELAPSED_SECONDS);
}
if (task == null) {
return;
}
if(task.getTimerStart() > 0) {
int newElapsed = (int)((DateUtilities.now() - task.getTimerStart()) / 1000L);
task.setTimerStart(0L);
@ -80,7 +92,7 @@ public class TimerPlugin {
.setContentTitle(appName)
.setContentText(text)
.setWhen(currentTimeMillis())
.setSmallIcon(R.drawable.timers_notification)
.setSmallIcon(R.drawable.ic_timer_white_24dp)
.setAutoCancel(false)
.setOngoing(true)
.build();

@ -37,6 +37,6 @@ public class TimerTaskCompleteListener extends InjectingBroadcastReceiver {
return;
}
TimerPlugin.updateTimer(notificationManager, taskService, context, task, false);
TimerPlugin.stopTimer(notificationManager, taskService, context, task);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M6,19h4V5H6v14zm8,-14v14h4V5h-4z"/>
</vector>

@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M8,5v14l11,-7z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

@ -118,7 +118,6 @@
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_weight="1"
android:background="#00000000"
android:gravity="center_vertical|center_horizontal"
android:paddingRight="5dip"
android:paddingLeft="5dip"
@ -130,7 +129,7 @@
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_horizontal"
android:textColor="?attr/asThemeTextColor"
android:textColor="@android:color/white"
android:textSize="10sp"
android:visibility="visible" />
</LinearLayout>

Loading…
Cancel
Save