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

Minor cleanup

parent 712dc4f2
Branches
Tags
No related merge requests found
Pipeline #
Showing
with 36 additions and 60 deletions
......@@ -5,8 +5,6 @@
/.idea/
.DS_Store
/captures
.externalNativeBuild
build/
/reports/
/persistence/schemas/
/deploy.sh
......@@ -29,7 +29,6 @@ import de.kuschku.malheur.CrashHandler
import de.kuschku.quasseldroid.dagger.DaggerAppComponent
import de.kuschku.quasseldroid.persistence.AccountDatabase
import de.kuschku.quasseldroid.persistence.LegacyAccountDatabase
import de.kuschku.quasseldroid.persistence.QuasselDatabase
import de.kuschku.quasseldroid.settings.AppearanceSettings
import de.kuschku.quasseldroid.settings.SettingsMigration
import de.kuschku.quasseldroid.settings.SettingsMigrationManager
......
......@@ -616,7 +616,7 @@ class ChatActivity : ServiceBoundActivity(), SharedPreferences.OnSharedPreferenc
onNewIntent(intent)
}
var bufferData: BufferData? = null
private var bufferData: BufferData? = null
var actionMode: ActionMode? = null
private var statusBarColor: Int? = null
......
......@@ -79,13 +79,13 @@ class ClientSettingsFragment : DaggerPreferenceFragmentCompat(),
}
}
fun updateSummary(preference: Preference) {
private fun updateSummary(preference: Preference) {
if (preference is ListPreference) {
preference.summary = preference.entry
}
}
fun initSummary(preference: Preference) {
private fun initSummary(preference: Preference) {
if (preference is PreferenceGroup) {
(0 until preference.preferenceCount).asSequence().map(preference::getPreference).forEach(::initSummary)
} else {
......
......@@ -30,7 +30,7 @@ class AndroidHandlerThread(name: String) : HandlerThread(name) {
private var handler: Handler? =
null
fun started(): AndroidHandlerThread {
private fun started(): AndroidHandlerThread {
onCreate()
return this
}
......
......@@ -11,7 +11,7 @@ import de.kuschku.quasseldroid.util.ui.TextDrawable
import de.kuschku.quasseldroid.viewmodel.EditorViewModel
class ColorContext(context: Context, private val messageSettings: MessageSettings) {
val senderColors = context.theme.styledAttributes(
private val senderColors = context.theme.styledAttributes(
R.attr.senderColor0, R.attr.senderColor1, R.attr.senderColor2, R.attr.senderColor3,
R.attr.senderColor4, R.attr.senderColor5, R.attr.senderColor6, R.attr.senderColor7,
R.attr.senderColor8, R.attr.senderColor9, R.attr.senderColorA, R.attr.senderColorB,
......@@ -22,15 +22,15 @@ class ColorContext(context: Context, private val messageSettings: MessageSetting
}
}
val selfColor = context.theme.styledAttributes(R.attr.colorForegroundSecondary) {
private val selfColor = context.theme.styledAttributes(R.attr.colorForegroundSecondary) {
getColor(0, 0)
}
val textColor = context.theme.styledAttributes(R.attr.colorBackground) {
private val textColor = context.theme.styledAttributes(R.attr.colorBackground) {
getColor(0, 0)
}
val radius = context.resources.getDimensionPixelSize(R.dimen.avatar_radius)
private val radius = context.resources.getDimensionPixelSize(R.dimen.avatar_radius)
fun prepareTextDrawable(@ColorInt textColor: Int = this.textColor) =
......
......@@ -25,7 +25,8 @@ import com.bumptech.glide.signature.ObjectKey
import de.kuschku.quasseldroid.viewmodel.data.Avatar
import java.io.InputStream
class MatrixModelLoader(val api: MatrixApi) : ModelLoader<Avatar.MatrixAvatar, InputStream> {
class MatrixModelLoader(private val api: MatrixApi) :
ModelLoader<Avatar.MatrixAvatar, InputStream> {
override fun buildLoadData(model: Avatar.MatrixAvatar, width: Int, height: Int,
options: Options): ModelLoader.LoadData<InputStream>? {
return ModelLoader.LoadData(ObjectKey(model), MatrixDataFetcher(model, api))
......
......@@ -42,7 +42,7 @@ import org.intellij.lang.annotations.Language
import javax.inject.Inject
class ContentFormatter @Inject constructor(
private val context: Context,
context: Context,
private val ircFormatDeserializer: IrcFormatDeserializer,
private val messageSettings: MessageSettings
) {
......
......@@ -33,7 +33,7 @@ import javax.inject.Inject
* color and format codes
*/
class IrcFormatDeserializer @Inject constructor(context: Context) {
val mircColors = listOf(
private val mircColors = listOf(
R.color.mircColor00, R.color.mircColor01, R.color.mircColor02, R.color.mircColor03,
R.color.mircColor04, R.color.mircColor05, R.color.mircColor06, R.color.mircColor07,
R.color.mircColor08, R.color.mircColor09, R.color.mircColor10, R.color.mircColor11,
......@@ -64,7 +64,7 @@ class IrcFormatDeserializer @Inject constructor(context: Context) {
/**
* Function to handle mIRC formatted strings
*
* @param str mIRC formatted String
* @param content mIRC formatted String
* @return a CharSequence with Android’s span format representing the input string
*/
fun formatString(content: String?, colorize: Boolean): CharSequence {
......
......@@ -30,7 +30,7 @@ import java.util.*
import javax.inject.Inject
class IrcFormatSerializer @Inject constructor(context: Context) {
val mircColors = listOf(
private val mircColors = listOf(
R.color.mircColor00, R.color.mircColor01, R.color.mircColor02, R.color.mircColor03,
R.color.mircColor04, R.color.mircColor05, R.color.mircColor06, R.color.mircColor07,
R.color.mircColor08, R.color.mircColor09, R.color.mircColor10, R.color.mircColor11,
......
......@@ -440,8 +440,8 @@ public class BetterLinkMovementMethod extends LinkMovementMethod {
* A wrapper to support all {@link ClickableSpan}s that may or may not provide URLs.
*/
protected static class ClickableSpanWithText {
private ClickableSpan span;
private String text;
private final ClickableSpan span;
private final String text;
private ClickableSpanWithText(ClickableSpan span, String text) {
this.span = span;
......
......@@ -26,7 +26,6 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.RestrictTo;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
......@@ -44,8 +43,6 @@ import com.afollestad.materialdialogs.MaterialDialog;
import de.kuschku.quasseldroid.R;
import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP;
/**
* Abstract base class which presents a dialog associated with a
* {@link android.support.v7.preference.DialogPreference}. Since the preference object may
......@@ -208,10 +205,7 @@ public abstract class PreferenceDialogFragmentCompat extends DialogFragment impl
* Returns whether the preference needs to display a soft input method when the dialog
* is displayed. Default is false. Subclasses should override this method if they need
* the soft input method brought up automatically.
*
* @hide
*/
@RestrictTo(LIBRARY_GROUP)
protected boolean needInputMethod() {
return false;
}
......
......@@ -29,7 +29,7 @@ import android.text.TextUtils
import android.util.AttributeSet
import de.kuschku.quasseldroid.R
class RingtonePreference : DialogPreference,
open class RingtonePreference : DialogPreference,
RequiresActivityLauncher,
OnActivityResultListener {
private val TAG = "RingtonePreference"
......
......@@ -24,7 +24,7 @@ import de.kuschku.libquassel.util.flag.Flag
import de.kuschku.libquassel.util.flag.Flags
import org.threeten.bp.Instant
class Message(
data class Message(
val messageId: MsgId,
val time: Instant,
val type: Message_Types,
......@@ -86,24 +86,4 @@ class Message(
override fun toString(): String {
return "Message(messageId=$messageId, time=$time, type=$type, flag=$flag, bufferInfo=$bufferInfo, sender='$sender', senderPrefixes='$senderPrefixes', content='$content')"
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Message
if (messageId != other.messageId) return false
if (time != other.time) return false
if (type != other.type) return false
if (flag != other.flag) return false
if (bufferInfo != other.bufferInfo) return false
if (sender != other.sender) return false
if (senderPrefixes != other.senderPrefixes) return false
if (realName != other.realName) return false
if (avatarUrl != other.avatarUrl) return false
if (content != other.content) return false
return true
}
}
......@@ -56,7 +56,8 @@ interface ISession : Closeable {
val rpcHandler: RpcHandler?
val initStatus: Observable<Pair<Int, Int>>
fun network(networkId: NetworkId): Network?
fun network(id: NetworkId): Network?
fun identity(id: IdentityId): Identity?
val proxy: SignalProxy
val error: Flowable<Error>
......@@ -93,7 +94,8 @@ interface ISession : Closeable {
override val initStatus: Observable<Pair<Int, Int>> = Observable.just(0 to 0)
override val lag: Observable<Long> = Observable.just(0L)
override fun network(networkId: NetworkId) = null
override fun network(id: NetworkId): Network? = null
override fun identity(id: IdentityId): Identity? = null
override fun login(user: String, pass: String) = Unit
override fun close() = Unit
......
......@@ -38,8 +38,8 @@ import javax.net.ssl.X509TrustManager
class SessionManager(
offlineSession: ISession,
val backlogStorage: BacklogStorage,
val notificationManager: NotificationManager?,
private val backlogStorage: BacklogStorage,
private val notificationManager: NotificationManager?,
val handlerService: HandlerService,
private val disconnectFromCore: () -> Unit,
private val initCallback: (Session) -> Unit,
......@@ -58,7 +58,7 @@ class SessionManager(
private var lastSession: ISession = offlineSession
val state: Observable<ConnectionState> = inProgressSession.switchMap(ISession::state)
val initStatus: Observable<Pair<Int, Int>> = inProgressSession.switchMap(ISession::initStatus)
private val initStatus: Observable<Pair<Int, Int>> = inProgressSession.switchMap(ISession::initStatus)
val session: Observable<ISession> = state.map { connectionState ->
if (connectionState == ConnectionState.CONNECTED)
inProgressSession.value
......@@ -66,8 +66,7 @@ class SessionManager(
lastSession
}
var hasErrored: Boolean = false
private set
private var hasErrored: Boolean = false
val error: Flowable<Error>
get() = inProgressSession
......
......@@ -125,11 +125,11 @@ abstract class QuasselDatabase : RoomDatabase() {
@Query("UPDATE filtered SET filtered = :filtered WHERE accountId = :accountId AND bufferId = :bufferId")
fun setFiltered(accountId: Long, bufferId: Int, filtered: Int)
@Query("SELECT filtered FROM filtered WHERE bufferId = :bufferId AND accountId = :accountId UNION SELECT :default as filtered ORDER BY filtered DESC LIMIT 1")
fun get(accountId: Long, bufferId: Int, default: Int): Int
@Query("SELECT filtered FROM filtered WHERE bufferId = :bufferId AND accountId = :accountId UNION SELECT :defaultValue as filtered ORDER BY filtered DESC LIMIT 1")
fun get(accountId: Long, bufferId: Int, defaultValue: Int): Int
@Query("SELECT filtered FROM filtered WHERE bufferId = :bufferId AND accountId = :accountId UNION SELECT :default as filtered ORDER BY filtered DESC LIMIT 1")
fun listen(accountId: Long, bufferId: Int, default: Int): LiveData<Int>
@Query("SELECT filtered FROM filtered WHERE bufferId = :bufferId AND accountId = :accountId UNION SELECT :defaultValue as filtered ORDER BY filtered DESC LIMIT 1")
fun listen(accountId: Long, bufferId: Int, defaultValue: Int): LiveData<Int>
@Query("SELECT * FROM filtered WHERE accountId = :accountId")
fun listen(accountId: Long): LiveData<List<Filtered>>
......
......@@ -71,7 +71,6 @@ class QuasselViewModel : ViewModel() {
val bufferViewConfigId = BehaviorSubject.createDefault(-1)
val MAX_RECENT_MESSAGES = 20
val recentlySentMessages = BehaviorSubject.createDefault(emptyList<CharSequence>())
fun addRecentlySentMessage(message: CharSequence) {
recentlySentMessages.onNext(
......@@ -523,4 +522,8 @@ class QuasselViewModel : ViewModel() {
}
val bufferListThrottled = bufferList.distinctUntilChanged().throttleLast(100,
TimeUnit.MILLISECONDS)
companion object {
const val MAX_RECENT_MESSAGES = 20
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment