Skip to content

Commit

Permalink
add accessibility notification note and icon
Browse files Browse the repository at this point in the history
  • Loading branch information
tsynik committed Jun 4, 2024
1 parent d01f309 commit ca0f546
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import android.os.IBinder
import androidx.core.app.NotificationCompat
import androidx.core.app.ServiceCompat
import ru.yourok.torrserve.R
import ru.yourok.torrserve.app.App
import ru.yourok.torrserve.atv.Utils
import ru.yourok.torrserve.server.local.TorrService
import ru.yourok.torrserve.ui.activities.main.MainActivity
import ru.yourok.torrserve.utils.Accessibility

class NotificationHelper {
private var mService: NotificationTS? = null
Expand Down Expand Up @@ -117,22 +119,22 @@ class NotificationTS : Service() {
this.getSystemService(NotificationManager::class.java)!!
.createNotificationChannel(channel)
}

val accessibilityNote = if (Accessibility.isEnabledService(App.context)) this.getText(R.string.accessibility_note) else ""
if (builder == null)
builder = NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.mipmap.ic_launcher)
.setSmallIcon(R.drawable.ts_icon)
.setContentText(getString(R.string.stat_running))
.setAutoCancel(false)
.setOngoing(true)
.setContentIntent(contentPendingIntent)
.setStyle(NotificationCompat.BigTextStyle().bigText(""))
.setStyle(NotificationCompat.BigTextStyle().bigText(accessibilityNote))
.addAction(
android.R.drawable.ic_delete,
this.getText(R.string.exit),
exitPendingIntent
)
else
builder?.setStyle(NotificationCompat.BigTextStyle().bigText(""))
builder?.setStyle(NotificationCompat.BigTextStyle().bigText(accessibilityNote))

if (Utils.isAmazonTV)
builder?.setLargeIcon(BitmapFactory.decodeResource(resources, R.drawable.ic_notification))
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/ts_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="600"
android:viewportHeight="600">
<path
android:pathData="M300,30C150.88,30 30,150.88 30,300s120.88,270 270,270s270,-120.88 270,-270S449.12,30 300,30zM300,520c-121.5,0 -220,-98.5 -220,-220S178.5,80 300,80s220,98.5 220,220S421.5,520 300,520z"
android:fillColor="#2A2122"/>
<path
android:pathData="M395.11,356.81c-0.35,-1.46 -0.7,-2.57 -0.89,-3.71c-2.44,-15.02 -9,-22.58 -23.98,-24.56c-7.7,-1.02 -15.92,0.1 -23.63,1.61c-3.83,0.75 -7.85,3.92 -10.43,7.1c-7.3,9 -4.39,21.07 6.48,25.55c7.93,3.27 16.54,4.9 24.86,7.19c9.3,2.56 18.83,4.47 27.89,7.68c16.3,5.77 27.37,16.4 28.46,34.8c1.09,18.47 -7.63,33.57 -25,41.21c-22.65,9.96 -45.77,10.13 -68.22,-0.6c-17.48,-8.35 -26.14,-23 -26.93,-42.38c-0.17,-4.12 1.54,-5.84 5.51,-5.79c4.34,0.06 8.71,-0.3 12.99,0.18c1.68,0.19 4.18,1.89 4.56,3.36c5.83,22.47 14.96,30.3 37.94,30.65c6.85,0.11 13.98,-1.15 20.56,-3.17c9.44,-2.9 13.77,-9.5 13.95,-18.54c0.19,-9.17 -3.24,-14.9 -13.15,-18.3c-10.03,-3.45 -20.55,-5.47 -30.81,-8.27c-7.7,-2.1 -15.49,-4.01 -22.95,-6.8c-13.6,-5.09 -22.95,-14.19 -24.22,-29.48c-1.35,-16.29 4.44,-29.5 18.27,-38.57c12.78,-8.39 27.23,-10.95 42.11,-9.43c8.31,0.85 16.91,2.72 24.49,6.11c16.32,7.31 23.49,21.36 24.91,38.7c0.26,3.12 -0.88,5.35 -4.28,5.42C407.46,356.9 401.31,356.81 395.11,356.81z"
android:fillColor="#242424"/>
<path
android:pathData="M223.2,185.61c-14.24,0 -27.57,0.01 -40.89,-0.01c-5.81,-0.01 -6.76,-0.9 -6.75,-6.62c0.03,-16.52 -1.68,-14.79 14.58,-14.8c32.67,-0.02 65.34,-0.01 98.01,0c6.41,0 7.2,0.78 7.21,7.18c0.01,15.84 1.4,14.24 -14.14,14.25c-10.96,0.01 -21.92,0 -33.51,0c0,2.44 0,4.38 0,6.32c0,37.68 0,75.36 0,113.04c0,7.03 -0.73,7.76 -7.69,7.77c-3,0.01 -6,0.01 -9,0c-7.07,-0.01 -7.81,-0.73 -7.81,-7.65c0,-37.68 0,-75.36 0,-113.04C223.2,190.09 223.2,188.14 223.2,185.61z"
android:fillColor="#242424"/>
<path
android:pathData="M437.72,39.43c0.17,0.34 0.12,0.76 -0.15,1.04c-0.94,0.99 0.68,-1.15 0,0C402,100.78 363.82,164.18 328.3,224.52c-0.38,0.64 -0.66,1.33 -1.07,2.33c-0.29,0.71 0.36,1.44 1.1,1.24c25.64,-6.99 50.54,-13.79 76.43,-20.85c0.86,-0.23 1.52,0.76 0.97,1.46c-33.68,43.03 -66.74,85.26 -99.78,127.47c0.69,1.27 0.76,1.4 1.44,2.67c19.85,-1.67 39.72,-3.34 60.26,-5.07c0.8,-0.07 1.3,0.86 0.8,1.49c-0.61,0.76 -1.13,1.42 -1.71,2.02C296.38,409.7 225.99,482.1 155.63,554.52c-0.65,0.67 -1.2,1.44 -1.74,2.22c-0.4,0.57 -1.26,0.51 -1.58,-0.12l-0.01,-0.02c-0.18,-0.37 -0.1,-0.82 0.2,-1.09c0.64,-0.58 1.32,-1.15 1.77,-1.85c34.29,-54.11 68.55,-108.23 102.81,-162.37c0.35,-0.55 0.63,-1.14 1.06,-2.03c0.32,-0.66 -0.22,-1.41 -0.95,-1.32c-20.5,2.6 -40.29,5.1 -60.85,7.7c-0.78,0.1 -1.33,-0.77 -0.88,-1.43c27.77,-41.29 55.13,-81.95 83.24,-123.74c0.45,-0.66 -0.11,-1.55 -0.91,-1.43c-21.2,3.21 -41.2,6.25 -62.07,9.41c-0.86,0.13 -1.4,-0.89 -0.82,-1.53c3.15,-3.48 5.9,-6.55 8.71,-9.56c53.23,-56.98 106.47,-113.93 159.69,-170.92c17.05,-18.26 34.03,-36.61 51.01,-54.94c0.66,-0.71 1.22,-1.5 1.79,-2.29c0.4,-0.57 1.26,-0.5 1.57,0.12L437.72,39.43z"
android:fillColor="#FE7E00"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,5 @@
<string name="cat_music">Музика</string>
<string name="cat_other">Друго</string>
<string name="cat_none">Всички торенти</string>
<string name="accessibility_note">Деактивирайте услугата за достъпност, за да спрете TorrServer</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,5 @@
<string name="cat_music">Музыка</string>
<string name="cat_other">Другое</string>
<string name="cat_none">Все торренты</string>
<string name="accessibility_note">Отключите сервис специальных возможностей, чтобы остановить TorrServer.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,5 @@
<string name="cat_music">Музика</string>
<string name="cat_other">Інше</string>
<string name="cat_none">Усі торренти</string>
<string name="accessibility_note">Вимкніть службу доступності, щоб зупинити TorrServer.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,6 @@
<string name="cat_music">音乐</string>
<string name="cat_other">其他</string>
<string name="cat_none">所有种子</string>

<string name="accessibility_note">禁用辅助功能服务以停止 TorrServer</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,6 @@
<string name="cat_music">Music</string>
<string name="cat_other">Other</string>
<string name="cat_none">All torrents</string>

<string name="accessibility_note">Disable Accessibility service to stop TorrServer</string>
</resources>

0 comments on commit ca0f546

Please sign in to comment.