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

Implemented static dispatch and ignorelist editing

parent 89fb9fd1
No related branches found
No related tags found
No related merge requests found
/*
* 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.irc;
import android.support.annotation.Nullable;
import java.util.Locale;
public class IrcCaseMappers {
public static IrcCaseMapper irc = new UnicodeCaseMapper();
public static IrcCaseMapper unicode = new ClassicalIrcCaseMapper();
private IrcCaseMappers() {
}
public interface IrcCaseMapper {
boolean equalsIgnoreCase(@Nullable String a, @Nullable String b);
@Nullable
String toLowerCase(@Nullable String in);
@Nullable
String toUpperCase(@Nullable String in);
}
static class UnicodeCaseMapper implements IrcCaseMapper {
@Override
public boolean equalsIgnoreCase(@Nullable String a, @Nullable String b) {
if (a == null || b == null)
return a == null && b == null;
else
return a.equalsIgnoreCase(b);
}
@Nullable
@Override
public String toLowerCase(@Nullable String in) {
return in != null ? in.toLowerCase(Locale.US) : null;
}
@Nullable
@Override
public String toUpperCase(@Nullable String in) {
return in != null ? in.toUpperCase(Locale.US) : null;
}
}
static class ClassicalIrcCaseMapper implements IrcCaseMapper {
@Nullable
public String toLowerCase(@Nullable String s) {
return s != null ? s.toLowerCase(Locale.US)
.replace('[', '{')
.replace(']', '}')
.replace('^', '~') : null;
}
@Nullable
public String toUpperCase(@Nullable String s) {
return s != null ? s.toUpperCase(Locale.US)
.replace('{', '[')
.replace('}', ']')
.replace('~', '^') : null;
}
@Override
public boolean equalsIgnoreCase(@Nullable String a, @Nullable String b) {
if (a == null || b == null)
return a == null && b == null;
else
return toLowerCase(a).equals(toLowerCase(b)) || toUpperCase(a).equals(toUpperCase(b));
}
}
}
......@@ -25,8 +25,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.util.SortedList;
import com.afollestad.materialdialogs.MaterialDialog;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
......@@ -232,8 +230,19 @@ public class ObservableSortedList<T> implements IObservableList<UICallback, T> {
@NonNull
@Override
public <T1> T1[] toArray(@NonNull T1[] array) {
throw new MaterialDialog.NotImplementedException("Not implemented");
public <T1> T1[] toArray(@NonNull T1[] a) {
try {
Object[] elements = toArray();
if (a.length < elements.length)
// Make a new array of a's runtime type, but my contents:
return (T1[]) Arrays.copyOf(elements, elements.length, a.getClass());
System.arraycopy(elements, 0, a, 0, elements.length);
if (a.length > elements.length)
a[elements.length] = null;
return a;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void notifyItemChanged(int position) {
......
<?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/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="?attr/actionBarTheme">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingBottom="8dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:text="@string/labelIgnoreRuleStrictness"
android:textSize="12sp"/>
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/strictness"
style="@style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="8dp"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingBottom="8dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:text="@string/labelIgnoreRuleType"
android:textSize="12sp"/>
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/type"
style="@style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="8dp"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/ignoreRule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/labelIgnoreRule"/>
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/isRegEx"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/labelIgnoreRuleIsRegEx"/>
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:text="@string/labelIgnoreRuleScope"
android:textColor="?attr/colorAccent"
android:textSize="14sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="16dp">
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/scopeType"
style="@style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="8dp"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/scope"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
<?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/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?selectableItemBackground"
android:clickable="true"
android:orientation="horizontal"
android:paddingLeft="?listPreferredItemPaddingLeft"
android:paddingRight="?listPreferredItemPaddingRight">
<TextView
android:id="@+id/text"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:lines="1"
android:singleLine="true"
android:textSize="16sp"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/active"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
</LinearLayout>
......@@ -32,6 +32,11 @@
<string name="labelChatlistShowQueries">Show queries</string>
<string name="labelChatlistSortAlphabetically">Sort alphabetically</string>
<string name="labelChatlistMinimumActivityNone">labelChatlistMinimumActivityNone</string>
<string name="labelChatlistMinimumActivityOther">labelChatlistMinimumActivityOther</string>
<string name="labelChatlistMinimumActivityMessage">labelChatlistMinimumActivityMessage</string>
<string name="labelChatlistMinimumActivityHighlight">labelChatlistMinimumActivityHighlight</string>
<string name="labelIdentityAway">Away</string>
<string name="labelIdentityAwayReason">Reason</string>
<string name="labelIdentityDetachAway">Away on Detach</string>
......@@ -44,6 +49,24 @@
<string name="labelIdentityQuitReason">Quit Reason</string>
<string name="labelIdentityRealName">Real Name</string>
<string name="labelIgnoreRule">Ignore Rule</string>
<string name="labelIgnoreRuleIsRegEx">Regular Expression</string>
<string name="labelIgnoreRuleScope">Scope</string>
<string name="labelIgnoreRuleStrictness">Strictness</string>
<string name="labelIgnoreRuleType">Rule Type</string>
<string name="labelIgnoreStrictnessUnmatched">Unmatched</string>
<string name="labelIgnoreStrictnessSoft">Dynamic</string>
<string name="labelIgnoreStrictnessHard">Permanent</string>
<string name="labelIgnoreRuleSender">Sender</string>
<string name="labelIgnoreRuleMessage">Message</string>
<string name="labelIgnoreRuleCtcp">CTCP</string>
<string name="labelIgnoreScopeGlobal">Global</string>
<string name="labelIgnoreScopeNetwork">Network</string>
<string name="labelIgnoreScopeChannel">Channel</string>
<string name="labelNetworkAutoIdentify">Auto Identify</string>
<string name="labelNetworkAutoIdentifyPassword">Password</string>
<string name="labelNetworkAutoIdentifyService">Service</string>
......@@ -72,4 +95,8 @@
<string name="labelNetworkServerProxyType">Type</string>
<string name="labelNetworkServerProxyUser">User</string>
<string name="labelNetworkServerUseSSL">SSL</string>
<string name="labelNetworkServerProxyDefault">Default Proxy</string>
<string name="labelNetworkServerProxySocks5">Socks5</string>
<string name="labelNetworkServerProxyHttp">Http</string>
</resources>
\ No newline at end of file
......@@ -33,6 +33,8 @@
<string name="titleEditChatLists">Edit Chat Lists</string>
<string name="titleEditIdentities">Edit Identities</string>
<string name="titleEditIdentity">Edit Identity</string>
<string name="titleEditIgnoreRule">Edit Ignore Rule</string>
<string name="titleEditIgnoreList">Edit Ignore List</string>
<string name="titleEditNetwork">Edit Network</string>
<string name="titleEditNetworkServer">Edit NetworkServer</string>
<string name="titleEditNetworkServers">Edit NetworkServers</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment