Improvements for Contacts
- create contacts by manually entering the address (or pasting it) - share address
This commit is contained in:
parent
563085ed79
commit
5db5442064
@ -89,7 +89,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".OpenBitmessageLinkActivity"
|
||||
android:name=".CreateAddressActivity"
|
||||
android:label="@string/title_activity_open_bitmessage_link"
|
||||
android:theme="@style/Theme.AppCompat.Light.Dialog">
|
||||
<intent-filter>
|
||||
|
@ -23,8 +23,6 @@ import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.widget.ShareActionProvider;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
@ -71,7 +69,6 @@ public class AddressDetailFragment extends Fragment {
|
||||
|
||||
private static final int QR_CODE_SIZE = 350;
|
||||
|
||||
private ShareActionProvider shareActionProvider;
|
||||
/**
|
||||
* The content this fragment is presenting.
|
||||
*/
|
||||
@ -103,11 +100,8 @@ public class AddressDetailFragment extends Fragment {
|
||||
inflater.inflate(R.menu.address, menu);
|
||||
|
||||
Drawables.addIcon(getActivity(), menu, R.id.write_message, GoogleMaterial.Icon.gmd_mail);
|
||||
Drawables.addIcon(getActivity(), menu, R.id.delete, GoogleMaterial.Icon.gmd_delete);
|
||||
Drawables.addIcon(getActivity(), menu, R.id.share, GoogleMaterial.Icon.gmd_share);
|
||||
|
||||
shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(
|
||||
menu.findItem(R.id.share));
|
||||
Drawables.addIcon(getActivity(), menu, R.id.delete, GoogleMaterial.Icon.gmd_delete);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
@ -143,20 +137,15 @@ public class AddressDetailFragment extends Fragment {
|
||||
.show();
|
||||
return true;
|
||||
case R.id.share:
|
||||
new AlertDialog.Builder(ctx)
|
||||
.setMessage("I have no fucking clue.")
|
||||
.show();
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, item.getAddress());
|
||||
startActivity(Intent.createChooser(shareIntent, null));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void setShareIntent(Intent shareIntent) {
|
||||
if (shareActionProvider != null) {
|
||||
shareActionProvider.setShareIntent(shareIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -138,6 +138,8 @@ public class AddressListFragment extends AbstractItemListFragment<BitmessageAddr
|
||||
.initiateScan();
|
||||
return true;
|
||||
case R.id.action_create_contact:
|
||||
Intent intent = new Intent(getActivity(), CreateAddressActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -155,9 +157,9 @@ public class AddressListFragment extends AbstractItemListFragment<BitmessageAddr
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (data.hasExtra("SCAN_RESULT")) {
|
||||
if (data != null && data.hasExtra("SCAN_RESULT")) {
|
||||
Uri uri = Uri.parse(data.getStringExtra("SCAN_RESULT"));
|
||||
Intent intent = new Intent(getActivity(), OpenBitmessageLinkActivity.class);
|
||||
Intent intent = new Intent(getActivity(), CreateAddressActivity.class);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
@ -30,32 +30,36 @@ import ch.dissem.apps.abit.service.Singleton;
|
||||
import ch.dissem.bitmessage.BitmessageContext;
|
||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
||||
|
||||
public class OpenBitmessageLinkActivity extends AppCompatActivity {
|
||||
public class CreateAddressActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_open_bitmessage_link);
|
||||
Uri uri = getIntent().getData();
|
||||
if (uri != null)
|
||||
setContentView(R.layout.activity_open_bitmessage_link);
|
||||
else
|
||||
setContentView(R.layout.activity_create_bitmessage_address);
|
||||
|
||||
final TextView addressView = (TextView) findViewById(R.id.address);
|
||||
final TextView address = (TextView) findViewById(R.id.address);
|
||||
final EditText label = (EditText) findViewById(R.id.label);
|
||||
final Switch subscribe = (Switch) findViewById(R.id.subscribe);
|
||||
|
||||
Uri uri = getIntent().getData();
|
||||
final String address = getAddress(uri);
|
||||
String[] parameters = getParameters(uri);
|
||||
for (String parameter : parameters) {
|
||||
String name = parameter.substring(0, 6).toLowerCase();
|
||||
if (name.startsWith("label")) {
|
||||
label.setText(parameter.substring(parameter.indexOf('=') + 1).trim());
|
||||
} else if (name.startsWith("action")) {
|
||||
parameter = parameter.toLowerCase();
|
||||
subscribe.setChecked(parameter.contains("subscribe"));
|
||||
if (uri != null) {
|
||||
String addressText = getAddress(uri);
|
||||
String[] parameters = getParameters(uri);
|
||||
for (String parameter : parameters) {
|
||||
String name = parameter.substring(0, 6).toLowerCase();
|
||||
if (name.startsWith("label")) {
|
||||
label.setText(parameter.substring(parameter.indexOf('=') + 1).trim());
|
||||
} else if (name.startsWith("action")) {
|
||||
parameter = parameter.toLowerCase();
|
||||
subscribe.setChecked(parameter.contains("subscribe"));
|
||||
}
|
||||
}
|
||||
|
||||
address.setText(addressText);
|
||||
}
|
||||
|
||||
addressView.setText(address);
|
||||
|
||||
|
||||
final Button cancel = (Button) findViewById(R.id.cancel);
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -68,18 +72,23 @@ public class OpenBitmessageLinkActivity extends AppCompatActivity {
|
||||
ok.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
BitmessageAddress bmAddress = new BitmessageAddress(address);
|
||||
bmAddress.setAlias(label.getText().toString());
|
||||
String addressText = String.valueOf(address.getText()).trim();
|
||||
try {
|
||||
BitmessageAddress bmAddress = new BitmessageAddress(addressText);
|
||||
bmAddress.setAlias(label.getText().toString());
|
||||
|
||||
BitmessageContext bmc = Singleton.getBitmessageContext(OpenBitmessageLinkActivity
|
||||
.this);
|
||||
bmc.addContact(bmAddress);
|
||||
if (subscribe.isChecked()) {
|
||||
bmc.addSubscribtion(bmAddress);
|
||||
BitmessageContext bmc = Singleton.getBitmessageContext
|
||||
(CreateAddressActivity.this);
|
||||
bmc.addContact(bmAddress);
|
||||
if (subscribe.isChecked()) {
|
||||
bmc.addSubscribtion(bmAddress);
|
||||
}
|
||||
|
||||
setResult(Activity.RESULT_OK);
|
||||
finish();
|
||||
} catch (RuntimeException e) {
|
||||
address.setError(getString(R.string.error_illegal_address));
|
||||
}
|
||||
|
||||
setResult(Activity.RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="24dp">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/address_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/address"
|
||||
android:inputType="textNoSuggestions" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/label_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignStart="@+id/address_wrapper"
|
||||
android:layout_below="@+id/address_wrapper"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/label"
|
||||
android:inputType="textPersonName" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/subscribe"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignStart="@+id/address_wrapper"
|
||||
android:layout_below="@+id/label_wrapper"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/subscribe" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/do_import"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@+id/subscribe"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/do_import" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/do_import"
|
||||
android:layout_toStartOf="@+id/do_import"
|
||||
android:text="@string/cancel" />
|
||||
|
||||
</RelativeLayout>
|
@ -38,8 +38,8 @@
|
||||
android:layout_alignTop="@+id/avatar"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_toEndOf="@+id/avatar"
|
||||
android:text=""
|
||||
android:inputType="textPersonName"
|
||||
android:text=""
|
||||
tools:ignore="LabelFor"/>
|
||||
|
||||
<TextView
|
||||
@ -50,9 +50,9 @@
|
||||
android:lines="1"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
tools:text="BM-XyYxXyYxXyYxXyYxXyYx"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold"/>
|
||||
android:textStyle="bold"
|
||||
tools:text="BM-XyYxXyYxXyYxXyYxXyYx"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/stream_number"
|
||||
@ -63,8 +63,8 @@
|
||||
android:lines="1"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
tools:text="Stream #"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
tools:text="Stream #"/>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/active"
|
||||
@ -82,8 +82,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@+id/active"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:src="@drawable/public_key"
|
||||
tools:ignore="ContentDescription"/>
|
||||
@ -92,26 +92,28 @@
|
||||
android:id="@+id/pubkey_available_desc"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:layout_alignBottom="@id/pubkey_available"
|
||||
android:layout_toEndOf="@id/pubkey_available"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_toEndOf="@id/pubkey_available"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="0dp"
|
||||
android:text="@string/pubkey_available"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/qr_code"
|
||||
tools:src="@drawable/public_key"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_below="@+id/pubkey_available"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@+id/pubkey_available"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:contentDescription="@string/alt_qr_code"/>
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:contentDescription="@string/alt_qr_code"
|
||||
android:elevation="2dp"
|
||||
tools:ignore="UnusedAttribute"
|
||||
tools:src="@drawable/public_key"/>
|
||||
</RelativeLayout>
|
@ -21,13 +21,12 @@
|
||||
android:id="@+id/write_message"
|
||||
android:title="@string/write_message"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/delete"
|
||||
android:title="@string/delete"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/share"
|
||||
android:title="@string/share"
|
||||
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
|
||||
app:showAsAction="always"/>
|
||||
<item
|
||||
android:id="@+id/delete"
|
||||
android:title="@string/delete"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
@ -69,4 +69,6 @@
|
||||
|
||||
Als Alternative kann in den Einstellungen ein vertrauenswürdiger Knoten konfiguriert werden, aber im Moment muss dieser selbst bereitgestellt werden.</string>
|
||||
<string name="got_it">Alles klar</string>
|
||||
<string name="address">Bitmessage-Adresse</string>
|
||||
<string name="error_illegal_address">Vielleicht hat es einen Tippfehler</string>
|
||||
</resources>
|
@ -72,4 +72,6 @@
|
||||
|
||||
As an alternative you could configure a trusted node in the settings, but as of now you\'ll need to deploy your own.</string>
|
||||
<string name="got_it">Got it</string>
|
||||
<string name="address">Bitmessage Address</string>
|
||||
<string name="error_illegal_address">There might be a typo</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user