Remove double brace initializers

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

@ -12,7 +12,7 @@ buildscript {
dependencies {
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'
}
}

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

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

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

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

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

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

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

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

@ -87,13 +87,13 @@ public class CalendarAlarmReceiver extends InjectingBroadcastReceiver {
}
if (shouldShowReminder && isMeeting(event)) {
context.startActivity(new Intent(context, CalendarReminderActivity.class) {{
putExtra(CalendarReminderActivity.TOKEN_EVENT_ID, eventId);
putExtra(CalendarReminderActivity.TOKEN_EVENT_NAME, event.getTitle());
putExtra(CalendarReminderActivity.TOKEN_EVENT_END_TIME, event.getEnd());
putExtra(CalendarReminderActivity.TOKEN_FROM_POSTPONE, fromPostpone);
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
}});
Intent intent = new Intent(context, CalendarReminderActivity.class);
intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_ID, eventId);
intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_NAME, event.getTitle());
intent.putExtra(CalendarReminderActivity.TOKEN_EVENT_END_TIME, event.getEnd());
intent.putExtra(CalendarReminderActivity.TOKEN_FROM_POSTPONE, fromPostpone);
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) {
startActivity(new Intent(CalendarReminderActivity.this, TaskListActivity.class) {{
putExtra(TaskListActivity.TOKEN_CREATE_NEW_LIST_NAME, name);
}});
Intent intent = new Intent(CalendarReminderActivity.this, TaskListActivity.class);
intent.putExtra(TaskListActivity.TOKEN_CREATE_NEW_LIST_NAME, name);
startActivity(intent);
dismissButton.performClick(); // finish with animation
}

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

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

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

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

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

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

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

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

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

@ -45,6 +45,8 @@ import javax.inject.Inject;
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.todoroo.andlib.utility.AndroidUtilities.atLeastJellybean;
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) {
final String title = context.getString(R.string.missed_call, TextUtils.isEmpty(name) ? number : name);
Intent missedCallDialog = new Intent(context, MissedCallActivity.class) {{
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
putExtra(MissedCallActivity.EXTRA_NUMBER, number);
putExtra(MissedCallActivity.EXTRA_NAME, name);
putExtra(MissedCallActivity.EXTRA_TITLE, title);
}};
Intent missedCallDialog = new Intent(context, MissedCallActivity.class);
missedCallDialog.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
missedCallDialog.putExtra(MissedCallActivity.EXTRA_NUMBER, number);
missedCallDialog.putExtra(MissedCallActivity.EXTRA_NAME, name);
missedCallDialog.putExtra(MissedCallActivity.EXTRA_TITLE, title);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_check_white_24dp)
@ -104,20 +105,19 @@ public class Notifier {
}
if (preferences.useNotificationActions()) {
Intent callNow = new Intent(context, MissedCallActivity.class) {{
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
putExtra(MissedCallActivity.EXTRA_NUMBER, number);
putExtra(MissedCallActivity.EXTRA_NAME, name);
putExtra(MissedCallActivity.EXTRA_TITLE, title);
putExtra(MissedCallActivity.EXTRA_CALL_NOW, true);
}};
Intent callLater = new Intent(context, MissedCallActivity.class) {{
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
putExtra(MissedCallActivity.EXTRA_NUMBER, number);
putExtra(MissedCallActivity.EXTRA_NAME, name);
putExtra(MissedCallActivity.EXTRA_TITLE, title);
putExtra(MissedCallActivity.EXTRA_CALL_LATER, true);
}};
Intent callNow = new Intent(context, MissedCallActivity.class);
callNow.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
callNow.putExtra(MissedCallActivity.EXTRA_NUMBER, number);
callNow.putExtra(MissedCallActivity.EXTRA_NAME, name);
callNow.putExtra(MissedCallActivity.EXTRA_TITLE, title);
callNow.putExtra(MissedCallActivity.EXTRA_CALL_NOW, true);
Intent callLater = new Intent(context, MissedCallActivity.class);
callLater.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
callLater.putExtra(MissedCallActivity.EXTRA_NUMBER, number);
callLater.putExtra(MissedCallActivity.EXTRA_NAME, name);
callLater.putExtra(MissedCallActivity.EXTRA_TITLE, title);
callLater.putExtra(MissedCallActivity.EXTRA_CALL_LATER, true);
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_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);
PendingIntent pendingIntent = PendingIntent.getActivity(context, (title + query).hashCode(), new Intent(context, TaskListActivity.class) {{
setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
putExtra(TaskListActivity.OPEN_FILTER, filter);
}}, PendingIntent.FLAG_UPDATE_CURRENT);
Intent intent = new Intent(context, TaskListActivity.class);
intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
intent.putExtra(TaskListActivity.OPEN_FILTER, filter);
PendingIntent pendingIntent = PendingIntent.getActivity(context, (title + query).hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_check_white_24dp)
@ -244,12 +244,11 @@ public class Notifier {
final String text = context.getString(R.string.app_name);
final Intent intent = new Intent(context, NotificationActivity.class) {{
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
setAction("NOTIFY" + id); //$NON-NLS-1$
putExtra(NotificationActivity.EXTRA_TASK_ID, id);
putExtra(NotificationActivity.EXTRA_TITLE, taskTitle);
}};
final Intent intent = new Intent(context, NotificationActivity.class);
intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
intent.setAction("NOTIFY" + id); //$NON-NLS-1$
intent.putExtra(NotificationActivity.EXTRA_TASK_ID, id);
intent.putExtra(NotificationActivity.EXTRA_TITLE, taskTitle);
// don't ring multiple times if random reminder
if (type == ReminderService.TYPE_RANDOM) {
@ -267,30 +266,30 @@ public class Notifier {
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(taskDescription));
}
if (preferences.useNotificationActions()) {
PendingIntent completeIntent = PendingIntent.getBroadcast(context, (int) id, new Intent(context, CompleteTaskReceiver.class) {{
putExtra(CompleteTaskReceiver.TASK_ID, id);
}}, PendingIntent.FLAG_UPDATE_CURRENT);
Intent completeIntent = new Intent(context, CompleteTaskReceiver.class);
completeIntent.putExtra(CompleteTaskReceiver.TASK_ID, id);
PendingIntent completePendingIntent = PendingIntent.getBroadcast(context, (int) id, completeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
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) {{
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
putExtra(SnoozeActivity.EXTRA_TASK_ID, id);
}}, PendingIntent.FLAG_UPDATE_CURRENT);
Intent snoozeIntent = new Intent(context, SnoozeActivity.class);
snoozeIntent.setFlags(FLAG_ACTIVITY_NEW_TASK);
snoozeIntent.putExtra(SnoozeActivity.EXTRA_TASK_ID, id);
PendingIntent snoozePendingIntent = PendingIntent.getActivity(context, (int) id, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
wearableExtender.addAction(completeAction);
for (final SnoozeOption snoozeOption : SnoozeDialog.getSnoozeOptions(preferences)) {
final long timestamp = snoozeOption.getDateTime().getMillis();
PendingIntent snoozeIntent = PendingIntent.getActivity(context, (int) id, new Intent(context, SnoozeActivity.class) {{
setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
setAction(String.format("snooze-%s-%s", id, timestamp));
putExtra(SnoozeActivity.EXTRA_TASK_ID, id);
putExtra(SnoozeActivity.EXTRA_SNOOZE_TIME, timestamp);
}}, PendingIntent.FLAG_UPDATE_CURRENT);
Intent wearableIntent = new Intent(context, SnoozeActivity.class);
wearableIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
wearableIntent.setAction(String.format("snooze-%s-%s", id, timestamp));
wearableIntent.putExtra(SnoozeActivity.EXTRA_TASK_ID, id);
wearableIntent.putExtra(SnoozeActivity.EXTRA_SNOOZE_TIME, timestamp);
PendingIntent wearablePendingIntent = PendingIntent.getActivity(context, (int) id, wearableIntent, PendingIntent.FLAG_UPDATE_CURRENT);
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());
}

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -31,6 +31,16 @@ public class Geofence implements Serializable, Parcelable {
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() {
return name;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save