After Width: | Height: | Size: 478 B |
After Width: | Height: | Size: 513 B |
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 335 B |
After Width: | Height: | Size: 356 B |
After Width: | Height: | Size: 204 B |
After Width: | Height: | Size: 665 B |
After Width: | Height: | Size: 694 B |
After Width: | Height: | Size: 329 B |
After Width: | Height: | Size: 973 B |
After Width: | Height: | Size: 1022 B |
After Width: | Height: | Size: 464 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 610 B |
@ -0,0 +1,95 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:background="@color/white">
|
||||||
|
|
||||||
|
<TextView android:id="@+id/unknown_sender_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="25dp"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:text="@string/unknown_sender_view__the_sender_is_not_in_your_contact_list"/>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/block"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="25dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageView android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_block_white_24dp"
|
||||||
|
android:tint="@color/signal_primary"/>
|
||||||
|
|
||||||
|
<TextView android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginStart="15dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/unknown_sender_view__block"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/signal_primary"
|
||||||
|
android:textSize="14sp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/add_to_contacts"
|
||||||
|
android:clickable="true"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="25dp"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageView android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_person_add_white_24dp"
|
||||||
|
android:tint="@color/signal_primary"/>
|
||||||
|
|
||||||
|
<TextView android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginStart="15dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/unknown_sender_view__add_to_contacts"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/signal_primary"
|
||||||
|
android:textSize="14sp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/share_profile"
|
||||||
|
android:clickable="true"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="25dp"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageView android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_face_white_24dp"
|
||||||
|
android:tint="@color/signal_primary"/>
|
||||||
|
|
||||||
|
<TextView android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginStart="15dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/unknown_sender_view__don_t_add_but_make_my_profile_visible"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/signal_primary"
|
||||||
|
android:textSize="14sp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,106 @@
|
|||||||
|
package org.thoughtcrime.securesms.profiles;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.provider.ContactsContract;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
|
|
||||||
|
public class UnknownSenderView extends FrameLayout {
|
||||||
|
|
||||||
|
private final @NonNull Recipient recipient;
|
||||||
|
private final long threadId;
|
||||||
|
|
||||||
|
public UnknownSenderView(@NonNull Context context, @NonNull Recipient recipient, long threadId) {
|
||||||
|
super(context);
|
||||||
|
this.recipient = recipient;
|
||||||
|
this.threadId = threadId;
|
||||||
|
|
||||||
|
inflate(context, R.layout.unknown_sender_view, this);
|
||||||
|
|
||||||
|
View block = ViewUtil.findById(this, R.id.block);
|
||||||
|
View add = ViewUtil.findById(this, R.id.add_to_contacts);
|
||||||
|
View profileAccess = ViewUtil.findById(this, R.id.share_profile);
|
||||||
|
|
||||||
|
block.setOnClickListener(v -> handleBlock());
|
||||||
|
add.setOnClickListener(v -> handleAdd());
|
||||||
|
profileAccess.setOnClickListener(v -> handleProfileAccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleBlock() {
|
||||||
|
final Context context = getContext();
|
||||||
|
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setIconAttribute(R.attr.dialog_alert_icon)
|
||||||
|
.setTitle(getContext().getString(R.string.UnknownSenderView_block_s, recipient.toShortString()))
|
||||||
|
.setMessage(R.string.UnknownSenderView_blocked_contacts_will_no_longer_be_able_to_send_you_messages_or_call_you)
|
||||||
|
.setPositiveButton(R.string.UnknownSenderView_block, (dialog, which) -> {
|
||||||
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
DatabaseFactory.getRecipientPreferenceDatabase(context).setBlocked(recipient, true);
|
||||||
|
if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
recipient.setBlocked(true);
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleAdd() {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
||||||
|
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(recipient.getProfileName())) {
|
||||||
|
intent.putExtra(ContactsContract.Intents.Insert.NAME, recipient.getProfileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recipient.getAddress().isEmail()) {
|
||||||
|
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, recipient.getAddress().toEmailString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recipient.getAddress().isPhone()) {
|
||||||
|
intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipient.getAddress().toPhoneString());
|
||||||
|
}
|
||||||
|
|
||||||
|
getContext().startActivity(intent);
|
||||||
|
if (threadId != -1) DatabaseFactory.getThreadDatabase(getContext()).setHasSent(threadId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleProfileAccess() {
|
||||||
|
final Context context = getContext();
|
||||||
|
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setIconAttribute(R.attr.dialog_info_icon)
|
||||||
|
.setTitle(getContext().getString(R.string.UnknownSenderView_share_profile_with_s, recipient.toShortString()))
|
||||||
|
.setMessage(R.string.UnknownSenderView_the_easiest_way_to_share_your_profile_information_is_to_add_the_sender_to_your_contacts)
|
||||||
|
.setPositiveButton(R.string.UnknownSenderView_share_profile, (dialog, which) -> {
|
||||||
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileSharing(recipient.getAddress(), true);
|
||||||
|
if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
}
|