Merge pull request #95 from vector-im/feature/fix_state

RageShake
This commit is contained in:
Benoit Marty 2019-03-29 21:13:14 +01:00 committed by GitHub
commit f75fe1201d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
94 changed files with 5210 additions and 73 deletions

View File

@ -167,7 +167,11 @@ dependencies {
implementation 'androidx.paging:paging-runtime:2.0.0' implementation 'androidx.paging:paging-runtime:2.0.0'


implementation 'com.jakewharton.threetenabp:threetenabp:1.1.1' implementation 'com.jakewharton.threetenabp:threetenabp:1.1.1'

// Log
implementation 'com.jakewharton.timber:timber:4.7.1' implementation 'com.jakewharton.timber:timber:4.7.1'

// Debug
implementation 'com.facebook.stetho:stetho:1.5.0' implementation 'com.facebook.stetho:stetho:1.5.0'


// rx // rx
@ -183,6 +187,9 @@ dependencies {
// FP // FP
implementation "io.arrow-kt:arrow-core:$arrow_version" implementation "io.arrow-kt:arrow-core:$arrow_version"


// Pref
implementation 'androidx.preference:preference:1.0.0'

// UI // UI
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.google.android.material:material:1.1.0-alpha02' implementation 'com.google.android.material:material:1.1.0-alpha02'
@ -190,6 +197,13 @@ dependencies {
implementation "ru.noties.markwon:core:$markwon_version" implementation "ru.noties.markwon:core:$markwon_version"
implementation "ru.noties.markwon:html:$markwon_version" implementation "ru.noties.markwon:html:$markwon_version"


// Butterknife
implementation 'com.jakewharton:butterknife:10.1.0'
kapt 'com.jakewharton:butterknife-compiler:10.1.0'

// Shake detection
implementation 'com.squareup:seismic:1.0.2'

// Image Loading // Image Loading
implementation "com.github.piasy:BigImageViewer:$big_image_viewer_version" implementation "com.github.piasy:BigImageViewer:$big_image_viewer_version"
implementation "com.github.piasy:GlideImageLoader:$big_image_viewer_version" implementation "com.github.piasy:GlideImageLoader:$big_image_viewer_version"

View File

@ -0,0 +1,73 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.receivers

import android.content.*
import android.preference.PreferenceManager
import androidx.core.content.edit
import im.vector.riotredesign.core.utils.lsFiles
import timber.log.Timber

/**
* Receiver to handle some command from ADB
*/
class DebugReceiver : BroadcastReceiver() {

override fun onReceive(context: Context, intent: Intent) {
Timber.d("Received debug action: ${intent.action}")

intent.action?.let {
when {
it.endsWith(DEBUG_ACTION_DUMP_FILESYSTEM) -> lsFiles(context)
it.endsWith(DEBUG_ACTION_DUMP_PREFERENCES) -> dumpPreferences(context)
it.endsWith(DEBUG_ACTION_ALTER_SCALAR_TOKEN) -> alterScalarToken(context)
}
}
}

private fun dumpPreferences(context: Context) {
logPrefs("DefaultSharedPreferences", PreferenceManager.getDefaultSharedPreferences(context))
}

private fun logPrefs(name: String, sharedPreferences: SharedPreferences?) {
Timber.d("SharedPreferences $name:")

sharedPreferences?.let { prefs ->
prefs.all.keys.forEach { key ->
Timber.d("$key : ${prefs.all[key]}")
}
}
}

private fun alterScalarToken(context: Context) {
PreferenceManager.getDefaultSharedPreferences(context).edit {
// putString("SCALAR_TOKEN_PREFERENCE_KEY" + Matrix.getInstance(context).defaultSession.myUserId, "bad_token")
}
}

companion object {
private const val DEBUG_ACTION_DUMP_FILESYSTEM = ".DEBUG_ACTION_DUMP_FILESYSTEM"
private const val DEBUG_ACTION_DUMP_PREFERENCES = ".DEBUG_ACTION_DUMP_PREFERENCES"
private const val DEBUG_ACTION_ALTER_SCALAR_TOKEN = ".DEBUG_ACTION_ALTER_SCALAR_TOKEN"

fun getIntentFilter(context: Context) = IntentFilter().apply {
addAction(context.packageName + DEBUG_ACTION_DUMP_FILESYSTEM)
addAction(context.packageName + DEBUG_ACTION_DUMP_PREFERENCES)
addAction(context.packageName + DEBUG_ACTION_ALTER_SCALAR_TOKEN)
}
}
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="im.vector.riotredesign"> package="im.vector.riotredesign">




@ -7,12 +8,13 @@


<application <application
android:name=".Riot" android:name=".Riot"
android:allowBackup="true" android:allowBackup="false"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Riot"> android:theme="@style/AppTheme.Light"
tools:replace="android:allowBackup">


<activity <activity
android:name=".features.MainActivity" android:name=".features.MainActivity"
@ -27,6 +29,9 @@
<activity android:name=".features.home.HomeActivity" /> <activity android:name=".features.home.HomeActivity" />
<activity android:name=".features.login.LoginActivity" /> <activity android:name=".features.login.LoginActivity" />
<activity android:name=".features.media.MediaViewerActivity" /> <activity android:name=".features.media.MediaViewerActivity" />
<activity
android:name=".features.rageshake.BugReportActivity"
android:label="@string/title_activity_bug_report" />
</application> </application>


</manifest> </manifest>

View File

@ -26,6 +26,8 @@ import com.jakewharton.threetenabp.AndroidThreeTen
import im.vector.matrix.android.api.Matrix import im.vector.matrix.android.api.Matrix
import im.vector.riotredesign.core.di.AppModule import im.vector.riotredesign.core.di.AppModule
import im.vector.riotredesign.features.home.HomeModule import im.vector.riotredesign.features.home.HomeModule
import im.vector.riotredesign.features.rageshake.VectorFileLogger
import im.vector.riotredesign.features.rageshake.VectorUncaughtExceptionHandler
import org.koin.log.EmptyLogger import org.koin.log.EmptyLogger
import org.koin.standalone.StandAloneContext.startKoin import org.koin.standalone.StandAloneContext.startKoin
import timber.log.Timber import timber.log.Timber
@ -35,10 +37,17 @@ class Riot : Application() {


override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()

VectorUncaughtExceptionHandler.activate(this)

// Log
VectorFileLogger.init(this)
Timber.plant(Timber.DebugTree(), VectorFileLogger)

if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
Stetho.initializeWithDefaults(this) Stetho.initializeWithDefaults(this)
} }

AndroidThreeTen.init(this) AndroidThreeTen.init(this)
BigImageViewer.initialize(GlideImageLoader.with(applicationContext)) BigImageViewer.initialize(GlideImageLoader.with(applicationContext))
val appModule = AppModule(applicationContext).definition val appModule = AppModule(applicationContext).definition

View File

@ -65,7 +65,7 @@ class AppModule(private val context: Context) {
} }


factory { factory {
Matrix.getInstance().currentSession Matrix.getInstance().currentSession!!
} }





View File

@ -0,0 +1,27 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.core.extensions

import android.os.Bundle
import androidx.fragment.app.Fragment

fun Boolean.toOnOff() = if (this) "ON" else "OFF"

/**
* Apply argument to a Fragment
*/
fun <T : Fragment> T.withArgs(block: Bundle.() -> Unit) = apply { arguments = Bundle().apply(block) }

View File

@ -16,18 +16,56 @@


package im.vector.riotredesign.core.platform package im.vector.riotredesign.core.platform


import android.content.res.Configuration
import android.os.Bundle import android.os.Bundle
import androidx.annotation.MainThread import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.annotation.*
import androidx.appcompat.widget.Toolbar
import butterknife.BindView
import butterknife.ButterKnife
import butterknife.Unbinder
import com.airbnb.mvrx.BaseMvRxActivity import com.airbnb.mvrx.BaseMvRxActivity
import com.bumptech.glide.util.Util import com.bumptech.glide.util.Util
import im.vector.riotredesign.BuildConfig
import im.vector.riotredesign.R
import im.vector.riotredesign.features.rageshake.BugReportActivity
import im.vector.riotredesign.features.rageshake.BugReporter
import im.vector.riotredesign.features.rageshake.RageShake
import im.vector.riotredesign.features.themes.ThemeUtils
import im.vector.riotredesign.receivers.DebugReceiver
import im.vector.ui.themes.ActivityOtherThemes
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import timber.log.Timber



abstract class RiotActivity : BaseMvRxActivity() { abstract class RiotActivity : BaseMvRxActivity() {
/* ==========================================================================================
* UI
* ========================================================================================== */

@Nullable
@BindView(R.id.toolbar)
protected lateinit var toolbar: Toolbar

/* ==========================================================================================
* DATA
* ========================================================================================== */

private var unBinder: Unbinder? = null

private var savedInstanceState: Bundle? = null

// For debug only
private var debugReceiver: DebugReceiver? = null


private val uiDisposables = CompositeDisposable() private val uiDisposables = CompositeDisposable()
private val restorables = ArrayList<Restorable>() private val restorables = ArrayList<Restorable>()


private var rageShake: RageShake? = null

override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
restorables.forEach { it.onSaveInstanceState(outState) } restorables.forEach { it.onSaveInstanceState(outState) }
@ -50,4 +88,185 @@ abstract class RiotActivity : BaseMvRxActivity() {
return this return this
} }


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Shake detector
rageShake = RageShake(this)

ThemeUtils.setActivityTheme(this, getOtherThemes())

doBeforeSetContentView()

if (getLayoutRes() != -1) {
setContentView(getLayoutRes())
}

unBinder = ButterKnife.bind(this)

this.savedInstanceState = savedInstanceState

initUiAndData()

val titleRes = getTitleRes()
if (titleRes != -1) {
supportActionBar?.let {
it.setTitle(titleRes)
} ?: run {
setTitle(titleRes)
}
}
}

override fun onDestroy() {
super.onDestroy()

unBinder?.unbind()
unBinder = null
}

override fun onResume() {
super.onResume()

if (this !is BugReportActivity) {
rageShake?.start()
}

DebugReceiver
.getIntentFilter(this)
.takeIf { BuildConfig.DEBUG }
?.let {
debugReceiver = DebugReceiver()
registerReceiver(debugReceiver, it)
}
}

override fun onPause() {
super.onPause()

rageShake?.stop()

debugReceiver?.let {
unregisterReceiver(debugReceiver)
debugReceiver = null
}
}

override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)

if (hasFocus && displayInFullscreen()) {
setFullScreen()
}
}

override fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean, newConfig: Configuration?) {
super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig)

Timber.w("onMultiWindowModeChanged. isInMultiWindowMode: $isInMultiWindowMode")
BugReporter.inMultiWindowMode = isInMultiWindowMode
}


/* ==========================================================================================
* PRIVATE METHODS
* ========================================================================================== */

/**
* Force to render the activity in fullscreen
*/
private fun setFullScreen() {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
}

/* ==========================================================================================
* MENU MANAGEMENT
* ========================================================================================== */

final override fun onCreateOptionsMenu(menu: Menu): Boolean {
val menuRes = getMenuRes()

if (menuRes != -1) {
menuInflater.inflate(menuRes, menu)
ThemeUtils.tintMenuIcons(menu, ThemeUtils.getColor(this, getMenuTint()))
return true
}

return super.onCreateOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
setResult(RESULT_CANCELED)
finish()
return true
}

return super.onOptionsItemSelected(item)
}

/* ==========================================================================================
* PROTECTED METHODS
* ========================================================================================== */

/**
* Get the saved instance state.
* Ensure {@link isFirstCreation()} returns false before calling this
*
* @return
*/
protected fun getSavedInstanceState(): Bundle {
return savedInstanceState!!
}

/**
* Is first creation
*
* @return true if Activity is created for the first time (and not restored by the system)
*/
protected fun isFirstCreation() = savedInstanceState == null

/**
* Configure the Toolbar. It MUST be present in your layout with id "toolbar"
*/
protected fun configureToolbar() {
setSupportActionBar(toolbar)

supportActionBar?.let {
it.setDisplayShowHomeEnabled(true)
it.setDisplayHomeAsUpEnabled(true)
}
}

/* ==========================================================================================
* OPEN METHODS
* ========================================================================================== */

@LayoutRes
open fun getLayoutRes() = -1

open fun displayInFullscreen() = false

open fun doBeforeSetContentView() = Unit

open fun initUiAndData() = Unit

@StringRes
open fun getTitleRes() = -1

@MenuRes
open fun getMenuRes() = -1

@AttrRes
open fun getMenuTint() = R.attr.vctr_icon_tint_on_dark_action_bar_color

/**
* Return a object containing other themes for this activity
*/
open fun getOtherThemes(): ActivityOtherThemes = ActivityOtherThemes.Default
} }

View File

@ -0,0 +1,89 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.core.utils

import android.content.Context
import timber.log.Timber
import java.io.File

// Implementation should return true in case of success
typealias ActionOnFile = (file: File) -> Boolean

/* ==========================================================================================
* Delete
* ========================================================================================== */

fun deleteAllFiles(context: Context) {
Timber.v("Delete cache dir:")
recursiveActionOnFile(context.cacheDir, ::deleteAction)

Timber.v("Delete files dir:")
recursiveActionOnFile(context.filesDir, ::deleteAction)
}

private fun deleteAction(file: File): Boolean {
if (file.exists()) {
Timber.v("deleteFile: $file")
return file.delete()
}

return true
}

/* ==========================================================================================
* Log
* ========================================================================================== */

fun lsFiles(context: Context) {
Timber.v("Content of cache dir:")
recursiveActionOnFile(context.cacheDir, ::logAction)

Timber.v("Content of files dir:")
recursiveActionOnFile(context.filesDir, ::logAction)
}

private fun logAction(file: File): Boolean {
if (file.isDirectory) {
Timber.d(file.toString())
} else {
Timber.d(file.toString() + " " + file.length() + " bytes")
}
return true
}

/* ==========================================================================================
* Private
* ========================================================================================== */

/**
* Return true in case of success
*/
private fun recursiveActionOnFile(file: File, action: ActionOnFile): Boolean {
if (file.isDirectory) {
file.list().forEach {
val result = recursiveActionOnFile(File(file, it), action)

if (!result) {
// Break the loop
return false
}
}
}

return action.invoke(file)
}

View File

@ -0,0 +1,186 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.core.utils

import android.annotation.TargetApi
import android.app.Activity
import android.content.*
import android.net.Uri
import android.os.Build
import android.os.PowerManager
import android.provider.Settings
import android.widget.Toast
import androidx.fragment.app.Fragment
import im.vector.riotredesign.R
import im.vector.riotredesign.features.settings.VectorLocale
import timber.log.Timber
import java.util.*

/**
* Tells if the application ignores battery optimizations.
*
* Ignoring them allows the app to run in background to make background sync with the homeserver.
* This user option appears on Android M but Android O enforces its usage and kills apps not
* authorised by the user to run in background.
*
* @param context the context
* @return true if battery optimisations are ignored
*/
fun isIgnoringBatteryOptimizations(context: Context): Boolean {
// no issue before Android M, battery optimisations did not exist
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isIgnoringBatteryOptimizations(context.packageName) == true
}

/**
* display the system dialog for granting this permission. If previously granted, the
* system will not show it (so you should call this method).
*
* Note: If the user finally does not grant the permission, PushManager.isBackgroundSyncAllowed()
* will return false and the notification privacy will fallback to "LOW_DETAIL".
*/
@TargetApi(Build.VERSION_CODES.M)
fun requestDisablingBatteryOptimization(activity: Activity, fragment: Fragment?, requestCode: Int) {
val intent = Intent()
intent.action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
intent.data = Uri.parse("package:" + activity.packageName)
if (fragment != null) {
fragment.startActivityForResult(intent, requestCode)
} else {
activity.startActivityForResult(intent, requestCode)
}
}

//==============================================================================================================
// Clipboard helper
//==============================================================================================================

/**
* Copy a text to the clipboard, and display a Toast when done
*
* @param context the context
* @param text the text to copy
*/
fun copyToClipboard(context: Context, text: CharSequence) {
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.primaryClip = ClipData.newPlainText("", text)
context.toast(R.string.copied_to_clipboard)
}

/**
* Provides the device locale
*
* @return the device locale
*/
fun getDeviceLocale(context: Context): Locale {
var locale: Locale

locale = try {
val packageManager = context.packageManager
val resources = packageManager.getResourcesForApplication("android")
resources.configuration.locale
} catch (e: Exception) {
Timber.e(e, "## getDeviceLocale() failed " + e.message)
// Fallback to application locale
VectorLocale.applicationLocale
}

return locale
}

/**
* Shows notification settings for the current app.
* In android O will directly opens the notification settings, in lower version it will show the App settings
*/
fun startNotificationSettingsIntent(fragment: Fragment, requestCode: Int) {
val intent = Intent()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
intent.putExtra(Settings.EXTRA_APP_PACKAGE, fragment.context?.packageName)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
intent.putExtra("app_package", fragment.context?.packageName)
intent.putExtra("app_uid", fragment.context?.applicationInfo?.uid)
} else {
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
intent.addCategory(Intent.CATEGORY_DEFAULT);
val uri = Uri.fromParts("package", fragment.activity?.packageName, null)
intent.data = uri
}
fragment.startActivityForResult(intent, requestCode)
}

// TODO This comes from NotificationUtils
fun supportNotificationChannels() = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)


/**
* Shows notification system settings for the given channel id.
*/
@TargetApi(Build.VERSION_CODES.O)
fun startNotificationChannelSettingsIntent(fragment: Fragment, channelID: String) {
if (!supportNotificationChannels()) return
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS).apply {
putExtra(Settings.EXTRA_APP_PACKAGE, fragment.context?.packageName)
putExtra(Settings.EXTRA_CHANNEL_ID, channelID)
}
fragment.startActivity(intent)
}

fun startAddGoogleAccountIntent(fragment: Fragment, requestCode: Int) {
try {
val intent = Intent(Settings.ACTION_ADD_ACCOUNT)
intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, arrayOf("com.google"))
fragment.startActivityForResult(intent, requestCode)
} catch (activityNotFoundException: ActivityNotFoundException) {
fragment.activity?.toast(R.string.error_no_external_application_found)
}
}

fun startSharePlainTextIntent(fragment: Fragment, chooserTitle: String?, text: String, subject: String? = null) {
val share = Intent(Intent.ACTION_SEND)
share.type = "text/plain"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
share.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
} else {
share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
}
// Add data to the intent, the receiving app will decide what to do with it.
share.putExtra(Intent.EXTRA_SUBJECT, subject)
share.putExtra(Intent.EXTRA_TEXT, text)
try {
fragment.startActivity(Intent.createChooser(share, chooserTitle))
} catch (activityNotFoundException: ActivityNotFoundException) {
fragment.activity?.toast(R.string.error_no_external_application_found)
}
}

fun startImportTextFromFileIntent(fragment: Fragment, requestCode: Int) {
val intent = Intent(Intent.ACTION_GET_CONTENT).apply {
type = "text/plain"
}
if (intent.resolveActivity(fragment.activity!!.packageManager) != null) {
fragment.startActivityForResult(intent, requestCode)
} else {
fragment.activity?.toast(R.string.error_no_external_application_found)
}
}

// Not in KTX anymore
fun Context.toast(resId: Int) {
Toast.makeText(this, resId, Toast.LENGTH_SHORT).show()
}

View File

@ -90,7 +90,7 @@ object AvatarRenderer {
// PRIVATE API ********************************************************************************* // PRIVATE API *********************************************************************************


private fun buildGlideRequest(glideRequest: GlideRequests, avatarUrl: String?, size: Int): GlideRequest<Drawable> { private fun buildGlideRequest(glideRequest: GlideRequests, avatarUrl: String?, size: Int): GlideRequest<Drawable> {
val resolvedUrl = Matrix.getInstance().currentSession val resolvedUrl = Matrix.getInstance().currentSession!!
.contentUrlResolver() .contentUrlResolver()
.resolveThumbnail(avatarUrl, size, size, ContentUrlResolver.ThumbnailMethod.SCALE) .resolveThumbnail(avatarUrl, size, size, ContentUrlResolver.ThumbnailMethod.SCALE)



View File

@ -21,6 +21,7 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
@ -34,6 +35,8 @@ import im.vector.riotredesign.core.platform.OnBackPressed
import im.vector.riotredesign.core.platform.RiotActivity import im.vector.riotredesign.core.platform.RiotActivity
import im.vector.riotredesign.core.platform.ToolbarConfigurable import im.vector.riotredesign.core.platform.ToolbarConfigurable
import im.vector.riotredesign.features.home.room.detail.LoadingRoomDetailFragment import im.vector.riotredesign.features.home.room.detail.LoadingRoomDetailFragment
import im.vector.riotredesign.features.rageshake.BugReporter
import im.vector.riotredesign.features.rageshake.VectorUncaughtExceptionHandler
import kotlinx.android.synthetic.main.activity_home.* import kotlinx.android.synthetic.main.activity_home.*
import org.koin.android.ext.android.inject import org.koin.android.ext.android.inject
import org.koin.android.scope.ext.android.bindScope import org.koin.android.scope.ext.android.bindScope
@ -74,6 +77,21 @@ class HomeActivity : RiotActivity(), ToolbarConfigurable {
super.onDestroy() super.onDestroy()
} }


override fun onResume() {
super.onResume()

if (VectorUncaughtExceptionHandler.didAppCrash(this)) {
VectorUncaughtExceptionHandler.clearAppCrashStatus(this)

AlertDialog.Builder(this)
.setMessage(R.string.send_bug_report_app_crashed)
.setCancelable(false)
.setPositiveButton(R.string.yes) { _, _ -> BugReporter.openBugReportScreen(this) }
.setNegativeButton(R.string.no) { _, _ -> BugReporter.deleteCrashFile(this) }
.show()
}
}

override fun configure(toolbar: Toolbar) { override fun configure(toolbar: Toolbar) {
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
supportActionBar?.setHomeButtonEnabled(true) supportActionBar?.setHomeButtonEnabled(true)

View File

@ -41,7 +41,7 @@ class HomeActivityViewModel(state: EmptyState,


@JvmStatic @JvmStatic
override fun create(viewModelContext: ViewModelContext, state: EmptyState): HomeActivityViewModel? { override fun create(viewModelContext: ViewModelContext, state: EmptyState): HomeActivityViewModel? {
val session = Matrix.getInstance().currentSession val session = Matrix.getInstance().currentSession!!
val roomSelectionRepository = viewModelContext.activity.get<RoomSelectionRepository>() val roomSelectionRepository = viewModelContext.activity.get<RoomSelectionRepository>()
return HomeActivityViewModel(state, session, roomSelectionRepository) return HomeActivityViewModel(state, session, roomSelectionRepository)
} }

View File

@ -63,8 +63,7 @@ class LoginActivity : RiotActivity() {
progressBar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE
authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> { authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> {
override fun onSuccess(data: Session) { override fun onSuccess(data: Session) {
Matrix.getInstance().currentSession = data Matrix.getInstance().currentSession = data.apply { open() }
Matrix.getInstance().currentSession.open()
goToHome() goToHome()
} }



View File

@ -49,7 +49,7 @@ object MediaContentRenderer {
val (width, height) = processSize(data, mode) val (width, height) = processSize(data, mode)
imageView.layoutParams.height = height imageView.layoutParams.height = height
imageView.layoutParams.width = width imageView.layoutParams.width = width
val contentUrlResolver = Matrix.getInstance().currentSession.contentUrlResolver() val contentUrlResolver = Matrix.getInstance().currentSession!!.contentUrlResolver()
val resolvedUrl = when (mode) { val resolvedUrl = when (mode) {
Mode.FULL_SIZE -> contentUrlResolver.resolveFullSize(data.url) Mode.FULL_SIZE -> contentUrlResolver.resolveFullSize(data.url)
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE) Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE)
@ -64,7 +64,7 @@ object MediaContentRenderer {


fun render(data: Data, imageView: BigImageView) { fun render(data: Data, imageView: BigImageView) {
val (width, height) = processSize(data, Mode.THUMBNAIL) val (width, height) = processSize(data, Mode.THUMBNAIL)
val contentUrlResolver = Matrix.getInstance().currentSession.contentUrlResolver() val contentUrlResolver = Matrix.getInstance().currentSession!!.contentUrlResolver()
val fullSize = contentUrlResolver.resolveFullSize(data.url) val fullSize = contentUrlResolver.resolveFullSize(data.url)
val thumbnail = contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE) val thumbnail = contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE)
imageView.showImage( imageView.showImage(

View File

@ -21,7 +21,6 @@ package im.vector.riotredesign.features.media
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator
import com.github.piasy.biv.view.GlideImageViewFactory import com.github.piasy.biv.view.GlideImageViewFactory
@ -54,17 +53,6 @@ class MediaViewerActivity : RiotActivity() {
} }
} }


override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {
finish()
return true
}
}
return true
}


companion object { companion object {


private const val EXTRA_MEDIA_DATA = "EXTRA_MEDIA_DATA" private const val EXTRA_MEDIA_DATA = "EXTRA_MEDIA_DATA"

View File

@ -0,0 +1,209 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.rageshake

import android.text.TextUtils
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.*
import androidx.core.view.isVisible
import butterknife.BindView
import butterknife.OnCheckedChanged
import butterknife.OnTextChanged
import im.vector.riotredesign.R
import im.vector.riotredesign.core.platform.RiotActivity
import timber.log.Timber

/**
* Form to send a bug report
*/
class BugReportActivity : RiotActivity() {

/* ==========================================================================================
* UI
* ========================================================================================== */

@BindView(R.id.bug_report_edit_text)
lateinit var mBugReportText: EditText

@BindView(R.id.bug_report_button_include_logs)
lateinit var mIncludeLogsButton: CheckBox

@BindView(R.id.bug_report_button_include_crash_logs)
lateinit var mIncludeCrashLogsButton: CheckBox

@BindView(R.id.bug_report_button_include_screenshot)
lateinit var mIncludeScreenShotButton: CheckBox

@BindView(R.id.bug_report_screenshot_preview)
lateinit var mScreenShotPreview: ImageView

@BindView(R.id.bug_report_progress_view)
lateinit var mProgressBar: ProgressBar

@BindView(R.id.bug_report_progress_text_view)
lateinit var mProgressTextView: TextView

@BindView(R.id.bug_report_scrollview)
lateinit var mScrollView: View

@BindView(R.id.bug_report_mask_view)
lateinit var mMaskView: View

override fun getLayoutRes() = R.layout.activity_bug_report

override fun initUiAndData() {
configureToolbar()

if (BugReporter.screenshot != null) {
mScreenShotPreview.setImageBitmap(BugReporter.screenshot)
} else {
mScreenShotPreview.isVisible = false
mIncludeScreenShotButton.isChecked = false
mIncludeScreenShotButton.isEnabled = false
}
}

override fun getMenuRes() = R.menu.bug_report

override fun onPrepareOptionsMenu(menu: Menu): Boolean {
menu.findItem(R.id.ic_action_send_bug_report)?.let {
val isValid = mBugReportText.text.toString().trim().length > 10
&& !mMaskView.isVisible

it.isEnabled = isValid
it.icon.alpha = if (isValid) 255 else 100
}

return super.onPrepareOptionsMenu(menu)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.ic_action_send_bug_report -> {
sendBugReport()
return true
}
}
return super.onOptionsItemSelected(item)
}


/**
* Send the bug report
*/
private fun sendBugReport() {
mScrollView.alpha = 0.3f
mMaskView.isVisible = true

invalidateOptionsMenu()

mProgressTextView.isVisible = true
mProgressTextView.text = getString(R.string.send_bug_report_progress, 0.toString() + "")

mProgressBar.isVisible = true
mProgressBar.progress = 0

BugReporter.sendBugReport(this,
mIncludeLogsButton.isChecked,
mIncludeCrashLogsButton.isChecked,
mIncludeScreenShotButton.isChecked,
mBugReportText.text.toString(),
object : BugReporter.IMXBugReportListener {
override fun onUploadFailed(reason: String?) {
try {
if (!TextUtils.isEmpty(reason)) {
Toast.makeText(this@BugReportActivity,
getString(R.string.send_bug_report_failed, reason), Toast.LENGTH_LONG).show()
}
} catch (e: Exception) {
Timber.e(e, "## onUploadFailed() : failed to display the toast " + e.message)
}

mMaskView.isVisible = false
mProgressBar.isVisible = false
mProgressTextView.isVisible = false
mScrollView.alpha = 1.0f

invalidateOptionsMenu()
}

override fun onUploadCancelled() {
onUploadFailed(null)
}

override fun onProgress(progress: Int) {
var progress = progress
if (progress > 100) {
Timber.e("## onProgress() : progress > 100")
progress = 100
} else if (progress < 0) {
Timber.e("## onProgress() : progress < 0")
progress = 0
}

mProgressBar.progress = progress
mProgressTextView.text = getString(R.string.send_bug_report_progress, progress.toString() + "")
}

override fun onUploadSucceed() {
try {
Toast.makeText(this@BugReportActivity, R.string.send_bug_report_sent, Toast.LENGTH_LONG).show()
} catch (e: Exception) {
Timber.e(e, "## onUploadSucceed() : failed to dismiss the toast " + e.message)
}

try {
finish()
} catch (e: Exception) {
Timber.e(e, "## onUploadSucceed() : failed to dismiss the dialog " + e.message)
}

}
})
}

/* ==========================================================================================
* UI Event
* ========================================================================================== */

@OnTextChanged(R.id.bug_report_edit_text)
internal fun textChanged() {
invalidateOptionsMenu()
}

@OnCheckedChanged(R.id.bug_report_button_include_screenshot)
internal fun onSendScreenshotChanged() {
mScreenShotPreview.isVisible = mIncludeScreenShotButton.isChecked && BugReporter.screenshot != null
}

override fun onBackPressed() {
// Ensure there is no crash status remaining, which will be sent later on by mistake
BugReporter.deleteCrashFile(this)

super.onBackPressed()
}

/* ==========================================================================================
* Companion
* ========================================================================================== */

companion object {
private val LOG_TAG = BugReportActivity::class.java.simpleName
}
}

View File

@ -0,0 +1,687 @@
/*
* Copyright 2016 OpenMarket Ltd
* Copyright 2017 Vector Creations Ltd
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.rageshake

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.os.AsyncTask
import android.os.Build
import android.text.TextUtils
import android.view.View
import im.vector.matrix.android.api.Matrix
import im.vector.riotredesign.BuildConfig
import im.vector.riotredesign.R
import im.vector.riotredesign.core.extensions.toOnOff
import im.vector.riotredesign.core.utils.getDeviceLocale
import im.vector.riotredesign.features.settings.VectorLocale
import im.vector.riotredesign.features.themes.ThemeUtils
import okhttp3.*
import org.json.JSONException
import org.json.JSONObject
import timber.log.Timber
import java.io.*
import java.net.HttpURLConnection
import java.util.*
import java.util.zip.GZIPOutputStream

/**
* BugReporter creates and sends the bug reports.
*/
object BugReporter {
var inMultiWindowMode = false

// filenames
private const val LOG_CAT_ERROR_FILENAME = "logcatError.log"
private const val LOG_CAT_FILENAME = "logcat.log"
private const val LOG_CAT_SCREENSHOT_FILENAME = "screenshot.png"
private const val CRASH_FILENAME = "crash.log"


// the http client
private val mOkHttpClient = OkHttpClient()

// the pending bug report call
private var mBugReportCall: Call? = null


// boolean to cancel the bug report
private val mIsCancelled = false

/**
* Get current Screenshot
*
* @return screenshot or null if not available
*/
var screenshot: Bitmap? = null
private set

private const val BUFFER_SIZE = 1024 * 1024 * 50

private val LOGCAT_CMD_ERROR = arrayOf("logcat", ///< Run 'logcat' command
"-d", ///< Dump the log rather than continue outputting it
"-v", // formatting
"threadtime", // include timestamps
"AndroidRuntime:E " + ///< Pick all AndroidRuntime errors (such as uncaught exceptions)"communicatorjni:V " + ///< All communicatorjni logging
"libcommunicator:V " + ///< All libcommunicator logging
"DEBUG:V " + ///< All DEBUG logging - which includes native land crashes (seg faults, etc)
"*:S" ///< Everything else silent, so don't pick it..
)

private val LOGCAT_CMD_DEBUG = arrayOf("logcat", "-d", "-v", "threadtime", "*:*")

/**
* Bug report upload listener
*/
interface IMXBugReportListener {
/**
* The bug report has been cancelled
*/
fun onUploadCancelled()

/**
* The bug report upload failed.
*
* @param reason the failure reason
*/
fun onUploadFailed(reason: String?)

/**
* The upload progress (in percent)
*
* @param progress the upload progress
*/
fun onProgress(progress: Int)

/**
* The bug report upload succeeded.
*/
fun onUploadSucceed()
}

/**
* Send a bug report.
*
* @param context the application context
* @param withDevicesLogs true to include the device log
* @param withCrashLogs true to include the crash logs
* @param withScreenshot true to include the screenshot
* @param theBugDescription the bug description
* @param listener the listener
*/
@SuppressLint("StaticFieldLeak")
fun sendBugReport(context: Context,
withDevicesLogs: Boolean,
withCrashLogs: Boolean,
withScreenshot: Boolean,
theBugDescription: String,
listener: IMXBugReportListener?) {
object : AsyncTask<Void, Int, String>() {

// enumerate files to delete
val mBugReportFiles: MutableList<File> = ArrayList()

override fun doInBackground(vararg voids: Void?): String? {
var bugDescription = theBugDescription
var serverError: String? = null
val crashCallStack = getCrashDescription(context)

if (null != crashCallStack) {
bugDescription += "\n\n\n\n--------------------------------- crash call stack ---------------------------------\n"
bugDescription += crashCallStack
}

val gzippedFiles = ArrayList<File>()

if (withDevicesLogs) {
val files = VectorFileLogger.getLogFiles()

for (f in files) {
if (!mIsCancelled) {
val gzippedFile = compressFile(f)

if (null != gzippedFile) {
gzippedFiles.add(gzippedFile)
}
}
}
}

if (!mIsCancelled && (withCrashLogs || withDevicesLogs)) {
val gzippedLogcat = saveLogCat(context, false)

if (null != gzippedLogcat) {
if (gzippedFiles.size == 0) {
gzippedFiles.add(gzippedLogcat)
} else {
gzippedFiles.add(0, gzippedLogcat)
}
}

val crashDescription = getCrashFile(context)
if (crashDescription.exists()) {
val compressedCrashDescription = compressFile(crashDescription)

if (null != compressedCrashDescription) {
if (gzippedFiles.size == 0) {
gzippedFiles.add(compressedCrashDescription)
} else {
gzippedFiles.add(0, compressedCrashDescription)
}
}
}
}

var deviceId = "undefined"
var userId = "undefined"
var matrixSdkVersion = "undefined"
var olmVersion = "undefined"

Matrix.getInstance().currentSession?.let { session ->
userId = session.sessionParams.credentials.userId
deviceId = session.sessionParams.credentials.deviceId ?: "undefined"
// TODO matrixSdkVersion = session.getVersion(true);
// TODO olmVersion = session.getCryptoVersion(context, true);
}

if (!mIsCancelled) {
// build the multi part request
val builder = BugReporterMultipartBody.Builder()
.addFormDataPart("text", "[RiotX] $bugDescription")
.addFormDataPart("app", "riot-android")
.addFormDataPart("user_agent", Matrix.getInstance().getUserAgent())
.addFormDataPart("user_id", userId)
.addFormDataPart("device_id", deviceId)
// TODO .addFormDataPart("version", Matrix.getInstance(context).getVersion(true, false))
.addFormDataPart("branch_name", context.getString(R.string.git_branch_name))
.addFormDataPart("matrix_sdk_version", matrixSdkVersion)
.addFormDataPart("olm_version", olmVersion)
.addFormDataPart("device", Build.MODEL.trim())
.addFormDataPart("lazy_loading", true.toOnOff())
.addFormDataPart("multi_window", inMultiWindowMode.toOnOff())
.addFormDataPart("os", Build.VERSION.RELEASE + " (API " + Build.VERSION.SDK_INT + ") "
+ Build.VERSION.INCREMENTAL + "-" + Build.VERSION.CODENAME)
.addFormDataPart("locale", Locale.getDefault().toString())
.addFormDataPart("app_language", VectorLocale.applicationLocale.toString())
.addFormDataPart("default_app_language", getDeviceLocale(context).toString())
.addFormDataPart("theme", ThemeUtils.getApplicationTheme(context))

val buildNumber = context.getString(R.string.build_number)
if (!TextUtils.isEmpty(buildNumber) && buildNumber != "0") {
builder.addFormDataPart("build_number", buildNumber)
}

// add the gzipped files
for (file in gzippedFiles) {
builder.addFormDataPart("compressed-log", file.name, RequestBody.create(MediaType.parse("application/octet-stream"), file))
}

mBugReportFiles.addAll(gzippedFiles)

if (withScreenshot) {
val bitmap = screenshot

if (null != bitmap) {
val logCatScreenshotFile = File(context.cacheDir.absolutePath, LOG_CAT_SCREENSHOT_FILENAME)

if (logCatScreenshotFile.exists()) {
logCatScreenshotFile.delete()
}

try {
val fos = FileOutputStream(logCatScreenshotFile)
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos)
fos.flush()
fos.close()

builder.addFormDataPart("file",
logCatScreenshotFile.name, RequestBody.create(MediaType.parse("application/octet-stream"), logCatScreenshotFile))
} catch (e: Exception) {
Timber.e(e, "## sendBugReport() : fail to write screenshot$e")
}

}
}

screenshot = null

// add some github labels
builder.addFormDataPart("label", BuildConfig.VERSION_NAME)
builder.addFormDataPart("label", BuildConfig.FLAVOR_DESCRIPTION)
builder.addFormDataPart("label", context.getString(R.string.git_branch_name))

// Special for RiotX
builder.addFormDataPart("label", "[RiotX]")

if (getCrashFile(context).exists()) {
builder.addFormDataPart("label", "crash")
deleteCrashFile(context)
}

val requestBody = builder.build()

// add a progress listener
requestBody.setWriteListener { totalWritten, contentLength ->
val percentage: Int

if (-1L != contentLength) {
if (totalWritten > contentLength) {
percentage = 100
} else {
percentage = (totalWritten * 100 / contentLength).toInt()
}
} else {
percentage = 0
}

if (mIsCancelled && null != mBugReportCall) {
mBugReportCall!!.cancel()
}

Timber.d("## onWrite() : $percentage%")
publishProgress(percentage)
}

// build the request
val request = Request.Builder()
.url(context.getString(R.string.bug_report_url))
.post(requestBody)
.build()

var responseCode = HttpURLConnection.HTTP_INTERNAL_ERROR
var response: Response? = null
var errorMessage: String? = null

// trigger the request
try {
mBugReportCall = mOkHttpClient.newCall(request)
response = mBugReportCall!!.execute()
responseCode = response!!.code()
} catch (e: Exception) {
Timber.e(e, "response " + e.message)
errorMessage = e.localizedMessage
}

// if the upload failed, try to retrieve the reason
if (responseCode != HttpURLConnection.HTTP_OK) {
if (null != errorMessage) {
serverError = "Failed with error $errorMessage"
} else if (null == response || null == response.body()) {
serverError = "Failed with error $responseCode"
} else {
var `is`: InputStream? = null

try {
`is` = response.body()!!.byteStream()

if (null != `is`) {
var ch = `is`.read()
val b = StringBuilder()
while (ch != -1) {
b.append(ch.toChar())
ch = `is`.read()
}
serverError = b.toString()
`is`.close()

// check if the error message
try {
val responseJSON = JSONObject(serverError)
serverError = responseJSON.getString("error")
} catch (e: JSONException) {
Timber.e(e, "doInBackground ; Json conversion failed " + e.message)
}

// should never happen
if (null == serverError) {
serverError = "Failed with error $responseCode"
}
}
} catch (e: Exception) {
Timber.e(e, "## sendBugReport() : failed to parse error " + e.message)
} finally {
try {
`is`?.close()
} catch (e: Exception) {
Timber.e(e, "## sendBugReport() : failed to close the error stream " + e.message)
}

}
}
}
}

return serverError
}


override fun onProgressUpdate(vararg progress: Int?) {
if (null != listener) {
try {
listener.onProgress(progress?.get(0) ?: 0)
} catch (e: Exception) {
Timber.e(e, "## onProgress() : failed " + e.message)
}

}
}

override fun onPostExecute(reason: String?) {
mBugReportCall = null

// delete when the bug report has been successfully sent
for (file in mBugReportFiles) {
file.delete()
}

if (null != listener) {
try {
if (mIsCancelled) {
listener.onUploadCancelled()
} else if (null == reason) {
listener.onUploadSucceed()
} else {
listener.onUploadFailed(reason)
}
} catch (e: Exception) {
Timber.e(e, "## onPostExecute() : failed " + e.message)
}

}
}
}.execute()
}

/**
* Send a bug report either with email or with Vector.
*/
fun openBugReportScreen(activity: Activity) {
screenshot = takeScreenshot(activity)

val intent = Intent(activity, BugReportActivity::class.java)
activity.startActivity(intent)
}

//==============================================================================================================
// crash report management
//==============================================================================================================

/**
* Provides the crash file
*
* @param context the context
* @return the crash file
*/
private fun getCrashFile(context: Context): File {
return File(context.cacheDir.absolutePath, CRASH_FILENAME)
}

/**
* Remove the crash file
*
* @param context
*/
fun deleteCrashFile(context: Context) {
val crashFile = getCrashFile(context)

if (crashFile.exists()) {
crashFile.delete()
}

// Also reset the screenshot
screenshot = null
}

/**
* Save the crash report
*
* @param context the context
* @param crashDescription teh crash description
*/
fun saveCrashReport(context: Context, crashDescription: String) {
val crashFile = getCrashFile(context)

if (crashFile.exists()) {
crashFile.delete()
}

if (!TextUtils.isEmpty(crashDescription)) {
try {
val fos = FileOutputStream(crashFile)
val osw = OutputStreamWriter(fos)
osw.write(crashDescription)
osw.close()

fos.flush()
fos.close()
} catch (e: Exception) {
Timber.e(e, "## saveCrashReport() : fail to write $e")
}

}
}

/**
* Read the crash description file and return its content.
*
* @param context teh context
* @return the crash description
*/
private fun getCrashDescription(context: Context): String? {
var crashDescription: String? = null
val crashFile = getCrashFile(context)

if (crashFile.exists()) {
try {
val fis = FileInputStream(crashFile)
val isr = InputStreamReader(fis)

val buffer = CharArray(fis.available())
val len = isr.read(buffer, 0, fis.available())
crashDescription = String(buffer, 0, len)
isr.close()
fis.close()
} catch (e: Exception) {
Timber.e(e, "## getCrashDescription() : fail to read $e")
}

}

return crashDescription
}

//==============================================================================================================
// Screenshot management
//==============================================================================================================

/**
* Take a screenshot of the display.
*
* @return the screenshot
*/
private fun takeScreenshot(activity: Activity): Bitmap? {
// get content view
val contentView = activity.findViewById<View>(android.R.id.content)
if (contentView == null) {
Timber.e("Cannot find content view on $activity. Cannot take screenshot.")
return null
}

// get the root view to snapshot
val rootView = contentView.rootView
if (rootView == null) {
Timber.e("Cannot find root view on $activity. Cannot take screenshot.")
return null
}
// refresh it
rootView.isDrawingCacheEnabled = false
rootView.isDrawingCacheEnabled = true

try {
var bitmap = rootView.drawingCache

// Make a copy, because if Activity is destroyed, the bitmap will be recycled
bitmap = Bitmap.createBitmap(bitmap)

return bitmap
} catch (oom: OutOfMemoryError) {
Timber.e(oom, "Cannot get drawing cache for $activity OOM.")
} catch (e: Exception) {
Timber.e(e, "Cannot get snapshot of screen: $e")
}

return null
}

//==============================================================================================================
// Logcat management
//==============================================================================================================

/**
* Save the logcat
*
* @param context the context
* @param isErrorLogcat true to save the error logcat
* @return the file if the operation succeeds
*/
private fun saveLogCat(context: Context, isErrorLogcat: Boolean): File? {
val logCatErrFile = File(context.cacheDir.absolutePath, if (isErrorLogcat) LOG_CAT_ERROR_FILENAME else LOG_CAT_FILENAME)

if (logCatErrFile.exists()) {
logCatErrFile.delete()
}

try {
val fos = FileOutputStream(logCatErrFile)
val osw = OutputStreamWriter(fos)
getLogCatError(osw, isErrorLogcat)
osw.close()

fos.flush()
fos.close()

return compressFile(logCatErrFile)
} catch (error: OutOfMemoryError) {
Timber.e(error, "## saveLogCat() : fail to write logcat$error")
} catch (e: Exception) {
Timber.e(e, "## saveLogCat() : fail to write logcat$e")
}

return null
}

/**
* Retrieves the logs
*
* @param streamWriter the stream writer
* @param isErrorLogCat true to save the error logs
*/
private fun getLogCatError(streamWriter: OutputStreamWriter, isErrorLogCat: Boolean) {
val logcatProc: Process

try {
logcatProc = Runtime.getRuntime().exec(if (isErrorLogCat) LOGCAT_CMD_ERROR else LOGCAT_CMD_DEBUG)
} catch (e1: IOException) {
return
}

var reader: BufferedReader? = null
try {
val separator = System.getProperty("line.separator")
reader = BufferedReader(InputStreamReader(logcatProc.inputStream), BUFFER_SIZE)
var line = reader.readLine()
while (line != null) {
streamWriter.append(line)
streamWriter.append(separator)
line = reader.readLine()
}
} catch (e: IOException) {
Timber.e(e, "getLog fails with " + e.localizedMessage)
} finally {
if (reader != null) {
try {
reader.close()
} catch (e: IOException) {
Timber.e(e, "getLog fails with " + e.localizedMessage)
}

}
}
}

//==============================================================================================================
// File compression management
//==============================================================================================================

/**
* GZip a file
*
* @param fin the input file
* @return the gzipped file
*/
private fun compressFile(fin: File): File? {
Timber.d("## compressFile() : compress " + fin.name)

val dstFile = File(fin.parent, fin.name + ".gz")

if (dstFile.exists()) {
dstFile.delete()
}

var fos: FileOutputStream? = null
var gos: GZIPOutputStream? = null
var inputStream: InputStream? = null
try {
fos = FileOutputStream(dstFile)
gos = GZIPOutputStream(fos)

inputStream = FileInputStream(fin)

val buffer = ByteArray(2048)
var n = inputStream.read(buffer)
while (n != -1) {
gos.write(buffer, 0, n)
n = inputStream.read(buffer)
}

gos.close()
inputStream.close()

Timber.d("## compressFile() : " + fin.length() + " compressed to " + dstFile.length() + " bytes")
return dstFile
} catch (e: Exception) {
Timber.e(e, "## compressFile() failed " + e.message)
} catch (oom: OutOfMemoryError) {
Timber.e(oom, "## compressFile() failed " + oom.message)
} finally {
try {
fos?.close()
gos?.close()
inputStream?.close()
} catch (e: Exception) {
Timber.e(e, "## compressFile() failed to close inputStream " + e.message)
}

}

return null
}
}

View File

@ -0,0 +1,300 @@
/*
* Copyright 2017 Vector Creations Ltd
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.rageshake;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.internal.Util;
import okio.Buffer;
import okio.BufferedSink;
import okio.ByteString;

// simplified version of MultipartBody (OkHttp 3.6.0)
public class BugReporterMultipartBody extends RequestBody {

/**
* Listener
*/
public interface WriteListener {
/**
* Upload listener
*
* @param totalWritten total written bytes
* @param contentLength content length
*/
void onWrite(long totalWritten, long contentLength);
}

private static final MediaType FORM = MediaType.parse("multipart/form-data");

private static final byte[] COLONSPACE = {':', ' '};
private static final byte[] CRLF = {'\r', '\n'};
private static final byte[] DASHDASH = {'-', '-'};

private final ByteString mBoundary;
private final MediaType mContentType;
private final List<Part> mParts;
private long mContentLength = -1L;

// listener
private WriteListener mWriteListener;

//
private List<Long> mContentLengthSize = null;

private BugReporterMultipartBody(ByteString boundary, List<Part> parts) {
mBoundary = boundary;
mContentType = MediaType.parse(FORM + "; boundary=" + boundary.utf8());
mParts = Util.immutableList(parts);
}

@Override
public MediaType contentType() {
return mContentType;
}

@Override
public long contentLength() throws IOException {
long result = mContentLength;
if (result != -1L) return result;
return mContentLength = writeOrCountBytes(null, true);
}

@Override
public void writeTo(BufferedSink sink) throws IOException {
writeOrCountBytes(sink, false);
}

/**
* Set the listener
*
* @param listener the
*/
public void setWriteListener(WriteListener listener) {
mWriteListener = listener;
}

/**
* Warn the listener that some bytes have been written
*
* @param totalWrittenBytes the total written bytes
*/
private void onWrite(long totalWrittenBytes) {
if ((null != mWriteListener) && (mContentLength > 0)) {
mWriteListener.onWrite(totalWrittenBytes, mContentLength);
}
}

/**
* Either writes this request to {@code sink} or measures its content length. We have one method
* do double-duty to make sure the counting and content are consistent, particularly when it comes
* to awkward operations like measuring the encoded length of header strings, or the
* length-in-digits of an encoded integer.
*/
private long writeOrCountBytes(BufferedSink sink, boolean countBytes) throws IOException {
long byteCount = 0L;

Buffer byteCountBuffer = null;
if (countBytes) {
sink = byteCountBuffer = new Buffer();
mContentLengthSize = new ArrayList<>();
}

for (int p = 0, partCount = mParts.size(); p < partCount; p++) {
Part part = mParts.get(p);
Headers headers = part.headers;
RequestBody body = part.body;

sink.write(DASHDASH);
sink.write(mBoundary);
sink.write(CRLF);

if (headers != null) {
for (int h = 0, headerCount = headers.size(); h < headerCount; h++) {
sink.writeUtf8(headers.name(h))
.write(COLONSPACE)
.writeUtf8(headers.value(h))
.write(CRLF);
}
}

MediaType contentType = body.contentType();
if (contentType != null) {
sink.writeUtf8("Content-Type: ")
.writeUtf8(contentType.toString())
.write(CRLF);
}

int contentLength = (int) body.contentLength();
if (contentLength != -1) {
sink.writeUtf8("Content-Length: ")
.writeUtf8(contentLength + "")
.write(CRLF);
} else if (countBytes) {
// We can't measure the body's size without the sizes of its components.
byteCountBuffer.clear();
return -1L;
}

sink.write(CRLF);

if (countBytes) {
byteCount += contentLength;
mContentLengthSize.add(byteCount);
} else {
body.writeTo(sink);

// warn the listener of upload progress
// sink.buffer().size() does not give the right value
// assume that some data are popped
if ((null != mContentLengthSize) && (p < mContentLengthSize.size())) {
onWrite(mContentLengthSize.get(p));
}
}
sink.write(CRLF);
}

sink.write(DASHDASH);
sink.write(mBoundary);
sink.write(DASHDASH);
sink.write(CRLF);

if (countBytes) {
byteCount += byteCountBuffer.size();
byteCountBuffer.clear();
}

return byteCount;
}

private static void appendQuotedString(StringBuilder target, String key) {
target.append('"');
for (int i = 0, len = key.length(); i < len; i++) {
char ch = key.charAt(i);
switch (ch) {
case '\n':
target.append("%0A");
break;
case '\r':
target.append("%0D");
break;
case '"':
target.append("%22");
break;
default:
target.append(ch);
break;
}
}
target.append('"');
}

public static final class Part {
public static Part create(Headers headers, RequestBody body) {
if (body == null) {
throw new NullPointerException("body == null");
}
if (headers != null && headers.get("Content-Type") != null) {
throw new IllegalArgumentException("Unexpected header: Content-Type");
}
if (headers != null && headers.get("Content-Length") != null) {
throw new IllegalArgumentException("Unexpected header: Content-Length");
}
return new Part(headers, body);
}

public static Part createFormData(String name, String value) {
return createFormData(name, null, RequestBody.create(null, value));
}

public static Part createFormData(String name, String filename, RequestBody body) {
if (name == null) {
throw new NullPointerException("name == null");
}
StringBuilder disposition = new StringBuilder("form-data; name=");
appendQuotedString(disposition, name);

if (filename != null) {
disposition.append("; filename=");
appendQuotedString(disposition, filename);
}

return create(Headers.of("Content-Disposition", disposition.toString()), body);
}

final Headers headers;
final RequestBody body;

private Part(Headers headers, RequestBody body) {
this.headers = headers;
this.body = body;
}
}

public static final class Builder {
private final ByteString boundary;
private final List<Part> parts = new ArrayList<>();

public Builder() {
this(UUID.randomUUID().toString());
}

public Builder(String boundary) {
this.boundary = ByteString.encodeUtf8(boundary);
}

/**
* Add a form data part to the body.
*/
public Builder addFormDataPart(String name, String value) {
return addPart(Part.createFormData(name, value));
}

/**
* Add a form data part to the body.
*/
public Builder addFormDataPart(String name, String filename, RequestBody body) {
return addPart(Part.createFormData(name, filename, body));
}

/**
* Add a part to the body.
*/
public Builder addPart(Part part) {
if (part == null) throw new NullPointerException("part == null");
parts.add(part);
return this;
}

/**
* Assemble the specified parts into a request body.
*/
public BugReporterMultipartBody build() {
if (parts.isEmpty()) {
throw new IllegalStateException("Multipart body must have at least one part.");
}
return new BugReporterMultipartBody(boundary, parts);
}
}
}

View File

@ -0,0 +1,118 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.rageshake

import android.app.Activity
import android.content.Context
import android.hardware.Sensor
import android.hardware.SensorManager
import android.preference.PreferenceManager
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import com.squareup.seismic.ShakeDetector
import im.vector.riotredesign.R

class RageShake(val activity: Activity) : ShakeDetector.Listener {

private var shakeDetector: ShakeDetector? = null

private var dialogDisplayed = false

fun start() {
if (!isEnable(activity)) {
return
}


val sensorManager = activity.getSystemService(AppCompatActivity.SENSOR_SERVICE) as? SensorManager

if (sensorManager == null) {
return
}

shakeDetector = ShakeDetector(this).apply {
start(sensorManager)
}
}

fun stop() {
shakeDetector?.stop()
}

/**
* Enable the feature, and start it
*/
fun enable() {
PreferenceManager.getDefaultSharedPreferences(activity).edit {
putBoolean(SETTINGS_USE_RAGE_SHAKE_KEY, true)
}

start()
}

/**
* Disable the feature, and stop it
*/
fun disable() {
PreferenceManager.getDefaultSharedPreferences(activity).edit {
putBoolean(SETTINGS_USE_RAGE_SHAKE_KEY, false)
}

stop()
}

override fun hearShake() {
if (dialogDisplayed) {
// Filtered!
return
}

dialogDisplayed = true

AlertDialog.Builder(activity)
.setMessage(R.string.send_bug_report_alert_message)
.setPositiveButton(R.string.yes) { _, _ -> openBugReportScreen() }
.setNeutralButton(R.string.disable) { _, _ -> disable() }
.setOnDismissListener { dialogDisplayed = false }
.setNegativeButton(R.string.no, null)
.show()
}

private fun openBugReportScreen() {
BugReporter.openBugReportScreen(activity)
}

companion object {
private const val SETTINGS_USE_RAGE_SHAKE_KEY = "SETTINGS_USE_RAGE_SHAKE_KEY"

/**
* Check if the feature is available
*/
fun isAvailable(context: Context): Boolean {
return (context.getSystemService(AppCompatActivity.SENSOR_SERVICE) as? SensorManager)
?.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null
}

/**
* Check if the feature is enable (enabled by default)
*/
private fun isEnable(context: Context): Boolean {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_USE_RAGE_SHAKE_KEY, true)
}
}
}

View File

@ -0,0 +1,186 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.rageshake

import android.content.Context
import android.text.TextUtils
import timber.log.Timber
import java.io.File
import java.io.IOException
import java.io.PrintWriter
import java.io.StringWriter
import java.text.SimpleDateFormat
import java.util.*
import java.util.logging.*
import java.util.logging.Formatter
import kotlin.collections.ArrayList

object VectorFileLogger : Timber.DebugTree() {

private const val LOG_SIZE_BYTES = 50 * 1024 * 1024 // 50MB

// relatively large rotation count because closing > opening the app rotates the log (!)
private const val LOG_ROTATION_COUNT = 15

private val sLogger = Logger.getLogger("im.vector.riotredesign")
private lateinit var sFileHandler: FileHandler
private lateinit var sCacheDirectory: File
private var sFileName = "riotx"

fun init(context: Context) {
val logsDirectoryFile = context.cacheDir.absolutePath + "/logs"

setLogDirectory(File(logsDirectoryFile))
init("RiotXLog")
}

override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (t != null) {
logToFile(t)
}

logToFile("$priority ", tag ?: "Tag", message)
}

/**
* Set the directory to put log files.
*
* @param cacheDir The directory, usually [android.content.ContextWrapper.getCacheDir]
*/
private fun setLogDirectory(cacheDir: File) {
if (!cacheDir.exists()) {
cacheDir.mkdirs()
}
sCacheDirectory = cacheDir
}

/**
* Initialises the logger. Should be called AFTER [Log.setLogDirectory].
*
* @param fileName the base file name
*/
private fun init(fileName: String) {
try {
if (!TextUtils.isEmpty(fileName)) {
sFileName = fileName
}
sFileHandler = FileHandler(sCacheDirectory.absolutePath + "/" + sFileName + ".%g.txt", LOG_SIZE_BYTES, LOG_ROTATION_COUNT)
sFileHandler.formatter = LogFormatter()
sLogger.useParentHandlers = false
sLogger.level = Level.ALL
sLogger.addHandler(sFileHandler)
} catch (e: IOException) {
}
}

/**
* Adds our own log files to the provided list of files.
*
* @param files The list of files to add to.
* @return The same list with more files added.
*/
fun getLogFiles(): List<File> {
val files = ArrayList<File>()

try {
// reported by GA
if (null != sFileHandler) {
sFileHandler.flush()
val absPath = sCacheDirectory.absolutePath

for (i in 0..LOG_ROTATION_COUNT) {
val filepath = "$absPath/$sFileName.$i.txt"
val file = File(filepath)
if (file.exists()) {
files.add(file)
}
}
}
} catch (e: Exception) {
Timber.e(e, "## addLogFiles() failed : " + e.message)
}

return files
}

class LogFormatter : Formatter() {

override fun format(r: LogRecord): String {
if (!mIsTimeZoneSet) {
DATE_FORMAT.timeZone = TimeZone.getTimeZone("UTC")
mIsTimeZoneSet = true
}

val thrown = r.thrown
if (thrown != null) {
val sw = StringWriter()
val pw = PrintWriter(sw)
sw.write(r.message)
sw.write(LINE_SEPARATOR)
thrown.printStackTrace(pw)
pw.flush()
return sw.toString()
} else {
val b = StringBuilder()
val date = DATE_FORMAT.format(Date(r.millis))
b.append(date)
b.append("Z ")
b.append(r.message)
b.append(LINE_SEPARATOR)
return b.toString()
}
}

companion object {
private val LINE_SEPARATOR = System.getProperty("line.separator") ?: "\n"
private val DATE_FORMAT = SimpleDateFormat("MM-dd HH:mm:ss.SSS", Locale.US)
private var mIsTimeZoneSet = false
}
}

/**
* Log an Throwable
*
* @param throwable the throwable to log
*/
private fun logToFile(throwable: Throwable?) {
if (null == sCacheDirectory || throwable == null) {
return
}

val errors = StringWriter()
throwable.printStackTrace(PrintWriter(errors))

sLogger.info(errors.toString())
}

private fun logToFile(level: String, tag: String, content: String) {
if (null == sCacheDirectory) {
return
}

val b = StringBuilder()
b.append(Thread.currentThread().id)
b.append(" ")
b.append(level)
b.append("/")
b.append(tag)
b.append(": ")
b.append(content)
sLogger.info(b.toString())
}
}

View File

@ -0,0 +1,147 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.rageshake

import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import im.vector.riotredesign.BuildConfig
import timber.log.Timber
import java.io.PrintWriter
import java.io.StringWriter

@SuppressLint("StaticFieldLeak")
object VectorUncaughtExceptionHandler : Thread.UncaughtExceptionHandler {

// key to save the crash status
private const val PREFS_CRASH_KEY = "PREFS_CRASH_KEY"

private var vectorVersion: String = ""
private var matrixSdkVersion: String = ""

private var previousHandler: Thread.UncaughtExceptionHandler? = null

private lateinit var context: Context

/**
* Activate this handler
*/
fun activate(context: Context) {
this.context = context

previousHandler = Thread.getDefaultUncaughtExceptionHandler()

Thread.setDefaultUncaughtExceptionHandler(this)
}

/**
* An uncaught exception has been triggered
*
* @param thread the thread
* @param throwable the throwable
* @return the exception description
*/
override fun uncaughtException(thread: Thread, throwable: Throwable) {
if (context == null) {
previousHandler?.uncaughtException(thread, throwable)
return
}

PreferenceManager.getDefaultSharedPreferences(context).edit {
putBoolean(PREFS_CRASH_KEY, true)
}

val b = StringBuilder()
val appName = "RiotX" // TODO Matrix.getApplicationName()

b.append(appName + " Build : " + BuildConfig.VERSION_CODE + "\n")
b.append("$appName Version : $vectorVersion\n")
b.append("SDK Version : $matrixSdkVersion\n")
b.append("Phone : " + Build.MODEL.trim() + " (" + Build.VERSION.INCREMENTAL + " " + Build.VERSION.RELEASE + " " + Build.VERSION.CODENAME + ")\n")

b.append("Memory statuses \n")

var freeSize = 0L
var totalSize = 0L
var usedSize = -1L
try {
val info = Runtime.getRuntime()
freeSize = info.freeMemory()
totalSize = info.totalMemory()
usedSize = totalSize - freeSize
} catch (e: Exception) {
e.printStackTrace()
}

b.append("usedSize " + usedSize / 1048576L + " MB\n")
b.append("freeSize " + freeSize / 1048576L + " MB\n")
b.append("totalSize " + totalSize / 1048576L + " MB\n")

b.append("Thread: ")
b.append(thread.name)

/*
val a = VectorApp.getCurrentActivity()
if (a != null) {
b.append(", Activity:")
b.append(a.localClassName)
}
*/

b.append(", Exception: ")

val sw = StringWriter()
val pw = PrintWriter(sw, true)
throwable.printStackTrace(pw)
b.append(sw.buffer.toString())
Timber.e("FATAL EXCEPTION " + b.toString())

val bugDescription = b.toString()

BugReporter.saveCrashReport(context, bugDescription)

// Show the classical system popup
previousHandler?.uncaughtException(thread, throwable)
}

// TODO Call me
fun setVersions(vectorVersion: String, matrixSdkVersion: String) {
this.vectorVersion = vectorVersion
this.matrixSdkVersion = matrixSdkVersion
}

/**
* Tells if the application crashed
*
* @return true if the application crashed
*/
fun didAppCrash(context: Context): Boolean {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(PREFS_CRASH_KEY, false)
}

/**
* Clear the crash status
*/
fun clearAppCrashStatus(context: Context) {
PreferenceManager.getDefaultSharedPreferences(context).edit {
remove(PREFS_CRASH_KEY)
}
}
}

View File

@ -0,0 +1,152 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.settings

import android.content.Context
import android.content.res.Configuration
import android.text.TextUtils
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import im.vector.riotredesign.R

/**
* Object to manage the Font Scale choice of the user
*/
object FontScale {
// Key for the SharedPrefs
private const val APPLICATION_FONT_SCALE_KEY = "APPLICATION_FONT_SCALE_KEY"

// Possible values for the SharedPrefs
private const val FONT_SCALE_TINY = "FONT_SCALE_TINY"
private const val FONT_SCALE_SMALL = "FONT_SCALE_SMALL"
private const val FONT_SCALE_NORMAL = "FONT_SCALE_NORMAL"
private const val FONT_SCALE_LARGE = "FONT_SCALE_LARGE"
private const val FONT_SCALE_LARGER = "FONT_SCALE_LARGER"
private const val FONT_SCALE_LARGEST = "FONT_SCALE_LARGEST"
private const val FONT_SCALE_HUGE = "FONT_SCALE_HUGE"

private val fontScaleToPrefValue = mapOf(
0.70f to FONT_SCALE_TINY,
0.85f to FONT_SCALE_SMALL,
1.00f to FONT_SCALE_NORMAL,
1.15f to FONT_SCALE_LARGE,
1.30f to FONT_SCALE_LARGER,
1.45f to FONT_SCALE_LARGEST,
1.60f to FONT_SCALE_HUGE
)

private val prefValueToNameResId = mapOf(
FONT_SCALE_TINY to R.string.tiny,
FONT_SCALE_SMALL to R.string.small,
FONT_SCALE_NORMAL to R.string.normal,
FONT_SCALE_LARGE to R.string.large,
FONT_SCALE_LARGER to R.string.larger,
FONT_SCALE_LARGEST to R.string.largest,
FONT_SCALE_HUGE to R.string.huge
)

/**
* Get the font scale value from SharedPrefs. Init the SharedPrefs if necessary
*
* @return the font scale
*/
fun getFontScalePrefValue(context: Context): String {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
var scalePreferenceValue: String

if (!preferences.contains(APPLICATION_FONT_SCALE_KEY)) {
val fontScale = context.resources.configuration.fontScale

scalePreferenceValue = FONT_SCALE_NORMAL

if (fontScaleToPrefValue.containsKey(fontScale)) {
scalePreferenceValue = fontScaleToPrefValue[fontScale] as String
}

preferences.edit {
putString(APPLICATION_FONT_SCALE_KEY, scalePreferenceValue)
}
} else {
scalePreferenceValue = preferences.getString(APPLICATION_FONT_SCALE_KEY, FONT_SCALE_NORMAL)!!
}

return scalePreferenceValue
}

/**
* Provides the font scale value
*
* @return the font scale
*/
fun getFontScale(context: Context): Float {
val fontScale = getFontScalePrefValue(context)

if (fontScaleToPrefValue.containsValue(fontScale)) {
for (entry in fontScaleToPrefValue) {
if (TextUtils.equals(entry.value, fontScale)) {
return entry.key
}
}
}

return 1.0f
}

/**
* Provides the font scale description
*
* @return the font description
*/
fun getFontScaleDescription(context: Context): String {
val fontScale = getFontScalePrefValue(context)

return if (prefValueToNameResId.containsKey(fontScale)) {
context.getString(prefValueToNameResId[fontScale] as Int)
} else context.getString(R.string.normal)
}

/**
* Update the font size from the locale description.
*
* @param fontScaleDescription the font scale description
*/
fun updateFontScale(context: Context, fontScaleDescription: String) {
for (entry in prefValueToNameResId) {
if (TextUtils.equals(context.getString(entry.value), fontScaleDescription)) {
saveFontScale(context, entry.key)
}
}

val config = Configuration(context.resources.configuration)
config.fontScale = getFontScale(context)
context.resources.updateConfiguration(config, context.resources.displayMetrics)
}

/**
* Save the new font scale
*
* @param scaleValue the text scale
*/
fun saveFontScale(context: Context, scaleValue: String) {
if (!TextUtils.isEmpty(scaleValue)) {
PreferenceManager.getDefaultSharedPreferences(context)
.edit {
putString(APPLICATION_FONT_SCALE_KEY, scaleValue)
}
}
}
}

View File

@ -0,0 +1,198 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.settings

import android.content.Context
import android.content.res.Configuration
import android.os.Build
import android.preference.PreferenceManager
import android.text.TextUtils
import android.util.Pair
import androidx.core.content.edit
import im.vector.riotredesign.R
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import timber.log.Timber
import java.util.*

/**
* Object to manage the Locale choice of the user
*/
object VectorLocale {
private const val APPLICATION_LOCALE_COUNTRY_KEY = "APPLICATION_LOCALE_COUNTRY_KEY"
private const val APPLICATION_LOCALE_VARIANT_KEY = "APPLICATION_LOCALE_VARIANT_KEY"
private const val APPLICATION_LOCALE_LANGUAGE_KEY = "APPLICATION_LOCALE_LANGUAGE_KEY"

private val defaultLocale = Locale("en", "US")

/**
* The supported application languages
*/
var supportedLocales = ArrayList<Locale>()
private set

/**
* Provides the current application locale
*/
var applicationLocale = defaultLocale
private set

/**
* Init this object
*/
fun init(context: Context) {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)

if (preferences.contains(APPLICATION_LOCALE_LANGUAGE_KEY)) {
applicationLocale = Locale(preferences.getString(APPLICATION_LOCALE_LANGUAGE_KEY, ""),
preferences.getString(APPLICATION_LOCALE_COUNTRY_KEY, ""),
preferences.getString(APPLICATION_LOCALE_VARIANT_KEY, "")
)
} else {
applicationLocale = Locale.getDefault()

// detect if the default language is used
val defaultStringValue = getString(context, defaultLocale, R.string.resources_country_code)
if (TextUtils.equals(defaultStringValue, getString(context, applicationLocale, R.string.resources_country_code))) {
applicationLocale = defaultLocale
}

saveApplicationLocale(context, applicationLocale)
}

// init the known locales in background, using kotlin coroutines
GlobalScope.launch {
initApplicationLocales(context)
}
}

/**
* Save the new application locale.
*/
fun saveApplicationLocale(context: Context, locale: Locale) {
applicationLocale = locale

PreferenceManager.getDefaultSharedPreferences(context).edit {
val language = locale.language
if (TextUtils.isEmpty(language)) {
remove(APPLICATION_LOCALE_LANGUAGE_KEY)
} else {
putString(APPLICATION_LOCALE_LANGUAGE_KEY, language)
}

val country = locale.country
if (TextUtils.isEmpty(country)) {
remove(APPLICATION_LOCALE_COUNTRY_KEY)
} else {
putString(APPLICATION_LOCALE_COUNTRY_KEY, country)
}

val variant = locale.variant
if (TextUtils.isEmpty(variant)) {
remove(APPLICATION_LOCALE_VARIANT_KEY)
} else {
putString(APPLICATION_LOCALE_VARIANT_KEY, variant)
}
}
}

/**
* Get String from a locale
*
* @param context the context
* @param locale the locale
* @param resourceId the string resource id
* @return the localized string
*/
private fun getString(context: Context, locale: Locale, resourceId: Int): String {
var result: String

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
val config = Configuration(context.resources.configuration)
config.setLocale(locale)
try {
result = context.createConfigurationContext(config).getText(resourceId).toString()
} catch (e: Exception) {
Timber.e(e, "## getString() failed : " + e.message)
// use the default one
result = context.getString(resourceId)
}
} else {
val resources = context.resources
val conf = resources.configuration
val savedLocale = conf.locale
conf.locale = locale
resources.updateConfiguration(conf, null)

// retrieve resources from desired locale
result = resources.getString(resourceId)

// restore original locale
conf.locale = savedLocale
resources.updateConfiguration(conf, null)
}

return result
}

/**
* Provides the supported application locales list
*
* @param context the context
*/
private fun initApplicationLocales(context: Context) {
val knownLocalesSet = HashSet<Pair<String, String>>()

try {
val availableLocales = Locale.getAvailableLocales()

for (locale in availableLocales) {
knownLocalesSet.add(Pair(getString(context, locale, R.string.resources_language),
getString(context, locale, R.string.resources_country_code)))
}
} catch (e: Exception) {
Timber.e(e, "## getApplicationLocales() : failed " + e.message)
knownLocalesSet.add(Pair(context.getString(R.string.resources_language), context.getString(R.string.resources_country_code)))
}

supportedLocales.clear()

for (knownLocale in knownLocalesSet) {
supportedLocales.add(Locale(knownLocale.first, knownLocale.second))
}

// sort by human display names
supportedLocales.sortWith(Comparator { lhs, rhs -> localeToLocalisedString(lhs).compareTo(localeToLocalisedString(rhs)) })
}

/**
* Convert a locale to a string
*
* @param locale the locale to convert
* @return the string
*/
fun localeToLocalisedString(locale: Locale): String {
var res = locale.getDisplayLanguage(locale)

if (!TextUtils.isEmpty(locale.getDisplayCountry(locale))) {
res += " (" + locale.getDisplayCountry(locale) + ")"
}

return res
}
}

View File

@ -0,0 +1,77 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.ui.themes

import androidx.annotation.StyleRes
import im.vector.riotredesign.R

/**
* Class to manage Activity other possible themes.
* Note that style for light theme is default and is declared in the Android Manifest
*/
sealed class ActivityOtherThemes(@StyleRes val dark: Int,
@StyleRes val black: Int,
@StyleRes val status: Int) {

object Default : ActivityOtherThemes(
R.style.AppTheme_Dark,
R.style.AppTheme_Black,
R.style.AppTheme_Status
)

object NoActionBarFullscreen : ActivityOtherThemes(
R.style.AppTheme_NoActionBar_FullScreen_Dark,
R.style.AppTheme_NoActionBar_FullScreen_Black,
R.style.AppTheme_NoActionBar_FullScreen_Status
)

object Home : ActivityOtherThemes(
R.style.HomeActivityTheme_Dark,
R.style.HomeActivityTheme_Black,
R.style.HomeActivityTheme_Status
)

object Group : ActivityOtherThemes(
R.style.GroupAppTheme_Dark,
R.style.GroupAppTheme_Black,
R.style.GroupAppTheme_Status
)

object Picker : ActivityOtherThemes(
R.style.CountryPickerTheme_Dark,
R.style.CountryPickerTheme_Black,
R.style.CountryPickerTheme_Status
)

object Lock : ActivityOtherThemes(
R.style.Theme_Vector_Lock_Dark,
R.style.Theme_Vector_Lock_Light,
R.style.Theme_Vector_Lock_Status
)

object Search : ActivityOtherThemes(
R.style.SearchesAppTheme_Dark,
R.style.SearchesAppTheme_Black,
R.style.SearchesAppTheme_Status
)

object Call : ActivityOtherThemes(
R.style.CallActivityTheme_Dark,
R.style.CallActivityTheme_Black,
R.style.CallActivityTheme_Status
)
}

View File

@ -0,0 +1,226 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.features.themes


import android.app.Activity
import android.content.Context
import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.util.TypedValue
import android.view.Menu
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.preference.PreferenceManager
import im.vector.riotredesign.R
import im.vector.ui.themes.ActivityOtherThemes
import timber.log.Timber
import java.util.*

/**
* Util class for managing themes.
*/
object ThemeUtils {
// preference key
const val APPLICATION_THEME_KEY = "APPLICATION_THEME_KEY"

// the theme possible values
private const val THEME_DARK_VALUE = "dark"
private const val THEME_LIGHT_VALUE = "light"
private const val THEME_BLACK_VALUE = "black"
private const val THEME_STATUS_VALUE = "status"

private val mColorByAttr = HashMap<Int, Int>()

/**
* Provides the selected application theme
*
* @param context the context
* @return the selected application theme
*/
fun getApplicationTheme(context: Context): String {
return PreferenceManager.getDefaultSharedPreferences(context)
.getString(APPLICATION_THEME_KEY, THEME_LIGHT_VALUE)
}

/**
* Update the application theme
*
* @param aTheme the new theme
*/
fun setApplicationTheme(context: Context, aTheme: String) {
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putString(APPLICATION_THEME_KEY, aTheme)
.apply()

/* TODO
when (aTheme) {
THEME_DARK_VALUE -> VectorApp.getInstance().setTheme(R.style.AppTheme_Dark)
THEME_BLACK_VALUE -> VectorApp.getInstance().setTheme(R.style.AppTheme_Black)
THEME_STATUS_VALUE -> VectorApp.getInstance().setTheme(R.style.AppTheme_Status)
else -> VectorApp.getInstance().setTheme(R.style.AppTheme_Light)
}
*/

mColorByAttr.clear()
}

/**
* Set the activity theme according to the selected one.
*
* @param activity the activity
*/
fun setActivityTheme(activity: Activity, otherThemes: ActivityOtherThemes) {
when (getApplicationTheme(activity)) {
THEME_DARK_VALUE -> activity.setTheme(otherThemes.dark)
THEME_BLACK_VALUE -> activity.setTheme(otherThemes.black)
THEME_STATUS_VALUE -> activity.setTheme(otherThemes.status)
}

mColorByAttr.clear()
}

/**
* Set the TabLayout colors.
* It seems that there is no proper way to manage it with the manifest file.
*
* @param activity the activity
* @param layout the layout
*/
/*
fun setTabLayoutTheme(activity: Activity, layout: TabLayout) {
if (activity is VectorGroupDetailsActivity) {
val textColor: Int
val underlineColor: Int
val backgroundColor: Int

if (TextUtils.equals(getApplicationTheme(activity), THEME_LIGHT_VALUE)) {
textColor = ContextCompat.getColor(activity, android.R.color.white)
underlineColor = textColor
backgroundColor = ContextCompat.getColor(activity, R.color.tab_groups)
} else if (TextUtils.equals(getApplicationTheme(activity), THEME_STATUS_VALUE)) {
textColor = ContextCompat.getColor(activity, android.R.color.white)
underlineColor = textColor
backgroundColor = getColor(activity, R.attr.colorPrimary)
} else {
textColor = ContextCompat.getColor(activity, R.color.tab_groups)
underlineColor = textColor
backgroundColor = getColor(activity, R.attr.colorPrimary)
}

layout.setTabTextColors(textColor, textColor)
layout.setSelectedTabIndicatorColor(underlineColor)
layout.setBackgroundColor(backgroundColor)
}
} */

/**
* Translates color attributes to colors
*
* @param c Context
* @param colorAttribute Color Attribute
* @return Requested Color
*/
@ColorInt
fun getColor(c: Context, @AttrRes colorAttribute: Int): Int {
if (mColorByAttr.containsKey(colorAttribute)) {
return mColorByAttr[colorAttribute] as Int
}

var matchedColor: Int

try {
val color = TypedValue()
c.theme.resolveAttribute(colorAttribute, color, true)
matchedColor = color.data
} catch (e: Exception) {
Timber.e(e, "Unable to get color")
matchedColor = ContextCompat.getColor(c, android.R.color.holo_red_dark)
}

mColorByAttr[colorAttribute] = matchedColor

return matchedColor
}

/**
* Get the resource Id applied to the current theme
*
* @param c the context
* @param resourceId the resource id
* @return the resource Id for the current theme
*/
fun getResourceId(c: Context, resourceId: Int): Int {
if (TextUtils.equals(getApplicationTheme(c), THEME_LIGHT_VALUE)
|| TextUtils.equals(getApplicationTheme(c), THEME_STATUS_VALUE)) {
return when (resourceId) {
R.drawable.line_divider_dark -> R.drawable.line_divider_light
R.style.Floating_Actions_Menu -> R.style.Floating_Actions_Menu_Light
else -> resourceId
}
}
return resourceId
}

/**
* Update the menu icons colors
*
* @param menu the menu
* @param color the color
*/
fun tintMenuIcons(menu: Menu, color: Int) {
for (i in 0 until menu.size()) {
val item = menu.getItem(i)
val drawable = item.icon
if (drawable != null) {
val wrapped = DrawableCompat.wrap(drawable)
drawable.mutate()
DrawableCompat.setTint(wrapped, color)
item.icon = drawable
}
}
}

/**
* Tint the drawable with a theme attribute
*
* @param context the context
* @param drawable the drawable to tint
* @param attribute the theme color
* @return the tinted drawable
*/
fun tintDrawable(context: Context, drawable: Drawable, @AttrRes attribute: Int): Drawable {
return tintDrawableWithColor(drawable, getColor(context, attribute))
}

/**
* Tint the drawable with a color integer
*
* @param drawable the drawable to tint
* @param color the color
* @return the tinted drawable
*/
fun tintDrawableWithColor(drawable: Drawable, @ColorInt color: Int): Drawable {
val tinted = DrawableCompat.wrap(drawable)
drawable.mutate()
DrawableCompat.setTint(tinted, color)
return tinted
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/button_disabled_text_color" android:state_enabled="false" />
<item android:color="@color/button_enabled_text_color" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorAccent" android:state_checked="true" />
<item android:color="@color/vector_silver_color" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/riot_primary_text_color_dark" android:state_enabled="true" />
<item android:color="@color/riot_primary_text_color_disabled_dark" android:state_enabled="false" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/riot_primary_text_color_light" android:state_enabled="true" />
<item android:color="@color/riot_secondary_text_color_light" android:state_enabled="false" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/riot_primary_text_color_status" android:state_enabled="true" />
<item android:color="@color/riot_primary_text_color_disabled_status" android:state_enabled="false" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#F7F7F7" />
</shape>
</item>

<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="#E4E4E4" />
</shape>
</item>


</layer-list>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="#00000000"
android:startColor="#8a000000"
android:type="linear" />
</shape>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<!-- required on android < 4.2 devices -->
<solid android:color="@android:color/transparent" />

<stroke
android:width="4dp"
android:color="@color/direct_chat_ring_color_black" />
</shape>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<!-- required on android < 4.2 devices -->
<solid android:color="@android:color/transparent" />

<stroke
android:width="4dp"
android:color="@color/direct_chat_ring_color_dark" />
</shape>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<!-- required on android < 4.2 devices -->
<solid android:color="@android:color/transparent" />

<stroke
android:width="4dp"
android:color="@color/direct_chat_ring_color_light" />
</shape>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<!-- required on android < 4.2 devices -->
<solid android:color="@android:color/transparent" />

<stroke
android:width="4dp"
android:color="@color/direct_chat_ring_color_status" />
</shape>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<size
android:width="1dp"
android:height="1dp" />

<solid android:color="@color/list_divider_color_dark" />

</shape>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<size
android:width="1dp"
android:height="1dp" />

<solid android:color="@color/list_divider_color_light" />

</shape>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="@color/vector_fuchsia_color" />
</shape>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#343a46" />
</shape>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#1A000000" />
</shape>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#1A000000" />
</shape>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#343a46" />
</shape>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#1A000000" />
</shape>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#1A000000" />
</shape>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<!--item
android:drawable="@drawable/riot_splash_0_blue"
android:duration="@integer/splash_animation_velocity" />
<item
android:drawable="@drawable/riot_splash_1_green"
android:duration="@integer/splash_animation_velocity" />
<item
android:drawable="@drawable/riot_splash_2_pink"
android:duration="@integer/splash_animation_velocity" />
<item
android:drawable="@drawable/riot_splash_3_red"
android:duration="@integer/splash_animation_velocity" /-->
</animation-list>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:width="1dp" />
<solid android:color="#7D7D7D" />
</shape>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<gradient
android:angle="90"
android:endColor="#1a1a1a"
android:startColor="#212121"
android:type="linear" />
</shape>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<gradient
android:angle="90"
android:endColor="#c0c0c0"
android:startColor="#e1e1e1"
android:type="linear" />
</shape>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<gradient
android:angle="90"
android:endColor="#212121"
android:startColor="#1a1a1a" />
</shape>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<gradient
android:angle="90"
android:endColor="#e1e1e1"
android:startColor="#d3d3d3" />
</shape>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- The android:opacity=”opaque” linethis is critical in preventing a flash of black as your theme transitions. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">

<!-- Background color -->
<item android:drawable="@color/riot_primary_background_color_light" />

<!-- Centered logo -->
<!--item>
<bitmap
android:gravity="center"
android:src="@drawable/riot_splash_0_blue" />
</item-->

</layer-list>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="@color/list_divider_color_light" />
<padding
android:bottom="5dp"
android:left="8dp"
android:right="5dp"
android:top="5dp" />
</shape>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="15dp"
android:height="12dp"
android:viewportWidth="100"
android:viewportHeight="100">
<group android:name="triableGroup">
<path
android:name="triangle"
android:fillColor="#339D9D9D"
android:pathData="m 50,0 l 50,100 -100,0 z" />
</group>
</vector>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#4d4d4d" />
<padding
android:bottom="4dp"
android:left="16dp"
android:right="16dp"
android:top="4dp" />
<corners android:radius="3dp" />
</shape>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFF2F2F2" />
<padding
android:bottom="4dp"
android:left="16dp"
android:right="16dp"
android:top="4dp" />
<corners android:radius="3dp" />
</shape>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#28000000" />
<corners
android:bottomLeftRadius="23dp"
android:bottomRightRadius="23dp"
android:topLeftRadius="23dp"
android:topRightRadius="23dp" />
</shape>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Non focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_dark" android:state_focused="false" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_dark" android:state_focused="false" android:state_pressed="false" android:state_selected="true" />

<!-- Focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_dark" android:state_focused="true" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_dark" android:state_focused="true" android:state_pressed="false" android:state_selected="true" />

<!-- Pressed -->
<!-- Non focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_dark" android:state_focused="false" android:state_pressed="true" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_dark" android:state_focused="false" android:state_pressed="true" android:state_selected="true" />

<!-- Focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_dark" android:state_focused="true" android:state_pressed="true" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_dark" android:state_focused="true" android:state_pressed="true" android:state_selected="true" />

</selector>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Non focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_group_light" android:state_focused="false" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_group_light" android:state_focused="false" android:state_pressed="false" android:state_selected="true" />

<!-- Focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_group_light" android:state_focused="true" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_group_light" android:state_focused="true" android:state_pressed="false" android:state_selected="true" />

<!-- Pressed -->
<!-- Non focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_group_light" android:state_focused="false" android:state_pressed="true" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_group_light" android:state_focused="false" android:state_pressed="true" android:state_selected="true" />

<!-- Focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_group_light" android:state_focused="true" android:state_pressed="true" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_group_light" android:state_focused="true" android:state_pressed="true" android:state_selected="true" />

</selector>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Non focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_light" android:state_focused="false" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_light" android:state_focused="false" android:state_pressed="false" android:state_selected="true" />

<!-- Focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_light" android:state_focused="true" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_light" android:state_focused="true" android:state_pressed="false" android:state_selected="true" />

<!-- Pressed -->
<!-- Non focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_light" android:state_focused="false" android:state_pressed="true" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_light" android:state_focused="false" android:state_pressed="true" android:state_selected="true" />

<!-- Focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_light" android:state_focused="true" android:state_pressed="true" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_light" android:state_focused="true" android:state_pressed="true" android:state_selected="true" />

</selector>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Non focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_status" android:state_focused="false" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_status" android:state_focused="false" android:state_pressed="false" android:state_selected="true" />

<!-- Focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_status" android:state_focused="true" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_status" android:state_focused="true" android:state_pressed="false" android:state_selected="true" />

<!-- Pressed -->
<!-- Non focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_status" android:state_focused="false" android:state_pressed="true" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_status" android:state_focused="false" android:state_pressed="true" android:state_selected="true" />

<!-- Focused states -->
<item android:drawable="@drawable/vector_tabbar_unselected_background_status" android:state_focused="true" android:state_pressed="true" android:state_selected="false" />
<item android:drawable="@drawable/vector_tabbar_selected_background_status" android:state_focused="true" android:state_pressed="true" android:state_selected="true" />

</selector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/list_divider_color_dark" />
<padding android:bottom="1dp" />
</shape>
</item>

<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<padding android:bottom="2dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/tab_bar_selected_background_color_dark" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/list_divider_color_light" />
<padding android:bottom="1dp" />
</shape>
</item>

<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<padding android:bottom="2dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/tab_groups" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/list_divider_color_light" />
<padding android:bottom="1dp" />
</shape>
</item>

<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<padding android:bottom="2dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/tab_bar_selected_background_color_light" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/list_divider_color_light" />
<padding android:bottom="1dp" />
</shape>
</item>

<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<padding android:bottom="2dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/tab_bar_selected_background_color_status" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/tab_bar_unselected_background_color_dark" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/tab_groups" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/tab_bar_unselected_background_color_light" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/tab_bar_unselected_background_color_status" />
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,192 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
style="@style/VectorToolbarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<LinearLayout
android:id="@+id/bug_report_body_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">

<TextView
android:id="@+id/bug_report_progress_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/send_bug_report_progress"
android:visibility="gone"
tools:visibility="visible" />

<ProgressBar
android:id="@+id/bug_report_progress_view"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:max="100"
android:visibility="gone"
tools:progress="70"
tools:visibility="visible" />

<ScrollView
android:id="@+id/bug_report_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/send_bug_report_description" />

<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:textColorHint="?attr/vctr_default_text_hint_color">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/bug_report_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/send_bug_report_placeholder"
android:minHeight="40dp"
android:textColor="?android:textColorPrimary" />

</com.google.android.material.textfield.TextInputLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/send_bug_report_description_in_english"
android:textSize="12sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/send_bug_report_logs_description" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<CheckBox
android:id="@+id/bug_report_button_include_logs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="@string/send_bug_report_include_logs" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<CheckBox
android:id="@+id/bug_report_button_include_crash_logs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="@string/send_bug_report_include_crash_logs" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<CheckBox
android:id="@+id/bug_report_button_include_screenshot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="@string/send_bug_report_include_screenshot" />
</LinearLayout>

<ImageView
android:id="@+id/bug_report_screenshot_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:adjustViewBounds="true"
android:maxWidth="260dp"
android:scaleType="fitCenter"
tools:src="@tools:sample/backgrounds/scenic" />

</LinearLayout>
</ScrollView>
</LinearLayout>

<View
android:id="@+id/bug_report_mask_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:clickable="true"
android:visibility="gone" />
</LinearLayout>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.matrix.vector.activity.RoomActivity">

<item
android:id="@+id/ic_action_send_bug_report"
android:icon="@drawable/ic_material_send_black"
android:title="@string/send_bug_report"
app:showAsAction="always" />
</menu>

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<declare-styleable name="VectorStyles">

<attr name="vctr_bottom_nav_background_color" format="color" />

<!-- waiting view background -->
<attr name="vctr_waiting_background_color" format="color" />

<!-- application bar text color -->
<attr name="vctr_toolbar_primary_text_color" format="color" />
<attr name="vctr_toolbar_secondary_text_color" format="color" />
<attr name="vctr_toolbar_link_text_color" format="color" />

<!-- application bar text hint color -->
<attr name="vctr_primary_hint_text_color" format="color" />

<!-- default text colors -->
<attr name="vctr_default_text_hint_color" format="color" />

<!-- room message colors -->
<attr name="vctr_unread_room_indent_color" format="color" />
<attr name="vctr_unsent_message_text_color" format="color" />
<attr name="vctr_message_text_color" format="color" />
<attr name="vctr_notice_text_color" format="color" />
<attr name="vctr_notice_secondary" format="color" />
<attr name="vctr_encrypting_message_text_color" format="color" />
<attr name="vctr_sending_message_text_color" format="color" />
<attr name="vctr_highlighted_message_text_color" format="color" />
<attr name="vctr_highlighted_searched_message_text_color" format="color" />
<attr name="vctr_search_mode_room_name_text_color" format="color" />
<attr name="vctr_unread_marker_line_color" format="color" />
<attr name="vctr_markdown_block_background_color" format="color" />
<attr name="vctr_room_activity_divider_color" format="color" />

<!-- tab bar colors -->
<attr name="vctr_tab_bar_inverted_background_color" format="color" />
<attr name="vctr_tab_bar_selected_background_color" format="color" />
<attr name="vctr_tab_bar_unselected_background_color" format="color" />

<!-- list colors -->
<attr name="vctr_list_header_background_color" format="color" />
<attr name="vctr_list_header_primary_text_color" format="color" />
<attr name="vctr_list_header_secondary_text_color" format="color" />

<attr name="vctr_list_divider_color" format="color" />

<!-- gradient on the bottom of some activities -->
<attr name="vctr_activity_bottom_gradient_color" format="color" />

<!-- outgoing call background color -->
<attr name="vctr_pending_outgoing_view_background_color" format="color" />

<!-- multi selection member background color -->
<attr name="vctr_multi_selection_background_color" format="color" />

<!-- sliding menu icon colors -->
<attr name="vctr_home_navigation_icon_color" format="color" />

<!-- room notification text color (typing, unsent...) -->
<attr name="vctr_room_notification_text_color" format="color" />

<!-- color for dividers in settings -->
<attr name="vctr_preference_divider_color" format="color" />

<!-- icon colors -->
<attr name="vctr_icon_tint_on_light_action_bar_color" format="color" />
<attr name="vctr_icon_tint_on_dark_action_bar_color" format="color" />
<attr name="vctr_settings_icon_tint_color" format="color" />

<!-- Tab home colors -->
<attr name="vctr_tab_home" format="color" />
<attr name="vctr_tab_home_secondary" format="color" />

<!-- theses colours are requested a background cannot be set by an ?att on android < 5 -->
<!-- dedicated drawables are created for each theme -->
<attr name="vctr_line_divider" format="reference" />
<attr name="vctr_shadow_bottom" format="reference" />
<attr name="vctr_shadow_top" format="reference" />
<attr name="vctr_tabbar_selected_background" format="reference" />
<attr name="vctr_tabbar_unselected_background" format="reference" />
<attr name="vctr_tabbar_background" format="reference" />
<attr name="vctr_direct_chat_circle" format="reference" />

<attr name="vctr_pill_background_user_id" format="reference" />
<attr name="vctr_pill_background_room_alias" format="reference" />
<attr name="vctr_pill_text_color_user_id" format="reference" />
<attr name="vctr_pill_text_color_room_alias" format="reference" />

<!-- Widget banner background -->
<attr name="vctr_widget_banner_background" format="color" />

</declare-styleable>
</resources>

View File

@ -18,8 +18,4 @@
<color name="brown_grey">#a5a5a5</color> <color name="brown_grey">#a5a5a5</color>
<color name="grey_lynch">#61708B</color> <color name="grey_lynch">#61708B</color>


<color name="vector_silver_color">#FFC7C7C7</color>
<color name="vector_dark_grey_color">#FF999999</color>
<color name="vector_fuchsia_color">#FFF56679</color>

</resources> </resources>

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- Error colors -->
<color name="vector_success_color">#70BF56</color>
<color name="vector_warning_color">#ff4b55</color>
<color name="vector_error_color">#ff4b55</color>

<!-- main app colors -->
<color name="vector_fuchsia_color">#ff4b55</color>
<color name="vector_silver_color">#FFC7C7C7</color>
<color name="vector_dark_grey_color">#FF999999</color>

<!-- home activity tab bar color -->
<color name="tab_favourites">#BD79CC</color>
<color name="tab_favourites_secondary">#744C7F</color>
<color name="tab_people">#F8A15F</color>
<color name="tab_people_secondary">#D97051</color>
<color name="tab_rooms">@color/accent_color_light</color>
<color name="tab_rooms_secondary">#5EA584</color>
<color name="tab_groups">#a6d0e5</color>
<color name="tab_groups_secondary">#81bddb</color>

<!-- color of the direct chat avatar ring (it's 50% of color accent) -->
<color name="direct_chat_ring_color_light">#7F03b381</color>
<color name="direct_chat_ring_color_dark">#7F03b381</color>
<color name="direct_chat_ring_color_black">#7F03b381</color>
<color name="direct_chat_ring_color_status">#7F586C7B</color>

<!-- theses colours are requested a background cannot be set by an ?attr on android < 5 -->
<!-- dedicated drawables are created for each theme -->
<!-- Default/Background-->
<color name="riot_primary_background_color_light">#FFFFFFFF</color>
<!-- Dark/Background-->
<color name="riot_primary_background_color_dark">#FF181B21</color>
<!-- Black/Background-->
<color name="riot_primary_background_color_black">#F000</color>
<color name="riot_primary_background_color_status">#FFEEF2F5</color>

<!--Default/Android Status Bar-->
<color name="primary_color_dark_light">#FF1A2027</color>
<!--Default/Base-->
<color name="primary_color_light">#FF27303A</color>
<!--Default/Accent-->
<color name="accent_color_light">#03b381</color>

<!--Dark/Android Status Bar-->
<color name="primary_color_dark_dark">#FF0D0E10</color>
<!--Dark/Base-->
<color name="primary_color_dark">#FF15171B</color>
<!--Dark/Accent-->
<color name="accent_color_dark">#03b381</color>

<!--Black/Android Status Bar-->
<color name="primary_color_dark_black">#000</color>
<!--Black/Base-->
<color name="primary_color_black">#FF060708</color>

<color name="primary_color_dark_status">#FF465561</color>
<color name="primary_color_status">#FF586C7B</color>
<color name="accent_color_status">#FF586C7B</color>

<!--Default/Line break mobile-->
<color name="list_divider_color_light">#EEEFEF</color>
<!--Dark/Line break mobile-->
<color name="list_divider_color_dark">#FF61708B</color>
<!--Black/Line break mobile-->
<color name="list_divider_color_black">#FF22262E</color>

<color name="tab_bar_selected_background_color_light">@color/primary_color_light</color>
<color name="tab_bar_selected_background_color_dark">@color/primary_color_dark</color>
<color name="tab_bar_selected_background_color_status">@color/primary_color_status</color>

<color name="tab_bar_unselected_background_color_light">@color/primary_color_light</color>
<color name="tab_bar_unselected_background_color_dark">@color/primary_color_dark</color>
<color name="tab_bar_unselected_background_color_status">@color/primary_color_status</color>

<!-- Hint Colors -->
<color name="primary_hint_text_color_light">#FFFFFF</color>
<color name="primary_hint_text_color_dark">#FFFFFF</color>

<color name="default_text_hint_color_light">#903C3C3C</color>
<color name="default_text_hint_color_dark">#CCDDDDDD</color>

<!-- Text Colors -->
<!--Default/Text Primary-->
<color name="riot_primary_text_color_light">#FF2E2F32</color>
<color name="riot_primary_text_color_disabled_light">#FF9E9E9E</color>
<!--Default/Text Secondary-->
<color name="riot_secondary_text_color_light">#FF9E9E9E</color>
<color name="riot_tertiary_text_color_light">@color/riot_primary_text_color_light</color>

<!--Dark /Text Primary-->
<color name="riot_primary_text_color_dark">#FFEDF3FF</color>
<color name="riot_primary_text_color_disabled_dark">#FFA1B2D1</color>
<!--Dark /Text Secondary-->
<color name="riot_secondary_text_color_dark">#FFA1B2D1</color>
<color name="riot_tertiary_text_color_dark">@color/riot_primary_text_color_dark</color>

<!-- Status/Text Primary-->
<color name="riot_primary_text_color_status">#FF70808D</color>
<color name="riot_primary_text_color_disabled_status">#7F70808D</color>
<!-- Status/Text Secondary-->
<color name="riot_secondary_text_color_status">#7F70808D</color>
<color name="riot_tertiary_text_color_status">@color/riot_primary_text_color_status</color>

<!-- Quote Colors -->
<color name="quote_strip_color">#FFDDDDDD</color>
<color name="quote_background_color">@android:color/transparent</color>

<!-- Notification view colors -->
<color name="soft_resource_limit_exceeded">#2f9edb</color>
<color name="hard_resource_limit_exceeded">@color/vector_fuchsia_color</color>

<!-- Avatar colors -->
<color name="avatar_color_1">#03b381</color>
<color name="avatar_color_2">#368bd6</color>
<color name="avatar_color_3">#ac3ba8</color>

<!-- Password Strength bar colors -->
<color name="password_strength_bar_weak">#FFF56679</color>
<color name="password_strength_bar_low">#FFFFC666</color>
<color name="password_strength_bar_ok">#FFF8E71C</color>
<color name="password_strength_bar_strong">#FF7AC9A1</color>
<color name="password_strength_bar_undefined">#FF9E9E9E</color>

<!-- Button color -->
<color name="button_enabled_text_color">#FFFFFFFF</color>
<color name="button_disabled_text_color">#FF7F7F7F</color>

<!-- User names color -->
<color name="username_1">#368bd6</color>
<color name="username_2">#ac3ba8</color>
<color name="username_3">#03b381</color>
<color name="username_4">#e64f7a</color>
<color name="username_5">#ff812d</color>
<color name="username_6">#2dc2c5</color>
<color name="username_7">#5c56f5</color>
<color name="username_8">#74d12c</color>

<!-- Link color -->
<color name="link_color_light">#368BD6</color>
<color name="link_color_dark">#368BD6</color>
<color name="link_color_status">#368BD6</color>

<!-- Notification (do not depends on theme -->
<color name="notification_accent_color">#368BD6</color>


</resources>

View File

@ -1,4 +0,0 @@
<resources>


</resources>

View File

@ -0,0 +1,249 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- ************************ Common items ************************ -->

<!-- Launcher Theme, only used for VectorLauncherActivity (will be use even before the Activity is started) -->
<style name="AppTheme.Launcher" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>

<item name="colorPrimaryDark">@color/primary_color_dark</item>
</style>

<!-- toolbar styles-->
<style name="VectorToolbarStyle" parent="Widget.AppCompat.Toolbar">
<item name="android:background">?colorPrimary</item>
<item name="background">?colorPrimary</item>

<!-- main text -->
<item name="titleTextAppearance">@style/Vector.Toolbar.Title</item>
<item name="subtitleTextAppearance">@style/Vector.Toolbar.SubTitle</item>

<item name="theme">@style/VectorToolbarTheme</item>
</style>

<style name="VectorToolbarStyle.Group">
<item name="android:background">@color/tab_groups</item>
<item name="background">@color/tab_groups</item>
</style>

<style name="VectorToolbarTheme">
<!-- toolbar icons -->
<item name="colorControlNormal">@android:color/white</item>
</style>

<style name="Vector.Toolbar.Title" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">20sp</item>
<item name="android:textColor">?attr/vctr_toolbar_primary_text_color</item>
<item name="android:fontFamily">"sans-serif-medium"</item>
</style>

<style name="Vector.Toolbar.SubTitle" parent="TextAppearance.Widget.AppCompat.Toolbar.Subtitle">
<item name="android:textSize">16sp</item>
<item name="android:textColor">?attr/vctr_toolbar_primary_text_color</item>
<item name="android:fontFamily">"sans-serif"</item>
</style>

<!-- tabbar text color -->
<style name="Vector.TabText" parent="Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">@android:color/white</item>
</style>


<style name="Vector.PopupMenuBase" parent="Widget.AppCompat.PopupMenu">
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textSize">16sp</item>
<item name="android:dropDownHorizontalOffset">0dp</item>
<item name="android:dropDownVerticalOffset">0dp</item>
</style>

<style name="Vector.PopupMenu" parent="Vector.PopupMenuBase">
<!--
Before Lollipop the popup background is white on dark theme, so force color here.
(v21 will revert back to default drawable)
-->
<item name="android:popupBackground">?colorBackgroundFloating</item>
</style>

<!-- actionbar icons color -->
<style name="Vector.ActionBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="colorControlNormal">@android:color/white</item>
</style>

<!-- custom action bar -->
<style name="Vector.Styled.ActionBar" parent="Widget.AppCompat.Toolbar">
<item name="android:background">?colorPrimary</item>
<item name="background">?colorPrimary</item>

<!-- remove shadow under the action bar -->
<item name="elevation">0dp</item>

<!-- main text -->
<item name="titleTextStyle">@style/ActionBarTitleText</item>

<!-- sub text -->
<item name="subtitleTextStyle">@style/ActionBarSubTitleText</item>
</style>

<!-- main text -->
<style name="ActionBarTitleText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">?attr/vctr_toolbar_primary_text_color</item>
<item name="android:fontFamily">"sans-serif-medium"</item>
<item name="android:textSize">20sp</item>
</style>

<!-- sub text -->
<style name="ActionBarSubTitleText" parent="TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
<item name="android:textColor">?attr/vctr_toolbar_primary_text_color</item>
<item name="android:fontFamily">"sans-serif-medium"</item>
<item name="android:textSize">12sp</item>
</style>

<!-- home scroller menu -->
<style name="NavigationViewStyle">
<item name="android:textSize">14sp</item>
</style>

<!-- Styles for login screen -->
<style name="LoginEditTextStyle" parent="Widget.AppCompat.EditText">
<item name="android:textSize">16sp</item>
</style>

<!-- Styles for button -->
<!--
Widget.AppCompat.Button.Colored, which sets the button color to colorAccent,
using colorControlHighlight as an overlay for focused and pressed states.
-->
<style name="VectorButtonStyle" parent="Widget.AppCompat.Button.Colored">
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item>
<item name="android:minWidth">94dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:textColor">@color/button_text_color_selector</item>
</style>

<!--Widget.AppCompat.Button.Borderless.Colored, which sets the text color to colorAccent,
using colorControlHighlight as an overlay for focused and pressed states.-->
<style name="VectorButtonStyleFlat" parent="Widget.AppCompat.Button.Borderless.Colored">
<item name="android:textStyle">bold</item>
<item name="android:textAllCaps">false</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="colorControlHighlight">?colorAccent</item>
</style>

<style name="VectorSearches.EditText" parent="Widget.AppCompat.EditText">
<item name="android:textCursorDrawable">@drawable/searches_cursor_background</item>
<item name="android:background">@android:color/transparent</item>
<item name="background">@android:color/transparent</item>
</style>

<style name="VectorSearches.Styled.ActionBar" parent="Vector.Styled.ActionBar">
<item name="android:background">?android:attr/colorBackground</item>
<item name="background">?android:attr/colorBackground</item>
</style>

<!-- tabbar text color -->
<style name="VectorSearches.TabText" parent="Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">?attr/colorAccent</item>
</style>

<style name="VectorSearches.ActionBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="colorControlNormal">?attr/colorAccent</item>
</style>

<style name="VectorPeopleSearches.TabLayout" parent="Widget.Design.TabLayout">
<item name="tabGravity">fill</item>
<item name="tabMode">fixed</item>
<item name="tabPaddingStart">0dp</item>
<item name="tabPaddingEnd">0dp</item>
<item name="tabBackground">?attr/colorAccent</item>
<item name="tabTextColor">@android:color/white</item>
<item name="tabSelectedTextColor">@android:color/white</item>
<item name="tabIndicatorColor">@android:color/white</item>
<item name="tabMaxWidth">0dp</item>
</style>

<style name="VectorUnifiedSearches.TabLayout" parent="Widget.Design.TabLayout">
<item name="tabGravity">fill</item>
<item name="tabMode">fixed</item>
<item name="tabPaddingStart">0dp</item>
<item name="tabPaddingEnd">0dp</item>
<item name="tabBackground">?attr/vctr_tab_bar_inverted_background_color</item>
<item name="tabTextColor">?attr/colorAccent</item>
<item name="tabSelectedTextColor">?attr/colorAccent</item>
<item name="tabIndicatorColor">?attr/colorAccent</item>
<item name="tabMaxWidth">0dp</item>
</style>

<style name="ListHeader">
<item name="android:textSize">14sp</item>
<item name="android:textColor">?vctr_list_header_primary_text_color</item>
<item name="android:textAllCaps">true</item>
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:background">?vctr_list_header_background_color</item>
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
</style>

<style name="SpinnerTheme">
<item name="colorControlNormal">?attr/vctr_list_header_primary_text_color</item>
</style>

<style name="PopMenuStyle" parent="Widget.AppCompat.PopupMenu">
<item name="android:textSize">14sp</item>
</style>

<!--style name="Floating_Action_Button">
<item name="fab_labelsPosition">left</item>
</style-->

<style name="Floating_Actions_Menu">
<item name="android:background">@drawable/vector_background_fab_label</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>

<style name="Floating_Actions_Menu.Light">
<item name="android:background">@drawable/vector_background_fab_label_light</item>
</style>

<style name="Vector.TabView.Group" parent="Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/vector_tabbar_background_group_light</item>
<item name="background">@drawable/vector_tabbar_background_group_light</item>
</style>

<!-- Linear Layout orientation, depending on screen size. Vertical by default -->
<style name="VectorLinearLayout">
<item name="android:gravity">end</item>
<item name="android:orientation">vertical</item>
</style>

<!-- BottomSheet theming -->
<style name="Vector.BottomSheet.Dark" parent="Theme.Design.BottomSheetDialog">
<item name="android:textColorPrimary">@color/riot_primary_text_color_dark</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_dark</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_dark</item>
</style>

<style name="Vector.BottomSheet.Light" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:textColorPrimary">@color/riot_primary_text_color_light</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_light</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_light</item>
</style>

<style name="Vector.BottomSheet.Status" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:textColorPrimary">@color/riot_primary_text_color_status</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_status</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_status</item>
</style>

</resources>

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- BLACK THEME COLORS -->

<style name="AppTheme.Base.Black" parent="AppTheme.Base.Dark">
<!-- Only setting the items we need to override to get the background to be pure black, otherwise inheriting -->

<item name="colorPrimaryDark">@color/primary_color_dark_black</item>
<item name="colorPrimary">@color/primary_color_black</item>

<!-- list colors -->
<!--Header/Panel Background-->
<item name="vctr_list_header_background_color">#FF090A0C</item>
<!--Header/Panel Text Primary-->
<item name="vctr_tab_home">@color/primary_color_black</item>
<!--Header/Panel Text Secondary-->
<item name="vctr_tab_home_secondary">@color/primary_color_dark_black</item>
<item name="vctr_list_divider_color">@color/list_divider_color_black</item>

<!-- color for dividers in settings -->
<item name="vctr_preference_divider_color">@color/list_divider_color_black</item>

<item name="android:colorBackground">@color/riot_primary_background_color_black</item>
<item name="vctr_markdown_block_background_color">#FF4D4D4D</item>

<!-- activities background -->
<item name="android:windowBackground">@color/riot_primary_background_color_black</item>
<item name="vctr_bottom_nav_background_color">@color/primary_color_black</item>

<item name="vctr_direct_chat_circle">@drawable/direct_chat_circle_black</item>
</style>

<style name="AppTheme.Black" parent="AppTheme.Base.Black" />

<style name="Theme.Vector.Lock.Black" parent="Theme.Vector.Lock.Dark">
<item name="colorPrimary">@color/riot_primary_background_color_black</item>
<item name="android:colorBackground">@color/riot_primary_background_color_black</item>
</style>

<!-- home activity -->
<style name="HomeActivityTheme.Black" parent="AppTheme.Black">
<item name="editTextColor">?android:attr/textColorPrimary</item>
<item name="android:editTextColor">?android:attr/textColorPrimary</item>
<item name="android:textColorHint">?attr/vctr_default_text_hint_color</item>
</style>

<!-- call activity -->
<style name="CallActivityTheme.Black" parent="AppTheme.Black">
<!-- status bar color -->
<item name="colorPrimaryDark">@android:color/black</item>
</style>

<!-- NoActionBar + FullScreen -->
<style name="AppTheme.NoActionBar.FullScreen.Black" parent="AppTheme.Black">
<item name="android:windowFullscreen">true</item>
<!-- activities background -->
<item name="android:windowBackground">@android:color/transparent</item>
</style>

<!-- Picker activities -->
<style name="CountryPickerTheme.Black" parent="AppTheme.Black">
<item name="editTextColor">@android:color/white</item>
<item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">?attr/vctr_activity_bottom_gradient_color</item>
</style>

<!-- searches activity -->
<style name="SearchesAppTheme.Black" parent="AppTheme.Black">
<!-- custom action bar -->
<item name="android:actionBarStyle">@style/VectorSearches.Styled.ActionBar</item>
<item name="actionBarStyle">@style/VectorSearches.Styled.ActionBar</item>

<!-- no divider -->
<item name="android:actionBarDivider">@null</item>

<!-- edit text -->
<item name="android:editTextStyle">@style/VectorSearches.EditText</item>

<!-- actionbar icons color -->
<item name="actionBarTheme">@style/VectorSearches.ActionBarTheme</item>
</style>

<style name="CallAppTheme.Black" parent="AppTheme.Black">
<item name="android:colorBackground">?attr/colorBackgroundFloating</item>
<item name="android:colorBackgroundCacheHint">@null</item>

<item name="android:windowFrame">@null</item>
<item name="android:windowTitleStyle">@style/RtlOverlay.DialogWindowTitle.AppCompat</item>
<item name="android:windowTitleBackgroundStyle">
@style/Base.DialogWindowTitleBackground.AppCompat
</item>
<item name="android:windowBackground">@drawable/abc_dialog_material_background</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@style/Animation.AppCompat.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>

<item name="windowActionModeOverlay">true</item>

<item name="listPreferredItemPaddingLeft">24dip</item>
<item name="listPreferredItemPaddingRight">24dip</item>

<item name="android:listDivider">@null</item>
</style>

<style name="GroupAppTheme.Black" parent="AppTheme.Black">
<item name="colorPrimaryDark">@color/tab_groups_secondary</item>

<item name="android:actionBarTabStyle">@style/Vector.TabView.Group</item>
<item name="actionBarTabStyle">@style/Vector.TabView.Group</item>
</style>

</resources>

View File

@ -0,0 +1,263 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- DARK THEME COLORS -->

<style name="AppTheme.Base.Dark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimaryDark">@color/primary_color_dark_dark</item>
<item name="colorPrimary">@color/primary_color_dark</item>
<item name="colorAccent">@color/accent_color_dark</item>

<item name="android:textColorPrimary">@color/primary_text_color_selector_dark</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_dark</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_dark</item>

<item name="android:textColorLink">@color/link_color_dark</item>

<!-- Menu text color -->
<item name="android:actionMenuTextColor">#FFFFFFFF</item>

<!-- default background color -->
<item name="android:colorBackground">@color/riot_primary_background_color_dark</item>
<item name="vctr_bottom_nav_background_color">@color/primary_color_dark</item>

<!-- waiting view background -->
<item name="vctr_waiting_background_color">#55555555</item>


<!-- application bar text color -->
<item name="vctr_toolbar_primary_text_color">@color/riot_primary_text_color_dark</item>
<item name="vctr_toolbar_secondary_text_color">@color/riot_secondary_text_color_dark</item>
<item name="vctr_toolbar_link_text_color">@color/link_color_dark</item>

<!-- application bar text hint color -->
<item name="vctr_primary_hint_text_color">@color/primary_hint_text_color_dark</item>

<item name="vctr_tab_home">@color/primary_color_dark</item>
<item name="vctr_tab_home_secondary">@color/primary_color_dark_dark</item>

<!-- default text colors -->
<item name="vctr_default_text_hint_color">@color/default_text_hint_color_dark</item>

<!-- room message colors -->
<!--Unread Room Indent-->
<item name="vctr_unread_room_indent_color">#FF2E3648</item>
<item name="vctr_notice_secondary">#61708B</item>
<item name="vctr_unsent_message_text_color">@color/vector_fuchsia_color</item>
<item name="vctr_message_text_color">@android:color/white</item>
<item name="vctr_notice_text_color">@color/riot_primary_text_color_dark</item>
<item name="vctr_encrypting_message_text_color">@color/accent_color_dark</item>
<item name="vctr_sending_message_text_color">?android:textColorSecondary</item>
<item name="vctr_highlighted_message_text_color">@color/vector_fuchsia_color</item>
<item name="vctr_highlighted_searched_message_text_color">@color/primary_color_light</item>
<item name="vctr_search_mode_room_name_text_color">#CCC3C3C3</item>
<item name="vctr_unread_marker_line_color">@color/accent_color_dark</item>
<item name="vctr_markdown_block_background_color">@android:color/black</item>
<item name="vctr_room_activity_divider_color">#565656</item>

<!-- tab bar colors -->
<item name="vctr_tab_bar_inverted_background_color">?colorPrimary</item>
<item name="vctr_tab_bar_selected_background_color">
@color/tab_bar_selected_background_color_dark
</item>
<item name="vctr_tab_bar_unselected_background_color">
@color/tab_bar_unselected_background_color_dark
</item>

<!-- list colors -->
<!--Header/Panel Background-->
<item name="vctr_list_header_background_color">@color/primary_color_dark</item>
<!--Header/Panel Text Primary-->
<item name="vctr_list_header_primary_text_color">#FFA1B2D1</item>
<!--Header/Panel Text Secondary-->
<item name="vctr_list_header_secondary_text_color">#FFC8C8CD</item>

<item name="vctr_list_divider_color">@color/list_divider_color_dark</item>

<!-- gradient on the home bottom -->
<item name="vctr_activity_bottom_gradient_color">#80000000</item>

<!-- outgoing call background color -->
<item name="vctr_pending_outgoing_view_background_color">#33FFFFFF</item>

<!-- multi selection member background color -->
<item name="vctr_multi_selection_background_color">#4d4d4d</item>

<!-- sliding menu icon colors -->
<item name="vctr_home_navigation_icon_color">@color/riot_primary_text_color_dark</item>

<!-- room notification text color (typing, unsent...) -->
<!--Notice (secondary)-->
<item name="vctr_room_notification_text_color">#FF61708b</item>

<!-- color for dividers in settings -->
<item name="vctr_preference_divider_color">@color/list_divider_color_dark</item>

<!-- icon colors -->
<item name="vctr_settings_icon_tint_color">@android:color/white</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@android:color/white</item>
<item name="vctr_icon_tint_on_dark_action_bar_color">@android:color/white</item>

<!-- theses colours are requested a background cannot be set by an ?att on android < 5 -->
<!-- dedicated drawables are created for each theme -->
<item name="vctr_line_divider">@drawable/line_divider_dark</item>
<item name="vctr_shadow_bottom">@drawable/shadow_bottom_dark</item>
<item name="vctr_shadow_top">@drawable/shadow_top_dark</item>
<item name="vctr_tabbar_selected_background">
@drawable/vector_tabbar_selected_background_dark
</item>
<item name="vctr_tabbar_unselected_background">
@drawable/vector_tabbar_unselected_background_dark
</item>
<item name="vctr_tabbar_background">@drawable/vector_tabbar_background_dark</item>

<item name="vctr_pill_background_user_id">@drawable/pill_background_user_id_dark</item>
<item name="vctr_pill_background_room_alias">@drawable/pill_background_room_alias_dark</item>

<item name="vctr_pill_text_color_user_id">@android:color/white</item>
<item name="vctr_pill_text_color_room_alias">@color/riot_primary_text_color_dark</item>

<item name="vctr_direct_chat_circle">@drawable/direct_chat_circle_dark</item>

<item name="vctr_widget_banner_background">#FF454545</item>

<!-- ANDROID SUPPORT ATTRIBUTES -->
<!-- disable the overscroll because setOverscrollHeader/Footer don't always work -->
<item name="android:overScrollMode">never</item>

<!-- activities background -->
<item name="android:windowBackground">@color/riot_primary_background_color_dark</item>

<!-- fonts -->
<item name="android:typeface">sans</item>

<!-- custom action bar -->
<item name="android:actionBarStyle">@style/Vector.Styled.ActionBar</item>
<item name="actionBarStyle">@style/Vector.Styled.ActionBar</item>

<!-- actionbar icons color -->
<item name="actionBarTheme">@style/Vector.ActionBarTheme</item>

<!-- remove the shadow under the actionbar -->
<item name="android:windowContentOverlay">@null</item>

<item name="android:popupMenuStyle">@style/Vector.PopupMenu</item>

<!-- no divider -->
<item name="android:actionBarDivider">@null</item>

<!-- tabbar background -->
<item name="android:actionBarTabStyle">@style/Vector.TabView.Dark</item>
<item name="actionBarTabStyle">@style/Vector.TabView.Dark</item>

<!-- tabbar text color -->
<item name="android:actionBarTabTextStyle">@style/Vector.TabText</item>
<item name="actionBarTabTextStyle">@style/Vector.TabText</item>

<!-- Preference -->
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>

<item name="bottomSheetDialogTheme">@style/Vector.BottomSheet.Dark</item>
</style>

<style name="AppTheme.Dark" parent="AppTheme.Base.Dark" />

<style name="Theme.Vector.Lock.Dark" parent="Theme.AppCompat.Dialog">
<item name="colorPrimary">@color/primary_color_dark</item>
<item name="colorAccent">@color/accent_color_dark</item>

<item name="android:textColorPrimary">@color/riot_primary_text_color_dark</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_dark</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_dark</item>

<item name="vctr_primary_hint_text_color">@color/primary_hint_text_color_dark</item>
<item name="vctr_message_text_color">?android:attr/textColorPrimary</item>

<item name="android:background">@color/riot_primary_background_color_dark</item>
<item name="android:textColor">@color/riot_tertiary_text_color_dark</item>
<item name="editTextColor">?android:attr/textColorPrimary</item>
<item name="android:editTextColor">?android:attr/textColorPrimary</item>
</style>

<style name="Vector.TabView.Dark" parent="Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/vector_tabbar_background_dark</item>
<item name="background">@drawable/vector_tabbar_background_dark</item>
</style>

<!-- home activity -->
<style name="HomeActivityTheme.Dark" parent="AppTheme.Dark">
<item name="editTextColor">?android:attr/textColorPrimary</item>
<item name="android:editTextColor">?android:attr/textColorPrimary</item>
<item name="android:textColorHint">?attr/vctr_default_text_hint_color</item>
</style>

<!-- call activity -->
<style name="CallActivityTheme.Dark" parent="AppTheme.Dark">
<!-- status bar color -->
<item name="colorPrimaryDark">@android:color/black</item>
</style>

<!-- NoActionBar + FullScreen -->
<style name="AppTheme.NoActionBar.FullScreen.Dark" parent="AppTheme.Dark">
<item name="android:windowFullscreen">true</item>
<!-- activities background -->
<item name="android:windowBackground">@android:color/transparent</item>
</style>

<!-- Picker activities -->
<style name="CountryPickerTheme.Dark" parent="AppTheme.Dark">
<item name="editTextColor">@android:color/white</item>
<item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">?attr/vctr_activity_bottom_gradient_color</item>
</style>

<!-- searches activity -->
<style name="SearchesAppTheme.Dark" parent="AppTheme.Dark">
<!-- custom action bar -->
<item name="android:actionBarStyle">@style/VectorSearches.Styled.ActionBar</item>
<item name="actionBarStyle">@style/VectorSearches.Styled.ActionBar</item>

<!-- no divider -->
<item name="android:actionBarDivider">@null</item>

<!-- edit text -->
<item name="android:editTextStyle">@style/VectorSearches.EditText</item>

<!-- actionbar icons color -->
<item name="actionBarTheme">@style/VectorSearches.ActionBarTheme</item>
</style>

<style name="CallAppTheme.Dark" parent="AppTheme.Dark">
<item name="android:colorBackground">@color/primary_color_dark</item>
<item name="android:colorBackgroundCacheHint">@null</item>

<item name="android:windowFrame">@null</item>
<item name="android:windowTitleStyle">@style/RtlOverlay.DialogWindowTitle.AppCompat</item>
<item name="android:windowTitleBackgroundStyle">
@style/Base.DialogWindowTitleBackground.AppCompat
</item>
<item name="android:windowBackground">@drawable/abc_dialog_material_background</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@style/Animation.AppCompat.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>

<item name="windowActionModeOverlay">true</item>

<item name="listPreferredItemPaddingLeft">24dip</item>
<item name="listPreferredItemPaddingRight">24dip</item>

<item name="android:listDivider">@null</item>
</style>

<style name="GroupAppTheme.Dark" parent="AppTheme.Dark">
<item name="colorPrimaryDark">@color/tab_groups_secondary</item>

<item name="android:actionBarTabStyle">@style/Vector.TabView.Group</item>
<item name="actionBarTabStyle">@style/Vector.TabView.Group</item>
</style>

</resources>

View File

@ -0,0 +1,266 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- LIGHT THEME COLORS -->

<style name="AppTheme.Base.Light" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">@color/primary_color_dark_light</item>
<item name="colorPrimary">@color/primary_color_light</item>
<item name="colorAccent">@color/accent_color_light</item>

<item name="android:textColorPrimary">@color/primary_text_color_selector_light</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_light</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_light</item>

<item name="android:textColorLink">@color/link_color_light</item>

<!-- Menu text color -->
<item name="android:actionMenuTextColor">#FFFFFFFF</item>

<!-- default background color -->
<item name="android:colorBackground">@color/riot_primary_background_color_light</item>
<item name="vctr_bottom_nav_background_color">#FFF3F8FD</item>

<!-- waiting view background -->
<item name="vctr_waiting_background_color">#AAAAAAAA</item>

<!-- application bar text color -->
<!-- Base Text Primary-->
<item name="vctr_toolbar_primary_text_color">#FFFFFFFF</item>
<!-- Base Text Secondary-->
<item name="vctr_toolbar_secondary_text_color">#FFFFFFFF</item>
<item name="vctr_toolbar_link_text_color">@color/link_color_light</item>

<!-- application bar text hint color -->
<item name="vctr_primary_hint_text_color">@color/primary_hint_text_color_light</item>

<item name="vctr_tab_home">@color/primary_color_light</item>
<item name="vctr_tab_home_secondary">@color/primary_color_dark_light</item>

<!-- default text colors -->
<item name="vctr_default_text_hint_color">@color/default_text_hint_color_light</item>

<!-- room message colors -->
<!-- Notice (Secondary) -->
<item name="vctr_unread_room_indent_color">#FF2E3648</item>
<item name="vctr_notice_secondary">#61708B</item>
<item name="vctr_unsent_message_text_color">@color/vector_fuchsia_color</item>
<item name="vctr_message_text_color">@color/riot_primary_text_color_light</item>
<item name="vctr_notice_text_color">#FF61708b</item>
<item name="vctr_encrypting_message_text_color">@color/accent_color_light</item>
<item name="vctr_sending_message_text_color">?android:textColorSecondary</item>
<item name="vctr_highlighted_message_text_color">@color/vector_fuchsia_color</item>
<item name="vctr_highlighted_searched_message_text_color">@color/primary_color_light</item>
<item name="vctr_search_mode_room_name_text_color">#333C3C3C</item>
<item name="vctr_unread_marker_line_color">@color/accent_color_light</item>
<item name="vctr_markdown_block_background_color">#FFEEEEEE</item>
<item name="vctr_room_activity_divider_color">#FFF2F2F2</item>

<!-- tab bar colors -->
<item name="vctr_tab_bar_inverted_background_color">#FFF2F2F2</item>
<item name="vctr_tab_bar_selected_background_color">
@color/tab_bar_selected_background_color_light
</item>
<item name="vctr_tab_bar_unselected_background_color">
@color/tab_bar_unselected_background_color_light
</item>

<!-- list colors -->
<!--Header/Panel Background-->
<item name="vctr_list_header_background_color">#FFF3F8FD</item>
<!--Header/Panel Text Primary-->
<item name="vctr_list_header_primary_text_color">#FF61708B</item>
<!--Header/Panel Text Secondary-->
<item name="vctr_list_header_secondary_text_color">#FFC8C8CD</item>

<item name="vctr_list_divider_color">@color/list_divider_color_light</item>

<!-- gradient on the home bottom -->
<item name="vctr_activity_bottom_gradient_color">#80ffffff</item>

<!-- outgoing call background color -->
<item name="vctr_pending_outgoing_view_background_color">#33000000</item>

<!-- multi selection member background color -->
<item name="vctr_multi_selection_background_color">#FFF2F2F2</item>

<!-- sliding menu icon colors -->
<item name="vctr_home_navigation_icon_color">@color/riot_primary_text_color_light</item>

<!-- room notification text color (typing, unsent...) -->
<!--Notice (secondary)-->
<item name="vctr_room_notification_text_color">#FF61708b</item>

<!-- color for dividers in settings -->
<item name="vctr_preference_divider_color">@color/list_divider_color_light</item>

<!-- icon colors -->
<item name="vctr_settings_icon_tint_color">@android:color/black</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@android:color/white</item>
<item name="vctr_icon_tint_on_dark_action_bar_color">@android:color/white</item>

<!-- theses colours are requested a background cannot be set by an ?att on android < 5 -->
<!-- dedicated drawables are created for each theme -->
<item name="vctr_line_divider">@drawable/line_divider_light</item>
<item name="vctr_shadow_bottom">@drawable/shadow_bottom_light</item>
<item name="vctr_shadow_top">@drawable/shadow_top_light</item>
<item name="vctr_tabbar_selected_background">
@drawable/vector_tabbar_selected_background_light
</item>
<item name="vctr_tabbar_unselected_background">
@drawable/vector_tabbar_unselected_background_light
</item>
<item name="vctr_tabbar_background">@drawable/vector_tabbar_background_light</item>

<item name="vctr_pill_background_user_id">@drawable/pill_background_user_id_light</item>
<item name="vctr_pill_background_room_alias">@drawable/pill_background_room_alias_light</item>

<item name="vctr_pill_text_color_user_id">@color/riot_primary_text_color_light</item>
<item name="vctr_pill_text_color_room_alias">@android:color/white</item>

<item name="vctr_direct_chat_circle">@drawable/direct_chat_circle_light</item>

<item name="vctr_widget_banner_background">#FFD3EFE1</item>

<!-- ANDROID SUPPORT ATTRIBUTES -->
<!-- disable the overscroll because setOverscrollHeader/Footer don't always work -->
<item name="android:overScrollMode">never</item>

<!-- activities background -->
<item name="android:windowBackground">@color/riot_primary_background_color_light</item>

<!-- fonts -->
<item name="android:typeface">sans</item>

<!-- custom action bar -->
<item name="android:actionBarStyle">@style/Vector.Styled.ActionBar</item>
<item name="actionBarStyle">@style/Vector.Styled.ActionBar</item>

<!-- actionbar icons color -->
<item name="actionBarTheme">@style/Vector.ActionBarTheme</item>

<!-- remove the shadow under the actionbar -->
<item name="android:windowContentOverlay">@null</item>

<item name="android:popupMenuStyle">@style/Vector.PopupMenu</item>

<!-- no divider -->
<item name="android:actionBarDivider">@null</item>

<!-- tabbar background -->
<item name="android:actionBarTabStyle">@style/Vector.TabView.Light</item>
<item name="actionBarTabStyle">@style/Vector.TabView.Light</item>

<!-- tabbar text color -->
<item name="android:actionBarTabTextStyle">@style/Vector.TabText</item>
<item name="actionBarTabTextStyle">@style/Vector.TabText</item>

<!-- Preference -->
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>

<item name="bottomSheetDialogTheme">@style/Vector.BottomSheet.Light</item>
</style>

<style name="AppTheme.Light" parent="AppTheme.Base.Light" />

<style name="Theme.Vector.Lock.Light" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/primary_color_light</item>
<item name="colorAccent">@color/accent_color_light</item>

<item name="android:textColorPrimary">@color/riot_primary_text_color_light</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_light</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_light</item>

<item name="vctr_primary_hint_text_color">@color/primary_hint_text_color_light</item>
<item name="vctr_message_text_color">?android:attr/textColorPrimary</item>

<item name="android:background">@color/riot_primary_background_color_light</item>
<item name="android:textColor">@color/riot_tertiary_text_color_light</item>
<item name="editTextColor">?android:attr/textColorPrimary</item>
<item name="android:editTextColor">?android:attr/textColorPrimary</item>
</style>

<style name="Vector.TabView.Light" parent="Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/vector_tabbar_background_light</item>
<item name="background">@drawable/vector_tabbar_background_light</item>
</style>

<!-- home activity -->
<style name="HomeActivityTheme.Light" parent="AppTheme.Light">
<item name="editTextColor">@android:color/white</item>
<item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">?attr/vctr_activity_bottom_gradient_color</item>
</style>

<!-- call activity -->
<style name="CallActivityTheme.Light" parent="AppTheme.Light">
<!-- status bar color -->
<item name="colorPrimaryDark">@android:color/black</item>
</style>

<!-- NoActionBar + FullScreen -->
<style name="AppTheme.NoActionBar.FullScreen.Light" parent="AppTheme.Light">
<item name="android:windowFullscreen">true</item>
<!-- activities background -->
<item name="android:windowBackground">@android:color/transparent</item>
</style>

<!-- Picker activities -->
<style name="CountryPickerTheme.Light" parent="AppTheme.Light">
<item name="editTextColor">@android:color/white</item>
<item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">?attr/vctr_activity_bottom_gradient_color</item>
</style>

<!-- searches activity -->
<style name="SearchesAppTheme.Light" parent="AppTheme.Light">
<!-- custom action bar -->
<item name="android:actionBarStyle">@style/VectorSearches.Styled.ActionBar</item>
<item name="actionBarStyle">@style/VectorSearches.Styled.ActionBar</item>

<!-- no divider -->
<item name="android:actionBarDivider">@null</item>

<!-- edit text -->
<item name="android:editTextStyle">@style/VectorSearches.EditText</item>

<!-- actionbar icons color -->
<item name="actionBarTheme">@style/VectorSearches.ActionBarTheme</item>
</style>

<style name="CallAppTheme.Light" parent="AppTheme.Light">
<item name="android:colorBackground">?attr/colorBackgroundFloating</item>
<item name="android:colorBackgroundCacheHint">@null</item>

<item name="android:windowFrame">@null</item>
<item name="android:windowTitleStyle">@style/RtlOverlay.DialogWindowTitle.AppCompat</item>
<item name="android:windowTitleBackgroundStyle">
@style/Base.DialogWindowTitleBackground.AppCompat
</item>
<item name="android:windowBackground">@drawable/abc_dialog_material_background</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@style/Animation.AppCompat.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>

<item name="windowActionModeOverlay">true</item>

<item name="listPreferredItemPaddingLeft">24dip</item>
<item name="listPreferredItemPaddingRight">24dip</item>

<item name="android:listDivider">@null</item>
</style>

<style name="GroupAppTheme.Light" parent="AppTheme.Light">
<item name="colorPrimaryDark">@color/tab_groups_secondary</item>

<item name="android:actionBarTabStyle">@style/Vector.TabView.Group</item>
<item name="actionBarTabStyle">@style/Vector.TabView.Group</item>
</style>

<style name="AppTheme.Dialog.Light" parent="Theme.AppCompat.Light.Dialog.Alert" />

</resources>

View File

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- STATUS.IM THEME COLORS -->

<style name="AppTheme.Base.Status" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">@color/primary_color_dark_status</item>
<item name="colorPrimary">@color/primary_color_status</item>
<item name="colorAccent">@color/accent_color_status</item>

<item name="android:textColorPrimary">@color/primary_text_color_selector_status</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_status</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_status</item>

<item name="android:textColorLink">@color/link_color_status</item>


<!-- Menu text color -->
<item name="android:actionMenuTextColor">#FFFFFFFF</item>

<!-- default background color -->
<item name="android:colorBackground">@color/riot_primary_background_color_status</item>
<item name="vctr_bottom_nav_background_color">@color/riot_primary_background_color_status</item>

<!-- waiting view background -->
<item name="vctr_waiting_background_color">#AAAAAAAA</item>

<!-- application bar text color -->
<item name="vctr_toolbar_primary_text_color">#FFFFFFFF</item>
<item name="vctr_toolbar_secondary_text_color">#FFD8D8D8</item>
<item name="vctr_toolbar_link_text_color">#FFD8D8D8</item>

<!-- application bar text hint color -->
<item name="vctr_primary_hint_text_color">@color/primary_hint_text_color_light</item>

<item name="vctr_tab_home">@color/primary_color_status</item>
<item name="vctr_tab_home_secondary">@color/primary_color_dark_status</item>

<!-- default text colors -->
<item name="vctr_default_text_hint_color">@color/default_text_hint_color_light</item>

<!-- room message colors -->
<item name="vctr_unread_room_indent_color">?colorAccent</item>
<item name="vctr_notice_secondary">#61708B</item>
<item name="vctr_unsent_message_text_color">#FFFF4444</item>
<item name="vctr_message_text_color">#70879d</item>
<item name="vctr_notice_text_color">#adadbe</item>
<item name="vctr_encrypting_message_text_color">#AECDF9</item>
<item name="vctr_sending_message_text_color">#b3e8d2</item>
<item name="vctr_highlighted_message_text_color">@color/vector_fuchsia_color</item>
<item name="vctr_highlighted_searched_message_text_color">@color/primary_color_status</item>
<item name="vctr_search_mode_room_name_text_color">#333C3C3C</item>
<item name="vctr_unread_marker_line_color">#AECDF9</item>
<item name="vctr_markdown_block_background_color">#FFEEEEEE</item>
<item name="vctr_room_activity_divider_color">#FFF2F2F2</item>

<!-- tab bar colors -->
<item name="vctr_tab_bar_inverted_background_color">#FFF2F2F2</item>
<item name="vctr_tab_bar_selected_background_color">
@color/tab_bar_selected_background_color_status
</item>
<item name="vctr_tab_bar_unselected_background_color">
@color/tab_bar_unselected_background_color_status
</item>

<!-- list colors -->
<item name="vctr_list_header_background_color">#FFF6F6F6</item>
<item name="vctr_list_header_primary_text_color">#7F3C3C3C</item>
<item name="vctr_list_header_secondary_text_color">#4D3C3C3C</item>

<item name="vctr_list_divider_color">@color/list_divider_color_light</item>

<!-- gradient on the home bottom -->
<item name="vctr_activity_bottom_gradient_color">#80ffffff</item>

<!-- outgoing call background color -->
<item name="vctr_pending_outgoing_view_background_color">#33000000</item>

<!-- multi selection member background color -->
<item name="vctr_multi_selection_background_color">#FFF2F2F2</item>

<!-- sliding menu icon colors -->
<item name="vctr_home_navigation_icon_color">@color/riot_primary_text_color_status</item>

<!-- room notification text color (typing, unsent...) -->
<item name="vctr_room_notification_text_color">#a0a29f</item>

<!-- color for dividers in settings -->
<item name="vctr_preference_divider_color">#e1e1e1</item>

<!-- icon colors -->
<item name="vctr_settings_icon_tint_color">@color/accent_color_status</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@android:color/white</item>
<item name="vctr_icon_tint_on_dark_action_bar_color">@android:color/white</item>

<!-- theses colours are requested a background cannot be set by an ?att on android < 5 -->
<!-- dedicated drawables are created for each theme -->
<item name="vctr_line_divider">@drawable/line_divider_light</item>
<item name="vctr_shadow_bottom">@drawable/shadow_bottom_light</item>
<item name="vctr_shadow_top">@drawable/shadow_top_light</item>
<item name="vctr_tabbar_selected_background">
@drawable/vector_tabbar_selected_background_status
</item>
<item name="vctr_tabbar_unselected_background">
@drawable/vector_tabbar_unselected_background_status
</item>
<item name="vctr_tabbar_background">@drawable/vector_tabbar_background_status</item>

<item name="vctr_pill_background_user_id">@drawable/pill_background_user_id_status</item>
<item name="vctr_pill_background_room_alias">@drawable/pill_background_room_alias_status</item>

<item name="vctr_pill_text_color_user_id">@color/riot_primary_text_color_status</item>
<item name="vctr_pill_text_color_room_alias">@android:color/white</item>

<item name="vctr_direct_chat_circle">@drawable/direct_chat_circle_status</item>

<item name="vctr_widget_banner_background">#FFF7F7F7</item>

<!-- ANDROID SUPPORT ATTRIBUTES -->
<!-- disable the overscroll because setOverscrollHeader/Footer don't always work -->
<item name="android:overScrollMode">never</item>

<!-- activities background -->
<item name="android:windowBackground">@color/riot_primary_background_color_status</item>

<!-- fonts -->
<item name="android:typeface">sans</item>

<!-- custom action bar -->
<item name="android:actionBarStyle">@style/Vector.Styled.ActionBar</item>
<item name="actionBarStyle">@style/Vector.Styled.ActionBar</item>

<!-- actionbar icons color -->
<item name="actionBarTheme">@style/Vector.ActionBarTheme</item>

<!-- remove the shadow under the actionbar -->
<item name="android:windowContentOverlay">@null</item>

<item name="android:popupMenuStyle">@style/Vector.PopupMenu</item>

<!-- no divider -->
<item name="android:actionBarDivider">@null</item>

<!-- tabbar background -->
<item name="android:actionBarTabStyle">@style/Vector.TabView.Status</item>
<item name="actionBarTabStyle">@style/Vector.TabView.Status</item>

<!-- tabbar text color -->
<item name="android:actionBarTabTextStyle">@style/Vector.TabText</item>
<item name="actionBarTabTextStyle">@style/Vector.TabText</item>

<!-- Preference -->
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>

<item name="bottomSheetDialogTheme">@style/Vector.BottomSheet.Status</item>
</style>

<style name="AppTheme.Status" parent="AppTheme.Base.Status" />

<style name="Theme.Vector.Lock.Status" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/primary_color_status</item>
<item name="colorAccent">@color/accent_color_status</item>

<item name="android:textColorPrimary">@color/riot_primary_text_color_status</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_status</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_status</item>

<item name="vctr_primary_hint_text_color">@color/primary_hint_text_color_light</item>
<item name="vctr_message_text_color">?android:attr/textColorPrimary</item>

<item name="android:background">@color/riot_primary_background_color_status</item>
<item name="android:textColor">@color/riot_tertiary_text_color_status</item>
<item name="editTextColor">?android:attr/textColorPrimary</item>
<item name="android:editTextColor">?android:attr/textColorPrimary</item>
</style>

<style name="Vector.TabView.Status" parent="Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/vector_tabbar_background_status</item>
<item name="background">@drawable/vector_tabbar_background_status</item>
</style>

<!-- home activity -->
<style name="HomeActivityTheme.Status" parent="AppTheme.Status">
<item name="editTextColor">?android:attr/textColorPrimary</item>
<item name="android:editTextColor">?android:attr/textColorPrimary</item>
<item name="android:textColorHint">?attr/vctr_default_text_hint_color</item>
</style>

<!-- call activity -->
<style name="CallActivityTheme.Status" parent="AppTheme.Status">
<!-- status bar color -->
<item name="colorPrimaryDark">@android:color/black</item>
</style>

<!-- NoActionBar + FullScreen -->
<style name="AppTheme.NoActionBar.FullScreen.Status" parent="AppTheme.Status">
<item name="android:windowFullscreen">true</item>
<!-- activities background -->
<item name="android:windowBackground">@android:color/transparent</item>
</style>

<!-- Picker activities -->
<style name="CountryPickerTheme.Status" parent="AppTheme.Status">
<item name="editTextColor">@android:color/white</item>
<item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">?attr/vctr_activity_bottom_gradient_color</item>
</style>

<!-- searches activity -->
<style name="SearchesAppTheme.Status" parent="AppTheme.Status">
<!-- custom action bar -->
<item name="android:actionBarStyle">@style/VectorSearches.Styled.ActionBar</item>
<item name="actionBarStyle">@style/VectorSearches.Styled.ActionBar</item>

<!-- no divider -->
<item name="android:actionBarDivider">@null</item>

<!-- edit text -->
<item name="android:editTextStyle">@style/VectorSearches.EditText</item>

<!-- actionbar icons color -->
<item name="actionBarTheme">@style/VectorSearches.ActionBarTheme</item>
</style>

<style name="CallAppTheme.Status" parent="AppTheme.Status">
<item name="android:colorBackground">?attr/colorBackgroundFloating</item>
<item name="android:colorBackgroundCacheHint">@null</item>

<item name="android:windowFrame">@null</item>
<item name="android:windowTitleStyle">@style/RtlOverlay.DialogWindowTitle.AppCompat</item>
<item name="android:windowTitleBackgroundStyle">
@style/Base.DialogWindowTitleBackground.AppCompat
</item>
<item name="android:windowBackground">@drawable/abc_dialog_material_background</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@style/Animation.AppCompat.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>

<item name="windowActionModeOverlay">true</item>

<item name="listPreferredItemPaddingLeft">24dip</item>
<item name="listPreferredItemPaddingRight">24dip</item>

<item name="android:listDivider">@null</item>
</style>

<style name="GroupAppTheme.Status" parent="AppTheme.Status">
<item name="colorPrimaryDark">@color/tab_groups_secondary</item>

<item name="android:actionBarTabStyle">@style/Vector.TabView.Group</item>
<item name="actionBarTabStyle">@style/Vector.TabView.Group</item>
</style>

<style name="AppTheme.Dialog.Status" parent="Theme.AppCompat.Light.Dialog.Alert" />

</resources>

View File

@ -0,0 +1,36 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.riotredesign.receivers

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter

/**
* No Op version
*/
class DebugReceiver : BroadcastReceiver() {

override fun onReceive(context: Context, intent: Intent) {
// No op
}

companion object {
fun getIntentFilter(context: Context) = IntentFilter()
}
}

View File

@ -1,19 +0,0 @@
<!--
~ Copyright 2019 New Vector Ltd
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<resources>
<string name="app_name">matrix-sdk-android-rx</string>
</resources>

View File

@ -39,9 +39,9 @@ import java.util.concurrent.atomic.AtomicBoolean
class Matrix private constructor(context: Context) : MatrixKoinComponent { class Matrix private constructor(context: Context) : MatrixKoinComponent {


private val authenticator by inject<Authenticator>() private val authenticator by inject<Authenticator>()
private val userAgent by inject<UserAgentHolder>() private val userAgentHolder by inject<UserAgentHolder>()
private val backgroundDetectionObserver by inject<BackgroundDetectionObserver>() private val backgroundDetectionObserver by inject<BackgroundDetectionObserver>()
lateinit var currentSession: Session var currentSession: Session? = null


init { init {
Monarchy.init(context) Monarchy.init(context)
@ -52,8 +52,9 @@ class Matrix private constructor(context: Context) : MatrixKoinComponent {
ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver) ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver)
val lastActiveSession = authenticator.getLastActiveSession() val lastActiveSession = authenticator.getLastActiveSession()
if (lastActiveSession != null) { if (lastActiveSession != null) {
currentSession = lastActiveSession currentSession = lastActiveSession.apply {
currentSession.open() open()
}
} }
} }


@ -65,9 +66,11 @@ class Matrix private constructor(context: Context) : MatrixKoinComponent {
* Set application flavor, to alter user agent. * Set application flavor, to alter user agent.
*/ */
fun setApplicationFlavor(flavor: String) { fun setApplicationFlavor(flavor: String) {
userAgent.setApplicationFlavor(flavor) userAgentHolder.setApplicationFlavor(flavor)
} }


fun getUserAgent() = userAgentHolder.userAgent

companion object { companion object {
private lateinit var instance: Matrix private lateinit var instance: Matrix
private val isInit = AtomicBoolean(false) private val isInit = AtomicBoolean(false)

View File

@ -16,11 +16,13 @@


package im.vector.matrix.android.internal.auth package im.vector.matrix.android.internal.auth


import android.content.Context
import im.vector.matrix.android.api.auth.Authenticator import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.internal.auth.db.RealmSessionParamsStore import im.vector.matrix.android.internal.auth.db.RealmSessionParamsStore
import im.vector.matrix.android.internal.auth.db.SessionParamsMapper import im.vector.matrix.android.internal.auth.db.SessionParamsMapper
import io.realm.RealmConfiguration import io.realm.RealmConfiguration
import org.koin.dsl.module.module import org.koin.dsl.module.module
import java.io.File


class AuthModule { class AuthModule {


@ -31,8 +33,18 @@ class AuthModule {
} }


single { single {
val context: Context = get()
val old = File(context.filesDir, "matrix-sdk-auth")

if (old.exists()) {
old.renameTo(File(context.filesDir, "matrix-sdk-auth.realm"))
}

val mapper = SessionParamsMapper((get())) val mapper = SessionParamsMapper((get()))
val realmConfiguration = RealmConfiguration.Builder().name("matrix-sdk-auth").deleteRealmIfMigrationNeeded().build() val realmConfiguration = RealmConfiguration.Builder()
.name("matrix-sdk-auth.realm")
.deleteRealmIfMigrationNeeded()
.build()
RealmSessionParamsStore(mapper, realmConfiguration) as SessionParamsStore RealmSessionParamsStore(mapper, realmConfiguration) as SessionParamsStore
} }



View File

@ -25,6 +25,7 @@ import im.vector.matrix.android.internal.database.model.ChunkEntity
import im.vector.matrix.android.internal.database.model.EventEntity import im.vector.matrix.android.internal.database.model.EventEntity
import im.vector.matrix.android.internal.database.model.EventEntityFields import im.vector.matrix.android.internal.database.model.EventEntityFields
import im.vector.matrix.android.internal.database.query.fastContains import im.vector.matrix.android.internal.database.query.fastContains
import im.vector.matrix.android.internal.extensions.assertIsManaged
import im.vector.matrix.android.internal.session.room.timeline.PaginationDirection import im.vector.matrix.android.internal.session.room.timeline.PaginationDirection
import io.realm.Sort import io.realm.Sort


@ -69,6 +70,7 @@ internal fun ChunkEntity.addAll(roomId: String,
events: List<Event>, events: List<Event>,
direction: PaginationDirection, direction: PaginationDirection,
stateIndexOffset: Int = 0, stateIndexOffset: Int = 0,
// Set to true for Event retrieved from a Permalink (i.e. not linked to live Chunk)
isUnlinked: Boolean = false) { isUnlinked: Boolean = false) {
assertIsManaged() assertIsManaged()
events.forEach { event -> events.forEach { event ->
@ -105,12 +107,6 @@ internal fun ChunkEntity.add(roomId: String,
events.add(position, eventEntity) events.add(position, eventEntity)
} }


private fun ChunkEntity.assertIsManaged() {
if (!isManaged) {
throw IllegalStateException("Chunk entity should be managed to use this function")
}
}

internal fun ChunkEntity.lastStateIndex(direction: PaginationDirection, defaultValue: Int = 0): Int { internal fun ChunkEntity.lastStateIndex(direction: PaginationDirection, defaultValue: Int = 0): Int {
return when (direction) { return when (direction) {
PaginationDirection.FORWARDS -> events.where().sort(EventEntityFields.STATE_INDEX, Sort.DESCENDING).findFirst()?.stateIndex PaginationDirection.FORWARDS -> events.where().sort(EventEntityFields.STATE_INDEX, Sort.DESCENDING).findFirst()?.stateIndex

View File

@ -22,6 +22,7 @@ import im.vector.matrix.android.internal.database.mapper.updateWith
import im.vector.matrix.android.internal.database.model.ChunkEntity import im.vector.matrix.android.internal.database.model.ChunkEntity
import im.vector.matrix.android.internal.database.model.RoomEntity import im.vector.matrix.android.internal.database.model.RoomEntity
import im.vector.matrix.android.internal.database.query.fastContains import im.vector.matrix.android.internal.database.query.fastContains
import im.vector.matrix.android.internal.extensions.assertIsManaged




internal fun RoomEntity.deleteOnCascade(chunkEntity: ChunkEntity) { internal fun RoomEntity.deleteOnCascade(chunkEntity: ChunkEntity) {
@ -40,9 +41,8 @@ internal fun RoomEntity.addStateEvents(stateEvents: List<Event>,
stateIndex: Int = Int.MIN_VALUE, stateIndex: Int = Int.MIN_VALUE,
filterDuplicates: Boolean = false, filterDuplicates: Boolean = false,
isUnlinked: Boolean = false) { isUnlinked: Boolean = false) {
if (!isManaged) { assertIsManaged()
throw IllegalStateException("Chunk entity should be managed to use fast contains")
}
stateEvents.forEach { event -> stateEvents.forEach { event ->
if (event.eventId == null || (filterDuplicates && fastContains(event.eventId))) { if (event.eventId == null || (filterDuplicates && fastContains(event.eventId))) {
return@forEach return@forEach

View File

@ -0,0 +1,25 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.matrix.android.internal.extensions

import io.realm.RealmObject

internal fun RealmObject.assertIsManaged() {
if (!isManaged) {
throw IllegalStateException("${javaClass.simpleName} entity should be managed to use this function")
}
}

View File

@ -27,9 +27,73 @@ import im.vector.matrix.android.internal.database.query.findAllIncludingEvents
import im.vector.matrix.android.internal.database.query.where import im.vector.matrix.android.internal.database.query.where
import im.vector.matrix.android.internal.util.tryTransactionSync import im.vector.matrix.android.internal.util.tryTransactionSync



/**
* Insert Chunk in DB, and eventually merge with existing chunk event
*/
internal class TokenChunkEventPersistor(private val monarchy: Monarchy) { internal class TokenChunkEventPersistor(private val monarchy: Monarchy) {


/**
* <pre>
* ========================================================================================================
* | Backward case |
* ========================================================================================================
*
* *--------------------------* *--------------------------*
* | startToken1 | | startToken1 |
* *--------------------------* *--------------------------*
* | | | |
* | | | |
* | receivedChunk backward | | |
* | Events | | |
* | | | |
* | | | |
* | | | |
* *--------------------------* *--------------------------* | |
* | startToken0 | | endToken1 | => | Merged chunk |
* *--------------------------* *--------------------------* | Events |
* | | | |
* | | | |
* | Current Chunk | | |
* | Events | | |
* | | | |
* | | | |
* | | | |
* *--------------------------* *--------------------------*
* | endToken0 | | endToken0 |
* *--------------------------* *--------------------------*
*
*
* ========================================================================================================
* | Forward case |
* ========================================================================================================
*
* *--------------------------* *--------------------------*
* | startToken0 | | startToken0 |
* *--------------------------* *--------------------------*
* | | | |
* | | | |
* | Current Chunk | | |
* | Events | | |
* | | | |
* | | | |
* | | | |
* *--------------------------* *--------------------------* | |
* | endToken0 | | startToken1 | => | Merged chunk |
* *--------------------------* *--------------------------* | Events |
* | | | |
* | | | |
* | receivedChunk forward | | |
* | Events | | |
* | | | |
* | | | |
* | | | |
* *--------------------------* *--------------------------*
* | endToken1 | | endToken1 |
* *--------------------------* *--------------------------*
*
* ========================================================================================================
* </pre>
*/
fun insertInDb(receivedChunk: TokenChunkEvent, fun insertInDb(receivedChunk: TokenChunkEvent,
roomId: String, roomId: String,
direction: PaginationDirection): Try<Boolean> { direction: PaginationDirection): Try<Boolean> {
@ -60,11 +124,10 @@ internal class TokenChunkEventPersistor(private val monarchy: Monarchy) {


var currentChunk = if (direction == PaginationDirection.FORWARDS) { var currentChunk = if (direction == PaginationDirection.FORWARDS) {
prevChunk?.apply { this.nextToken = nextToken } prevChunk?.apply { this.nextToken = nextToken }
?: ChunkEntity.create(realm, prevToken, nextToken)
} else { } else {
nextChunk?.apply { this.prevToken = prevToken } nextChunk?.apply { this.prevToken = prevToken }
?: ChunkEntity.create(realm, prevToken, nextToken)
} }
?: ChunkEntity.create(realm, prevToken, nextToken)


currentChunk.addAll(roomId, receivedChunk.events, direction, isUnlinked = currentChunk.isUnlinked()) currentChunk.addAll(roomId, receivedChunk.events, direction, isUnlinked = currentChunk.isUnlinked())



View File

@ -28,7 +28,8 @@ internal object FilterUtil {
* *
* *
* If data save mode is on, FilterBody will contains * If data save mode is on, FilterBody will contains
* "{\"room\": {\"ephemeral\": {\"types\": [\"m.receipt\"]}}, \"presence\":{\"notTypes\": [\"*\"]}}" * FIXME New expected filter:
* "{\"room\": {\"ephemeral\": {\"notTypes\": [\"m.typing\"]}}, \"presence\":{\"notTypes\": [\"*\"]}}"
* *
* @param filterBody filterBody to patch * @param filterBody filterBody to patch
* @param useDataSaveMode true to enable data save mode * @param useDataSaveMode true to enable data save mode

View File

@ -32,7 +32,9 @@ if [[ ${numberOfFiles1} -eq ${numberOfFiles5} ]] && [[ ${numberOfFiles2} -eq ${n
resultNbOfDrawable=0 resultNbOfDrawable=0
echo "OK" echo "OK"
else else
resultNbOfDrawable=1 # Ignore for the moment
# resultNbOfDrawable=1
resultNbOfDrawable=0
echo "ERROR, missing drawable alternative." echo "ERROR, missing drawable alternative."
fi fi



View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash


adb shell am broadcast -a im.vector.receiver.DEBUG_ACTION_ALTER_SCALAR_TOKEN adb shell am broadcast -a im.vector.riotredesign.DEBUG_ACTION_ALTER_SCALAR_TOKEN

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash


adb shell am broadcast -a im.vector.receiver.DEBUG_ACTION_DUMP_FILESYSTEM adb shell am broadcast -a im.vector.riotredesign.DEBUG_ACTION_DUMP_FILESYSTEM

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash


adb shell am broadcast -a im.vector.receiver.DEBUG_ACTION_DUMP_PREFERENCES adb shell am broadcast -a im.vector.riotredesign.DEBUG_ACTION_DUMP_PREFERENCES