Added UI for sending broadcasts
- UI shouldn't block until the first identity is ready anymore
This commit is contained in:
parent
6a8648ca28
commit
7332886786
@ -11,13 +11,13 @@ if (project.hasProperty("project.configs")
|
|||||||
|
|
||||||
//noinspection GroovyMissingReturnStatement
|
//noinspection GroovyMissingReturnStatement
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 24
|
compileSdkVersion 25
|
||||||
buildToolsVersion "24.0.3"
|
buildToolsVersion "25.0.0"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "ch.dissem.apps." + appName.toLowerCase()
|
applicationId "ch.dissem.apps." + appName.toLowerCase()
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 24
|
targetSdkVersion 25
|
||||||
versionCode 9
|
versionCode 9
|
||||||
versionName "1.0-beta9"
|
versionName "1.0-beta9"
|
||||||
jackOptions.enabled = true
|
jackOptions.enabled = true
|
||||||
@ -36,12 +36,12 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.jabitVersion = '2.0.2'
|
ext.jabitVersion = '2.0.3'
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
compile 'com.android.support:appcompat-v7:24.2.1'
|
compile 'com.android.support:appcompat-v7:25.0.0'
|
||||||
compile 'com.android.support:support-v4:24.2.1'
|
compile 'com.android.support:support-v4:25.0.0'
|
||||||
compile 'com.android.support:design:24.2.1'
|
compile 'com.android.support:design:25.0.0'
|
||||||
|
|
||||||
compile "ch.dissem.jabit:jabit-core:$jabitVersion"
|
compile "ch.dissem.jabit:jabit-core:$jabitVersion"
|
||||||
compile "ch.dissem.jabit:jabit-networking:$jabitVersion"
|
compile "ch.dissem.jabit:jabit-networking:$jabitVersion"
|
||||||
@ -63,7 +63,7 @@ dependencies {
|
|||||||
|
|
||||||
compile 'com.journeyapps:zxing-android-embedded:3.3.0@aar'
|
compile 'com.journeyapps:zxing-android-embedded:3.3.0@aar'
|
||||||
compile 'com.google.zxing:core:3.3.0'
|
compile 'com.google.zxing:core:3.3.0'
|
||||||
compile 'io.github.yavski:fab-speed-dial:1.0.4'
|
compile 'io.github.yavski:fab-speed-dial:1.0.6'
|
||||||
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
|
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
|
||||||
compile('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.9.3@aar') {
|
compile('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.9.3@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
|
@ -33,6 +33,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatWriter;
|
import com.google.zxing.MultiFormatWriter;
|
||||||
@ -115,10 +116,15 @@ public class AddressDetailFragment extends Fragment {
|
|||||||
final Activity ctx = getActivity();
|
final Activity ctx = getActivity();
|
||||||
switch (menuItem.getItemId()) {
|
switch (menuItem.getItemId()) {
|
||||||
case R.id.write_message: {
|
case R.id.write_message: {
|
||||||
Intent intent = new Intent(ctx, ComposeMessageActivity.class);
|
BitmessageAddress identity = Singleton.getIdentity(ctx);
|
||||||
intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, Singleton.getIdentity(ctx));
|
if (identity == null) {
|
||||||
intent.putExtra(ComposeMessageActivity.EXTRA_RECIPIENT, item);
|
Toast.makeText(ctx, R.string.no_identity_warning, Toast.LENGTH_LONG).show();
|
||||||
startActivity(intent);
|
} else {
|
||||||
|
Intent intent = new Intent(ctx, ComposeMessageActivity.class);
|
||||||
|
intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, identity);
|
||||||
|
intent.putExtra(ComposeMessageActivity.EXTRA_RECIPIENT, item);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case R.id.delete: {
|
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_RECIPIENT = "ch.dissem.abit.Message.RECIPIENT";
|
||||||
public static final String EXTRA_SUBJECT = "ch.dissem.abit.Message.SUBJECT";
|
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_CONTENT = "ch.dissem.abit.Message.CONTENT";
|
||||||
|
public static final String EXTRA_BROADCAST = "ch.dissem.abit.Message.IS_BROADCAST";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
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.apps.abit.service.Singleton;
|
||||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
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_CONTENT;
|
||||||
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_IDENTITY;
|
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_IDENTITY;
|
||||||
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_RECIPIENT;
|
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_RECIPIENT;
|
||||||
@ -50,6 +51,7 @@ public class ComposeMessageFragment extends Fragment {
|
|||||||
private AutoCompleteTextView recipientInput;
|
private AutoCompleteTextView recipientInput;
|
||||||
private EditText subjectInput;
|
private EditText subjectInput;
|
||||||
private EditText bodyInput;
|
private EditText bodyInput;
|
||||||
|
private boolean broadcast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mandatory empty constructor for the fragment manager to instantiate the
|
* Mandatory empty constructor for the fragment manager to instantiate the
|
||||||
@ -67,6 +69,7 @@ public class ComposeMessageFragment extends Fragment {
|
|||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("No identity set for ComposeMessageFragment");
|
throw new RuntimeException("No identity set for ComposeMessageFragment");
|
||||||
}
|
}
|
||||||
|
broadcast = getArguments().getBoolean(EXTRA_BROADCAST, false);
|
||||||
if (getArguments().containsKey(EXTRA_RECIPIENT)) {
|
if (getArguments().containsKey(EXTRA_RECIPIENT)) {
|
||||||
recipient = (BitmessageAddress) getArguments().getSerializable(EXTRA_RECIPIENT);
|
recipient = (BitmessageAddress) getArguments().getSerializable(EXTRA_RECIPIENT);
|
||||||
}
|
}
|
||||||
@ -87,23 +90,28 @@ public class ComposeMessageFragment extends Fragment {
|
|||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View rootView = inflater.inflate(R.layout.fragment_compose_message, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_compose_message, container, false);
|
||||||
recipientInput = (AutoCompleteTextView) rootView.findViewById(R.id.recipient);
|
recipientInput = (AutoCompleteTextView) rootView.findViewById(R.id.recipient);
|
||||||
final ContactAdapter adapter = new ContactAdapter(getContext());
|
if (broadcast) {
|
||||||
recipientInput.setAdapter(adapter);
|
recipientInput.setVisibility(View.GONE);
|
||||||
recipientInput.setOnItemClickListener(
|
} else {
|
||||||
(parent, view, position, id) -> recipient = adapter.getItem(position)
|
final ContactAdapter adapter = new ContactAdapter(getContext());
|
||||||
);
|
recipientInput.setAdapter(adapter);
|
||||||
recipientInput.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
recipientInput.setOnItemClickListener(
|
||||||
@Override
|
(parent, view, position, id) -> recipient = adapter.getItem(position)
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long 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
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
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 = (EditText) rootView.findViewById(R.id.subject);
|
||||||
subjectInput.setText(subject);
|
subjectInput.setText(subject);
|
||||||
@ -132,25 +140,31 @@ public class ComposeMessageFragment extends Fragment {
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.send:
|
case R.id.send:
|
||||||
String inputString = recipientInput.getText().toString();
|
if (broadcast) {
|
||||||
if (recipient == null || !recipient.toString().equals(inputString)) {
|
Singleton.getBitmessageContext(getContext()).broadcast(identity,
|
||||||
try {
|
subjectInput.getText().toString(),
|
||||||
recipient = new BitmessageAddress(inputString);
|
bodyInput.getText().toString());
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
List<BitmessageAddress> contacts = Singleton.getAddressRepository
|
String inputString = recipientInput.getText().toString();
|
||||||
(getContext()).getContacts();
|
if (recipient == null || !recipient.toString().equals(inputString)) {
|
||||||
for (BitmessageAddress contact : contacts) {
|
try {
|
||||||
if (inputString.equalsIgnoreCase(contact.getAlias())) {
|
recipient = new BitmessageAddress(inputString);
|
||||||
recipient = contact;
|
} catch (Exception e) {
|
||||||
if (inputString.equals(contact.getAlias()))
|
List<BitmessageAddress> contacts = Singleton.getAddressRepository
|
||||||
break;
|
(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();
|
getActivity().finish();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package ch.dissem.apps.abit;
|
package ch.dissem.apps.abit;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -26,6 +25,7 @@ import android.support.v7.widget.Toolbar;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.github.amlcurran.showcaseview.ShowcaseView;
|
import com.github.amlcurran.showcaseview.ShowcaseView;
|
||||||
import com.mikepenz.community_material_typeface_library.CommunityMaterial;
|
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.Plaintext;
|
||||||
import ch.dissem.bitmessage.entity.valueobject.Label;
|
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.ComposeMessageActivity.launchReplyTo;
|
||||||
import static ch.dissem.apps.abit.service.BitmessageService.isRunning;
|
import static ch.dissem.apps.abit.service.BitmessageService.isRunning;
|
||||||
|
|
||||||
@ -223,13 +224,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
if (profiles.isEmpty()) {
|
if (profiles.isEmpty()) {
|
||||||
// Create an initial identity
|
// Create an initial identity
|
||||||
BitmessageAddress identity = Singleton.getIdentity(this);
|
Singleton.getIdentity(this);
|
||||||
profiles.add(new ProfileDrawerItem()
|
|
||||||
.withIcon(new Identicon(identity))
|
|
||||||
.withName(identity.toString())
|
|
||||||
.withEmail(identity.getAddress())
|
|
||||||
.withTag(identity)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
profiles.add(new ProfileSettingDrawerItem()
|
profiles.add(new ProfileSettingDrawerItem()
|
||||||
.withName(getString(R.string.add_identity))
|
.withName(getString(R.string.add_identity))
|
||||||
@ -256,11 +251,15 @@ public class MainActivity extends AppCompatActivity
|
|||||||
addIdentityDialog();
|
addIdentityDialog();
|
||||||
break;
|
break;
|
||||||
case MANAGE_IDENTITY:
|
case MANAGE_IDENTITY:
|
||||||
Intent show = new Intent(MainActivity.this,
|
BitmessageAddress identity = Singleton.getIdentity(this);
|
||||||
AddressDetailActivity.class);
|
if (identity == null) {
|
||||||
show.putExtra(AddressDetailFragment.ARG_ITEM,
|
Toast.makeText(this, R.string.no_identity_warning, LENGTH_LONG).show();
|
||||||
Singleton.getIdentity(getApplicationContext()));
|
} else {
|
||||||
startActivity(show);
|
Intent show = new Intent(MainActivity.this,
|
||||||
|
AddressDetailActivity.class);
|
||||||
|
show.putExtra(AddressDetailFragment.ARG_ITEM, identity);
|
||||||
|
startActivity(show);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (profile instanceof ProfileDrawerItem) {
|
if (profile instanceof ProfileDrawerItem) {
|
||||||
|
@ -18,7 +18,6 @@ package ch.dissem.apps.abit;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
@ -29,6 +28,7 @@ import android.view.MenuInflater;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
|
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator;
|
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.ActionBarListener;
|
||||||
import ch.dissem.apps.abit.listener.ListSelectionListener;
|
import ch.dissem.apps.abit.listener.ListSelectionListener;
|
||||||
import ch.dissem.apps.abit.service.Singleton;
|
import ch.dissem.apps.abit.service.Singleton;
|
||||||
|
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
||||||
import ch.dissem.bitmessage.entity.Plaintext;
|
import ch.dissem.bitmessage.entity.Plaintext;
|
||||||
import ch.dissem.bitmessage.entity.valueobject.Label;
|
import ch.dissem.bitmessage.entity.valueobject.Label;
|
||||||
import ch.dissem.bitmessage.ports.MessageRepository;
|
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;
|
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);
|
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
|
||||||
|
|
||||||
// Show the dummy content as text in a TextView.
|
// 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_compose_message);
|
||||||
fab.setOnClickListener(view -> {
|
fab.setMenuListener(new SimpleMenuListenerAdapter() {
|
||||||
Intent intent = new Intent(getActivity().getApplicationContext(),
|
@Override
|
||||||
ComposeMessageActivity.class);
|
public boolean onMenuItemSelected(MenuItem menuItem) {
|
||||||
intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, Singleton.getIdentity
|
BitmessageAddress identity = Singleton.getIdentity(getActivity());
|
||||||
(getActivity()));
|
if (identity == null) {
|
||||||
startActivity(intent);
|
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
|
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss
|
||||||
|
@ -244,16 +244,19 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
|
|||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
|
||||||
// save from address if necessary
|
// save from address if necessary
|
||||||
|
BitmessageAddress savedAddress = ctx.getAddressRepository().getAddress(message
|
||||||
|
.getFrom().getAddress());
|
||||||
if (message.getId() == null) {
|
if (message.getId() == null) {
|
||||||
BitmessageAddress savedAddress = ctx.getAddressRepository().getAddress(message
|
if (savedAddress == null) {
|
||||||
.getFrom().getAddress());
|
|
||||||
if (savedAddress == null || savedAddress.getPrivateKey() == null) {
|
|
||||||
if (savedAddress != null && savedAddress.getAlias() != null) {
|
|
||||||
message.getFrom().setAlias(savedAddress.getAlias());
|
|
||||||
}
|
|
||||||
ctx.getAddressRepository().save(message.getFrom());
|
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
|
// save message
|
||||||
if (message.getId() == null) {
|
if (message.getId() == null) {
|
||||||
|
@ -53,6 +53,7 @@ public class BitmessageIntentService extends IntentService {
|
|||||||
Plaintext item = (Plaintext) intent.getSerializableExtra(EXTRA_DELETE_MESSAGE);
|
Plaintext item = (Plaintext) intent.getSerializableExtra(EXTRA_DELETE_MESSAGE);
|
||||||
bmc.labeler().delete(item);
|
bmc.labeler().delete(item);
|
||||||
bmc.messages().save(item);
|
bmc.messages().save(item);
|
||||||
|
Singleton.getMessageListener(this).resetNotification();
|
||||||
}
|
}
|
||||||
if (intent.hasExtra(EXTRA_STARTUP_NODE)) {
|
if (intent.hasExtra(EXTRA_STARTUP_NODE)) {
|
||||||
if (Preferences.isConnectionAllowed(this)) {
|
if (Preferences.isConnectionAllowed(this)) {
|
||||||
|
@ -17,9 +17,12 @@
|
|||||||
package ch.dissem.apps.abit.service;
|
package ch.dissem.apps.abit.service;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import ch.dissem.apps.abit.MainActivity;
|
||||||
import ch.dissem.apps.abit.R;
|
import ch.dissem.apps.abit.R;
|
||||||
import ch.dissem.apps.abit.adapter.AndroidCryptography;
|
import ch.dissem.apps.abit.adapter.AndroidCryptography;
|
||||||
import ch.dissem.apps.abit.adapter.SwitchingProofOfWorkEngine;
|
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.apps.abit.util.Constants;
|
||||||
import ch.dissem.bitmessage.BitmessageContext;
|
import ch.dissem.bitmessage.BitmessageContext;
|
||||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
||||||
|
import ch.dissem.bitmessage.entity.payload.Pubkey;
|
||||||
import ch.dissem.bitmessage.networking.nio.NioNetworkHandler;
|
import ch.dissem.bitmessage.networking.nio.NioNetworkHandler;
|
||||||
import ch.dissem.bitmessage.ports.AddressRepository;
|
import ch.dissem.bitmessage.ports.AddressRepository;
|
||||||
import ch.dissem.bitmessage.ports.MessageRepository;
|
import ch.dissem.bitmessage.ports.MessageRepository;
|
||||||
@ -50,6 +54,7 @@ public class Singleton {
|
|||||||
private static MessageListener messageListener;
|
private static MessageListener messageListener;
|
||||||
private static BitmessageAddress identity;
|
private static BitmessageAddress identity;
|
||||||
private static AndroidProofOfWorkRepository powRepo;
|
private static AndroidProofOfWorkRepository powRepo;
|
||||||
|
private static boolean creatingIdentity;
|
||||||
|
|
||||||
public static BitmessageContext getBitmessageContext(Context context) {
|
public static BitmessageContext getBitmessageContext(Context context) {
|
||||||
if (bitmessageContext == null) {
|
if (bitmessageContext == null) {
|
||||||
@ -110,15 +115,39 @@ public class Singleton {
|
|||||||
BitmessageContext bmc = getBitmessageContext(ctx);
|
BitmessageContext bmc = getBitmessageContext(ctx);
|
||||||
synchronized (Singleton.class) {
|
synchronized (Singleton.class) {
|
||||||
if (identity == null) {
|
if (identity == null) {
|
||||||
// FIXME: this may block the UI, there must be a better way!
|
|
||||||
List<BitmessageAddress> identities = bmc.addresses()
|
List<BitmessageAddress> identities = bmc.addresses()
|
||||||
.getIdentities();
|
.getIdentities();
|
||||||
if (identities.size() > 0) {
|
if (identities.size() > 0) {
|
||||||
identity = identities.get(0);
|
identity = identities.get(0);
|
||||||
} else {
|
} else {
|
||||||
identity = bmc.createIdentity(false);
|
if (!creatingIdentity) {
|
||||||
identity.setAlias(ctx.getString(R.string.alias_default_identity));
|
creatingIdentity = true;
|
||||||
bmc.addresses().save(identity);
|
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:width="24dp"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24">
|
||||||
<path android:fillColor="#000" android:pathData="M3,11H5V13H3V11M11,5H13V9H11V5M9,11H13V15H11V13H9V11M15,11H17V13H19V11H21V13H19V15H21V19H19V21H17V19H13V21H11V17H15V15H17V13H15V11M19,19V15H17V19H19M15,3H21V9H15V3M17,5V7H19V5H17M3,3H9V9H3V3M5,5V7H7V5H5M3,15H9V21H3V15M5,17V19H7V17H5Z" />
|
<path android:fillColor="#DEFFFFFF" android:pathData="M3,11H5V13H3V11M11,5H13V9H11V5M9,11H13V15H11V13H9V11M15,11H17V13H19V11H21V13H19V15H21V19H19V21H17V19H13V21H11V17H15V15H17V13H15V11M19,19V15H17V19H19M15,3H21V9H15V3M17,5V7H19V5H17M3,3H9V9H3V3M5,5V7H7V5H5M3,15H9V21H3V15M5,17V19H7V17H5Z" />
|
||||||
</vector>
|
</vector>
|
@ -8,12 +8,10 @@
|
|||||||
android:id="@id/android:list"
|
android:id="@id/android:list"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:choiceMode="singleChoice"
|
|
||||||
|
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
android:choiceMode="singleChoice"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingBottom="88dp"
|
android:paddingBottom="88dp"
|
||||||
android:scrollbarStyle="outsideOverlay"/>
|
android:scrollbarStyle="outsideOverlay"/>
|
||||||
@ -26,8 +24,8 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:src="@drawable/ic_action_add_contact"
|
|
||||||
app:elevation="8dp"
|
app:elevation="8dp"
|
||||||
|
app:fabDrawable="@drawable/ic_action_add_contact"
|
||||||
app:fabGravity="bottom_end"
|
app:fabGravity="bottom_end"
|
||||||
app:fabMenu="@menu/fab_address"/>
|
app:fabMenu="@menu/fab_address"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -19,13 +19,16 @@
|
|||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
tools:listitem="@layout/message_row"/>
|
tools:listitem="@layout/message_row"/>
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<io.github.yavski.fabspeeddial.FabSpeedDial
|
||||||
android:id="@+id/fab_compose_message"
|
android:id="@+id/fab_compose_message"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_margin="16dp"
|
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>
|
</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_restart">Knoten starten</string>
|
||||||
<string name="full_node_stop">Knoten beenden</string>
|
<string name="full_node_stop">Knoten beenden</string>
|
||||||
<string name="startup_node">Knoten starten</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>
|
</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_stop">shutdown node</string>
|
||||||
<string name="full_node_restart">restart node</string>
|
<string name="full_node_restart">restart node</string>
|
||||||
<string name="startup_node">Startup 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>
|
</resources>
|
||||||
|
@ -9,7 +9,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.2.1'
|
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
Loading…
Reference in New Issue
Block a user