Remove double brace initializers

pull/467/head
Alex Baker 9 years ago
parent cc56d80eab
commit a8692ffd76

@ -12,7 +12,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.google.guava:guava:19.0' classpath 'com.google.guava:guava:19.0'
classpath 'com.android.tools.build:gradle:2.2.0-beta3' classpath 'com.android.tools.build:gradle:2.2.0-rc1'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.2' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.2'
} }
} }

@ -136,9 +136,9 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
@OnClick(R.id.theme_row) @OnClick(R.id.theme_row)
protected void showThemePicker() { protected void showThemePicker() {
startActivityForResult(new Intent(TagSettingsActivity.this, ColorPickerActivity.class) {{ Intent intent = new Intent(TagSettingsActivity.this, ColorPickerActivity.class);
putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.COLORS); intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.COLORS);
}}, REQUEST_COLOR_PICKER); startActivityForResult(intent, REQUEST_COLOR_PICKER);
} }
@OnClick(R.id.clear) @OnClick(R.id.clear)

@ -63,9 +63,9 @@ public class TagViewFragment extends TaskListFragment {
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.menu_tag_settings: case R.id.menu_tag_settings:
startActivityForResult(new Intent(getActivity(), TagSettingsActivity.class) {{ Intent intent = new Intent(getActivity(), TagSettingsActivity.class);
putExtra(TagSettingsActivity.EXTRA_TAG_DATA, tagData); intent.putExtra(TagSettingsActivity.EXTRA_TAG_DATA, tagData);
}}, REQUEST_EDIT_TAG); startActivityForResult(intent, REQUEST_EDIT_TAG);
return true; return true;
default: default:
return super.onMenuItemClick(item); return super.onMenuItemClick(item);

@ -14,9 +14,9 @@ public class TaskEditActivity extends Activity {
final long taskId = getIntent().getLongExtra(TOKEN_ID, 0); final long taskId = getIntent().getLongExtra(TOKEN_ID, 0);
startActivity(new Intent(this, TaskListActivity.class) {{ Intent intent = new Intent(this, TaskListActivity.class);
putExtra(TaskListActivity.OPEN_TASK, taskId); intent.putExtra(TaskListActivity.OPEN_TASK, taskId);
}}); startActivity(intent);
finish(); finish();
} }

@ -225,9 +225,11 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
if (syncAdapterHelper.shouldShowBackgroundSyncWarning() && !preferences.getBoolean(R.string.p_sync_warning_shown, false)) { if (syncAdapterHelper.shouldShowBackgroundSyncWarning() && !preferences.getBoolean(R.string.p_sync_warning_shown, false)) {
if (taskListFragment != null) { if (taskListFragment != null) {
taskListFragment.makeSnackbar(R.string.master_sync_warning) taskListFragment.makeSnackbar(R.string.master_sync_warning)
.setAction(R.string.TLA_menu_settings, view -> startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS) {{ .setAction(R.string.TLA_menu_settings, view -> {
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
}})) intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
})
.setCallback(new Snackbar.Callback() { .setCallback(new Snackbar.Callback() {
@Override @Override
public void onShown(Snackbar snackbar) { public void onShown(Snackbar snackbar) {
@ -326,9 +328,9 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
if (intent.hasExtra(TOKEN_CREATE_NEW_LIST_NAME)) { if (intent.hasExtra(TOKEN_CREATE_NEW_LIST_NAME)) {
final String listName = intent.getStringExtra(TOKEN_CREATE_NEW_LIST_NAME); final String listName = intent.getStringExtra(TOKEN_CREATE_NEW_LIST_NAME);
intent.removeExtra(TOKEN_CREATE_NEW_LIST_NAME); intent.removeExtra(TOKEN_CREATE_NEW_LIST_NAME);
startActivityForResult(new Intent(TaskListActivity.this, TagSettingsActivity.class) {{ Intent activityIntent = new Intent(TaskListActivity.this, TagSettingsActivity.class);
putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_NAME, listName); activityIntent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_NAME, listName);
}}, NavigationDrawerFragment.REQUEST_NEW_LIST); startActivityForResult(activityIntent, NavigationDrawerFragment.REQUEST_NEW_LIST);
} }
} }

@ -338,9 +338,9 @@ public class TaskListFragment extends InjectingListFragment implements
broadcaster.refresh(); broadcaster.refresh();
return true; return true;
case R.id.menu_filter_settings: case R.id.menu_filter_settings:
startActivityForResult(new Intent(getActivity(), FilterSettingsActivity.class) {{ Intent intent = new Intent(getActivity(), FilterSettingsActivity.class);
putExtra(FilterSettingsActivity.TOKEN_FILTER, filter); intent.putExtra(FilterSettingsActivity.TOKEN_FILTER, filter);
}}, REQUEST_EDIT_FILTER); startActivityForResult(intent, REQUEST_EDIT_FILTER);
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

@ -21,14 +21,14 @@ public class CustomFilter extends Filter {
} }
public StoreObject toStoreObject() { public StoreObject toStoreObject() {
return new StoreObject() {{ StoreObject storeObject = new StoreObject();
setId(id); storeObject.setId(id);
setValue(SavedFilter.NAME, listingTitle); storeObject.setValue(SavedFilter.NAME, listingTitle);
setValue(SavedFilter.SQL, sqlQuery); storeObject.setValue(SavedFilter.SQL, sqlQuery);
if (valuesForNewTasks != null && valuesForNewTasks.size() > 0) { if (valuesForNewTasks != null && valuesForNewTasks.size() > 0) {
setValue(SavedFilter.VALUES, AndroidUtilities.contentValuesToSerializedString(valuesForNewTasks)); storeObject.setValue(SavedFilter.VALUES, AndroidUtilities.contentValuesToSerializedString(valuesForNewTasks));
} }
}}; return storeObject;
} }
public long getId() { public long getId() {

@ -62,9 +62,9 @@ public class DefaultsPreferences extends InjectingPreferenceActivity {
} }
private void startCalendarSelectionActivity() { private void startCalendarSelectionActivity() {
startActivityForResult(new Intent(DefaultsPreferences.this, CalendarSelectionActivity.class) {{ Intent intent = new Intent(DefaultsPreferences.this, CalendarSelectionActivity.class);
putExtra(CalendarSelectionActivity.EXTRA_SHOW_NONE, true); intent.putExtra(CalendarSelectionActivity.EXTRA_SHOW_NONE, true);
}}, REQUEST_CALENDAR_SELECTION); startActivityForResult(intent, REQUEST_CALENDAR_SELECTION);
} }
@Override @Override

@ -89,9 +89,9 @@ abstract public class RemoteModel extends AbstractModel {
public static JSONObject savePictureJson(final Uri uri) { public static JSONObject savePictureJson(final Uri uri) {
try { try {
return new JSONObject() {{ JSONObject json = new JSONObject();
put("uri", uri.toString()); json.put("uri", uri.toString());
}}; return json;
} catch (JSONException e) { } catch (JSONException e) {
Timber.e(e, e.getMessage()); Timber.e(e, e.getMessage());
} }

@ -87,13 +87,13 @@ public class CalendarAlarmReceiver extends InjectingBroadcastReceiver {
} }
if (shouldShowReminder && isMeeting(event)) { if (shouldShowReminder && isMeeting(event)) {
context.startActivity(new Intent(context, CalendarReminderActivity.class) {{ Intent intent = new Intent(context, CalendarReminderActivity.class);
putExtra(CalendarReminderActivity.TOKEN_EVENT_ID, eventId); intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_ID, eventId);
putExtra(CalendarReminderActivity.TOKEN_EVENT_NAME, event.getTitle()); intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_NAME, event.getTitle());
putExtra(CalendarReminderActivity.TOKEN_EVENT_END_TIME, event.getEnd()); intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_END_TIME, event.getEnd());
putExtra(CalendarReminderActivity.TOKEN_FROM_POSTPONE, fromPostpone); intent.putExtra(CalendarReminderActivity.TOKEN_FROM_POSTPONE, fromPostpone);
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
}}); context.startActivity(intent);
} }
} }

@ -143,9 +143,9 @@ public class CalendarReminderActivity extends ThemedInjectingAppCompatActivity {
} }
private void createNewList(final String name) { private void createNewList(final String name) {
startActivity(new Intent(CalendarReminderActivity.this, TaskListActivity.class) {{ Intent intent = new Intent(CalendarReminderActivity.this, TaskListActivity.class);
putExtra(TaskListActivity.TOKEN_CREATE_NEW_LIST_NAME, name); intent.putExtra(TaskListActivity.TOKEN_CREATE_NEW_LIST_NAME, name);
}}); startActivity(intent);
dismissButton.performClick(); // finish with animation dismissButton.performClick(); // finish with animation
} }

@ -17,13 +17,17 @@ public class GtasksList {
private StoreObject storeObject; private StoreObject storeObject;
public GtasksList(final String remoteId) { public GtasksList(final String remoteId) {
this(new StoreObject() {{ this(newStoreObject());
setType(GtasksList.TYPE);
}});
setLastSync(0L); setLastSync(0L);
setRemoteId(remoteId); setRemoteId(remoteId);
} }
private static StoreObject newStoreObject() {
StoreObject storeObject = new StoreObject();
storeObject.setType(GtasksList.TYPE);
return storeObject;
}
public GtasksList(StoreObject storeObject) { public GtasksList(StoreObject storeObject) {
if (!storeObject.getType().equals(TYPE)) { if (!storeObject.getType().equals(TYPE)) {
throw new RuntimeException("Type is not " + TYPE); throw new RuntimeException("Type is not " + TYPE);

@ -138,9 +138,11 @@ public class CommentsController {
String path = getPathFromUri(activity, updateBitmap); String path = getPathFromUri(activity, updateBitmap);
commentPictureView.setImageBitmap(sampleBitmap(path, commentPictureView.getLayoutParams().width, commentPictureView.getLayoutParams().height)); commentPictureView.setImageBitmap(sampleBitmap(path, commentPictureView.getLayoutParams().width, commentPictureView.getLayoutParams().height));
view.setOnClickListener(v -> activity.startActivity(new Intent(Intent.ACTION_VIEW) {{ view.setOnClickListener(v -> {
setDataAndType(updateBitmap, "image/*"); Intent intent = new Intent(Intent.ACTION_VIEW);
}})); intent.setDataAndType(updateBitmap, "image/*");
activity.startActivity(intent);
});
} else { } else {
commentPictureView.setVisibility(View.GONE); commentPictureView.setVisibility(View.GONE);
} }

@ -82,9 +82,9 @@ public class ReminderPreferences extends InjectingPreferenceActivity {
initializeTimePreference(getQuietEndPreference(), REQUEST_QUIET_END); initializeTimePreference(getQuietEndPreference(), REQUEST_QUIET_END);
findPreference(getString(R.string.p_led_color)).setOnPreferenceClickListener(preference -> { findPreference(getString(R.string.p_led_color)).setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(ReminderPreferences.this, ColorPickerActivity.class) {{ Intent intent = new Intent(ReminderPreferences.this, ColorPickerActivity.class);
putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.LED); intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.LED);
}}, REQUEST_LED_PICKER); startActivityForResult(intent, REQUEST_LED_PICKER);
return false; return false;
}); });
@ -130,9 +130,9 @@ public class ReminderPreferences extends InjectingPreferenceActivity {
private void initializeTimePreference(final TimePreference preference, final int requestCode) { private void initializeTimePreference(final TimePreference preference, final int requestCode) {
preference.setOnPreferenceClickListener(ignored -> { preference.setOnPreferenceClickListener(ignored -> {
final DateTime current = new DateTime().withMillisOfDay(preference.getMillisOfDay()); final DateTime current = new DateTime().withMillisOfDay(preference.getMillisOfDay());
startActivityForResult(new Intent(ReminderPreferences.this, TimePickerActivity.class) {{ Intent intent = new Intent(ReminderPreferences.this, TimePickerActivity.class);
putExtra(TimePickerActivity.EXTRA_TIMESTAMP, current.getMillis()); intent.putExtra(TimePickerActivity.EXTRA_TIMESTAMP, current.getMillis());
}}, requestCode); startActivityForResult(intent, requestCode);
return true; return true;
}); });
} }

@ -133,13 +133,13 @@ public class RepeatControlSet extends TaskEditControlFragment {
dialogView = inflater.inflate(R.layout.control_set_repeat, null); dialogView = inflater.inflate(R.layout.control_set_repeat, null);
value = (Button) dialogView.findViewById(R.id.repeatValue); value = (Button) dialogView.findViewById(R.id.repeatValue);
Spinner interval = (Spinner) dialogView.findViewById(R.id.repeatInterval); Spinner interval = (Spinner) dialogView.findViewById(R.id.repeatInterval);
interval.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeat_interval)) {{ ArrayAdapter<String> intervalAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeat_interval));
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); intervalAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}}); interval.setAdapter(intervalAdapter);
Spinner type = (Spinner) dialogView.findViewById(R.id.repeatType); Spinner type = (Spinner) dialogView.findViewById(R.id.repeatType);
type.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeat_type)) {{ ArrayAdapter<String> typeAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeat_type));
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}}); type.setAdapter(typeAdapter);
type.setOnItemSelectedListener(new OnItemSelectedListener() { type.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
@ -426,9 +426,9 @@ public class RepeatControlSet extends TaskEditControlFragment {
} }
private void repeatUntilClick() { private void repeatUntilClick() {
startActivityForResult(new Intent(context, DatePickerActivity.class) {{ Intent intent = new Intent(context, DatePickerActivity.class);
putExtra(DatePickerActivity.EXTRA_TIMESTAMP, repeatUntilValue > 0 ? repeatUntilValue : 0L); intent.putExtra(DatePickerActivity.EXTRA_TIMESTAMP, repeatUntilValue > 0 ? repeatUntilValue : 0L);
}}, REQUEST_PICK_DATE); startActivityForResult(intent, REQUEST_PICK_DATE);
} }
@Override @Override

@ -289,9 +289,9 @@ public class HideUntilControlSet extends TaskEditControlFragment implements OnIt
.withSecondOfMinute(0); .withSecondOfMinute(0);
final Activity activity = getActivity(); final Activity activity = getActivity();
startActivityForResult(new Intent(activity, DateAndTimePickerActivity.class) {{ Intent intent = new Intent(activity, DateAndTimePickerActivity.class);
putExtra(DateAndTimePickerActivity.EXTRA_TIMESTAMP, customDate.getMillis()); intent.putExtra(DateAndTimePickerActivity.EXTRA_TIMESTAMP, customDate.getMillis());
}}, REQUEST_HIDE_UNTIL); startActivityForResult(intent, REQUEST_HIDE_UNTIL);
spinner.setSelection(previousSetting); spinner.setSelection(previousSetting);
} else { } else {
previousSetting = position; previousSetting = position;

@ -318,9 +318,9 @@ public class ReminderControlSet extends TaskEditControlFragment {
} }
private void addNewAlarm() { private void addNewAlarm() {
startActivityForResult(new Intent(getActivity(), DateAndTimePickerActivity.class) {{ Intent intent = new Intent(getActivity(), DateAndTimePickerActivity.class);
putExtra(DateAndTimePickerActivity.EXTRA_TIMESTAMP, newDateTime().startOfDay().getMillis()); intent.putExtra(DateAndTimePickerActivity.EXTRA_TIMESTAMP, newDateTime().startOfDay().getMillis());
}}, REQUEST_NEW_ALARM); startActivityForResult(intent, REQUEST_NEW_ALARM);
} }
private View addAlarmRow(String text, final OnClickListener onRemove) { private View addAlarmRow(String text, final OnClickListener onRemove) {

@ -25,14 +25,13 @@ public class AACRecorder {
return; return;
} }
mediaRecorder = new MediaRecorder() {{ mediaRecorder = new MediaRecorder();
setAudioSource(AudioSource.MIC); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
setOutputFormat(OutputFormat.MPEG_4); mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
setAudioEncoder(AudioEncoder.AAC); mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
setOutputFile(tempFile); mediaRecorder.setOutputFile(tempFile);
setOnErrorListener((mr, what, extra) -> Timber.e("mediaRecorder.onError(mr, %s, %s)", what, extra)); mediaRecorder.setOnErrorListener((mr, what, extra) -> Timber.e("mediaRecorder.onError(mr, %s, %s)", what, extra));
setOnInfoListener((mr, what, extra) -> Timber.i("mediaRecorder.onInfo(mr, %s, %s)", what, extra)); mediaRecorder.setOnInfoListener((mr, what, extra) -> Timber.i("mediaRecorder.onInfo(mr, %s, %s)", what, extra));
}};
try { try {
mediaRecorder.prepare(); mediaRecorder.prepare();

@ -56,10 +56,10 @@ public class VoiceOutputAssistant implements OnInitListener {
shutdown(); shutdown();
} }
}); });
mTts.speak(textToSpeak, TextToSpeech.QUEUE_ADD, new HashMap<String, String>() {{ HashMap<String, String> params = new HashMap<>();
put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_NOTIFICATION)); params.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_NOTIFICATION));
put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, id); params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, id);
}}); mTts.speak(textToSpeak, TextToSpeech.QUEUE_ADD, params);
} else { } else {
lastTextToSpeak = textToSpeak; lastTextToSpeak = textToSpeak;
initTTS(); initTTS();

@ -31,16 +31,16 @@ public class Broadcaster {
} }
private void completeTask(final long taskId, final boolean flipState) { private void completeTask(final long taskId, final boolean flipState) {
sendOrderedBroadcast(new Intent(context, CompleteTaskReceiver.class) {{ Intent intent = new Intent(context, CompleteTaskReceiver.class);
putExtra(CompleteTaskReceiver.TASK_ID, taskId); intent.putExtra(CompleteTaskReceiver.TASK_ID, taskId);
putExtra(CompleteTaskReceiver.TOGGLE_STATE, flipState); intent.putExtra(CompleteTaskReceiver.TOGGLE_STATE, flipState);
}}); sendOrderedBroadcast(intent);
} }
public void taskCompleted(final long id) { public void taskCompleted(final long id) {
sendOrderedBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_COMPLETED) {{ Intent intent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_COMPLETED);
putExtra(AstridApiConstants.EXTRAS_TASK_ID, id); intent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, id);
}}); sendOrderedBroadcast(intent);
} }
public void refresh() { public void refresh() {
@ -48,10 +48,10 @@ public class Broadcaster {
} }
public void taskUpdated(final Task task, final ContentValues values) { public void taskUpdated(final Task task, final ContentValues values) {
context.sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_SAVED) {{ Intent intent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_SAVED);
putExtra(AstridApiConstants.EXTRAS_TASK, task); intent.putExtra(AstridApiConstants.EXTRAS_TASK, task);
putExtra(AstridApiConstants.EXTRAS_VALUES, values); intent.putExtra(AstridApiConstants.EXTRAS_VALUES, values);
}}); context.sendBroadcast(intent);
} }
private void sendOrderedBroadcast(Intent intent) { private void sendOrderedBroadcast(Intent intent) {

@ -45,6 +45,8 @@ import javax.inject.Inject;
import timber.log.Timber; import timber.log.Timber;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybean; import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybean;
import static org.tasks.time.DateTimeUtils.currentTimeMillis; import static org.tasks.time.DateTimeUtils.currentTimeMillis;
@ -83,12 +85,11 @@ public class Notifier {
public void triggerMissedCallNotification(final String name, final String number, long contactId) { public void triggerMissedCallNotification(final String name, final String number, long contactId) {
final String title = context.getString(R.string.missed_call, TextUtils.isEmpty(name) ? number : name); final String title = context.getString(R.string.missed_call, TextUtils.isEmpty(name) ? number : name);
Intent missedCallDialog = new Intent(context, MissedCallActivity.class) {{ Intent missedCallDialog = new Intent(context, MissedCallActivity.class);
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); missedCallDialog.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
putExtra(MissedCallActivity.EXTRA_NUMBER, number); missedCallDialog.putExtra(MissedCallActivity.EXTRA_NUMBER, number);
putExtra(MissedCallActivity.EXTRA_NAME, name); missedCallDialog.putExtra(MissedCallActivity.EXTRA_NAME, name);
putExtra(MissedCallActivity.EXTRA_TITLE, title); missedCallDialog.putExtra(MissedCallActivity.EXTRA_TITLE, title);
}};
NotificationCompat.Builder builder = new NotificationCompat.Builder(context) NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_check_white_24dp) .setSmallIcon(R.drawable.ic_check_white_24dp)
@ -104,20 +105,19 @@ public class Notifier {
} }
if (preferences.useNotificationActions()) { if (preferences.useNotificationActions()) {
Intent callNow = new Intent(context, MissedCallActivity.class) {{ Intent callNow = new Intent(context, MissedCallActivity.class);
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); callNow.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
putExtra(MissedCallActivity.EXTRA_NUMBER, number); callNow.putExtra(MissedCallActivity.EXTRA_NUMBER, number);
putExtra(MissedCallActivity.EXTRA_NAME, name); callNow.putExtra(MissedCallActivity.EXTRA_NAME, name);
putExtra(MissedCallActivity.EXTRA_TITLE, title); callNow.putExtra(MissedCallActivity.EXTRA_TITLE, title);
putExtra(MissedCallActivity.EXTRA_CALL_NOW, true); callNow.putExtra(MissedCallActivity.EXTRA_CALL_NOW, true);
}};
Intent callLater = new Intent(context, MissedCallActivity.class) {{ Intent callLater = new Intent(context, MissedCallActivity.class);
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); callLater.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
putExtra(MissedCallActivity.EXTRA_NUMBER, number); callLater.putExtra(MissedCallActivity.EXTRA_NUMBER, number);
putExtra(MissedCallActivity.EXTRA_NAME, name); callLater.putExtra(MissedCallActivity.EXTRA_NAME, name);
putExtra(MissedCallActivity.EXTRA_TITLE, title); callLater.putExtra(MissedCallActivity.EXTRA_TITLE, title);
putExtra(MissedCallActivity.EXTRA_CALL_LATER, true); callLater.putExtra(MissedCallActivity.EXTRA_CALL_LATER, true);
}};
builder builder
.addAction(R.drawable.ic_phone_white_24dp, context.getString(R.string.MCA_return_call), PendingIntent.getActivity(context, callNow.hashCode(), callNow, PendingIntent.FLAG_UPDATE_CURRENT)) .addAction(R.drawable.ic_phone_white_24dp, context.getString(R.string.MCA_return_call), PendingIntent.getActivity(context, callNow.hashCode(), callNow, PendingIntent.FLAG_UPDATE_CURRENT))
.addAction(R.drawable.ic_add_white_24dp, context.getString(R.string.MCA_add_task), PendingIntent.getActivity(context, callLater.hashCode(), callLater, PendingIntent.FLAG_UPDATE_CURRENT)); .addAction(R.drawable.ic_add_white_24dp, context.getString(R.string.MCA_add_task), PendingIntent.getActivity(context, callLater.hashCode(), callLater, PendingIntent.FLAG_UPDATE_CURRENT));
@ -170,10 +170,10 @@ public class Notifier {
String subtitle = context.getString(R.string.task_count, count); String subtitle = context.getString(R.string.task_count, count);
PendingIntent pendingIntent = PendingIntent.getActivity(context, (title + query).hashCode(), new Intent(context, TaskListActivity.class) {{ Intent intent = new Intent(context, TaskListActivity.class);
setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK); intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
putExtra(TaskListActivity.OPEN_FILTER, filter); intent.putExtra(TaskListActivity.OPEN_FILTER, filter);
}}, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(context, (title + query).hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(context) Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_check_white_24dp) .setSmallIcon(R.drawable.ic_check_white_24dp)
@ -244,12 +244,11 @@ public class Notifier {
final String text = context.getString(R.string.app_name); final String text = context.getString(R.string.app_name);
final Intent intent = new Intent(context, NotificationActivity.class) {{ final Intent intent = new Intent(context, NotificationActivity.class);
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
setAction("NOTIFY" + id); //$NON-NLS-1$ intent.setAction("NOTIFY" + id); //$NON-NLS-1$
putExtra(NotificationActivity.EXTRA_TASK_ID, id); intent.putExtra(NotificationActivity.EXTRA_TASK_ID, id);
putExtra(NotificationActivity.EXTRA_TITLE, taskTitle); intent.putExtra(NotificationActivity.EXTRA_TITLE, taskTitle);
}};
// don't ring multiple times if random reminder // don't ring multiple times if random reminder
if (type == ReminderService.TYPE_RANDOM) { if (type == ReminderService.TYPE_RANDOM) {
@ -267,30 +266,30 @@ public class Notifier {
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(taskDescription)); builder.setStyle(new NotificationCompat.BigTextStyle().bigText(taskDescription));
} }
if (preferences.useNotificationActions()) { if (preferences.useNotificationActions()) {
PendingIntent completeIntent = PendingIntent.getBroadcast(context, (int) id, new Intent(context, CompleteTaskReceiver.class) {{ Intent completeIntent = new Intent(context, CompleteTaskReceiver.class);
putExtra(CompleteTaskReceiver.TASK_ID, id); completeIntent.putExtra(CompleteTaskReceiver.TASK_ID, id);
}}, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent completePendingIntent = PendingIntent.getBroadcast(context, (int) id, completeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action completeAction = new NotificationCompat.Action.Builder( NotificationCompat.Action completeAction = new NotificationCompat.Action.Builder(
R.drawable.ic_check_white_24dp, context.getResources().getString(R.string.rmd_NoA_done), completeIntent).build(); R.drawable.ic_check_white_24dp, context.getResources().getString(R.string.rmd_NoA_done), completePendingIntent).build();
PendingIntent snoozePendingIntent = PendingIntent.getActivity(context, (int) id, new Intent(context, SnoozeActivity.class) {{ Intent snoozeIntent = new Intent(context, SnoozeActivity.class);
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); snoozeIntent.setFlags(FLAG_ACTIVITY_NEW_TASK);
putExtra(SnoozeActivity.EXTRA_TASK_ID, id); snoozeIntent.putExtra(SnoozeActivity.EXTRA_TASK_ID, id);
}}, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent snoozePendingIntent = PendingIntent.getActivity(context, (int) id, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
wearableExtender.addAction(completeAction); wearableExtender.addAction(completeAction);
for (final SnoozeOption snoozeOption : SnoozeDialog.getSnoozeOptions(preferences)) { for (final SnoozeOption snoozeOption : SnoozeDialog.getSnoozeOptions(preferences)) {
final long timestamp = snoozeOption.getDateTime().getMillis(); final long timestamp = snoozeOption.getDateTime().getMillis();
PendingIntent snoozeIntent = PendingIntent.getActivity(context, (int) id, new Intent(context, SnoozeActivity.class) {{ Intent wearableIntent = new Intent(context, SnoozeActivity.class);
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); wearableIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
setAction(String.format("snooze-%s-%s", id, timestamp)); wearableIntent.setAction(String.format("snooze-%s-%s", id, timestamp));
putExtra(SnoozeActivity.EXTRA_TASK_ID, id); wearableIntent.putExtra(SnoozeActivity.EXTRA_TASK_ID, id);
putExtra(SnoozeActivity.EXTRA_SNOOZE_TIME, timestamp); wearableIntent.putExtra(SnoozeActivity.EXTRA_SNOOZE_TIME, timestamp);
}}, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent wearablePendingIntent = PendingIntent.getActivity(context, (int) id, wearableIntent, PendingIntent.FLAG_UPDATE_CURRENT);
wearableExtender.addAction(new NotificationCompat.Action.Builder( wearableExtender.addAction(new NotificationCompat.Action.Builder(
R.drawable.ic_snooze_white_24dp, context.getString(snoozeOption.getResId()), snoozeIntent) R.drawable.ic_snooze_white_24dp, context.getString(snoozeOption.getResId()), wearablePendingIntent)
.build()); .build());
} }

@ -81,9 +81,8 @@ public class AddAttachmentActivity extends InjectingAppCompatActivity implements
@Override @Override
public void pickFromGallery() { public void pickFromGallery() {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI) {{ Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
setType("image/*"); intent.setType("image/*");
}};
if (intent.resolveActivity(getPackageManager()) != null) { if (intent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(intent, REQUEST_GALLERY); startActivityForResult(intent, REQUEST_GALLERY);
} }
@ -103,20 +102,20 @@ public class AddAttachmentActivity extends InjectingAppCompatActivity implements
String path = file.getPath(); String path = file.getPath();
Timber.i("Saved %s", file.getAbsolutePath()); Timber.i("Saved %s", file.getAbsolutePath());
final String extension = path.substring(path.lastIndexOf('.') + 1); final String extension = path.substring(path.lastIndexOf('.') + 1);
setResult(RESULT_OK, new Intent() {{ Intent intent = new Intent();
putExtra(EXTRA_PATH, file.getAbsolutePath()); intent.putExtra(EXTRA_PATH, file.getAbsolutePath());
putExtra(EXTRA_TYPE, TaskAttachment.FILE_TYPE_IMAGE + extension); intent.putExtra(EXTRA_TYPE, TaskAttachment.FILE_TYPE_IMAGE + extension);
}}); setResult(RESULT_OK, intent);
} }
finish(); finish();
} else if (requestCode == REQUEST_CODE_RECORD) { } else if (requestCode == REQUEST_CODE_RECORD) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
final String recordedAudioPath = data.getStringExtra(AACRecordingActivity.RESULT_OUTFILE); final String recordedAudioPath = data.getStringExtra(AACRecordingActivity.RESULT_OUTFILE);
final String extension = recordedAudioPath.substring(recordedAudioPath.lastIndexOf('.') + 1); final String extension = recordedAudioPath.substring(recordedAudioPath.lastIndexOf('.') + 1);
setResult(RESULT_OK, new Intent() {{ Intent intent = new Intent();
putExtra(EXTRA_PATH, recordedAudioPath); intent.putExtra(EXTRA_PATH, recordedAudioPath);
putExtra(EXTRA_TYPE, TaskAttachment.FILE_TYPE_AUDIO + extension); intent.putExtra(EXTRA_TYPE, TaskAttachment.FILE_TYPE_AUDIO + extension);
}}); setResult(RESULT_OK, intent);
} }
finish(); finish();
} else if (requestCode == REQUEST_GALLERY) { } else if (requestCode == REQUEST_GALLERY) {
@ -133,10 +132,10 @@ public class AddAttachmentActivity extends InjectingAppCompatActivity implements
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
setResult(RESULT_OK, new Intent() {{ Intent intent = new Intent();
putExtra(EXTRA_PATH, tempFile.getAbsolutePath()); intent.putExtra(EXTRA_PATH, tempFile.getAbsolutePath());
putExtra(EXTRA_TYPE, TaskAttachment.FILE_TYPE_IMAGE + extension); intent.putExtra(EXTRA_TYPE, TaskAttachment.FILE_TYPE_IMAGE + extension);
}}); setResult(RESULT_OK, intent);
} }
finish(); finish();
} else if (requestCode == REQUEST_STORAGE) { } else if (requestCode == REQUEST_STORAGE) {
@ -146,10 +145,10 @@ public class AddAttachmentActivity extends InjectingAppCompatActivity implements
if (destination != null) { if (destination != null) {
Timber.i("Copied %s to %s", path, destination); Timber.i("Copied %s to %s", path, destination);
final String extension = destination.substring(path.lastIndexOf('.') + 1); final String extension = destination.substring(path.lastIndexOf('.') + 1);
setResult(RESULT_OK, new Intent() {{ Intent intent = new Intent();
putExtra(EXTRA_PATH, destination); intent.putExtra(EXTRA_PATH, destination);
putExtra(EXTRA_TYPE, TaskAttachment.FILE_TYPE_IMAGE + extension); intent.putExtra(EXTRA_TYPE, TaskAttachment.FILE_TYPE_IMAGE + extension);
}}); setResult(RESULT_OK, intent);
} }
} }
finish(); finish();

@ -37,10 +37,10 @@ public class CalendarSelectionActivity extends InjectingAppCompatActivity implem
@Override @Override
public void selectedCalendar(final AndroidCalendar androidCalendar) { public void selectedCalendar(final AndroidCalendar androidCalendar) {
setResult(RESULT_OK, new Intent() {{ Intent data = new Intent();
putExtra(EXTRA_CALENDAR_ID, androidCalendar.getId()); data.putExtra(EXTRA_CALENDAR_ID, androidCalendar.getId());
putExtra(EXTRA_CALENDAR_NAME, androidCalendar.getName()); data.putExtra(EXTRA_CALENDAR_NAME, androidCalendar.getName());
}}); setResult(RESULT_OK, data);
finish(); finish();
} }

@ -70,9 +70,9 @@ public class CameraActivity extends InjectingAppCompatActivity {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
if (output != null) { if (output != null) {
final Uri uri = Uri.fromFile(output); final Uri uri = Uri.fromFile(output);
setResult(RESULT_OK, new Intent() {{ Intent intent = new Intent();
putExtra(EXTRA_URI, uri); intent.putExtra(EXTRA_URI, uri);
}}); setResult(RESULT_OK, intent);
} }
} }
finish(); finish();

@ -46,10 +46,10 @@ public class ColorPickerActivity extends InjectingAppCompatActivity implements C
@Override @Override
public void themePicked(final ColorPickerDialog.ColorPalette palette, final int index) { public void themePicked(final ColorPickerDialog.ColorPalette palette, final int index) {
setResult(RESULT_OK, new Intent() {{ Intent data = new Intent();
putExtra(EXTRA_PALETTE, palette); data.putExtra(EXTRA_PALETTE, palette);
putExtra(EXTRA_THEME_INDEX, index); data.putExtra(EXTRA_THEME_INDEX, index);
}}); setResult(RESULT_OK, data);
finish(); finish();
} }

@ -104,10 +104,10 @@ public class DateAndTimePickerActivity extends InjectingAppCompatActivity implem
final long timestamp = new DateTime(year, month + 1, day) final long timestamp = new DateTime(year, month + 1, day)
.withMillisOfDay(initial.getMillisOfDay()) .withMillisOfDay(initial.getMillisOfDay())
.getMillis(); .getMillis();
startActivity(new Intent(this, TimePickerActivity.class) {{ Intent intent = new Intent(this, TimePickerActivity.class);
addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
putExtra(TimePickerActivity.EXTRA_TIMESTAMP, timestamp); intent.putExtra(TimePickerActivity.EXTRA_TIMESTAMP, timestamp);
}}); startActivity(intent);
finish(); finish();
} }
} }

@ -77,9 +77,9 @@ public class DatePickerActivity extends InjectingAppCompatActivity implements Da
} }
private void dateSet(final int year, final int month, final int day) { private void dateSet(final int year, final int month, final int day) {
setResult(RESULT_OK, new Intent() {{ Intent data = new Intent();
putExtra(EXTRA_TIMESTAMP, new DateTime(year, month + 1, day).getMillis()); data.putExtra(EXTRA_TIMESTAMP, new DateTime(year, month + 1, day).getMillis());
}}); setResult(RESULT_OK, data);
finish(); finish();
} }
} }

@ -46,16 +46,16 @@ public class FilterSelectionActivity extends InjectingAppCompatActivity {
dialogBuilder.newDialog() dialogBuilder.newDialog()
.setSingleChoiceItems(filterAdapter, -1, (dialog, which) -> { .setSingleChoiceItems(filterAdapter, -1, (dialog, which) -> {
final Filter selectedFilter = (Filter) filterAdapter.getItem(which); final Filter selectedFilter = (Filter) filterAdapter.getItem(which);
setResult(RESULT_OK, new Intent() {{ Intent data = new Intent();
if (returnFilter) { if (returnFilter) {
putExtra(EXTRA_FILTER, selectedFilter); data.putExtra(EXTRA_FILTER, selectedFilter);
} }
putExtra(EXTRA_FILTER_NAME, selectedFilter.listingTitle); data.putExtra(EXTRA_FILTER_NAME, selectedFilter.listingTitle);
putExtra(EXTRA_FILTER_SQL, selectedFilter.getSqlQuery()); data.putExtra(EXTRA_FILTER_SQL, selectedFilter.getSqlQuery());
if (selectedFilter.valuesForNewTasks != null) { if (selectedFilter.valuesForNewTasks != null) {
putExtra(EXTRA_FILTER_VALUES, AndroidUtilities.contentValuesToSerializedString(selectedFilter.valuesForNewTasks)); data.putExtra(EXTRA_FILTER_VALUES, AndroidUtilities.contentValuesToSerializedString(selectedFilter.valuesForNewTasks));
} }
}}); setResult(RESULT_OK, data);
dialog.dismiss(); dialog.dismiss();
}) })
.setOnDismissListener(dialog -> finish()) .setOnDismissListener(dialog -> finish())

@ -81,13 +81,13 @@ public class TimePickerActivity extends InjectingAppCompatActivity implements Ti
} }
private void timeSet(final int hour, final int minute) { private void timeSet(final int hour, final int minute) {
setResult(RESULT_OK, new Intent() {{ Intent data = new Intent();
putExtra(EXTRA_TIMESTAMP, initial data.putExtra(EXTRA_TIMESTAMP, initial
.startOfDay() .startOfDay()
.withHourOfDay(hour) .withHourOfDay(hour)
.withMinuteOfHour(minute) .withMinuteOfHour(minute)
.getMillis()); .getMillis());
}}); setResult(RESULT_OK, data);
finish(); finish();
} }
} }

@ -69,15 +69,15 @@ public class DashClockExtension extends com.google.android.apps.dashclock.api.Da
if (count == 0) { if (count == 0) {
publish(null); publish(null);
} else { } else {
Intent clickIntent = new Intent(this, TaskListActivity.class);
clickIntent.putExtra(TaskListActivity.LOAD_FILTER, filterPreference);
ExtensionData extensionData = new ExtensionData() ExtensionData extensionData = new ExtensionData()
.visible(true) .visible(true)
.icon(R.drawable.ic_check_white_24dp) .icon(R.drawable.ic_check_white_24dp)
.status(Integer.toString(count)) .status(Integer.toString(count))
.expandedTitle(getString(R.string.task_count, count)) .expandedTitle(getString(R.string.task_count, count))
.expandedBody(filter.listingTitle) .expandedBody(filter.listingTitle)
.clickIntent(new Intent(this, TaskListActivity.class) {{ .clickIntent(clickIntent);
putExtra(TaskListActivity.LOAD_FILTER, filterPreference);
}});
if (count == 1) { if (count == 1) {
List<Task> tasks = taskDao.query(filter); List<Task> tasks = taskDao.query(filter);
if (!tasks.isEmpty()) { if (!tasks.isEmpty()) {

@ -44,9 +44,9 @@ public class DashClockSettings extends InjectingPreferenceActivity implements Pu
addPreferencesFromResource(R.xml.preferences_dashclock); addPreferencesFromResource(R.xml.preferences_dashclock);
findPreference(getString(R.string.p_dashclock_filter)).setOnPreferenceClickListener(preference -> { findPreference(getString(R.string.p_dashclock_filter)).setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(DashClockSettings.this, FilterSelectionActivity.class) {{ Intent intent = new Intent(DashClockSettings.this, FilterSelectionActivity.class);
putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true); intent.putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true);
}}, REQUEST_SELECT_FILTER); startActivityForResult(intent, REQUEST_SELECT_FILTER);
return false; return false;
}); });

@ -97,9 +97,9 @@ public class FileExplore extends InjectingAppCompatActivity {
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
Uri uri = data.getData(); Uri uri = data.getData();
final File file = new File(uri.getPath()); final File file = new File(uri.getPath());
setResult(Activity.RESULT_OK, new Intent() {{ Intent intent = new Intent();
putExtra(directoryMode ? EXTRA_DIRECTORY : EXTRA_FILE, file.getAbsolutePath()); intent.putExtra(directoryMode ? EXTRA_DIRECTORY : EXTRA_FILE, file.getAbsolutePath());
}}); setResult(Activity.RESULT_OK, intent);
} }
finish(); finish();
} else { } else {

@ -36,11 +36,11 @@ public class FilterProvider {
} }
public List<Filter> getFilters() { public List<Filter> getFilters() {
return new ArrayList<Filter>() {{ ArrayList<Filter> filters = new ArrayList<>();
addAll(builtInFilterExposer.getFilters()); filters.addAll(builtInFilterExposer.getFilters());
addAll(timerFilterExposer.getFilters()); filters.addAll(timerFilterExposer.getFilters());
addAll(customFilterExposer.getFilters()); filters.addAll(customFilterExposer.getFilters());
}}; return filters;
} }
public List<Filter> getTags() { public List<Filter> getTags() {

@ -50,9 +50,9 @@ public final class TaskerSettingsActivity extends AbstractFragmentPluginAppCompa
} }
findPreference(R.string.filter).setOnPreferenceClickListener(preference -> { findPreference(R.string.filter).setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(TaskerSettingsActivity.this, FilterSelectionActivity.class) {{ Intent intent = new Intent(TaskerSettingsActivity.this, FilterSelectionActivity.class);
putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true); intent.putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true);
}}, REQUEST_SELECT_FILTER); startActivityForResult(intent, REQUEST_SELECT_FILTER);
return false; return false;
}); });

@ -31,6 +31,16 @@ public class Geofence implements Serializable, Parcelable {
this.radius = radius; this.radius = radius;
} }
public Metadata toMetadata() {
Metadata metadata = new Metadata();
metadata.setKey(GeofenceFields.METADATA_KEY);
metadata.setValue(GeofenceFields.PLACE, name);
metadata.setValue(GeofenceFields.LATITUDE, latitude);
metadata.setValue(GeofenceFields.LONGITUDE, longitude);
metadata.setValue(GeofenceFields.RADIUS, radius);
return metadata;
}
public String getName() { public String getName() {
return name; return name;
} }

@ -2,7 +2,6 @@ package org.tasks.location;
import android.content.ContentValues; import android.content.ContentValues;
import com.google.common.base.Function;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Order; import com.todoroo.andlib.sql.Order;
@ -61,15 +60,9 @@ public class GeofenceService {
} }
public boolean synchronizeGeofences(final long taskId, Set<Geofence> geofences) { public boolean synchronizeGeofences(final long taskId, Set<Geofence> geofences) {
List<Metadata> metadata = newArrayList(transform(geofences, (Function<Geofence, Metadata>) geofence -> new Metadata() {{ List<Metadata> metadatas = newArrayList(transform(geofences, Geofence::toMetadata));
setKey(GeofenceFields.METADATA_KEY);
setValue(GeofenceFields.PLACE, geofence.getName()); boolean changed = synchronizeMetadata(taskId, metadatas, m -> geofenceApi.cancel(new Geofence(m)));
setValue(GeofenceFields.LATITUDE, geofence.getLatitude());
setValue(GeofenceFields.LONGITUDE, geofence.getLongitude());
setValue(GeofenceFields.RADIUS, geofence.getRadius());
}}));
boolean changed = synchronizeMetadata(taskId, metadata, m -> geofenceApi.cancel(new Geofence(m)));
if(changed) { if(changed) {
setupGeofences(taskId); setupGeofences(taskId);

@ -54,9 +54,9 @@ public class AppearancePreferences extends InjectingPreferenceActivity {
Filter filter = defaultFilterProvider.getDefaultFilter(); Filter filter = defaultFilterProvider.getDefaultFilter();
defaultList.setSummary(filter.listingTitle); defaultList.setSummary(filter.listingTitle);
defaultList.setOnPreferenceClickListener(preference -> { defaultList.setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(AppearancePreferences.this, FilterSelectionActivity.class) {{ Intent intent = new Intent(AppearancePreferences.this, FilterSelectionActivity.class);
putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true); intent.putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true);
}}, REQUEST_DEFAULT_LIST); startActivityForResult(intent, REQUEST_DEFAULT_LIST);
return true; return true;
}); });
} }
@ -70,9 +70,9 @@ public class AppearancePreferences extends InjectingPreferenceActivity {
@Override @Override
public void finish() { public void finish() {
setResult(RESULT_OK, new Intent() {{ Intent data = new Intent();
putExtras(result); data.putExtras(result);
}}); setResult(RESULT_OK, data);
super.finish(); super.finish();
} }

@ -31,9 +31,9 @@ public class BackupPreferences extends InjectingPreferenceActivity {
addPreferencesFromResource(R.xml.preferences_backup); addPreferencesFromResource(R.xml.preferences_backup);
findPreference(R.string.backup_BAc_import).setOnPreferenceClickListener(preference -> { findPreference(R.string.backup_BAc_import).setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(BackupPreferences.this, FileExplore.class) {{ Intent intent = new Intent(BackupPreferences.this, FileExplore.class);
putExtra(FileExplore.EXTRA_START_PATH, preferences.getBackupDirectory().getAbsolutePath()); intent.putExtra(FileExplore.EXTRA_START_PATH, preferences.getBackupDirectory().getAbsolutePath());
}}, REQUEST_PICKER); startActivityForResult(intent, REQUEST_PICKER);
return false; return false;
}); });

@ -83,25 +83,25 @@ public class BasicPreferences extends InjectingPreferenceActivity implements
Preference themePreference = findPreference(getString(R.string.p_theme)); Preference themePreference = findPreference(getString(R.string.p_theme));
themePreference.setSummary(themeBase.getName()); themePreference.setSummary(themeBase.getName());
themePreference.setOnPreferenceClickListener(preference -> { themePreference.setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(BasicPreferences.this, ColorPickerActivity.class) {{ Intent intent = new Intent(BasicPreferences.this, ColorPickerActivity.class);
putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.THEMES); intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.THEMES);
}}, REQUEST_THEME_PICKER); startActivityForResult(intent, REQUEST_THEME_PICKER);
return false; return false;
}); });
Preference colorPreference = findPreference(getString(R.string.p_theme_color)); Preference colorPreference = findPreference(getString(R.string.p_theme_color));
colorPreference.setSummary(themeColor.getName()); colorPreference.setSummary(themeColor.getName());
colorPreference.setOnPreferenceClickListener(preference -> { colorPreference.setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(BasicPreferences.this, ColorPickerActivity.class) {{ Intent intent = new Intent(BasicPreferences.this, ColorPickerActivity.class);
putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.COLORS); intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.COLORS);
}}, REQUEST_COLOR_PICKER); startActivityForResult(intent, REQUEST_COLOR_PICKER);
return false; return false;
}); });
Preference accentPreference = findPreference(getString(R.string.p_theme_accent)); Preference accentPreference = findPreference(getString(R.string.p_theme_accent));
accentPreference.setSummary(themeAccent.getName()); accentPreference.setSummary(themeAccent.getName());
accentPreference.setOnPreferenceClickListener(preference -> { accentPreference.setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(BasicPreferences.this, ColorPickerActivity.class) {{ Intent intent = new Intent(BasicPreferences.this, ColorPickerActivity.class);
putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.ACCENTS); intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.ACCENTS);
}}, REQUEST_ACCENT_PICKER); startActivityForResult(intent, REQUEST_ACCENT_PICKER);
return false; return false;
}); });
Preference languagePreference = findPreference(getString(R.string.p_language)); Preference languagePreference = findPreference(getString(R.string.p_language));
@ -266,9 +266,11 @@ public class BasicPreferences extends InjectingPreferenceActivity implements
private void showRestartDialog() { private void showRestartDialog() {
dialogBuilder.newDialog() dialogBuilder.newDialog()
.setMessage(R.string.restart_required) .setMessage(R.string.restart_required)
.setPositiveButton(R.string.restart_now, (dialogInterface, i) -> ProcessPhoenix.triggerRebirth(BasicPreferences.this, new Intent(BasicPreferences.this, TaskListActivity.class) {{ .setPositiveButton(R.string.restart_now, (dialogInterface, i) -> {
putExtra(TaskListActivity.OPEN_FILTER, (Filter) null); Intent nextIntent = new Intent(BasicPreferences.this, TaskListActivity.class);
}})) nextIntent.putExtra(TaskListActivity.OPEN_FILTER, (Filter) null);
ProcessPhoenix.triggerRebirth(BasicPreferences.this, nextIntent);
})
.setNegativeButton(R.string.restart_later, null) .setNegativeButton(R.string.restart_later, null)
.show(); .show();
} }
@ -281,9 +283,9 @@ public class BasicPreferences extends InjectingPreferenceActivity implements
@Override @Override
public void finish() { public void finish() {
setResult(Activity.RESULT_OK, new Intent() {{ Intent data = new Intent();
putExtras(result); data.putExtras(result);
}}); setResult(Activity.RESULT_OK, data);
super.finish(); super.finish();
} }

@ -55,9 +55,9 @@ public class DateShortcutPreferences extends InjectingPreferenceActivity impleme
preference.setOnPreferenceChangeListener(this); preference.setOnPreferenceChangeListener(this);
preference.setOnPreferenceClickListener(ignored -> { preference.setOnPreferenceClickListener(ignored -> {
final DateTime current = new DateTime().withMillisOfDay(preference.getMillisOfDay()); final DateTime current = new DateTime().withMillisOfDay(preference.getMillisOfDay());
startActivityForResult(new Intent(DateShortcutPreferences.this, TimePickerActivity.class) {{ Intent intent = new Intent(DateShortcutPreferences.this, TimePickerActivity.class);
putExtra(TimePickerActivity.EXTRA_TIMESTAMP, current.getMillis()); intent.putExtra(TimePickerActivity.EXTRA_TIMESTAMP, current.getMillis());
}}, requestCode); startActivityForResult(intent, requestCode);
return true; return true;
}); });
} }

@ -31,9 +31,9 @@ public class Device {
} }
public boolean hasGallery() { public boolean hasGallery() {
return new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI) {{ Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
setType("image/*"); intent.setType("image/*");
}}.resolveActivity(context.getPackageManager()) != null; return intent.resolveActivity(context.getPackageManager()) != null;
} }
public boolean supportsLocationServices() { public boolean supportsLocationServices() {

@ -21,11 +21,10 @@ public class HelpAndFeedbackActivity extends InjectingPreferenceActivity {
addPreferencesFromResource(R.xml.preferences_help); addPreferencesFromResource(R.xml.preferences_help);
findPreference(getString(R.string.contact_developer)).setIntent( Intent mailto = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "Tasks Support <support@tasks.org>", null));
new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "Tasks Support <support@tasks.org>", null)) {{ mailto.putExtra(Intent.EXTRA_SUBJECT, "Tasks Feedback");
putExtra(Intent.EXTRA_SUBJECT, "Tasks Feedback"); mailto.putExtra(Intent.EXTRA_TEXT, device.getDebugInfo());
putExtra(Intent.EXTRA_TEXT, device.getDebugInfo()); findPreference(getString(R.string.contact_developer)).setIntent(mailto);
}});
if (!getResources().getBoolean(R.bool.google_play_store_available)) { if (!getResources().getBoolean(R.bool.google_play_store_available)) {
remove(R.string.rate_tasks); remove(R.string.rate_tasks);
} }

@ -86,11 +86,10 @@ public class MissedCallActivity extends InjectingAppCompatActivity implements Mi
@Override @Override
public void callLater() { public void callLater() {
Task task = new Task() {{ Task task = new Task();
setTitle(TextUtils.isEmpty(name) task.setTitle(TextUtils.isEmpty(name)
? getString(R.string.MCA_task_title_no_name, number) ? getString(R.string.MCA_task_title_no_name, number)
: getString(R.string.MCA_task_title_name, name, number)); : getString(R.string.MCA_task_title_name, name, number));
}};
taskService.save(task); taskService.save(task);
TaskIntents TaskIntents
.getEditTaskStack(this, null, task.getId()) .getEditTaskStack(this, null, task.getId())

@ -12,6 +12,8 @@ import org.tasks.notifications.NotificationManager;
import javax.inject.Inject; import javax.inject.Inject;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
public class NotificationActivity extends InjectingAppCompatActivity implements NotificationDialog.NotificationHandler { public class NotificationActivity extends InjectingAppCompatActivity implements NotificationDialog.NotificationHandler {
private static final String FRAG_TAG_NOTIFICATION_FRAGMENT = "frag_tag_notification_fragment"; private static final String FRAG_TAG_NOTIFICATION_FRAGMENT = "frag_tag_notification_fragment";
@ -72,10 +74,10 @@ public class NotificationActivity extends InjectingAppCompatActivity implements
@Override @Override
public void snooze() { public void snooze() {
finish(); finish();
startActivity(new Intent(this, SnoozeActivity.class) {{ Intent intent = new Intent(this, SnoozeActivity.class);
setFlags(FLAG_ACTIVITY_NEW_TASK); intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
putExtra(SnoozeActivity.EXTRA_TASK_ID, taskId); intent.putExtra(SnoozeActivity.EXTRA_TASK_ID, taskId);
}}); startActivity(intent);
} }
@Override @Override

@ -96,9 +96,9 @@ public class SnoozeActivity extends InjectingAppCompatActivity implements Snooze
public void pickDateTime() { public void pickDateTime() {
pickingDateTime = true; pickingDateTime = true;
startActivityForResult(new Intent(this, DateAndTimePickerActivity.class) {{ Intent intent = new Intent(this, DateAndTimePickerActivity.class);
putExtra(DateAndTimePickerActivity.EXTRA_TIMESTAMP, new DateTime().plusMinutes(30).getMillis()); intent.putExtra(DateAndTimePickerActivity.EXTRA_TIMESTAMP, new DateTime().plusMinutes(30).getMillis());
}}, REQUEST_DATE_TIME); startActivityForResult(intent, REQUEST_DATE_TIME);
} }
@Override @Override

@ -43,10 +43,9 @@ public class CalendarNotificationIntentService extends RecurringIntervalIntentSe
long end = now + TimeUnit.DAYS.toMillis(1); long end = now + TimeUnit.DAYS.toMillis(1);
for (final AndroidCalendarEvent event : calendarEventProvider.getEventsBetween(now, end)) { for (final AndroidCalendarEvent event : calendarEventProvider.getEventsBetween(now, end)) {
Intent eventAlarm = new Intent(context, CalendarAlarmReceiver.class) {{ Intent eventAlarm = new Intent(context, CalendarAlarmReceiver.class);
setAction(CalendarAlarmReceiver.BROADCAST_CALENDAR_REMINDER); eventAlarm.setAction(CalendarAlarmReceiver.BROADCAST_CALENDAR_REMINDER);
setData(Uri.parse(URI_PREFIX + "://" + event.getId())); eventAlarm.setData(Uri.parse(URI_PREFIX + "://" + event.getId()));
}};
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
CalendarAlarmReceiver.REQUEST_CODE_CAL_REMINDER, eventAlarm, PendingIntent.FLAG_CANCEL_CURRENT); CalendarAlarmReceiver.REQUEST_CODE_CAL_REMINDER, eventAlarm, PendingIntent.FLAG_CANCEL_CURRENT);

@ -212,9 +212,9 @@ public class DeadlineControlSet extends TaskEditControlFragment {
setDate(today.plusWeeks(1).getMillis()); setDate(today.plusWeeks(1).getMillis());
break; break;
case 4: case 4:
startActivityForResult(new Intent(context, DatePickerActivity.class) {{ Intent intent = new Intent(context, DatePickerActivity.class);
putExtra(DatePickerActivity.EXTRA_TIMESTAMP, date); intent.putExtra(DatePickerActivity.EXTRA_TIMESTAMP, date);
}}, REQUEST_DATE); startActivityForResult(intent, REQUEST_DATE);
updateDueDateOptions(); updateDueDateOptions();
break; break;
} }
@ -241,9 +241,9 @@ public class DeadlineControlSet extends TaskEditControlFragment {
setTime(dateShortcutNight); setTime(dateShortcutNight);
break; break;
case 6: case 6:
startActivityForResult(new Intent(context, TimePickerActivity.class) {{ Intent intent = new Intent(context, TimePickerActivity.class);
putExtra(TimePickerActivity.EXTRA_TIMESTAMP, getDueDateTime()); intent.putExtra(TimePickerActivity.EXTRA_TIMESTAMP, getDueDateTime());
}}, REQUEST_TIME); startActivityForResult(intent, REQUEST_TIME);
updateDueTimeOptions(); updateDueTimeOptions();
break; break;
} }

@ -31,9 +31,9 @@ public class ShortcutConfigActivity extends InjectingAppCompatActivity {
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
startActivityForResult(new Intent(this, FilterSelectionActivity.class) {{ Intent intent = new Intent(this, FilterSelectionActivity.class);
putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true); intent.putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true);
}}, REQUEST_FILTER); startActivityForResult(intent, REQUEST_FILTER);
} }
@Override @Override

@ -65,9 +65,9 @@ public class WidgetConfigActivity extends InjectingPreferenceActivity implements
return; return;
} }
widgetPreferences = new WidgetPreferences(this, preferences, appWidgetId); widgetPreferences = new WidgetPreferences(this, preferences, appWidgetId);
setResult(RESULT_OK, new Intent() {{ Intent data = new Intent();
putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); data.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
}}); setResult(RESULT_OK, data);
setupCheckbox(R.string.p_widget_show_due_date); setupCheckbox(R.string.p_widget_show_due_date);
setupCheckbox(R.string.p_widget_show_checkboxes); setupCheckbox(R.string.p_widget_show_checkboxes);
@ -76,25 +76,25 @@ public class WidgetConfigActivity extends InjectingPreferenceActivity implements
showSettings.setDependency(showHeader.getKey()); showSettings.setDependency(showHeader.getKey());
findPreference(R.string.p_widget_filter).setOnPreferenceClickListener(preference -> { findPreference(R.string.p_widget_filter).setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(WidgetConfigActivity.this, FilterSelectionActivity.class) {{ Intent intent = new Intent(WidgetConfigActivity.this, FilterSelectionActivity.class);
putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true); intent.putExtra(FilterSelectionActivity.EXTRA_RETURN_FILTER, true);
}}, REQUEST_FILTER); startActivityForResult(intent, REQUEST_FILTER);
return false; return false;
}); });
findPreference(R.string.p_widget_theme).setOnPreferenceClickListener(preference -> { findPreference(R.string.p_widget_theme).setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(WidgetConfigActivity.this, ColorPickerActivity.class) {{ Intent intent = new Intent(WidgetConfigActivity.this, ColorPickerActivity.class);
putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.WIDGET_BACKGROUND); intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.WIDGET_BACKGROUND);
}}, REQUEST_THEME_SELECTION); startActivityForResult(intent, REQUEST_THEME_SELECTION);
return false; return false;
}); });
Preference colorPreference = findPreference(R.string.p_widget_color); Preference colorPreference = findPreference(R.string.p_widget_color);
colorPreference.setDependency(showHeader.getKey()); colorPreference.setDependency(showHeader.getKey());
colorPreference.setOnPreferenceClickListener(preference -> { colorPreference.setOnPreferenceClickListener(preference -> {
startActivityForResult(new Intent(WidgetConfigActivity.this, ColorPickerActivity.class) {{ Intent intent = new Intent(WidgetConfigActivity.this, ColorPickerActivity.class);
putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.COLORS); intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.COLORS);
}}, REQUEST_COLOR_SELECTION); startActivityForResult(intent, REQUEST_COLOR_SELECTION);
return false; return false;
}); });
@ -156,10 +156,10 @@ public class WidgetConfigActivity extends InjectingPreferenceActivity implements
broadcaster.refresh(); broadcaster.refresh();
// force update after setting preferences // force update after setting preferences
sendBroadcast(new Intent(this, TasksWidget.class) {{ Intent intent = new Intent(this, TasksWidget.class);
setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{appWidgetId}); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{appWidgetId});
}}); sendBroadcast(intent);
} }
@Override @Override

Loading…
Cancel
Save