Skip to content

Commit

Permalink
change info
Browse files Browse the repository at this point in the history
  • Loading branch information
tsynik committed Feb 23, 2024
1 parent ed6a886 commit 85d7773
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/ru/yourok/torrserve/settings/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ object Settings {
fun getTheme(): String = get("theme", "auto")
fun setTheme(v: String) = set("theme", v)

fun getHost(): String = get("host", "http://127.0.0.1:8090")
fun getHost(): String = get("host", "http://localhost:8090")
fun setHost(host: String) {
var hst = host
if (hst.isEmpty())
hst = "http://127.0.0.1:8090"
hst = "http://localhost:8090"
val url = Uri.parse(hst)
if (url.scheme.isNullOrBlank())
hst = "http://$hst"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ru.yourok.torrserve.ui.activities.main

import android.content.DialogInterface.BUTTON_POSITIVE
import android.content.Intent
import android.content.res.ColorStateList
import android.content.res.Configuration
import android.net.Uri
import android.os.Bundle
Expand Down Expand Up @@ -135,12 +136,24 @@ class MainActivity : AppCompatActivity() {

private fun updateStatus() {
val host = viewModel.getHost()
val hostView = findViewById<TextView>(R.id.tvCurrentHost)
val hostColor = ThemeUtil.getColorFromAttr(this, R.attr.colorHost)
host.observe(this) {
findViewById<TextView>(R.id.tvCurrentHost)?.text = it.removePrefix("http://")
hostView?.text = it.removePrefix("http://")
}
val data = viewModel.get()
data.observe(this) {
findViewById<TextView>(R.id.tvStatus)?.text = it
if (it.equals(getString(R.string.server_not_responding)))
hostView.apply {
setTextColor(ThemeUtil.getColorFromAttr(this@MainActivity, R.attr.colorOnSurface))
alpha = 0.75f
}
else
hostView.apply {
setTextColor(hostColor)
alpha = 1.0f
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class HostAdapter : RecyclerView.Adapter<HostAdapter.ViewHolder>() {
val hostColor = ColorStateList.valueOf(ThemeUtil.getColorFromAttr(holder.view.context, R.attr.colorHost))
val versionColor = ColorStateList.valueOf(ThemeUtil.getColorFromAttr(holder.view.context, R.attr.colorPrimary))
val labelsTextColor = ThemeUtil.getColorFromAttr(holder.view.context, R.attr.colorSurface)
val hostView = holder.view.findViewById<TextView>(R.id.tvHost)

holder.view.findViewById<TextView>(R.id.tvHost).apply {
hostView.apply {
text = hosts[position].host.removePrefix("http://")
val shapeDrawable = MaterialShapeDrawable(shapeAppearanceModel)
shapeDrawable.fillColor = hostColor.withAlpha(10)
Expand All @@ -96,9 +97,10 @@ class HostAdapter : RecyclerView.Adapter<HostAdapter.ViewHolder>() {
//if (version.contains("·", true) || version.startsWith("1.2.") || version.startsWith("MatriX"))
if (version.isNotBlank() && (version.startsWith("1.2.") || version.startsWith("MatriX")))
holder.view.findViewById<ImageView>(R.id.ivOnline)?.visibility = View.VISIBLE
else
else {
holder.view.findViewById<ImageView>(R.id.ivOnline)?.visibility = View.INVISIBLE

hostView.alpha = 0.6f
}
val status = hosts[position].status
holder.view.findViewById<TextView>(R.id.tvStatus).apply {
if (status.isNotBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class ServerFinderFragment : TSFragment() {
view?.findViewById<TextView>(R.id.tvCurrentIP)?.text = ips
hostAdapter.clear()
// add local
val localhost = "http://127.0.0.1:8090"
val localhost = "http://localhost:8090"
var status = App.context.getString(R.string.local_server)
if (TorrService.isLocal())
status += " · ${App.context.getString(R.string.connected_host)}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ open class InfoFragment : TSFragment() {
} else
(activity as? PlayActivity)?.hideProgress()

val peers = "${torr.connected_seeders} · ${torr.active_peers}/${torr.total_peers}"
val peers = "${torr.active_peers}/${torr.total_peers}"
if (peers.isNotEmpty()) {
// spannable
findViewById<TextView>(R.id.tvPeers).apply {
Expand All @@ -173,6 +173,16 @@ open class InfoFragment : TSFragment() {
}
}

val seeds = "${torr.connected_seeders}"
if (seeds.isNotEmpty()) {
// spannable
findViewById<TextView>(R.id.tvSeeds).apply {
text = "" // txt
append("${getString(R.string.seeds)} ", color1, true)
append(seeds, color2, true)
}
}

//val speed = Format.byteFmt(torr.download_speed) + getString(R.string.fmt_s)
val speed = Format.speedFmt(torr.download_speed)
if (speed.isNotEmpty() && torr.download_speed > 50.0) {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/host_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:paddingEnd="12dp"
android:paddingBottom="3dp"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
tools:text="http://127.0.0.1:8090" />
tools:text="http://localhost:8090" />

<com.google.android.flexbox.FlexboxLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -68,12 +68,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center|end"
android:layout_marginEnd="5dp"
android:background="@drawable/ic_circle_online"
android:visibility="invisible" />
android:visibility="invisible"
android:contentDescription="@string/online" />
<!-- can't use vectors with ?attr on 4.4 -->

</RelativeLayout>
7 changes: 7 additions & 0 deletions app/src/main/res/layout/info_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
android:layout_marginEnd="6dp"
tools:text="Peers" />

<TextView
android:id="@+id/tvSeeds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
tools:text="Seeds" />

<TextView
android:id="@+id/tvSpeed"
android:layout_width="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/navigation_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textColor="?attr/colorHost"
android:textSize="16sp"
tools:text="http://localhost:8090"/>
<!--android:textColor="?attr/colorHost"-->

<TextView
android:id="@+id/tvStatus"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/speedtest_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
android:textColor="?attr/colorHost"
android:textSize="20sp"
android:visibility="gone"
tools:text="127.0.0.1:8090"
tools:text="localhost:8090"
tools:visibility="visible" />

<FrameLayout
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<string name="online">На линия</string>
<string name="buffer">Буфер</string>
<string name="peers">Пиъри</string>
<string name="seeds">Сийдъри</string>
<string name="size">Размер</string>
<string name="download_speed">Скорост на сваляне</string>
<string name="bit_rate">Битрейт</string>
Expand All @@ -122,7 +123,7 @@
<string name="need_install_server">Сървърът трябва да бъде инсталиран</string>
<string name="need_update_server">Сървърът трябва да бъде ъпдейтнат</string>
<string name="not_support_old_server">Сървър с версия 1.1.x не се поддържа. Опреснете сървъра или използвайте клиент с версия 1.1.x за такъв сървър.</string>
<string name="not_support_local_ip">Не слагайте IP адрес като URL адрес към сървъра! Използвайте localhost/127.0.0.1 вместо това.</string>
<string name="not_support_local_ip">Не слагайте IP адрес като URL адрес към сървъра! Използвайте localhost | 127.0.0.1 вместо това.</string>
<string name="copy_to_clipboard">Копиран в клипборда</string>
<string name="stat_running">Услугата работи</string>
<string name="server_not_responding">TorrServer не отговаря</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<string name="online">Онлайн</string>
<string name="buffer">Буфер</string>
<string name="peers">Пиры</string>
<string name="seeds">Сиды</string>
<string name="size">Размер</string>
<string name="download_speed">Скорость загрузки</string>
<string name="bit_rate">Битрейт</string>
Expand All @@ -122,7 +123,7 @@
<string name="need_install_server">Необходимо установить сервер</string>
<string name="need_update_server">Необходимо обновить сервер</string>
<string name="not_support_old_server">Версия сервера 1.1.x не поддерживается. Обновите сервер или используйте клиент 1.1.x с ней.</string>
<string name="not_support_local_ip">Не устанавливайте локальный IP-адрес в качестве URL-адреса TorrServer! Вместо этого используйте localhost/127.0.0.1.</string>
<string name="not_support_local_ip">Не устанавливайте локальный IP-адрес устройства в качестве URL-адреса TorrServer! Вместо этого используйте localhost | 127.0.0.1.</string>
<string name="copy_to_clipboard">Скопированно в буфер обмена</string>
<string name="stat_running">Локальный сервер запущен</string>
<string name="server_not_responding">TorrServer не отвечает</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<string name="online">Онлайн</string>
<string name="buffer">Буфер</string>
<string name="peers">Піри</string>
<string name="seeds">Сіди</string>
<string name="size">Розмір</string>
<string name="download_speed">Швидкість завантаження</string>
<string name="found_new_app_update">Знайдено оновлення додатку</string>
Expand All @@ -115,7 +116,7 @@
<string name="need_install_server">Необхідно встановити сервер</string>
<string name="need_update_server">Потрібно оновити сервер</string>
<string name="not_support_old_server">Сервер версії 1.1.x не підтримується. Оновіть сервер або користується клієнтом версії 1.1.x.</string>
<string name="not_support_local_ip">Не встановлюйте локальну IP як URL TorrServer! Натомість використовуйте localhost/127.0.0.1.</string>
<string name="not_support_local_ip">Не встановлюйте локальну IP як URL TorrServer! Натомість використовуйте localhost | 127.0.0.1.</string>
<string name="copy_to_clipboard">Скопійовано до буферу обміну</string>
<string name="stat_running">Службу запущено</string>
<string name="server_not_responding">TorrServer не відповідає</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@

<string name="buffer">缓冲</string>
<string name="peers">用户</string>
<string name="seeds">Seeds</string>
<string name="size">大小</string>
<string name="download_speed">下载速度</string>
<string name="bit_rate">比特率</string>
Expand All @@ -133,7 +134,7 @@
<string name="need_install_server">需要安装服务端</string>
<string name="need_update_server">服务端需要更新</string>
<string name="not_support_old_server">不支持服务端版本 1.1.x。更新服务端或使用客户端 1.1.x。</string>
<string name="not_support_local_ip">不要将本地 IP 设置为 TorrServer URL! 请改用 localhost/127.0.0.1。</string>
<string name="not_support_local_ip">不要将本地 IP 设置为 TorrServer URL! 请改用 localhost | 127.0.0.1。</string>

<string name="copy_to_clipboard">复制到剪贴板</string>
<string name="stat_running">服务正在运行</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@

<string name="buffer">Buffer</string>
<string name="peers">Peers</string>
<string name="seeds">Seeds</string>
<string name="size">Size</string>
<string name="download_speed">Download speed</string>
<string name="bit_rate">Bitrate</string>
Expand All @@ -148,7 +149,7 @@
<string name="need_install_server">Server needs to be installed</string>
<string name="need_update_server">Server needs to be updated</string>
<string name="not_support_old_server">Server version 1.1.x is not supported. Update server or use client 1.1.x for it.</string>
<string name="not_support_local_ip">Don\'t set local IP as torrserver URL! Use localhost/127.0.0.1 instead.</string>
<string name="not_support_local_ip">Don\'t set local device IP as torrserver URL! Use localhost | 127.0.0.1 instead.</string>

<string name="copy_to_clipboard">Copied to clipboard</string>
<string name="stat_running">Service is running</string>
Expand Down

0 comments on commit 85d7773

Please sign in to comment.