mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #1668 from deltachat/view-profile-from-contact-list
open profile from contact list
This commit is contained in:
@@ -2,7 +2,12 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item android:title="@string/menu_delete_chat"
|
||||
<item android:title="@string/menu_view_profile"
|
||||
android:id="@+id/menu_view_profile"
|
||||
android:icon="?menu_info_icon"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:title="@string/delete_contact"
|
||||
android:id="@+id/menu_delete_selected"
|
||||
android:icon="?menu_trash_icon"
|
||||
app:showAsAction="always" />
|
||||
@@ -11,4 +16,4 @@
|
||||
android:id="@+id/menu_select_all"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
||||
</menu>
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
<string name="ask_delete_named_chat">Are you sure you want to delete \"%1$s\"?</string>
|
||||
<string name="menu_delete_messages">Delete messages</string>
|
||||
<string name="menu_delete_image">Delete image</string>
|
||||
<string name="delete_contact">Delete contact</string>
|
||||
<string name="menu_delete_locations">Delete all locations?</string>
|
||||
<string name="menu_delete_location">Delete this location?</string>
|
||||
<string name="menu_message_details">Message details</string>
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.thoughtcrime.securesms;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
@@ -64,6 +65,7 @@ import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.util.StickyHeaderDecoration;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.views.AdaptiveActionsToolbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
@@ -148,6 +150,7 @@ public class ContactSelectionListFragment extends Fragment
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
|
||||
}
|
||||
setCorrectMenuVisibility(menu);
|
||||
actionMode.setTitle("1");
|
||||
return true;
|
||||
}
|
||||
@@ -163,6 +166,9 @@ public class ContactSelectionListFragment extends Fragment
|
||||
case R.id.menu_select_all:
|
||||
handleSelectAll();
|
||||
return true;
|
||||
case R.id.menu_view_profile:
|
||||
handleViewProfile();
|
||||
return true;
|
||||
case R.id.menu_delete_selected:
|
||||
handleDeleteSelected();
|
||||
return true;
|
||||
@@ -205,6 +211,26 @@ public class ContactSelectionListFragment extends Fragment
|
||||
actionMode.setTitle(String.valueOf(getContactSelectionListAdapter().getActionModeSelection().size()));
|
||||
}
|
||||
|
||||
private void setCorrectMenuVisibility(Menu menu) {
|
||||
ContactSelectionListAdapter adapter = getContactSelectionListAdapter();
|
||||
if (adapter.getActionModeSelection().size() > 1) {
|
||||
menu.findItem(R.id.menu_view_profile).setVisible(false);
|
||||
} else {
|
||||
menu.findItem(R.id.menu_view_profile).setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleViewProfile() {
|
||||
ContactSelectionListAdapter adapter = getContactSelectionListAdapter();
|
||||
if (adapter.getActionModeSelection().size() == 1) {
|
||||
int contactId = adapter.getActionModeSelection().valueAt(0);
|
||||
|
||||
Intent intent = new Intent(getContext(), ProfileActivity.class);
|
||||
intent.putExtra(ProfileActivity.CONTACT_ID_EXTRA, contactId);
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteSelected() {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.ask_delete_contacts)
|
||||
@@ -365,6 +391,8 @@ public class ContactSelectionListFragment extends Fragment
|
||||
{
|
||||
if (handleActionMode) {
|
||||
if (actionMode != null) {
|
||||
Menu menu = actionMode.getMenu();
|
||||
setCorrectMenuVisibility(menu);
|
||||
updateActionModeTitle();
|
||||
finishActionModeIfSelectionIsEmpty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user