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,23 +96,25 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
setSupportActionBar(this.toolbar);
|
||||
ActionBar supportActionBar = getSupportActionBar();
|
||||
if (isGlobalProfile()) {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
supportActionBar.setHomeActionContentDescription(getString(R.string.back));
|
||||
} else {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(false);
|
||||
supportActionBar.setCustomView(R.layout.conversation_title_view);
|
||||
supportActionBar.setDisplayShowCustomEnabled(true);
|
||||
supportActionBar.setDisplayShowTitleEnabled(false);
|
||||
Toolbar parent = (Toolbar) supportActionBar.getCustomView().getParent();
|
||||
parent.setPadding(0,0,0,0);
|
||||
parent.setContentInsetsAbsolute(0,0);
|
||||
if (supportActionBar != null) {
|
||||
if (isGlobalProfile()) {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
supportActionBar.setHomeActionContentDescription(getString(R.string.back));
|
||||
} else {
|
||||
supportActionBar.setDisplayHomeAsUpEnabled(false);
|
||||
supportActionBar.setCustomView(R.layout.conversation_title_view);
|
||||
supportActionBar.setDisplayShowCustomEnabled(true);
|
||||
supportActionBar.setDisplayShowTitleEnabled(false);
|
||||
Toolbar parent = (Toolbar) supportActionBar.getCustomView().getParent();
|
||||
parent.setPadding(0,0,0,0);
|
||||
parent.setContentInsetsAbsolute(0,0);
|
||||
|
||||
titleView = (ConversationTitleView) supportActionBar.getCustomView();
|
||||
titleView.setOnBackClickedListener(view -> onBackPressed());
|
||||
titleView.setOnClickListener(view -> onEnlargeAvatar());
|
||||
if (isContactProfile() && !isSelfProfile() && !chatIsDeviceTalk) {
|
||||
titleView.registerForContextMenu(this);
|
||||
titleView = (ConversationTitleView) supportActionBar.getCustomView();
|
||||
titleView.setOnBackClickedListener(view -> onBackPressed());
|
||||
titleView.setOnClickListener(view -> onEnlargeAvatar());
|
||||
if (isContactProfile() && !isSelfProfile() && !chatIsDeviceTalk) {
|
||||
titleView.registerForContextMenu(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,7 +306,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
|
||||
@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);
|
||||
if (currentFragment != null && currentFragment != object) {
|
||||
ActionMode action = null;
|
||||
|
@ -320,6 +322,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
currentFragment = object;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
int tabId = tabs.get(position);
|
||||
|
@ -417,7 +420,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
// =========================================================================
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
super.onOptionsItemSelected(item);
|
||||
|
||||
int itemId = item.getItemId();
|
||||
|
@ -447,7 +450,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
public boolean onContextItemSelected(@NonNull MenuItem item) {
|
||||
super.onContextItemSelected(item);
|
||||
if (item.getItemId() == R.id.copy_addr_to_clipboard) {
|
||||
onCopyAddrToClipboard();
|
||||
|
@ -460,7 +463,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
|
|||
setMuted(0);
|
||||
}
|
||||
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 int itemDataMemberCount;
|
||||
private DcChatlist itemDataSharedChats;
|
||||
private DcContact itemDataContact;
|
||||
private String itemDataStatusText;
|
||||
private boolean isMailingList;
|
||||
private boolean isBroadcast;
|
||||
|
@ -115,8 +114,9 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ProfileSettingsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
public ProfileSettingsAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == ItemData.CATEGORY_MEMBERS) {
|
||||
final ContactSelectionListItem item = (ContactSelectionListItem)layoutInflater.inflate(R.layout.contact_selection_list_item, parent, false);
|
||||
item.setNoHeaderPadding();
|
||||
|
@ -138,7 +138,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||
ViewHolder holder = (ViewHolder) viewHolder;
|
||||
if (holder.itemView instanceof ContactSelectionListItem) {
|
||||
ContactSelectionListItem contactItem = (ContactSelectionListItem) holder.itemView;
|
||||
|
@ -279,23 +279,24 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
|||
itemData.clear();
|
||||
itemDataMemberCount = 0;
|
||||
itemDataSharedChats = null;
|
||||
itemDataContact = null;
|
||||
itemDataStatusText = "";
|
||||
isMailingList = false;
|
||||
isBroadcast = false;
|
||||
|
||||
if (memberList!=null) {
|
||||
itemDataMemberCount = memberList.length;
|
||||
if (dcChat.isBroadcast()) {
|
||||
isBroadcast = true;
|
||||
}
|
||||
if (dcChat != null) {
|
||||
if (dcChat.isBroadcast()) {
|
||||
isBroadcast = true;
|
||||
}
|
||||
|
||||
if (dcChat.isMailingList()) {
|
||||
isMailingList = true;
|
||||
} else if (dcChat.canSend()) {
|
||||
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_ADD_MEMBER, 0));
|
||||
if (!isBroadcast) {
|
||||
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));
|
||||
if (dcChat.isMailingList()) {
|
||||
isMailingList = true;
|
||||
} else if (dcChat.canSend()) {
|
||||
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_ADD_MEMBER, 0));
|
||||
if (!isBroadcast) {
|
||||
itemData.add(new ItemData(ItemData.CATEGORY_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,7 +307,6 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
|||
else if (sharedChats!=null && dcContact!=null) {
|
||||
boolean chatIsDeviceTalk = dcChat != null && dcChat.isDeviceTalk();
|
||||
|
||||
itemDataContact = dcContact;
|
||||
if (!chatIsDeviceTalk) {
|
||||
int verifierId = dcContact.getVerifierId();
|
||||
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));
|
||||
}
|
||||
|
||||
long lastSeenTimestamp = (itemDataContact!=null? itemDataContact.getLastSeen() : 0);
|
||||
long lastSeenTimestamp = dcContact.getLastSeen();
|
||||
String lastSeenTxt;
|
||||
if (lastSeenTimestamp == 0) {
|
||||
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 RecyclerView list;
|
||||
private StickyHeaderDecoration listDecoration;
|
||||
private ProfileSettingsAdapter adapter;
|
||||
private ActionMode actionMode;
|
||||
|
@ -66,17 +65,17 @@ public class ProfileSettingsFragment extends Fragment
|
|||
public void onCreate(Bundle 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);
|
||||
dcContext = DcHelper.getContext(getContext());
|
||||
dcContext = DcHelper.getContext(requireContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
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.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
listDecoration = new StickyHeaderDecoration(adapter, false, true);
|
||||
|
@ -84,7 +83,7 @@ public class ProfileSettingsFragment extends Fragment
|
|||
|
||||
update();
|
||||
|
||||
DcEventCenter eventCenter = DcHelper.getEventCenter(getContext());
|
||||
DcEventCenter eventCenter = DcHelper.getEventCenter(requireContext());
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_CHAT_MODIFIED, this);
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_CONTACTS_CHANGED, this);
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_MSGS_CHANGED, this);
|
||||
|
@ -94,12 +93,12 @@ public class ProfileSettingsFragment extends Fragment
|
|||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
DcHelper.getEventCenter(getContext()).removeObservers(this);
|
||||
DcHelper.getEventCenter(requireContext()).removeObservers(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
listDecoration.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
@ -148,7 +147,7 @@ public class ProfileSettingsFragment extends Fragment
|
|||
|
||||
@Override
|
||||
public void onStatusLongClicked() {
|
||||
Context context = getContext();
|
||||
Context context = requireContext();
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.pref_default_status_label)
|
||||
.setItems(new CharSequence[]{
|
||||
|
@ -169,7 +168,7 @@ public class ProfileSettingsFragment extends Fragment
|
|||
DcChat dcChat = dcContext.getChat(chatId);
|
||||
if (dcChat.canSend()) {
|
||||
adapter.toggleMemberSelection(contactId);
|
||||
actionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(actionModeCallback);
|
||||
actionMode = ((AppCompatActivity) requireActivity()).startSupportActionMode(actionModeCallback);
|
||||
}
|
||||
} else {
|
||||
onMemberClicked(contactId);
|
||||
|
@ -225,8 +224,8 @@ public class ProfileSettingsFragment extends Fragment
|
|||
public void onSharedChatClicked(int chatId) {
|
||||
Intent intent = new Intent(getContext(), ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
|
||||
getContext().startActivity(intent);
|
||||
getActivity().finish();
|
||||
requireContext().startActivity(intent);
|
||||
requireActivity().finish();
|
||||
}
|
||||
|
||||
private void onVerifiedByClicked() {
|
||||
|
@ -245,8 +244,8 @@ public class ProfileSettingsFragment extends Fragment
|
|||
if (chatId != 0) {
|
||||
Intent intent = new Intent(getActivity(), ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
|
||||
getActivity().startActivity(intent);
|
||||
getActivity().finish();
|
||||
requireActivity().startActivity(intent);
|
||||
requireActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +265,7 @@ public class ProfileSettingsFragment extends Fragment
|
|||
menu.findItem(R.id.menu_select_all).setVisible(false);
|
||||
mode.setTitle("1");
|
||||
|
||||
Window window = getActivity().getWindow();
|
||||
Window window = requireActivity().getWindow();
|
||||
originalStatusBarColor = window.getStatusBarColor();
|
||||
window.setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
|
||||
return true;
|
||||
|
@ -289,7 +288,7 @@ public class ProfileSettingsFragment extends Fragment
|
|||
readableToDelList.append(dcContext.getContact(toDelId).getDisplayName());
|
||||
}
|
||||
DcChat dcChat = dcContext.getChat(chatId);
|
||||
AlertDialog dialog = new AlertDialog.Builder(getContext())
|
||||
AlertDialog dialog = new AlertDialog.Builder(requireContext())
|
||||
.setPositiveButton(R.string.remove_desktop, (d, which) -> {
|
||||
for (Integer toDelId : toDelIds) {
|
||||
dcContext.removeContactFromChat(chatId, toDelId);
|
||||
|
@ -309,7 +308,7 @@ public class ProfileSettingsFragment extends Fragment
|
|||
public void onDestroyActionMode(ActionMode mode) {
|
||||
actionMode = null;
|
||||
adapter.clearSelection();
|
||||
getActivity().getWindow().setStatusBarColor(originalStatusBarColor);
|
||||
requireActivity().getWindow().setStatusBarColor(originalStatusBarColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue