diff --git a/res/menu/add_members.xml b/res/menu/add_members.xml new file mode 100644 index 000000000..afc34651c --- /dev/null +++ b/res/menu/add_members.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/src/org/thoughtcrime/securesms/ContactMultiSelectionActivity.java b/src/org/thoughtcrime/securesms/ContactMultiSelectionActivity.java index 74022cb3b..e83345f36 100644 --- a/src/org/thoughtcrime/securesms/ContactMultiSelectionActivity.java +++ b/src/org/thoughtcrime/securesms/ContactMultiSelectionActivity.java @@ -18,6 +18,9 @@ package org.thoughtcrime.securesms; import android.content.Intent; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import java.util.ArrayList; import java.util.List; @@ -37,11 +40,34 @@ public class ContactMultiSelectionActivity extends ContactSelectionActivity { protected void onCreate(Bundle icicle, boolean ready) { getIntent().putExtra(ContactSelectionListFragment.MULTI_SELECT, true); super.onCreate(icicle, ready); + getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp); - getToolbar().setNavigationOnClickListener(v -> { - saveSelection(); - finish(); - }); + // it's a bit confusing having one "X" button on the left and one on the right - + // and the "clear search" button is not that important. + getToolbar().setUseClearButton(false); + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + MenuInflater inflater = this.getMenuInflater(); + menu.clear(); + + inflater.inflate(R.menu.add_members, menu); + super.onPrepareOptionsMenu(menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + super.onOptionsItemSelected(item); + switch (item.getItemId()) { + case R.id.menu_add_members: + saveSelection(); + finish(); + return true; + } + + return false; } @Override diff --git a/src/org/thoughtcrime/securesms/components/ContactFilterToolbar.java b/src/org/thoughtcrime/securesms/components/ContactFilterToolbar.java index 930cbf02b..9dec57e54 100644 --- a/src/org/thoughtcrime/securesms/components/ContactFilterToolbar.java +++ b/src/org/thoughtcrime/securesms/components/ContactFilterToolbar.java @@ -24,6 +24,7 @@ public class ContactFilterToolbar extends Toolbar { private AnimatingToggle toggle; private ImageView clearToggle; private LinearLayout toggleContainer; + private boolean useClearButton; public ContactFilterToolbar(Context context) { this(context, null); @@ -31,6 +32,7 @@ public class ContactFilterToolbar extends Toolbar { public ContactFilterToolbar(Context context, AttributeSet attrs) { this(context, attrs, R.attr.toolbarStyle); + useClearButton = true; } public ContactFilterToolbar(Context context, AttributeSet attrs, int defStyleAttr) { @@ -66,7 +68,9 @@ public class ContactFilterToolbar extends Toolbar { @Override public void afterTextChanged(Editable s) { if (!SearchUtil.isEmpty(searchText)) { - displayTogglingView(clearToggle); + if(useClearButton) { + displayTogglingView(clearToggle); + } } else { displayTogglingView(null); @@ -90,6 +94,10 @@ public class ContactFilterToolbar extends Toolbar { notifyListener(); } + public void setUseClearButton(boolean useClearButton) { + this.useClearButton = useClearButton; + } + public void setOnFilterChangedListener(OnFilterChangedListener listener) { this.listener = listener; }