Commit 68bebc48 authored by Grigory Fedorov's avatar Grigory Fedorov

Navigation drawer: account list added.

parent 63404961
...@@ -65,6 +65,7 @@ import com.xabber.android.ui.dialog.StartAtBootDialogFragment; ...@@ -65,6 +65,7 @@ import com.xabber.android.ui.dialog.StartAtBootDialogFragment;
import com.xabber.android.ui.helper.BarPainter; import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedActivity; import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.preferences.AboutViewer; import com.xabber.android.ui.preferences.AboutViewer;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.android.ui.preferences.PreferenceEditor; import com.xabber.android.ui.preferences.PreferenceEditor;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
...@@ -593,4 +594,10 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList ...@@ -593,4 +594,10 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
} }
} }
@Override
public void onAccountSelected(String account) {
drawerLayout.closeDrawers();
startActivity(AccountEditor.createIntent(this, account));
}
} }
...@@ -2,36 +2,67 @@ package com.xabber.android.ui; ...@@ -2,36 +2,67 @@ package com.xabber.android.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.ui.adapter.AccountListAdapter;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
public class ContactListDrawerFragment extends Fragment implements View.OnClickListener { import java.util.Collection;
public class ContactListDrawerFragment extends Fragment implements View.OnClickListener, OnAccountChangedListener, AdapterView.OnItemClickListener {
ContactListDrawerListener listener; ContactListDrawerListener listener;
private AccountListAdapter adapter;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
listener = (ContactListDrawerListener) activity;
}
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.contact_list_drawer, container, false); View view = inflater.inflate(R.layout.contact_list_drawer, container, false);
view.findViewById(R.id.drawer_action_settings).setOnClickListener(this);
view.findViewById(R.id.drawer_action_about).setOnClickListener(this); ListView listView = (ListView) view.findViewById(R.id.drawer_account_list);
view.findViewById(R.id.drawer_action_exit).setOnClickListener(this); adapter = new AccountListAdapter(getActivity());
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
View footerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.contact_list_drawer_footer, null, false);
listView.addFooterView(footerView);
footerView.findViewById(R.id.drawer_action_settings).setOnClickListener(this);
footerView.findViewById(R.id.drawer_action_about).setOnClickListener(this);
footerView.findViewById(R.id.drawer_action_exit).setOnClickListener(this);
return view; return view;
} }
@Override
public void onResume() {
super.onResume();
Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
adapter.onChange();
}
@Override @Override
public void onAttach(Activity activity) { public void onPause() {
super.onAttach(activity); super.onPause();
listener = (ContactListDrawerListener) activity; Application.getInstance().removeUIListener(OnAccountChangedListener.class, this);
} }
@Override @Override
...@@ -43,10 +74,21 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -43,10 +74,21 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
@Override @Override
public void onClick(View v) { public void onClick(View v) {
listener.onContactListDrawerListener(v.getId()); listener.onContactListDrawerListener(v.getId());
}
@Override
public void onAccountsChanged(Collection<String> accounts) {
adapter.onChange();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
listener.onAccountSelected(adapter.getItem(position));
} }
interface ContactListDrawerListener { interface ContactListDrawerListener {
void onContactListDrawerListener(int viewId); void onContactListDrawerListener(int viewId);
void onAccountSelected(String account);
} }
} }
...@@ -16,7 +16,7 @@ package com.xabber.android.ui.helper; ...@@ -16,7 +16,7 @@ package com.xabber.android.ui.helper;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.AppCompatActivity;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
...@@ -29,7 +29,7 @@ import com.xabber.android.data.ActivityManager; ...@@ -29,7 +29,7 @@ import com.xabber.android.data.ActivityManager;
* *
* @author alexander.ivanov * @author alexander.ivanov
*/ */
public abstract class ManagedListActivity extends ActionBarActivity { public abstract class ManagedListActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
......
...@@ -20,87 +20,8 @@ ...@@ -20,87 +20,8 @@
</RelativeLayout> </RelativeLayout>
<LinearLayout <ListView
android:id="@+id/drawer_account_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content" />
android:orientation="vertical">
<LinearLayout
android:id="@+id/drawer_action_settings"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/drawer_touch"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_settings_grey600_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:text="@string/preference_editor"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_action_about"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/drawer_touch"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_help_circle_grey600_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:text="@string/preference_about"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black" />
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_action_exit"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/drawer_touch"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_exit_grey600_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:text="@string/exit"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/drawer_action_settings"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/drawer_touch"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_settings_grey600_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:text="@string/preference_editor"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_action_about"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/drawer_touch"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_help_circle_grey600_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:text="@string/preference_about"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black" />
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_action_exit"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/drawer_touch"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_exit_grey600_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:text="@string/exit"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black" />
</LinearLayout>
</LinearLayout>
\ 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