From 96e1a19b4c155ea2c0e876bbbadd31ecea44a8ee Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Wed, 28 Nov 2018 01:44:27 +0100 Subject: [PATCH] remove unused profile sharing --- res/layout/conversation_activity.xml | 6 -- ...tion_activity_group_share_profile_stub.xml | 6 -- .../securesms/ConversationActivity.java | 14 ---- .../securesms/database/RecipientDatabase.java | 19 +---- .../profiles/GroupShareProfileView.java | 69 ------------------- .../securesms/recipients/Recipient.java | 18 ----- .../recipients/RecipientProvider.java | 2 - 7 files changed, 2 insertions(+), 132 deletions(-) delete mode 100644 res/layout/conversation_activity_group_share_profile_stub.xml delete mode 100644 src/org/thoughtcrime/securesms/profiles/GroupShareProfileView.java diff --git a/res/layout/conversation_activity.xml b/res/layout/conversation_activity.xml index f4e4f58ba..2c0daf4a6 100644 --- a/res/layout/conversation_activity.xml +++ b/res/layout/conversation_activity.xml @@ -24,12 +24,6 @@ android:clipToPadding="false" android:clipChildren="false"> - - - diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index 11232702f..caa96bd4c 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -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; - private Stub 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(); diff --git a/src/org/thoughtcrime/securesms/database/RecipientDatabase.java b/src/org/thoughtcrime/securesms/database/RecipientDatabase.java index a5aada6af..213adae7e 100644 --- a/src/org/thoughtcrime/securesms/database/RecipientDatabase.java +++ b/src/org/thoughtcrime/securesms/database/RecipientDatabase.java @@ -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
getAllAddresses() { SQLiteDatabase db = databaseHelper.getReadableDatabase(); Set
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 { diff --git a/src/org/thoughtcrime/securesms/profiles/GroupShareProfileView.java b/src/org/thoughtcrime/securesms/profiles/GroupShareProfileView.java deleted file mode 100644 index 47bd3db44..000000000 --- a/src/org/thoughtcrime/securesms/profiles/GroupShareProfileView.java +++ /dev/null @@ -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; - } -} diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index 9cb9640ae..60102d93a 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -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 + '}'; } diff --git a/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java b/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java index c687c16fb..ee91d8145 100644 --- a/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java +++ b/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java @@ -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();