remove unused profile sharing

This commit is contained in:
B. Petersen
2018-11-28 01:44:27 +01:00
parent fce4a4267a
commit 96e1a19b4c
7 changed files with 2 additions and 132 deletions
-6
View File
@@ -24,12 +24,6 @@
android:clipToPadding="false"
android:clipChildren="false">
<ViewStub android:id="@+id/group_share_profile_view_stub"
android:layout="@layout/conversation_activity_group_share_profile_stub"
android:inflatedId="@+id/group_share_profile_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ViewStub
android:id="@+id/reminder_stub"
android:layout="@layout/conversation_activity_reminderview_stub"
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<org.thoughtcrime.securesms.profiles.GroupShareProfileView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/group_share_profile_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -113,7 +113,6 @@ import org.thoughtcrime.securesms.mms.Slide;
import org.thoughtcrime.securesms.mms.SlideDeck;
import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.profiles.GroupShareProfileView;
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
@@ -195,7 +194,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private InputAwareLayout container;
private View composePanel;
protected Stub<ReminderView> reminderView;
private Stub<GroupShareProfileView> groupShareProfileView;
private AttachmentTypeSelector attachmentTypeSelector;
private AttachmentManager attachmentManager;
@@ -316,7 +314,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
composeText.setTransport(sendButton.getSelectedTransport());
titleView.setTitle(glideRequests, dcChat);
setGroupShareProfileReminder(recipient);
calculateCharactersRemaining();
MessageNotifier.setVisibleThread(threadId);
@@ -760,7 +757,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
composePanel = ViewUtil.findById(this, R.id.bottom_panel);
container = ViewUtil.findById(this, R.id.layout_container);
reminderView = ViewUtil.findStubById(this, R.id.reminder_stub);
groupShareProfileView = ViewUtil.findStubById(this, R.id.group_share_profile_view_stub);
quickAttachmentDrawer = ViewUtil.findById(this, R.id.quick_attachment_drawer);
quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
@@ -985,15 +981,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
return future;
}
private void setGroupShareProfileReminder(@NonNull Recipient recipient) {
if (recipient.isPushGroupRecipient() && !recipient.isProfileSharing()) {
groupShareProfileView.get().setRecipient(recipient);
groupShareProfileView.get().setVisibility(View.VISIBLE);
} else if (groupShareProfileView.resolved()) {
groupShareProfileView.get().setVisibility(View.GONE);
}
}
private void calculateCharactersRemaining() {
String messageBody = composeText.getTextTrimmed();
TransportOption transportOption = sendButton.getSelectedTransport();
@@ -1592,7 +1579,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
public void handleEvent(int eventId, Object data1, Object data2) {
if (eventId==DcContext.DC_EVENT_CHAT_MODIFIED || eventId==DcContext.DC_EVENT_CONTACTS_CHANGED) {
titleView.setTitle(glideRequests, dcChat);
setGroupShareProfileReminder(recipient);
updateReminders();
initializeSecurity(isSecureText, isDefaultSms);
invalidateOptionsMenu();
@@ -154,7 +154,6 @@ public class RecipientDatabase extends Database {
String systemContactUri = cursor.getString(cursor.getColumnIndexOrThrow(SYSTEM_CONTACT_URI));
String signalProfileName = cursor.getString(cursor.getColumnIndexOrThrow(SIGNAL_PROFILE_NAME));
String signalProfileAvatar = cursor.getString(cursor.getColumnIndexOrThrow(SIGNAL_PROFILE_AVATAR));
boolean profileSharing = cursor.getInt(cursor.getColumnIndexOrThrow(PROFILE_SHARING)) == 1;
MaterialColor color;
byte[] profileKey = null;
@@ -181,7 +180,7 @@ public class RecipientDatabase extends Database {
RegisteredState.fromId(registeredState),
profileKey, systemDisplayName, systemContactPhoto,
systemPhoneLabel, systemContactUri,
signalProfileName, signalProfileAvatar, profileSharing));
signalProfileName, signalProfileAvatar));
}
public BulkOperationsHandle resetAllSystemContactInfo() {
@@ -257,13 +256,6 @@ public class RecipientDatabase extends Database {
recipient.resolve().setProfileAvatar(profileAvatar);
}
public void setProfileSharing(@NonNull Recipient recipient, @SuppressWarnings("SameParameterValue") boolean enabled) {
ContentValues contentValues = new ContentValues(1);
contentValues.put(PROFILE_SHARING, enabled ? 1 : 0);
updateOrInsert(recipient.getAddress(), contentValues);
recipient.setProfileSharing(enabled);
}
public Set<Address> getAllAddresses() {
SQLiteDatabase db = databaseHelper.getReadableDatabase();
Set<Address> results = new HashSet<>();
@@ -407,7 +399,6 @@ public class RecipientDatabase extends Database {
private final String systemContactUri;
private final String signalProfileName;
private final String signalProfileAvatar;
private final boolean profileSharing;
RecipientSettings(boolean blocked, long muteUntil,
@Nullable MaterialColor color,
@@ -421,8 +412,7 @@ public class RecipientDatabase extends Database {
@Nullable String systemPhoneLabel,
@Nullable String systemContactUri,
@Nullable String signalProfileName,
@Nullable String signalProfileAvatar,
boolean profileSharing)
@Nullable String signalProfileAvatar)
{
this.blocked = blocked;
this.muteUntil = muteUntil;
@@ -438,7 +428,6 @@ public class RecipientDatabase extends Database {
this.systemContactUri = systemContactUri;
this.signalProfileName = signalProfileName;
this.signalProfileAvatar = signalProfileAvatar;
this.profileSharing = profileSharing;
}
public @Nullable MaterialColor getColor() {
@@ -496,10 +485,6 @@ public class RecipientDatabase extends Database {
public @Nullable String getProfileAvatar() {
return signalProfileAvatar;
}
public boolean isProfileSharing() {
return profileSharing;
}
}
public static class BlockedReader {
@@ -1,69 +0,0 @@
package org.thoughtcrime.securesms.profiles;
import android.content.Context;
import android.os.Build;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.StyleRes;
import android.support.v7.app.AlertDialog;
import android.util.AttributeSet;
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 GroupShareProfileView extends FrameLayout {
private View container;
private @Nullable Recipient recipient;
public GroupShareProfileView(@NonNull Context context) {
super(context);
initialize();
}
public GroupShareProfileView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initialize();
}
public GroupShareProfileView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize();
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public GroupShareProfileView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
initialize();
}
private void initialize() {
inflate(getContext(), R.layout.profile_group_share_view, this);
this.container = ViewUtil.findById(this, R.id.container);
this.container.setOnClickListener(view -> {
if (this.recipient != null) {
new AlertDialog.Builder(getContext())
.setIconAttribute(R.attr.dialog_info_icon)
.setTitle(R.string.GroupShareProfileView_share_your_profile_name_and_photo_with_this_group)
.setMessage(R.string.GroupShareProfileView_do_you_want_to_make_your_profile_name_and_photo_visible_to_all_current_and_future_members_of_this_group)
.setPositiveButton(R.string.GroupShareProfileView_make_visible, (dialog, which) -> {
DatabaseFactory.getRecipientDatabase(getContext()).setProfileSharing(recipient, true);
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
});
}
public void setRecipient(@NonNull Recipient recipient) {
this.recipient = recipient;
}
}
@@ -85,7 +85,6 @@ public class Recipient implements RecipientModifiedListener {
private @Nullable byte[] profileKey;
private @Nullable String profileName;
private @Nullable String profileAvatar;
private boolean profileSharing;
public static @NonNull Recipient fromChat(@NonNull Context context, int dcMsgId) {
ApplicationDcContext dcContext = DcHelper.getContext(context);
@@ -154,7 +153,6 @@ public class Recipient implements RecipientModifiedListener {
this.profileKey = stale.profileKey;
this.profileName = stale.profileName;
this.profileAvatar = stale.profileAvatar;
this.profileSharing = stale.profileSharing;
this.participants.clear();
this.participants.addAll(stale.participants);
}
@@ -171,7 +169,6 @@ public class Recipient implements RecipientModifiedListener {
this.profileKey = details.get().profileKey;
this.profileName = details.get().profileName;
this.profileAvatar = details.get().profileAvatar;
this.profileSharing = details.get().profileSharing;
this.participants.clear();
this.participants.addAll(details.get().participants);
}
@@ -194,7 +191,6 @@ public class Recipient implements RecipientModifiedListener {
Recipient.this.profileKey = result.profileKey;
Recipient.this.profileName = result.profileName;
Recipient.this.profileAvatar = result.profileAvatar;
Recipient.this.profileSharing = result.profileSharing;
Recipient.this.profileName = result.profileName;
Recipient.this.participants.clear();
@@ -234,7 +230,6 @@ public class Recipient implements RecipientModifiedListener {
this.profileKey = details.profileKey;
this.profileName = details.profileName;
this.profileAvatar = details.profileAvatar;
this.profileSharing = details.profileSharing;
this.participants.addAll(details.participants);
this.resolving = false;
}
@@ -354,18 +349,6 @@ public class Recipient implements RecipientModifiedListener {
notifyListeners();
}
public synchronized boolean isProfileSharing() {
return profileSharing;
}
public void setProfileSharing(boolean value) {
synchronized (this) {
this.profileSharing = value;
}
notifyListeners();
}
public boolean isGroupRecipient() {
return participants.size() > 1;
}
@@ -596,7 +579,6 @@ public class Recipient implements RecipientModifiedListener {
", profileKey=" + Arrays.toString(profileKey) +
", profileName='" + profileName + '\'' +
", profileAvatar='" + profileAvatar + '\'' +
", profileSharing=" + profileSharing +
'}';
}
@@ -166,7 +166,6 @@ public class RecipientProvider {
@NonNull final RegisteredState registered;
@Nullable final byte[] profileKey;
@Nullable final String profileAvatar;
final boolean profileSharing;
final boolean systemContact;
public RecipientDetails(@Nullable String name, @Nullable Long groupAvatarId,
@@ -187,7 +186,6 @@ public class RecipientProvider {
this.registered = settings != null ? settings.getRegistered() : RegisteredState.UNKNOWN;
this.profileKey = settings != null ? settings.getProfileKey() : null;
this.profileAvatar = settings != null ? settings.getProfileAvatar() : null;
this.profileSharing = settings != null && settings.isProfileSharing();
this.systemContact = systemContact;
if (name == null && settings != null) this.name = settings.getSystemDisplayName();