mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Use 'forum' instead of 'group'. #174
This commit is contained in:
@@ -125,35 +125,35 @@
|
||||
/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".android.groups.AvailableGroupsActivity"
|
||||
android:name=".android.forum.AvailableForumsActivity"
|
||||
android:label="@string/available_forums_title"
|
||||
android:parentActivityName=".android.groups.GroupListActivity" >
|
||||
android:parentActivityName=".android.forum.ForumListActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".android.groups.GroupListActivity"
|
||||
android:value=".android.forum.ForumListActivity"
|
||||
/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".android.groups.CreateGroupActivity"
|
||||
android:name=".android.forum.CreateForumActivity"
|
||||
android:label="@string/create_forum_title"
|
||||
android:windowSoftInputMode="stateVisible"
|
||||
android:parentActivityName=".android.groups.GroupListActivity" >
|
||||
android:parentActivityName=".android.forum.ForumListActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".android.groups.GroupListActivity"
|
||||
android:value=".android.forum.ForumListActivity"
|
||||
/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".android.groups.GroupActivity"
|
||||
android:name=".android.forum.ForumActivity"
|
||||
android:label="@string/app_name"
|
||||
android:parentActivityName=".android.groups.GroupListActivity" >
|
||||
android:parentActivityName=".android.forum.ForumListActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".android.groups.GroupListActivity"
|
||||
android:value=".android.forum.ForumListActivity"
|
||||
/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".android.groups.GroupListActivity"
|
||||
android:name=".android.forum.ForumListActivity"
|
||||
android:label="@string/forums_title"
|
||||
android:parentActivityName=".android.DashboardActivity" >
|
||||
<meta-data
|
||||
@@ -162,31 +162,31 @@
|
||||
/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".android.groups.ReadGroupPostActivity"
|
||||
android:name=".android.forum.ReadForumPostActivity"
|
||||
android:label="@string/app_name"
|
||||
android:parentActivityName=".android.groups.GroupListActivity" >
|
||||
android:parentActivityName=".android.forum.ForumListActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".android.groups.GroupListActivity"
|
||||
android:value=".android.forum.ForumListActivity"
|
||||
/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".android.groups.ShareGroupActivity"
|
||||
android:name=".android.forum.ShareForumActivity"
|
||||
android:label="@string/app_name"
|
||||
android:parentActivityName=".android.groups.GroupListActivity" >
|
||||
android:parentActivityName=".android.forum.ForumListActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".android.groups.GroupListActivity"
|
||||
android:value=".android.forum.ForumListActivity"
|
||||
/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".android.groups.WriteGroupPostActivity"
|
||||
android:name=".android.forum.WriteForumPostActivity"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="stateVisible"
|
||||
android:parentActivityName=".android.groups.GroupListActivity" >
|
||||
android:parentActivityName=".android.forum.ForumListActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".android.groups.GroupListActivity"
|
||||
android:value=".android.forum.ForumListActivity"
|
||||
/>
|
||||
</activity>
|
||||
<activity
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
<string name="bluetooth_setting_disabled">Only when adding contacts</string>
|
||||
<string name="notification_settings_title">NOTIFICATIONS</string>
|
||||
<string name="notify_private_messages_setting">Show alerts for private messages</string>
|
||||
<string name="notify_group_posts_setting">Show alerts for forum posts</string>
|
||||
<string name="notify_forum_posts_setting">Show alerts for forum posts</string>
|
||||
<string name="notify_vibration_setting">Vibrate</string>
|
||||
<string name="notify_sound_setting">Sound</string>
|
||||
<string name="notify_sound_setting_default">Default ringtone</string>
|
||||
|
||||
@@ -1,27 +1,18 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import static android.app.Notification.DEFAULT_LIGHTS;
|
||||
import static android.app.Notification.DEFAULT_SOUND;
|
||||
import static android.app.Notification.DEFAULT_VIBRATE;
|
||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import android.app.Application;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.contact.ContactListActivity;
|
||||
import org.briarproject.android.contact.ConversationActivity;
|
||||
import org.briarproject.android.groups.GroupActivity;
|
||||
import org.briarproject.android.groups.GroupListActivity;
|
||||
import org.briarproject.android.forum.ForumActivity;
|
||||
import org.briarproject.android.forum.ForumListActivity;
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.Settings;
|
||||
import org.briarproject.api.android.AndroidNotificationManager;
|
||||
@@ -35,23 +26,32 @@ import org.briarproject.api.event.SettingsUpdatedEvent;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.app.Notification.DEFAULT_LIGHTS;
|
||||
import static android.app.Notification.DEFAULT_SOUND;
|
||||
import static android.app.Notification.DEFAULT_VIBRATE;
|
||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
||||
EventListener {
|
||||
|
||||
private static final int PRIVATE_MESSAGE_NOTIFICATION_ID = 3;
|
||||
private static final int GROUP_POST_NOTIFICATION_ID = 4;
|
||||
private static final int FORUM_POST_NOTIFICATION_ID = 4;
|
||||
private static final String CONTACT_URI =
|
||||
"content://org.briarproject/contact";
|
||||
private static final String GROUP_URI =
|
||||
"content://org.briarproject/group";
|
||||
private static final String FORUM_URI =
|
||||
"content://org.briarproject/forum";
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(AndroidNotificationManagerImpl.class.getName());
|
||||
@@ -65,9 +65,9 @@ EventListener {
|
||||
// The following are locking: lock
|
||||
private final Map<ContactId, Integer> contactCounts =
|
||||
new HashMap<ContactId, Integer>();
|
||||
private final Map<GroupId, Integer> groupCounts =
|
||||
private final Map<GroupId, Integer> forumCounts =
|
||||
new HashMap<GroupId, Integer>();
|
||||
private int privateTotal = 0, groupTotal = 0;
|
||||
private int contactTotal = 0, forumTotal = 0;
|
||||
private int nextRequestId = 0;
|
||||
|
||||
private volatile Settings settings = new Settings();
|
||||
@@ -116,7 +116,7 @@ EventListener {
|
||||
Integer count = contactCounts.get(c);
|
||||
if (count == null) contactCounts.put(c, 1);
|
||||
else contactCounts.put(c, count + 1);
|
||||
privateTotal++;
|
||||
contactTotal++;
|
||||
updatePrivateMessageNotification();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
@@ -128,7 +128,7 @@ EventListener {
|
||||
try {
|
||||
Integer count = contactCounts.remove(c);
|
||||
if (count == null) return; // Already cleared
|
||||
privateTotal -= count;
|
||||
contactTotal -= count;
|
||||
updatePrivateMessageNotification();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
@@ -137,18 +137,16 @@ EventListener {
|
||||
|
||||
// Locking: lock
|
||||
private void updatePrivateMessageNotification() {
|
||||
if (privateTotal == 0) {
|
||||
if (contactTotal == 0) {
|
||||
clearPrivateMessageNotification();
|
||||
} else if (!settings.getBoolean("notifyPrivateMessages", true)) {
|
||||
return;
|
||||
} else {
|
||||
} else if (settings.getBoolean("notifyPrivateMessages", true)) {
|
||||
NotificationCompat.Builder b =
|
||||
new NotificationCompat.Builder(appContext);
|
||||
b.setSmallIcon(R.drawable.message_notification_icon);
|
||||
b.setContentTitle(appContext.getText(R.string.app_name));
|
||||
b.setContentText(appContext.getResources().getQuantityString(
|
||||
R.plurals.private_message_notification_text, privateTotal,
|
||||
privateTotal));
|
||||
R.plurals.private_message_notification_text, contactTotal,
|
||||
contactTotal));
|
||||
boolean sound = settings.getBoolean("notifySound", true);
|
||||
String ringtoneUri = settings.get("notifyRingtoneUri");
|
||||
if (sound && !StringUtils.isNullOrEmpty(ringtoneUri))
|
||||
@@ -198,91 +196,89 @@ EventListener {
|
||||
return defaults;
|
||||
}
|
||||
|
||||
public void showGroupPostNotification(GroupId g) {
|
||||
public void showForumPostNotification(GroupId g) {
|
||||
lock.lock();
|
||||
try {
|
||||
Integer count = groupCounts.get(g);
|
||||
if (count == null) groupCounts.put(g, 1);
|
||||
else groupCounts.put(g, count + 1);
|
||||
groupTotal++;
|
||||
updateGroupPostNotification();
|
||||
Integer count = forumCounts.get(g);
|
||||
if (count == null) forumCounts.put(g, 1);
|
||||
else forumCounts.put(g, count + 1);
|
||||
forumTotal++;
|
||||
updateForumPostNotification();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearGroupPostNotification(GroupId g) {
|
||||
public void clearForumPostNotification(GroupId g) {
|
||||
lock.lock();
|
||||
try {
|
||||
Integer count = groupCounts.remove(g);
|
||||
Integer count = forumCounts.remove(g);
|
||||
if (count == null) return; // Already cleared
|
||||
groupTotal -= count;
|
||||
updateGroupPostNotification();
|
||||
forumTotal -= count;
|
||||
updateForumPostNotification();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: lock
|
||||
private void updateGroupPostNotification() {
|
||||
if (groupTotal == 0) {
|
||||
clearGroupPostNotification();
|
||||
} else if (!settings.getBoolean("notifyGroupPosts", true)) {
|
||||
return;
|
||||
} else {
|
||||
private void updateForumPostNotification() {
|
||||
if (forumTotal == 0) {
|
||||
clearForumPostNotification();
|
||||
} else if (settings.getBoolean("notifyForumPosts", true)) {
|
||||
NotificationCompat.Builder b =
|
||||
new NotificationCompat.Builder(appContext);
|
||||
b.setSmallIcon(R.drawable.message_notification_icon);
|
||||
b.setContentTitle(appContext.getText(R.string.app_name));
|
||||
b.setContentText(appContext.getResources().getQuantityString(
|
||||
R.plurals.forum_post_notification_text, groupTotal,
|
||||
groupTotal));
|
||||
R.plurals.forum_post_notification_text, forumTotal,
|
||||
forumTotal));
|
||||
String ringtoneUri = settings.get("notifyRingtoneUri");
|
||||
if (!StringUtils.isNullOrEmpty(ringtoneUri))
|
||||
b.setSound(Uri.parse(ringtoneUri));
|
||||
b.setDefaults(getDefaults());
|
||||
b.setOnlyAlertOnce(true);
|
||||
b.setAutoCancel(true);
|
||||
if (groupCounts.size() == 1) {
|
||||
Intent i = new Intent(appContext, GroupActivity.class);
|
||||
GroupId g = groupCounts.keySet().iterator().next();
|
||||
if (forumCounts.size() == 1) {
|
||||
Intent i = new Intent(appContext, ForumActivity.class);
|
||||
GroupId g = forumCounts.keySet().iterator().next();
|
||||
i.putExtra("briar.GROUP_ID", g.getBytes());
|
||||
String idHex = StringUtils.toHexString(g.getBytes());
|
||||
i.setData(Uri.parse(GROUP_URI + "/" + idHex));
|
||||
i.setData(Uri.parse(FORUM_URI + "/" + idHex));
|
||||
i.setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
|
||||
TaskStackBuilder t = TaskStackBuilder.create(appContext);
|
||||
t.addParentStack(GroupActivity.class);
|
||||
t.addParentStack(ForumActivity.class);
|
||||
t.addNextIntent(i);
|
||||
b.setContentIntent(t.getPendingIntent(nextRequestId++, 0));
|
||||
} else {
|
||||
Intent i = new Intent(appContext, GroupListActivity.class);
|
||||
Intent i = new Intent(appContext, ForumListActivity.class);
|
||||
i.setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
|
||||
TaskStackBuilder t = TaskStackBuilder.create(appContext);
|
||||
t.addParentStack(GroupListActivity.class);
|
||||
t.addParentStack(ForumListActivity.class);
|
||||
t.addNextIntent(i);
|
||||
b.setContentIntent(t.getPendingIntent(nextRequestId++, 0));
|
||||
}
|
||||
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = (NotificationManager) o;
|
||||
nm.notify(GROUP_POST_NOTIFICATION_ID, b.build());
|
||||
nm.notify(FORUM_POST_NOTIFICATION_ID, b.build());
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: lock
|
||||
private void clearGroupPostNotification() {
|
||||
private void clearForumPostNotification() {
|
||||
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = (NotificationManager) o;
|
||||
nm.cancel(GROUP_POST_NOTIFICATION_ID);
|
||||
nm.cancel(FORUM_POST_NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
public void clearNotifications() {
|
||||
lock.lock();
|
||||
try {
|
||||
contactCounts.clear();
|
||||
groupCounts.clear();
|
||||
privateTotal = groupTotal = 0;
|
||||
forumCounts.clear();
|
||||
contactTotal = forumTotal = 0;
|
||||
clearPrivateMessageNotification();
|
||||
clearGroupPostNotification();
|
||||
clearForumPostNotification();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult.ALREADY_RUNNING;
|
||||
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult.SUCCESS;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.api.ContactId;
|
||||
@@ -30,15 +25,21 @@ import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager.StartResult;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.service.RoboService;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult.ALREADY_RUNNING;
|
||||
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult.SUCCESS;
|
||||
|
||||
public class BriarService extends RoboService implements EventListener {
|
||||
|
||||
@@ -182,7 +183,7 @@ public class BriarService extends RoboService implements EventListener {
|
||||
lifecycleManager.waitForDatabase();
|
||||
if (g.equals(db.getInboxGroupId(c)))
|
||||
notificationManager.showPrivateMessageNotification(c);
|
||||
else notificationManager.showGroupPostNotification(g);
|
||||
else notificationManager.showForumPostNotification(g);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
|
||||
@@ -1,26 +1,5 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.contact.ContactListActivity;
|
||||
import org.briarproject.android.groups.GroupListActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.LocalAuthor;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
@@ -34,6 +13,27 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.contact.ContactListActivity;
|
||||
import org.briarproject.android.forum.ForumListActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.LocalAuthor;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
|
||||
public class DashboardActivity extends BriarActivity {
|
||||
|
||||
private static final Logger LOG =
|
||||
@@ -109,7 +109,7 @@ public class DashboardActivity extends BriarActivity {
|
||||
forumsButton.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(DashboardActivity.this,
|
||||
GroupListActivity.class));
|
||||
ForumListActivity.class));
|
||||
}
|
||||
});
|
||||
buttons.add(forumsButton);
|
||||
|
||||
@@ -1,5 +1,40 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.FixedVerticalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.Settings;
|
||||
import org.briarproject.api.TransportConfig;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.event.EventListener;
|
||||
import org.briarproject.api.event.SettingsUpdatedEvent;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.graphics.Typeface.DEFAULT_BOLD;
|
||||
import static android.media.RingtoneManager.ACTION_RINGTONE_PICKER;
|
||||
import static android.media.RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI;
|
||||
@@ -20,41 +55,6 @@ import static org.briarproject.android.TestingConstants.SHOW_TESTING_ACTIVITY;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.FixedVerticalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.Settings;
|
||||
import org.briarproject.api.TransportConfig;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.event.EventListener;
|
||||
import org.briarproject.api.event.SettingsUpdatedEvent;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SettingsActivity extends BriarActivity implements EventListener,
|
||||
OnClickListener {
|
||||
|
||||
@@ -65,7 +65,7 @@ OnClickListener {
|
||||
|
||||
private ScrollView scroll = null;
|
||||
private TextView enableBluetooth = null, enableBluetoothHint = null;
|
||||
private CheckBox notifyPrivateMessages = null, notifyGroupPosts = null;
|
||||
private CheckBox notifyPrivateMessages = null, notifyForumPosts = null;
|
||||
private CheckBox notifyVibration = null;
|
||||
private TextView notifySound = null, notifySoundHint = null;
|
||||
private ListLoadingProgressBar progress = null;
|
||||
@@ -140,11 +140,11 @@ OnClickListener {
|
||||
settings.addView(new HorizontalBorder(this));
|
||||
settings.addView(new FixedVerticalSpace(this));
|
||||
|
||||
notifyGroupPosts = new CheckBox(this);
|
||||
notifyGroupPosts.setTextSize(18);
|
||||
notifyGroupPosts.setText(R.string.notify_group_posts_setting);
|
||||
notifyGroupPosts.setOnClickListener(this);
|
||||
settings.addView(notifyGroupPosts);
|
||||
notifyForumPosts = new CheckBox(this);
|
||||
notifyForumPosts.setTextSize(18);
|
||||
notifyForumPosts.setText(R.string.notify_forum_posts_setting);
|
||||
notifyForumPosts.setOnClickListener(this);
|
||||
settings.addView(notifyForumPosts);
|
||||
|
||||
settings.addView(new FixedVerticalSpace(this));
|
||||
settings.addView(new HorizontalBorder(this));
|
||||
@@ -241,8 +241,8 @@ OnClickListener {
|
||||
notifyPrivateMessages.setChecked(settings.getBoolean(
|
||||
"notifyPrivateMessages", true));
|
||||
|
||||
notifyGroupPosts.setChecked(settings.getBoolean(
|
||||
"notifyGroupPosts", true));
|
||||
notifyForumPosts.setChecked(settings.getBoolean(
|
||||
"notifyForumPosts", true));
|
||||
|
||||
notifyVibration.setChecked(settings.getBoolean(
|
||||
"notifyVibration", true));
|
||||
@@ -285,9 +285,9 @@ OnClickListener {
|
||||
s.putBoolean("notifyPrivateMessages",
|
||||
notifyPrivateMessages.isChecked());
|
||||
storeSettings(s);
|
||||
} else if (view == notifyGroupPosts) {
|
||||
} else if (view == notifyForumPosts) {
|
||||
Settings s = new Settings();
|
||||
s.putBoolean("notifyGroupPosts", notifyGroupPosts.isChecked());
|
||||
s.putBoolean("notifyForumPosts", notifyForumPosts.isChecked());
|
||||
storeSettings(s);
|
||||
} else if (view == notifyVibration) {
|
||||
Settings s = new Settings();
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
@@ -28,20 +24,24 @@ import org.briarproject.api.event.SubscriptionRemovedEvent;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AvailableGroupsActivity extends BriarActivity
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
|
||||
public class AvailableForumsActivity extends BriarActivity
|
||||
implements EventListener, OnItemClickListener {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(AvailableGroupsActivity.class.getName());
|
||||
Logger.getLogger(AvailableForumsActivity.class.getName());
|
||||
|
||||
private AvailableGroupsAdapter adapter = null;
|
||||
private AvailableForumsAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
|
||||
@@ -53,7 +53,7 @@ implements EventListener, OnItemClickListener {
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
adapter = new AvailableGroupsAdapter(this);
|
||||
adapter = new AvailableForumsAdapter(this);
|
||||
list = new ListView(this);
|
||||
list.setLayoutParams(MATCH_MATCH);
|
||||
list.setAdapter(adapter);
|
||||
@@ -68,29 +68,29 @@ implements EventListener, OnItemClickListener {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
eventBus.addListener(this);
|
||||
loadGroups();
|
||||
loadForums();
|
||||
}
|
||||
|
||||
private void loadGroups() {
|
||||
private void loadForums() {
|
||||
runOnDbThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Collection<GroupContacts> available =
|
||||
new ArrayList<GroupContacts>();
|
||||
Collection<ForumContacts> available =
|
||||
new ArrayList<ForumContacts>();
|
||||
long now = System.currentTimeMillis();
|
||||
for (Group g : db.getAvailableGroups()) {
|
||||
try {
|
||||
GroupId id = g.getId();
|
||||
Collection<Contact> c = db.getSubscribers(id);
|
||||
available.add(new GroupContacts(g, c));
|
||||
available.add(new ForumContacts(g, c));
|
||||
} catch (NoSuchSubscriptionException e) {
|
||||
continue;
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Load took " + duration + " ms");
|
||||
displayGroups(available);
|
||||
displayForums(available);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
@@ -99,18 +99,18 @@ implements EventListener, OnItemClickListener {
|
||||
});
|
||||
}
|
||||
|
||||
private void displayGroups(final Collection<GroupContacts> available) {
|
||||
private void displayForums(final Collection<ForumContacts> available) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (available.isEmpty()) {
|
||||
LOG.info("No groups available, finishing");
|
||||
LOG.info("No forums available, finishing");
|
||||
finish();
|
||||
} else {
|
||||
setContentView(list);
|
||||
adapter.clear();
|
||||
for (GroupContacts g : available)
|
||||
adapter.add(new AvailableGroupsItem(g));
|
||||
adapter.sort(AvailableGroupsItemComparator.INSTANCE);
|
||||
for (ForumContacts f : available)
|
||||
adapter.add(new AvailableForumsItem(f));
|
||||
adapter.sort(AvailableForumsItemComparator.INSTANCE);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -126,19 +126,19 @@ implements EventListener, OnItemClickListener {
|
||||
public void eventOccurred(Event e) {
|
||||
if (e instanceof RemoteSubscriptionsUpdatedEvent) {
|
||||
LOG.info("Remote subscriptions changed, reloading");
|
||||
loadGroups();
|
||||
loadForums();
|
||||
} else if (e instanceof SubscriptionAddedEvent) {
|
||||
LOG.info("Subscription added, reloading");
|
||||
loadGroups();
|
||||
loadForums();
|
||||
} else if (e instanceof SubscriptionRemovedEvent) {
|
||||
LOG.info("Subscription removed, reloading");
|
||||
loadGroups();
|
||||
loadForums();
|
||||
}
|
||||
}
|
||||
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
AvailableGroupsItem item = adapter.getItem(position);
|
||||
AvailableForumsItem item = adapter.getItem(position);
|
||||
Collection<ContactId> visible = new ArrayList<ContactId>();
|
||||
for (Contact c : item.getContacts()) visible.add(c.getId());
|
||||
addSubscription(item.getGroup(), visible);
|
||||
@@ -1,15 +1,4 @@
|
||||
package org.briarproject.android.groups;
|
||||
|
||||
import static android.text.TextUtils.TruncateAt.END;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.Contact;
|
||||
import org.briarproject.util.StringUtils;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
@@ -18,19 +7,30 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
class AvailableGroupsAdapter extends ArrayAdapter<AvailableGroupsItem> {
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.Contact;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import static android.text.TextUtils.TruncateAt.END;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
|
||||
class AvailableForumsAdapter extends ArrayAdapter<AvailableForumsItem> {
|
||||
|
||||
private final int pad;
|
||||
|
||||
AvailableGroupsAdapter(Context ctx) {
|
||||
AvailableForumsAdapter(Context ctx) {
|
||||
super(ctx, android.R.layout.simple_expandable_list_item_1,
|
||||
new ArrayList<AvailableGroupsItem>());
|
||||
new ArrayList<AvailableForumsItem>());
|
||||
pad = LayoutUtils.getPadding(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
AvailableGroupsItem item = getItem(position);
|
||||
AvailableForumsItem item = getItem(position);
|
||||
Context ctx = getContext();
|
||||
|
||||
LinearLayout layout = new LinearLayout(ctx);
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import org.briarproject.api.Contact;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
class AvailableForumsItem {
|
||||
|
||||
private final ForumContacts forumContacts;
|
||||
|
||||
AvailableForumsItem(ForumContacts forumContacts) {
|
||||
this.forumContacts = forumContacts;
|
||||
}
|
||||
|
||||
Group getGroup() {
|
||||
return forumContacts.getGroup();
|
||||
}
|
||||
|
||||
Collection<Contact> getContacts() {
|
||||
return forumContacts.getContacts();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
class AvailableForumsItemComparator implements Comparator<AvailableForumsItem> {
|
||||
|
||||
static final AvailableForumsItemComparator INSTANCE =
|
||||
new AvailableForumsItemComparator();
|
||||
|
||||
public int compare(AvailableForumsItem a, AvailableForumsItem b) {
|
||||
if (a == b) return 0;
|
||||
String aName = a.getGroup().getName();
|
||||
String bName = b.getGroup().getName();
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(aName, bName);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,30 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.messaging.GroupFactory;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.text.InputType.TYPE_CLASS_TEXT;
|
||||
import static android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
|
||||
@@ -14,37 +40,11 @@ import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_GROUP_NAME_LENGTH;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.messaging.GroupFactory;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class CreateGroupActivity extends BriarActivity
|
||||
public class CreateForumActivity extends BriarActivity
|
||||
implements OnEditorActionListener, OnClickListener {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(CreateGroupActivity.class.getName());
|
||||
Logger.getLogger(CreateForumActivity.class.getName());
|
||||
|
||||
private EditText nameEntry = null;
|
||||
private Button createForumButton = null;
|
||||
@@ -130,11 +130,11 @@ implements OnEditorActionListener, OnClickListener {
|
||||
if (!validateName()) return;
|
||||
createForumButton.setVisibility(GONE);
|
||||
progress.setVisibility(VISIBLE);
|
||||
storeGroup(nameEntry.getText().toString());
|
||||
storeForum(nameEntry.getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void storeGroup(final String name) {
|
||||
private void storeForum(final String name) {
|
||||
runOnDbThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
@@ -143,8 +143,8 @@ implements OnEditorActionListener, OnClickListener {
|
||||
db.addGroup(g);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Storing group took " + duration + " ms");
|
||||
displayGroup(g);
|
||||
LOG.info("Storing forum took " + duration + " ms");
|
||||
displayForum(g);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
@@ -154,15 +154,15 @@ implements OnEditorActionListener, OnClickListener {
|
||||
});
|
||||
}
|
||||
|
||||
private void displayGroup(final Group g) {
|
||||
private void displayForum(final Group g) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
Intent i = new Intent(CreateGroupActivity.this,
|
||||
GroupActivity.class);
|
||||
Intent i = new Intent(CreateForumActivity.this,
|
||||
ForumActivity.class);
|
||||
i.putExtra("briar.GROUP_ID", g.getId().getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", g.getName());
|
||||
i.putExtra("briar.FORUM_NAME", g.getName());
|
||||
startActivity(i);
|
||||
Toast.makeText(CreateGroupActivity.this,
|
||||
Toast.makeText(CreateForumActivity.this,
|
||||
R.string.forum_created_toast, LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
@@ -1,26 +1,16 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.groups.ReadGroupPostActivity.RESULT_PREV_NEXT;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
@@ -44,29 +34,39 @@ import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
import org.briarproject.api.messaging.MessageId;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class GroupActivity extends BriarActivity implements EventListener,
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.forum.ReadForumPostActivity.RESULT_PREV_NEXT;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
|
||||
public class ForumActivity extends BriarActivity implements EventListener,
|
||||
OnClickListener, OnItemClickListener {
|
||||
|
||||
private static final int REQUEST_READ = 2;
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(GroupActivity.class.getName());
|
||||
Logger.getLogger(ForumActivity.class.getName());
|
||||
|
||||
@Inject private AndroidNotificationManager notificationManager;
|
||||
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>();
|
||||
private TextView empty = null;
|
||||
private GroupAdapter adapter = null;
|
||||
private ForumAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
private ImageButton composeButton = null, shareButton = null;
|
||||
@@ -85,8 +85,8 @@ OnClickListener, OnItemClickListener {
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if (b == null) throw new IllegalStateException();
|
||||
groupId = new GroupId(b);
|
||||
String name = i.getStringExtra("briar.GROUP_NAME");
|
||||
if (name != null) setTitle(name);
|
||||
String forumName = i.getStringExtra("briar.FORUM_NAME");
|
||||
if (forumName != null) setTitle(forumName);
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setLayoutParams(MATCH_MATCH);
|
||||
@@ -101,7 +101,7 @@ OnClickListener, OnItemClickListener {
|
||||
empty.setVisibility(GONE);
|
||||
layout.addView(empty);
|
||||
|
||||
adapter = new GroupAdapter(this);
|
||||
adapter = new ForumAdapter(this);
|
||||
list = new ListView(this);
|
||||
list.setLayoutParams(MATCH_WRAP_1);
|
||||
list.setAdapter(adapter);
|
||||
@@ -144,11 +144,11 @@ OnClickListener, OnItemClickListener {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
eventBus.addListener(this);
|
||||
loadGroup();
|
||||
loadForum();
|
||||
loadHeaders();
|
||||
}
|
||||
|
||||
private void loadGroup() {
|
||||
private void loadForum() {
|
||||
runOnDbThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
@@ -157,7 +157,7 @@ OnClickListener, OnItemClickListener {
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Loading group " + duration + " ms");
|
||||
displayGroupName();
|
||||
displayForumName();
|
||||
} catch (NoSuchSubscriptionException e) {
|
||||
finishOnUiThread();
|
||||
} catch (DbException e) {
|
||||
@@ -168,7 +168,7 @@ OnClickListener, OnItemClickListener {
|
||||
});
|
||||
}
|
||||
|
||||
private void displayGroupName() {
|
||||
private void displayForumName() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
setTitle(group.getName());
|
||||
@@ -209,13 +209,13 @@ OnClickListener, OnItemClickListener {
|
||||
empty.setVisibility(GONE);
|
||||
list.setVisibility(VISIBLE);
|
||||
for (MessageHeader h : headers) {
|
||||
GroupItem item = new GroupItem(h);
|
||||
ForumItem item = new ForumItem(h);
|
||||
byte[] body = bodyCache.get(h.getId());
|
||||
if (body == null) loadMessageBody(h);
|
||||
else item.setBody(body);
|
||||
adapter.add(item);
|
||||
}
|
||||
adapter.sort(GroupItemComparator.INSTANCE);
|
||||
adapter.sort(ForumItemComparator.INSTANCE);
|
||||
// Scroll to the bottom
|
||||
list.setSelection(adapter.getCount() - 1);
|
||||
}
|
||||
@@ -250,7 +250,7 @@ OnClickListener, OnItemClickListener {
|
||||
bodyCache.put(m, body);
|
||||
int count = adapter.getCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
GroupItem item = adapter.getItem(i);
|
||||
ForumItem item = adapter.getItem(i);
|
||||
if (item.getHeader().getId().equals(m)) {
|
||||
item.setBody(body);
|
||||
adapter.notifyDataSetChanged();
|
||||
@@ -281,7 +281,7 @@ OnClickListener, OnItemClickListener {
|
||||
}
|
||||
|
||||
private void markMessagesRead() {
|
||||
notificationManager.clearGroupPostNotification(groupId);
|
||||
notificationManager.clearForumPostNotification(groupId);
|
||||
List<MessageId> unread = new ArrayList<MessageId>();
|
||||
int count = adapter.getCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -331,15 +331,15 @@ OnClickListener, OnItemClickListener {
|
||||
|
||||
public void onClick(View view) {
|
||||
if (view == composeButton) {
|
||||
Intent i = new Intent(this, WriteGroupPostActivity.class);
|
||||
Intent i = new Intent(this, WriteForumPostActivity.class);
|
||||
i.putExtra("briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", group.getName());
|
||||
i.putExtra("briar.FORUM_NAME", group.getName());
|
||||
i.putExtra("briar.MIN_TIMESTAMP", getMinTimestampForNewMessage());
|
||||
startActivity(i);
|
||||
} else if (view == shareButton) {
|
||||
Intent i = new Intent(this, ShareGroupActivity.class);
|
||||
Intent i = new Intent(this, ShareForumActivity.class);
|
||||
i.putExtra("briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", group.getName());
|
||||
i.putExtra("briar.FORUM_NAME", group.getName());
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
@@ -362,9 +362,9 @@ OnClickListener, OnItemClickListener {
|
||||
|
||||
private void displayMessage(int position) {
|
||||
MessageHeader item = adapter.getItem(position).getHeader();
|
||||
Intent i = new Intent(this, ReadGroupPostActivity.class);
|
||||
Intent i = new Intent(this, ReadForumPostActivity.class);
|
||||
i.putExtra("briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", group.getName());
|
||||
i.putExtra("briar.FORUM_NAME", group.getName());
|
||||
i.putExtra("briar.MESSAGE_ID", item.getId().getBytes());
|
||||
Author author = item.getAuthor();
|
||||
if (author != null) i.putExtra("briar.AUTHOR_NAME", author.getName());
|
||||
@@ -1,19 +1,4 @@
|
||||
package org.briarproject.android.groups;
|
||||
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.Gravity.CENTER_VERTICAL;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.AuthorView;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.Author;
|
||||
import org.briarproject.api.db.MessageHeader;
|
||||
import org.briarproject.util.StringUtils;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -25,19 +10,34 @@ import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
class GroupAdapter extends ArrayAdapter<GroupItem> {
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.AuthorView;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.Author;
|
||||
import org.briarproject.api.db.MessageHeader;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.Gravity.CENTER_VERTICAL;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
class ForumAdapter extends ArrayAdapter<ForumItem> {
|
||||
|
||||
private final int pad;
|
||||
|
||||
GroupAdapter(Context ctx) {
|
||||
ForumAdapter(Context ctx) {
|
||||
super(ctx, android.R.layout.simple_expandable_list_item_1,
|
||||
new ArrayList<GroupItem>());
|
||||
new ArrayList<ForumItem>());
|
||||
pad = LayoutUtils.getPadding(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
GroupItem item = getItem(position);
|
||||
ForumItem item = getItem(position);
|
||||
MessageHeader header = item.getHeader();
|
||||
Context ctx = getContext();
|
||||
Resources res = ctx.getResources();
|
||||
@@ -1,16 +1,16 @@
|
||||
package org.briarproject.android.groups;
|
||||
|
||||
import java.util.Collection;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import org.briarproject.api.Contact;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
|
||||
class GroupContacts {
|
||||
import java.util.Collection;
|
||||
|
||||
class ForumContacts {
|
||||
|
||||
private final Group group;
|
||||
private final Collection<Contact> contacts;
|
||||
|
||||
GroupContacts(Group group, Collection<Contact> contacts) {
|
||||
ForumContacts(Group group, Collection<Contact> contacts) {
|
||||
this.group = group;
|
||||
this.contacts = contacts;
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import org.briarproject.api.db.MessageHeader;
|
||||
|
||||
// This class is not thread-safe
|
||||
class GroupItem {
|
||||
class ForumItem {
|
||||
|
||||
private final MessageHeader header;
|
||||
private byte[] body;
|
||||
|
||||
GroupItem(MessageHeader header) {
|
||||
ForumItem(MessageHeader header) {
|
||||
this.header = header;
|
||||
body = null;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
class GroupItemComparator implements Comparator<GroupItem> {
|
||||
class ForumItemComparator implements Comparator<ForumItem> {
|
||||
|
||||
static final GroupItemComparator INSTANCE = new GroupItemComparator();
|
||||
static final ForumItemComparator INSTANCE = new ForumItemComparator();
|
||||
|
||||
public int compare(GroupItem a, GroupItem b) {
|
||||
public int compare(ForumItem a, ForumItem b) {
|
||||
// The oldest message comes first
|
||||
long aTime = a.getHeader().getTimestamp();
|
||||
long bTime = b.getHeader().getTimestamp();
|
||||
@@ -1,25 +1,22 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.Menu.NONE;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnCreateContextMenuListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
@@ -41,41 +38,44 @@ import org.briarproject.api.event.SubscriptionRemovedEvent;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnCreateContextMenuListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class GroupListActivity extends BriarActivity
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.Menu.NONE;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
|
||||
public class ForumListActivity extends BriarActivity
|
||||
implements EventListener, OnClickListener, OnItemClickListener,
|
||||
OnCreateContextMenuListener {
|
||||
|
||||
private static final int MENU_ITEM_UNSUBSCRIBE = 1;
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(GroupListActivity.class.getName());
|
||||
Logger.getLogger(ForumListActivity.class.getName());
|
||||
|
||||
private final Map<GroupId,GroupId> groups =
|
||||
new ConcurrentHashMap<GroupId,GroupId>();
|
||||
private final Map<GroupId, GroupId> groupIds =
|
||||
new ConcurrentHashMap<GroupId, GroupId>();
|
||||
|
||||
private TextView empty = null;
|
||||
private GroupListAdapter adapter = null;
|
||||
private ForumListAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
private TextView available = null;
|
||||
private ImageButton newGroupButton = null;
|
||||
private ImageButton newForumButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@@ -99,7 +99,7 @@ OnCreateContextMenuListener {
|
||||
empty.setVisibility(GONE);
|
||||
layout.addView(empty);
|
||||
|
||||
adapter = new GroupListAdapter(this);
|
||||
adapter = new ForumListAdapter(this);
|
||||
list = new ListView(this);
|
||||
list.setLayoutParams(MATCH_WRAP_1);
|
||||
list.setAdapter(adapter);
|
||||
@@ -131,11 +131,11 @@ OnCreateContextMenuListener {
|
||||
footer.setOrientation(HORIZONTAL);
|
||||
footer.setGravity(CENTER);
|
||||
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
|
||||
newGroupButton = new ImageButton(this);
|
||||
newGroupButton.setBackgroundResource(0);
|
||||
newGroupButton.setImageResource(R.drawable.social_new_chat);
|
||||
newGroupButton.setOnClickListener(this);
|
||||
footer.addView(newGroupButton);
|
||||
newForumButton = new ImageButton(this);
|
||||
newForumButton.setBackgroundResource(0);
|
||||
newForumButton.setImageResource(R.drawable.social_new_chat);
|
||||
newForumButton.setOnClickListener(this);
|
||||
footer.addView(newForumButton);
|
||||
layout.addView(footer);
|
||||
|
||||
setContentView(layout);
|
||||
@@ -177,7 +177,7 @@ OnCreateContextMenuListener {
|
||||
private void clearHeaders() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
groups.clear();
|
||||
groupIds.clear();
|
||||
empty.setVisibility(GONE);
|
||||
list.setVisibility(GONE);
|
||||
available.setVisibility(GONE);
|
||||
@@ -193,15 +193,15 @@ OnCreateContextMenuListener {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
GroupId id = g.getId();
|
||||
groups.put(id, id);
|
||||
groupIds.put(id, id);
|
||||
list.setVisibility(VISIBLE);
|
||||
loading.setVisibility(GONE);
|
||||
// Remove the old item, if any
|
||||
GroupListItem item = findGroup(id);
|
||||
ForumListItem item = findForum(id);
|
||||
if (item != null) adapter.remove(item);
|
||||
// Add a new item
|
||||
adapter.add(new GroupListItem(g, headers));
|
||||
adapter.sort(GroupListItemComparator.INSTANCE);
|
||||
adapter.add(new ForumListItem(g, headers));
|
||||
adapter.sort(ForumListItemComparator.INSTANCE);
|
||||
adapter.notifyDataSetChanged();
|
||||
selectFirstUnread();
|
||||
}
|
||||
@@ -225,10 +225,10 @@ OnCreateContextMenuListener {
|
||||
});
|
||||
}
|
||||
|
||||
private GroupListItem findGroup(GroupId g) {
|
||||
private ForumListItem findForum(GroupId g) {
|
||||
int count = adapter.getCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
GroupListItem item = adapter.getItem(i);
|
||||
ForumListItem item = adapter.getItem(i);
|
||||
if (item.getGroup().getId().equals(g)) return item;
|
||||
}
|
||||
return null; // Not found
|
||||
@@ -255,7 +255,7 @@ OnCreateContextMenuListener {
|
||||
public void eventOccurred(Event e) {
|
||||
if (e instanceof MessageAddedEvent) {
|
||||
Group g = ((MessageAddedEvent) e).getGroup();
|
||||
if (groups.containsKey(g.getId())) {
|
||||
if (groupIds.containsKey(g.getId())) {
|
||||
LOG.info("Message added, reloading");
|
||||
loadHeaders(g);
|
||||
}
|
||||
@@ -270,7 +270,7 @@ OnCreateContextMenuListener {
|
||||
loadHeaders();
|
||||
} else if (e instanceof SubscriptionRemovedEvent) {
|
||||
Group g = ((SubscriptionRemovedEvent) e).getGroup();
|
||||
if (groups.containsKey(g.getId())) {
|
||||
if (groupIds.containsKey(g.getId())) {
|
||||
LOG.info("Group removed, reloading");
|
||||
loadHeaders();
|
||||
}
|
||||
@@ -289,7 +289,7 @@ OnCreateContextMenuListener {
|
||||
LOG.info("Partial load took " + duration + " ms");
|
||||
displayHeaders(g, headers);
|
||||
} catch (NoSuchSubscriptionException e) {
|
||||
removeGroup(g.getId());
|
||||
removeForum(g.getId());
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
@@ -298,12 +298,12 @@ OnCreateContextMenuListener {
|
||||
});
|
||||
}
|
||||
|
||||
private void removeGroup(final GroupId g) {
|
||||
private void removeForum(final GroupId g) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
GroupListItem item = findGroup(g);
|
||||
ForumListItem item = findForum(g);
|
||||
if (item != null) {
|
||||
groups.remove(g);
|
||||
groupIds.remove(g);
|
||||
adapter.remove(item);
|
||||
adapter.notifyDataSetChanged();
|
||||
if (adapter.isEmpty()) {
|
||||
@@ -337,18 +337,18 @@ OnCreateContextMenuListener {
|
||||
|
||||
public void onClick(View view) {
|
||||
if (view == available) {
|
||||
startActivity(new Intent(this, AvailableGroupsActivity.class));
|
||||
} else if (view == newGroupButton) {
|
||||
startActivity(new Intent(this, CreateGroupActivity.class));
|
||||
startActivity(new Intent(this, AvailableForumsActivity.class));
|
||||
} else if (view == newForumButton) {
|
||||
startActivity(new Intent(this, CreateForumActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
Intent i = new Intent(this, GroupActivity.class);
|
||||
Intent i = new Intent(this, ForumActivity.class);
|
||||
Group g = adapter.getItem(position).getGroup();
|
||||
i.putExtra("briar.GROUP_ID", g.getId().getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", g.getName());
|
||||
i.putExtra("briar.FORUM_NAME", g.getName());
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ OnCreateContextMenuListener {
|
||||
if (menuItem.getItemId() == MENU_ITEM_UNSUBSCRIBE) {
|
||||
ContextMenuInfo info = menuItem.getMenuInfo();
|
||||
int position = ((AdapterContextMenuInfo) info).position;
|
||||
GroupListItem item = adapter.getItem(position);
|
||||
ForumListItem item = adapter.getItem(position);
|
||||
removeSubscription(item.getGroup());
|
||||
String unsubscribed = getString(R.string.unsubscribed_toast);
|
||||
Toast.makeText(this, unsubscribed, LENGTH_SHORT).show();
|
||||
@@ -1,13 +1,4 @@
|
||||
package org.briarproject.android.groups;
|
||||
|
||||
import static android.text.TextUtils.TruncateAt.END;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -18,19 +9,28 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
class GroupListAdapter extends ArrayAdapter<GroupListItem> {
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static android.text.TextUtils.TruncateAt.END;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
class ForumListAdapter extends ArrayAdapter<ForumListItem> {
|
||||
|
||||
private final int pad;
|
||||
|
||||
GroupListAdapter(Context ctx) {
|
||||
ForumListAdapter(Context ctx) {
|
||||
super(ctx, android.R.layout.simple_expandable_list_item_1,
|
||||
new ArrayList<GroupListItem>());
|
||||
new ArrayList<ForumListItem>());
|
||||
pad = LayoutUtils.getPadding(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
GroupListItem item = getItem(position);
|
||||
ForumListItem item = getItem(position);
|
||||
Context ctx = getContext();
|
||||
Resources res = ctx.getResources();
|
||||
|
||||
@@ -46,9 +46,9 @@ class GroupListAdapter extends ArrayAdapter<GroupListItem> {
|
||||
name.setSingleLine();
|
||||
name.setEllipsize(END);
|
||||
name.setPadding(pad, pad, pad, pad);
|
||||
String groupName = item.getGroup().getName();
|
||||
if (unread > 0) name.setText(groupName + " (" + unread + ")");
|
||||
else name.setText(groupName);
|
||||
String forumName = item.getGroup().getName();
|
||||
if (unread > 0) name.setText(forumName + " (" + unread + ")");
|
||||
else name.setText(forumName);
|
||||
layout.addView(name);
|
||||
|
||||
if (item.isEmpty()) {
|
||||
@@ -1,30 +1,26 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.briarproject.api.Author;
|
||||
import org.briarproject.api.db.MessageHeader;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
|
||||
class GroupListItem {
|
||||
import java.util.Collection;
|
||||
|
||||
class ForumListItem {
|
||||
|
||||
private final Group group;
|
||||
private final boolean empty;
|
||||
private final String authorName, contentType;
|
||||
private final long timestamp;
|
||||
private final int unread;
|
||||
|
||||
GroupListItem(Group group, Collection<MessageHeader> headers) {
|
||||
ForumListItem(Group group, Collection<MessageHeader> headers) {
|
||||
this.group = group;
|
||||
empty = headers.isEmpty();
|
||||
if (empty) {
|
||||
authorName = null;
|
||||
contentType = null;
|
||||
timestamp = 0;
|
||||
unread = 0;
|
||||
} else {
|
||||
MessageHeader newest = null;
|
||||
long timestamp = 0;
|
||||
long timestamp = -1;
|
||||
int unread = 0;
|
||||
for (MessageHeader h : headers) {
|
||||
if (h.getTimestamp() > timestamp) {
|
||||
@@ -33,10 +29,6 @@ class GroupListItem {
|
||||
}
|
||||
if (!h.isRead()) unread++;
|
||||
}
|
||||
Author a = newest.getAuthor();
|
||||
if (a == null) authorName = null;
|
||||
else authorName = a.getName();
|
||||
contentType = newest.getContentType();
|
||||
this.timestamp = newest.getTimestamp();
|
||||
this.unread = unread;
|
||||
}
|
||||
@@ -50,14 +42,6 @@ class GroupListItem {
|
||||
return empty;
|
||||
}
|
||||
|
||||
String getAuthorName() {
|
||||
return authorName;
|
||||
}
|
||||
|
||||
String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
class GroupListItemComparator implements Comparator<GroupListItem> {
|
||||
class ForumListItemComparator implements Comparator<ForumListItem> {
|
||||
|
||||
static final GroupListItemComparator INSTANCE =
|
||||
new GroupListItemComparator();
|
||||
static final ForumListItemComparator INSTANCE =
|
||||
new ForumListItemComparator();
|
||||
|
||||
public int compare(GroupListItem a, GroupListItem b) {
|
||||
public int compare(ForumListItem a, ForumListItem b) {
|
||||
if (a == b) return 0;
|
||||
// The item with the newest message comes first
|
||||
long aTime = a.getTimestamp(), bTime = b.getTimestamp();
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.android.groups;
|
||||
|
||||
import org.briarproject.R;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
import org.briarproject.R;
|
||||
|
||||
public class NoContactsDialog {
|
||||
|
||||
private Listener listener = null;
|
||||
@@ -1,18 +1,15 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_VERTICAL;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
@@ -28,29 +25,32 @@ import org.briarproject.api.messaging.GroupId;
|
||||
import org.briarproject.api.messaging.MessageId;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ReadGroupPostActivity extends BriarActivity
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_VERTICAL;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
public class ReadForumPostActivity extends BriarActivity
|
||||
implements OnClickListener {
|
||||
|
||||
static final int RESULT_REPLY = RESULT_FIRST_USER;
|
||||
static final int RESULT_PREV_NEXT = RESULT_FIRST_USER + 1;
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ReadGroupPostActivity.class.getName());
|
||||
Logger.getLogger(ReadForumPostActivity.class.getName());
|
||||
|
||||
private GroupId groupId = null;
|
||||
private String groupName = null;
|
||||
private long timestamp = -1, minTimestamp = -1;
|
||||
private String forumName = null;
|
||||
private long minTimestamp = -1;
|
||||
private ImageButton prevButton = null, nextButton = null;
|
||||
private ImageButton replyButton = null;
|
||||
private TextView content = null;
|
||||
@@ -68,15 +68,15 @@ implements OnClickListener {
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if (b == null) throw new IllegalStateException();
|
||||
groupId = new GroupId(b);
|
||||
groupName = i.getStringExtra("briar.GROUP_NAME");
|
||||
if (groupName == null) throw new IllegalStateException();
|
||||
setTitle(groupName);
|
||||
forumName = i.getStringExtra("briar.FORUM_NAME");
|
||||
if (forumName == null) throw new IllegalStateException();
|
||||
setTitle(forumName);
|
||||
b = i.getByteArrayExtra("briar.MESSAGE_ID");
|
||||
if (b == null) throw new IllegalStateException();
|
||||
messageId = new MessageId(b);
|
||||
String contentType = i.getStringExtra("briar.CONTENT_TYPE");
|
||||
if (contentType == null) throw new IllegalStateException();
|
||||
timestamp = i.getLongExtra("briar.TIMESTAMP", -1);
|
||||
long timestamp = i.getLongExtra("briar.TIMESTAMP", -1);
|
||||
if (timestamp == -1) throw new IllegalStateException();
|
||||
minTimestamp = i.getLongExtra("briar.MIN_TIMESTAMP", -1);
|
||||
if (minTimestamp == -1) throw new IllegalStateException();
|
||||
@@ -221,9 +221,9 @@ implements OnClickListener {
|
||||
setResult(RESULT_PREV_NEXT, i);
|
||||
finish();
|
||||
} else if (view == replyButton) {
|
||||
Intent i = new Intent(this, WriteGroupPostActivity.class);
|
||||
Intent i = new Intent(this, WriteForumPostActivity.class);
|
||||
i.putExtra("briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", groupName);
|
||||
i.putExtra("briar.FORUM_NAME", forumName);
|
||||
i.putExtra("briar.PARENT_ID", messageId.getBytes());
|
||||
i.putExtra("briar.MIN_TIMESTAMP", minTimestamp);
|
||||
startActivity(i);
|
||||
@@ -1,19 +1,14 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
@@ -26,24 +21,28 @@ import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ShareGroupActivity extends BriarActivity
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||
|
||||
public class ShareForumActivity extends BriarActivity
|
||||
implements OnClickListener, NoContactsDialog.Listener,
|
||||
SelectContactsDialog.Listener {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ShareGroupActivity.class.getName());
|
||||
Logger.getLogger(ShareForumActivity.class.getName());
|
||||
|
||||
private String groupName = null;
|
||||
private RadioGroup radioGroup = null;
|
||||
private RadioButton shareWithAll = null, shareWithSome = null;
|
||||
private Button shareButton = null;
|
||||
@@ -64,9 +63,9 @@ SelectContactsDialog.Listener {
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if (b == null) throw new IllegalStateException();
|
||||
groupId = new GroupId(b);
|
||||
groupName = i.getStringExtra("briar.GROUP_NAME");
|
||||
if (groupName == null) throw new IllegalStateException();
|
||||
setTitle(groupName);
|
||||
String forumName = i.getStringExtra("briar.FORUM_NAME");
|
||||
if (forumName == null) throw new IllegalStateException();
|
||||
setTitle(forumName);
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setLayoutParams(MATCH_MATCH);
|
||||
@@ -156,14 +155,14 @@ SelectContactsDialog.Listener {
|
||||
public void run() {
|
||||
if (contacts.isEmpty()) {
|
||||
NoContactsDialog builder = new NoContactsDialog();
|
||||
builder.setListener(ShareGroupActivity.this);
|
||||
builder.build(ShareGroupActivity.this).show();
|
||||
builder.setListener(ShareForumActivity.this);
|
||||
builder.build(ShareForumActivity.this).show();
|
||||
} else {
|
||||
SelectContactsDialog builder = new SelectContactsDialog();
|
||||
builder.setListener(ShareGroupActivity.this);
|
||||
builder.setListener(ShareForumActivity.this);
|
||||
builder.setContacts(contacts);
|
||||
builder.setSelected(selected);
|
||||
builder.build(ShareGroupActivity.this).show();
|
||||
builder.build(ShareForumActivity.this).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,25 +1,19 @@
|
||||
package org.briarproject.android.groups;
|
||||
package org.briarproject.android.forum;
|
||||
|
||||
import static android.text.InputType.TYPE_CLASS_TEXT;
|
||||
import static android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT;
|
||||
import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT;
|
||||
import static android.widget.RelativeLayout.CENTER_VERTICAL;
|
||||
import static android.widget.RelativeLayout.LEFT_OF;
|
||||
import static android.widget.RelativeLayout.RIGHT_OF;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
@@ -44,27 +38,33 @@ import org.briarproject.api.messaging.MessageFactory;
|
||||
import org.briarproject.api.messaging.MessageId;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class WriteGroupPostActivity extends BriarActivity
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.text.InputType.TYPE_CLASS_TEXT;
|
||||
import static android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static android.widget.RelativeLayout.ALIGN_PARENT_LEFT;
|
||||
import static android.widget.RelativeLayout.ALIGN_PARENT_RIGHT;
|
||||
import static android.widget.RelativeLayout.CENTER_VERTICAL;
|
||||
import static android.widget.RelativeLayout.LEFT_OF;
|
||||
import static android.widget.RelativeLayout.RIGHT_OF;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||
|
||||
public class WriteForumPostActivity extends BriarActivity
|
||||
implements OnItemSelectedListener, OnClickListener {
|
||||
|
||||
private static final int REQUEST_CREATE_IDENTITY = 2;
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(WriteGroupPostActivity.class.getName());
|
||||
Logger.getLogger(WriteForumPostActivity.class.getName());
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
private LocalAuthorSpinnerAdapter adapter = null;
|
||||
@@ -91,9 +91,9 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if (b == null) throw new IllegalStateException();
|
||||
groupId = new GroupId(b);
|
||||
String groupName = i.getStringExtra("briar.GROUP_NAME");
|
||||
if (groupName == null) throw new IllegalStateException();
|
||||
setTitle(groupName);
|
||||
String forumName = i.getStringExtra("briar.FORUM_NAME");
|
||||
if (forumName == null) throw new IllegalStateException();
|
||||
setTitle(forumName);
|
||||
minTimestamp = i.getLongExtra("briar.MIN_TIMESTAMP", -1);
|
||||
if (minTimestamp == -1) throw new IllegalStateException();
|
||||
b = i.getByteArrayExtra("briar.PARENT_ID");
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.briarproject.android.groups;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.briarproject.api.Contact;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
|
||||
class AvailableGroupsItem {
|
||||
|
||||
private final GroupContacts groupContacts;
|
||||
|
||||
AvailableGroupsItem(GroupContacts groupContacts) {
|
||||
this.groupContacts = groupContacts;
|
||||
}
|
||||
|
||||
Group getGroup() {
|
||||
return groupContacts.getGroup();
|
||||
}
|
||||
|
||||
Collection<Contact> getContacts() {
|
||||
return groupContacts.getContacts();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.briarproject.android.groups;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
class AvailableGroupsItemComparator implements Comparator<AvailableGroupsItem> {
|
||||
|
||||
static final AvailableGroupsItemComparator INSTANCE =
|
||||
new AvailableGroupsItemComparator();
|
||||
|
||||
public int compare(AvailableGroupsItem a, AvailableGroupsItem b) {
|
||||
if (a == b) return 0;
|
||||
String aName = a.getGroup().getName();
|
||||
String bName = b.getGroup().getName();
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(aName, bName);
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,13 @@ import org.briarproject.api.messaging.GroupId;
|
||||
*/
|
||||
public interface AndroidNotificationManager extends Service {
|
||||
|
||||
public void showPrivateMessageNotification(ContactId c);
|
||||
void showPrivateMessageNotification(ContactId c);
|
||||
|
||||
public void clearPrivateMessageNotification(ContactId c);
|
||||
void clearPrivateMessageNotification(ContactId c);
|
||||
|
||||
public void showGroupPostNotification(GroupId g);
|
||||
void showForumPostNotification(GroupId g);
|
||||
|
||||
public void clearGroupPostNotification(GroupId g);
|
||||
void clearForumPostNotification(GroupId g);
|
||||
|
||||
public void clearNotifications();
|
||||
void clearNotifications();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user