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

Cleaned up the code a bit

parent b0689157
No related branches found
No related tags found
No related merge requests found
Showing
with 112 additions and 131 deletions
...@@ -19,6 +19,7 @@ import de.kuschku.util.observables.callbacks.wrappers.MultiUICallbackWrapper; ...@@ -19,6 +19,7 @@ import de.kuschku.util.observables.callbacks.wrappers.MultiUICallbackWrapper;
import static de.kuschku.util.AndroidAssert.assertTrue; import static de.kuschku.util.AndroidAssert.assertTrue;
@SuppressWarnings("unchecked")
public class ObservableSortedList<T> implements IObservableList<UICallback, T> { public class ObservableSortedList<T> implements IObservableList<UICallback, T> {
@NonNull @NonNull
private final SortedList<T> list; private final SortedList<T> list;
...@@ -213,6 +214,7 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> { ...@@ -213,6 +214,7 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> {
callback.notifyItemChanged(position); callback.notifyItemChanged(position);
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return Arrays.toString(toArray()); return Arrays.toString(toArray());
...@@ -234,7 +236,6 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> { ...@@ -234,7 +236,6 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
if (callback != null)
if (count == 1) if (count == 1)
callback.notifyItemInserted(position); callback.notifyItemInserted(position);
else else
...@@ -243,7 +244,6 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> { ...@@ -243,7 +244,6 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> {
@Override @Override
public void onRemoved(int position, int count) { public void onRemoved(int position, int count) {
if (callback != null)
if (count == 1) if (count == 1)
callback.notifyItemRemoved(position); callback.notifyItemRemoved(position);
else else
...@@ -252,13 +252,11 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> { ...@@ -252,13 +252,11 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> {
@Override @Override
public void onMoved(int fromPosition, int toPosition) { public void onMoved(int fromPosition, int toPosition) {
if (callback != null)
callback.notifyItemMoved(fromPosition, toPosition); callback.notifyItemMoved(fromPosition, toPosition);
} }
@Override @Override
public void onChanged(int position, int count) { public void onChanged(int position, int count) {
if (callback != null)
if (count == 1) if (count == 1)
callback.notifyItemChanged(position); callback.notifyItemChanged(position);
else else
......
package de.kuschku.util.ui; package de.kuschku.util.ui;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
...@@ -18,7 +19,8 @@ public class MessageUtil { ...@@ -18,7 +19,8 @@ public class MessageUtil {
/** /**
* Parse mIRC style codes in IrcMessage * Parse mIRC style codes in IrcMessage
*/ */
public static SpannableString parseStyleCodes(ThemeUtil themeUtil, String content, boolean parse) { @NonNull
public static SpannableString parseStyleCodes(@NonNull ThemeUtil themeUtil, @NonNull String content, boolean parse) {
if (!parse) { if (!parse) {
return new SpannableString(content return new SpannableString(content
.replaceAll("\\x02", "") .replaceAll("\\x02", "")
...@@ -46,7 +48,6 @@ public class MessageUtil { ...@@ -46,7 +48,6 @@ public class MessageUtil {
int start, end, endSearchOffset, startIndicatorLength, style, fg, bg; int start, end, endSearchOffset, startIndicatorLength, style, fg, bg;
while (true) { while (true) {
content = newString.toString(); content = newString.toString();
start = -1;
end = -1; end = -1;
startIndicatorLength = 1; startIndicatorLength = 1;
style = 0; style = 0;
......
...@@ -94,12 +94,14 @@ public class StorageBackendParcelable extends StorageBackend implements Parcelab ...@@ -94,12 +94,14 @@ public class StorageBackendParcelable extends StorageBackend implements Parcelab
dest.writeInt(type.getValue()); dest.writeInt(type.getValue());
switch (type) { switch (type) {
case Int: case Int:
assertNotNull(q.data);
dest.writeInt((Integer) q.data); dest.writeInt((Integer) q.data);
break; break;
case QString: case QString:
dest.writeString((String) q.data); dest.writeString((String) q.data);
break; break;
case Bool: case Bool:
assertNotNull(q.data);
dest.writeInt(((Boolean) q.data) ? 1 : 0); dest.writeInt(((Boolean) q.data) ? 1 : 0);
break; break;
default: default:
......
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="?attr/colorBackground" />
</shape>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/swipe_view" android:id="@+id/swipe_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorBackground"> android:background="?attr/colorBackground"
tools:showIn="@layout/activity_chat">
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/messages" android:id="@+id/messages"
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText <android.support.v7.widget.AppCompatEditText
android:id="@+id/host" android:id="@+id/host"
android:hint="Hostname" android:hint="@string/labelHostname"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textUri" /> android:inputType="textUri" />
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText <android.support.v7.widget.AppCompatEditText
android:id="@+id/port" android:id="@+id/port"
android:hint="Port" android:hint="@string/labelPort"
android:text="4242"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number" /> android:inputType="number" />
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText <android.support.v7.widget.AppCompatEditText
android:id="@+id/username" android:id="@+id/username"
android:hint="Username" android:hint="@string/labelUsername"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="text" /> android:inputType="text" />
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText <android.support.v7.widget.AppCompatEditText
android:id="@+id/password" android:id="@+id/password"
android:hint="Password" android:hint="@string/labelPassword"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textPassword" /> android:inputType="textPassword" />
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android" <com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sothree="http://schemas.android.com/apk/res-auto" xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sliding_layout_history" android:id="@+id/sliding_layout_history"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
...@@ -12,7 +13,8 @@ ...@@ -12,7 +13,8 @@
sothree:umanoOverlay="true" sothree:umanoOverlay="true"
sothree:umanoPanelHeight="@dimen/message_history_panel_height" sothree:umanoPanelHeight="@dimen/message_history_panel_height"
sothree:umanoScrollableView="@+id/msg_history" sothree:umanoScrollableView="@+id/msg_history"
sothree:umanoShadowHeight="0.0dip"> sothree:umanoShadowHeight="0.0dip"
tools:showIn="@layout/activity_chat">
<include layout="@layout/widget_editor" /> <include layout="@layout/widget_editor" />
...@@ -42,7 +44,7 @@ ...@@ -42,7 +44,7 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="16.0dip" android:paddingLeft="16.0dip"
android:paddingRight="16.0dip" android:paddingRight="16.0dip"
android:text="@string/message_history" android:text="@string/labelHistory"
android:textAppearance="@style/TextAppearance.AppCompat.Body2" android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="?attr/colorForegroundSecondary" /> android:textColor="?attr/colorForegroundSecondary" />
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingBottom="@dimen/message_history_panel_height"> xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="@dimen/message_history_panel_height"
tools:showIn="@layout/slider_main">
<ScrollView <ScrollView
android:id="@+id/chatline_scroller" android:id="@+id/chatline_scroller"
...@@ -22,7 +23,7 @@ ...@@ -22,7 +23,7 @@
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:gravity="top" android:gravity="top"
android:hint="@string/message_placeholder" android:hint="@string/placeholder"
android:inputType="textCapSentences|textShortMessage|textAutoCorrect" android:inputType="textCapSentences|textShortMessage|textAutoCorrect"
android:paddingBottom="17dp" android:paddingBottom="17dp"
android:paddingLeft="20dp" android:paddingLeft="20dp"
......
...@@ -5,11 +5,6 @@ ...@@ -5,11 +5,6 @@
android:id="@+id/action_hide_events" android:id="@+id/action_hide_events"
android:icon="@android:drawable/ic_menu_sort_by_size" android:icon="@android:drawable/ic_menu_sort_by_size"
android:orderInCategory="100" android:orderInCategory="100"
android:title="Hide events" android:title="@string/labelHideEvents"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu> </menu>
...@@ -3,32 +3,32 @@ ...@@ -3,32 +3,32 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/format_bold" android:id="@+id/format_bold"
android:icon="?attr/ic_format_bold" android:icon="?attr/iconFormatBold"
app:showAsAction="always" app:showAsAction="always"
android:title="@string/format_bold" /> android:title="@string/formatBold" />
<item <item
android:id="@+id/format_italic" android:id="@+id/format_italic"
android:icon="?attr/ic_format_italic" android:icon="?attr/iconFormatItalic"
app:showAsAction="always" app:showAsAction="always"
android:title="@string/format_italic" /> android:title="@string/formatItalic" />
<item <item
android:id="@+id/format_underline" android:id="@+id/format_underline"
android:icon="?attr/ic_format_underline" android:icon="?attr/iconFormatUnderline"
app:showAsAction="always" app:showAsAction="always"
android:title="@string/format_underline" /> android:title="@string/formatUnderline" />
<item <item
android:id="@+id/format_paint" android:id="@+id/format_paint"
android:icon="?attr/ic_format_paint" android:icon="?attr/iconFormatPaint"
app:showAsAction="always" app:showAsAction="always"
android:title="@string/format_color" /> android:title="@string/formatColor" />
<item <item
android:id="@+id/format_fill" android:id="@+id/format_fill"
android:icon="?attr/ic_format_fill" android:icon="?attr/iconFormatFill"
app:showAsAction="always" app:showAsAction="always"
android:title="@string/format_fill" /> android:title="@string/formatFill" />
<item <item
android:id="@+id/action_history" android:id="@+id/action_history"
android:icon="?attr/ic_history" android:icon="?attr/iconHistory"
app:showAsAction="always" app:showAsAction="always"
android:title="@string/message_history" /> android:title="@string/labelHistory" />
</menu> </menu>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
...@@ -60,12 +60,12 @@ ...@@ -60,12 +60,12 @@
<attr name="chatlineExpandedSize" /> <attr name="chatlineExpandedSize" />
<!-- Format icons --> <!-- Format icons -->
<attr name="ic_format_bold" format="reference" /> <attr name="iconFormatBold" format="reference" />
<attr name="ic_format_italic" format="reference" /> <attr name="iconFormatItalic" format="reference" />
<attr name="ic_format_underline" format="reference" /> <attr name="iconFormatUnderline" format="reference" />
<attr name="ic_format_paint" format="reference" /> <attr name="iconFormatPaint" format="reference" />
<attr name="ic_format_fill" format="reference" /> <attr name="iconFormatFill" format="reference" />
<attr name="ic_history" format="reference" /> <attr name="iconHistory" format="reference" />
<attr name="cardStyle" format="reference" /> <attr name="cardStyle" format="reference" />
</resources> </resources>
...@@ -2,14 +2,9 @@ ...@@ -2,14 +2,9 @@
<!-- Default screen margins, per the Android Design guidelines. --> <!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="message_horizontal">8dp</dimen> <dimen name="message_horizontal">8dp</dimen>
<dimen name="message_vertical">4dp</dimen> <dimen name="message_vertical">4dp</dimen>
<dimen name="text_margin">16dp</dimen>
<!-- Per the design guidelines, navigation drawers should be between 240dp and 320dp:
https://developer.android.com/design/patterns/navigation-drawer.html -->
<dimen name="navigation_drawer_width">240dp</dimen>
<dimen name="message_history_panel_height">0dip</dimen> <dimen name="message_history_panel_height">0dip</dimen>
</resources> </resources>
<resources> <resources>
<string name="app_name">QuasselDroid</string> <string name="appName">QuasselDroid</string>
<string name="action_settings">Settings</string> <string name="appDescription">An Android-based client for the decentralized Quassel IRC client.</string>
<string name="appDescriptionLong">Quassel is a distributed, decentralized IRC client, written using C++ and Qt. QuasselDroid is a pure-java client for the Quassel core, allowing you to connect to your Quassel core using your Android™ phone.</string>
<string name="appLinkGithubTitle">GitHub</string>
<string name="appLinkGithubUrl" translatable="false">https://github.com/sandsmark/QuasselDroid</string>
<string name="appLinkCommunityTitle">Community</string>
<string name="appLinkCommunityUrl" translatable="false">https://plus.google.com/communities/104094956084217666662</string>
<!-- Message format strings --> <!-- Message format strings -->
<string name="message_plain">%1$s: %2$s</string> <string name="usernameHostmask">%1$s (%2$s)</string>
<string name="message_join">%1$s has joined %2$s</string> <string name="messagePlain">%1$s: %2$s</string>
<string name="message_part">%1$s has left %2$s</string> <string name="messageJoin">%1$s has joined %2$s</string>
<string name="message_part_extra">"%1$s has left %2$s (%3$s)</string>
<string name="message_quit">%1$s has quit</string> <string name="messagePart">%1$s has left %2$s</string>
<string name="message_quit_extra">%1$s has quit (%2$s)</string> <string name="messagePartExtra">"%1$s has left %2$s (%3$s)</string>
<string name="message_kill">%1$s was killed: %2$s</string> <string name="messageQuit">%1$s has quit</string>
<string name="messageQuitExtra">%1$s has quit (%2$s)</string>
<string name="message_kick">%1$s has kicked %2$s from %3$s</string> <string name="messageKill">%1$s was killed: %2$s</string>
<string name="message_kick_extra">%1$s has kicked %2$s from %3$s: %4$s</string>
<string name="message_mode">Mode %1$s by %2$s</string> <string name="messageKick">%1$s has kicked %2$s from %3$s</string>
<string name="messageKickExtra">%1$s has kicked %2$s from %3$s: %4$s</string>
<string name="message_nick_self">You are now known as %1$s</string> <string name="messageMode">Mode %1$s by %2$s</string>
<string name="message_nick_other">%1$s is now known as %2$s</string>
<string name="message_daychange">{ Day changed to %1$s }</string> <string name="messageNickSelf">You are now known as %1$s</string>
<string name="messageNickOther">%1$s is now known as %2$s</string>
<string name="message_action">* %1$s %2$s</string> <string name="messageDayChange">{ Day changed to %1$s }</string>
<string name="messageAction">* %1$s %2$s</string>
<!-- Editor UI --> <!-- Editor UI -->
<string name="message_placeholder">Write a message…</string> <string name="placeholder">Write a message…</string>
<string name="message_history">Message History</string> <string name="formatBold">Bold</string>
<string name="format_bold">Bold</string> <string name="formatItalic">Italic</string>
<string name="format_italic">Italic</string> <string name="formatUnderline">Underline</string>
<string name="format_underline">Underline</string> <string name="formatColor">Text Color</string>
<string name="format_color">Text Color</string> <string name="formatFill">Background Color</string>
<string name="format_fill">Background Color</string>
<!-- Actions -->
<!-- Misc --> <string name="labelLogin">Login</string>
<string name="username_hostmask">%1$s (%2$s)</string> <string name="labelCancel">Cancel</string>
<string name="title_status_buffer">Status Buffer</string> <string name="labelConnect">Connect</string>
<string name="open_drawer">open</string> <string name="labelSettings">Settings</string>
<string name="close_drawer">close</string> <string name="labelStatusBuffer">Status Buffer</string>
<string name="labelAddress">Address</string>
<string name="labelHistory">Input History</string>
<string name="labelHostname">Hostname</string>
<string name="labelPort">Port</string>
<string name="labelPassword">Password</string>
<string name="labelUsername">Username</string>
<string name="labelHideEvents">Hide events</string>
<string name="warningCertificate">Do you trust this certificate?</string>
</resources> </resources>
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
<item name="colorControlHighlight">@color/colorAccentFocus</item> <item name="colorControlHighlight">@color/colorAccentFocus</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="ic_format_bold">@drawable/ic_format_bold_dark</item> <item name="iconFormatBold">@drawable/ic_format_bold_dark</item>
<item name="ic_format_italic">@drawable/ic_format_italic_dark</item> <item name="iconFormatItalic">@drawable/ic_format_italic_dark</item>
<item name="ic_format_underline">@drawable/ic_format_underline_dark</item> <item name="iconFormatUnderline">@drawable/ic_format_underline_dark</item>
<item name="ic_format_paint">@drawable/ic_format_paint_dark</item> <item name="iconFormatPaint">@drawable/ic_format_paint_dark</item>
<item name="ic_format_fill">@drawable/ic_format_fill_dark</item> <item name="iconFormatFill">@drawable/ic_format_fill_dark</item>
<item name="ic_history">@drawable/ic_history_dark</item> <item name="iconHistory">@drawable/ic_history_dark</item>
<item name="cardStyle">@style/CardView.Dark</item> <item name="cardStyle">@style/CardView.Dark</item>
</style> </style>
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
<item name="colorControlHighlight">@color/colorAccentFocus</item> <item name="colorControlHighlight">@color/colorAccentFocus</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="ic_format_bold">@drawable/ic_format_bold_light</item> <item name="iconFormatBold">@drawable/ic_format_bold_light</item>
<item name="ic_format_italic">@drawable/ic_format_italic_light</item> <item name="iconFormatItalic">@drawable/ic_format_italic_light</item>
<item name="ic_format_underline">@drawable/ic_format_underline_light</item> <item name="iconFormatUnderline">@drawable/ic_format_underline_light</item>
<item name="ic_format_paint">@drawable/ic_format_paint_light</item> <item name="iconFormatPaint">@drawable/ic_format_paint_light</item>
<item name="ic_format_fill">@drawable/ic_format_fill_light</item> <item name="iconFormatFill">@drawable/ic_format_fill_light</item>
<item name="ic_history">@drawable/ic_history_light</item> <item name="iconHistory">@drawable/ic_history_light</item>
<item name="cardStyle">@style/CardView.Light</item> <item name="cardStyle">@style/CardView.Light</item>
</style> </style>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment