Target SDK 26
* Broadcast restrictions * Background restrictions * Adaptive iconpull/574/head
@ -0,0 +1,27 @@
|
||||
package org.tasks.receivers;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
|
||||
import org.tasks.injection.BroadcastComponent;
|
||||
import org.tasks.injection.InjectingBroadcastReceiver;
|
||||
|
||||
public class PushReceiver extends InjectingBroadcastReceiver {
|
||||
|
||||
public static void broadcast(Context context, Task task, ContentValues values) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
super.onReceive(context, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inject(BroadcastComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.tasks.receivers;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
|
||||
import org.tasks.injection.BroadcastComponent;
|
||||
import org.tasks.injection.InjectingBroadcastReceiver;
|
||||
|
||||
public class PushReceiver extends InjectingBroadcastReceiver {
|
||||
|
||||
public static void broadcast(Context context, Task task, ContentValues values) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
super.onReceive(context, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inject(BroadcastComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.tasks.receivers;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
|
||||
import org.tasks.injection.BroadcastComponent;
|
||||
import org.tasks.injection.InjectingBroadcastReceiver;
|
||||
|
||||
public class PushReceiver extends InjectingBroadcastReceiver {
|
||||
|
||||
public static void broadcast(Context context, Task task, ContentValues values) {
|
||||
Intent intent = new Intent(context, PushReceiver.class);
|
||||
intent.putExtra(AstridApiConstants.EXTRAS_TASK, task);
|
||||
intent.putExtra(AstridApiConstants.EXTRAS_VALUES, values);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
super.onReceive(context, intent);
|
||||
|
||||
GoogleTaskPushReceiver.broadcast(
|
||||
context,
|
||||
intent.getParcelableExtra(AstridApiConstants.EXTRAS_TASK),
|
||||
intent.getParcelableExtra(AstridApiConstants.EXTRAS_VALUES));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inject(BroadcastComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 37 KiB |
@ -1,59 +0,0 @@
|
||||
package org.tasks;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
|
||||
import org.tasks.injection.ForApplication;
|
||||
import org.tasks.receivers.CompleteTaskReceiver;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Broadcaster {
|
||||
|
||||
private final Context context;
|
||||
|
||||
@Inject
|
||||
public Broadcaster(@ForApplication Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void toggleCompletedState(long taskId) {
|
||||
completeTask(taskId, true);
|
||||
}
|
||||
|
||||
public void completeTask(long taskId) {
|
||||
completeTask(taskId, false);
|
||||
}
|
||||
|
||||
private void completeTask(final long taskId, final boolean flipState) {
|
||||
Intent intent = new Intent(context, CompleteTaskReceiver.class);
|
||||
intent.putExtra(CompleteTaskReceiver.TASK_ID, taskId);
|
||||
intent.putExtra(CompleteTaskReceiver.TOGGLE_STATE, flipState);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void taskCompleted(final long id) {
|
||||
Intent intent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_COMPLETED);
|
||||
intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, id);
|
||||
context.sendOrderedBroadcast(intent, null);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
context.sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
|
||||
}
|
||||
|
||||
public void refreshLists() {
|
||||
context.sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH_LISTS));
|
||||
}
|
||||
|
||||
public void taskUpdated(final Task task, final ContentValues values) {
|
||||
Intent intent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_SAVED);
|
||||
intent.putExtra(AstridApiConstants.EXTRAS_TASK, task);
|
||||
intent.putExtra(AstridApiConstants.EXTRAS_VALUES, values);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package org.tasks;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import com.todoroo.astrid.api.AstridApiConstants;
|
||||
|
||||
import org.tasks.injection.ForApplication;
|
||||
import org.tasks.widget.AppWidgetManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class LocalBroadcastManager {
|
||||
|
||||
public static final String REFRESH = BuildConfig.APPLICATION_ID + ".REFRESH";
|
||||
public static final String REFRESH_LIST = BuildConfig.APPLICATION_ID + ".REFRESH_LIST";
|
||||
private static final String REPEAT = BuildConfig.APPLICATION_ID + ".REPEAT";
|
||||
|
||||
private final android.support.v4.content.LocalBroadcastManager localBroadcastManager;
|
||||
private final AppWidgetManager appWidgetManager;
|
||||
|
||||
@Inject
|
||||
public LocalBroadcastManager(@ForApplication Context context, AppWidgetManager appWidgetManager) {
|
||||
this.appWidgetManager = appWidgetManager;
|
||||
localBroadcastManager = android.support.v4.content.LocalBroadcastManager.getInstance(context);
|
||||
}
|
||||
|
||||
public void registerRefreshReceiver(BroadcastReceiver broadcastReceiver) {
|
||||
localBroadcastManager.registerReceiver(broadcastReceiver, new IntentFilter(REFRESH));
|
||||
}
|
||||
|
||||
public void registerRefreshListReceiver(BroadcastReceiver broadcastReceiver) {
|
||||
localBroadcastManager.registerReceiver(broadcastReceiver, new IntentFilter(REFRESH_LIST));
|
||||
}
|
||||
|
||||
public void registerRepeatReceiver(BroadcastReceiver broadcastReceiver) {
|
||||
localBroadcastManager.registerReceiver(broadcastReceiver, new IntentFilter(REPEAT));
|
||||
}
|
||||
|
||||
public void broadcastRefresh() {
|
||||
localBroadcastManager.sendBroadcast(new Intent(REFRESH));
|
||||
appWidgetManager.updateWidgets();
|
||||
}
|
||||
|
||||
public void broadcastRefreshList() {
|
||||
localBroadcastManager.sendBroadcast(new Intent(REFRESH_LIST));
|
||||
}
|
||||
|
||||
/**
|
||||
* Action name for broadcast intent notifying that task was created from repeating template
|
||||
* <li> EXTRAS_TASK_ID id of the task
|
||||
* <li> EXTRAS_OLD_DUE_DATE task old due date (could be 0)
|
||||
* <li> EXTRAS_NEW_DUE_DATE task new due date (will not be 0)
|
||||
*/
|
||||
public void broadcastRepeat(long id, long oldDueDate, long newDueDate) {
|
||||
Intent intent = new Intent(REPEAT);
|
||||
intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, id);
|
||||
intent.putExtra(AstridApiConstants.EXTRAS_OLD_DUE_DATE, oldDueDate);
|
||||
intent.putExtra(AstridApiConstants.EXTRAS_NEW_DUE_DATE, newDueDate);
|
||||
localBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void unregisterReceiver(BroadcastReceiver broadcastReceiver) {
|
||||
localBroadcastManager.unregisterReceiver(broadcastReceiver);
|
||||
}
|
||||
}
|
@ -1,20 +1,18 @@
|
||||
package org.tasks.injection;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.JobIntentService;
|
||||
|
||||
public abstract class InjectingIntentService extends IntentService {
|
||||
|
||||
protected InjectingIntentService(String name) {
|
||||
super(name);
|
||||
}
|
||||
public abstract class InjectingJobIntentService extends JobIntentService {
|
||||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
protected void onHandleWork(@NonNull Intent intent) {
|
||||
inject(((InjectingApplication) getApplication())
|
||||
.getComponent()
|
||||
.plus(new IntentServiceModule()));
|
||||
}
|
||||
|
||||
|
||||
protected abstract void inject(IntentServiceComponent component);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package org.tasks.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.content.WakefulBroadcastReceiver;
|
||||
|
||||
public class AlarmJobBroadcast extends WakefulBroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
startWakefulService(context, new Intent(context, AlarmJob.class));
|
||||
}
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
package org.tasks.jobs;
|
||||
|
||||
public abstract class MidnightJob extends Job {
|
||||
public MidnightJob(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
package org.tasks.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.content.WakefulBroadcastReceiver;
|
||||
|
||||
public class ReminderJobBroadcast extends WakefulBroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
startWakefulService(context, new Intent(context, ReminderJob.class));
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package org.tasks.jobs;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
public abstract class WakefulJob extends Job {
|
||||
|
||||
public WakefulJob(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
super.onHandleIntent(intent);
|
||||
completeWakefulIntent(intent);
|
||||
}
|
||||
|
||||
protected abstract void completeWakefulIntent(Intent intent);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package org.tasks.widget;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
|
||||
import org.tasks.R;
|
||||
import org.tasks.injection.ForApplication;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class AppWidgetManager {
|
||||
private final android.appwidget.AppWidgetManager appWidgetManager;
|
||||
private Context context;
|
||||
|
||||
@Inject
|
||||
public AppWidgetManager(@ForApplication Context context) {
|
||||
this.context = context;
|
||||
appWidgetManager = android.appwidget.AppWidgetManager.getInstance(context);
|
||||
}
|
||||
|
||||
public void updateWidgets() {
|
||||
int[] widgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, TasksWidget.class));
|
||||
appWidgetManager.notifyAppWidgetViewDataChanged(widgetIds, R.id.list_view);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 599 B |
After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#607D8B</color>
|
||||
</resources>
|
Before Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 6.6 KiB |