Skip to content
Snippets Groups Projects
Commit 0ecafb9c authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixed the drawer issues

parent 180a85ed
No related branches found
No related tags found
No related merge requests found
Showing
with 111 additions and 23 deletions
......@@ -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;
}
......
......@@ -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()));
......
......@@ -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,13 +196,29 @@ 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) {
......
app/src/main/res/drawable-hdpi/ic_plus_dark.png

253 B

app/src/main/res/drawable-mdpi/ic_plus_dark.png

171 B

app/src/main/res/drawable-xhdpi/ic_plus_dark.png

209 B

app/src/main/res/drawable-xxhdpi/ic_plus_dark.png

268 B

app/src/main/res/drawable-xxxhdpi/ic_plus_dark.png

313 B

......@@ -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>
......
......@@ -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>
......
<?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" />
......@@ -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>
<?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>
......@@ -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>
......@@ -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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment