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

Fixed several issues:

- Fixed an issue where backlog for some buffers could not be loaded
- Fixed an issue where chat list filters didn’t work properly
parent fd41061f
Branches
Tags
No related merge requests found
Showing
with 116 additions and 102 deletions
......@@ -148,10 +148,9 @@ dependencies {
// UI Libs
compile 'com.bignerdranch.android:expandablerecyclerview:2.0.4'
compile 'com.fnp:material-preferences:0.1.4'
compile 'com.pavelsikun:material-seekbar-preference:0.12.1+'
compile(name:'library-release', ext:'aar')
compile('com.mikepenz:materialdrawer:5.0.0.b27-SNAPSHOT@aar') { transitive = true }
// This dependency can be removed as soon as the requires ressources are copied over.
compile('com.mikepenz:materialdrawer:5.0.3@aar') { transitive = true }
compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') { transitive = true }
compile('com.github.afollestad.material-dialogs:commons:0.8.5.3@aar') { transitive = true }
......
......@@ -42,13 +42,13 @@ public class Message implements ContentComparable<Message> {
public final Flags flags;
@NonNull
public final BufferInfo bufferInfo;
@NonNull
@Nullable
public final String sender;
@NonNull
@Nullable
public final String content;
public Message(int messageId, @NonNull DateTime time, @NonNull Type type, @NonNull Flags flags, @NonNull BufferInfo bufferInfo, @NonNull String sender,
@NonNull String content) {
public Message(int messageId, @NonNull DateTime time, @NonNull Type type, @NonNull Flags flags, @NonNull BufferInfo bufferInfo, @Nullable String sender,
@Nullable String content) {
this.messageId = messageId;
this.time = time;
this.type = type;
......@@ -73,7 +73,7 @@ public class Message implements ContentComparable<Message> {
}
@Override
public boolean areContentsTheSame(@NonNull Message message) {
public boolean areContentsTheSame(@Nullable Message message) {
return this == message;
}
......
......@@ -33,8 +33,6 @@ import java.nio.channels.ByteChannel;
import de.kuschku.libquassel.message.Message;
import de.kuschku.libquassel.primitives.types.BufferInfo;
import static de.kuschku.util.AndroidAssert.assertNotNull;
public class MessageSerializer implements PrimitiveSerializer<Message> {
@NonNull
private static final MessageSerializer serializer = new MessageSerializer();
......@@ -69,8 +67,6 @@ public class MessageSerializer implements PrimitiveSerializer<Message> {
String sender = ByteArraySerializer.get().deserialize(buffer);
String message = ByteArraySerializer.get().deserialize(buffer);
assertNotNull(sender);
assertNotNull(message);
return new Message(
messageId,
time,
......
......@@ -132,7 +132,7 @@ public class BacklogManager extends ABacklogManager<BacklogManager> {
provider.sendEvent(new BacklogReceivedEvent(id));
if (id == openBuffer && openBuffer != -1)
client.bufferSyncer().requestMarkBufferAsRead(openBuffer);
waiting.remove(id);
removeWaiting(id);
initialized.add(id);
}
checkWaiting();
......
......@@ -23,7 +23,6 @@ package de.kuschku.libquassel.syncables.types.impl;
import android.databinding.ObservableInt;
import android.support.annotation.NonNull;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseIntArray;
......@@ -236,7 +235,6 @@ public class BufferSyncer extends ABufferSyncer<BufferSyncer> {
int lastSeenMsg = lastSeenMsg(message.bufferInfo.id());
if (message.messageId > lastSeenMsg) {
addActivity(message.bufferInfo.id(), message.type);
Log.d("libquassel", "Unread: " + lastSeenMsg + "/" + message);
}
}
}
......@@ -29,6 +29,7 @@ import java.util.Map;
import de.kuschku.libquassel.BusProvider;
import de.kuschku.libquassel.client.Client;
import de.kuschku.libquassel.localtypes.buffers.Buffer;
import de.kuschku.libquassel.primitives.types.QVariant;
import de.kuschku.libquassel.syncables.serializers.BufferViewConfigSerializer;
import de.kuschku.libquassel.syncables.types.abstracts.ABufferViewConfig;
......@@ -137,6 +138,24 @@ public class BufferViewConfig extends ABufferViewConfig<BufferViewConfig> {
}
}
@Override
public DisplayType mayDisplay(Buffer buffer) {
if (buffer != null &&
(allowedBufferTypes == 0 || (0 != (buffer.getInfo().type().id & allowedBufferTypes()))) &&
(networkId == 0 || (networkId == buffer.getInfo().networkId()))
) {
int bufferid = buffer.getInfo().id();
if (bufferIds.contains(bufferid) && !temporarilyRemovedBuffers.contains(bufferid) && !removedBuffers.contains(bufferid))
return DisplayType.ALWAYS;
else if (temporarilyRemovedBuffers.contains(bufferid) && !removedBuffers.contains(bufferid))
return DisplayType.TEMP_HIDDEN;
else
return DisplayType.PERM_HIDDEN;
} else {
return DisplayType.NONE;
}
}
@Override
public boolean addNewBuffersAutomatically() {
return addNewBuffersAutomatically;
......
......@@ -23,6 +23,7 @@ package de.kuschku.libquassel.syncables.types.interfaces;
import android.support.annotation.NonNull;
import de.kuschku.libquassel.localtypes.buffers.Buffer;
import de.kuschku.libquassel.syncables.Synced;
import de.kuschku.util.observables.lists.ObservableList;
import de.kuschku.util.observables.lists.ObservableSet;
......@@ -156,4 +157,13 @@ public interface QBufferViewConfig extends QObservable {
ObservableSet<QNetwork> networkList();
void updateNetworks();
DisplayType mayDisplay(Buffer buffer);
enum DisplayType {
NONE,
ALWAYS,
TEMP_HIDDEN,
PERM_HIDDEN
}
}
......@@ -28,7 +28,6 @@ import android.support.v7.app.AppCompatActivity;
import de.kuschku.quasseldroid_ng.ui.chat.MainActivity;
import de.kuschku.quasseldroid_ng.ui.chat.util.ServiceHelper;
import de.kuschku.quasseldroid_ng.ui.settings.Settings;
import de.kuschku.quasseldroid_ng.ui.setup.AccountSelectActivity;
import de.kuschku.quasseldroid_ng.ui.theme.AppContext;
......@@ -41,8 +40,7 @@ public class LoginActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ServiceHelper.initTheme(context, this);
context.withSettings(new Settings(this));
ServiceHelper.initContext(context, this);
}
@Override
......
......@@ -74,14 +74,14 @@ public class NetworkItem implements ParentListItem {
this.network = network;
for (int id : config.bufferList()) {
Buffer buffer = context.client().bufferManager().buffer(id);
if (buffer != null && buffer.getInfo().networkId() == network.networkId())
if (context.bufferDisplayTypes().contains(config.mayDisplay(buffer)) && buffer.getInfo().networkId() == network.networkId())
buffers.add(buffer);
}
config.bufferIds().addCallback(new ElementCallback<Integer>() {
@Override
public void notifyItemInserted(Integer id) {
Buffer buffer = context.client().bufferManager().buffer(id);
if (buffer != null && buffer.getInfo().networkId() == network.networkId())
if (context.bufferDisplayTypes().contains(config.mayDisplay(buffer)) && buffer.getInfo().networkId() == network.networkId())
buffers.add(buffer);
}
......
......@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig;
import de.kuschku.quasseldroid_ng.service.QuasselService;
import de.kuschku.quasseldroid_ng.ui.settings.Settings;
import de.kuschku.quasseldroid_ng.ui.theme.AppContext;
......@@ -64,12 +65,15 @@ public class ServiceHelper {
context.startService(intent);
}
public static int initContext(AppContext context, Activity activity) {
context.setSettings(new Settings(activity));
context.bufferDisplayTypes().add(QBufferViewConfig.DisplayType.ALWAYS);
return initTheme(context, activity);
}
public static int initTheme(AppContext context, Activity activity) {
// Init SharedPreferences
Settings settings = new Settings(activity);
context.setSettings(settings);
// Load Theme from Preferences
AppTheme theme = AppTheme.themeFromString(settings.preferenceTheme.get());
AppTheme theme = AppTheme.themeFromString(context.settings().preferenceTheme.get());
activity.setTheme(theme.themeId);
context.setThemeUtil(new ThemeUtil(activity, theme));
return theme.themeId;
......
......@@ -45,7 +45,7 @@ public class SettingsActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
themeid = ServiceHelper.initTheme(context, this);
themeid = ServiceHelper.initContext(context, this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ButterKnife.bind(this);
......@@ -87,7 +87,7 @@ public class SettingsActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
ServiceHelper.initTheme(context, getActivity());
ServiceHelper.initContext(context, getActivity());
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_appearance);
}
......
......@@ -23,8 +23,12 @@ package de.kuschku.quasseldroid_ng.ui.theme;
import android.support.annotation.NonNull;
import java.util.HashSet;
import java.util.Set;
import de.kuschku.libquassel.BusProvider;
import de.kuschku.libquassel.client.Client;
import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig;
import de.kuschku.quasseldroid_ng.ui.settings.Settings;
import de.kuschku.util.irc.format.IrcFormatDeserializer;
import de.kuschku.util.irc.format.IrcFormatSerializer;
......@@ -36,6 +40,8 @@ public class AppContext {
private BusProvider provider;
private IrcFormatDeserializer deserializer;
private IrcFormatSerializer serializer;
private QBufferViewConfig.DisplayType bufferDisplayType;
private Set<QBufferViewConfig.DisplayType> bufferDisplayTypes = new HashSet<>();
public ThemeUtil themeUtil() {
return themeUtil;
......@@ -103,4 +109,8 @@ public class AppContext {
public IrcFormatSerializer serializer() {
return serializer;
}
public Set<QBufferViewConfig.DisplayType> bufferDisplayTypes() {
return bufferDisplayTypes;
}
}
......@@ -24,31 +24,34 @@ package de.kuschku.util.niohelpers;
import android.support.annotation.NonNull;
import android.util.Log;
import java.util.LinkedList;
import java.util.List;
public class Helper {
// Making default constructor invisible
private Helper() {
}
public static void printHexDump(@NonNull byte[] data) {
Log.e("HexDump", "Hexdump following: ");
public static void printHexDump(String prefix, @NonNull byte[] data) {
List<String> strs = new LinkedList<>();
Log.e("HexDump" + prefix, "========");
String bytes = "";
String text = "";
int i;
for (i = 0; i < data.length; i++) {
bytes += String.format("%02x ", data[i]);
text += encodeChar(data[1]);
if (i > 0 && (i + 1) % 8 == 0) {
Log.e("HexDump", String.format("%08x ", i - 7) + bytes + text);
if (i > 0 && (i + 1) % 32 == 0) {
strs.add(bytes);
bytes = "";
text = "";
}
}
Log.e("HexDump", String.format("%08x ", i - 7) + bytes + text);
strs.add(bytes);
for (int j = 0; j < strs.size(); j++) {
Log.e("HexDump" + prefix + ":" + j, strs.get(j));
}
}
private static char encodeChar(byte data) {
if (data < 127 && data > 32) return (char) data;
else return '.';
public static void printHexDump(@NonNull byte[] data) {
printHexDump("", data);
}
}
......@@ -21,8 +21,10 @@
package de.kuschku.util.observables;
import android.support.annotation.NonNull;
public interface ContentComparable<T extends ContentComparable<T>> extends Comparable<T> {
boolean areItemsTheSame(T other);
boolean areItemsTheSame(@NonNull T other);
boolean areContentsTheSame(T other);
boolean areContentsTheSame(@NonNull T other);
}
......@@ -61,7 +61,7 @@ public abstract class BoundActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
themeId = ServiceHelper.initTheme(context, this);
themeId = ServiceHelper.initContext(context, this);
super.onCreate(savedInstanceState);
context.settings().preferenceTheme.addChangeListener(s -> recreate());
ServiceHelper.startServiceIfNotRunning(this);
......
......@@ -57,7 +57,7 @@ public abstract class BoundFragment extends Fragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
ServiceHelper.initTheme(context, getActivity());
ServiceHelper.initContext(context, getActivity());
super.onCreate(savedInstanceState);
ServiceHelper.startServiceIfNotRunning(getContext());
}
......
......@@ -18,6 +18,7 @@
~ You should have received a copy of the GNU General Public License along
~ with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -28,53 +29,53 @@
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/slideAccountcoreTitle"
android:textColor="@android:color/white"
android:textSize="28sp"
android:textStyle="bold"
android:layout_above="@+id/view"
android:layout_toLeftOf="@+id/scrollView2"
android:layout_toStartOf="@+id/scrollView2"
android:gravity="end"
android:paddingEnd="64dp"
android:paddingRight="64dp"
android:paddingEnd="64dp" />
android:text="@string/slideAccountcoreTitle"
android:textColor="@android:color/white"
android:textSize="28sp"
android:textStyle="bold" />
<android.support.v4.widget.Space
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/scrollView2"
android:layout_toStartOf="@+id/scrollView2"
android:id="@+id/view" />
android:layout_toStartOf="@+id/scrollView2" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/slideAccountcoreDescription"
android:textColor="@android:color/white"
android:textSize="16sp"
android:layout_below="@+id/view"
android:layout_toLeftOf="@+id/scrollView2"
android:layout_toStartOf="@+id/scrollView2"
android:gravity="end"
android:paddingEnd="64dp"
android:paddingRight="64dp"
android:paddingEnd="64dp" />
android:text="@string/slideAccountcoreDescription"
android:textColor="@android:color/white"
android:textSize="16sp" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true">
<android.support.v7.widget.CardView
android:id="@+id/content_host"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="400dp"
android:background="@color/md_light_background" />
android:background="@color/md_light_cards"
android:minHeight="400dp" />
</ScrollView>
......
......@@ -22,55 +22,55 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<LinearLayout
android:orientation="vertical"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:padding="32dp"
android:orientation="vertical">
android:orientation="vertical"
android:padding="32dp">
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="@android:color/white"
android:textSize="28sp"
android:layout_marginBottom="32dp"
android:text="@string/slideAccountcoreTitle"
android:id="@+id/title" />
android:textColor="@android:color/white"
android:textSize="28sp"
android:textStyle="bold" />
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/slideAccountcoreDescription"
android:id="@+id/description" />
android:textColor="@android:color/white"
android:textSize="16sp" />
</LinearLayout>
<android.support.v7.widget.CardView
android:id="@+id/content_host"
android:minHeight="400dp"
android:background="@color/md_light_background"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:background="@color/md_light_cards"
android:minHeight="400dp" />
</LinearLayout>
......
......@@ -23,8 +23,7 @@
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/md_light_background">
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
......@@ -61,7 +60,8 @@
<FrameLayout
android:id="@+id/content_host"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:background="@color/md_light_cards" />
</LinearLayout>
......
<?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/>.
-->
<resources>
<style name="BaseTheme" parent="MaterialDrawerTheme" />
<style name="BaseTheme.Light" parent="MaterialDrawerTheme.Light.DarkToolbar" />
</resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment