syncslides: Add discovery interfaces.
Added the main interface for discovery as well as interfaces and
classes it depends upon. I left Deck as an interface because
we might want to support a version that streams image bytes in addition
to the version that simply buffers the whole byte array.
Change-Id: I5dc93c85baf5b91f692c4cc9b547744b435a8672
diff --git a/android/app/src/main/java/io/v/syncslides/discovery/PresentationDiscovery.java b/android/app/src/main/java/io/v/syncslides/discovery/PresentationDiscovery.java
new file mode 100644
index 0000000..b9357ee
--- /dev/null
+++ b/android/app/src/main/java/io/v/syncslides/discovery/PresentationDiscovery.java
@@ -0,0 +1,28 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.syncslides.discovery;
+
+import io.v.syncslides.model.DynamicList;
+import io.v.syncslides.model.PresentationAdvertisement;
+import io.v.v23.context.VContext;
+
+/**
+ * Handles advertising and scanning for live presentations.
+ */
+public interface PresentationDiscovery {
+ /**
+ * Finds all live presentations. The returned list will be continually
+ * updated as new presentations start and old presentations end.
+ */
+ DynamicList<PresentationAdvertisement> scan();
+
+ /**
+ * Starts advertising a presentation.
+ * @param vContext context for the advertisement. Client should cancel the context
+ * to stop advertising.
+ * @param advertisement details of the presentation.
+ */
+ void advertise(VContext vContext, PresentationAdvertisement advertisement);
+}
diff --git a/android/app/src/main/java/io/v/syncslides/model/Deck.java b/android/app/src/main/java/io/v/syncslides/model/Deck.java
new file mode 100644
index 0000000..0b214ff
--- /dev/null
+++ b/android/app/src/main/java/io/v/syncslides/model/Deck.java
@@ -0,0 +1,33 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.syncslides.model;
+
+import android.graphics.Bitmap;
+
+/**
+ * A deck, aka a set of slides.
+ */
+public interface Deck {
+ /**
+ * Returns a Bitmap suitable as a thumbnail of the deck (e.g. the title
+ * slide).
+ */
+ Bitmap getThumb();
+
+ /**
+ * Returns raw thumbnail data.
+ */
+ byte[] getThumbData();
+
+ /**
+ * Returns the title of the deck.
+ */
+ String getTitle();
+
+ /**
+ * Returns the deck id.
+ */
+ String getId();
+}
diff --git a/android/app/src/main/java/io/v/syncslides/model/DynamicList.java b/android/app/src/main/java/io/v/syncslides/model/DynamicList.java
new file mode 100644
index 0000000..3eddb8f
--- /dev/null
+++ b/android/app/src/main/java/io/v/syncslides/model/DynamicList.java
@@ -0,0 +1,30 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.syncslides.model;
+
+/**
+ * Provides a list of elements via an API that fits well with RecyclerView.Adapter.
+ */
+public interface DynamicList<E> {
+ /**
+ * Returns the number of items in the list.
+ */
+ int getItemCount();
+
+ /**
+ * Returns the ith item in the list.
+ */
+ E get(int i);
+
+ /**
+ * Adds a listener for changes to the list.
+ */
+ void addListener(ListListener listener);
+
+ /**
+ * Stops any subsequent notifications to the given listener.
+ */
+ void removeListener(ListListener listener);
+}
diff --git a/android/app/src/main/java/io/v/syncslides/model/ListListener.java b/android/app/src/main/java/io/v/syncslides/model/ListListener.java
new file mode 100644
index 0000000..015d621
--- /dev/null
+++ b/android/app/src/main/java/io/v/syncslides/model/ListListener.java
@@ -0,0 +1,14 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.syncslides.model;
+
+/**
+ * Callbacks for list changes.
+ */
+public interface ListListener {
+ void notifyItemChanged(int position);
+ void notifyItemInserted(int position);
+ void notifyItemRemoved(int position);
+}
diff --git a/android/app/src/main/java/io/v/syncslides/model/Person.java b/android/app/src/main/java/io/v/syncslides/model/Person.java
new file mode 100644
index 0000000..0e317e9
--- /dev/null
+++ b/android/app/src/main/java/io/v/syncslides/model/Person.java
@@ -0,0 +1,36 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.syncslides.model;
+
+/**
+ * Represents either an audience member or the presenter.
+ */
+public class Person {
+ String mBlessing;
+ String mName;
+
+ /**
+ * @param blessing the Vanadium blessing for this user
+ * @param name the human full name
+ */
+ public Person(String blessing, String name) {
+ mBlessing = blessing;
+ mName = name;
+ }
+
+ /**
+ * Returns the blessing for this user.
+ */
+ public String getBlessing() {
+ return mBlessing;
+ }
+
+ /**
+ * Returns the human full name.
+ */
+ public String getName() {
+ return mName;
+ }
+}
\ No newline at end of file
diff --git a/android/app/src/main/java/io/v/syncslides/model/PresentationAdvertisement.java b/android/app/src/main/java/io/v/syncslides/model/PresentationAdvertisement.java
new file mode 100644
index 0000000..4271746
--- /dev/null
+++ b/android/app/src/main/java/io/v/syncslides/model/PresentationAdvertisement.java
@@ -0,0 +1,42 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.syncslides.model;
+
+/**
+ * Contains sufficient details of a live presentation such that a potential audience
+ * member could choose to join it.
+ */
+public class PresentationAdvertisement {
+ Person mPresenter;
+ Deck mDeck;
+ String mSyncgroupName;
+
+ public PresentationAdvertisement(Person presenter, Deck deck, String syncgroupName) {
+ mPresenter = presenter;
+ mDeck = deck;
+ mSyncgroupName = syncgroupName;
+ }
+
+ /**
+ * Returns the person who is presenting.
+ */
+ public Person getPresenter() {
+ return mPresenter;
+ }
+
+ /**
+ * Returns the deck being presented.
+ */
+ public Deck getDeck() {
+ return mDeck;
+ }
+
+ /**
+ * Returns the syncgroup name for this presentation.
+ */
+ public String getSyncgroupName() {
+ return mSyncgroupName;
+ }
+}