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>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".OpenBitmessageLinkActivity"
|
android:name=".CreateAddressActivity"
|
||||||
android:label="@string/title_activity_open_bitmessage_link"
|
android:label="@string/title_activity_open_bitmessage_link"
|
||||||
android:theme="@style/Theme.AppCompat.Light.Dialog">
|
android:theme="@style/Theme.AppCompat.Light.Dialog">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -23,8 +23,6 @@ import android.content.Intent;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
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.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -71,7 +69,6 @@ public class AddressDetailFragment extends Fragment {
|
|||||||
|
|
||||||
private static final int QR_CODE_SIZE = 350;
|
private static final int QR_CODE_SIZE = 350;
|
||||||
|
|
||||||
private ShareActionProvider shareActionProvider;
|
|
||||||
/**
|
/**
|
||||||
* The content this fragment is presenting.
|
* The content this fragment is presenting.
|
||||||
*/
|
*/
|
||||||
@ -103,11 +100,8 @@ public class AddressDetailFragment extends Fragment {
|
|||||||
inflater.inflate(R.menu.address, menu);
|
inflater.inflate(R.menu.address, menu);
|
||||||
|
|
||||||
Drawables.addIcon(getActivity(), menu, R.id.write_message, GoogleMaterial.Icon.gmd_mail);
|
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);
|
Drawables.addIcon(getActivity(), menu, R.id.share, GoogleMaterial.Icon.gmd_share);
|
||||||
|
Drawables.addIcon(getActivity(), menu, R.id.delete, GoogleMaterial.Icon.gmd_delete);
|
||||||
shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(
|
|
||||||
menu.findItem(R.id.share));
|
|
||||||
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
@ -143,20 +137,15 @@ public class AddressDetailFragment extends Fragment {
|
|||||||
.show();
|
.show();
|
||||||
return true;
|
return true;
|
||||||
case R.id.share:
|
case R.id.share:
|
||||||
new AlertDialog.Builder(ctx)
|
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
.setMessage("I have no fucking clue.")
|
shareIntent.setType("text/plain");
|
||||||
.show();
|
shareIntent.putExtra(Intent.EXTRA_TEXT, item.getAddress());
|
||||||
|
startActivity(Intent.createChooser(shareIntent, null));
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShareIntent(Intent shareIntent) {
|
|
||||||
if (shareActionProvider != null) {
|
|
||||||
shareActionProvider.setShareIntent(shareIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -138,6 +138,8 @@ public class AddressListFragment extends AbstractItemListFragment<BitmessageAddr
|
|||||||
.initiateScan();
|
.initiateScan();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_create_contact:
|
case R.id.action_create_contact:
|
||||||
|
Intent intent = new Intent(getActivity(), CreateAddressActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -155,9 +157,9 @@ public class AddressListFragment extends AbstractItemListFragment<BitmessageAddr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
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"));
|
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);
|
intent.setData(uri);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -30,32 +30,36 @@ import ch.dissem.apps.abit.service.Singleton;
|
|||||||
import ch.dissem.bitmessage.BitmessageContext;
|
import ch.dissem.bitmessage.BitmessageContext;
|
||||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
||||||
|
|
||||||
public class OpenBitmessageLinkActivity extends AppCompatActivity {
|
public class CreateAddressActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(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 EditText label = (EditText) findViewById(R.id.label);
|
||||||
final Switch subscribe = (Switch) findViewById(R.id.subscribe);
|
final Switch subscribe = (Switch) findViewById(R.id.subscribe);
|
||||||
|
|
||||||
Uri uri = getIntent().getData();
|
if (uri != null) {
|
||||||
final String address = getAddress(uri);
|
String addressText = getAddress(uri);
|
||||||
String[] parameters = getParameters(uri);
|
String[] parameters = getParameters(uri);
|
||||||
for (String parameter : parameters) {
|
for (String parameter : parameters) {
|
||||||
String name = parameter.substring(0, 6).toLowerCase();
|
String name = parameter.substring(0, 6).toLowerCase();
|
||||||
if (name.startsWith("label")) {
|
if (name.startsWith("label")) {
|
||||||
label.setText(parameter.substring(parameter.indexOf('=') + 1).trim());
|
label.setText(parameter.substring(parameter.indexOf('=') + 1).trim());
|
||||||
} else if (name.startsWith("action")) {
|
} else if (name.startsWith("action")) {
|
||||||
parameter = parameter.toLowerCase();
|
parameter = parameter.toLowerCase();
|
||||||
subscribe.setChecked(parameter.contains("subscribe"));
|
subscribe.setChecked(parameter.contains("subscribe"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
address.setText(addressText);
|
||||||
}
|
}
|
||||||
|
|
||||||
addressView.setText(address);
|
|
||||||
|
|
||||||
|
|
||||||
final Button cancel = (Button) findViewById(R.id.cancel);
|
final Button cancel = (Button) findViewById(R.id.cancel);
|
||||||
cancel.setOnClickListener(new View.OnClickListener() {
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -68,18 +72,23 @@ public class OpenBitmessageLinkActivity extends AppCompatActivity {
|
|||||||
ok.setOnClickListener(new View.OnClickListener() {
|
ok.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
BitmessageAddress bmAddress = new BitmessageAddress(address);
|
String addressText = String.valueOf(address.getText()).trim();
|
||||||
bmAddress.setAlias(label.getText().toString());
|
try {
|
||||||
|
BitmessageAddress bmAddress = new BitmessageAddress(addressText);
|
||||||
|
bmAddress.setAlias(label.getText().toString());
|
||||||
|
|
||||||
BitmessageContext bmc = Singleton.getBitmessageContext(OpenBitmessageLinkActivity
|
BitmessageContext bmc = Singleton.getBitmessageContext
|
||||||
.this);
|
(CreateAddressActivity.this);
|
||||||
bmc.addContact(bmAddress);
|
bmc.addContact(bmAddress);
|
||||||
if (subscribe.isChecked()) {
|
if (subscribe.isChecked()) {
|
||||||
bmc.addSubscribtion(bmAddress);
|
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_alignTop="@+id/avatar"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_toEndOf="@+id/avatar"
|
android:layout_toEndOf="@+id/avatar"
|
||||||
android:text=""
|
|
||||||
android:inputType="textPersonName"
|
android:inputType="textPersonName"
|
||||||
|
android:text=""
|
||||||
tools:ignore="LabelFor"/>
|
tools:ignore="LabelFor"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -50,9 +50,9 @@
|
|||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
tools:text="BM-XyYxXyYxXyYxXyYxXyYx"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:textStyle="bold"/>
|
android:textStyle="bold"
|
||||||
|
tools:text="BM-XyYxXyYxXyYxXyYxXyYx"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/stream_number"
|
android:id="@+id/stream_number"
|
||||||
@ -63,8 +63,8 @@
|
|||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
tools:text="Stream #"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
tools:text="Stream #"/>
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/active"
|
android:id="@+id/active"
|
||||||
@ -82,8 +82,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_below="@+id/active"
|
android:layout_below="@+id/active"
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="4dp"
|
android:paddingEnd="4dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:src="@drawable/public_key"
|
android:src="@drawable/public_key"
|
||||||
tools:ignore="ContentDescription"/>
|
tools:ignore="ContentDescription"/>
|
||||||
@ -92,26 +92,28 @@
|
|||||||
android:id="@+id/pubkey_available_desc"
|
android:id="@+id/pubkey_available_desc"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="0dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:layout_alignBottom="@id/pubkey_available"
|
android:layout_alignBottom="@id/pubkey_available"
|
||||||
android:layout_toEndOf="@id/pubkey_available"
|
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_toEndOf="@id/pubkey_available"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:paddingStart="0dp"
|
||||||
android:text="@string/pubkey_available"
|
android:text="@string/pubkey_available"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/qr_code"
|
android:id="@+id/qr_code"
|
||||||
tools:src="@drawable/public_key"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="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_alignParentBottom="true"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_below="@+id/pubkey_available"
|
||||||
android:layout_marginBottom="64dp"
|
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>
|
</RelativeLayout>
|
@ -21,13 +21,12 @@
|
|||||||
android:id="@+id/write_message"
|
android:id="@+id/write_message"
|
||||||
android:title="@string/write_message"
|
android:title="@string/write_message"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
|
||||||
android:id="@+id/delete"
|
|
||||||
android:title="@string/delete"
|
|
||||||
app:showAsAction="ifRoom"/>
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/share"
|
android:id="@+id/share"
|
||||||
android:title="@string/share"
|
android:title="@string/share"
|
||||||
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
|
|
||||||
app:showAsAction="always"/>
|
app:showAsAction="always"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/delete"
|
||||||
|
android:title="@string/delete"
|
||||||
|
app:showAsAction="never"/>
|
||||||
</menu>
|
</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>
|
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="got_it">Alles klar</string>
|
||||||
|
<string name="address">Bitmessage-Adresse</string>
|
||||||
|
<string name="error_illegal_address">Vielleicht hat es einen Tippfehler</string>
|
||||||
</resources>
|
</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>
|
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="got_it">Got it</string>
|
||||||
|
<string name="address">Bitmessage Address</string>
|
||||||
|
<string name="error_illegal_address">There might be a typo</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user