mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
use ok/cancel buttons on adding members, closes #224
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item android:title="@string/group_add_members"
|
||||
android:id="@+id/menu_add_members"
|
||||
android:icon="?menu_accept_icon"
|
||||
app:showAsAction="always|withText"/>
|
||||
|
||||
</menu>
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user