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

Removed a dependency

parent 74d46d71
No related branches found
No related tags found
No related merge requests found
Showing
with 114 additions and 77 deletions
......@@ -94,10 +94,7 @@ android {
targetSdkVersion 24
versionCode versionBuild
versionName rawVersionName + " Build #" + versionBuild
buildConfigField "String", "GitHash", "\"${getGitHash()}\""
}
dataBinding {
enabled = true
buildConfigField "String", "VERSION_HASH", "\"${getGitHash()}\""
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
......@@ -133,6 +130,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
applicationVariants.all { variant ->
variant.resValue "string", "versionName", variant.versionName
variant.resValue "string", "versionCode", String.valueOf(versionBuild)
variant.resValue "string", "versionHash", getGitHash()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_7
......
......@@ -21,11 +21,11 @@
package de.kuschku.libquassel.localtypes.buffers;
import android.databinding.ObservableField;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import de.kuschku.libquassel.primitives.types.BufferInfo;
import de.kuschku.util.observables.lists.ObservableElement;
public interface Buffer {
@NonNull
......@@ -37,7 +37,7 @@ public interface Buffer {
String getName();
@NonNull
ObservableField<BufferInfo.BufferStatus> getStatus();
ObservableElement<BufferInfo.BufferStatus> getStatus();
void renameBuffer(@NonNull String newName);
......
......@@ -21,18 +21,18 @@
package de.kuschku.libquassel.localtypes.buffers;
import android.databinding.ObservableField;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import de.kuschku.libquassel.client.Client;
import de.kuschku.libquassel.primitives.types.BufferInfo;
import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel;
import de.kuschku.util.observables.lists.ObservableElement;
public class ChannelBuffer implements Buffer {
@NonNull
private final Client client;
private final ObservableField<BufferInfo.BufferStatus> status = new ObservableField<>();
private final ObservableElement<BufferInfo.BufferStatus> status = new ObservableElement<>();
@NonNull
private BufferInfo info;
......@@ -60,7 +60,7 @@ public class ChannelBuffer implements Buffer {
@NonNull
@Override
public ObservableField<BufferInfo.BufferStatus> getStatus() {
public ObservableElement<BufferInfo.BufferStatus> getStatus() {
// FIXME: Make this dynamic
status.set(getChannel() == null ? BufferInfo.BufferStatus.OFFLINE : BufferInfo.BufferStatus.ONLINE);
return status;
......
......@@ -21,18 +21,18 @@
package de.kuschku.libquassel.localtypes.buffers;
import android.databinding.ObservableField;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import de.kuschku.libquassel.client.Client;
import de.kuschku.libquassel.primitives.types.BufferInfo;
import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser;
import de.kuschku.util.observables.lists.ObservableElement;
public class QueryBuffer implements Buffer {
@NonNull
private final Client client;
private final ObservableField<BufferInfo.BufferStatus> status = new ObservableField<>();
private final ObservableElement<BufferInfo.BufferStatus> status = new ObservableElement<>();
@NonNull
private BufferInfo info;
......@@ -60,7 +60,7 @@ public class QueryBuffer implements Buffer {
@NonNull
@Override
public ObservableField<BufferInfo.BufferStatus> getStatus() {
public ObservableElement<BufferInfo.BufferStatus> getStatus() {
// FIXME: Make this dynamic
status.set((getUser() == null) ? BufferInfo.BufferStatus.OFFLINE :
(getUser().isAway()) ? BufferInfo.BufferStatus.AWAY :
......
......@@ -21,18 +21,18 @@
package de.kuschku.libquassel.localtypes.buffers;
import android.databinding.ObservableField;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import de.kuschku.libquassel.client.Client;
import de.kuschku.libquassel.primitives.types.BufferInfo;
import de.kuschku.libquassel.syncables.types.interfaces.QNetwork;
import de.kuschku.util.observables.lists.ObservableElement;
public class StatusBuffer implements Buffer {
@NonNull
private final Client client;
private final ObservableField<BufferInfo.BufferStatus> status = new ObservableField<>();
private final ObservableElement<BufferInfo.BufferStatus> status = new ObservableElement<>();
@NonNull
private BufferInfo info;
......@@ -68,7 +68,7 @@ public class StatusBuffer implements Buffer {
@NonNull
@Override
public ObservableField<BufferInfo.BufferStatus> getStatus() {
public ObservableElement<BufferInfo.BufferStatus> getStatus() {
updateStatus();
return status;
}
......
......@@ -21,7 +21,6 @@
package de.kuschku.libquassel.syncables.types.impl;
import android.databinding.ObservableInt;
import android.support.annotation.NonNull;
import android.util.SparseArray;
import android.util.SparseIntArray;
......@@ -39,6 +38,7 @@ import de.kuschku.libquassel.syncables.types.interfaces.QBacklogManager;
import de.kuschku.libquassel.syncables.types.interfaces.QBufferSyncer;
import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig;
import de.kuschku.util.observables.lists.ObservableComparableSortedList;
import de.kuschku.util.observables.lists.ObservableElement;
import de.kuschku.util.observables.lists.ObservableSet;
import de.kuschku.util.observables.lists.ObservableSortedList;
......@@ -47,7 +47,7 @@ import static de.kuschku.util.AndroidAssert.assertNotNull;
public class BufferSyncer extends ABufferSyncer {
@NonNull
private final SparseArray<ObservableInt> activities = new SparseArray<>();
private final SparseArray<ObservableElement<Integer>> activities = new SparseArray<>();
@NonNull
private SparseIntArray lastSeenMsgs = new SparseIntArray();
@NonNull
......@@ -211,7 +211,7 @@ public class BufferSyncer extends ABufferSyncer {
_update();
}
public ObservableInt activity(int bufferid) {
public ObservableElement<Integer> activity(int bufferid) {
assertNotNull(activities);
ensureExistingActivity(bufferid);
......@@ -227,7 +227,7 @@ public class BufferSyncer extends ABufferSyncer {
private void ensureExistingActivity(int bufferid) {
if (activities.get(bufferid) == null)
activities.put(bufferid, new ObservableInt());
activities.put(bufferid, new ObservableElement<>(0));
}
public void addActivity(int bufferid, int activity) {
......
......@@ -21,11 +21,11 @@
package de.kuschku.libquassel.syncables.types.interfaces;
import android.databinding.ObservableInt;
import android.util.SparseIntArray;
import de.kuschku.libquassel.message.Message;
import de.kuschku.libquassel.syncables.Synced;
import de.kuschku.util.observables.lists.ObservableElement;
import de.kuschku.util.observables.lists.ObservableSet;
public interface QBufferSyncer extends QObservable<QBufferSyncer> {
......@@ -99,7 +99,7 @@ public interface QBufferSyncer extends QObservable<QBufferSyncer> {
void _markBufferAsRead(int buffer);
ObservableInt activity(int bufferid);
ObservableElement<Integer> activity(int bufferid);
void setActivity(int bufferid, int activity);
......
......@@ -21,8 +21,6 @@
package de.kuschku.quasseldroid_ng.ui;
import android.databinding.Observable;
import android.databinding.ObservableInt;
import android.view.View;
import android.widget.TextView;
......@@ -31,41 +29,32 @@ import com.google.common.base.Function;
import java.util.HashSet;
import java.util.Set;
import de.kuschku.util.observables.callbacks.GeneralCallback;
import de.kuschku.util.observables.lists.ObservableElement;
public class ViewIntBinder {
private final ObservableInt field;
private final Set<Observable.OnPropertyChangedCallback> callbacks = new HashSet<>();
private final ObservableElement<Integer> field;
private final Set<GeneralCallback<Integer>> callbacks = new HashSet<>();
public ViewIntBinder(ObservableInt field) {
public ViewIntBinder(ObservableElement<Integer> field) {
this.field = field;
}
public void bindBackgroundColor(View v, Function<Integer, Integer> mapper) {
v.setBackgroundColor(mapper.apply(field.get()));
Observable.OnPropertyChangedCallback callback = new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable sender, int propertyId) {
v.setBackgroundColor(mapper.apply(field.get()));
}
};
GeneralCallback<Integer> callback = object -> v.setBackgroundColor(mapper.apply(object));
callbacks.add(callback);
field.addOnPropertyChangedCallback(callback);
field.addCallback(callback);
}
public void bindTextColor(TextView v, Function<Integer, Integer> mapper) {
v.setTextColor(mapper.apply(field.get()));
Observable.OnPropertyChangedCallback callback = new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable sender, int propertyId) {
v.setTextColor(mapper.apply(field.get()));
}
};
GeneralCallback<Integer> callback = object -> v.setTextColor(mapper.apply(object));
callbacks.add(callback);
field.addOnPropertyChangedCallback(callback);
field.addCallback(callback);
}
public void unbind() {
for (Observable.OnPropertyChangedCallback callback : callbacks) {
field.removeOnPropertyChangedCallback(callback);
}
field.removeCallbacks();
}
}
......@@ -21,7 +21,6 @@
package de.kuschku.quasseldroid_ng.ui.chat.drawer;
import android.databinding.ObservableField;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
......@@ -42,6 +41,7 @@ import de.kuschku.libquassel.syncables.types.interfaces.QNetwork;
import de.kuschku.quasseldroid_ng.ui.theme.AppContext;
import de.kuschku.util.observables.callbacks.ElementCallback;
import de.kuschku.util.observables.callbacks.UICallback;
import de.kuschku.util.observables.lists.ObservableElement;
import de.kuschku.util.observables.lists.ObservableSortedList;
import static de.kuschku.util.AndroidAssert.assertNotNull;
......@@ -51,7 +51,7 @@ public class BufferViewConfigAdapter extends ExpandableRecyclerAdapter<NetworkVi
private final ObservableSortedList<NetworkItem> items;
private final Map<QNetwork, NetworkItem> itemMap = new WeakHashMap<>();
private final Map<Integer, BufferViewHolder> bufferViewHolderMap = new WeakHashMap<>();
private final ObservableField<Boolean> showAll = new ObservableField<>(false);
private final ObservableElement<Boolean> showAll = new ObservableElement<>(false);
private QBufferViewConfig config;
private final ElementCallback<QNetwork> callback = new ElementCallback<QNetwork>() {
@Override
......@@ -298,7 +298,7 @@ public class BufferViewConfigAdapter extends ExpandableRecyclerAdapter<NetworkVi
return -1;
}
public ObservableField<Boolean> showAll() {
public ObservableElement<Boolean> showAll() {
return showAll;
}
......
......@@ -21,8 +21,6 @@
package de.kuschku.quasseldroid_ng.ui.chat.drawer;
import android.databinding.Observable;
import android.databinding.ObservableField;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.StateListDrawable;
import android.support.annotation.LayoutRes;
......@@ -51,6 +49,8 @@ import de.kuschku.libquassel.syncables.types.interfaces.QIrcUser;
import de.kuschku.quasseldroid_ng.R;
import de.kuschku.quasseldroid_ng.ui.ViewIntBinder;
import de.kuschku.quasseldroid_ng.ui.theme.AppContext;
import de.kuschku.util.observables.callbacks.GeneralCallback;
import de.kuschku.util.observables.lists.ObservableElement;
public class BufferViewHolder extends ChildViewHolder {
......@@ -67,8 +67,8 @@ public class BufferViewHolder extends ChildViewHolder {
TextView name;
@Bind(R.id.material_drawer_description)
TextView description;
private ObservableField<BufferInfo.BufferStatus> status;
private Observable.OnPropertyChangedCallback callback;
private ObservableElement<BufferInfo.BufferStatus> status;
private GeneralCallback<BufferInfo.BufferStatus> callback;
private ViewIntBinder viewIntBinder;
private boolean selected = false;
private boolean checked = false;
......@@ -92,7 +92,7 @@ public class BufferViewHolder extends ChildViewHolder {
public void bind(OnBufferClickListener listener, OnBufferLongClickListener longClickListener, Buffer buffer) {
if (status != null)
status.removeOnPropertyChangedCallback(callback);
status.removeCallback(callback);
status = buffer.getStatus();
name.setText(buffer.getName());
if (viewIntBinder != null) viewIntBinder.unbind();
......@@ -110,13 +110,8 @@ public class BufferViewHolder extends ChildViewHolder {
BufferInfo.Type type = buffer.getInfo().type;
setIcon(context, type, status);
callback = new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable sender, int propertyId) {
setIcon(context, type, status);
}
};
status.addOnPropertyChangedCallback(callback);
callback = object -> setIcon(context, type, status);
status.addCallback(callback);
}
@NonNull
......@@ -155,7 +150,7 @@ public class BufferViewHolder extends ChildViewHolder {
itemView.setSelected(selected || checked);
}
private void setIcon(AppContext context, BufferInfo.Type type, ObservableField<BufferInfo.BufferStatus> status) {
private void setIcon(AppContext context, BufferInfo.Type type, ObservableElement<BufferInfo.BufferStatus> status) {
icon.setImageDrawable(context.themeUtil().statusDrawables.of(type, status.get()));
}
......
......@@ -21,8 +21,6 @@
package de.kuschku.quasseldroid_ng.ui.chat.drawer;
import android.databinding.Observable;
import com.bignerdranch.expandablerecyclerview.Model.ParentListItem;
import java.util.List;
......@@ -105,12 +103,7 @@ public class NetworkItem implements ParentListItem {
this.context = context;
this.config = config;
this.network = network;
bufferViewConfigAdapter.showAll().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable sender, int propertyId) {
setShowAll(bufferViewConfigAdapter.showAll().get());
}
});
bufferViewConfigAdapter.showAll().addCallback(object -> setShowAll(object));
setShowAll(bufferViewConfigAdapter.showAll().get());
this.buffers.addCallback(new UICallback() {
@Override
......
/*
* 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/>.
*/
package de.kuschku.util.observables.lists;
import de.kuschku.util.observables.IObservable;
import de.kuschku.util.observables.callbacks.GeneralCallback;
import de.kuschku.util.observables.callbacks.wrappers.MultiGeneralCallback;
public class ObservableElement<T> implements IObservable<GeneralCallback<T>> {
private MultiGeneralCallback<T> callbacks = MultiGeneralCallback.of();
private T value;
public ObservableElement(T value) {
this.value = value;
}
public ObservableElement() {
this.value = null;
}
@Override
public void addCallback(GeneralCallback<T> callback) {
callbacks.addCallback(callback);
}
@Override
public void removeCallback(GeneralCallback<T> callback) {
callbacks.removeCallback(callback);
}
@Override
public void removeCallbacks() {
callbacks.removeCallbacks();
}
public void set(T value) {
this.value = value;
}
public T get() {
return this.value;
}
}
......@@ -21,22 +21,17 @@
package de.kuschku.util.ui;
import android.databinding.Observable;
import android.databinding.ObservableField;
import android.widget.TextView;
import de.kuschku.util.observables.lists.ObservableElement;
public class ObservableTextBinder {
private final ObservableField<CharSequence> text;
private final ObservableElement<CharSequence> text;
private TextView view;
public ObservableTextBinder(ObservableField<CharSequence> text) {
public ObservableTextBinder(ObservableElement<CharSequence> text) {
this.text = text;
this.text.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable sender, int propertyId) {
updateView();
}
});
this.text.addCallback(object -> updateView());
}
private void updateView() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment