mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
Merge pull request #3745 from deltachat/adb/fix-warnings-in-profile
fix some linter warnings in classes related to profile
This commit is contained in:
commit
848a86c718
3 changed files with 54 additions and 52 deletions
|
@ -96,6 +96,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
||||||
|
|
||||||
setSupportActionBar(this.toolbar);
|
setSupportActionBar(this.toolbar);
|
||||||
ActionBar supportActionBar = getSupportActionBar();
|
ActionBar supportActionBar = getSupportActionBar();
|
||||||
|
if (supportActionBar != null) {
|
||||||
if (isGlobalProfile()) {
|
if (isGlobalProfile()) {
|
||||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
supportActionBar.setHomeActionContentDescription(getString(R.string.back));
|
supportActionBar.setHomeActionContentDescription(getString(R.string.back));
|
||||||
|
@ -115,6 +116,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
||||||
titleView.registerForContextMenu(this);
|
titleView.registerForContextMenu(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
|
|
||||||
|
@ -304,7 +306,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||||
super.setPrimaryItem(container, position, object);
|
super.setPrimaryItem(container, position, object);
|
||||||
if (currentFragment != null && currentFragment != object) {
|
if (currentFragment != null && currentFragment != object) {
|
||||||
ActionMode action = null;
|
ActionMode action = null;
|
||||||
|
@ -320,6 +322,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
||||||
currentFragment = object;
|
currentFragment = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
int tabId = tabs.get(position);
|
int tabId = tabs.get(position);
|
||||||
|
@ -417,7 +420,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
super.onOptionsItemSelected(item);
|
super.onOptionsItemSelected(item);
|
||||||
|
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
|
@ -447,7 +450,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(@NonNull MenuItem item) {
|
||||||
super.onContextItemSelected(item);
|
super.onContextItemSelected(item);
|
||||||
if (item.getItemId() == R.id.copy_addr_to_clipboard) {
|
if (item.getItemId() == R.id.copy_addr_to_clipboard) {
|
||||||
onCopyAddrToClipboard();
|
onCopyAddrToClipboard();
|
||||||
|
@ -460,7 +463,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
||||||
setMuted(0);
|
setMuted(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MuteDialog.show(this, duration -> setMuted(duration));
|
MuteDialog.show(this, this::setMuted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||||
private final @NonNull ArrayList<ItemData> itemData = new ArrayList<>();
|
private final @NonNull ArrayList<ItemData> itemData = new ArrayList<>();
|
||||||
private int itemDataMemberCount;
|
private int itemDataMemberCount;
|
||||||
private DcChatlist itemDataSharedChats;
|
private DcChatlist itemDataSharedChats;
|
||||||
private DcContact itemDataContact;
|
|
||||||
private String itemDataStatusText;
|
private String itemDataStatusText;
|
||||||
private boolean isMailingList;
|
private boolean isMailingList;
|
||||||
private boolean isBroadcast;
|
private boolean isBroadcast;
|
||||||
|
@ -115,8 +114,9 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ProfileSettingsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ProfileSettingsAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
if (viewType == ItemData.CATEGORY_MEMBERS) {
|
if (viewType == ItemData.CATEGORY_MEMBERS) {
|
||||||
final ContactSelectionListItem item = (ContactSelectionListItem)layoutInflater.inflate(R.layout.contact_selection_list_item, parent, false);
|
final ContactSelectionListItem item = (ContactSelectionListItem)layoutInflater.inflate(R.layout.contact_selection_list_item, parent, false);
|
||||||
item.setNoHeaderPadding();
|
item.setNoHeaderPadding();
|
||||||
|
@ -138,7 +138,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||||
ViewHolder holder = (ViewHolder) viewHolder;
|
ViewHolder holder = (ViewHolder) viewHolder;
|
||||||
if (holder.itemView instanceof ContactSelectionListItem) {
|
if (holder.itemView instanceof ContactSelectionListItem) {
|
||||||
ContactSelectionListItem contactItem = (ContactSelectionListItem) holder.itemView;
|
ContactSelectionListItem contactItem = (ContactSelectionListItem) holder.itemView;
|
||||||
|
@ -279,13 +279,13 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||||
itemData.clear();
|
itemData.clear();
|
||||||
itemDataMemberCount = 0;
|
itemDataMemberCount = 0;
|
||||||
itemDataSharedChats = null;
|
itemDataSharedChats = null;
|
||||||
itemDataContact = null;
|
|
||||||
itemDataStatusText = "";
|
itemDataStatusText = "";
|
||||||
isMailingList = false;
|
isMailingList = false;
|
||||||
isBroadcast = false;
|
isBroadcast = false;
|
||||||
|
|
||||||
if (memberList!=null) {
|
if (memberList!=null) {
|
||||||
itemDataMemberCount = memberList.length;
|
itemDataMemberCount = memberList.length;
|
||||||
|
if (dcChat != null) {
|
||||||
if (dcChat.isBroadcast()) {
|
if (dcChat.isBroadcast()) {
|
||||||
isBroadcast = true;
|
isBroadcast = true;
|
||||||
}
|
}
|
||||||
|
@ -298,6 +298,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||||
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));
|
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int value : memberList) {
|
for (int value : memberList) {
|
||||||
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, value, 0));
|
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, value, 0));
|
||||||
|
@ -306,7 +307,6 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||||
else if (sharedChats!=null && dcContact!=null) {
|
else if (sharedChats!=null && dcContact!=null) {
|
||||||
boolean chatIsDeviceTalk = dcChat != null && dcChat.isDeviceTalk();
|
boolean chatIsDeviceTalk = dcChat != null && dcChat.isDeviceTalk();
|
||||||
|
|
||||||
itemDataContact = dcContact;
|
|
||||||
if (!chatIsDeviceTalk) {
|
if (!chatIsDeviceTalk) {
|
||||||
int verifierId = dcContact.getVerifierId();
|
int verifierId = dcContact.getVerifierId();
|
||||||
if (verifierId != 0) {
|
if (verifierId != 0) {
|
||||||
|
@ -319,7 +319,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||||
itemData.add(new ItemData(ItemData.CATEGORY_INFO, INFO_VERIFIED, verifiedInfo, 0, R.drawable.ic_verified));
|
itemData.add(new ItemData(ItemData.CATEGORY_INFO, INFO_VERIFIED, verifiedInfo, 0, R.drawable.ic_verified));
|
||||||
}
|
}
|
||||||
|
|
||||||
long lastSeenTimestamp = (itemDataContact!=null? itemDataContact.getLastSeen() : 0);
|
long lastSeenTimestamp = dcContact.getLastSeen();
|
||||||
String lastSeenTxt;
|
String lastSeenTxt;
|
||||||
if (lastSeenTimestamp == 0) {
|
if (lastSeenTimestamp == 0) {
|
||||||
lastSeenTxt = context.getString(R.string.last_seen_unknown);
|
lastSeenTxt = context.getString(R.string.last_seen_unknown);
|
||||||
|
|
|
@ -47,7 +47,6 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
|
|
||||||
private static final int REQUEST_CODE_PICK_CONTACT = 2;
|
private static final int REQUEST_CODE_PICK_CONTACT = 2;
|
||||||
|
|
||||||
private RecyclerView list;
|
|
||||||
private StickyHeaderDecoration listDecoration;
|
private StickyHeaderDecoration listDecoration;
|
||||||
private ProfileSettingsAdapter adapter;
|
private ProfileSettingsAdapter adapter;
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
|
@ -66,17 +65,17 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
|
|
||||||
chatId = getArguments().getInt(CHAT_ID_EXTRA, -1);
|
chatId = getArguments() != null ? getArguments().getInt(CHAT_ID_EXTRA, -1) : -1;
|
||||||
contactId = getArguments().getInt(CONTACT_ID_EXTRA, -1);
|
contactId = getArguments().getInt(CONTACT_ID_EXTRA, -1);
|
||||||
dcContext = DcHelper.getContext(getContext());
|
dcContext = DcHelper.getContext(requireContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.profile_settings_fragment, container, false);
|
View view = inflater.inflate(R.layout.profile_settings_fragment, container, false);
|
||||||
adapter = new ProfileSettingsAdapter(getContext(), GlideApp.with(this), this);
|
adapter = new ProfileSettingsAdapter(requireContext(), GlideApp.with(this), this);
|
||||||
|
|
||||||
list = ViewUtil.findById(view, R.id.recycler_view);
|
RecyclerView list = ViewUtil.findById(view, R.id.recycler_view);
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
list.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||||
listDecoration = new StickyHeaderDecoration(adapter, false, true);
|
listDecoration = new StickyHeaderDecoration(adapter, false, true);
|
||||||
|
@ -84,7 +83,7 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
DcEventCenter eventCenter = DcHelper.getEventCenter(getContext());
|
DcEventCenter eventCenter = DcHelper.getEventCenter(requireContext());
|
||||||
eventCenter.addObserver(DcContext.DC_EVENT_CHAT_MODIFIED, this);
|
eventCenter.addObserver(DcContext.DC_EVENT_CHAT_MODIFIED, this);
|
||||||
eventCenter.addObserver(DcContext.DC_EVENT_CONTACTS_CHANGED, this);
|
eventCenter.addObserver(DcContext.DC_EVENT_CONTACTS_CHANGED, this);
|
||||||
eventCenter.addObserver(DcContext.DC_EVENT_MSGS_CHANGED, this);
|
eventCenter.addObserver(DcContext.DC_EVENT_MSGS_CHANGED, this);
|
||||||
|
@ -94,12 +93,12 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
DcHelper.getEventCenter(getContext()).removeObservers(this);
|
DcHelper.getEventCenter(requireContext()).removeObservers(this);
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
listDecoration.onConfigurationChanged(newConfig);
|
listDecoration.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
@ -148,7 +147,7 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStatusLongClicked() {
|
public void onStatusLongClicked() {
|
||||||
Context context = getContext();
|
Context context = requireContext();
|
||||||
new AlertDialog.Builder(context)
|
new AlertDialog.Builder(context)
|
||||||
.setTitle(R.string.pref_default_status_label)
|
.setTitle(R.string.pref_default_status_label)
|
||||||
.setItems(new CharSequence[]{
|
.setItems(new CharSequence[]{
|
||||||
|
@ -169,7 +168,7 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
DcChat dcChat = dcContext.getChat(chatId);
|
DcChat dcChat = dcContext.getChat(chatId);
|
||||||
if (dcChat.canSend()) {
|
if (dcChat.canSend()) {
|
||||||
adapter.toggleMemberSelection(contactId);
|
adapter.toggleMemberSelection(contactId);
|
||||||
actionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(actionModeCallback);
|
actionMode = ((AppCompatActivity) requireActivity()).startSupportActionMode(actionModeCallback);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onMemberClicked(contactId);
|
onMemberClicked(contactId);
|
||||||
|
@ -225,8 +224,8 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
public void onSharedChatClicked(int chatId) {
|
public void onSharedChatClicked(int chatId) {
|
||||||
Intent intent = new Intent(getContext(), ConversationActivity.class);
|
Intent intent = new Intent(getContext(), ConversationActivity.class);
|
||||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
|
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
|
||||||
getContext().startActivity(intent);
|
requireContext().startActivity(intent);
|
||||||
getActivity().finish();
|
requireActivity().finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onVerifiedByClicked() {
|
private void onVerifiedByClicked() {
|
||||||
|
@ -245,8 +244,8 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
if (chatId != 0) {
|
if (chatId != 0) {
|
||||||
Intent intent = new Intent(getActivity(), ConversationActivity.class);
|
Intent intent = new Intent(getActivity(), ConversationActivity.class);
|
||||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
|
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
|
||||||
getActivity().startActivity(intent);
|
requireActivity().startActivity(intent);
|
||||||
getActivity().finish();
|
requireActivity().finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +265,7 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
menu.findItem(R.id.menu_select_all).setVisible(false);
|
menu.findItem(R.id.menu_select_all).setVisible(false);
|
||||||
mode.setTitle("1");
|
mode.setTitle("1");
|
||||||
|
|
||||||
Window window = getActivity().getWindow();
|
Window window = requireActivity().getWindow();
|
||||||
originalStatusBarColor = window.getStatusBarColor();
|
originalStatusBarColor = window.getStatusBarColor();
|
||||||
window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
|
window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
|
||||||
return true;
|
return true;
|
||||||
|
@ -289,7 +288,7 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
readableToDelList.append(dcContext.getContact(toDelId).getDisplayName());
|
readableToDelList.append(dcContext.getContact(toDelId).getDisplayName());
|
||||||
}
|
}
|
||||||
DcChat dcChat = dcContext.getChat(chatId);
|
DcChat dcChat = dcContext.getChat(chatId);
|
||||||
AlertDialog dialog = new AlertDialog.Builder(getContext())
|
AlertDialog dialog = new AlertDialog.Builder(requireContext())
|
||||||
.setPositiveButton(R.string.remove_desktop, (d, which) -> {
|
.setPositiveButton(R.string.remove_desktop, (d, which) -> {
|
||||||
for (Integer toDelId : toDelIds) {
|
for (Integer toDelId : toDelIds) {
|
||||||
dcContext.removeContactFromChat(chatId, toDelId);
|
dcContext.removeContactFromChat(chatId, toDelId);
|
||||||
|
@ -309,7 +308,7 @@ public class ProfileSettingsFragment extends Fragment
|
||||||
public void onDestroyActionMode(ActionMode mode) {
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
actionMode = null;
|
actionMode = null;
|
||||||
adapter.clearSelection();
|
adapter.clearSelection();
|
||||||
getActivity().getWindow().setStatusBarColor(originalStatusBarColor);
|
requireActivity().getWindow().setStatusBarColor(originalStatusBarColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue