Commit ec6b27ce authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Merge branch 'develop'

parents b2ba9edf 271c381b
......@@ -16,8 +16,8 @@ android {
minSdkVersion(19)
targetSdkVersion(28)
versionName = "1.4.1"
versionCode = 13
versionName = "1.4.2"
versionCode = 14
buildToolsVersion = "28.0.3"
......@@ -134,9 +134,7 @@ dependencies {
//Image load and cache
implementation("com.github.bumptech.glide:glide:$glideVersion")
kapt("com.github.bumptech.glide:compiler:$glideVersion")
implementation("com.github.bumptech.glide:okhttp3-integration:4.6.1") {
exclude(group = "glide-parent")
}
implementation("com.github.bumptech.glide:okhttp3-integration:$glideVersion")
//Markdown to HTML converter
implementation("ru.noties:markwon:$markwonVersion")
implementation("ru.noties:markwon-image-loader:$markwonVersion")
......
......@@ -14,6 +14,7 @@ import toothpick.Toothpick
import toothpick.configuration.Configuration
import toothpick.registries.FactoryRegistryLocator
import toothpick.registries.MemberInjectorRegistryLocator
import java.util.*
/**
* @author Konstantin Tskhovrebov (aka terrakok) on 26.03.17.
......@@ -22,6 +23,7 @@ class App : Application() {
override fun onCreate() {
super.onCreate()
appCode = UUID.randomUUID().toString()
initLogger()
initFabric()
......@@ -75,4 +77,9 @@ class App : Application() {
private fun initThreetenABP() {
AndroidThreeTen.init(this)
}
companion object {
lateinit var appCode: String
private set
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ package ru.terrakok.gitlabclient.entity.app.target
*/
enum class TargetHeaderIcon {
CREATED,
IMPORTED,
JOINED,
COMMENTED,
MERGED,
......
......@@ -12,6 +12,8 @@ enum class EventAction(private val jsonName: String) {
COMMENTED_ON("commented on"),
@SerializedName("created")
CREATED("created"),
@SerializedName("imported")
IMPORTED("imported"),
@SerializedName("pushed to")
PUSHED_TO("pushed to"),
@SerializedName("pushed new")
......
......@@ -71,11 +71,13 @@ fun EventAction.getHumanName(resources: Resources) = when (this) {
EventAction.COMMENTED_ON -> resources.getString(R.string.event_action_commented_on)
EventAction.JOINED -> resources.getString(R.string.event_action_joined)
EventAction.CREATED -> resources.getString(R.string.event_action_created)
EventAction.IMPORTED -> resources.getString(R.string.event_action_imported)
}
@DrawableRes
fun TargetHeaderIcon.getIcon() = when (this) {
TargetHeaderIcon.CREATED -> R.drawable.ic_event_created_24dp
TargetHeaderIcon.IMPORTED -> R.drawable.ic_event_imported_24dp
TargetHeaderIcon.JOINED -> R.drawable.ic_event_joined_24dp
TargetHeaderIcon.COMMENTED -> R.drawable.ic_event_commented_24dp
TargetHeaderIcon.MERGED -> R.drawable.ic_event_merged_24dp
......@@ -101,7 +103,11 @@ fun TodoAction.getHumanName(resources: Resources): String = when (this) {
fun TargetHeaderTitle.getHumanName(resources: Resources) = when (this) {
is TargetHeaderTitle.Event -> {
"$userName ${action.getHumanName(resources)} $targetName ${resources.getString(R.string.at)} $projectName"
if (action == EventAction.IMPORTED) {
"$userName ${action.getHumanName(resources)} $targetName $projectName"
} else {
"$userName ${action.getHumanName(resources)} $targetName ${resources.getString(R.string.at)} $projectName"
}
}
is TargetHeaderTitle.Todo -> {
val actionName = action.getHumanName(resources)
......
......@@ -155,6 +155,7 @@ class EventRepository @Inject constructor(
private fun getIcon(action: EventAction) = when (action) {
EventAction.CREATED -> TargetHeaderIcon.CREATED
EventAction.IMPORTED -> TargetHeaderIcon.IMPORTED
EventAction.JOINED -> TargetHeaderIcon.JOINED
EventAction.COMMENTED_ON,
EventAction.COMMENTED -> TargetHeaderIcon.COMMENTED
......@@ -240,6 +241,8 @@ class EventRepository @Inject constructor(
event.projectId
)
}
} else if (event.actionName == EventAction.IMPORTED) {
TargetData(AppTarget.PROJECT, AppTarget.PROJECT.toString(), event.projectId)
} else {
TargetData(AppTarget.PROJECT, "${AppTarget.PROJECT} ${event.projectId}", event.projectId)
}
......
......@@ -5,6 +5,7 @@ import android.os.Handler
import android.view.LayoutInflater
import android.view.ViewGroup
import com.arellomobile.mvp.MvpAppCompatFragment
import ru.terrakok.gitlabclient.App
import ru.terrakok.gitlabclient.extension.objectScopeName
import timber.log.Timber
import toothpick.Scope
......@@ -12,6 +13,7 @@ import toothpick.Toothpick
private const val PROGRESS_TAG = "bf_progress"
private const val STATE_SCOPE_NAME = "state_scope_name"
private const val STATE_LAUNCH_FLAG = "state_launch_flag"
private const val STATE_SCOPE_WAS_CLOSED = "state_scope_was_closed"
/**
......@@ -32,13 +34,16 @@ abstract class BaseFragment : MvpAppCompatFragment() {
protected open val scopeModuleInstaller: (Scope) -> Unit = {}
private lateinit var fragmentScopeName: String
private var scopeIsNotInit: Boolean = true
protected lateinit var scope: Scope
private set
override fun onCreate(savedInstanceState: Bundle?) {
val savedAppCode = savedInstanceState?.getString(STATE_LAUNCH_FLAG)
//False - if fragment was restored without new app process (for example: activity rotation)
val isNewInAppProcess = savedAppCode != App.appCode
val scopeWasClosed = savedInstanceState?.getBoolean(STATE_SCOPE_WAS_CLOSED) ?: true
scopeIsNotInit = savedInstanceState?.getBoolean(STATE_SCOPE_WAS_CLOSED) ?: true
val scopeIsNotInit = isNewInAppProcess || scopeWasClosed
fragmentScopeName = savedInstanceState?.getString(STATE_SCOPE_NAME) ?: objectScopeName()
scope = Toothpick.openScopes(parentScopeName, fragmentScopeName)
.apply {
......@@ -74,20 +79,34 @@ abstract class BaseFragment : MvpAppCompatFragment() {
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putString(STATE_SCOPE_NAME, fragmentScopeName)
outState.putBoolean(STATE_SCOPE_WAS_CLOSED, activity?.isChangingConfigurations == false)
instanceStateSaved = true
outState.putString(STATE_SCOPE_NAME, fragmentScopeName)
outState.putString(STATE_LAUNCH_FLAG, App.appCode)
outState.putBoolean(STATE_SCOPE_WAS_CLOSED, needCloseScope()) //save it but will be used only if destroyed
}
override fun onDestroy() {
super.onDestroy()
if (activity?.isChangingConfigurations == false) {
if (needCloseScope()) {
//destroy this fragment with scope
Timber.d("Destroy UI scope: $fragmentScopeName")
Toothpick.closeScope(scope.name)
}
}
//This is android, baby!
private fun isRealRemoving(): Boolean =
(isRemoving && !instanceStateSaved) //because isRemoving == true for fragment in backstack on screen rotation
|| ((parentFragment as? BaseFragment)?.isRealRemoving() ?: false)
//It will be valid only for 'onDestroy()' method
private fun needCloseScope(): Boolean =
when {
activity?.isChangingConfigurations == true -> false
activity?.isFinishing == true -> true
else -> isRealRemoving()
}
protected fun showProgressDialog(progress: Boolean) {
if (!isAdded || instanceStateSaved) return
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="401.952"
android:viewportHeight="401.952">
<path
android:fillColor="#FFFFFF"
android:pathData="M279.368,211.107L247.84,211.107c-5.573,0 -10.134,-4.56 -10.134,-10.133l-0.049,-32.893L237.657,81.28l0,0C237.296,76.027 232.732,71.841 227.396,71.839l-53.197,0.001c-5.573,0 -10.133,4.558 -10.133,10.129l0.179,119.004c0,5.573 -4.558,10.133 -10.132,10.133L122.586,211.107c-5.574,0 -7.173,3.467 -3.557,7.707l75.367,108.12c3.619,4.24 9.541,4.24 13.159,0l75.364,-108.118C286.539,214.576 284.942,211.107 279.368,211.107z" />
</vector>
......@@ -102,6 +102,7 @@
<string name="event_action_closed">closed</string>
<string name="event_action_commented_on">commented on</string>
<string name="event_action_created">created</string>
<string name="event_action_imported">imported</string>
<string name="event_action_pushed_to">pushed to</string>
<string name="event_action_pushed_new">pushed new</string>
<string name="event_action_deleted">deleted</string>
......
......@@ -5,15 +5,15 @@ buildscript {
maven { url = uri("https://maven.fabric.io/public") }
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.0-alpha09")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10")
classpath("com.android.tools.build:gradle:3.4.0-alpha10")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11")
classpath("com.google.gms:google-services:4.2.0")
classpath("io.fabric.tools:gradle:1.26.1")
}
}
allprojects {
extra["kotlinVersion"] = "1.3.0"
extra["kotlinVersion"] = "1.3.11"
repositories {
google()
jcenter()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment