Commit c77acef0 authored by Grigory Fedorov's avatar Grigory Fedorov

First very unstable implementation of tablet design.

parent 69ae3543
......@@ -34,7 +34,6 @@ import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.message.OnChatChangedListener;
import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.ui.helper.ChatScroller;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.StatusBarPainter;
/**
......@@ -43,7 +42,7 @@ import com.xabber.android.ui.helper.StatusBarPainter;
*
* @author alexander.ivanov
*/
public class ChatViewer extends ManagedActivity implements ChatScroller.ChatScrollerListener, ChatScroller.ChatScrollerProvider {
public class ChatViewer extends MainBasicActivity implements ChatScroller.ChatScrollerListener, ChatScroller.ChatScrollerProvider {
/**
* Attention request.
......@@ -150,6 +149,11 @@ public class ChatViewer extends ManagedActivity implements ChatScroller.ChatScro
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (findViewById(R.id.chat_container) != null) {
finish();
return;
}
if (isFinishing()) {
return;
}
......@@ -302,7 +306,7 @@ public class ChatViewer extends ManagedActivity implements ChatScroller.ChatScro
}
@Override
public void onAccountSelected(String account) {
public void onStatusBarNeedPaint(String account) {
if (account == null) {
statusBarPainter.updateWithDefaultColor();
} else {
......
......@@ -27,9 +27,8 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Gravity;
......@@ -37,6 +36,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.SearchView;
import android.widget.Toast;
......@@ -64,10 +64,7 @@ import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListene
import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment;
import com.xabber.android.ui.dialog.StartAtBootDialogFragment;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
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.helper.ChatScroller;
import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.uri.XMPPUri;
......@@ -79,8 +76,9 @@ import java.util.Collection;
*
* @author alexander.ivanov
*/
public class ContactList extends ManagedActivity implements OnAccountChangedListener,
View.OnClickListener, OnChoosedListener, OnContactClickListener, ContactListDrawerFragment.ContactListDrawerListener {
public class ContactList extends MainBasicActivity implements OnAccountChangedListener,
View.OnClickListener, OnChoosedListener, OnContactClickListener, ChatScroller.ChatScrollerListener,
ChatScroller.ChatScrollerProvider {
/**
* Select contact to be invited to the room was requested.
......@@ -108,8 +106,9 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
private SearchView searchView;
private BarPainter barPainter;
private ActionBarDrawerToggle drawerToggle;
private DrawerLayout drawerLayout;
private boolean isDualPanelView;
private ChatScroller chatScroller;
public static Intent createPersistentIntent(Context context) {
Intent intent = new Intent(context, ContactList.class);
......@@ -152,12 +151,19 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
return;
}
setContentView(R.layout.contact_list);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
isDualPanelView = findViewById(R.id.chat_container) != null;
if (isDualPanelView) {
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
LinearLayout chatScrollIndicatorLayout = (LinearLayout) findViewById(R.id.chat_scroll_indicator);
chatScroller = new ChatScroller(this, viewPager, chatScrollIndicatorLayout);
chatScroller.initChats(null);
}
toolbar.setOnClickListener(this);
setSupportActionBar(toolbar);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.application_title_short, R.string.application_title_short);
drawerLayout.setDrawerListener(drawerToggle);
......@@ -324,6 +330,10 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
}
}
}
if (isDualPanelView) {
chatScroller.update();
}
}
@Override
......@@ -445,7 +455,8 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
super.onBackPressed();
}
private void exit() {
@Override
protected void exit() {
Application.getInstance().requestToClose();
showDialog(DIALOG_CLOSE_APPLICATION_ID);
getContactListFragment().unregisterListeners();
......@@ -508,9 +519,14 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
@Override
public void onContactClick(AbstractContact abstractContact) {
if (action == null) {
startActivity(ChatViewer.createSpecificChatIntent(this,
abstractContact.getAccount(), abstractContact.getUser()));
return;
if (isDualPanelView) {
chatScroller.setSelectedChat(abstractContact);
chatScroller.update();
} else {
startActivity(ChatViewer.createSpecificChatIntent(this,
abstractContact.getAccount(), abstractContact.getUser()));
return;
}
}
switch (action) {
case ACTION_ROOM_INVITE: {
......@@ -540,8 +556,15 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
break;
}
default:
startActivity(ChatViewer.createSpecificChatIntent(this,
abstractContact.getAccount(), abstractContact.getUser()));
if (isDualPanelView) {
chatScroller.initChats(abstractContact);
chatScroller.setSelectedChat(abstractContact);
chatScroller.update();
} else {
startActivity(ChatViewer.createSpecificChatIntent(this,
abstractContact.getAccount(), abstractContact.getUser()));
return;
}
break;
}
}
......@@ -579,25 +602,17 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
}
@Override
public void onContactListDrawerListener(int viewId) {
drawerLayout.closeDrawers();
switch (viewId) {
case R.id.drawer_action_settings:
startActivity(PreferenceEditor.createIntent(this));
break;
case R.id.drawer_action_about:
startActivity(AboutViewer.createIntent(this));
break;
case R.id.drawer_action_exit:
exit();
break;
public void onStatusBarNeedPaint(String account) {
}
@Override
public void onClose() {
}
}
@Override
public void onAccountSelected(String account) {
drawerLayout.closeDrawers();
startActivity(AccountEditor.createIntent(this, account));
public ChatScroller getChatScroller() {
return chatScroller;
}
}
package com.xabber.android.ui;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import com.xabber.android.R;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.preferences.AboutViewer;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.android.ui.preferences.PreferenceEditor;
public class MainBasicActivity extends ManagedActivity implements ContactListDrawerFragment.ContactListDrawerListener {
protected ActionBarDrawerToggle drawerToggle;
protected DrawerLayout drawerLayout;
protected Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contact_list);
toolbar = (Toolbar) findViewById(R.id.toolbar_default);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
}
@Override
public void onContactListDrawerListener(int viewId) {
drawerLayout.closeDrawers();
switch (viewId) {
case R.id.drawer_action_settings:
startActivity(PreferenceEditor.createIntent(this));
break;
case R.id.drawer_action_about:
startActivity(AboutViewer.createIntent(this));
break;
case R.id.drawer_action_exit:
exit();
break;
}
}
protected void exit() {
}
@Override
public void onAccountSelected(String account) {
drawerLayout.closeDrawers();
startActivity(AccountEditor.createIntent(this, account));
}
}
......@@ -65,7 +65,7 @@ public class RecentChatFragment extends ListFragment implements Toolbar.OnMenuIt
if (getListAdapter().isEmpty()) {
Activity activity = getActivity();
Toast.makeText(activity, R.string.chat_list_is_empty, Toast.LENGTH_LONG).show();
activity.finish();
// activity.finish();
}
Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar_default);
......@@ -89,15 +89,18 @@ public class RecentChatFragment extends ListFragment implements Toolbar.OnMenuIt
@Override
public void onResume() {
super.onResume();
listener.getChatScroller().registerRecentChatsList(this);
if (null != listener.getChatScroller()) {
listener.getChatScroller().registerRecentChatsList(this);
}
}
@Override
public void onPause() {
super.onPause();
listener.getChatScroller().unregisterRecentChatsList(this);
if (null != listener.getChatScroller()) {
listener.getChatScroller().unregisterRecentChatsList(this);
}
}
@Override
......@@ -111,7 +114,7 @@ public class RecentChatFragment extends ListFragment implements Toolbar.OnMenuIt
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
if (null != listener) {
if (null != listener.getChatScroller()) {
listener.getChatScroller().onChatSelected((AbstractChat) getListAdapter().getItem(position));
}
}
......@@ -126,7 +129,9 @@ public class RecentChatFragment extends ListFragment implements Toolbar.OnMenuIt
}
public void updateChats() {
((ChatListAdapter) getListAdapter()).updateChats(listener.getChatScroller().getActiveChats());
if (listener.getChatScroller() != null) {
((ChatListAdapter) getListAdapter()).updateChats(listener.getChatScroller().getActiveChats());
}
}
public interface RecentChatFragmentInteractionListener {
......
......@@ -141,9 +141,9 @@ public class ChatScroller implements
private void updateStatusBar() {
if (isRecentChatsSelected) {
listener.onAccountSelected(null);
listener.onStatusBarNeedPaint(null);
} else {
listener.onAccountSelected(selectedChat.getAccount());
listener.onStatusBarNeedPaint(selectedChat.getAccount());
}
}
......@@ -307,7 +307,7 @@ public class ChatScroller implements
}
public interface ChatScrollerListener {
void onAccountSelected(String account);
void onStatusBarNeedPaint(String account);
void onClose();
}
......
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber 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/.
-->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_default"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleTextAppearance="@style/ToolbarTitle" />
<!-- Main layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="8dp" />
<FrameLayout
android:id="@+id/chat_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:padding="8dp">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/chat_scroll_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="80dp"
android:orientation="horizontal" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
<!-- Nav drawer -->
<fragment
android:id="@+id/fragment_drawer"
android:name="com.xabber.android.ui.ContactListDrawerFragment"
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="left|start" />
</android.support.v4.widget.DrawerLayout>
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