From 0390d845e5727fa59d9f925502cb0fd2e6429a13 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Thu, 11 Feb 2021 17:23:51 +0100 Subject: [PATCH] cleanup --- .../securesms/ProfileActivity.java | 19 +++++++------- .../securesms/ProfileSettingsAdapter.java | 25 ------------------- .../securesms/ProfileSettingsFragment.java | 18 ------------- 3 files changed, 9 insertions(+), 53 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ProfileActivity.java b/src/org/thoughtcrime/securesms/ProfileActivity.java index 3613ca72d..a19a4df26 100644 --- a/src/org/thoughtcrime/securesms/ProfileActivity.java +++ b/src/org/thoughtcrime/securesms/ProfileActivity.java @@ -18,7 +18,6 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; import android.view.Menu; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.EditText; @@ -251,7 +250,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity } private boolean isContactProfile() { - // there may still be a single-chat lined to the contact profile + // contact-profiles are profiles without a chat or with a one-to-one chat return contactId!=0 && (chatId==0 || !chatIsGroup); } @@ -307,7 +306,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity switch(tabId) { case TAB_SETTINGS: if(isContactProfile()) { - return getString(contactId==DcContact.DC_CONTACT_ID_SELF? R.string.self : R.string.tab_contact); + return getString(R.string.tab_contact); } else if (chatIsMailingList) { return getString(R.string.mailing_list); @@ -369,7 +368,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity return false; } - public void onNotifyOnOff() { + private void onNotifyOnOff() { if (Prefs.isChatMuted(dcContext.getChat(chatId))) { setMuted(0); } @@ -384,7 +383,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity } } - public void onSoundSettings() { + private void onSoundSettings() { Uri current = Prefs.getChatRingtone(this, chatId); Uri defaultUri = Prefs.getNotificationRingtone(this); @@ -401,7 +400,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity startActivityForResult(intent, REQUEST_CODE_PICK_RINGTONE); } - public void onVibrateSettings() { + private void onVibrateSettings() { int checkedItem = Prefs.getChatVibrate(this, chatId).getId(); int[] selectedChoice = new int[]{checkedItem}; new AlertDialog.Builder(this) @@ -414,7 +413,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity .show(); } - public void onEnlargeAvatar() { + private void onEnlargeAvatar() { String profileImagePath; String title; Uri profileImageUri; @@ -441,7 +440,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity startActivity(intent); } - public void onEditName() { + private void onEditName() { if (chatIsGroup) { Intent intent = new Intent(this, GroupCreateActivity.class); intent.putExtra(GroupCreateActivity.EDIT_GROUP_CHAT_ID, chatId); @@ -468,7 +467,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity } } - public void onEncrInfo() { + private void onEncrInfo() { String info_str = isContactProfile() ? dcContext.getContactEncrInfo(contactId) : dcContext.getChatEncrInfo(chatId); new AlertDialog.Builder(this) @@ -477,7 +476,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity .show(); } - public void onBlockContact() { + private void onBlockContact() { DcContact dcContact = dcContext.getContact(contactId); if(dcContact.isBlocked()) { new AlertDialog.Builder(this) diff --git a/src/org/thoughtcrime/securesms/ProfileSettingsAdapter.java b/src/org/thoughtcrime/securesms/ProfileSettingsAdapter.java index 7354b25ce..8f467784e 100644 --- a/src/org/thoughtcrime/securesms/ProfileSettingsAdapter.java +++ b/src/org/thoughtcrime/securesms/ProfileSettingsAdapter.java @@ -33,15 +33,6 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter { public static final int SETTING_CONTACT_ADDR = 110; public static final int SETTING_NEW_CHAT = 120; - public static final int SETTING_CONTACT_NAME = 130; - public static final int SETTING_ENCRYPTION = 140; - public static final int SETTING_BLOCK_CONTACT = 150; - - public static final int SETTING_GROUP_NAME_N_IMAGE = 210; - - public static final int SETTING_NOTIFY = 310; - public static final int SETTING_SOUND = 320; - public static final int SETTING_VIBRATE = 330; private final @NonNull Context context; private final @NonNull Locale locale; @@ -62,7 +53,6 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter static final int TYPE_PRIMARY_SETTING = 1; static final int TYPE_MEMBER = 2; static final int TYPE_SHARED_CHAT = 3; - static final int TYPE_SECONDARY_SETTING = 4; int type; int contactId; int chatlistIndex; @@ -279,13 +269,10 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter for (int value : memberList) { itemData.add(new ItemData(ItemData.TYPE_MEMBER, value, 0)); } -// itemData.add(new ItemData(ItemData.TYPE_SECONDARY_SETTING, SETTING_GROUP_NAME_N_IMAGE, context.getString(R.string.menu_group_name_and_image))); } else if (sharedChats!=null && dcContact!=null) { itemDataContact = dcContact; itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_CONTACT_ADDR,dcContact.getAddr())); -// itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_CONTACT_NAME, context.getString(R.string.menu_edit_name))); -// itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_ENCRYPTION, context.getString(R.string.profile_encryption))); itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_NEW_CHAT, context.getString(R.string.send_message))); itemDataSharedChats = sharedChats; int sharedChatsCnt = sharedChats.getCnt(); @@ -294,18 +281,6 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter } } -// if(dcChat!=null) { -// itemData.add(new ItemData(ItemData.TYPE_SECONDARY_SETTING, SETTING_NOTIFY, -// context.getString(Prefs.isChatMuted(context, dcChat.getId())? R.string.menu_unmute : R.string.menu_mute))); -// itemData.add(new ItemData(ItemData.TYPE_SECONDARY_SETTING, SETTING_SOUND, context.getString(R.string.pref_sound))); -// itemData.add(new ItemData(ItemData.TYPE_SECONDARY_SETTING, SETTING_VIBRATE, context.getString(R.string.pref_vibrate))); -// } - -// if (dcContact!=null) { -// itemData.add(new ItemData(ItemData.TYPE_SECONDARY_SETTING, SETTING_BLOCK_CONTACT, -// context.getString(dcContact.isBlocked()? R.string.menu_unblock_contact : R.string.menu_block_contact))); -// } - notifyDataSetChanged(); } } diff --git a/src/org/thoughtcrime/securesms/ProfileSettingsFragment.java b/src/org/thoughtcrime/securesms/ProfileSettingsFragment.java index 61623a96a..c75258381 100644 --- a/src/org/thoughtcrime/securesms/ProfileSettingsFragment.java +++ b/src/org/thoughtcrime/securesms/ProfileSettingsFragment.java @@ -144,24 +144,6 @@ public class ProfileSettingsFragment extends Fragment case ProfileSettingsAdapter.SETTING_NEW_CHAT: onNewChat(); break; - case ProfileSettingsAdapter.SETTING_CONTACT_NAME: - ((ProfileActivity)getActivity()).onEditName(); - break; - case ProfileSettingsAdapter.SETTING_ENCRYPTION: - ((ProfileActivity)getActivity()).onEncrInfo(); - break; - case ProfileSettingsAdapter.SETTING_BLOCK_CONTACT: - ((ProfileActivity)getActivity()).onBlockContact(); - break; - case ProfileSettingsAdapter.SETTING_NOTIFY: - ((ProfileActivity)getActivity()).onNotifyOnOff(); - break; - case ProfileSettingsAdapter.SETTING_SOUND: - ((ProfileActivity)getActivity()).onSoundSettings(); - break; - case ProfileSettingsAdapter.SETTING_VIBRATE: - ((ProfileActivity)getActivity()).onVibrateSettings(); - break; } }