diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/BufferViewConfigSpinnerAdapter.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/BufferViewConfigSpinnerAdapter.java index 7a1eda952e94e793b5b3f9eebb4f737fdd3bee2e..1a2dad4dee4a1a4dedeba06d46ba1b36b16e2a07 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/BufferViewConfigSpinnerAdapter.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/BufferViewConfigSpinnerAdapter.java @@ -36,6 +36,7 @@ import java.util.Set; import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig; import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewManager; +import de.kuschku.quasseldroid_ng.R; import de.kuschku.quasseldroid_ng.ui.theme.AppContext; public class BufferViewConfigSpinnerAdapter implements ThemedSpinnerAdapter { @@ -65,7 +66,7 @@ public class BufferViewConfigSpinnerAdapter implements ThemedSpinnerAdapter { @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(new ContextThemeWrapper(parent.getContext(), theme)); - TextView view = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, parent, false); + TextView view = (TextView) inflater.inflate(R.layout.widget_md_spinner_item, parent, false); view.setText(((QBufferViewConfig) getItem(position)).bufferViewName()); return view; } @@ -102,8 +103,8 @@ public class BufferViewConfigSpinnerAdapter implements ThemedSpinnerAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { - LayoutInflater inflater = LayoutInflater.from(new ContextThemeWrapper(parent.getContext(), theme)); - TextView view = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, parent, false); + LayoutInflater inflater = LayoutInflater.from(parent.getContext()); + TextView view = (TextView) inflater.inflate(R.layout.widget_md_spinner_item, parent, false); view.setText(((QBufferViewConfig) getItem(position)).bufferViewName()); return view; } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java index 4295df4a8d39fa2e1378fa7f0662b9a5ff60795b..fb0caa1bfcef10a0938d67e1a65b1d590b303294 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java @@ -138,10 +138,13 @@ public class MainActivity extends BoundActivity { drawerLayout.closeDrawer(GravityCompat.START); } }); + chatListAdapter.setRecyclerView(chatList); chatList.setItemAnimator(new DefaultItemAnimator()); chatList.setLayoutManager(new LinearLayoutManager(this)); chatList.setAdapter(chatListAdapter); + chatListToolbar.inflateMenu(R.menu.chatlist); + DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawerLayout != null) { ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.material_drawer_open, R.string.material_drawer_close); @@ -317,14 +320,13 @@ public class MainActivity extends BoundActivity { if (thread == null) connectToServer(manager.account(context.settings().lastAccount.get())); else { - if (context.client() != null) { + if (context.client() != null && context.client().connectionStatus() == ConnectionChangeEvent.Status.CONNECTED) { onConnected(); } } } private void onConnected() { - context.client().backlogManager().init("", context.provider(), context.client()); context.client().backlogManager().open(status.bufferId); if (context.client().bufferViewManager() != null) { chatListSpinner.setAdapter(new BufferViewConfigSpinnerAdapter(context, context.client().bufferViewManager())); diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewConfigAdapter.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewConfigAdapter.java index 2d1983fa4f69b2087a27c0749ff478e408eaa80f..507f53d345d74b42560534c49e366f22fe1c7b8b 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewConfigAdapter.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewConfigAdapter.java @@ -21,6 +21,8 @@ package de.kuschku.quasseldroid_ng.ui.chat.drawer; +import android.os.Parcelable; +import android.support.annotation.Nullable; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -180,14 +182,7 @@ public class BufferViewConfigAdapter extends ExpandableRecyclerAdapter<NetworkVi public void selectConfig(int id) { QBufferViewConfig newconfig = context.client().bufferViewManager().bufferViewConfig(id); - int firstVisible = -1; - if (newconfig == config) { - RecyclerView list = recyclerView.get(); - if (list != null) { - LinearLayoutManager layoutManager = (LinearLayoutManager) list.getLayoutManager(); - firstVisible = layoutManager.findFirstVisibleItemPosition(); - } - } + Parcelable state = (newconfig == config) ? saveState() : null; if (config != null) config.networkList().removeCallback(callback); @@ -201,15 +196,31 @@ public class BufferViewConfigAdapter extends ExpandableRecyclerAdapter<NetworkVi items.add(networkItem); } config.networkList().addCallback(callback); - if (firstVisible != -1) { + + loadState(state); + } + + private void loadState(@Nullable Parcelable state) { + if (state != null) { RecyclerView list = recyclerView.get(); if (list != null) { LinearLayoutManager layoutManager = (LinearLayoutManager) list.getLayoutManager(); - layoutManager.scrollToPosition(firstVisible); + layoutManager.onRestoreInstanceState(state); } } } + @Nullable + private Parcelable saveState() { + RecyclerView list = recyclerView.get(); + if (list != null) { + LinearLayoutManager layoutManager = (LinearLayoutManager) list.getLayoutManager(); + return layoutManager.onSaveInstanceState(); + } else { + return null; + } + } + public void setSelection(int from, int to) { } diff --git a/app/src/main/res/drawable-hdpi/ic_plus_dark.png b/app/src/main/res/drawable-hdpi/ic_plus_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..e5565772a094e4554dde22234f3831e96fd08d34 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_plus_dark.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_plus_dark.png b/app/src/main/res/drawable-mdpi/ic_plus_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..36a5b40fcfb623a5984401c29614b32b0bc7f374 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_plus_dark.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_plus_dark.png b/app/src/main/res/drawable-xhdpi/ic_plus_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..265017dceb955b9ac5d463e48d4487d7377536bc Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_plus_dark.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_plus_dark.png b/app/src/main/res/drawable-xxhdpi/ic_plus_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..567bbf6b823afa49119054e3e75cec0307d553cb Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_plus_dark.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_plus_dark.png b/app/src/main/res/drawable-xxxhdpi/ic_plus_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..5213a1faefba04c467a0c8b71c2a1bc9d0350237 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_plus_dark.png differ diff --git a/app/src/main/res/layout-w720dp/activity_main.xml b/app/src/main/res/layout-w720dp/activity_main.xml index 5f40523c267512a38a26c1780d00eac7b5eb49ae..e4836f906c1f346b364f40ae7a71c951d809a35d 100644 --- a/app/src/main/res/layout-w720dp/activity_main.xml +++ b/app/src/main/res/layout-w720dp/activity_main.xml @@ -52,7 +52,9 @@ <android.support.v7.widget.AppCompatSpinner android:id="@+id/chatListSpinner" android:layout_width="fill_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:theme="@style/AppTheme.AppBarOverlay" + app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.v7.widget.Toolbar> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6d611690792936f7c2888ec21c7a1d23557b37ab..cd3cc62ad6aa1446c637b79c9deade0ab8509d20 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -71,7 +71,9 @@ <android.support.v7.widget.AppCompatSpinner android:id="@+id/chatListSpinner" android:layout_width="fill_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:theme="@style/AppTheme.AppBarOverlay" + app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.v7.widget.Toolbar> diff --git a/app/src/main/res/layout/widget_md_spinner_item.xml b/app/src/main/res/layout/widget_md_spinner_item.xml new file mode 100644 index 0000000000000000000000000000000000000000..0a057aeeff8997648b3a0d42564f46b19d11b87d --- /dev/null +++ b/app/src/main/res/layout/widget_md_spinner_item.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + ~ QuasselDroid - Quassel client for Android + ~ Copyright (C) 2016 Janne Koschinski + ~ Copyright (C) 2016 Ken Børge Viktil + ~ Copyright (C) 2016 Magnus Fjell + ~ Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + ~ + ~ This program is free software: you can redistribute it and/or modify it + ~ under the terms of the GNU General Public License as published by the Free + ~ Software Foundation, either version 3 of the License, or (at your option) + ~ any later version. + ~ + ~ This program 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/>. + --> + +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:minHeight="?attr/actionBarSize" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:textAppearance="?android:attr/textAppearanceListItemSmall" /> diff --git a/app/src/main/res/menu/chat.xml b/app/src/main/res/menu/chat.xml index 5b232764cb900c0d3df9db7793606baabdd2a9ae..026d4bd0e9976088ded942b7fab34c18cfd03dec 100644 --- a/app/src/main/res/menu/chat.xml +++ b/app/src/main/res/menu/chat.xml @@ -22,14 +22,17 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> - <item - android:id="@+id/action_reauth" - android:title="Reauth" - app:showAsAction="ifRoom" /> <item android:id="@+id/action_hide_events" android:icon="@drawable/ic_filter_dark" - android:orderInCategory="100" android:title="@string/labelHideEvents" app:showAsAction="ifRoom" /> + <item + android:id="@+id/action_settings" + android:title="Settings" + app:showAsAction="never" /> + <item + android:id="@+id/action_reauth" + android:title="Disconnect" + app:showAsAction="never" /> </menu> diff --git a/app/src/main/res/menu/chatlist.xml b/app/src/main/res/menu/chatlist.xml new file mode 100644 index 0000000000000000000000000000000000000000..6011afc639036bcd5b085e7c89822d0c69224ce0 --- /dev/null +++ b/app/src/main/res/menu/chatlist.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + ~ QuasselDroid - Quassel client for Android + ~ Copyright (C) 2016 Janne Koschinski + ~ Copyright (C) 2016 Ken Børge Viktil + ~ Copyright (C) 2016 Magnus Fjell + ~ Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + ~ + ~ This program is free software: you can redistribute it and/or modify it + ~ under the terms of the GNU General Public License as published by the Free + ~ Software Foundation, either version 3 of the License, or (at your option) + ~ any later version. + ~ + ~ This program 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/>. + --> + +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + <item + android:icon="@drawable/ic_plus_dark" + android:title="Join Channel" + app:showAsAction="ifRoom" /> + <item + android:title="Show/Hide Hidden" + app:showAsAction="never" /> + <item + android:title="Manage Chat Lists" + app:showAsAction="never" /> +</menu> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 89b556f2f4292e2683e162d1d50b57d2a82cdc6f..2cf6d8c07d9d4be643f0c3467ee0a83ffe595e44 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -91,6 +91,7 @@ <attr name="iconFilter" format="reference" /> <attr name="iconDelete" format="reference" /> <attr name="iconModify" format="reference" /> + <attr name="iconAdd" format="reference" /> <attr name="cardStyle" format="reference" /> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 2af2ed3c4942cff454044c7c12f627da9a620298..c516e4a73632f90e9ef3d80237582b672ae733ee 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -48,6 +48,7 @@ <item name="iconFilter">@drawable/ic_filter_dark</item> <item name="iconModify">@drawable/ic_pencil_dark</item> <item name="iconDelete">@drawable/ic_delete_dark</item> + <item name="iconAdd">@drawable/ic_plus_dark</item> <item name="cardStyle">@style/CardView.Dark</item> </style> @@ -76,6 +77,7 @@ <item name="iconFilter">@drawable/ic_filter_light</item> <item name="iconModify">@drawable/ic_pencil_light</item> <item name="iconDelete">@drawable/ic_delete_light</item> + <item name="iconAdd">@drawable/ic_plus_light</item> <item name="cardStyle">@style/CardView.Light</item> </style> @@ -97,5 +99,5 @@ <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> - <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark" /> + <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> </resources>