Skip to content
Permalink
Browse files

Contacts can now be shared via QR

  • Loading branch information...
dakhnod committed Jul 16, 2018
1 parent bb40ecd commit 6aa57dd89d26457ce6392f6b8eebf6b8c323c12b
@@ -278,6 +278,7 @@ public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, lon
menu.getMenu().add("delete");
menu.getMenu().add("rename");
menu.getMenu().add("share");
menu.getMenu().add("qr-ify");
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
@@ -286,8 +287,12 @@ public boolean onMenuItemClick(MenuItem menuItem) {
refreshContactList();
}else if(menuItem.getTitle().equals("rename")){
showContactEditDialog(contacts.get(i));
}else{
}else if(menuItem.getTitle().equals("share")){
shareContact(contacts.get(i));
}else{
Intent intent = new Intent(ContactListActivity.this, QRPresenterActivity.class);
intent.putExtra("EXTRA_CONTACT", contacts.get(i));
startActivity(intent);
}
return false;
}
@@ -14,7 +14,10 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.google.zxing.BarcodeFormat;
@@ -30,11 +33,23 @@
private MainService.MainBinder binder;
private String json;

private Contact contact = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_qrpresenter);

if(getIntent().hasExtra("EXTRA_CONTACT")){
this.contact = (Contact) getIntent().getExtras().get("EXTRA_CONTACT");
findViewById(R.id.fabPresenter).setVisibility(View.GONE);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.addRule(RelativeLayout.ALIGN_PARENT_END, RelativeLayout.TRUE);
params.bottomMargin = params.rightMargin = 80;
findViewById(R.id.fabShare).setLayoutParams(params);
}

setTitle(getString(R.string.scan_invitation));
bindService();

@@ -91,7 +106,13 @@ private void generateQR() throws Exception {
private String generateJson() throws JSONException{
JSONObject object = new JSONObject();

Log.d(QRPresenterActivity.class.getSimpleName(), "generateQR " + (this.binder == null));
if(this.contact != null){
object.put("address", contact.getAddress());
object.put("identifier", contact.getIdentifier());
object.put("username", contact.getName());
object.put("challenge", this.binder.generateChallenge());
return object.toString();
}

SharedPreferences prefs = getSharedPreferences(getPackageName(), MODE_PRIVATE);
object.put("username", prefs.getString("username", "Unknown"));

0 comments on commit 6aa57dd

Please sign in to comment.
You can’t perform that action at this time.