diff --git a/briar-android/res/drawable-hdpi/social_share.png b/briar-android/res/drawable-hdpi/social_share.png
deleted file mode 100644
index 47ae18674..000000000
Binary files a/briar-android/res/drawable-hdpi/social_share.png and /dev/null differ
diff --git a/briar-android/res/drawable-mdpi/social_share.png b/briar-android/res/drawable-mdpi/social_share.png
deleted file mode 100644
index 8aa52bc7d..000000000
Binary files a/briar-android/res/drawable-mdpi/social_share.png and /dev/null differ
diff --git a/briar-android/res/drawable-xhdpi/social_share.png b/briar-android/res/drawable-xhdpi/social_share.png
deleted file mode 100644
index cdafd8abc..000000000
Binary files a/briar-android/res/drawable-xhdpi/social_share.png and /dev/null differ
diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml
index 7dabb29c7..50b17cc29 100644
--- a/briar-android/res/values/strings.xml
+++ b/briar-android/res/values/strings.xml
@@ -17,7 +17,6 @@
Quit
New identity\u2026
Contacts
- Share the Briar App
Connected
Last connected <br /> %1$s
Add a Contact
@@ -71,16 +70,15 @@
Share this forum with chosen contacts
New Post
New forum\u2026
- Manage Subscriptions
+ Available Forums
No forums available from contacts
Subscribed, shared with all contacts
Subscribed, shared with chosen contacts
Not subscribed
New nickname\u2026
- New Identity
+ New Nickname
Create
You don\'t have any contacts. Add a contact now?
Add
Cancel
- You aren\'t subscribed to any forums. Create a forum now?
diff --git a/briar-android/src/net/sf/briar/android/contact/ContactListActivity.java b/briar-android/src/net/sf/briar/android/contact/ContactListActivity.java
index e1f939324..f1e3316e4 100644
--- a/briar-android/src/net/sf/briar/android/contact/ContactListActivity.java
+++ b/briar-android/src/net/sf/briar/android/contact/ContactListActivity.java
@@ -1,20 +1,14 @@
package net.sf.briar.android.contact;
-import static android.content.Intent.ACTION_SEND;
-import static android.content.Intent.EXTRA_STREAM;
-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.HORIZONTAL;
import static android.widget.LinearLayout.VERTICAL;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static net.sf.briar.android.util.CommonLayoutParams.MATCH_MATCH;
-import static net.sf.briar.android.util.CommonLayoutParams.MATCH_WRAP;
import static net.sf.briar.android.util.CommonLayoutParams.MATCH_WRAP_1;
-import java.io.File;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
@@ -26,7 +20,6 @@ import javax.inject.Inject;
import net.sf.briar.R;
import net.sf.briar.android.invitation.AddContactActivity;
import net.sf.briar.android.util.HorizontalBorder;
-import net.sf.briar.android.util.HorizontalSpace;
import net.sf.briar.android.util.ListLoadingProgressBar;
import net.sf.briar.api.Contact;
import net.sf.briar.api.ContactId;
@@ -46,7 +39,6 @@ import net.sf.briar.api.transport.ConnectionListener;
import net.sf.briar.api.transport.ConnectionRegistry;
import roboguice.activity.RoboActivity;
import android.content.Intent;
-import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
@@ -64,7 +56,7 @@ implements OnClickListener, DatabaseListener, ConnectionListener {
private ContactListAdapter adapter = null;
private ListView list = null;
private ListLoadingProgressBar loading = null;
- private ImageButton addContactButton = null, shareButton = null;
+ private ImageButton addContactButton = null;
// Fields that are accessed from background threads must be volatile
@Inject private volatile DatabaseComponent db;
@@ -94,26 +86,11 @@ implements OnClickListener, DatabaseListener, ConnectionListener {
layout.addView(new HorizontalBorder(this));
- LinearLayout footer = new LinearLayout(this);
- footer.setLayoutParams(MATCH_WRAP);
- footer.setOrientation(HORIZONTAL);
- footer.setGravity(CENTER);
- footer.addView(new HorizontalSpace(this));
-
addContactButton = new ImageButton(this);
addContactButton.setBackgroundResource(0);
addContactButton.setImageResource(R.drawable.social_add_person);
addContactButton.setOnClickListener(this);
- footer.addView(addContactButton);
- footer.addView(new HorizontalSpace(this));
-
- shareButton = new ImageButton(this);
- shareButton.setBackgroundResource(0);
- shareButton.setImageResource(R.drawable.social_share);
- shareButton.setOnClickListener(this);
- footer.addView(shareButton);
- footer.addView(new HorizontalSpace(this));
- layout.addView(footer);
+ layout.addView(addContactButton);
setContentView(layout);
}
@@ -218,16 +195,7 @@ implements OnClickListener, DatabaseListener, ConnectionListener {
}
public void onClick(View view) {
- if(view == addContactButton) {
- startActivity(new Intent(this, AddContactActivity.class));
- } else if(view == shareButton) {
- String apkPath = getPackageCodePath();
- Intent i = new Intent(ACTION_SEND);
- i.setType("application/*");
- i.putExtra(EXTRA_STREAM, Uri.fromFile(new File(apkPath)));
- String shareApp = getResources().getString(R.string.share_app);
- startActivity(Intent.createChooser(i, shareApp));
- }
+ startActivity(new Intent(this, AddContactActivity.class));
}
public void eventOccurred(DatabaseEvent e) {
diff --git a/briar-android/src/net/sf/briar/android/groups/GroupListActivity.java b/briar-android/src/net/sf/briar/android/groups/GroupListActivity.java
index 894e67c68..0689eba6d 100644
--- a/briar-android/src/net/sf/briar/android/groups/GroupListActivity.java
+++ b/briar-android/src/net/sf/briar/android/groups/GroupListActivity.java
@@ -54,8 +54,7 @@ import android.widget.LinearLayout;
import android.widget.ListView;
public class GroupListActivity extends RoboFragmentActivity
-implements DatabaseListener, OnClickListener, NoGroupsDialog.Listener,
-OnItemClickListener {
+implements DatabaseListener, OnClickListener, OnItemClickListener {
private static final Logger LOG =
Logger.getLogger(GroupListActivity.class.getName());
@@ -66,8 +65,7 @@ OnItemClickListener {
private GroupListAdapter adapter = null;
private ListView list = null;
private ListLoadingProgressBar loading = null;
- private ImageButton newGroupButton = null, composeButton = null;
- private ImageButton manageGroupsButton = null;
+ private ImageButton newGroupButton = null, manageGroupsButton = null;
// Fields that are accessed from background threads must be volatile
@Inject private volatile DatabaseComponent db;
@@ -110,13 +108,6 @@ OnItemClickListener {
footer.addView(newGroupButton);
footer.addView(new HorizontalSpace(this));
- composeButton = new ImageButton(this);
- composeButton.setBackgroundResource(0);
- composeButton.setImageResource(R.drawable.content_new_email);
- composeButton.setOnClickListener(this);
- footer.addView(composeButton);
- footer.addView(new HorizontalSpace(this));
-
manageGroupsButton = new ImageButton(this);
manageGroupsButton.setBackgroundResource(0);
manageGroupsButton.setImageResource(R.drawable.action_settings);
@@ -343,25 +334,11 @@ OnItemClickListener {
public void onClick(View view) {
if(view == newGroupButton) {
startActivity(new Intent(this, CreateGroupActivity.class));
- } else if(view == composeButton) {
- if(adapter.isEmpty()) {
- NoGroupsDialog dialog = new NoGroupsDialog();
- dialog.setListener(this);
- dialog.show(getSupportFragmentManager(), "NoGroupsDialog");
- } else {
- startActivity(new Intent(this, WriteGroupPostActivity.class));
- }
} else if(view == manageGroupsButton) {
startActivity(new Intent(this, ManageGroupsActivity.class));
}
}
- public void groupCreationSelected() {
- startActivity(new Intent(this, CreateGroupActivity.class));
- }
-
- public void groupCreationCancelled() {}
-
public void onItemClick(AdapterView> parent, View view, int position,
long id) {
GroupListItem item = adapter.getItem(position);
diff --git a/briar-android/src/net/sf/briar/android/groups/GroupSpinnerAdapter.java b/briar-android/src/net/sf/briar/android/groups/GroupSpinnerAdapter.java
deleted file mode 100644
index 73cbbd715..000000000
--- a/briar-android/src/net/sf/briar/android/groups/GroupSpinnerAdapter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package net.sf.briar.android.groups;
-
-import static net.sf.briar.android.groups.GroupItem.NEW;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import net.sf.briar.R;
-import android.content.Context;
-import android.content.res.Resources;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.SpinnerAdapter;
-import android.widget.TextView;
-
-class GroupSpinnerAdapter extends BaseAdapter implements SpinnerAdapter {
-
- private final Context ctx;
- private final List list = new ArrayList();
-
- GroupSpinnerAdapter(Context ctx) {
- this.ctx = ctx;
- }
-
- public void add(GroupItem item) {
- list.add(item);
- }
-
- public void clear() {
- list.clear();
- }
-
- public int getCount() {
- return list.isEmpty() ? 0 : list.size() + 1;
- }
-
- @Override
- public View getDropDownView(int position, View convertView,
- ViewGroup parent) {
- return getView(position, convertView, parent);
- }
-
- public GroupItem getItem(int position) {
- if(position == list.size()) return NEW;
- return list.get(position);
- }
-
- public long getItemId(int position) {
- return android.R.layout.simple_spinner_item;
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- TextView name = new TextView(ctx);
- name.setTextSize(18);
- name.setMaxLines(1);
- Resources res = ctx.getResources();
- int pad = res.getInteger(R.integer.spinner_padding);
- name.setPadding(pad, pad, pad, pad);
- GroupItem item = getItem(position);
- if(item == NEW) name.setText(R.string.new_forum_item);
- else name.setText(item.getGroup().getName());
- return name;
- }
-
- @Override
- public boolean isEmpty() {
- return list.isEmpty();
- }
-
- public void sort(Comparator comparator) {
- Collections.sort(list, comparator);
- }
-}
diff --git a/briar-android/src/net/sf/briar/android/groups/NoGroupsDialog.java b/briar-android/src/net/sf/briar/android/groups/NoGroupsDialog.java
deleted file mode 100644
index 4b51bd38c..000000000
--- a/briar-android/src/net/sf/briar/android/groups/NoGroupsDialog.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package net.sf.briar.android.groups;
-
-import net.sf.briar.R;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-
-public class NoGroupsDialog extends DialogFragment {
-
- private Listener listener = null;
-
- void setListener(Listener listener) {
- this.listener = listener;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle state) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setMessage(R.string.no_forums);
- builder.setPositiveButton(R.string.create_button,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- listener.groupCreationSelected();
- }
- });
- builder.setNegativeButton(R.string.cancel_button,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- listener.groupCreationCancelled();
- }
- });
- return builder.create();
- }
-
- interface Listener {
-
- void groupCreationSelected();
-
- void groupCreationCancelled();
- }
-}
diff --git a/briar-android/src/net/sf/briar/android/groups/WriteGroupPostActivity.java b/briar-android/src/net/sf/briar/android/groups/WriteGroupPostActivity.java
index 14f4f7f72..21e486015 100644
--- a/briar-android/src/net/sf/briar/android/groups/WriteGroupPostActivity.java
+++ b/briar-android/src/net/sf/briar/android/groups/WriteGroupPostActivity.java
@@ -11,7 +11,6 @@ import static net.sf.briar.android.util.CommonLayoutParams.MATCH_WRAP;
import java.io.IOException;
import java.security.GeneralSecurityException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.Executor;
import java.util.logging.Logger;
@@ -35,12 +34,12 @@ import net.sf.briar.api.db.DbException;
import net.sf.briar.api.lifecycle.LifecycleManager;
import net.sf.briar.api.messaging.Group;
import net.sf.briar.api.messaging.GroupId;
-import net.sf.briar.api.messaging.GroupStatus;
import net.sf.briar.api.messaging.Message;
import net.sf.briar.api.messaging.MessageFactory;
import net.sf.briar.api.messaging.MessageId;
import roboguice.activity.RoboActivity;
import android.content.Intent;
+import android.content.res.Resources;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
@@ -61,10 +60,10 @@ implements OnItemSelectedListener, OnClickListener {
@Inject private CryptoComponent crypto;
@Inject private MessageFactory messageFactory;
- private LocalAuthorSpinnerAdapter fromAdapter = null;
- private GroupSpinnerAdapter toAdapter = null;
- private Spinner fromSpinner = null, toSpinner = null;
+ private LocalAuthorSpinnerAdapter adapter = null;
+ private Spinner spinner = null;
private ImageButton sendButton = null;
+ private TextView to = null;
private EditText content = null;
private AuthorId localAuthorId = null;
private GroupId groupId = null;
@@ -84,7 +83,9 @@ implements OnItemSelectedListener, OnClickListener {
Intent i = getIntent();
byte[] b = i.getByteArrayExtra("net.sf.briar.GROUP_ID");
- if(b != null) groupId = new GroupId(b);
+ if(b == null) throw new IllegalStateException();
+ groupId = new GroupId(b);
+
b = i.getByteArrayExtra("net.sf.briar.PARENT_ID");
if(b != null) parentId = new MessageId(b);
timestamp = i.getLongExtra("net.sf.briar.TIMESTAMP", -1);
@@ -92,8 +93,6 @@ implements OnItemSelectedListener, OnClickListener {
if(state != null) {
b = state.getByteArray("net.sf.briar.LOCAL_AUTHOR_ID");
if(b != null) localAuthorId = new AuthorId(b);
- b = state.getByteArray("net.sf.briar.GROUP_ID");
- if(b != null) groupId = new GroupId(b);
}
LinearLayout layout = new LinearLayout(this);
@@ -111,39 +110,27 @@ implements OnItemSelectedListener, OnClickListener {
from.setText(R.string.from);
header.addView(from);
- fromAdapter = new LocalAuthorSpinnerAdapter(this, true);
- fromSpinner = new Spinner(this);
- fromSpinner.setAdapter(fromAdapter);
- fromSpinner.setOnItemSelectedListener(this);
- header.addView(fromSpinner);
+ adapter = new LocalAuthorSpinnerAdapter(this, true);
+ spinner = new Spinner(this);
+ spinner.setAdapter(adapter);
+ spinner.setOnItemSelectedListener(this);
+ header.addView(spinner);
header.addView(new HorizontalSpace(this));
sendButton = new ImageButton(this);
sendButton.setBackgroundResource(0);
sendButton.setImageResource(R.drawable.social_send_now);
- sendButton.setEnabled(false); // Enabled when a group is selected
+ sendButton.setEnabled(false); // Enabled after loading the group
sendButton.setOnClickListener(this);
header.addView(sendButton);
layout.addView(header);
- header = new LinearLayout(this);
- header.setLayoutParams(MATCH_WRAP);
- header.setOrientation(HORIZONTAL);
- header.setGravity(CENTER_VERTICAL);
-
- TextView to = new TextView(this);
+ to = new TextView(this);
to.setTextSize(18);
- to.setPadding(10, 0, 0, 10);
+ to.setPadding(10, 0, 10, 10);
to.setText(R.string.to);
- header.addView(to);
-
- toAdapter = new GroupSpinnerAdapter(this);
- toSpinner = new Spinner(this);
- toSpinner.setAdapter(toAdapter);
- toSpinner.setOnItemSelectedListener(this);
- header.addView(toSpinner);
- layout.addView(header);
+ layout.addView(to);
content = new EditText(this);
content.setId(1);
@@ -158,21 +145,21 @@ implements OnItemSelectedListener, OnClickListener {
@Override
public void onResume() {
super.onResume();
- loadLocalAuthors();
- loadGroups();
+ loadAuthorsAndGroup();
}
- private void loadLocalAuthors() {
+ private void loadAuthorsAndGroup() {
dbUiExecutor.execute(new Runnable() {
public void run() {
try {
lifecycleManager.waitForDatabase();
long now = System.currentTimeMillis();
Collection localAuthors = db.getLocalAuthors();
+ group = db.getGroup(groupId);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
- LOG.info("Loading authors took " + duration + " ms");
- displayLocalAuthors(localAuthors);
+ LOG.info("Load took " + duration + " ms");
+ displayAuthorsAndGroup(localAuthors);
} catch(DbException e) {
if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
@@ -184,73 +171,31 @@ implements OnItemSelectedListener, OnClickListener {
});
}
- private void displayLocalAuthors(
+ private void displayAuthorsAndGroup(
final Collection localAuthors) {
runOnUiThread(new Runnable() {
public void run() {
if(localAuthors.isEmpty()) throw new IllegalStateException();
- fromAdapter.clear();
+ adapter.clear();
for(LocalAuthor a : localAuthors)
- fromAdapter.add(new LocalAuthorItem(a));
- fromAdapter.sort(LocalAuthorItemComparator.INSTANCE);
- fromAdapter.notifyDataSetChanged();
- int count = fromAdapter.getCount();
+ adapter.add(new LocalAuthorItem(a));
+ adapter.sort(LocalAuthorItemComparator.INSTANCE);
+ adapter.notifyDataSetChanged();
+ int count = adapter.getCount();
for(int i = 0; i < count; i++) {
- LocalAuthorItem item = fromAdapter.getItem(i);
+ LocalAuthorItem item = adapter.getItem(i);
if(item == LocalAuthorItem.ANONYMOUS) continue;
if(item == LocalAuthorItem.NEW) continue;
if(item.getLocalAuthor().getId().equals(localAuthorId)) {
localAuthor = item.getLocalAuthor();
- fromSpinner.setSelection(i);
- break;
- }
- }
- }
- });
- }
-
- private void loadGroups() {
- dbUiExecutor.execute(new Runnable() {
- public void run() {
- try {
- lifecycleManager.waitForDatabase();
- long now = System.currentTimeMillis();
- Collection groups = new ArrayList();
- for(GroupStatus s : db.getAvailableGroups())
- if(s.isSubscribed()) groups.add(s.getGroup());
- long duration = System.currentTimeMillis() - now;
- if(LOG.isLoggable(INFO))
- LOG.info("Loading groups took " + duration + " ms");
- displayGroups(groups);
- } catch(DbException e) {
- if(LOG.isLoggable(WARNING))
- LOG.log(WARNING, e.toString(), e);
- } catch(InterruptedException e) {
- LOG.info("Interrupted while waiting for database");
- Thread.currentThread().interrupt();
- }
- }
- });
- }
-
- private void displayGroups(final Collection groups) {
- runOnUiThread(new Runnable() {
- public void run() {
- if(groups.isEmpty()) finish();
- toAdapter.clear();
- for(Group g : groups) toAdapter.add(new GroupItem(g));
- toAdapter.sort(GroupItemComparator.INSTANCE);
- toAdapter.notifyDataSetChanged();
- int count = toAdapter.getCount();
- for(int i = 0; i < count; i++) {
- GroupItem g = toAdapter.getItem(i);
- if(g == GroupItem.NEW) continue;
- if(g.getGroup().getId().equals(groupId)) {
- group = g.getGroup();
- toSpinner.setSelection(i);
+ spinner.setSelection(i);
break;
}
}
+ Resources res = getResources();
+ String format = res.getString(R.string.format_to);
+ to.setText(String.format(format, group.getName()));
+ sendButton.setEnabled(true);
}
});
}
@@ -270,8 +215,7 @@ implements OnItemSelectedListener, OnClickListener {
public void onItemSelected(AdapterView> parent, View view, int position,
long id) {
- if(parent == fromSpinner) {
- LocalAuthorItem item = fromAdapter.getItem(position);
+ LocalAuthorItem item = adapter.getItem(position);
if(item == LocalAuthorItem.ANONYMOUS) {
localAuthor = null;
localAuthorId = null;
@@ -283,29 +227,11 @@ implements OnItemSelectedListener, OnClickListener {
localAuthor = item.getLocalAuthor();
localAuthorId = localAuthor.getId();
}
- } else if(parent == toSpinner) {
- GroupItem item = toAdapter.getItem(position);
- if(item == GroupItem.NEW) {
- group = null;
- groupId = null;
- startActivity(new Intent(this, CreateGroupActivity.class));
- } else {
- group = item.getGroup();
- groupId = group.getId();
- sendButton.setEnabled(true);
- }
- }
}
public void onNothingSelected(AdapterView> parent) {
- if(parent == fromSpinner) {
localAuthor = null;
localAuthorId = null;
- } else if(parent == toSpinner) {
- group = null;
- groupId = null;
- sendButton.setEnabled(false);
- }
}
public void onClick(View view) {