From 835d2c833c4f54705000fc99e8e3aefa0632ffa5 Mon Sep 17 00:00:00 2001 From: Tal Hacohen Date: Tue, 9 May 2017 21:11:24 +0300 Subject: [PATCH] Remote Module - Add journal list --- .../syncadapter/model/CollectionInfo.aidl | 4 + .../etesync/syncadapter/IEteSyncService.aidl | 3 + .../syncadapter/model/CollectionInfo.aidl | 4 + .../remotecontroller/MainActivity.java | 10 +++ .../syncadapter/model/CollectionInfo.java | 78 +++++++++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 app/src/main/aidl/com/etesync/syncadapter/model/CollectionInfo.aidl create mode 100644 remoteexample/src/main/aidl/com/etesync/syncadapter/model/CollectionInfo.aidl create mode 100644 remoteexample/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java diff --git a/app/src/main/aidl/com/etesync/syncadapter/model/CollectionInfo.aidl b/app/src/main/aidl/com/etesync/syncadapter/model/CollectionInfo.aidl new file mode 100644 index 00000000..5ed502b7 --- /dev/null +++ b/app/src/main/aidl/com/etesync/syncadapter/model/CollectionInfo.aidl @@ -0,0 +1,4 @@ +// CollectionInfo.aidl +package com.etesync.syncadapter.model; + +parcelable CollectionInfo; diff --git a/remoteexample/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl b/remoteexample/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl index 19920d52..dc15a1a2 100644 --- a/remoteexample/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl +++ b/remoteexample/src/main/aidl/com/etesync/syncadapter/IEteSyncService.aidl @@ -2,9 +2,12 @@ package com.etesync.syncadapter; // Declare any non-default types here with import statements +import com.etesync.syncadapter.model.CollectionInfo; interface IEteSyncService { boolean hasPermission(String journalType); void requestPermission(String journalType); + + CollectionInfo[] getJournalEntries(String journalType); } diff --git a/remoteexample/src/main/aidl/com/etesync/syncadapter/model/CollectionInfo.aidl b/remoteexample/src/main/aidl/com/etesync/syncadapter/model/CollectionInfo.aidl new file mode 100644 index 00000000..5ed502b7 --- /dev/null +++ b/remoteexample/src/main/aidl/com/etesync/syncadapter/model/CollectionInfo.aidl @@ -0,0 +1,4 @@ +// CollectionInfo.aidl +package com.etesync.syncadapter.model; + +parcelable CollectionInfo; diff --git a/remoteexample/src/main/java/com/etesync/remotecontroller/MainActivity.java b/remoteexample/src/main/java/com/etesync/remotecontroller/MainActivity.java index 9f09e712..2c1e166d 100644 --- a/remoteexample/src/main/java/com/etesync/remotecontroller/MainActivity.java +++ b/remoteexample/src/main/java/com/etesync/remotecontroller/MainActivity.java @@ -10,6 +10,7 @@ import android.support.v7.app.AppCompatActivity; import android.util.Log; import com.etesync.syncadapter.IEteSyncService; +import com.etesync.syncadapter.model.CollectionInfo; public class MainActivity extends AppCompatActivity { @@ -28,6 +29,15 @@ public class MainActivity extends AppCompatActivity { boolean isAllowed = mEteSyncService.hasPermission(JOURNAL_TYPE); if (!isAllowed) { mEteSyncService.requestPermission(JOURNAL_TYPE); + } else { + CollectionInfo[] collectionInfo = mEteSyncService.getJournalEntries(JOURNAL_TYPE); + if (collectionInfo == null) { + Log.i(TAG, "Received no collection infos"); + } else { + for (CollectionInfo collectionInfo1 : collectionInfo) { + Log.i(TAG, "Received collection info: " + collectionInfo1.displayName); + } + } } Log.i(TAG, JOURNAL_TYPE + " isAllowed:" + mEteSyncService.hasPermission(JOURNAL_TYPE) + diff --git a/remoteexample/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java b/remoteexample/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java new file mode 100644 index 00000000..2ba89ffd --- /dev/null +++ b/remoteexample/src/main/java/com/etesync/syncadapter/model/CollectionInfo.java @@ -0,0 +1,78 @@ +/* + * Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + */ + +package com.etesync.syncadapter.model; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.io.Serializable; + +public class CollectionInfo implements Serializable, Parcelable { + public int serviceID; + + public long id; + + public enum Type { + ADDRESS_BOOK, + CALENDAR + } + + public int version = -1; + + public Type type; + + public String uid; + + public String displayName, description; + public Integer color; + + public String timeZone; + + public boolean selected; + + protected CollectionInfo(Parcel in) { + id = in.readLong(); + serviceID = in.readInt(); + version = in.readInt(); + uid = in.readString(); + displayName = in.readString(); + description = in.readString(); + timeZone = in.readString(); + selected = in.readByte() != 0; + } + + public static final Creator CREATOR = new Creator() { + @Override + public CollectionInfo createFromParcel(Parcel in) { + return new CollectionInfo(in); + } + + @Override + public CollectionInfo[] newArray(int size) { + return new CollectionInfo[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel aParcel, int aI) { + aParcel.writeLong(id); + aParcel.writeInt(serviceID); + aParcel.writeInt(version); + aParcel.writeString(uid); + aParcel.writeString(displayName); + aParcel.writeString(description); + aParcel.writeString(timeZone); + aParcel.writeByte((byte) (selected ? 1 : 0)); + } +}