Some minor fixes for working with extended encoding

This commit is contained in:
Christian Basler 2017-04-20 07:23:21 +02:00
parent a8dada6c89
commit 572ecf1577
5 changed files with 28 additions and 7 deletions

View File

@ -87,8 +87,8 @@ public class ComposeMessageActivity extends AppCompatActivity {
// so features like threading can be supported
if (item.getEncoding() == EXTENDED) {
replyIntent.putExtra(EXTRA_ENCODING, EXTENDED);
replyIntent.putExtra(EXTRA_PARENT, item);
}
replyIntent.putExtra(EXTRA_PARENT, item);
String prefix;
if (item.getSubject().length() >= 3 && item.getSubject().substring(0, 3)
.equalsIgnoreCase("RE:")) {

View File

@ -16,6 +16,7 @@
package ch.dissem.apps.abit;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@ -79,6 +80,11 @@ public class ComposeMessageFragment extends Fragment {
if (getArguments() != null) {
if (getArguments().containsKey(EXTRA_IDENTITY)) {
identity = (BitmessageAddress) getArguments().getSerializable(EXTRA_IDENTITY);
if (getActivity() != null) {
if (identity == null || identity.getPrivateKey() == null) {
identity = Singleton.getIdentity(getActivity());
}
}
} else {
throw new RuntimeException("No identity set for ComposeMessageFragment");
}
@ -156,6 +162,14 @@ public class ComposeMessageFragment extends Fragment {
return rootView;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (identity == null || identity.getPrivateKey() == null) {
identity = Singleton.getIdentity(context);
}
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.compose, menu);
@ -170,6 +184,9 @@ public class ComposeMessageFragment extends Fragment {
return true;
case R.id.select_encoding:
SelectEncodingDialogFragment encodingDialog = new SelectEncodingDialogFragment();
Bundle args = new Bundle();
args.putSerializable(EXTRA_ENCODING, encoding);
encodingDialog.setArguments(args);
encodingDialog.setTargetFragment(this, 0);
encodingDialog.show(getFragmentManager(), "select encoding dialog");
return true;

View File

@ -156,7 +156,10 @@ public class MessageDetailFragment extends Fragment {
}
List<Plaintext> parents = new ArrayList<>(item.getParents().size());
for (InventoryVector parentIV : item.getParents()) {
parents.add(messageRepo.getMessage(parentIV));
Plaintext parent = messageRepo.getMessage(parentIV);
if (parent != null) {
parents.add(parent);
}
}
showRelatedMessages(rootView, R.id.parents, parents);
showRelatedMessages(rootView, R.id.responses, messageRepo.findResponses(item));
@ -165,7 +168,7 @@ public class MessageDetailFragment extends Fragment {
}
private void showRelatedMessages(View rootView, @IdRes int id, List<Plaintext> messages) {
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.parents);
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(id);
RelatedMessageAdapter adapter = new RelatedMessageAdapter(getActivity(), messages);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

View File

@ -201,9 +201,9 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
// There are no parents to save yet (they are saved in the extended data, that's enough for now)
return;
}
db.delete(PARENTS_TABLE_NAME, "child=?", new String[]{hex(message.getInitialHash()).toString()});
byte[] childIV = message.getInventoryVector().getHash();
db.delete(PARENTS_TABLE_NAME, "child=?", new String[]{hex(childIV).toString()});
// save new parents
int order = 0;
for (InventoryVector parentIV : message.getParents()) {

View File

@ -105,13 +105,14 @@
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/responses"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_below="@+id/labels"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />
</RelativeLayout>