mirror of https://github.com/tasks/tasks
Set default google task list
parent
3cc6e7a527
commit
2e3d422509
@ -0,0 +1,8 @@
|
|||||||
|
package org.tasks.injection;
|
||||||
|
|
||||||
|
import dagger.Subcomponent;
|
||||||
|
|
||||||
|
@Subcomponent(modules = DialogFragmentModule.class)
|
||||||
|
public interface DialogFragmentComponent extends BaseDialogFragmentComponent {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package org.tasks.injection;
|
||||||
|
|
||||||
|
import dagger.Subcomponent;
|
||||||
|
|
||||||
|
@Subcomponent(modules = DialogFragmentModule.class)
|
||||||
|
public interface DialogFragmentComponent extends BaseDialogFragmentComponent {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
package org.tasks.activities;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.todoroo.astrid.gtasks.GtasksList;
|
||||||
|
import com.todoroo.astrid.gtasks.GtasksListService;
|
||||||
|
|
||||||
|
import org.tasks.dialogs.DialogBuilder;
|
||||||
|
import org.tasks.injection.DialogFragmentComponent;
|
||||||
|
import org.tasks.injection.InjectingDialogFragment;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Lists.transform;
|
||||||
|
|
||||||
|
public class GoogleTaskListSelectionDialog extends InjectingDialogFragment {
|
||||||
|
|
||||||
|
public interface GoogleTaskListSelectionHandler {
|
||||||
|
void selectedList(GtasksList list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject DialogBuilder dialogBuilder;
|
||||||
|
@Inject GtasksListService gtasksListService;
|
||||||
|
|
||||||
|
private GoogleTaskListSelectionHandler handler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
final List<GtasksList> lists = gtasksListService.getLists();
|
||||||
|
List<String> listNames = transform(lists, new Function<GtasksList, String>() {
|
||||||
|
@Override
|
||||||
|
public String apply(GtasksList gtasksList) {
|
||||||
|
return gtasksList.getName();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return dialogBuilder.newDialog()
|
||||||
|
.setItems(listNames.toArray(new String[listNames.size()]), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
handler.selectedList(lists.get(which));
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
|
||||||
|
handler = (GoogleTaskListSelectionHandler) activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void inject(DialogFragmentComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package org.tasks.injection;
|
||||||
|
|
||||||
|
import org.tasks.activities.GoogleTaskListSelectionDialog;
|
||||||
|
|
||||||
|
import dagger.Subcomponent;
|
||||||
|
|
||||||
|
@Subcomponent(modules = DialogFragmentModule.class)
|
||||||
|
public interface DialogFragmentComponent extends BaseDialogFragmentComponent {
|
||||||
|
|
||||||
|
void inject(GoogleTaskListSelectionDialog googleTaskListSelectionDialog);
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,20 +1,16 @@
|
|||||||
package org.tasks.injection;
|
package org.tasks.injection;
|
||||||
|
|
||||||
import org.tasks.dialogs.SortDialog;
|
|
||||||
import org.tasks.dialogs.ThemePickerDialog;
|
|
||||||
import org.tasks.widget.WidgetConfigDialog;
|
|
||||||
|
|
||||||
import org.tasks.activities.CalendarSelectionDialog;
|
import org.tasks.activities.CalendarSelectionDialog;
|
||||||
import org.tasks.dialogs.AccountSelectionDialog;
|
import org.tasks.dialogs.AccountSelectionDialog;
|
||||||
import org.tasks.dialogs.AddAttachmentDialog;
|
import org.tasks.dialogs.AddAttachmentDialog;
|
||||||
|
import org.tasks.dialogs.SortDialog;
|
||||||
|
import org.tasks.dialogs.ThemePickerDialog;
|
||||||
import org.tasks.reminders.MissedCallDialog;
|
import org.tasks.reminders.MissedCallDialog;
|
||||||
import org.tasks.reminders.NotificationDialog;
|
import org.tasks.reminders.NotificationDialog;
|
||||||
import org.tasks.reminders.SnoozeDialog;
|
import org.tasks.reminders.SnoozeDialog;
|
||||||
|
import org.tasks.widget.WidgetConfigDialog;
|
||||||
|
|
||||||
import dagger.Subcomponent;
|
public interface BaseDialogFragmentComponent {
|
||||||
|
|
||||||
@Subcomponent(modules = DialogFragmentModule.class)
|
|
||||||
public interface DialogFragmentComponent {
|
|
||||||
void inject(NotificationDialog notificationDialog);
|
void inject(NotificationDialog notificationDialog);
|
||||||
|
|
||||||
void inject(MissedCallDialog missedCallDialog);
|
void inject(MissedCallDialog missedCallDialog);
|
||||||
Loading…
Reference in New Issue