Added UI for sending broadcasts
- UI shouldn't block until the first identity is ready anymore
This commit is contained in:
		@@ -33,6 +33,7 @@ import android.view.ViewGroup;
 | 
			
		||||
import android.widget.ImageView;
 | 
			
		||||
import android.widget.Switch;
 | 
			
		||||
import android.widget.TextView;
 | 
			
		||||
import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
import com.google.zxing.BarcodeFormat;
 | 
			
		||||
import com.google.zxing.MultiFormatWriter;
 | 
			
		||||
@@ -115,10 +116,15 @@ public class AddressDetailFragment extends Fragment {
 | 
			
		||||
        final Activity ctx = getActivity();
 | 
			
		||||
        switch (menuItem.getItemId()) {
 | 
			
		||||
            case R.id.write_message: {
 | 
			
		||||
                Intent intent = new Intent(ctx, ComposeMessageActivity.class);
 | 
			
		||||
                intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, Singleton.getIdentity(ctx));
 | 
			
		||||
                intent.putExtra(ComposeMessageActivity.EXTRA_RECIPIENT, item);
 | 
			
		||||
                startActivity(intent);
 | 
			
		||||
                BitmessageAddress identity = Singleton.getIdentity(ctx);
 | 
			
		||||
                if (identity == null) {
 | 
			
		||||
                    Toast.makeText(ctx, R.string.no_identity_warning, Toast.LENGTH_LONG).show();
 | 
			
		||||
                } else {
 | 
			
		||||
                    Intent intent = new Intent(ctx, ComposeMessageActivity.class);
 | 
			
		||||
                    intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, identity);
 | 
			
		||||
                    intent.putExtra(ComposeMessageActivity.EXTRA_RECIPIENT, item);
 | 
			
		||||
                    startActivity(intent);
 | 
			
		||||
                }
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            case R.id.delete: {
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ public class ComposeMessageActivity extends AppCompatActivity {
 | 
			
		||||
    public static final String EXTRA_RECIPIENT = "ch.dissem.abit.Message.RECIPIENT";
 | 
			
		||||
    public static final String EXTRA_SUBJECT = "ch.dissem.abit.Message.SUBJECT";
 | 
			
		||||
    public static final String EXTRA_CONTENT = "ch.dissem.abit.Message.CONTENT";
 | 
			
		||||
    public static final String EXTRA_BROADCAST = "ch.dissem.abit.Message.IS_BROADCAST";
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ import ch.dissem.apps.abit.adapter.ContactAdapter;
 | 
			
		||||
import ch.dissem.apps.abit.service.Singleton;
 | 
			
		||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
 | 
			
		||||
 | 
			
		||||
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_BROADCAST;
 | 
			
		||||
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_CONTENT;
 | 
			
		||||
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_IDENTITY;
 | 
			
		||||
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_RECIPIENT;
 | 
			
		||||
@@ -50,6 +51,7 @@ public class ComposeMessageFragment extends Fragment {
 | 
			
		||||
    private AutoCompleteTextView recipientInput;
 | 
			
		||||
    private EditText subjectInput;
 | 
			
		||||
    private EditText bodyInput;
 | 
			
		||||
    private boolean broadcast;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Mandatory empty constructor for the fragment manager to instantiate the
 | 
			
		||||
@@ -67,6 +69,7 @@ public class ComposeMessageFragment extends Fragment {
 | 
			
		||||
            } else {
 | 
			
		||||
                throw new RuntimeException("No identity set for ComposeMessageFragment");
 | 
			
		||||
            }
 | 
			
		||||
            broadcast = getArguments().getBoolean(EXTRA_BROADCAST, false);
 | 
			
		||||
            if (getArguments().containsKey(EXTRA_RECIPIENT)) {
 | 
			
		||||
                recipient = (BitmessageAddress) getArguments().getSerializable(EXTRA_RECIPIENT);
 | 
			
		||||
            }
 | 
			
		||||
@@ -87,23 +90,28 @@ public class ComposeMessageFragment extends Fragment {
 | 
			
		||||
                             Bundle savedInstanceState) {
 | 
			
		||||
        View rootView = inflater.inflate(R.layout.fragment_compose_message, container, false);
 | 
			
		||||
        recipientInput = (AutoCompleteTextView) rootView.findViewById(R.id.recipient);
 | 
			
		||||
        final ContactAdapter adapter = new ContactAdapter(getContext());
 | 
			
		||||
        recipientInput.setAdapter(adapter);
 | 
			
		||||
        recipientInput.setOnItemClickListener(
 | 
			
		||||
            (parent, view, position, id) -> recipient = adapter.getItem(position)
 | 
			
		||||
        );
 | 
			
		||||
        recipientInput.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
 | 
			
		||||
                recipient = adapter.getItem(position);
 | 
			
		||||
            }
 | 
			
		||||
        if (broadcast) {
 | 
			
		||||
            recipientInput.setVisibility(View.GONE);
 | 
			
		||||
        } else {
 | 
			
		||||
            final ContactAdapter adapter = new ContactAdapter(getContext());
 | 
			
		||||
            recipientInput.setAdapter(adapter);
 | 
			
		||||
            recipientInput.setOnItemClickListener(
 | 
			
		||||
                (parent, view, position, id) -> recipient = adapter.getItem(position)
 | 
			
		||||
            );
 | 
			
		||||
            recipientInput.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onItemSelected(AdapterView<?> parent, View view, int position, long
 | 
			
		||||
                    id) {
 | 
			
		||||
                    recipient = adapter.getItem(position);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onNothingSelected(AdapterView<?> parent) {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onNothingSelected(AdapterView<?> parent) {
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            if (recipient != null) {
 | 
			
		||||
                recipientInput.setText(recipient.toString());
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        if (recipient != null) {
 | 
			
		||||
            recipientInput.setText(recipient.toString());
 | 
			
		||||
        }
 | 
			
		||||
        subjectInput = (EditText) rootView.findViewById(R.id.subject);
 | 
			
		||||
        subjectInput.setText(subject);
 | 
			
		||||
@@ -132,25 +140,31 @@ public class ComposeMessageFragment extends Fragment {
 | 
			
		||||
    public boolean onOptionsItemSelected(MenuItem item) {
 | 
			
		||||
        switch (item.getItemId()) {
 | 
			
		||||
            case R.id.send:
 | 
			
		||||
                String inputString = recipientInput.getText().toString();
 | 
			
		||||
                if (recipient == null || !recipient.toString().equals(inputString)) {
 | 
			
		||||
                    try {
 | 
			
		||||
                        recipient = new BitmessageAddress(inputString);
 | 
			
		||||
                    } catch (Exception e) {
 | 
			
		||||
                        List<BitmessageAddress> contacts = Singleton.getAddressRepository
 | 
			
		||||
                            (getContext()).getContacts();
 | 
			
		||||
                        for (BitmessageAddress contact : contacts) {
 | 
			
		||||
                            if (inputString.equalsIgnoreCase(contact.getAlias())) {
 | 
			
		||||
                                recipient = contact;
 | 
			
		||||
                                if (inputString.equals(contact.getAlias()))
 | 
			
		||||
                                    break;
 | 
			
		||||
                if (broadcast) {
 | 
			
		||||
                    Singleton.getBitmessageContext(getContext()).broadcast(identity,
 | 
			
		||||
                        subjectInput.getText().toString(),
 | 
			
		||||
                        bodyInput.getText().toString());
 | 
			
		||||
                } else {
 | 
			
		||||
                    String inputString = recipientInput.getText().toString();
 | 
			
		||||
                    if (recipient == null || !recipient.toString().equals(inputString)) {
 | 
			
		||||
                        try {
 | 
			
		||||
                            recipient = new BitmessageAddress(inputString);
 | 
			
		||||
                        } catch (Exception e) {
 | 
			
		||||
                            List<BitmessageAddress> contacts = Singleton.getAddressRepository
 | 
			
		||||
                                (getContext()).getContacts();
 | 
			
		||||
                            for (BitmessageAddress contact : contacts) {
 | 
			
		||||
                                if (inputString.equalsIgnoreCase(contact.getAlias())) {
 | 
			
		||||
                                    recipient = contact;
 | 
			
		||||
                                    if (inputString.equals(contact.getAlias()))
 | 
			
		||||
                                        break;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    Singleton.getBitmessageContext(getContext()).send(identity, recipient,
 | 
			
		||||
                        subjectInput.getText().toString(),
 | 
			
		||||
                        bodyInput.getText().toString());
 | 
			
		||||
                }
 | 
			
		||||
                Singleton.getBitmessageContext(getContext()).send(identity, recipient,
 | 
			
		||||
                    subjectInput.getText().toString(),
 | 
			
		||||
                    bodyInput.getText().toString());
 | 
			
		||||
                getActivity().finish();
 | 
			
		||||
                return true;
 | 
			
		||||
            default:
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,6 @@
 | 
			
		||||
 | 
			
		||||
package ch.dissem.apps.abit;
 | 
			
		||||
 | 
			
		||||
import android.app.AlertDialog;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.graphics.Point;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
@@ -26,6 +25,7 @@ import android.support.v7.widget.Toolbar;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.RelativeLayout;
 | 
			
		||||
import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
import com.github.amlcurran.showcaseview.ShowcaseView;
 | 
			
		||||
import com.mikepenz.community_material_typeface_library.CommunityMaterial;
 | 
			
		||||
@@ -66,6 +66,7 @@ import ch.dissem.bitmessage.entity.BitmessageAddress;
 | 
			
		||||
import ch.dissem.bitmessage.entity.Plaintext;
 | 
			
		||||
import ch.dissem.bitmessage.entity.valueobject.Label;
 | 
			
		||||
 | 
			
		||||
import static android.widget.Toast.LENGTH_LONG;
 | 
			
		||||
import static ch.dissem.apps.abit.ComposeMessageActivity.launchReplyTo;
 | 
			
		||||
import static ch.dissem.apps.abit.service.BitmessageService.isRunning;
 | 
			
		||||
 | 
			
		||||
@@ -223,13 +224,7 @@ public class MainActivity extends AppCompatActivity
 | 
			
		||||
        }
 | 
			
		||||
        if (profiles.isEmpty()) {
 | 
			
		||||
            // Create an initial identity
 | 
			
		||||
            BitmessageAddress identity = Singleton.getIdentity(this);
 | 
			
		||||
            profiles.add(new ProfileDrawerItem()
 | 
			
		||||
                .withIcon(new Identicon(identity))
 | 
			
		||||
                .withName(identity.toString())
 | 
			
		||||
                .withEmail(identity.getAddress())
 | 
			
		||||
                .withTag(identity)
 | 
			
		||||
            );
 | 
			
		||||
            Singleton.getIdentity(this);
 | 
			
		||||
        }
 | 
			
		||||
        profiles.add(new ProfileSettingDrawerItem()
 | 
			
		||||
            .withName(getString(R.string.add_identity))
 | 
			
		||||
@@ -256,11 +251,15 @@ public class MainActivity extends AppCompatActivity
 | 
			
		||||
                        addIdentityDialog();
 | 
			
		||||
                        break;
 | 
			
		||||
                    case MANAGE_IDENTITY:
 | 
			
		||||
                        Intent show = new Intent(MainActivity.this,
 | 
			
		||||
                            AddressDetailActivity.class);
 | 
			
		||||
                        show.putExtra(AddressDetailFragment.ARG_ITEM,
 | 
			
		||||
                            Singleton.getIdentity(getApplicationContext()));
 | 
			
		||||
                        startActivity(show);
 | 
			
		||||
                        BitmessageAddress identity = Singleton.getIdentity(this);
 | 
			
		||||
                        if (identity == null) {
 | 
			
		||||
                            Toast.makeText(this, R.string.no_identity_warning, LENGTH_LONG).show();
 | 
			
		||||
                        } else {
 | 
			
		||||
                            Intent show = new Intent(MainActivity.this,
 | 
			
		||||
                                AddressDetailActivity.class);
 | 
			
		||||
                            show.putExtra(AddressDetailFragment.ARG_ITEM, identity);
 | 
			
		||||
                            startActivity(show);
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        if (profile instanceof ProfileDrawerItem) {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,6 @@ package ch.dissem.apps.abit;
 | 
			
		||||
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.support.design.widget.FloatingActionButton;
 | 
			
		||||
import android.support.v4.app.Fragment;
 | 
			
		||||
import android.support.v4.content.ContextCompat;
 | 
			
		||||
import android.support.v7.widget.LinearLayoutManager;
 | 
			
		||||
@@ -29,6 +28,7 @@ import android.view.MenuInflater;
 | 
			
		||||
import android.view.MenuItem;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
 | 
			
		||||
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator;
 | 
			
		||||
@@ -43,10 +43,15 @@ import ch.dissem.apps.abit.adapter.SwipeableMessageAdapter;
 | 
			
		||||
import ch.dissem.apps.abit.listener.ActionBarListener;
 | 
			
		||||
import ch.dissem.apps.abit.listener.ListSelectionListener;
 | 
			
		||||
import ch.dissem.apps.abit.service.Singleton;
 | 
			
		||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
 | 
			
		||||
import ch.dissem.bitmessage.entity.Plaintext;
 | 
			
		||||
import ch.dissem.bitmessage.entity.valueobject.Label;
 | 
			
		||||
import ch.dissem.bitmessage.ports.MessageRepository;
 | 
			
		||||
import io.github.yavski.fabspeeddial.FabSpeedDial;
 | 
			
		||||
import io.github.yavski.fabspeeddial.SimpleMenuListenerAdapter;
 | 
			
		||||
 | 
			
		||||
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_BROADCAST;
 | 
			
		||||
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_IDENTITY;
 | 
			
		||||
import static ch.dissem.apps.abit.MessageDetailFragment.isInTrash;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -128,14 +133,36 @@ public class MessageListFragment extends Fragment implements ListHolder {
 | 
			
		||||
        layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
 | 
			
		||||
 | 
			
		||||
        // Show the dummy content as text in a TextView.
 | 
			
		||||
        FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id
 | 
			
		||||
        FabSpeedDial fab = (FabSpeedDial) rootView.findViewById(R.id
 | 
			
		||||
            .fab_compose_message);
 | 
			
		||||
        fab.setOnClickListener(view -> {
 | 
			
		||||
            Intent intent = new Intent(getActivity().getApplicationContext(),
 | 
			
		||||
                ComposeMessageActivity.class);
 | 
			
		||||
            intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, Singleton.getIdentity
 | 
			
		||||
                (getActivity()));
 | 
			
		||||
            startActivity(intent);
 | 
			
		||||
        fab.setMenuListener(new SimpleMenuListenerAdapter() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public boolean onMenuItemSelected(MenuItem menuItem) {
 | 
			
		||||
                BitmessageAddress identity = Singleton.getIdentity(getActivity());
 | 
			
		||||
                if (identity == null) {
 | 
			
		||||
                    Toast.makeText(getActivity(), R.string.no_identity_warning,
 | 
			
		||||
                        Toast.LENGTH_LONG).show();
 | 
			
		||||
                    return false;
 | 
			
		||||
                } else {
 | 
			
		||||
                    switch (menuItem.getItemId()) {
 | 
			
		||||
                        case R.id.action_compose_message: {
 | 
			
		||||
                            Intent intent = new Intent(getActivity(), ComposeMessageActivity.class);
 | 
			
		||||
                            intent.putExtra(EXTRA_IDENTITY, identity);
 | 
			
		||||
                            startActivity(intent);
 | 
			
		||||
                            return true;
 | 
			
		||||
                        }
 | 
			
		||||
                        case R.id.action_compose_broadcast: {
 | 
			
		||||
                            Intent intent = new Intent(getActivity(), ComposeMessageActivity.class);
 | 
			
		||||
                            intent.putExtra(EXTRA_IDENTITY, identity);
 | 
			
		||||
                            intent.putExtra(EXTRA_BROADCAST, true);
 | 
			
		||||
                            startActivity(intent);
 | 
			
		||||
                            return true;
 | 
			
		||||
                        }
 | 
			
		||||
                        default:
 | 
			
		||||
                            return false;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        // touch guard manager  (this class is required to suppress scrolling while swipe-dismiss
 | 
			
		||||
 
 | 
			
		||||
@@ -244,16 +244,19 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
 | 
			
		||||
            db.beginTransaction();
 | 
			
		||||
 | 
			
		||||
            // save from address if necessary
 | 
			
		||||
            BitmessageAddress savedAddress = ctx.getAddressRepository().getAddress(message
 | 
			
		||||
                .getFrom().getAddress());
 | 
			
		||||
            if (message.getId() == null) {
 | 
			
		||||
                BitmessageAddress savedAddress = ctx.getAddressRepository().getAddress(message
 | 
			
		||||
                    .getFrom().getAddress());
 | 
			
		||||
                if (savedAddress == null || savedAddress.getPrivateKey() == null) {
 | 
			
		||||
                    if (savedAddress != null && savedAddress.getAlias() != null) {
 | 
			
		||||
                        message.getFrom().setAlias(savedAddress.getAlias());
 | 
			
		||||
                    }
 | 
			
		||||
                if (savedAddress == null) {
 | 
			
		||||
                    ctx.getAddressRepository().save(message.getFrom());
 | 
			
		||||
                } else if (savedAddress.getPubkey() == null) {
 | 
			
		||||
                    savedAddress.setPubkey(message.getFrom().getPubkey());
 | 
			
		||||
                    ctx.getAddressRepository().save(savedAddress);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (savedAddress != null) {
 | 
			
		||||
                message.getFrom().setAlias(savedAddress.getAlias());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // save message
 | 
			
		||||
            if (message.getId() == null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,7 @@ public class BitmessageIntentService extends IntentService {
 | 
			
		||||
            Plaintext item = (Plaintext) intent.getSerializableExtra(EXTRA_DELETE_MESSAGE);
 | 
			
		||||
            bmc.labeler().delete(item);
 | 
			
		||||
            bmc.messages().save(item);
 | 
			
		||||
            Singleton.getMessageListener(this).resetNotification();
 | 
			
		||||
        }
 | 
			
		||||
        if (intent.hasExtra(EXTRA_STARTUP_NODE)) {
 | 
			
		||||
            if (Preferences.isConnectionAllowed(this)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,12 @@
 | 
			
		||||
package ch.dissem.apps.abit.service;
 | 
			
		||||
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.os.AsyncTask;
 | 
			
		||||
import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import ch.dissem.apps.abit.MainActivity;
 | 
			
		||||
import ch.dissem.apps.abit.R;
 | 
			
		||||
import ch.dissem.apps.abit.adapter.AndroidCryptography;
 | 
			
		||||
import ch.dissem.apps.abit.adapter.SwitchingProofOfWorkEngine;
 | 
			
		||||
@@ -34,6 +37,7 @@ import ch.dissem.apps.abit.repository.SqlHelper;
 | 
			
		||||
import ch.dissem.apps.abit.util.Constants;
 | 
			
		||||
import ch.dissem.bitmessage.BitmessageContext;
 | 
			
		||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
 | 
			
		||||
import ch.dissem.bitmessage.entity.payload.Pubkey;
 | 
			
		||||
import ch.dissem.bitmessage.networking.nio.NioNetworkHandler;
 | 
			
		||||
import ch.dissem.bitmessage.ports.AddressRepository;
 | 
			
		||||
import ch.dissem.bitmessage.ports.MessageRepository;
 | 
			
		||||
@@ -50,6 +54,7 @@ public class Singleton {
 | 
			
		||||
    private static MessageListener messageListener;
 | 
			
		||||
    private static BitmessageAddress identity;
 | 
			
		||||
    private static AndroidProofOfWorkRepository powRepo;
 | 
			
		||||
    private static boolean creatingIdentity;
 | 
			
		||||
 | 
			
		||||
    public static BitmessageContext getBitmessageContext(Context context) {
 | 
			
		||||
        if (bitmessageContext == null) {
 | 
			
		||||
@@ -110,15 +115,39 @@ public class Singleton {
 | 
			
		||||
            BitmessageContext bmc = getBitmessageContext(ctx);
 | 
			
		||||
            synchronized (Singleton.class) {
 | 
			
		||||
                if (identity == null) {
 | 
			
		||||
                    // FIXME: this may block the UI, there must be a better way!
 | 
			
		||||
                    List<BitmessageAddress> identities = bmc.addresses()
 | 
			
		||||
                        .getIdentities();
 | 
			
		||||
                    if (identities.size() > 0) {
 | 
			
		||||
                        identity = identities.get(0);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        identity = bmc.createIdentity(false);
 | 
			
		||||
                        identity.setAlias(ctx.getString(R.string.alias_default_identity));
 | 
			
		||||
                        bmc.addresses().save(identity);
 | 
			
		||||
                        if (!creatingIdentity) {
 | 
			
		||||
                            creatingIdentity = true;
 | 
			
		||||
                            new AsyncTask<Void, Void, BitmessageAddress>() {
 | 
			
		||||
                                @Override
 | 
			
		||||
                                protected BitmessageAddress doInBackground(Void... args) {
 | 
			
		||||
                                    BitmessageAddress identity = bmc.createIdentity(false,
 | 
			
		||||
                                        Pubkey.Feature.DOES_ACK);
 | 
			
		||||
                                    identity.setAlias(
 | 
			
		||||
                                        ctx.getString(R.string.alias_default_identity)
 | 
			
		||||
                                    );
 | 
			
		||||
                                    bmc.addresses().save(identity);
 | 
			
		||||
                                    return identity;
 | 
			
		||||
                                }
 | 
			
		||||
 | 
			
		||||
                                @Override
 | 
			
		||||
                                protected void onPostExecute(BitmessageAddress identity) {
 | 
			
		||||
                                    Singleton.identity = identity;
 | 
			
		||||
                                    Toast.makeText(ctx,
 | 
			
		||||
                                        R.string.toast_identity_created,
 | 
			
		||||
                                        Toast.LENGTH_SHORT).show();
 | 
			
		||||
                                    MainActivity mainActivity = MainActivity.getInstance();
 | 
			
		||||
                                    if (mainActivity != null) {
 | 
			
		||||
                                        mainActivity.addIdentityEntry(identity);
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            }.execute();
 | 
			
		||||
                        }
 | 
			
		||||
                        return null;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								app/src/main/res/drawable/ic_action_broadcast.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								app/src/main/res/drawable/ic_action_broadcast.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
<!--
 | 
			
		||||
  ~ Copyright 2016 Christian Basler
 | 
			
		||||
  ~
 | 
			
		||||
  ~ Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  ~ you may not use this file except in compliance with the License.
 | 
			
		||||
  ~ You may obtain a copy of the License at
 | 
			
		||||
  ~
 | 
			
		||||
  ~     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
  ~
 | 
			
		||||
  ~ Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  ~ distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  ~ See the License for the specific language governing permissions and
 | 
			
		||||
  ~ limitations under the License.
 | 
			
		||||
  -->
 | 
			
		||||
 | 
			
		||||
<!-- drawable/radio_tower.xml -->
 | 
			
		||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
    android:height="24dp"
 | 
			
		||||
    android:width="24dp"
 | 
			
		||||
    android:viewportWidth="24"
 | 
			
		||||
    android:viewportHeight="24">
 | 
			
		||||
    <path android:fillColor="#DEFFFFFF" android:pathData="M12,10A2,2 0 0,1 14,12C14,12.5 13.82,12.94 13.53,13.29L16.7,22H14.57L12,14.93L9.43,22H7.3L10.47,13.29C10.18,12.94 10,12.5 10,12A2,2 0 0,1 12,10M12,8A4,4 0 0,0 8,12C8,12.5 8.1,13 8.28,13.46L7.4,15.86C6.53,14.81 6,13.47 6,12A6,6 0 0,1 12,6A6,6 0 0,1 18,12C18,13.47 17.47,14.81 16.6,15.86L15.72,13.46C15.9,13 16,12.5 16,12A4,4 0 0,0 12,8M12,4A8,8 0 0,0 4,12C4,14.36 5,16.5 6.64,17.94L5.92,19.94C3.54,18.11 2,15.23 2,12A10,10 0 0,1 12,2A10,10 0 0,1 22,12C22,15.23 20.46,18.11 18.08,19.94L17.36,17.94C19,16.5 20,14.36 20,12A8,8 0 0,0 12,4Z" />
 | 
			
		||||
</vector>
 | 
			
		||||
							
								
								
									
										25
									
								
								app/src/main/res/drawable/ic_action_personal.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								app/src/main/res/drawable/ic_action_personal.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
<!--
 | 
			
		||||
  ~ Copyright 2016 Christian Basler
 | 
			
		||||
  ~
 | 
			
		||||
  ~ Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  ~ you may not use this file except in compliance with the License.
 | 
			
		||||
  ~ You may obtain a copy of the License at
 | 
			
		||||
  ~
 | 
			
		||||
  ~     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
  ~
 | 
			
		||||
  ~ Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  ~ distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  ~ See the License for the specific language governing permissions and
 | 
			
		||||
  ~ limitations under the License.
 | 
			
		||||
  -->
 | 
			
		||||
 | 
			
		||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
        android:width="24dp"
 | 
			
		||||
        android:height="24dp"
 | 
			
		||||
        android:viewportWidth="24.0"
 | 
			
		||||
        android:viewportHeight="24.0">
 | 
			
		||||
    <path
 | 
			
		||||
        android:fillColor="#DEFFFFFF"
 | 
			
		||||
        android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
 | 
			
		||||
</vector>
 | 
			
		||||
@@ -3,5 +3,5 @@
 | 
			
		||||
        android:width="24dp"
 | 
			
		||||
        android:viewportWidth="24"
 | 
			
		||||
        android:viewportHeight="24">
 | 
			
		||||
    <path android:fillColor="#000" android:pathData="M3,11H5V13H3V11M11,5H13V9H11V5M9,11H13V15H11V13H9V11M15,11H17V13H19V11H21V13H19V15H21V19H19V21H17V19H13V21H11V17H15V15H17V13H15V11M19,19V15H17V19H19M15,3H21V9H15V3M17,5V7H19V5H17M3,3H9V9H3V3M5,5V7H7V5H5M3,15H9V21H3V15M5,17V19H7V17H5Z" />
 | 
			
		||||
</vector>
 | 
			
		||||
    <path android:fillColor="#DEFFFFFF" android:pathData="M3,11H5V13H3V11M11,5H13V9H11V5M9,11H13V15H11V13H9V11M15,11H17V13H19V11H21V13H19V15H21V19H19V21H17V19H13V21H11V17H15V15H17V13H15V11M19,19V15H17V19H19M15,3H21V9H15V3M17,5V7H19V5H17M3,3H9V9H3V3M5,5V7H7V5H5M3,15H9V21H3V15M5,17V19H7V17H5Z" />
 | 
			
		||||
</vector>
 | 
			
		||||
 
 | 
			
		||||
@@ -8,12 +8,10 @@
 | 
			
		||||
        android:id="@id/android:list"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:choiceMode="singleChoice"
 | 
			
		||||
 | 
			
		||||
        android:layout_alignParentBottom="true"
 | 
			
		||||
        android:layout_alignParentStart="true"
 | 
			
		||||
        android:layout_alignParentTop="true"
 | 
			
		||||
 | 
			
		||||
        android:choiceMode="singleChoice"
 | 
			
		||||
        android:clipToPadding="false"
 | 
			
		||||
        android:paddingBottom="88dp"
 | 
			
		||||
        android:scrollbarStyle="outsideOverlay"/>
 | 
			
		||||
@@ -26,8 +24,8 @@
 | 
			
		||||
        android:layout_alignParentEnd="true"
 | 
			
		||||
        android:layout_gravity="bottom|end"
 | 
			
		||||
        android:layout_margin="16dp"
 | 
			
		||||
        android:src="@drawable/ic_action_add_contact"
 | 
			
		||||
        app:elevation="8dp"
 | 
			
		||||
        app:fabDrawable="@drawable/ic_action_add_contact"
 | 
			
		||||
        app:fabGravity="bottom_end"
 | 
			
		||||
        app:fabMenu="@menu/fab_address"/>
 | 
			
		||||
</RelativeLayout>
 | 
			
		||||
 
 | 
			
		||||
@@ -19,13 +19,16 @@
 | 
			
		||||
        android:scrollbars="vertical"
 | 
			
		||||
        tools:listitem="@layout/message_row"/>
 | 
			
		||||
 | 
			
		||||
    <android.support.design.widget.FloatingActionButton
 | 
			
		||||
    <io.github.yavski.fabspeeddial.FabSpeedDial
 | 
			
		||||
        android:id="@+id/fab_compose_message"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_alignParentBottom="true"
 | 
			
		||||
        android:layout_alignParentEnd="true"
 | 
			
		||||
        android:layout_gravity="bottom|end"
 | 
			
		||||
        android:layout_margin="16dp"
 | 
			
		||||
        android:src="@drawable/ic_action_compose_message"
 | 
			
		||||
        app:elevation="8dp"/>
 | 
			
		||||
        app:elevation="8dp"
 | 
			
		||||
        app:fabDrawable="@drawable/ic_action_compose_message"
 | 
			
		||||
        app:fabGravity="bottom_end"
 | 
			
		||||
        app:fabMenu="@menu/fab_message"/>
 | 
			
		||||
</RelativeLayout>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								app/src/main/res/menu/fab_message.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/src/main/res/menu/fab_message.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<!--
 | 
			
		||||
  ~ Copyright 2016 Christian Basler
 | 
			
		||||
  ~
 | 
			
		||||
  ~ Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
  ~ you may not use this file except in compliance with the License.
 | 
			
		||||
  ~ You may obtain a copy of the License at
 | 
			
		||||
  ~
 | 
			
		||||
  ~     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
  ~
 | 
			
		||||
  ~ Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
  ~ distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
  ~ See the License for the specific language governing permissions and
 | 
			
		||||
  ~ limitations under the License.
 | 
			
		||||
  -->
 | 
			
		||||
 | 
			
		||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/action_compose_broadcast"
 | 
			
		||||
        android:icon="@drawable/ic_action_broadcast"
 | 
			
		||||
        android:title="@string/broadcast"/>
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/action_compose_message"
 | 
			
		||||
        android:icon="@drawable/ic_action_personal"
 | 
			
		||||
        android:title="@string/personal_message"/>
 | 
			
		||||
</menu>
 | 
			
		||||
@@ -99,4 +99,6 @@ Als Alternative kann in den Einstellungen ein vertrauenswürdiger Knoten konfigu
 | 
			
		||||
    <string name="full_node_restart">Knoten starten</string>
 | 
			
		||||
    <string name="full_node_stop">Knoten beenden</string>
 | 
			
		||||
    <string name="startup_node">Knoten starten</string>
 | 
			
		||||
    <string name="personal_message">Nachricht</string>
 | 
			
		||||
    <string name="no_identity_warning">Bitte versuchs nochmals wenn eine Identität verfügbar ist.</string>
 | 
			
		||||
</resources>
 | 
			
		||||
 
 | 
			
		||||
@@ -98,4 +98,6 @@ As an alternative you could configure a trusted node in the settings, but as of
 | 
			
		||||
    <string name="full_node_stop">shutdown node</string>
 | 
			
		||||
    <string name="full_node_restart">restart node</string>
 | 
			
		||||
    <string name="startup_node">Startup node</string>
 | 
			
		||||
    <string name="personal_message">Message</string>
 | 
			
		||||
    <string name="no_identity_warning">Please try again once an identity is available.</string>
 | 
			
		||||
</resources>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user