Commit e589bc8d authored by Grigory Fedorov's avatar Grigory Fedorov

Old app bar imitation removed from ContactList layout and activity.

parent 0375cb0a
...@@ -14,19 +14,13 @@ ...@@ -14,19 +14,13 @@
*/ */
package com.xabber.android.ui; package com.xabber.android.ui;
import java.util.ArrayList;
import java.util.Collection;
import android.app.Dialog; import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnCancelListener;
import android.content.Intent; import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
...@@ -37,11 +31,7 @@ import android.view.KeyEvent; ...@@ -37,11 +31,7 @@ import android.view.KeyEvent;
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.View.OnLongClickListener;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.xabber.android.data.ActivityManager; import com.xabber.android.data.ActivityManager;
...@@ -49,8 +39,6 @@ import com.xabber.android.data.Application; ...@@ -49,8 +39,6 @@ import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.entity.BaseEntity; import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.avatar.AvatarManager; import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.data.extension.muc.MUCManager; import com.xabber.android.data.extension.muc.MUCManager;
...@@ -62,26 +50,25 @@ import com.xabber.android.data.roster.AbstractContact; ...@@ -62,26 +50,25 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.RosterContact; import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.ContactListFragment.OnContactClickListener; import com.xabber.android.ui.ContactListFragment.OnContactClickListener;
import com.xabber.android.ui.adapter.AccountToggleAdapter;
import com.xabber.android.ui.dialog.AccountChooseDialogFragment; import com.xabber.android.ui.dialog.AccountChooseDialogFragment;
import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListener; import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListener;
import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment; import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment;
import com.xabber.android.ui.dialog.StartAtBootDialogFragment; import com.xabber.android.ui.dialog.StartAtBootDialogFragment;
import com.xabber.android.ui.helper.ContextMenuHelper;
import com.xabber.android.ui.helper.ManagedActivity; import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.uri.XMPPUri; import com.xabber.xmpp.uri.XMPPUri;
import java.util.ArrayList;
import java.util.Collection;
/** /**
* Main application activity. * Main application activity.
* *
* @author alexander.ivanov * @author alexander.ivanov
* *
*/ */
public class ContactList extends ManagedActivity implements public class ContactList extends ManagedActivity implements OnChoosedListener, OnContactClickListener {
OnAccountChangedListener, View.OnClickListener, OnLongClickListener,
OnChoosedListener, OnContactClickListener {
/** /**
* Select contact to be invited to the room was requested. * Select contact to be invited to the room was requested.
...@@ -106,11 +93,6 @@ public class ContactList extends ManagedActivity implements ...@@ -106,11 +93,6 @@ public class ContactList extends ManagedActivity implements
private static final String CONTACT_LIST_TAG = "CONTACT_LIST"; private static final String CONTACT_LIST_TAG = "CONTACT_LIST";
/**
* Adapter for account list.
*/
private AccountToggleAdapter accountToggleAdapter;
/** /**
* Current action. * Current action.
*/ */
...@@ -121,11 +103,6 @@ public class ContactList extends ManagedActivity implements ...@@ -121,11 +103,6 @@ public class ContactList extends ManagedActivity implements
*/ */
private String sendText; private String sendText;
/**
* Title view.
*/
private View titleView;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
if (Intent.ACTION_VIEW.equals(getIntent().getAction()) if (Intent.ACTION_VIEW.equals(getIntent().getAction())
...@@ -139,7 +116,6 @@ public class ContactList extends ManagedActivity implements ...@@ -139,7 +116,6 @@ public class ContactList extends ManagedActivity implements
return; return;
setContentView(R.layout.contact_list); setContentView(R.layout.contact_list);
titleView = findViewById(android.R.id.title);
FragmentTransaction fragmentTransaction = getSupportFragmentManager() FragmentTransaction fragmentTransaction = getSupportFragmentManager()
.beginTransaction(); .beginTransaction();
...@@ -147,28 +123,6 @@ public class ContactList extends ManagedActivity implements ...@@ -147,28 +123,6 @@ public class ContactList extends ManagedActivity implements
CONTACT_LIST_TAG); CONTACT_LIST_TAG);
fragmentTransaction.commit(); fragmentTransaction.commit();
accountToggleAdapter = new AccountToggleAdapter(this, this,
(LinearLayout) findViewById(R.id.account_list));
View commonStatusText = findViewById(R.id.common_status_text);
View commonStatusMode = findViewById(R.id.common_status_mode);
TypedArray typedArray = obtainStyledAttributes(R.styleable.ContactList);
ColorStateList textColorPrimary = typedArray
.getColorStateList(R.styleable.ContactList_textColorPrimaryNoSelected);
Drawable titleMainBackground = typedArray
.getDrawable(R.styleable.ContactList_titleMainBackground);
typedArray.recycle();
((TextView) commonStatusText).setTextColor(textColorPrimary);
titleView.setBackgroundDrawable(titleMainBackground);
commonStatusText.setOnLongClickListener(this);
commonStatusMode.setOnClickListener(this);
commonStatusText.setOnClickListener(this);
titleView.setOnClickListener(this);
findViewById(R.id.back_button).setOnClickListener(this);
if (savedInstanceState != null) { if (savedInstanceState != null) {
sendText = savedInstanceState.getString(SAVED_SEND_TEXT); sendText = savedInstanceState.getString(SAVED_SEND_TEXT);
action = savedInstanceState.getString(SAVED_ACTION); action = savedInstanceState.getString(SAVED_ACTION);
...@@ -254,18 +208,16 @@ public class ContactList extends ManagedActivity implements ...@@ -254,18 +208,16 @@ public class ContactList extends ManagedActivity implements
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
updateStatusBar(); switch (action) {
rebuildAccountToggler(); case ContactList.ACTION_ROOM_INVITE:
Application.getInstance().addUIListener(OnAccountChangedListener.class, case Intent.ACTION_SEND:
this); case Intent.ACTION_CREATE_SHORTCUT:
if (ContactList.ACTION_ROOM_INVITE.equals(action)
|| Intent.ACTION_SEND.equals(action)
|| Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
if (Intent.ACTION_SEND.equals(action)) if (Intent.ACTION_SEND.equals(action))
sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT); sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
Toast.makeText(this, getString(R.string.select_contact), Toast.makeText(this, getString(R.string.select_contact),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} else if (Intent.ACTION_VIEW.equals(action)) { break;
case Intent.ACTION_VIEW: {
action = null; action = null;
Uri data = getIntent().getData(); Uri data = getIntent().getData();
if (data != null && "xmpp".equals(data.getScheme())) { if (data != null && "xmpp".equals(data.getScheme())) {
...@@ -283,7 +235,9 @@ public class ContactList extends ManagedActivity implements ...@@ -283,7 +235,9 @@ public class ContactList extends ManagedActivity implements
openChat(xmppUri.getPath(), text); openChat(xmppUri.getPath(), text);
} }
} }
} else if (Intent.ACTION_SENDTO.equals(action)) { break;
}
case Intent.ACTION_SENDTO: {
action = null; action = null;
Uri data = getIntent().getData(); Uri data = getIntent().getData();
if (data != null) { if (data != null) {
...@@ -291,6 +245,8 @@ public class ContactList extends ManagedActivity implements ...@@ -291,6 +245,8 @@ public class ContactList extends ManagedActivity implements
if (path != null && path.startsWith("/")) if (path != null && path.startsWith("/"))
openChat(path.substring(1), null); openChat(path.substring(1), null);
} }
break;
}
} }
if (Application.getInstance().doNotify()) { if (Application.getInstance().doNotify()) {
if (SettingsManager.bootCount() > 2 if (SettingsManager.bootCount() > 2
...@@ -312,8 +268,6 @@ public class ContactList extends ManagedActivity implements ...@@ -312,8 +268,6 @@ public class ContactList extends ManagedActivity implements
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
Application.getInstance().removeUIListener(
OnAccountChangedListener.class, this);
} }
@Override @Override
...@@ -398,9 +352,6 @@ public class ContactList extends ManagedActivity implements ...@@ -398,9 +352,6 @@ public class ContactList extends ManagedActivity implements
public void onCreateContextMenu(ContextMenu menu, View view, public void onCreateContextMenu(ContextMenu menu, View view,
ContextMenuInfo menuInfo) { ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo); super.onCreateContextMenu(menu, view, menuInfo);
ContextMenuHelper.createAccountContextMenu(this,
getContactListFragment().getAdapter(),
accountToggleAdapter.getItemForView(view), menu);
} }
@Override @Override
...@@ -434,44 +385,6 @@ public class ContactList extends ManagedActivity implements ...@@ -434,44 +385,6 @@ public class ContactList extends ManagedActivity implements
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
} }
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.common_status_mode:
startActivity(StatusEditor.createIntent(this));
break;
case R.id.back_button: // Xabber icon button
case R.id.common_status_text:
case android.R.id.title:
getContactListFragment().scrollUp();
break;
default:
String account = accountToggleAdapter.getItemForView(view);
if (account == null) // Check for tap on account in the title
break;
if (!SettingsManager.contactsShowAccounts()) {
if (AccountManager.getInstance().getAccounts().size() < 2)
getContactListFragment().scrollUp();
else {
getContactListFragment().setSelectedAccount(account);
rebuildAccountToggler();
}
} else
getContactListFragment().scrollTo(account);
break;
}
}
@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) {
if (ACTION_ROOM_INVITE.equals(action)) { if (ACTION_ROOM_INVITE.equals(action)) {
...@@ -520,36 +433,11 @@ public class ContactList extends ManagedActivity implements ...@@ -520,36 +433,11 @@ public class ContactList extends ManagedActivity implements
} }
} }
@Override
public void onAccountsChanged(Collection<String> accounts) {
accountToggleAdapter.onChange();
}
@Override @Override
public void onChoosed(String account, String user, String text) { public void onChoosed(String account, String user, String text) {
openChat(new BaseEntity(account, user), text); openChat(new BaseEntity(account, user), text);
} }
private void updateStatusBar() {
String statusText = SettingsManager.statusText();
StatusMode statusMode = SettingsManager.statusMode();
if ("".equals(statusText))
statusText = getString(statusMode.getStringID());
((TextView) findViewById(R.id.common_status_text)).setText(statusText);
((ImageView) findViewById(R.id.common_status_mode))
.setImageLevel(statusMode.getStatusLevel());
}
private void rebuildAccountToggler() {
updateStatusBar();
accountToggleAdapter.rebuild();
if (SettingsManager.contactsShowPanel()
&& accountToggleAdapter.getCount() > 0)
titleView.setVisibility(View.VISIBLE);
else
titleView.setVisibility(View.GONE);
}
/** /**
* Show search dialog. * Show search dialog.
*/ */
......
...@@ -14,122 +14,9 @@ ...@@ -14,122 +14,9 @@
along with this program. If not, see http://www.gnu.org/licenses/. along with this program. If not, see http://www.gnu.org/licenses/.
--> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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"
android:background="@drawable/title_main_background_dark" >
<ImageButton
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:background="@drawable/title_logo"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/contact_list_status_mode_width"
android:layout_toRightOf="@id/back_button"
android:orientation="horizontal" >
<HorizontalScrollView
android:id="@+id/account_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="72dip" >
<LinearLayout
android:id="@+id/account_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!--
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/account_bg"
android:layout_width="42dip"
android:layout_height="44dip"
android:background="@drawable/account_bg">
<ImageView
android:id="@+id/avatar"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginTop="4dip"
android:layout_marginLeft="4dip"
android:src="@drawable/avatar_account_1"
/>
<ImageView
android:id="@+id/status_mode"
android:layout_width="42dip"
android:layout_height="44dip"
android:src="@drawable/ic_status_account"
android:background="@drawable/ic_status_connection_account"
/>
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/account_bg"
android:layout_width="42dip"
android:layout_height="44dip"
android:background="@drawable/account_bg">
<ImageView
android:id="@+id/avatar"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginTop="4dip"
android:layout_marginLeft="4dip"
android:src="@drawable/avatar_account_1"
/>
<ImageView
android:id="@+id/status_mode"
android:layout_width="42dip"
android:layout_height="44dip"
android:src="@drawable/ic_status_account"
android:background="@drawable/ic_status_connection_account"
/>
</RelativeLayout>
-->
</LinearLayout>
</HorizontalScrollView>
<TextView
android:id="@+id/common_status_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginLeft="-72dip"
android:gravity="left|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: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"
......
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