mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
98 lines
2.9 KiB
Java
98 lines
2.9 KiB
Java
/*
|
|
* Copyright (C) 2015 Open Whisper Systems
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.thoughtcrime.securesms;
|
|
|
|
import android.os.Bundle;
|
|
import android.view.MenuItem;
|
|
|
|
import org.thoughtcrime.securesms.components.ContactFilterToolbar;
|
|
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
|
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
|
|
|
/**
|
|
* Base activity container for selecting a list of contacts.
|
|
*
|
|
* @author Moxie Marlinspike
|
|
*
|
|
*/
|
|
public abstract class ContactSelectionActivity extends PassphraseRequiredActionBarActivity
|
|
implements ContactSelectionListFragment.OnContactSelectedListener
|
|
{
|
|
private static final String TAG = ContactSelectionActivity.class.getSimpleName();
|
|
|
|
protected ContactSelectionListFragment contactsFragment;
|
|
|
|
private ContactFilterToolbar toolbar;
|
|
|
|
@Override
|
|
protected void onPreCreate() {
|
|
dynamicTheme = new DynamicNoActionBarTheme();
|
|
super.onPreCreate();
|
|
}
|
|
|
|
@Override
|
|
protected void onCreate(Bundle icicle, boolean ready) {
|
|
setContentView(R.layout.contact_selection_activity);
|
|
|
|
initializeToolbar();
|
|
initializeResources();
|
|
initializeSearch();
|
|
}
|
|
|
|
protected ContactFilterToolbar getToolbar() {
|
|
return toolbar;
|
|
}
|
|
|
|
private void initializeToolbar() {
|
|
this.toolbar = ViewUtil.findById(this, R.id.toolbar);
|
|
setSupportActionBar(toolbar);
|
|
|
|
assert getSupportActionBar() != null;
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
getSupportActionBar().setIcon(null);
|
|
getSupportActionBar().setLogo(null);
|
|
}
|
|
|
|
private void initializeResources() {
|
|
contactsFragment = (ContactSelectionListFragment) getSupportFragmentManager().findFragmentById(R.id.contact_selection_list_fragment);
|
|
contactsFragment.setOnContactSelectedListener(this);
|
|
}
|
|
|
|
private void initializeSearch() {
|
|
toolbar.setOnFilterChangedListener(filter -> contactsFragment.setQueryFilter(filter));
|
|
}
|
|
|
|
@Override
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
super.onOptionsItemSelected(item);
|
|
|
|
if (item.getItemId() == android.R.id.home) {
|
|
getOnBackPressedDispatcher().onBackPressed();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public void onContactSelected(int contactId) {}
|
|
|
|
@Override
|
|
public void onContactDeselected(int contactId) {}
|
|
}
|