Commit 392f4a5d authored by Grigory Fedorov's avatar Grigory Fedorov

Contact list: accounts panel inflated into action bar.

parent 5841f896
...@@ -26,16 +26,16 @@ import android.os.Bundle; ...@@ -26,16 +26,16 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.SearchView; import android.widget.SearchView;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.xabber.android.data.ActivityManager; import com.xabber.android.data.ActivityManager;
...@@ -77,7 +77,7 @@ import java.util.Collection; ...@@ -77,7 +77,7 @@ import java.util.Collection;
* @author alexander.ivanov * @author alexander.ivanov
*/ */
public class ContactList extends ManagedActivity implements public class ContactList extends ManagedActivity implements
OnAccountChangedListener, View.OnClickListener, View.OnLongClickListener, OnAccountChangedListener, View.OnClickListener,
OnChoosedListener, OnContactClickListener { OnChoosedListener, OnContactClickListener {
/** /**
...@@ -110,7 +110,7 @@ public class ContactList extends ManagedActivity implements ...@@ -110,7 +110,7 @@ public class ContactList extends ManagedActivity implements
private String sendText; private String sendText;
private SearchView searchView; private SearchView searchView;
private View titleView; private View actionBarView;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
...@@ -126,17 +126,21 @@ public class ContactList extends ManagedActivity implements ...@@ -126,17 +126,21 @@ public class ContactList extends ManagedActivity implements
} }
setContentView(R.layout.contact_list); setContentView(R.layout.contact_list);
titleView = findViewById(android.R.id.title);
accountToggleAdapter = new AccountToggleAdapter(this, this,
(LinearLayout) findViewById(R.id.account_list));
View commonStatusText = findViewById(R.id.common_status_text); ActionBar actionBar = getSupportActionBar();
View commonStatusMode = findViewById(R.id.common_status_mode); actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBarView = LayoutInflater.from(this).inflate(R.layout.contact_list_action_bar, null);
actionBarView.setOnClickListener(this);
commonStatusText.setOnLongClickListener(this); actionBar.setCustomView(actionBarView, new ActionBar.LayoutParams(
commonStatusMode.setOnClickListener(this); ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT));
commonStatusText.setOnClickListener(this);
titleView.setOnClickListener(this); accountToggleAdapter = new AccountToggleAdapter(this, this,
(LinearLayout) actionBarView.findViewById(R.id.account_list));
if (savedInstanceState != null) { if (savedInstanceState != null) {
sendText = savedInstanceState.getString(SAVED_SEND_TEXT); sendText = savedInstanceState.getString(SAVED_SEND_TEXT);
...@@ -448,10 +452,6 @@ public class ContactList extends ManagedActivity implements ...@@ -448,10 +452,6 @@ public class ContactList extends ManagedActivity implements
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.common_status_mode:
startActivity(StatusEditor.createIntent(this));
break;
case R.id.common_status_text:
case android.R.id.title: case android.R.id.title:
getContactListFragment().scrollUp(); getContactListFragment().scrollUp();
break; break;
...@@ -473,16 +473,6 @@ public class ContactList extends ManagedActivity implements ...@@ -473,16 +473,6 @@ public class ContactList extends ManagedActivity implements
} }
} }
@Override
public boolean onLongClick(View view) {
switch (view.getId()) {
case R.id.common_status_text:
startActivity(StatusEditor.createIntent(this));
return true;
}
return false;
}
@Override @Override
public void onContactClick(AbstractContact abstractContact) { public void onContactClick(AbstractContact abstractContact) {
switch (action) { switch (action) {
...@@ -550,9 +540,9 @@ public class ContactList extends ManagedActivity implements ...@@ -550,9 +540,9 @@ public class ContactList extends ManagedActivity implements
updateStatusBar(); updateStatusBar();
accountToggleAdapter.rebuild(); accountToggleAdapter.rebuild();
if (SettingsManager.contactsShowPanel() && accountToggleAdapter.getCount() > 0) { if (SettingsManager.contactsShowPanel() && accountToggleAdapter.getCount() > 0) {
titleView.setVisibility(View.VISIBLE); actionBarView.setVisibility(View.VISIBLE);
} else { } else {
titleView.setVisibility(View.GONE); actionBarView.setVisibility(View.GONE);
} }
} }
...@@ -562,8 +552,6 @@ public class ContactList extends ManagedActivity implements ...@@ -562,8 +552,6 @@ public class ContactList extends ManagedActivity implements
if ("".equals(statusText)) { if ("".equals(statusText)) {
statusText = getString(statusMode.getStringID()); statusText = getString(statusMode.getStringID());
} }
((TextView) findViewById(R.id.common_status_text)).setText(statusText);
((ImageView) findViewById(R.id.common_status_mode)).setImageLevel(statusMode.getStatusLevel());
} }
public static Intent createPersistentIntent(Context context) { public static Intent createPersistentIntent(Context context) {
......
...@@ -17,69 +17,6 @@ ...@@ -17,69 +17,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="@dimen/title_height"
android:layout_alignParentTop="true"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/contact_list_status_mode_width"
android:layout_marginEnd="@dimen/contact_list_status_mode_width"
android:orientation="horizontal" >
<HorizontalScrollView
android:id="@+id/account_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="72dip"
android:layout_marginEnd="72dip"
>
<LinearLayout
android:id="@+id/account_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
<TextView
android:id="@+id/common_status_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginLeft="-72dip"
android:layout_marginStart="-72dip"
android:gravity="start|center_vertical"
android:padding="2dip"
android:singleLine="true"
android:text="online"
android:textColor="?android:attr/textColorPrimary" />
</LinearLayout>
<ImageButton
android:id="@+id/common_status_mode"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="@drawable/btn_status_mode"
android:paddingLeft="@dimen/active_chat_padding_right"
android:paddingRight="@dimen/active_chat_padding_right"
android:src="@drawable/ic_status" />
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/container" android:id="@+id/container"
android:layout_width="match_parent" android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_gravity="fill_horizontal"
android:gravity="center_vertical">
<HorizontalScrollView
android:id="@+id/account_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<LinearLayout
android:id="@+id/account_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment