GCalControlSet extends TaskEditControlSetBase

pull/281/head
Alex Baker 10 years ago
parent 5b5b7342ba
commit b76c4ec065

@ -361,7 +361,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
RepeatControlSet repeatControls = new RepeatControlSet(preferences, getActivity());
controlSetMap.put(getString(R.string.TEA_ctrl_repeat_pref), repeatControls);
GCalControlSet gcalControl = new GCalControlSet(preferences, gcalHelper, getActivity());
GCalControlSet gcalControl = new GCalControlSet(gcalHelper, getActivity());
controlSetMap.put(getString(R.string.TEA_ctrl_gcal), gcalControl);
// The deadline control set contains the repeat controls and the

@ -17,18 +17,16 @@ import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.ui.PopupControlSet;
import com.todoroo.astrid.helper.TaskEditControlSetBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import org.tasks.preferences.ActivityPreferences;
import java.util.ArrayList;
import java.util.Collections;
@ -39,7 +37,7 @@ import java.util.Collections;
* @author Tim Su <tim@todoroo.com>
*
*/
public class GCalControlSet extends PopupControlSet {
public class GCalControlSet extends TaskEditControlSetBase {
private static final Logger log = LoggerFactory.getLogger(GCalControlSet.class);
private static final int title = R.string.gcal_TEA_addToCalendar_label;
@ -53,19 +51,28 @@ public class GCalControlSet extends PopupControlSet {
private final GCalHelper.CalendarResult calendars;
private boolean hasEvent = false;
private Spinner calendarSelector;
private TextView calendar;
public GCalControlSet(ActivityPreferences preferences, GCalHelper gcal, final Activity activity) {
super(preferences, activity, R.layout.control_set_gcal, R.layout.control_set_gcal_display, title);
public GCalControlSet(GCalHelper gcal, final Activity activity) {
super(activity, R.layout.control_set_gcal_display);
this.gcal = gcal;
this.calendars = gcal.getCalendars();
getDialogView(); // Hack to force initialized
}
@Override
protected void afterInflate() {
((LinearLayout) getView()).addView(getDialogView()); //hack for spinner
this.calendarSelector = (Spinner) getDialogView().findViewById(R.id.calendars);
calendarSelector = (Spinner) getView().findViewById(R.id.calendars);
calendar = (TextView) getView().findViewById(R.id.calendar_display_which);
calendar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!hasEvent) {
calendarSelector.performClick();
} else {
viewCalendarEvent();
}
}
});
ArrayList<String> items = new ArrayList<>();
Collections.addAll(items, calendars.calendars);
items.add(0, activity.getString(R.string.gcal_TEA_nocal));
@ -79,8 +86,7 @@ public class GCalControlSet extends PopupControlSet {
resetCalendarSelector();
calendarSelector.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
refreshDisplayView();
}
@ -217,13 +223,11 @@ public class GCalControlSet extends PopupControlSet {
activity.startActivity(intent);
}
@Override
protected void refreshDisplayView() {
TextView calendar = (TextView) getView().findViewById(R.id.calendar_display_which);
private void refreshDisplayView() {
calendar.setTextColor(themeColor);
if (initialized) {
if (hasEvent) {
calendar.setText(R.string.gcal_TEA_has_event);
calendar.setText(R.string.gcal_TEA_showCalendar_label);
} else if (calendarSelector.getSelectedItemPosition() != 0) {
calendar.setText((String)calendarSelector.getSelectedItem());
} else {
@ -233,7 +237,7 @@ public class GCalControlSet extends PopupControlSet {
} else {
int index = calendars.defaultIndex;
if (!TextUtils.isEmpty(model.getCalendarURI())) {
calendar.setText(R.string.gcal_TEA_has_event);
calendar.setText(R.string.gcal_TEA_showCalendar_label);
} else if (index >= 0 && index < calendars.calendars.length) {
calendar.setText(calendars.calendars[index]);
} else {
@ -242,21 +246,4 @@ public class GCalControlSet extends PopupControlSet {
}
}
}
@Override
protected OnClickListener getDisplayClickListener() {
return new OnClickListener() {
@Override
public void onClick(View v) {
if (calendarSelector == null) {
getDialogView(); // Force load
}
if (!hasEvent) {
calendarSelector.performClick();
} else {
viewCalendarEvent();
}
}
};
}
}

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="0dip"
android:layout_height="0dip">
<!-- calendar integration -->
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Spinner
android:id="@+id/calendars"
android:layout_width="0dip"
android:layout_height="0dip"/>
<Button
android:id="@+id/view_calendar_event"
android:layout_width="0dip"
android:layout_height="0dip"
android:text="@string/gcal_TEA_showCalendar_label"/>
</LinearLayout>
</LinearLayout>

@ -14,29 +14,39 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:padding="@dimen/task_edit_drawable_padding"/>
android:padding="@dimen/task_edit_drawable_padding" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/calendar_display_which"
android:layout_width="match_parent"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:gravity="start"
android:textColor="?attr/asThemeTextColor"
android:textSize="@dimen/task_edit_text_size"
android:orientation="horizontal"
android:paddingTop="@dimen/task_edit_padding_top_bottom"
android:paddingBottom="@dimen/task_edit_padding_top_bottom"
android:layout_marginTop="@dimen/task_edit_padding_top_bottom"
android:layout_marginBottom="@dimen/task_edit_padding_top_bottom"
android:paddingRight="@dimen/task_edit_padding_right"
android:paddingEnd="@dimen/task_edit_padding_right"/>
android:layout_marginBottom="@dimen/task_edit_padding_top_bottom">
<include layout="@layout/task_edit_divider"/>
<TextView
android:id="@+id/calendar_display_which"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:gravity="start"
android:textColor="?attr/asThemeTextColor"
android:textSize="@dimen/task_edit_text_size" />
<Spinner
android:id="@+id/calendars"
android:layout_width="0dip"
android:layout_height="0dip" />
</LinearLayout>
<include layout="@layout/task_edit_divider" />
</LinearLayout>

@ -286,7 +286,6 @@
<string name="gcal_TEA_showCalendar_label">Добави събитие към календара</string>
<string name="gcal_TEA_nocal">Не добавяй</string>
<string name="gcal_TEA_none_selected">Към календара?</string>
<string name="gcal_TEA_has_event">Събитие обаждане</string>
<string name="gcal_completed_title">%s (завършено)</string>
<string name="gcal_GCP_default">Календар по подразбиране</string>
<string name="CFC_gtasks_list_text">В списък: ?</string>

@ -191,7 +191,6 @@
<string name="gcal_TEA_showCalendar_label">Obrir Event del Calendari</string>
<string name="gcal_TEA_nocal">No afegir</string>
<string name="gcal_TEA_none_selected">Al calenari?</string>
<string name="gcal_TEA_has_event">Event del calendari</string>
<string name="gcal_completed_title">%s (completada)</string>
<string name="gcal_GCP_default">Calendari per defecte</string>
<string name="gtasks_FEx_title">Tasques de Google:%s</string>

@ -271,7 +271,6 @@
<string name="gcal_TEA_showCalendar_label">Otevřít událost v kalendáři</string>
<string name="gcal_TEA_nocal">Nepřidávat</string>
<string name="gcal_TEA_none_selected">Přidat do kal.</string>
<string name="gcal_TEA_has_event">Událost v kal.</string>
<string name="gcal_completed_title">%s (dokončeno)</string>
<string name="gcal_GCP_default">Výchozí kalendář</string>
<string name="gtasks_FEx_title">Google úkoly: %s</string>

@ -157,7 +157,6 @@
<string name="gcal_TEA_showCalendar_label">Åbn kalender-begivenhed</string>
<string name="gcal_TEA_nocal">Tilføj ikke</string>
<string name="gcal_TEA_none_selected">Til kalender?</string>
<string name="gcal_TEA_has_event">Cal-begivenhed</string>
<string name="gcal_completed_title">%s (fuldført)</string>
<string name="gcal_GCP_default">Standardkalender</string>
<string name="gtasks_FEx_title">Google Opgaver: %s</string>

@ -279,7 +279,6 @@
<string name="gcal_TEA_showCalendar_label">Öffne Kalendereintrag</string>
<string name="gcal_TEA_nocal">Nicht eintragen</string>
<string name="gcal_TEA_none_selected">In den Kalender?</string>
<string name="gcal_TEA_has_event">Kalendereintrag</string>
<string name="gcal_completed_title">%s (abgeschlossen)</string>
<string name="gcal_GCP_default">Standardkalender</string>
<string name="CFC_gtasks_list_text">In der Liste: ?</string>

@ -274,7 +274,6 @@
<string name="gcal_TEA_showCalendar_label">Άνοιγμα event ημερολογίου</string>
<string name="gcal_TEA_nocal">Μήν προσθέσετε</string>
<string name="gcal_TEA_none_selected">Προς ημερολόγιο?</string>
<string name="gcal_TEA_has_event">Event ημερολογίου</string>
<string name="gcal_completed_title">%s (έχει ολοκληρωθεί)</string>
<string name="gcal_GCP_default">Προεπιλεγμένο ημερολόγιο</string>
<string name="gtasks_FEx_title">Καθήκοντα Google: %s</string>

@ -276,7 +276,6 @@
<string name="gcal_TEA_showCalendar_label">Abrir evento del calendario</string>
<string name="gcal_TEA_nocal">No agregar</string>
<string name="gcal_TEA_none_selected">¿Al calendario?</string>
<string name="gcal_TEA_has_event">Evento de llamada</string>
<string name="gcal_completed_title">%s (completado)</string>
<string name="gcal_GCP_default">Calendario predeterminado</string>
<string name="CFC_gtasks_list_text">En la Lista: ?</string>

@ -68,7 +68,6 @@
<string name="gcal_TEA_showCalendar_label">Avaa tapahtumakalenteri</string>
<string name="gcal_TEA_nocal">Älä lisää</string>
<string name="gcal_TEA_none_selected">Kalenteriin?</string>
<string name="gcal_TEA_has_event">Kalenteri tapahtuma</string>
<string name="gcal_completed_title">%s (valmistunut)</string>
<string name="gcal_GCP_default">Oletus kalenteri</string>
<string name="gtasks_FEx_title">Google tehtävä: %s</string>

@ -273,7 +273,6 @@
<string name="gcal_TEA_showCalendar_label">Ouvrir l\'événement de l\'agenda</string>
<string name="gcal_TEA_nocal">Ne pas ajouter</string>
<string name="gcal_TEA_none_selected">Ajouter au calendrier?</string>
<string name="gcal_TEA_has_event">Evènement d\'appel</string>
<string name="gcal_completed_title">%s (complété)</string>
<string name="gcal_GCP_default">Agenda par défaut</string>
<string name="gtasks_FEx_title">Google Tâches : %s</string>

@ -248,7 +248,6 @@ Se visualizzi questo errore più volte, ti consigliamo di cancellare tutti i dat
<string name="gcal_TEA_addToCalendar_label">Aggiungi al Calendario</string>
<string name="gcal_TEA_showCalendar_label">Apri Calendario Eventi</string>
<string name="gcal_TEA_nocal">Non aggiungere</string>
<string name="gcal_TEA_has_event">Evento del calendario</string>
<string name="gcal_completed_title">%s (completato)</string>
<string name="gcal_GCP_default">Calendario Predefinito</string>
<string name="CFC_gtasks_list_text">Nella lista: ?</string>

@ -275,7 +275,6 @@
<string name="gcal_TEA_showCalendar_label">פתח אירוע ביומן</string>
<string name="gcal_TEA_nocal">אל תוסיף</string>
<string name="gcal_TEA_none_selected">ליומן?</string>
<string name="gcal_TEA_has_event">אירוע יומן</string>
<string name="gcal_completed_title">%s (בוצעה)</string>
<string name="gcal_GCP_default">ברירת מחדל ליומן</string>
<string name="gtasks_FEx_title">״משימות גוגל״: %s</string>

@ -283,7 +283,6 @@
<string name="gcal_TEA_showCalendar_label">カレンダーのイベントを開く</string>
<string name="gcal_TEA_nocal">追加しないで</string>
<string name="gcal_TEA_none_selected">カレンダーに?</string>
<string name="gcal_TEA_has_event">カレンダーイベント</string>
<string name="gcal_completed_title">%s完了</string>
<string name="gcal_GCP_default">標準のカレンダー</string>
<string name="CFC_gtasks_list_text">リストにありますか ?</string>

@ -281,7 +281,6 @@
<string name="gcal_TEA_showCalendar_label">달력 이벤트 열기</string>
<string name="gcal_TEA_nocal">추가하지 않기</string>
<string name="gcal_TEA_none_selected">달력에?</string>
<string name="gcal_TEA_has_event">달력 이벤트</string>
<string name="gcal_completed_title">%s (완료)</string>
<string name="gcal_GCP_default">기본 달력</string>
<string name="gtasks_FEx_title">구글 일정: %s</string>

@ -276,7 +276,6 @@
<string name="gcal_TEA_showCalendar_label">Gebeurtenis openen</string>
<string name="gcal_TEA_nocal">Niet toevoegen</string>
<string name="gcal_TEA_none_selected">Naar agenda?</string>
<string name="gcal_TEA_has_event">Agenda-item</string>
<string name="gcal_completed_title">%s (voltooid)</string>
<string name="gcal_GCP_default">Standaard agenda</string>
<string name="gtasks_FEx_title">Google Taken: %s</string>

@ -278,7 +278,6 @@ i odzyskanie zadań z kopi zapasowej (Settings-&gt;Sync and backup-&gt;Backup-&g
<string name="gcal_TEA_showCalendar_label">Otwórz zdarzenie kalendarza</string>
<string name="gcal_TEA_nocal">Nie dodawaj</string>
<string name="gcal_TEA_none_selected">Do kalendarza?</string>
<string name="gcal_TEA_has_event">Wydarzenie w kalendarzu</string>
<string name="gcal_completed_title">%s (ukończono)</string>
<string name="gcal_GCP_default">Domyślny kalendarz</string>
<string name="gtasks_FEx_title">Zadania Google: %s</string>

@ -275,7 +275,6 @@
<string name="gcal_TEA_showCalendar_label">Abrir evento no calendário</string>
<string name="gcal_TEA_nocal">Não adicionar</string>
<string name="gcal_TEA_none_selected">Para o calendário?</string>
<string name="gcal_TEA_has_event">Evento no calendário</string>
<string name="gcal_completed_title">%s (concluído)</string>
<string name="gcal_GCP_default">Calendário padrão</string>
<string name="gtasks_FEx_title">Tarefas do Google: %s</string>

@ -279,7 +279,6 @@ das tarefas através de um backup em Definições-&gt;Sincronização e backup-&
<string name="gcal_TEA_showCalendar_label">Abrir evento no calendário</string>
<string name="gcal_TEA_nocal">Não adicionar</string>
<string name="gcal_TEA_none_selected">Ao calendário?</string>
<string name="gcal_TEA_has_event">Evento de calendário</string>
<string name="gcal_completed_title">%s (terminada)</string>
<string name="gcal_GCP_default">Calendário predefinido</string>
<string name="gtasks_FEx_title">Tarefas Google: %s</string>

@ -282,7 +282,6 @@
<string name="gcal_TEA_showCalendar_label">Открыть событие календаря</string>
<string name="gcal_TEA_nocal">Не добавлять</string>
<string name="gcal_TEA_none_selected">Добавить в календарь</string>
<string name="gcal_TEA_has_event">Событие календаря</string>
<string name="gcal_completed_title">%s (выполнено)</string>
<string name="gcal_GCP_default">Календарь по умолчанию</string>
<string name="gtasks_FEx_title">Задачи Google: %s</string>

@ -279,7 +279,6 @@
<string name="gcal_TEA_showCalendar_label">Odpri dogodek v koledarju</string>
<string name="gcal_TEA_nocal">Ne dodaj</string>
<string name="gcal_TEA_none_selected">Na koledar?</string>
<string name="gcal_TEA_has_event">Kol dogodek</string>
<string name="gcal_completed_title">%s (končani)</string>
<string name="gcal_GCP_default">Privzeti koledar</string>
<string name="gtasks_FEx_title">Google Naloge: %s</string>

@ -272,7 +272,6 @@ och återställer dina aktuella uppgifter från en backup
<string name="gcal_TEA_showCalendar_label">Öppna kalenderhändelse</string>
<string name="gcal_TEA_nocal">Lägg inte till</string>
<string name="gcal_TEA_none_selected">Till kalender</string>
<string name="gcal_TEA_has_event">Kalenderhändelse</string>
<string name="gcal_completed_title">%s (avslutad)</string>
<string name="gcal_GCP_default">Standardkalender</string>
<string name="gtasks_FEx_title">Google Uppgifter: %s</string>

@ -249,7 +249,6 @@
<string name="gcal_TEA_addToCalendar_label">Takvime Ekle</string>
<string name="gcal_TEA_showCalendar_label">Takvim Olayı</string>
<string name="gcal_TEA_nocal">Ekleme</string>
<string name="gcal_TEA_has_event">Takvim olayı</string>
<string name="gcal_completed_title">%s (tamamlandı)</string>
<string name="gcal_GCP_default">Öntanımlı Takvim</string>
<string name="gtasks_FEx_title">Google Görevleri: %s</string>

@ -283,7 +283,6 @@
<string name="gcal_TEA_showCalendar_label">Відкрити календарну подію</string>
<string name="gcal_TEA_nocal">Не додавати</string>
<string name="gcal_TEA_none_selected">До календаря?</string>
<string name="gcal_TEA_has_event">Кал. подія</string>
<string name="gcal_completed_title">%s (завершено)</string>
<string name="gcal_GCP_default">Календар по замовчуванню</string>
<string name="CFC_gtasks_list_text">В списку: ?</string>

@ -229,7 +229,6 @@
<string name="gcal_TEA_addToCalendar_label">建立日程表事件</string>
<string name="gcal_TEA_showCalendar_label">打开日程表事件</string>
<string name="gcal_TEA_nocal">不要添加</string>
<string name="gcal_TEA_has_event">日历事件</string>
<string name="gcal_completed_title">%s (已完成)</string>
<string name="gcal_GCP_default">默认日程表</string>
<string name="CFC_gtasks_list_text">列表内容: ?</string>

@ -262,7 +262,6 @@
<string name="gcal_TEA_addToCalendar_label">建立行事曆事項</string>
<string name="gcal_TEA_showCalendar_label">打開行事曆事項</string>
<string name="gcal_TEA_nocal">事件開啟錯誤!</string>
<string name="gcal_TEA_has_event">日曆活動</string>
<string name="gcal_completed_title">%s (已完成)</string>
<string name="gcal_GCP_default">預設行事曆</string>
<string name="gtasks_FEx_title">Google 工作表:%s</string>

@ -21,8 +21,6 @@
<string name="gcal_TEA_none_selected">To calendar?</string>
<string name="gcal_TEA_has_event">Cal event</string>
<!-- ======================================================== Calendars == -->
<!-- Calendar event name when task is completed (%s => task title) -->

Loading…
Cancel
Save