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

Fixed some compile time errors by including the previous aspm preferences

parent 2f839ec3
Branches
Tags
No related merge requests found
Showing
with 339 additions and 11 deletions
......@@ -34,23 +34,18 @@ import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer;
import aspm.annotations.BooleanPreference;
import aspm.annotations.IntPreference;
import aspm.annotations.PreferenceWrapper;
import aspm.annotations.StringPreference;
import butterknife.Bind;
import butterknife.ButterKnife;
import de.kuschku.libquassel.events.ConnectionChangeEvent;
import de.kuschku.libquassel.events.GeneralErrorEvent;
import de.kuschku.quasseldroid_ng.BuildConfig;
import de.kuschku.quasseldroid_ng.R;
import de.kuschku.quasseldroid_ng.service.ClientBackgroundThread;
import de.kuschku.quasseldroid_ng.util.BoundActivity;
import de.kuschku.quasseldroid_ng.ui.chat.fragment.ChatFragment;
import de.kuschku.quasseldroid_ng.ui.chat.fragment.LoadingFragment;
import de.kuschku.quasseldroid_ng.ui.chat.util.ActivityImplFactory;
import de.kuschku.quasseldroid_ng.ui.chat.util.ILayoutHelper;
import de.kuschku.quasseldroid_ng.ui.chat.util.Status;
import de.kuschku.quasseldroid_ng.util.BoundActivity;
import de.kuschku.quasseldroid_ng.util.accounts.AccountManager;
import static de.kuschku.util.AndroidAssert.assertNotNull;
......
......@@ -24,9 +24,9 @@ package de.kuschku.quasseldroid_ng.ui.chat;
import android.content.Context;
import android.content.SharedPreferences;
import aspm.BooleanPreference;
import aspm.IntPreference;
import aspm.StringPreference;
import de.kuschku.quasseldroid_ng.util.preferences.BooleanPreference;
import de.kuschku.quasseldroid_ng.util.preferences.IntPreference;
import de.kuschku.quasseldroid_ng.util.preferences.StringPreference;
import de.kuschku.util.backports.Objects;
public class Settings {
......
......@@ -26,8 +26,6 @@ import android.content.Context;
import java.util.Set;
import java.util.UUID;
import aspm.StringPreference;
public class AccountManager {
AccountManagerHelper helper;
......
/*
* 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.quasseldroid_ng.util.preferences;
import android.content.SharedPreferences;
import java.util.HashSet;
import java.util.Set;
public abstract class AbstractPreferenceElement<T> implements PreferenceElement<T>, OnChangeListener<T> {
private final Set<OnChangeListener<T>> listeners = new HashSet<>();
protected SharedPreferences pref;
protected SharedPreferences.Editor edit;
protected String key;
protected T defValue;
public AbstractPreferenceElement(SharedPreferences pref, String key, T defValue) {
this.pref = pref;
this.key = key;
this.defValue = defValue;
}
public void change() {
change(get());
}
public void change(T value) {
for (OnChangeListener<T> listener : listeners)
listener.change(value);
}
public void addChangeListener(OnChangeListener<T> listener) {
listeners.add(listener);
}
public void removeChangeListener(OnChangeListener<T> listener) {
listeners.remove(listener);
}
protected abstract void put(T value);
public void batch(SharedPreferences.Editor edit) {
if (this.edit != null) this.edit.commit();
this.edit = edit;
}
public T get() {
return or(defValue);
}
public void set(T value) {
edit = pref.edit();
put(value);
edit.commit();
}
}
/*
* 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.quasseldroid_ng.util.preferences;
import android.content.SharedPreferences;
public class BooleanPreference extends AbstractPreferenceElement<Boolean> {
public BooleanPreference(SharedPreferences pref, String key, Boolean init) {
super(pref, key, init);
}
@Override
protected void put(Boolean value) {
edit.putBoolean(key, value);
}
@Override
public Boolean or(Boolean defValue) {
return pref.getBoolean(key, defValue);
}
}
/*
* 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.quasseldroid_ng.util.preferences;
import android.content.SharedPreferences;
public class FloatPreference extends AbstractPreferenceElement<Float> {
public FloatPreference(SharedPreferences pref, String key, Float init) {
super(pref, key, init);
}
@Override
protected void put(Float value) {
edit.putFloat(key, value);
}
@Override
public Float or(Float defValue) {
return pref.getFloat(key, defValue);
}
}
/*
* 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.quasseldroid_ng.util.preferences;
import android.content.SharedPreferences;
public class IntPreference extends AbstractPreferenceElement<Integer> {
public IntPreference(SharedPreferences pref, String key, Integer defValue) {
super(pref, key, defValue);
}
@Override
protected void put(Integer value) {
edit.putInt(key, value);
}
@Override
public Integer or(Integer defValue) {
return pref.getInt(key, defValue);
}
}
/*
* 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.quasseldroid_ng.util.preferences;
import android.content.SharedPreferences;
public class LongPreference extends AbstractPreferenceElement<Long> {
public LongPreference(SharedPreferences pref, String key, Long defValue) {
super(pref, key, defValue);
}
@Override
protected void put(Long value) {
edit.putLong(key, value);
}
@Override
public Long or(Long defValue) {
return pref.getLong(key, defValue);
}
}
/*
* 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.quasseldroid_ng.util.preferences;
public interface OnChangeListener<T> {
void change(T value);
}
/*
* 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.quasseldroid_ng.util.preferences;
public interface PreferenceElement<T> {
void addChangeListener(OnChangeListener<T> listener);
void removeChangeListener(OnChangeListener<T> listener);
T get();
T or(T otherwise);
void set(T value);
}
/*
* 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.quasseldroid_ng.util.preferences;
import android.content.SharedPreferences;
public class StringPreference extends AbstractPreferenceElement<String> {
public StringPreference(SharedPreferences pref, String key, String init) {
super(pref, key, init);
}
@Override
protected void put(String value) {
edit.putString(key, value);
}
@Override
public String or(String defValue) {
return pref.getString(key, defValue);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment