add fab to start conversations activity
This commit is contained in:
parent
2df1aaaed2
commit
c0b95a9d1c
|
@ -5,13 +5,11 @@ import android.support.v7.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.SwitchCompat;
|
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
|
@ -2,7 +2,14 @@ package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.databinding.DataBindingUtil;
|
||||||
|
import android.databinding.ViewDataBinding;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.annotation.AttrRes;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -58,6 +65,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.databinding.ActivityStartConversationBinding;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Bookmark;
|
import eu.siacs.conversations.entities.Bookmark;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
|
@ -78,7 +86,6 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
|
|
||||||
public int conference_context_id;
|
public int conference_context_id;
|
||||||
public int contact_context_id;
|
public int contact_context_id;
|
||||||
private ViewPager mViewPager;
|
|
||||||
private ListPagerAdapter mListPagerAdapter;
|
private ListPagerAdapter mListPagerAdapter;
|
||||||
private List<ListItem> contacts = new ArrayList<>();
|
private List<ListItem> contacts = new ArrayList<>();
|
||||||
private ListItemAdapter mContactsAdapter;
|
private ListItemAdapter mContactsAdapter;
|
||||||
|
@ -125,7 +132,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
|
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||||
mViewPager.setCurrentItem(tab.getPosition());
|
binding.startConversationViewPager.setCurrentItem(tab.getPosition());
|
||||||
onTabChanged();
|
onTabChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +222,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private Toast mToast;
|
private Toast mToast;
|
||||||
|
private ActivityStartConversationBinding binding;
|
||||||
|
|
||||||
protected void hideToast() {
|
protected void hideToast() {
|
||||||
if (mToast != null) {
|
if (mToast != null) {
|
||||||
|
@ -237,8 +245,14 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
new EmojiService(this).init();
|
new EmojiService(this).init();
|
||||||
setContentView(R.layout.activity_start_conversation);
|
this.binding = DataBindingUtil.setContentView(this,R.layout.activity_start_conversation);
|
||||||
mViewPager = findViewById(R.id.start_conversation_view_pager);
|
this.binding.fab.setOnClickListener((v) -> {
|
||||||
|
if (getSupportActionBar().getSelectedNavigationIndex() == 0) {
|
||||||
|
showCreateContactDialog(null, null);
|
||||||
|
} else {
|
||||||
|
showCreateConferenceDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||||
|
|
||||||
|
@ -247,9 +261,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
actionBar.addTab(mContactsTab);
|
actionBar.addTab(mContactsTab);
|
||||||
actionBar.addTab(mConferencesTab);
|
actionBar.addTab(mConferencesTab);
|
||||||
|
|
||||||
mViewPager.setOnPageChangeListener(mOnPageChangeListener);
|
binding.startConversationViewPager.setOnPageChangeListener(mOnPageChangeListener);
|
||||||
mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager());
|
mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager());
|
||||||
mViewPager.setAdapter(mListPagerAdapter);
|
binding.startConversationViewPager.setAdapter(mListPagerAdapter);
|
||||||
|
|
||||||
mConferenceAdapter = new ListItemAdapter(this, conferences);
|
mConferenceAdapter = new ListItemAdapter(this, conferences);
|
||||||
mContactsAdapter = new ListItemAdapter(this, contacts);
|
mContactsAdapter = new ListItemAdapter(this, contacts);
|
||||||
|
@ -589,8 +603,6 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.start_conversation, menu);
|
getMenuInflater().inflate(R.menu.start_conversation, menu);
|
||||||
MenuItem menuCreateContact = menu.findItem(R.id.action_create_contact);
|
|
||||||
MenuItem menuCreateConference = menu.findItem(R.id.action_conference);
|
|
||||||
MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline);
|
MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline);
|
||||||
menuHideOffline.setChecked(this.mHideOfflineContacts);
|
menuHideOffline.setChecked(this.mHideOfflineContacts);
|
||||||
mMenuSearchView = menu.findItem(R.id.action_search);
|
mMenuSearchView = menu.findItem(R.id.action_search);
|
||||||
|
@ -599,11 +611,6 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
mSearchEditText = mSearchView.findViewById(R.id.search_field);
|
mSearchEditText = mSearchView.findViewById(R.id.search_field);
|
||||||
mSearchEditText.addTextChangedListener(mSearchTextWatcher);
|
mSearchEditText.addTextChangedListener(mSearchTextWatcher);
|
||||||
mSearchEditText.setOnEditorActionListener(mSearchDone);
|
mSearchEditText.setOnEditorActionListener(mSearchDone);
|
||||||
if (getSupportActionBar().getSelectedNavigationIndex() == 0) {
|
|
||||||
menuCreateConference.setVisible(false);
|
|
||||||
} else {
|
|
||||||
menuCreateContact.setVisible(false);
|
|
||||||
}
|
|
||||||
if (mInitialJid != null) {
|
if (mInitialJid != null) {
|
||||||
MenuItemCompat.expandActionView(mMenuSearchView);
|
MenuItemCompat.expandActionView(mMenuSearchView);
|
||||||
mSearchEditText.append(mInitialJid);
|
mSearchEditText.append(mInitialJid);
|
||||||
|
@ -615,15 +622,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_create_contact:
|
|
||||||
showCreateContactDialog(null, null);
|
|
||||||
return true;
|
|
||||||
case R.id.action_join_conference:
|
case R.id.action_join_conference:
|
||||||
showJoinConferenceDialog(null);
|
showJoinConferenceDialog(null);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_create_conference:
|
|
||||||
showCreateConferenceDialog();
|
|
||||||
return true;
|
|
||||||
case R.id.action_scan_qr_code:
|
case R.id.action_scan_qr_code:
|
||||||
Intent intent = new Intent(this, UriHandlerActivity.class);
|
Intent intent = new Intent(this, UriHandlerActivity.class);
|
||||||
intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE);
|
intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE);
|
||||||
|
@ -932,6 +933,13 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTabChanged() {
|
private void onTabChanged() {
|
||||||
|
@DrawableRes final int fabDrawable;
|
||||||
|
if (getSupportActionBar().getSelectedNavigationIndex() == 0) {
|
||||||
|
fabDrawable = R.drawable.ic_person_add_white_24dp;
|
||||||
|
} else {
|
||||||
|
fabDrawable = R.drawable.ic_group_add_white_24dp;
|
||||||
|
}
|
||||||
|
binding.fab.setImageResource(fabDrawable);
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,19 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
android:id="@+id/start_conversation_view_pager"
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="?attr/color_background_primary" >
|
<android.support.v4.view.ViewPager
|
||||||
|
android:id="@+id/start_conversation_view_pager"
|
||||||
</android.support.v4.view.ViewPager>
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/color_background_primary"/>
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end|bottom"
|
||||||
|
android:src="?attr/icon_add_person"
|
||||||
|
android:layout_margin="16dp" />
|
||||||
|
</FrameLayout>
|
||||||
|
</layout>
|
||||||
|
|
|
@ -4,51 +4,35 @@
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_search"
|
android:id="@+id/action_search"
|
||||||
app:actionLayout="@layout/actionview_search"
|
|
||||||
android:icon="?attr/icon_search"
|
android:icon="?attr/icon_search"
|
||||||
app:showAsAction="collapseActionView|always"
|
android:title="@string/search"
|
||||||
android:title="@string/search" />
|
app:actionLayout="@layout/actionview_search"
|
||||||
|
app:showAsAction="collapseActionView|always"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_create_contact"
|
android:id="@+id/action_join_conference"
|
||||||
android:icon="?attr/icon_add_person"
|
android:title="@string/join_conference"
|
||||||
app:showAsAction="always"
|
app:showAsAction="never"/>
|
||||||
android:title="@string/create_contact" />
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_conference"
|
|
||||||
android:icon="?attr/icon_add_group"
|
|
||||||
app:showAsAction="always"
|
|
||||||
android:title="@string/join_or_create_conference">
|
|
||||||
<menu>
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_join_conference"
|
|
||||||
android:title="@string/join_conference"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_create_conference"
|
|
||||||
android:title="@string/create_conference"/>
|
|
||||||
|
|
||||||
</menu>
|
|
||||||
</item>
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_scan_qr_code"
|
android:id="@+id/action_scan_qr_code"
|
||||||
app:showAsAction="never"
|
android:title="@string/scan_qr_code"
|
||||||
android:title="@string/scan_qr_code" />
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_hide_offline"
|
android:id="@+id/action_hide_offline"
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
android:checked="false"
|
android:checked="false"
|
||||||
android:orderInCategory="85"
|
android:orderInCategory="85"
|
||||||
app:showAsAction="never"
|
android:title="@string/hide_offline"
|
||||||
android:title="@string/hide_offline"/>
|
app:showAsAction="never"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_accounts"
|
android:id="@+id/action_accounts"
|
||||||
android:orderInCategory="90"
|
android:orderInCategory="90"
|
||||||
app:showAsAction="never"
|
android:title="@string/action_accounts"
|
||||||
android:title="@string/action_accounts" />
|
app:showAsAction="never"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_settings"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
app:showAsAction="never"
|
android:title="@string/action_settings"
|
||||||
android:title="@string/action_settings" />
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
Loading…
Reference in a new issue