Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ext {
ext.buildScriptsDir = "$rootDir/BuildScripts"
versions = [
compileSdk : 28,
multidex : '2.0.1',
appcompat : '1.0.2',
androidx : '1.0.0',
material : '1.0.0',
Expand All @@ -41,6 +42,7 @@ ext {
location : '16.0.0',
coreKtx : '1.0.1',
yandex_mapkit: '3.4.0',
google_maps : '16.1.0'
google_maps : '16.1.0',
danlew_joda : '2.10.3'
]
}
6 changes: 3 additions & 3 deletions navigation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ dependencies {
api project(":utils")
api project(":logging")

api 'androidx.multidex:multidex:2.0.1'
api "androidx.multidex:multidex:$versions.multidex"

api 'net.danlew:android.joda:2.10.2'
api "net.danlew:android.joda:$versions.danlew_joda"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation "androidx.appcompat:appcompat:$versions.appcompat"

implementation("com.crashlytics.sdk.android:crashlytics:$versions.crashlytics@aar") {
implementation("com.crashlytics.sdk.android:crashlytics:$versions.crashlytics") {
transitive = true
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2019 Touch Instinct
*
* This file is part of RoboSwag library.
*
* 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 ru.touchin.roboswag.components.navigation

import android.app.Application
import android.content.Context
import android.os.StrictMode
import android.util.Log
import androidx.multidex.MultiDex
import com.crashlytics.android.Crashlytics
import io.fabric.sdk.android.Fabric
import net.danlew.android.joda.JodaTimeAndroid
import ru.touchin.roboswag.core.log.ConsoleLogProcessor
import ru.touchin.roboswag.core.log.CrashlyticsLogProcessor
import ru.touchin.roboswag.core.log.Lc
import ru.touchin.roboswag.core.log.LcGroup
import ru.touchin.roboswag.core.log.LcLevel

/**
* Base class of application to extends for Touch Instinct related projects.
*/
abstract class TouchinApp : Application() {

companion object {
private const val CRASHLYTICS_INITIALIZATION_ERROR = "Crashlytics initialization error! Did you forget to add\n" +
"compile('com.crashlytics.sdk.android:crashlytics:+') {\n" +
" transitive = true;\n" +
"}\n" +
"to your build.gradle?"
}

override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
MultiDex.install(base)
}

override fun onCreate() {
super.onCreate()
JodaTimeAndroid.init(this)
enableStrictMode()
initCrashlytics()
}

private fun enableStrictMode() {
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
.detectAll()
.permitDiskReads()
.permitDiskWrites()
.penaltyLog()
.build())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавь пустую строку

StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build())
}
}

private fun initCrashlytics() {
if (BuildConfig.DEBUG) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В отдельный метод

Lc.initialize(ConsoleLogProcessor(LcLevel.VERBOSE), true)
LcGroup.UI_LIFECYCLE.disable()
} else {
try {
val crashlytics = Crashlytics()
Fabric.with(this, crashlytics)
Fabric.getLogger().logLevel = Log.ERROR
Lc.initialize(CrashlyticsLogProcessor(crashlytics), false)
} catch (error: NoClassDefFoundError) {
Lc.initialize(ConsoleLogProcessor(LcLevel.INFO), false)
Lc.e(CRASHLYTICS_INITIALIZATION_ERROR, error)
}
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ru.touchin.roboswag.components.navigation.activities

interface OnBackPressedListener {

fun onBackPressed(): Boolean

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пустая строка в конце

Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ abstract class KeyboardResizeableViewController<TActivity : BaseActivity, TState

private var isKeyboardVisible: Boolean = false

private val keyboardHideListener = OnBackPressedListener {
if (isKeyboardVisible) {
UiUtils.OfViews.hideSoftInput(activity)
true
} else {
false
}
private val keyboardHideListener = object : OnBackPressedListener {

override fun onBackPressed(): Boolean =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Совмести 30 и 31

if (isKeyboardVisible) {
UiUtils.OfViews.hideSoftInput(activity)
true
} else {
false
}
}

private var isHideKeyboardOnBackEnabled = false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ru.touchin.roboswag.core.log

import android.util.Log
import com.crashlytics.android.Crashlytics
import ru.touchin.roboswag.core.utils.ShouldNotHappenException

class CrashlyticsLogProcessor(private val crashlytics: Crashlytics) : LogProcessor(LcLevel.INFO) {

override fun processLogMessage(
group: LcGroup,
level: LcLevel,
tag: String,
message: String,
throwable: Throwable?
) {
when {
group === LcGroup.UI_LIFECYCLE -> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В одну строку

crashlytics.core.log(level.priority, tag, message)
}
!level.lessThan(LcLevel.ASSERT) && level == LcLevel.ERROR -> {
Log.e(tag, message)
if (throwable != null) {
crashlytics.core.log(level.priority, tag, message)
crashlytics.core.logException(throwable)
} else {
val exceptionToLog = ShouldNotHappenException("$tag:$message")
reduceStackTrace(exceptionToLog)
crashlytics.core.logException(exceptionToLog)
}
}
}
}

private fun reduceStackTrace(throwable: Throwable) {
val stackTrace = throwable.stackTrace
val reducedStackTraceList = arrayListOf<StackTraceElement>()
for (i in stackTrace.indices.reversed()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write in kotlin style without for

val stackTraceElement = stackTrace[i]
if (stackTraceElement.className.contains(javaClass.simpleName)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Условие внутри if в отдельный метод

|| stackTraceElement.className.contains(LcGroup::class.java.name)
|| stackTraceElement.className.contains(Lc::class.java.name)) {
break
}
reducedStackTraceList.add(0, stackTraceElement)
}
throwable.stackTrace = reducedStackTraceList.toTypedArray()
}

}