mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 09:49:25 +02:00
Show reason at AnnoyActivity
This commit is contained in:
parent
59c9a5f83b
commit
09dbde910b
4 changed files with 60 additions and 7 deletions
|
@ -20,10 +20,14 @@ import android.content.Intent
|
|||
import android.os.Build
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import io.timelimit.android.R
|
||||
import io.timelimit.android.livedata.map
|
||||
import io.timelimit.android.logic.DefaultAppLogic
|
||||
import io.timelimit.android.ui.manage.device.manage.ManipulationWarningTypeLabel
|
||||
import io.timelimit.android.ui.manage.device.manage.ManipulationWarnings
|
||||
import io.timelimit.android.util.TimeTextUtil
|
||||
import kotlinx.android.synthetic.main.annoy_activity.*
|
||||
|
||||
|
@ -67,6 +71,27 @@ class AnnoyActivity : AppCompatActivity() {
|
|||
getString(R.string.annoy_timer, TimeTextUtil.seconds(it.toInt(), this@AnnoyActivity))
|
||||
)
|
||||
})
|
||||
|
||||
logic.deviceEntry.map {
|
||||
val reasonItems = (it?.let { ManipulationWarnings.getFromDevice(it) } ?: ManipulationWarnings.empty)
|
||||
.current
|
||||
.map {
|
||||
getString(ManipulationWarningTypeLabel.getLabel(it))
|
||||
}
|
||||
|
||||
if (reasonItems.isEmpty()) {
|
||||
null
|
||||
} else {
|
||||
getString(R.string.annoy_reason, reasonItems.joinToString(separator = ", "))
|
||||
}
|
||||
}.observe(this, Observer {
|
||||
if (it.isNullOrEmpty()) {
|
||||
annoy_reason.visibility = View.GONE
|
||||
} else {
|
||||
annoy_reason.visibility = View.VISIBLE
|
||||
annoy_reason.setText(it)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun shutdown() {
|
||||
|
|
|
@ -14,13 +14,35 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_margin="8dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_margin="4dp"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:gravity="center"
|
||||
android:id="@+id/annoy_reason"
|
||||
android:text="@string/annoy_reason"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:layout_margin="4dp"
|
||||
android:textAppearance="?android:textAppearanceMedium"
|
||||
android:layout_margin="16dp"
|
||||
android:gravity="center"
|
||||
android:id="@+id/annoy_timer"
|
||||
android:text="@string/annoy_timer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -20,4 +20,7 @@
|
|||
<string name="annoy_timer">
|
||||
Das Gerät wird in %s entsperrt.
|
||||
</string>
|
||||
<string name="annoy_reason">
|
||||
Folgendes wurde manipuliert: %s
|
||||
</string>
|
||||
</resources>
|
|
@ -20,4 +20,7 @@
|
|||
<string name="annoy_timer">
|
||||
The device will be unlocked in %s.
|
||||
</string>
|
||||
<string name="annoy_reason">
|
||||
This was manipulated: %s
|
||||
</string>
|
||||
</resources>
|
Loading…
Add table
Add a link
Reference in a new issue