notification
This commit is contained in:
4 files changed
+80
-5
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package com.github.kr328.clash.service
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
|
||||
class ClashNotification(private val context: Context) {
|
||||
companion object {
|
||||
private const val CLASH_STATUS_NOTIFICATION_CHANNEL = "clash_status_channel"
|
||||
private const val CLASH_STATUS_NOTIFICATION_ID = 413
|
||||
|
||||
private const val MAIN_ACTIVITY_NAME = ".MainActivity"
|
||||
}
|
||||
|
||||
init {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationManagerCompat.from(context)
|
||||
.createNotificationChannel(
|
||||
NotificationChannel(CLASH_STATUS_NOTIFICATION_CHANNEL,
|
||||
context.getString(R.string.clash_service_status_channel),
|
||||
NotificationManager.IMPORTANCE_MIN)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun show() {
|
||||
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,6 @@ import java.util.concurrent.Executors
|
||||
class ClashService : Service() {
|
||||
companion object {
|
||||
private const val TAG = "ClashForAndroid"
|
||||
|
||||
private const val CLASH_STATUS_NOTIFICATION_CHANNEL = "clash_status_channel"
|
||||
private const val CLASH_STATUS_NOTIFICATION_ID = 413
|
||||
|
||||
private const val MAIN_ACTIVITY_NAME = ".MainActivity"
|
||||
}
|
||||
|
||||
private val handler = Handler()
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/clash_notification_up_title"
|
||||
android:text="@string/clash_notification_up"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/clash_notification_down_title"
|
||||
android:text="@string/clash_notification_down"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/clash_notification_up"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/clash_notification_default" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/clash_notification_down"
|
||||
android:text="@string/clash_notification_default"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -5,4 +5,8 @@
|
||||
<string name="clash_service_running">Running</string>
|
||||
<string name="clash_service_running_message">Profile %s loaded</string>
|
||||
<string name="clash_service_vpn_mode">VPN</string>
|
||||
|
||||
<string name="clash_notification_up">UP</string>
|
||||
<string name="clash_notification_down">Down</string>
|
||||
<string name="clash_notification_default">0 KiB/s</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user