1
0
mirror of https://github.com/etesync/android synced 2024-11-22 07:58:09 +00:00

More tasks progress.

This commit is contained in:
Tom Hacohen 2017-12-11 11:07:24 +00:00
parent 5ebc101ca6
commit e5a409f538
3 changed files with 75 additions and 7 deletions

View File

@ -83,8 +83,8 @@ public class AccountActivity extends BaseActivity implements Toolbar.OnMenuItemC
private Account account; private Account account;
private AccountInfo accountInfo; private AccountInfo accountInfo;
ListView listCalDAV, listCardDAV; ListView listCalDAV, listCardDAV, listTasks;
Toolbar tbCardDAV, tbCalDAV; Toolbar tbCardDAV, tbCalDAV, tbTasks;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -111,6 +111,14 @@ public class AccountActivity extends BaseActivity implements Toolbar.OnMenuItemC
tbCalDAV.setOnMenuItemClickListener(this); tbCalDAV.setOnMenuItemClickListener(this);
tbCalDAV.setTitle(R.string.settings_caldav); tbCalDAV.setTitle(R.string.settings_caldav);
// Tasks toolbar
tbTasks = (Toolbar)findViewById(R.id.tasks_menu);
tbTasks.setOverflowIcon(icMenu);
tbTasks.inflateMenu(R.menu.vtodo_actions);
tbTasks.setOnMenuItemClickListener(this);
tbTasks.setTitle(R.string.settings_tasks);
// load CardDAV/CalDAV journals // load CardDAV/CalDAV journals
getLoaderManager().initLoader(0, getIntent().getExtras(), this); getLoaderManager().initLoader(0, getIntent().getExtras(), this);
@ -228,7 +236,7 @@ public class AccountActivity extends BaseActivity implements Toolbar.OnMenuItemC
/* LOADERS AND LOADED DATA */ /* LOADERS AND LOADED DATA */
protected static class AccountInfo { protected static class AccountInfo {
ServiceInfo carddav, caldav; ServiceInfo carddav, caldav, tasks;
public static class ServiceInfo { public static class ServiceInfo {
long id; long id;
@ -283,6 +291,21 @@ public class AccountActivity extends BaseActivity implements Toolbar.OnMenuItemC
listCalDAV.setOnItemClickListener(onItemClickListener); listCalDAV.setOnItemClickListener(onItemClickListener);
} else } else
card.setVisibility(View.GONE); card.setVisibility(View.GONE);
card = (CardView)findViewById(R.id.tasklist);
if (info.tasks != null) {
ProgressBar progress = (ProgressBar)findViewById(R.id.caldav_refreshing);
progress.setVisibility(info.tasks.refreshing ? View.VISIBLE : View.GONE);
listTasks = (ListView)findViewById(R.id.calendars);
listTasks.setEnabled(!info.tasks.refreshing);
listTasks.setAlpha(info.tasks.refreshing ? 0.5f : 1);
final CollectionListAdapter adapter = new CollectionListAdapter(this, account);
adapter.addAll(info.tasks.journals);
listTasks.setAdapter(adapter);
listTasks.setOnItemClickListener(onItemClickListener);
}
} }
@Override @Override
@ -292,6 +315,9 @@ public class AccountActivity extends BaseActivity implements Toolbar.OnMenuItemC
if (listCalDAV != null) if (listCalDAV != null)
listCalDAV.setAdapter(null); listCalDAV.setAdapter(null);
if (listTasks != null)
listTasks.setAdapter(null);
} }
@ -375,11 +401,11 @@ public class AccountActivity extends BaseActivity implements Toolbar.OnMenuItemC
ContentResolver.isSyncActive(account, CalendarContract.AUTHORITY); ContentResolver.isSyncActive(account, CalendarContract.AUTHORITY);
info.caldav.journals = JournalEntity.getJournals(data, serviceEntity); info.caldav.journals = JournalEntity.getJournals(data, serviceEntity);
} else if (service.equals(CollectionInfo.Type.TASK_LIST)) { } else if (service.equals(CollectionInfo.Type.TASK_LIST)) {
info.caldav = new AccountInfo.ServiceInfo(); info.tasks = new AccountInfo.ServiceInfo();
info.caldav.id = id; info.tasks.id = id;
info.caldav.refreshing = (davService != null && davService.isRefreshing(id)) || info.tasks.refreshing = (davService != null && davService.isRefreshing(id)) ||
ContentResolver.isSyncActive(account, TaskProvider.ProviderName.OpenTasks.authority); ContentResolver.isSyncActive(account, TaskProvider.ProviderName.OpenTasks.authority);
info.caldav.journals = JournalEntity.getJournals(data, serviceEntity); info.tasks.journals = JournalEntity.getJournals(data, serviceEntity);
} }
} }
return info; return info;

View File

@ -100,5 +100,46 @@
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/tasklist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/tasks_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/toolbar_theme"
style="@style/toolbar_style"
app:navigationIcon="@drawable/ic_event_light"
app:title="@string/settings_tasks"
android:elevation="2dp" tools:ignore="UnusedAttribute"/>
<ProgressBar
android:id="@+id/tasks_refreshing"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:indeterminate="true"/>
<com.etesync.syncadapter.ui.widget.MaximizedListView
android:id="@+id/tasks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:choiceMode="multipleChoice"
android:descendantFocusability="beforeDescendants"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@ -254,6 +254,7 @@
<string name="settings_sync_wifi_only_ssid_message">Enter the name of a WiFi network (SSID) to restrict synchronization to this network, or leave blank for all WiFi connections.</string> <string name="settings_sync_wifi_only_ssid_message">Enter the name of a WiFi network (SSID) to restrict synchronization to this network, or leave blank for all WiFi connections.</string>
<string name="settings_carddav">Contacts</string> <string name="settings_carddav">Contacts</string>
<string name="settings_caldav">Calendar</string> <string name="settings_caldav">Calendar</string>
<string name="settings_tasks">Tasks</string>
<!-- collection management --> <!-- collection management -->
<string name="create_addressbook">Create address book</string> <string name="create_addressbook">Create address book</string>