Skip to content
Snippets Groups Projects
Commit c184458d authored by akwizgran's avatar akwizgran
Browse files

Added app sharing button to contact list activity.

parent a2b3af87
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@
<string name="quit_button">Quit</string>
<string name="new_identity_item">New identity\u2026</string>
<string name="contact_list_title">Contacts</string>
<string name="share_app">Share the Briar App</string>
<string name="contact_connected">Connected</string>
<string name="format_last_connected">Last connected &lt;br /&gt; %1$s</string>
<string name="add_contact_title">Add a Contact</string>
......
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.widget.LinearLayout.HORIZONTAL;
......@@ -10,6 +12,7 @@ import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_MATCH;
import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_WRAP;
import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_WRAP_1;
import java.io.File;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
......@@ -35,6 +38,7 @@ import net.sf.briar.api.db.event.DatabaseListener;
import net.sf.briar.api.transport.ConnectionListener;
import net.sf.briar.api.transport.ConnectionRegistry;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
......@@ -56,6 +60,7 @@ implements OnClickListener, DatabaseListener, ConnectionListener {
@Inject private ConnectionRegistry connectionRegistry;
private ContactListAdapter adapter = null;
private ListView list = null;
private ImageButton addContactButton = null, shareButton = null;
// Fields that are accessed from background threads must be volatile
@Inject private volatile DatabaseComponent db;
......@@ -85,12 +90,19 @@ implements OnClickListener, DatabaseListener, ConnectionListener {
footer.setGravity(CENTER);
footer.addView(new HorizontalSpace(this));
ImageButton addContactButton = new ImageButton(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);
setContentView(layout);
......@@ -163,7 +175,16 @@ implements OnClickListener, DatabaseListener, ConnectionListener {
}
public void onClick(View view) {
startActivity(new Intent(this, AddContactActivity.class));
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));
}
}
public void eventOccurred(DatabaseEvent e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment