end view if conversation was archived
This commit is contained in:
parent
a1b3e2d57c
commit
f2b0a10c22
|
@ -1615,6 +1615,17 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isConversationStillOpen(final Conversation conversation) {
|
||||||
|
synchronized (this.conversations) {
|
||||||
|
for(Conversation current : this.conversations) {
|
||||||
|
if (current == conversation) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public Conversation findOrCreateConversation(Account account, Jid jid, boolean muc, final boolean async) {
|
public Conversation findOrCreateConversation(Account account, Jid jid, boolean muc, final boolean async) {
|
||||||
return this.findOrCreateConversation(account, jid, muc, false, async);
|
return this.findOrCreateConversation(account, jid, muc, false, async);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
package eu.siacs.conversations.ui;
|
package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
|
import android.databinding.DataBindingUtil;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.style.TypefaceSpan;
|
import android.text.style.TypefaceSpan;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.databinding.DialogBlockContactBinding;
|
||||||
import eu.siacs.conversations.entities.Blockable;
|
import eu.siacs.conversations.entities.Blockable;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
@ -23,13 +19,10 @@ public final class BlockContactDialog {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(xmppActivity);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(xmppActivity);
|
||||||
final boolean isBlocked = blockable.isBlocked();
|
final boolean isBlocked = blockable.isBlocked();
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
LayoutInflater inflater = (LayoutInflater) xmppActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
DialogBlockContactBinding binding = DataBindingUtil.inflate(xmppActivity.getLayoutInflater(), R.layout.dialog_block_contact, null, false);
|
||||||
LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_block_contact,null);
|
|
||||||
TextView message = (TextView) view.findViewById(R.id.text);
|
|
||||||
final CheckBox report = (CheckBox) view.findViewById(R.id.report_spam);
|
|
||||||
final boolean reporting = blockable.getAccount().getXmppConnection().getFeatures().spamReporting();
|
final boolean reporting = blockable.getAccount().getXmppConnection().getFeatures().spamReporting();
|
||||||
report.setVisibility(!isBlocked && reporting ? View.VISIBLE : View.GONE);
|
binding.reportSpam.setVisibility(!isBlocked && reporting ? View.VISIBLE : View.GONE);
|
||||||
builder.setView(view);
|
builder.setView(binding.getRoot());
|
||||||
|
|
||||||
String value;
|
String value;
|
||||||
SpannableString spannable;
|
SpannableString spannable;
|
||||||
|
@ -45,27 +38,23 @@ public final class BlockContactDialog {
|
||||||
}
|
}
|
||||||
int start = spannable.toString().indexOf(value);
|
int start = spannable.toString().indexOf(value);
|
||||||
if (start >= 0) {
|
if (start >= 0) {
|
||||||
spannable.setSpan(new TypefaceSpan("monospace"),start,start + value.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
spannable.setSpan(new TypefaceSpan("monospace"), start, start + value.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
message.setText(spannable);
|
binding.text.setText(spannable);
|
||||||
builder.setPositiveButton(isBlocked ? R.string.unblock : R.string.block, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(isBlocked ? R.string.unblock : R.string.block, (dialog, which) -> {
|
||||||
|
if (isBlocked) {
|
||||||
@Override
|
xmppActivity.xmppConnectionService.sendUnblockRequest(blockable);
|
||||||
public void onClick(final DialogInterface dialog, final int which) {
|
} else {
|
||||||
if (isBlocked) {
|
boolean toastShown = false;
|
||||||
xmppActivity.xmppConnectionService.sendUnblockRequest(blockable);
|
if (xmppActivity.xmppConnectionService.sendBlockRequest(blockable, binding.reportSpam.isChecked())) {
|
||||||
} else {
|
Toast.makeText(xmppActivity, R.string.corresponding_conversations_closed, Toast.LENGTH_SHORT).show();
|
||||||
boolean toastShown = false;
|
toastShown = true;
|
||||||
if (xmppActivity.xmppConnectionService.sendBlockRequest(blockable, report.isChecked())) {
|
}
|
||||||
Toast.makeText(xmppActivity,R.string.corresponding_conversations_closed,Toast.LENGTH_SHORT).show();
|
if (xmppActivity instanceof ContactDetailsActivity) {
|
||||||
toastShown = true;
|
if (!toastShown) {
|
||||||
}
|
Toast.makeText(xmppActivity, R.string.contact_blocked_past_tense, Toast.LENGTH_SHORT).show();
|
||||||
if (xmppActivity instanceof ContactDetailsActivity) {
|
|
||||||
if (!toastShown) {
|
|
||||||
Toast.makeText(xmppActivity,R.string.contact_blocked_past_tense,Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
xmppActivity.finish();
|
|
||||||
}
|
}
|
||||||
|
xmppActivity.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1435,9 +1435,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
switch (attachmentChoice) {
|
switch (attachmentChoice) {
|
||||||
case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
|
case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
|
||||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||||
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
|
||||||
}
|
|
||||||
intent.setType("image/*");
|
intent.setType("image/*");
|
||||||
chooser = true;
|
chooser = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1800,9 +1798,15 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
if (this.activity == null || this.binding == null) {
|
if (this.activity == null || this.binding == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!activity.xmppConnectionService.isConversationStillOpen(this.conversation)) {
|
||||||
|
activity.onConversationArchived(this.conversation);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
stopScrolling();
|
stopScrolling();
|
||||||
Log.d(Config.LOGTAG, "reInit(hasExtras=" + Boolean.toString(hasExtras) + ")");
|
Log.d(Config.LOGTAG, "reInit(hasExtras=" + Boolean.toString(hasExtras) + ")");
|
||||||
|
|
||||||
if (this.conversation.isRead() && hasExtras) {
|
if (this.conversation.isRead() && hasExtras) {
|
||||||
Log.d(Config.LOGTAG, "trimming conversation");
|
Log.d(Config.LOGTAG, "trimming conversation");
|
||||||
this.conversation.trim();
|
this.conversation.trim();
|
||||||
|
@ -1992,6 +1996,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
Log.d(Config.LOGTAG, "ConversationFragment.refresh() skipped updated because view binding was null");
|
Log.d(Config.LOGTAG, "ConversationFragment.refresh() skipped updated because view binding was null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.conversation != null && this.activity != null && this.activity.xmppConnectionService != null) {
|
||||||
|
if (!activity.xmppConnectionService.isConversationStillOpen(this.conversation)) {
|
||||||
|
activity.onConversationArchived(this.conversation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.refresh(true);
|
this.refresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2033,10 +2043,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFocusOnInputField() {
|
|
||||||
this.binding.textinput.requestFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doneSendingPgpMessage() {
|
public void doneSendingPgpMessage() {
|
||||||
mSendingPgpMessage.set(false);
|
mSendingPgpMessage.set(false);
|
||||||
}
|
}
|
||||||
|
@ -2464,8 +2470,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
Conversation conversation = activity.xmppConnectionService.findConversationByUuid(uuid);
|
Conversation conversation = activity.xmppConnectionService.findConversationByUuid(uuid);
|
||||||
if (conversation == null) {
|
if (conversation == null) {
|
||||||
Log.d(Config.LOGTAG, "unable to restore activity");
|
|
||||||
clearPending();
|
clearPending();
|
||||||
|
activity.onConversationArchived(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reInit(conversation);
|
reInit(conversation);
|
||||||
|
@ -2473,6 +2479,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
if (scrollState != null) {
|
if (scrollState != null) {
|
||||||
setScrollPosition(scrollState);
|
setScrollPosition(scrollState);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!activity.xmppConnectionService.isConversationStillOpen(conversation)) {
|
||||||
|
clearPending();
|
||||||
|
activity.onConversationArchived(conversation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ActivityResult activityResult = postponedActivityResult.pop();
|
ActivityResult activityResult = postponedActivityResult.pop();
|
||||||
if (activityResult != null) {
|
if (activityResult != null) {
|
||||||
|
|
|
@ -242,10 +242,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
|
||||||
Toast.makeText(this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
builder.setOnDismissListener(dialog -> setNeverAskForBatteryOptimizationsAgain());
|
||||||
builder.setOnDismissListener(dialog -> setNeverAskForBatteryOptimizationsAgain());
|
final AlertDialog dialog = builder.create();
|
||||||
}
|
|
||||||
AlertDialog dialog = builder.create();
|
|
||||||
dialog.setCanceledOnTouchOutside(false);
|
dialog.setCanceledOnTouchOutside(false);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,27 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingLeft="?attr/dialog_horizontal_padding"
|
|
||||||
android:paddingRight="?attr/dialog_horizontal_padding"
|
|
||||||
android:paddingBottom="?attr/dialog_vertical_padding"
|
|
||||||
android:paddingTop="?attr/dialog_vertical_padding">
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/text"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:orientation="vertical"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
android:paddingBottom="?attr/dialog_vertical_padding"
|
||||||
<CheckBox
|
android:paddingLeft="?attr/dialog_horizontal_padding"
|
||||||
android:layout_marginTop="8dp"
|
android:paddingRight="?attr/dialog_horizontal_padding"
|
||||||
android:id="@+id/report_spam"
|
android:paddingTop="?attr/dialog_vertical_padding">
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/report_jid_as_spammer" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/report_spam"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/report_jid_as_spammer"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
Loading…
Reference in a new issue