From 66aec427d47c72b3ec32b39248cf4e480ca90657 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Mon, 7 Dec 2020 13:45:36 +1100 Subject: [PATCH] Unused code cleanup. --- .../securesms/GroupMembersDialog.java | 130 ------------------ .../securesms/MasterSecretListener.java | 5 - .../PassphraseRequiredActionBarActivity.java | 3 +- .../conversation/ConversationActivity.java | 27 ---- .../res/layout/media_overview_activity.xml | 1 + .../main/res/values-notnight-v21/themes.xml | 1 - app/src/main/res/values/attrs.xml | 2 - app/src/main/res/values/themes.xml | 1 - 8 files changed, 2 insertions(+), 168 deletions(-) delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/GroupMembersDialog.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/MasterSecretListener.java diff --git a/app/src/main/java/org/thoughtcrime/securesms/GroupMembersDialog.java b/app/src/main/java/org/thoughtcrime/securesms/GroupMembersDialog.java deleted file mode 100644 index 20948a6196..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/GroupMembersDialog.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.thoughtcrime.securesms; - -import android.content.Context; -import android.content.DialogInterface; -import android.os.AsyncTask; -import androidx.appcompat.app.AlertDialog; -import android.text.TextUtils; - -import org.thoughtcrime.securesms.database.DatabaseFactory; -import org.thoughtcrime.securesms.recipients.Recipient; -import org.thoughtcrime.securesms.util.Util; - -import java.util.LinkedList; -import java.util.List; - -import network.loki.messenger.R; - -public class GroupMembersDialog extends AsyncTask> { - - private static final String TAG = GroupMembersDialog.class.getSimpleName(); - - private final Recipient recipient; - private final Context context; - - public GroupMembersDialog(Context context, Recipient recipient) { - this.recipient = recipient; - this.context = context; - } - - @Override - public void onPreExecute() {} - - @Override - protected List doInBackground(Void... params) { - return DatabaseFactory.getGroupDatabase(context).getGroupMembers(recipient.getAddress().toGroupString(), true); - } - - @Override - public void onPostExecute(List members) { - GroupMembers groupMembers = new GroupMembers(members); - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(R.string.ConversationActivity_group_members); - builder.setIconAttribute(R.attr.group_members_dialog_icon); - builder.setCancelable(true); - builder.setItems(groupMembers.getRecipientStrings(), new GroupMembersOnClickListener(context, groupMembers)); - builder.setPositiveButton(android.R.string.ok, null); - builder.show(); - } - - public void display() { - executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } - - private static class GroupMembersOnClickListener implements DialogInterface.OnClickListener { - private final GroupMembers groupMembers; - private final Context context; - - public GroupMembersOnClickListener(Context context, GroupMembers members) { - this.context = context; - this.groupMembers = members; - } - - @Override - public void onClick(DialogInterface dialogInterface, int item) { - // Loki - Do nothing -// Recipient recipient = groupMembers.get(item); -// -// if (recipient.getContactUri() != null) { -// Intent intent = new Intent(context, RecipientPreferenceActivity.class); -// intent.putExtra(RecipientPreferenceActivity.ADDRESS_EXTRA, recipient.getAddress()); -// -// context.startActivity(intent); -// } else { -// context.startActivity(RecipientExporter.export(recipient).asAddContactIntent()); -// } - } - } - - /** - * Wraps a List of Recipient (just like @class Recipients), - * but with focus on the order of the Recipients. - * So that the order of the RecipientStrings[] matches - * the internal order. - * - * @author Christoph Haefner - */ - private class GroupMembers { - private final String TAG = GroupMembers.class.getSimpleName(); - - private final LinkedList members = new LinkedList<>(); - - public GroupMembers(List recipients) { - for (Recipient recipient : recipients) { - if (isLocalNumber(recipient)) { - members.push(recipient); - } else { - members.add(recipient); - } - } - } - - public String[] getRecipientStrings() { - List recipientStrings = new LinkedList<>(); - - for (Recipient recipient : members) { - if (isLocalNumber(recipient)) { - recipientStrings.add(context.getString(R.string.GroupMembersDialog_me)); - } else { - String name = recipient.toShortString(); - - if (recipient.getName() == null && !TextUtils.isEmpty(recipient.getProfileName())) { - name += " ~" + recipient.getProfileName(); - } - - recipientStrings.add(name); - } - } - - return recipientStrings.toArray(new String[members.size()]); - } - - public Recipient get(int index) { - return members.get(index); - } - - private boolean isLocalNumber(Recipient recipient) { - return Util.isOwnNumber(context, recipient.getAddress()); - } - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/MasterSecretListener.java b/app/src/main/java/org/thoughtcrime/securesms/MasterSecretListener.java deleted file mode 100644 index 66070e6b26..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/MasterSecretListener.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.thoughtcrime.securesms; - -public interface MasterSecretListener { - void onMasterSecretCleared(); -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java b/app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java index b3ebc37845..720e4aa1fb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java @@ -21,7 +21,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences; import java.util.Locale; -public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarActivity implements MasterSecretListener { +public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarActivity { private static final String TAG = PassphraseRequiredActionBarActivity.class.getSimpleName(); public static final String LOCALE_EXTRA = "locale_extra"; @@ -68,7 +68,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA removeClearKeyReceiver(this); } - @Override public void onMasterSecretCleared() { Log.i(TAG, "onMasterSecretCleared()"); if (ApplicationContext.getInstance(this).isAppVisible()) routeApplicationState(true); diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java index b80d811d0b..675a495785 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -85,7 +85,6 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.ExpirationDialog; -import org.thoughtcrime.securesms.GroupMembersDialog; import org.thoughtcrime.securesms.MediaOverviewActivity; import org.thoughtcrime.securesms.MuteDialog; import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity; @@ -1198,32 +1197,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity } } - private void handleDisplayGroupRecipients() { - new GroupMembersDialog(this, getRecipient()).display(); - } - - private void handleAddToContacts() { - if (recipient.getAddress().isGroup()) return; - - try { - startActivityForResult(RecipientExporter.export(recipient).asAddContactIntent(), ADD_CONTACT); - } catch (ActivityNotFoundException e) { - Log.w(TAG, e); - } - } - - private boolean handleDisplayQuickContact() { - return !recipient.getAddress().isGroup(); - - /* - if (recipient.getContactUri() != null) { - ContactsContract.QuickContact.showQuickContact(ConversationActivity.this, titleView, recipient.getContactUri(), ContactsContract.QuickContact.MODE_LARGE, null); - } else { - handleAddToContacts(); - } - */ - } - private void handleAddAttachment() { if (this.isMmsEnabled || isSecureText) { if (attachmentTypeSelector == null) { diff --git a/app/src/main/res/layout/media_overview_activity.xml b/app/src/main/res/layout/media_overview_activity.xml index 514d20d631..75608f4521 100644 --- a/app/src/main/res/layout/media_overview_activity.xml +++ b/app/src/main/res/layout/media_overview_activity.xml @@ -36,3 +36,4 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior"/> + diff --git a/app/src/main/res/values-notnight-v21/themes.xml b/app/src/main/res/values-notnight-v21/themes.xml index 2807ff2ed7..274f2dbbd8 100644 --- a/app/src/main/res/values-notnight-v21/themes.xml +++ b/app/src/main/res/values-notnight-v21/themes.xml @@ -139,7 +139,6 @@ @color/textsecure_primary_dark - @drawable/ic_group_grey600_24dp @style/PreferenceThemeOverlay.Fix @color/grey_100 diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 783fdaaa38..f21ca1c700 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -126,8 +126,6 @@ - - diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 2fd7ff51a1..4239aebee4 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -265,7 +265,6 @@ #FFFFFF - @drawable/ic_group_white_24dp @style/PreferenceThemeOverlay.Fix @color/grey_800