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

Fixed several minor UI issues.

parent 1edd7908
No related branches found
No related tags found
No related merge requests found
Showing with 40 additions and 12 deletions
...@@ -452,8 +452,15 @@ public class MainActivity extends BoundActivity { ...@@ -452,8 +452,15 @@ public class MainActivity extends BoundActivity {
@Override @Override
protected void onConnectToThread(@Nullable ClientBackgroundThread thread) { protected void onConnectToThread(@Nullable ClientBackgroundThread thread) {
super.onConnectToThread(thread); super.onConnectToThread(thread);
if (thread == null) if (thread == null) {
connectToServer(manager.account(context.settings().preferenceLastAccount.get())); Account account = manager.account(context.settings().preferenceLastAccount.get());
if (account != null) {
connectToServer(account);
} else {
setResult(RESULT_CANCELED);
finish();
}
}
else { else {
if (context.client() != null && context.client().connectionStatus() == ConnectionChangeEvent.Status.CONNECTED) { if (context.client() != null && context.client().connectionStatus() == ConnectionChangeEvent.Status.CONNECTED) {
connected(); connected();
......
...@@ -236,6 +236,7 @@ public class BufferViewConfigAdapter extends ExpandableRecyclerAdapter<NetworkVi ...@@ -236,6 +236,7 @@ public class BufferViewConfigAdapter extends ExpandableRecyclerAdapter<NetworkVi
if (config != null) if (config != null)
config.networkList().removeCallback(callback); config.networkList().removeCallback(callback);
config = newconfig; config = newconfig;
for (NetworkItem item : items) item.onDestroy();
items.clear(); items.clear();
itemMap.clear(); itemMap.clear();
if (config != null) { if (config != null) {
......
...@@ -33,6 +33,7 @@ import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; ...@@ -33,6 +33,7 @@ import de.kuschku.libquassel.syncables.types.interfaces.QNetwork;
import de.kuschku.quasseldroid_ng.ui.theme.AppContext; import de.kuschku.quasseldroid_ng.ui.theme.AppContext;
import de.kuschku.util.irc.IrcCaseMappers; import de.kuschku.util.irc.IrcCaseMappers;
import de.kuschku.util.observables.callbacks.ElementCallback; import de.kuschku.util.observables.callbacks.ElementCallback;
import de.kuschku.util.observables.callbacks.GeneralCallback;
import de.kuschku.util.observables.callbacks.UICallback; import de.kuschku.util.observables.callbacks.UICallback;
import de.kuschku.util.observables.lists.ObservableSet; import de.kuschku.util.observables.lists.ObservableSet;
import de.kuschku.util.observables.lists.ObservableSortedList; import de.kuschku.util.observables.lists.ObservableSortedList;
...@@ -41,6 +42,7 @@ public class NetworkItem implements ParentListItem { ...@@ -41,6 +42,7 @@ public class NetworkItem implements ParentListItem {
private final AppContext context; private final AppContext context;
private final QBufferViewConfig config; private final QBufferViewConfig config;
private final QNetwork network; private final QNetwork network;
private final BufferViewConfigAdapter bufferViewConfigAdapter;
private final ObservableSortedList<Buffer> buffers = new ObservableSortedList<>(new Comparator<Buffer>() { private final ObservableSortedList<Buffer> buffers = new ObservableSortedList<>(new Comparator<Buffer>() {
@Override @Override
public int compare(Buffer o1, Buffer o2) { public int compare(Buffer o1, Buffer o2) {
...@@ -86,15 +88,20 @@ public class NetworkItem implements ParentListItem { ...@@ -86,15 +88,20 @@ public class NetworkItem implements ParentListItem {
public void notifyItemChanged(Integer element) { public void notifyItemChanged(Integer element) {
} }
}; };
private final UICallback callback1;
private final ElementCallback<Integer> callback2;
private final GeneralCallback<Boolean> booleanGeneralCallback;
private ObservableSet<Integer> backingSet; private ObservableSet<Integer> backingSet;
public NetworkItem(AppContext context, QBufferViewConfig config, QNetwork network, BufferViewConfigAdapter bufferViewConfigAdapter) { public NetworkItem(AppContext context, QBufferViewConfig config, QNetwork network, BufferViewConfigAdapter bufferViewConfigAdapter) {
this.context = context; this.context = context;
this.config = config; this.config = config;
this.network = network; this.network = network;
bufferViewConfigAdapter.showAll().addCallback(object -> setShowAll(object)); this.bufferViewConfigAdapter = bufferViewConfigAdapter;
booleanGeneralCallback = object -> setShowAll(object);
bufferViewConfigAdapter.showAll().addCallback(booleanGeneralCallback);
setShowAll(bufferViewConfigAdapter.showAll().get()); setShowAll(bufferViewConfigAdapter.showAll().get());
this.buffers.addCallback(new UICallback() { callback1 = new UICallback() {
@Override @Override
public void notifyItemInserted(int position) { public void notifyItemInserted(int position) {
bufferViewConfigAdapter.notifyChildItemInserted(NetworkItem.this, position); bufferViewConfigAdapter.notifyChildItemInserted(NetworkItem.this, position);
...@@ -136,8 +143,9 @@ public class NetworkItem implements ParentListItem { ...@@ -136,8 +143,9 @@ public class NetworkItem implements ParentListItem {
this.notifyItemRemoved(position); this.notifyItemRemoved(position);
} }
} }
}); };
context.client().bufferManager().bufferIds().addCallback(new ElementCallback<Integer>() { this.buffers.addCallback(callback1);
callback2 = new ElementCallback<Integer>() {
@Override @Override
public void notifyItemInserted(Integer element) { public void notifyItemInserted(Integer element) {
} }
...@@ -153,7 +161,8 @@ public class NetworkItem implements ParentListItem { ...@@ -153,7 +161,8 @@ public class NetworkItem implements ParentListItem {
buffers.notifyItemChanged(buffer); buffers.notifyItemChanged(buffer);
} }
} }
}); };
context.client().bufferManager().bufferIds().addCallback(callback2);
} }
public void populateList(ObservableSet<Integer> backingSet) { public void populateList(ObservableSet<Integer> backingSet) {
...@@ -193,4 +202,11 @@ public class NetworkItem implements ParentListItem { ...@@ -193,4 +202,11 @@ public class NetworkItem implements ParentListItem {
public String toString() { public String toString() {
return String.valueOf(network); return String.valueOf(network);
} }
public void onDestroy() {
this.backingSet.removeCallback(callback);
bufferViewConfigAdapter.showAll().removeCallback(booleanGeneralCallback);
this.buffers.removeCallback(callback1);
context.client().bufferManager().bufferIds().removeCallback(callback2);
}
} }
...@@ -183,12 +183,12 @@ public class NetworkServerEditActivity extends BoundActivity { ...@@ -183,12 +183,12 @@ public class NetworkServerEditActivity extends BoundActivity {
useSSL.isChecked(), useSSL.isChecked(),
0, 0,
host.getText().toString(), host.getText().toString(),
NumberHelper.parseInt(port.getText().toString(), -1), NumberHelper.parseInt(port.getText().toString(), 0),
password.getText().toString(), password.getText().toString(),
useProxy.isChecked(), useProxy.isChecked(),
NetworkServer.ProxyType.fromId((int) proxyType.getSelectedItemId()), NetworkServer.ProxyType.fromId((int) proxyType.getSelectedItemId()),
proxyHost.getText().toString(), proxyHost.getText().toString(),
NumberHelper.parseInt(proxyPort.getText().toString(), -1), NumberHelper.parseInt(proxyPort.getText().toString(), 0),
proxyUser.getText().toString(), proxyUser.getText().toString(),
proxyPassword.getText().toString() proxyPassword.getText().toString()
))); )));
......
...@@ -87,7 +87,7 @@ public class ObservableSortedList<T> extends ArrayList<T> implements IObservable ...@@ -87,7 +87,7 @@ public class ObservableSortedList<T> extends ArrayList<T> implements IObservable
@Override @Override
public boolean add(T object) { public boolean add(T object) {
int position = addInternal(object); int position = addInternal(object);
callback.notifyItemInserted(position); callback.notifyItemInserted(indexOf(object));
return position != -1; return position != -1;
} }
...@@ -125,7 +125,7 @@ public class ObservableSortedList<T> extends ArrayList<T> implements IObservable ...@@ -125,7 +125,7 @@ public class ObservableSortedList<T> extends ArrayList<T> implements IObservable
@Override @Override
public boolean remove(Object object) { public boolean remove(Object object) {
int position = indexOf(object); int position = super.indexOf(object);
if (position == -1) { if (position == -1) {
return false; return false;
} else { } else {
......
...@@ -51,5 +51,6 @@ ...@@ -51,5 +51,6 @@
android:layout_weight="1" android:layout_weight="1"
android:clickable="true" android:clickable="true"
android:textColor="?attr/colorForegroundAction" android:textColor="?attr/colorForegroundAction"
android:textIsSelectable="true"
android:textStyle="italic"/> android:textStyle="italic"/>
</LinearLayout> </LinearLayout>
...@@ -52,5 +52,6 @@ ...@@ -52,5 +52,6 @@
android:layout_weight="1" android:layout_weight="1"
android:clickable="true" android:clickable="true"
android:textColor="?attr/colorForegroundError" android:textColor="?attr/colorForegroundError"
android:textIsSelectable="true"
android:textStyle="italic"/> android:textStyle="italic"/>
</LinearLayout> </LinearLayout>
...@@ -50,5 +50,6 @@ ...@@ -50,5 +50,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:clickable="true" android:clickable="true"
android:textColor="?attr/colorForeground"/> android:textColor="?attr/colorForeground"
android:textIsSelectable="true"/>
</LinearLayout> </LinearLayout>
...@@ -52,5 +52,6 @@ ...@@ -52,5 +52,6 @@
android:layout_weight="1" android:layout_weight="1"
android:clickable="true" android:clickable="true"
android:textColor="?attr/colorForegroundSecondary" android:textColor="?attr/colorForegroundSecondary"
android:textIsSelectable="true"
android:textStyle="italic"/> android:textStyle="italic"/>
</LinearLayout> </LinearLayout>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment