From f3cce96c427982bc364b7c32a0ad9ee7dd1c0c91 Mon Sep 17 00:00:00 2001 From: Janne Koschinski <janne@kuschku.de> Date: Sat, 20 Feb 2016 21:02:59 +0100 Subject: [PATCH] Added Theming --- app/build.gradle | 2 + app/src/main/AndroidManifest.xml | 13 +- .../service/ClientBackgroundThread.java | 4 +- .../quasseldroid_ng/ui/LoginActivity.java | 8 +- .../ui/chat/ChannelDetailActivity.java | 10 +- .../quasseldroid_ng/ui/chat/MainActivity.java | 10 +- .../quasseldroid_ng/ui/chat/Settings.java | 62 ---- .../ui/chat/chatview/ChatMessageRenderer.java | 2 +- .../ui/chat/drawer/BufferViewHolder.java | 3 +- .../ui/chat/util/ServiceHelper.java | 7 +- .../quasseldroid_ng/ui/settings/Settings.java | 68 ++++ .../ui/settings/SettingsActivity.java | 95 +++++ .../quasseldroid_ng/ui/theme/AppContext.java | 2 +- .../quasseldroid_ng/ui/theme/AppTheme.java | 3 + .../ui/theme/PreferenceStrings.java | 59 ++++ .../quasseldroid_ng/ui/theme/ThemeUtil.java | 324 +++++++++--------- .../irc/format/IrcFormatDeserializer.java | 2 +- .../util/servicebound/BoundActivity.java | 15 +- .../util/servicebound/BoundFragment.java | 2 - .../preferences/MaterialListPreference.java | 60 ++++ .../ui/preferences/SeekBarPreference.java | 224 ++++++++++++ .../main/res/layout-w720dp/activity_main.xml | 4 +- .../res/layout/activity_channel_detail.xml | 12 +- app/src/main/res/layout/activity_main.xml | 6 +- app/src/main/res/layout/activity_settings.xml | 47 +++ .../main/res/layout/seek_bar_preference.xml | 51 +++ app/src/main/res/layout/widget_actionbar.xml | 2 +- .../main/res/layout/widget_channel_mode.xml | 9 +- app/src/main/res/layout/widget_editor.xml | 1 + app/src/main/res/menu/chat.xml | 2 +- app/src/main/res/menu/chatlist.xml | 2 +- app/src/main/res/values/preferences.xml | 35 +- app/src/main/res/values/styles.xml | 52 ++- app/src/main/res/values/themes.xml | 56 +++ app/src/main/res/xml/pref_appearance.xml | 55 +++ app/src/main/res/xml/pref_overview.xml | 32 ++ 36 files changed, 1067 insertions(+), 274 deletions(-) delete mode 100644 app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/Settings.java create mode 100644 app/src/main/java/de/kuschku/quasseldroid_ng/ui/settings/Settings.java create mode 100644 app/src/main/java/de/kuschku/quasseldroid_ng/ui/settings/SettingsActivity.java create mode 100644 app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/PreferenceStrings.java create mode 100644 app/src/main/java/de/kuschku/util/ui/preferences/MaterialListPreference.java create mode 100644 app/src/main/java/de/kuschku/util/ui/preferences/SeekBarPreference.java create mode 100644 app/src/main/res/layout/activity_settings.xml create mode 100644 app/src/main/res/layout/seek_bar_preference.xml create mode 100644 app/src/main/res/xml/pref_appearance.xml create mode 100644 app/src/main/res/xml/pref_overview.xml diff --git a/app/build.gradle b/app/build.gradle index 4502d0f3e..ca930cc2c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -148,6 +148,8 @@ dependencies { // UI Libs compile 'com.bignerdranch.android:expandablerecyclerview:2.0.4' + compile 'com.fnp:material-preferences:0.1.4' + compile 'com.pavelsikun:material-seekbar-preference:0.12.1+' compile(name:'library-release', ext:'aar') compile('com.mikepenz:materialdrawer:5.0.0.b27-SNAPSHOT@aar') { transitive = true } compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') { transitive = true } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 706f21623..fccfadc5d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,7 +23,6 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.kuschku.quasseldroid_ng"> - <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.INTERNET" /> <application @@ -63,17 +62,25 @@ <activity android:name=".ui.setup.AccountSetupActivity" - android:label="Setup a new Account" + android:label="Account Setup" android:launchMode="singleTask" android:parentActivityName=".ui.setup.AccountSelectActivity" android:theme="@style/SetupTheme" /> <activity android:name=".ui.setup.AccountSelectActivity" - android:label="Select an Account" + android:label="Account Selection" android:launchMode="singleTask" android:parentActivityName=".ui.LoginActivity" android:theme="@style/SetupTheme" /> + + <activity + android:name=".ui.settings.SettingsActivity" + android:label="Settings" + android:launchMode="singleTask" + android:parentActivityName=".ui.chat.MainActivity" + android:theme="@style/AppTheme.Light" /> + </application> </manifest> diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/service/ClientBackgroundThread.java b/app/src/main/java/de/kuschku/quasseldroid_ng/service/ClientBackgroundThread.java index 82a79a6f9..08db2fe2f 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/service/ClientBackgroundThread.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/service/ClientBackgroundThread.java @@ -35,7 +35,7 @@ import de.kuschku.libquassel.events.GeneralErrorEvent; import de.kuschku.libquassel.events.LoginRequireEvent; import de.kuschku.libquassel.localtypes.backlogstorage.MemoryBacklogStorage; import de.kuschku.libquassel.protocols.RemotePeer; -import de.kuschku.quasseldroid_ng.ui.chat.Settings; +import de.kuschku.quasseldroid_ng.ui.settings.Settings; import de.kuschku.util.CompatibilityUtils; import de.kuschku.util.accounts.Account; import de.kuschku.util.accounts.AccountManager; @@ -94,7 +94,7 @@ public class ClientBackgroundThread implements Runnable { public void onEvent(LoginRequireEvent event) { if (!event.failedLast) { - Account account = manager.account(settings.lastAccount.get()); + Account account = manager.account(settings.preferenceLastAccount.get()); client().client.login(account.user, account.pass); } } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/LoginActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/LoginActivity.java index c690cd62b..94900ce8f 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/LoginActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/LoginActivity.java @@ -27,8 +27,8 @@ import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import de.kuschku.quasseldroid_ng.ui.chat.MainActivity; -import de.kuschku.quasseldroid_ng.ui.chat.Settings; import de.kuschku.quasseldroid_ng.ui.chat.util.ServiceHelper; +import de.kuschku.quasseldroid_ng.ui.settings.Settings; import de.kuschku.quasseldroid_ng.ui.setup.AccountSelectActivity; import de.kuschku.quasseldroid_ng.ui.theme.AppContext; @@ -57,16 +57,16 @@ public class LoginActivity extends AppCompatActivity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { - context.settings().lastAccount.set(data.getBundleExtra("extra").getString("account")); + context.settings().preferenceLastAccount.set(data.getBundleExtra("extra").getString("account")); checkReady(); firstStart = true; - } else if (context.settings().lastAccount.get().isEmpty()) { + } else if (context.settings().preferenceLastAccount.get().isEmpty()) { finish(); } } private boolean checkReady() { - if (context.settings().lastAccount.get().isEmpty()) { + if (context.settings().preferenceLastAccount.get().isEmpty()) { Intent intent = new Intent(this, AccountSelectActivity.class); startActivityForResult(intent, 0); firstStart = true; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChannelDetailActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChannelDetailActivity.java index 05746007d..83101e46a 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChannelDetailActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChannelDetailActivity.java @@ -34,6 +34,7 @@ import android.widget.TextView; import butterknife.Bind; import butterknife.ButterKnife; +import de.kuschku.libquassel.client.Client; import de.kuschku.libquassel.events.GeneralErrorEvent; import de.kuschku.libquassel.localtypes.buffers.ChannelBuffer; import de.kuschku.libquassel.syncables.types.interfaces.QIrcChannel; @@ -71,7 +72,10 @@ public class ChannelDetailActivity extends BoundActivity { protected void onConnectToThread(@Nullable ClientBackgroundThread thread) { super.onConnectToThread(thread); - ChannelBuffer buffer = (ChannelBuffer) context.client().bufferManager().buffer(this.buffer); + Client client = context.client(); + if (client == null) return; + + ChannelBuffer buffer = (ChannelBuffer) client.bufferManager().buffer(this.buffer); if (buffer == null) return; QIrcChannel channel = buffer.getChannel(); @@ -112,10 +116,10 @@ public class ChannelDetailActivity extends BoundActivity { TextView description = (TextView) v.findViewById(R.id.description); TextView value = (TextView) v.findViewById(R.id.value); - String modeName = context.themeUtil().translations.chanModeToName(mode); + String modeName = context.themeUtil().chanModes.chanModeToName(mode); name.setText(String.format("%s (+%s)", modeName, c)); - String modeDescription = context.themeUtil().translations.chanModeToDescription(mode); + String modeDescription = context.themeUtil().chanModes.chanModeToDescription(mode); description.setText(modeDescription); String modeValue = channel.modeValue(c); diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java index fb0caa1bf..85595c7b9 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java @@ -70,6 +70,7 @@ import de.kuschku.quasseldroid_ng.ui.chat.drawer.BufferViewConfigAdapter; 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.Status; +import de.kuschku.quasseldroid_ng.ui.settings.SettingsActivity; import de.kuschku.util.accounts.Account; import de.kuschku.util.accounts.AccountManager; import de.kuschku.util.certificates.CertificateUtils; @@ -210,13 +211,16 @@ public class MainActivity extends BoundActivity { case R.id.action_reauth: reauth(); return true; + case R.id.action_settings: + startActivity(new Intent(this, SettingsActivity.class)); + return true; default: return super.onOptionsItemSelected(item); } } private void reauth() { - context.settings().lastAccount.set(""); + context.settings().preferenceLastAccount.set(""); stopConnection(); finish(); } @@ -318,7 +322,7 @@ public class MainActivity extends BoundActivity { protected void onConnectToThread(@Nullable ClientBackgroundThread thread) { super.onConnectToThread(thread); if (thread == null) - connectToServer(manager.account(context.settings().lastAccount.get())); + connectToServer(manager.account(context.settings().preferenceLastAccount.get())); else { if (context.client() != null && context.client().connectionStatus() == ConnectionChangeEvent.Status.CONNECTED) { onConnected(); @@ -434,7 +438,7 @@ public class MainActivity extends BoundActivity { String username = usernameField.getText().toString(); String password = passwordField.getText().toString(); - Account account = manager.account(context.settings().lastAccount.get()); + Account account = manager.account(context.settings().preferenceLastAccount.get()); manager.update(account.withLoginData(username, password)); }) .cancelListener(dialog1 -> finish()) diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/Settings.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/Settings.java deleted file mode 100644 index 304d2a760..000000000 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/Settings.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.ui.chat; - -import android.content.Context; -import android.content.SharedPreferences; - -import de.kuschku.util.backports.Objects; -import de.kuschku.util.preferences.BooleanPreference; -import de.kuschku.util.preferences.IntPreference; -import de.kuschku.util.preferences.StringPreference; - -public class Settings { - public final StringPreference lastAccount; - - public final IntPreference textSize; - - public final BooleanPreference mircColors; - - public final BooleanPreference fullHostmask; - - public final StringPreference theme; - - public Settings(SharedPreferences pref) { - this.lastAccount = new StringPreference(pref, "lastAccount", ""); - this.textSize = new IntPreference(pref, "textSize", 2); - this.mircColors = new BooleanPreference(pref, "mircColors", true); - this.fullHostmask = new BooleanPreference(pref, "fullHostmask", false); - this.theme = new StringPreference(pref, "theme", "QUASSEL_LIGHT"); - - pref.registerOnSharedPreferenceChangeListener((preferences, key) -> { - if (Objects.equals(key, "lastAccount")) lastAccount.change(); - if (Objects.equals(key, "textSize")) textSize.change(); - if (Objects.equals(key, "mircColors")) mircColors.change(); - if (Objects.equals(key, "fullHostmask")) fullHostmask.change(); - if (Objects.equals(key, "theme")) theme.change(); - }); - } - - public Settings(Context ctx) { - this(ctx.getSharedPreferences("de.kuschku.quasseldroid_ng", 0)); - } -} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/ChatMessageRenderer.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/ChatMessageRenderer.java index c01de5b24..48ede6dd5 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/ChatMessageRenderer.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/chatview/ChatMessageRenderer.java @@ -99,7 +99,7 @@ public class ChatMessageRenderer { @NonNull private CharSequence formatNick(@NonNull String hostmask) { - return formatNick(hostmask, context.settings().fullHostmask.or(false)); + return formatNick(hostmask, context.settings().preferenceHostmask.or(false)); } @NonNull diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewHolder.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewHolder.java index b2179c9b6..ac61dd2d5 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewHolder.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/BufferViewHolder.java @@ -23,6 +23,7 @@ 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; import android.support.annotation.Nullable; @@ -74,7 +75,7 @@ public class BufferViewHolder extends ChildViewHolder { context.provider().event.registerSticky(this); background = new StateListDrawable(); - background.addState(new int[]{android.R.attr.state_selected}, itemView.getResources().getDrawable(com.mikepenz.materialdrawer.R.color.material_drawer_selected)); + background.addState(new int[]{android.R.attr.state_selected}, new ColorDrawable(context.themeUtil().res.colorSelected)); background.addState(new int[0], UIUtils.getSelectableBackground(itemView.getContext())); } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/util/ServiceHelper.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/util/ServiceHelper.java index 3b810f20f..24a4901c4 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/util/ServiceHelper.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/util/ServiceHelper.java @@ -27,7 +27,7 @@ import android.content.Intent; import android.content.ServiceConnection; import de.kuschku.quasseldroid_ng.service.QuasselService; -import de.kuschku.quasseldroid_ng.ui.chat.Settings; +import de.kuschku.quasseldroid_ng.ui.settings.Settings; import de.kuschku.quasseldroid_ng.ui.theme.AppContext; import de.kuschku.quasseldroid_ng.ui.theme.AppTheme; import de.kuschku.quasseldroid_ng.ui.theme.ThemeUtil; @@ -64,13 +64,14 @@ public class ServiceHelper { context.startService(intent); } - public static void initTheme(AppContext context, Activity activity) { + public static int initTheme(AppContext context, Activity activity) { // Init SharedPreferences Settings settings = new Settings(activity); context.setSettings(settings); // Load Theme from Preferences - AppTheme theme = AppTheme.themeFromString(settings.theme.get()); + AppTheme theme = AppTheme.themeFromString(settings.preferenceTheme.get()); activity.setTheme(theme.themeId); context.setThemeUtil(new ThemeUtil(activity, theme)); + return theme.themeId; } } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/settings/Settings.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/settings/Settings.java new file mode 100644 index 000000000..67a60e18b --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/settings/Settings.java @@ -0,0 +1,68 @@ +/* + * 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.ui.settings; + +import android.content.Context; +import android.content.SharedPreferences; +import android.support.v7.preference.PreferenceManager; + +import de.kuschku.quasseldroid_ng.ui.theme.PreferenceStrings; +import de.kuschku.util.preferences.BooleanPreference; +import de.kuschku.util.preferences.IntPreference; +import de.kuschku.util.preferences.StringPreference; + +public class Settings { + public final StringPreference preferenceLastAccount; + + public final StringPreference preferenceTheme; + public final BooleanPreference preferenceColors; + public final BooleanPreference preferenceBrackets; + public final BooleanPreference preferenceHostmask; + public final BooleanPreference preferenceLag; + public final IntPreference preferenceFontSize; + + public Settings(PreferenceStrings prefs, SharedPreferences pref) { + this.preferenceLastAccount = new StringPreference(pref, prefs.preferenceLastAccount, ""); + + this.preferenceTheme = new StringPreference(pref, prefs.preferenceTheme, "QUASSEL_LIGHT"); + this.preferenceColors = new BooleanPreference(pref, prefs.preferenceColors, true); + this.preferenceBrackets = new BooleanPreference(pref, prefs.preferenceBrackets, false); + this.preferenceHostmask = new BooleanPreference(pref, prefs.preferenceHostmask, false); + this.preferenceLag = new BooleanPreference(pref, prefs.preferenceLag, false); + this.preferenceFontSize = new IntPreference(pref, prefs.preferenceFontSize, 14); + + pref.registerOnSharedPreferenceChangeListener((preferences, key) -> { + if (prefs.preferenceLastAccount.equals(key)) preferenceLastAccount.change(); + + if (prefs.preferenceTheme.equals(key)) preferenceTheme.change(); + if (prefs.preferenceColors.equals(key)) preferenceColors.change(); + if (prefs.preferenceBrackets.equals(key)) preferenceBrackets.change(); + if (prefs.preferenceHostmask.equals(key)) preferenceHostmask.change(); + if (prefs.preferenceLag.equals(key)) preferenceLag.change(); + if (prefs.preferenceFontSize.equals(key)) preferenceFontSize.change(); + }); + } + + public Settings(Context ctx) { + this(new PreferenceStrings(ctx), PreferenceManager.getDefaultSharedPreferences(ctx)); + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/settings/SettingsActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/settings/SettingsActivity.java new file mode 100644 index 000000000..7b27c3baf --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/settings/SettingsActivity.java @@ -0,0 +1,95 @@ +/* + * 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.ui.settings; + +import android.app.FragmentTransaction; +import android.os.Bundle; +import android.preference.PreferenceFragment; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; + +import butterknife.Bind; +import butterknife.ButterKnife; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.quasseldroid_ng.ui.chat.util.ServiceHelper; +import de.kuschku.quasseldroid_ng.ui.theme.AppContext; +import de.kuschku.quasseldroid_ng.ui.theme.AppTheme; + +public class SettingsActivity extends AppCompatActivity { + + AppContext context = new AppContext(); + + @Bind(R.id.toolbar) + Toolbar toolbar; + + int themeid; + + @Override + public void onCreate(Bundle savedInstanceState) { + themeid = ServiceHelper.initTheme(context, this); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_settings); + ButterKnife.bind(this); + + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + setPreferenceFragment(new AppearanceFragment()); + + context.settings().preferenceTheme.addChangeListener(value -> restart()); + } + + @Override + protected void onPause() { + super.onPause(); + } + + @Override + protected void onResume() { + super.onResume(); + if (themeid != AppTheme.resFromString(context.settings().preferenceTheme.get())) + restart(); + } + + public void restart() { + startActivity(getIntent()); + finish(); + overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); + } + + public void setPreferenceFragment(PreferenceFragment preferenceFragment) { + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + transaction.replace(R.id.content_host, preferenceFragment); + transaction.commit(); + } + + public static class AppearanceFragment extends PreferenceFragment { + AppContext context = new AppContext(); + + @Override + public void onCreate(Bundle savedInstanceState) { + ServiceHelper.initTheme(context, getActivity()); + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.pref_appearance); + } + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppContext.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppContext.java index 9cd1af445..28e4161f7 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppContext.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppContext.java @@ -25,7 +25,7 @@ import android.support.annotation.NonNull; import de.kuschku.libquassel.BusProvider; import de.kuschku.libquassel.client.Client; -import de.kuschku.quasseldroid_ng.ui.chat.Settings; +import de.kuschku.quasseldroid_ng.ui.settings.Settings; import de.kuschku.util.irc.format.IrcFormatDeserializer; import de.kuschku.util.irc.format.IrcFormatSerializer; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppTheme.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppTheme.java index 033e43242..7d7578006 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppTheme.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/AppTheme.java @@ -32,6 +32,7 @@ public enum AppTheme { QUASSEL_DARK(R.style.Quassel_Dark), MATERIAL_DARK(R.style.Material_Dark), MATERIAL_LIGHT(R.style.Material_Light), + SOLARIZED_LIGHT(R.style.Solarized_Light), SOLARIZED_DARK(R.style.Solarized_Dark); public final int themeId; @@ -54,6 +55,8 @@ public enum AppTheme { return MATERIAL_LIGHT; case "QUASSEL_DARK": return QUASSEL_DARK; + case "SOLARIZED_LIGHT": + return SOLARIZED_LIGHT; case "SOLARIZED_DARK": return SOLARIZED_DARK; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/PreferenceStrings.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/PreferenceStrings.java new file mode 100644 index 000000000..d172bfeea --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/PreferenceStrings.java @@ -0,0 +1,59 @@ +/* + * 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.ui.theme; + +import android.content.Context; + +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.util.annotationbind.AutoBinder; +import de.kuschku.util.annotationbind.AutoString; + +public class PreferenceStrings { + @AutoString(R.string.preference_last_account) + public String preferenceLastAccount; + + @AutoString(R.string.preference_font_size) + public String preferenceFontSize; + + @AutoString(R.string.preference_theme) + public String preferenceTheme; + + @AutoString(R.string.preference_colors) + public String preferenceColors; + + @AutoString(R.string.preference_brackets) + public String preferenceBrackets; + + @AutoString(R.string.preference_hostmask) + public String preferenceHostmask; + + @AutoString(R.string.preference_lag) + public String preferenceLag; + + public PreferenceStrings(Context wrapper) { + try { + AutoBinder.bind(this, wrapper); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/ThemeUtil.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/ThemeUtil.java index 759bf7441..0c649f6cc 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/ThemeUtil.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/theme/ThemeUtil.java @@ -44,10 +44,16 @@ import de.kuschku.util.ui.SpanFormatter; public class ThemeUtil { @NonNull public final Colors res = new Colors(); + @NonNull public final FormatStrings translations = new FormatStrings(); + + @NonNull + public final ChanModeStrings chanModes = new ChanModeStrings(); + @NonNull public final DateTimeFormatHelper formatter; + @NonNull public final StatusDrawables statusDrawables; @@ -68,6 +74,7 @@ public class ThemeUtil { try { AutoBinder.bind(res, wrapper); AutoBinder.bind(translations, wrapper); + AutoBinder.bind(chanModes, wrapper); } catch (IllegalAccessException e) { e.printStackTrace(); } @@ -125,79 +132,7 @@ public class ThemeUtil { } } - public static class FormatStrings { - @AutoString(R.string.usernameHostmask) - public String usernameHostmask; - - @AutoString(R.string.messagePlain) - public String messagePlain; - - @AutoString(R.string.messageJoin) - public String messageJoin; - - @AutoString(R.string.messagePart) - public String messagePart; - - @AutoString(R.string.messagePartExtra) - public String messagePartExtra; - - @AutoString(R.string.messageQuit) - public String messageQuit; - - @AutoString(R.string.messageQuitExtra) - public String messageQuitExtra; - - @AutoString(R.string.messageKill) - public String messageKill; - - @AutoString(R.string.messageKick) - public String messageKick; - - @AutoString(R.string.messageKickExtra) - public String messageKickExtra; - - @AutoString(R.string.messageMode) - public String messageMode; - - @AutoString(R.string.messageNickSelf) - public String messageNickSelf; - - @AutoString(R.string.messageNickOther) - public String messageNickOther; - - @AutoString(R.string.messageDayChange) - public String messageDaychange; - - @AutoString(R.string.messageAction) - public String messageAction; - - @AutoString(R.string.labelStatusBuffer) - public String titleStatusBuffer; - - @AutoString(R.string.warningCertificate) - public String warningCertificate; - - @AutoString(R.string.statusConnecting) - public String statusConnecting; - - @AutoString(R.string.statusHandshake) - public String statusHandshake; - - @AutoString(R.string.statusInitData) - public String statusInitData; - - @AutoString(R.string.statusBacklog) - public String statusBacklog; - - @AutoString(R.string.statusConnected) - public String statusConnected; - - @AutoString(R.string.statusDisconnected) - public String statusDisconnected; - - @AutoString(R.string.statusWelcome) - public String statusWelcome; - + public static class ChanModeStrings { @AutoString(R.string.chanMode_RESTRICT_TOPIC_NAME) public String chanMode_RESTRICT_TOPIC_NAME; @@ -434,88 +369,6 @@ public class ThemeUtil { public String chanMode_FORWARD_DESCRIPTION; - @NonNull - public CharSequence formatUsername(@NonNull CharSequence nick, @NonNull CharSequence hostmask) { - return SpanFormatter.format(usernameHostmask, nick, hostmask); - } - - @NonNull - public CharSequence formatJoin(@NonNull CharSequence user, @NonNull CharSequence channel) { - return SpanFormatter.format(messageJoin, user, channel); - } - - @NonNull - public CharSequence formatPart(@NonNull CharSequence user, @NonNull CharSequence channel) { - return SpanFormatter.format(messagePart, user, channel); - } - - @NonNull - public CharSequence formatPart(@NonNull CharSequence user, @NonNull CharSequence channel, @Nullable CharSequence reason) { - if (reason == null || reason.length() == 0) return formatPart(user, channel); - - return SpanFormatter.format(messagePartExtra, user, channel, reason); - } - - @NonNull - public CharSequence formatQuit(@NonNull CharSequence user) { - return SpanFormatter.format(messageQuit, user); - } - - @NonNull - public CharSequence formatQuit(@NonNull CharSequence user, @Nullable CharSequence reason) { - if (reason == null || reason.length() == 0) return formatQuit(user); - - return SpanFormatter.format(messageQuitExtra, user, reason); - } - - @NonNull - public CharSequence formatKill(@NonNull CharSequence user, @NonNull CharSequence channel) { - return SpanFormatter.format(messageKill, user, channel); - } - - @NonNull - public CharSequence formatKick(@NonNull CharSequence user, @NonNull CharSequence kicked) { - return SpanFormatter.format(messageKick, user, kicked); - } - - @NonNull - public CharSequence formatKick(@NonNull CharSequence user, @NonNull CharSequence kicked, @Nullable CharSequence reason) { - if (reason == null || reason.length() == 0) return formatKick(user, kicked); - - return SpanFormatter.format(messageKickExtra, user, kicked, reason); - } - - @NonNull - public CharSequence formatMode(@NonNull CharSequence mode, @NonNull CharSequence user) { - return SpanFormatter.format(messageMode, mode, user); - } - - @NonNull - public CharSequence formatNick(@NonNull CharSequence newNick) { - return SpanFormatter.format(messageNickSelf, newNick); - } - - @NonNull - public CharSequence formatNick(@NonNull CharSequence oldNick, @Nullable CharSequence newNick) { - if (newNick == null || newNick.length() == 0) return formatNick(oldNick); - - return SpanFormatter.format(messageNickOther, oldNick, newNick); - } - - @NonNull - public CharSequence formatDayChange(@NonNull CharSequence day) { - return SpanFormatter.format(messageDaychange, day); - } - - @NonNull - public CharSequence formatAction(@NonNull CharSequence user, @NonNull CharSequence channel) { - return SpanFormatter.format(messageAction, user, channel); - } - - @NonNull - public CharSequence formatPlain(@NonNull CharSequence nick, @NonNull CharSequence message) { - return SpanFormatter.format(messagePlain, nick, message); - } public String chanModeToDescription(ChanMode mode) { switch (mode) { @@ -686,6 +539,163 @@ public class ThemeUtil { } } + public static class FormatStrings { + @AutoString(R.string.usernameHostmask) + public String usernameHostmask; + + @AutoString(R.string.messagePlain) + public String messagePlain; + + @AutoString(R.string.messageJoin) + public String messageJoin; + + @AutoString(R.string.messagePart) + public String messagePart; + + @AutoString(R.string.messagePartExtra) + public String messagePartExtra; + + @AutoString(R.string.messageQuit) + public String messageQuit; + + @AutoString(R.string.messageQuitExtra) + public String messageQuitExtra; + + @AutoString(R.string.messageKill) + public String messageKill; + + @AutoString(R.string.messageKick) + public String messageKick; + + @AutoString(R.string.messageKickExtra) + public String messageKickExtra; + + @AutoString(R.string.messageMode) + public String messageMode; + + @AutoString(R.string.messageNickSelf) + public String messageNickSelf; + + @AutoString(R.string.messageNickOther) + public String messageNickOther; + + @AutoString(R.string.messageDayChange) + public String messageDaychange; + + @AutoString(R.string.messageAction) + public String messageAction; + + @AutoString(R.string.labelStatusBuffer) + public String titleStatusBuffer; + + @AutoString(R.string.warningCertificate) + public String warningCertificate; + + @AutoString(R.string.statusConnecting) + public String statusConnecting; + + @AutoString(R.string.statusHandshake) + public String statusHandshake; + + @AutoString(R.string.statusInitData) + public String statusInitData; + + @AutoString(R.string.statusBacklog) + public String statusBacklog; + + @AutoString(R.string.statusConnected) + public String statusConnected; + + @AutoString(R.string.statusDisconnected) + public String statusDisconnected; + + @AutoString(R.string.statusWelcome) + public String statusWelcome; + + @NonNull + public CharSequence formatUsername(@NonNull CharSequence nick, @NonNull CharSequence hostmask) { + return SpanFormatter.format(usernameHostmask, nick, hostmask); + } + + @NonNull + public CharSequence formatJoin(@NonNull CharSequence user, @NonNull CharSequence channel) { + return SpanFormatter.format(messageJoin, user, channel); + } + + @NonNull + public CharSequence formatPart(@NonNull CharSequence user, @NonNull CharSequence channel) { + return SpanFormatter.format(messagePart, user, channel); + } + + @NonNull + public CharSequence formatPart(@NonNull CharSequence user, @NonNull CharSequence channel, @Nullable CharSequence reason) { + if (reason == null || reason.length() == 0) return formatPart(user, channel); + + return SpanFormatter.format(messagePartExtra, user, channel, reason); + } + + @NonNull + public CharSequence formatQuit(@NonNull CharSequence user) { + return SpanFormatter.format(messageQuit, user); + } + + @NonNull + public CharSequence formatQuit(@NonNull CharSequence user, @Nullable CharSequence reason) { + if (reason == null || reason.length() == 0) return formatQuit(user); + + return SpanFormatter.format(messageQuitExtra, user, reason); + } + + @NonNull + public CharSequence formatKill(@NonNull CharSequence user, @NonNull CharSequence channel) { + return SpanFormatter.format(messageKill, user, channel); + } + + @NonNull + public CharSequence formatKick(@NonNull CharSequence user, @NonNull CharSequence kicked) { + return SpanFormatter.format(messageKick, user, kicked); + } + + @NonNull + public CharSequence formatKick(@NonNull CharSequence user, @NonNull CharSequence kicked, @Nullable CharSequence reason) { + if (reason == null || reason.length() == 0) return formatKick(user, kicked); + + return SpanFormatter.format(messageKickExtra, user, kicked, reason); + } + + @NonNull + public CharSequence formatMode(@NonNull CharSequence mode, @NonNull CharSequence user) { + return SpanFormatter.format(messageMode, mode, user); + } + + @NonNull + public CharSequence formatNick(@NonNull CharSequence newNick) { + return SpanFormatter.format(messageNickSelf, newNick); + } + + @NonNull + public CharSequence formatNick(@NonNull CharSequence oldNick, @Nullable CharSequence newNick) { + if (newNick == null || newNick.length() == 0) return formatNick(oldNick); + + return SpanFormatter.format(messageNickOther, oldNick, newNick); + } + + @NonNull + public CharSequence formatDayChange(@NonNull CharSequence day) { + return SpanFormatter.format(messageDaychange, day); + } + + @NonNull + public CharSequence formatAction(@NonNull CharSequence user, @NonNull CharSequence channel) { + return SpanFormatter.format(messageAction, user, channel); + } + + @NonNull + public CharSequence formatPlain(@NonNull CharSequence nick, @NonNull CharSequence message) { + return SpanFormatter.format(messagePlain, nick, message); + } + } + public static class Colors { @AutoColor(android.R.color.transparent) @ColorInt @@ -765,6 +775,10 @@ public class ThemeUtil { @ColorInt public int colorTintHighlight; + @AutoColor(R.attr.material_drawer_selected) + @ColorInt + public int colorSelected; + @AutoDimen(R.attr.actionBarSize) @ColorInt public int actionBarSize; diff --git a/app/src/main/java/de/kuschku/util/irc/format/IrcFormatDeserializer.java b/app/src/main/java/de/kuschku/util/irc/format/IrcFormatDeserializer.java index 68a11672b..dfd3c8a5e 100644 --- a/app/src/main/java/de/kuschku/util/irc/format/IrcFormatDeserializer.java +++ b/app/src/main/java/de/kuschku/util/irc/format/IrcFormatDeserializer.java @@ -119,7 +119,7 @@ public class IrcFormatDeserializer { FormatDescription italic = null; FormatDescription underline = null; FormatDescription color = null; - boolean colorize = context.settings().mircColors.get(); + boolean colorize = context.settings().preferenceColors.get(); // Iterating over every character for (int i = 0; i < str.length(); i++) { diff --git a/app/src/main/java/de/kuschku/util/servicebound/BoundActivity.java b/app/src/main/java/de/kuschku/util/servicebound/BoundActivity.java index 6cecaac28..04165be39 100644 --- a/app/src/main/java/de/kuschku/util/servicebound/BoundActivity.java +++ b/app/src/main/java/de/kuschku/util/servicebound/BoundActivity.java @@ -26,18 +26,21 @@ import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.support.annotation.Nullable; +import android.support.annotation.StyleRes; import android.support.v7.app.AppCompatActivity; import de.kuschku.libquassel.BusProvider; import de.kuschku.quasseldroid_ng.service.ClientBackgroundThread; import de.kuschku.quasseldroid_ng.service.QuasselService; -import de.kuschku.quasseldroid_ng.ui.chat.Settings; import de.kuschku.quasseldroid_ng.ui.chat.util.ServiceHelper; import de.kuschku.quasseldroid_ng.ui.theme.AppContext; +import de.kuschku.quasseldroid_ng.ui.theme.AppTheme; import de.kuschku.util.accounts.Account; public abstract class BoundActivity extends AppCompatActivity { protected AppContext context = new AppContext(); + @StyleRes + private int themeId; private QuasselService.LocalBinder binder; private ServiceConnection connection = new ServiceConnection() { @Override @@ -58,17 +61,21 @@ public abstract class BoundActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - ServiceHelper.initTheme(context, this); - context.withSettings(new Settings(this)); - context.settings().theme.addChangeListener(s -> recreate()); + themeId = ServiceHelper.initTheme(context, this); super.onCreate(savedInstanceState); + context.settings().preferenceTheme.addChangeListener(s -> recreate()); ServiceHelper.startServiceIfNotRunning(this); + ServiceHelper.connectToService(this, connection); } @Override protected void onResume() { super.onResume(); ServiceHelper.connectToService(this, connection); + if (themeId != AppTheme.themeFromString(context.settings().preferenceTheme.get()).themeId) { + finish(); + startActivity(getIntent()); + } } @Override diff --git a/app/src/main/java/de/kuschku/util/servicebound/BoundFragment.java b/app/src/main/java/de/kuschku/util/servicebound/BoundFragment.java index 5d45019a8..7ad88b903 100644 --- a/app/src/main/java/de/kuschku/util/servicebound/BoundFragment.java +++ b/app/src/main/java/de/kuschku/util/servicebound/BoundFragment.java @@ -31,7 +31,6 @@ import android.support.v4.app.Fragment; import de.kuschku.libquassel.BusProvider; import de.kuschku.quasseldroid_ng.service.ClientBackgroundThread; import de.kuschku.quasseldroid_ng.service.QuasselService; -import de.kuschku.quasseldroid_ng.ui.chat.Settings; import de.kuschku.quasseldroid_ng.ui.chat.util.ServiceHelper; import de.kuschku.quasseldroid_ng.ui.theme.AppContext; import de.kuschku.util.accounts.Account; @@ -59,7 +58,6 @@ public abstract class BoundFragment extends Fragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { ServiceHelper.initTheme(context, getActivity()); - context.withSettings(new Settings(getActivity())); super.onCreate(savedInstanceState); ServiceHelper.startServiceIfNotRunning(getContext()); } diff --git a/app/src/main/java/de/kuschku/util/ui/preferences/MaterialListPreference.java b/app/src/main/java/de/kuschku/util/ui/preferences/MaterialListPreference.java new file mode 100644 index 000000000..8df813bdc --- /dev/null +++ b/app/src/main/java/de/kuschku/util/ui/preferences/MaterialListPreference.java @@ -0,0 +1,60 @@ +/* + * 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.ui.preferences; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; + +public class MaterialListPreference extends com.afollestad.materialdialogs.prefs.MaterialListPreference { + public MaterialListPreference(Context context) { + super(context); + setSummary(getEntry()); + } + + public MaterialListPreference(Context context, AttributeSet attrs) { + super(context, attrs); + setSummary(getEntry()); + } + + public MaterialListPreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + setSummary(getEntry()); + } + + public MaterialListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + setSummary(getEntry()); + } + + @Override + protected void onDialogClosed(boolean positiveResult) { + super.onDialogClosed(positiveResult); + setSummary(getEntry()); + } + + @Override + protected void onBindView(View view) { + setSummary(getEntry()); + super.onBindView(view); + } +} diff --git a/app/src/main/java/de/kuschku/util/ui/preferences/SeekBarPreference.java b/app/src/main/java/de/kuschku/util/ui/preferences/SeekBarPreference.java new file mode 100644 index 000000000..90a6911a4 --- /dev/null +++ b/app/src/main/java/de/kuschku/util/ui/preferences/SeekBarPreference.java @@ -0,0 +1,224 @@ +/* + * 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.ui.preferences; + +import android.content.Context; +import android.content.res.TypedArray; +import android.preference.Preference; +import android.support.v7.widget.AppCompatSeekBar; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.SeekBar; +import android.widget.SeekBar.OnSeekBarChangeListener; +import android.widget.TextView; + +import de.kuschku.quasseldroid_ng.R; + +public class SeekBarPreference extends Preference implements OnSeekBarChangeListener { + + private static final String ANDROIDNS = "http://schemas.android.com/apk/res/android"; + private static final String APPLICATIONNS = "http://robobunny.com"; + private static final int DEFAULT_VALUE = 50; + private final String TAG = getClass().getName(); + private int mMaxValue = 100; + private int mMinValue = 0; + private int mInterval = 1; + private int mCurrentValue; + private String mUnitsLeft = ""; + private String mUnitsRight = ""; + private AppCompatSeekBar mSeekBar; + + private TextView mStatusText; + + public SeekBarPreference(Context context, AttributeSet attrs) { + super(context, attrs); + initPreference(context, attrs); + } + + public SeekBarPreference(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + initPreference(context, attrs); + } + + private void initPreference(Context context, AttributeSet attrs) { + setValuesFromXml(attrs); + mSeekBar = new AppCompatSeekBar(context, attrs); + mSeekBar.setMax(mMaxValue - mMinValue); + mSeekBar.setOnSeekBarChangeListener(this); + + setWidgetLayoutResource(R.layout.seek_bar_preference); + } + + private void setValuesFromXml(AttributeSet attrs) { + mMaxValue = attrs.getAttributeIntValue(ANDROIDNS, "max", 100); + mMinValue = attrs.getAttributeIntValue(APPLICATIONNS, "min", 0); + + mUnitsLeft = getAttributeStringValue(attrs, APPLICATIONNS, "unitsLeft", ""); + String units = getAttributeStringValue(attrs, APPLICATIONNS, "units", ""); + mUnitsRight = getAttributeStringValue(attrs, APPLICATIONNS, "unitsRight", units); + + try { + String newInterval = attrs.getAttributeValue(APPLICATIONNS, "interval"); + if (newInterval != null) + mInterval = Integer.parseInt(newInterval); + } catch (Exception e) { + Log.e(TAG, "Invalid interval value", e); + } + + } + + private String getAttributeStringValue(AttributeSet attrs, String namespace, String name, String defaultValue) { + String value = attrs.getAttributeValue(namespace, name); + if (value == null) + value = defaultValue; + + return value; + } + + @Override + protected View onCreateView(ViewGroup parent) { + View view = super.onCreateView(parent); + + // The basic preference layout puts the widget frame to the right of the title and summary, + // so we need to change it a bit - the seekbar should be under them. + LinearLayout layout = (LinearLayout) view; + layout.setOrientation(LinearLayout.VERTICAL); + + return view; + } + + @Override + public void onBindView(View view) { + super.onBindView(view); + if (view != null) { + mSeekBar = (AppCompatSeekBar) view.findViewById(R.id.seekBarPrefSeekBar); + mSeekBar.setMax(mMaxValue - mMinValue); + mSeekBar.setOnSeekBarChangeListener(this); + } + + updateView(view); + } + + /** + * Update a SeekBarPreference view with our current state + * + * @param view + */ + protected void updateView(View view) { + + try { + mStatusText = (TextView) view.findViewById(R.id.seekBarPrefValue); + + mStatusText.setText(String.valueOf(mCurrentValue)); + mStatusText.setMinimumWidth(30); + + mSeekBar.setProgress(mCurrentValue - mMinValue); + + } catch (Exception e) { + Log.e(TAG, "Error updating seek bar preference", e); + } + + } + + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + int newValue = progress + mMinValue; + + if (newValue > mMaxValue) + newValue = mMaxValue; + else if (newValue < mMinValue) + newValue = mMinValue; + else if (mInterval != 1 && newValue % mInterval != 0) + newValue = Math.round(((float) newValue) / mInterval) * mInterval; + + // change rejected, revert to the previous value + if (!callChangeListener(newValue)) { + seekBar.setProgress(mCurrentValue - mMinValue); + return; + } + + // change accepted, store it + mCurrentValue = newValue; + mStatusText.setText(String.valueOf(newValue)); + persistInt(newValue); + + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + notifyChanged(); + } + + + @Override + protected Object onGetDefaultValue(TypedArray ta, int index) { + + int defaultValue = ta.getInt(index, DEFAULT_VALUE); + return defaultValue; + + } + + @Override + protected void onSetInitialValue(boolean restoreValue, Object defaultValue) { + + if (restoreValue) { + mCurrentValue = getPersistedInt(mCurrentValue); + } else { + int temp = 0; + try { + temp = (Integer) defaultValue; + } catch (Exception ex) { + Log.e(TAG, "Invalid default value: " + defaultValue.toString()); + } + + persistInt(temp); + mCurrentValue = temp; + } + + } + + /** + * make sure that the seekbar is disabled if the preference is disabled + */ + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + mSeekBar.setEnabled(enabled); + } + + @Override + public void onDependencyChanged(Preference dependency, boolean disableDependent) { + super.onDependencyChanged(dependency, disableDependent); + + //Disable movement of seek bar when dependency is false + if (mSeekBar != null) { + mSeekBar.setEnabled(!disableDependent); + } + } +} diff --git a/app/src/main/res/layout-w720dp/activity_main.xml b/app/src/main/res/layout-w720dp/activity_main.xml index e4836f906..ed2eaaafb 100644 --- a/app/src/main/res/layout-w720dp/activity_main.xml +++ b/app/src/main/res/layout-w720dp/activity_main.xml @@ -39,21 +39,19 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="@style/AppTheme.AppBarOverlay"> + android:theme="?attr/actionBarTheme"> <android.support.v7.widget.Toolbar android:id="@+id/chatListToolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" - android:theme="@style/AppTheme.AppBarOverlay" app:popupTheme="@style/AppTheme.PopupOverlay"> <android.support.v7.widget.AppCompatSpinner android:id="@+id/chatListSpinner" android:layout_width="fill_parent" android:layout_height="match_parent" - android:theme="@style/AppTheme.AppBarOverlay" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.v7.widget.Toolbar> diff --git a/app/src/main/res/layout/activity_channel_detail.xml b/app/src/main/res/layout/activity_channel_detail.xml index 9b08044c7..90a6edf60 100644 --- a/app/src/main/res/layout/activity_channel_detail.xml +++ b/app/src/main/res/layout/activity_channel_detail.xml @@ -29,7 +29,7 @@ android:id="@+id/appBar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="@style/AppTheme.AppBarOverlay"> + android:theme="?attr/actionBarTheme"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" @@ -63,7 +63,8 @@ android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" - android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" /> + android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" + android:textColor="?attr/colorForeground" /> <android.support.v7.widget.AppCompatButton android:id="@+id/edit_topic" @@ -104,11 +105,4 @@ </ScrollView> - <ProgressBar - android:id="@+id/progressBar2" - style="?android:attr/progressBarStyleLarge" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="right" /> - </LinearLayout> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index cd3cc62ad..64bf92f02 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -58,21 +58,21 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="@style/AppTheme.AppBarOverlay"> + android:theme="?attr/actionBarTheme"> <android.support.v7.widget.Toolbar android:id="@+id/chatListToolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" - android:theme="@style/AppTheme.AppBarOverlay" + android:theme="?attr/actionBarTheme" app:popupTheme="@style/AppTheme.PopupOverlay"> <android.support.v7.widget.AppCompatSpinner android:id="@+id/chatListSpinner" android:layout_width="fill_parent" android:layout_height="match_parent" - android:theme="@style/AppTheme.AppBarOverlay" + android:theme="?attr/actionBarTheme" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.v7.widget.Toolbar> diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 000000000..f91e54994 --- /dev/null +++ b/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,47 @@ +<?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="match_parent" + android:background="?attr/colorBackground" + android:orientation="vertical"> + + <android.support.design.widget.AppBarLayout 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="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:background="?attr/colorPrimary" + app:popupTheme="@style/AppTheme.PopupOverlay" /> + + </android.support.design.widget.AppBarLayout> + + <FrameLayout + android:id="@+id/content_host" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> +</LinearLayout> diff --git a/app/src/main/res/layout/seek_bar_preference.xml b/app/src/main/res/layout/seek_bar_preference.xml new file mode 100644 index 000000000..f95ee3aa5 --- /dev/null +++ b/app/src/main/res/layout/seek_bar_preference.xml @@ -0,0 +1,51 @@ +<?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/>. + --> + +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@android:id/widget_frame" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:padding="4dp"> + + <android.support.v7.widget.AppCompatSeekBar + android:id="@+id/seekBarPrefSeekBar" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentEnd="true" + android:layout_alignParentRight="true" + android:layout_centerVertical="true" + android:layout_margin="4dp" + android:layout_toEndOf="@+id/seekBarPrefValue" + android:layout_toRightOf="@+id/seekBarPrefValue" /> + + <TextView + android:id="@+id/seekBarPrefValue" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" + android:layout_centerVertical="true" + android:layout_margin="4dp" + android:gravity="end" + tools:text="16" /> + +</RelativeLayout> diff --git a/app/src/main/res/layout/widget_actionbar.xml b/app/src/main/res/layout/widget_actionbar.xml index 0187f8723..8ef7e3e08 100644 --- a/app/src/main/res/layout/widget_actionbar.xml +++ b/app/src/main/res/layout/widget_actionbar.xml @@ -25,7 +25,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="@style/AppTheme.AppBarOverlay"> + android:theme="?attr/actionBarTheme"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" diff --git a/app/src/main/res/layout/widget_channel_mode.xml b/app/src/main/res/layout/widget_channel_mode.xml index c7a2b5363..6842f07b2 100644 --- a/app/src/main/res/layout/widget_channel_mode.xml +++ b/app/src/main/res/layout/widget_channel_mode.xml @@ -40,20 +40,23 @@ android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textAppearance="@style/Base.TextAppearance.AppCompat.Title" /> + android:textAppearance="@style/Base.TextAppearance.AppCompat.Title" + android:textColor="?attr/colorForeground" /> <TextView android:id="@+id/description" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" /> + android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" + android:textColor="?attr/colorForeground" /> <TextView android:id="@+id/value" - android:layout_marginTop="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginTop="8dp" android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" + android:textColor="?attr/colorForeground" android:visibility="gone" /> </LinearLayout> diff --git a/app/src/main/res/layout/widget_editor.xml b/app/src/main/res/layout/widget_editor.xml index fc8ef8744..a302902e5 100644 --- a/app/src/main/res/layout/widget_editor.xml +++ b/app/src/main/res/layout/widget_editor.xml @@ -49,6 +49,7 @@ android:paddingLeft="20dp" android:paddingRight="20dp" android:paddingTop="17dp" + android:textColor="?attr/colorForeground" android:textSize="16sp" /> </ScrollView> diff --git a/app/src/main/res/menu/chat.xml b/app/src/main/res/menu/chat.xml index 026d4bd0e..734041b96 100644 --- a/app/src/main/res/menu/chat.xml +++ b/app/src/main/res/menu/chat.xml @@ -24,7 +24,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_hide_events" - android:icon="@drawable/ic_filter_dark" + android:icon="?attr/iconFilter" android:title="@string/labelHideEvents" app:showAsAction="ifRoom" /> <item diff --git a/app/src/main/res/menu/chatlist.xml b/app/src/main/res/menu/chatlist.xml index 6011afc63..fefc30cbf 100644 --- a/app/src/main/res/menu/chatlist.xml +++ b/app/src/main/res/menu/chatlist.xml @@ -22,7 +22,7 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item - android:icon="@drawable/ic_plus_dark" + android:icon="?attr/iconAdd" android:title="Join Channel" app:showAsAction="ifRoom" /> <item diff --git a/app/src/main/res/values/preferences.xml b/app/src/main/res/values/preferences.xml index d451c47cb..3b51bbdff 100644 --- a/app/src/main/res/values/preferences.xml +++ b/app/src/main/res/values/preferences.xml @@ -21,22 +21,43 @@ --> <resources> - <string name="preference_theme" translatable="false">selectedtheme</string> + <string name="preference_last_account" translatable="false">preference_last_account</string> + + <string name="preference_font_size" translatable="false">preference_font_size</string> + + <string name="preference_theme" translatable="false">preference_theme</string> <string name="preference_theme_title">Theme</string> + + <string name="preference_colors" translatable="false">preference_colors</string> + <string name="preference_colors_title">Use mIRC Colors</string> + <string name="preference_colors_summary_on"></string> + <string name="preference_colors_summary_off"></string> + + <string name="preference_hostmask" translatable="false">preference_hostname</string> + <string name="preference_hostmask_title">Show Hostmask in Messages</string> + <string name="preference_hostmask_summary_on"></string> + <string name="preference_hostmask_summary_off"></string> + + <string name="preference_lag" translatable="false">preference_lag</string> + <string name="preference_lag_title">Show Connection Lag</string> + <string name="preference_lag_summary_on"></string> + <string name="preference_lag_summary_off"></string> + + <string name="preference_brackets" translatable="false">preference_brackets</string> + <string name="preference_brackets_title">Classical Nick Style</string> + <string name="preference_brackets_summary_on"></string> + <string name="preference_brackets_summary_off"></string> + <string-array name="preference_theme_entries"> - <item>Google® Material (Light)</item> - <item>Google® Material (Dark)</item> <item>Quassel™ (Light)</item> <item>Quassel™ (Dark)</item> - <!--<item>Solarized (Light)</item>--> + <item>Solarized (Light)</item> <item>Solarized (Dark)</item> </string-array> <string-array name="preference_theme_values"> - <item>MATERIAL_LIGHT</item> - <item>MATERIAL_DARK</item> <item>QUASSEL_LIGHT</item> <item>QUASSEL_DARK</item> - <!--<item>SOLARIZED_LIGHT</item>--> + <item>SOLARIZED_LIGHT</item> <item>SOLARIZED_DARK</item> </string-array> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c516e4a73..f8d3cc3d4 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -30,13 +30,16 @@ <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="colorAccentFocus">@color/colorAccentFocus</item> + <item name="actionBarTheme">@style/AppTheme.AppBarOverlay</item> <item name="windowActionModeOverlay">true</item> + <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> <item name="material_drawer_background">?attr/colorBackground</item> <item name="material_drawer_primary_text">?attr/colorForeground</item> <item name="material_drawer_primary_icon">?attr/colorForeground</item> <item name="material_drawer_secondary_text">?attr/colorForegroundSecondary</item> + <item name="material_drawer_selected">#26ffffff</item> <item name="iconFormatBold">@drawable/ic_format_bold_dark</item> <item name="iconFormatItalic">@drawable/ic_format_italic_dark</item> @@ -59,13 +62,16 @@ <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="colorAccentFocus">@color/colorAccentFocus</item> + <item name="actionBarTheme">@style/AppTheme.AppBarOverlay</item> <item name="windowActionModeOverlay">true</item> + <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> <item name="material_drawer_background">?attr/colorBackground</item> <item name="material_drawer_primary_text">?attr/colorForeground</item> <item name="material_drawer_primary_icon">?attr/colorForeground</item> <item name="material_drawer_secondary_text">?attr/colorForegroundSecondary</item> + <item name="material_drawer_selected">#26000000</item> <item name="iconFormatBold">@drawable/ic_format_bold_light</item> <item name="iconFormatItalic">@drawable/ic_format_italic_light</item> @@ -90,6 +96,8 @@ <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="colorAccentFocus">@color/colorAccentFocus</item> + <item name="actionBarTheme">@style/AppTheme.AppBarOverlay</item> + <item name="windowActionModeOverlay">true</item> </style> @@ -97,7 +105,49 @@ <item name="colorControlHighlight">?attr/colorAccentFocus</item> </style> - <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> + <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"> + <item name="colorControlNormal">#ffffff</item> + <item name="android:textColorPrimary">#ffffff</item> + <item name="drawerArrowStyle">@style/DrawerArrowToggle</item> + + <item name="iconFormatBold">@drawable/ic_format_bold_dark</item> + <item name="iconFormatItalic">@drawable/ic_format_italic_dark</item> + <item name="iconFormatUnderline">@drawable/ic_format_underline_dark</item> + <item name="iconFormatPaint">@drawable/ic_format_paint_dark</item> + <item name="iconFormatFill">@drawable/ic_format_fill_dark</item> + <item name="iconHistory">@drawable/ic_history_dark</item> + <item name="iconDebug">@drawable/ic_bug_dark</item> + <item name="iconFilter">@drawable/ic_filter_dark</item> + <item name="iconModify">@drawable/ic_pencil_dark</item> + <item name="iconDelete">@drawable/ic_delete_dark</item> + <item name="iconAdd">@drawable/ic_plus_dark</item> + </style> + + <style name="AppTheme.AppBarOverlay.Light" parent="ThemeOverlay.AppCompat.ActionBar"> + <item name="colorControlNormal">#727272</item> + <item name="android:textColorPrimary">#727272</item> + <item name="drawerArrowStyle">@style/DrawerArrowToggle.Light</item> + + <item name="iconFormatBold">@drawable/ic_format_bold_light</item> + <item name="iconFormatItalic">@drawable/ic_format_italic_light</item> + <item name="iconFormatUnderline">@drawable/ic_format_underline_light</item> + <item name="iconFormatPaint">@drawable/ic_format_paint_light</item> + <item name="iconFormatFill">@drawable/ic_format_fill_light</item> + <item name="iconHistory">@drawable/ic_history_light</item> + <item name="iconDebug">@drawable/ic_bug_light</item> + <item name="iconFilter">@drawable/ic_filter_light</item> + <item name="iconModify">@drawable/ic_pencil_light</item> + <item name="iconDelete">@drawable/ic_delete_light</item> + <item name="iconAdd">@drawable/ic_plus_light</item> + </style> + + <style name="DrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle"> + <item name="color">?attr/colorControlNormal</item> + </style> + + <style name="DrawerArrowToggle.Light" parent="Widget.AppCompat.DrawerArrowToggle"> + <item name="color">?attr/colorControlNormal</item> + </style> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> </resources> diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index ade8a8d16..96528bf4e 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -221,6 +221,62 @@ <item name="colorTintHighlight">#ff8811</item> </style> + <style name="Solarized_Light" parent="AppTheme.Light"> + <item name="colorPrimary">?attr/colorBackgroundCard</item> + <item name="colorPrimaryDark">#b0ac9e</item> + <item name="colorAccent">#B58900</item> + <item name="colorAccentFocus">#40B58900</item> + <item name="actionBarTheme">@style/AppTheme.AppBarOverlay.Light</item> + + <item name="senderColor0">#B58900</item> + <item name="senderColor1">#CB4B16</item> + <item name="senderColor2">#DC322f</item> + <item name="senderColor3">#D33682</item> + <item name="senderColor4">#6C71C4</item> + <item name="senderColor5">#268BD2</item> + <item name="senderColor6">#2AA198</item> + <item name="senderColor7">#859900</item> + <item name="senderColor8">#D5A920</item> + <item name="senderColor9">#EB6B36</item> + <item name="senderColorA">#FC524f</item> + <item name="senderColorB">#F356A2</item> + <item name="senderColorC">#8C91E4</item> + <item name="senderColorD">#46ABF2</item> + <item name="senderColorE">#4AC1B8</item> + <item name="senderColorF">#657900</item> + + <item name="mircColor0">#ffffff</item> + <item name="mircColor1">#000000</item> + <item name="mircColor2">#1155aa</item> + <item name="mircColor3">#008000</item> + <item name="mircColor4">#ff0000</item> + <item name="mircColor5">#800000</item> + <item name="mircColor6">#800080</item> + <item name="mircColor7">#ffa500</item> + <item name="mircColor8">#ffff00</item> + <item name="mircColor9">#00ff00</item> + <item name="mircColorA">#008080</item> + <item name="mircColorB">#00ffff</item> + <item name="mircColorC">#1155ff</item> + <item name="mircColorD">#ff00ff</item> + <item name="mircColorE">#808080</item> + <item name="mircColorF">#c0c0c0</item> + + <item name="colorForeground">#839495</item> + <item name="colorForegroundHighlight">#839495</item> + <item name="colorForegroundSecondary">#576A66</item> + <item name="colorForegroundAction">#268BD2</item> + + <item name="colorBackground">#FDF6E3</item> + <item name="colorBackgroundHighlight">#268bd2</item> + <item name="colorBackgroundSecondary">#FDF6E3</item> + <item name="colorBackgroundCard">#EEE8D5</item> + + <item name="colorTintActivity">#88cc33</item> + <item name="colorTintMessage">#2277dd</item> + <item name="colorTintHighlight">#ff8811</item> + </style> + <style name="Solarized_Dark" parent="AppTheme"> <item name="colorPrimary">?attr/colorBackgroundCard</item> <item name="colorPrimaryDark">?attr/colorBackground</item> diff --git a/app/src/main/res/xml/pref_appearance.xml b/app/src/main/res/xml/pref_appearance.xml new file mode 100644 index 000000000..b80318bac --- /dev/null +++ b/app/src/main/res/xml/pref_appearance.xml @@ -0,0 +1,55 @@ +<?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/>. + --> + +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + + <de.kuschku.util.ui.preferences.MaterialListPreference + android:defaultValue="QUASSEL_LIGHT" + android:entries="@array/preference_theme_entries" + android:entryValues="@array/preference_theme_values" + android:key="@string/preference_theme" + android:title="@string/preference_theme_title" /> + + <SwitchPreference + android:key="@string/preference_colors" + android:summaryOff="@string/preference_colors_summary_off" + android:summaryOn="@string/preference_colors_summary_on" + android:title="@string/preference_colors_title" /> + + <SwitchPreference + android:key="@string/preference_hostmask" + android:summaryOff="@string/preference_hostmask_summary_off" + android:summaryOn="@string/preference_hostmask_summary_on" + android:title="@string/preference_hostmask_title" /> + + <SwitchPreference + android:key="@string/preference_lag" + android:summaryOff="@string/preference_lag_summary_off" + android:summaryOn="@string/preference_lag_summary_on" + android:title="@string/preference_lag_title" /> + + <SwitchPreference + android:key="@string/preference_brackets" + android:summaryOff="@string/preference_brackets_summary_off" + android:summaryOn="@string/preference_brackets_summary_on" + android:title="@string/preference_brackets_title" /> + +</PreferenceScreen> diff --git a/app/src/main/res/xml/pref_overview.xml b/app/src/main/res/xml/pref_overview.xml new file mode 100644 index 000000000..d997aef11 --- /dev/null +++ b/app/src/main/res/xml/pref_overview.xml @@ -0,0 +1,32 @@ +<?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/>. + --> + +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + + <PreferenceScreen android:title="About"> + + <Preference + android:summary="@string/appDescriptionLong" + android:title="@string/app_name" /> + + </PreferenceScreen> + +</PreferenceScreen> -- GitLab