diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml
index f2d7f58fc..776d718b8 100644
--- a/TMessagesProj/src/main/AndroidManifest.xml
+++ b/TMessagesProj/src/main/AndroidManifest.xml
@@ -282,6 +282,7 @@
+
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
index f3fdcf0d5..1bfe654d0 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
@@ -106,6 +106,9 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import tw.nekomimi.nekogram.DuangService;
+import tw.nekomimi.nekogram.NekoConfig;
+
public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate {
private boolean finished;
@@ -658,6 +661,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
FileLog.e(e);
}
MediaController.getInstance().setBaseActivity(this, true);
+ if (NekoConfig.residentNotification) {
+ Intent duangIntent = new Intent(ApplicationLoader.applicationContext, DuangService.class);
+ ApplicationLoader.applicationContext.startService(duangIntent);
+ }
}
public void switchToAccount(int account, boolean removeAll) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
index c7bb0911c..6cc02149c 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
@@ -458,7 +458,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
LocaleController.getString("DebugMenuResetContacts", R.string.DebugMenuResetContacts),
LocaleController.getString("DebugMenuResetDialogs", R.string.DebugMenuResetDialogs),
BuildVars.LOGS_ENABLED ? LocaleController.getString("DebugMenuDisableLogs", R.string.DebugMenuDisableLogs) : LocaleController.getString("DebugMenuEnableLogs", R.string.DebugMenuEnableLogs),
- SharedConfig.inappCamera ? LocaleController.getString("DebugMenuDisableCamera", R.string.DebugMenuDisableCamera) : LocaleController.getString("DebugMenuEnableCamera", R.string.DebugMenuEnableCamera),
+ NekoConfig.residentNotification ? LocaleController.getString("DisableResidentNotification", R.string.DisableResidentNotification) : LocaleController.getString("EnableResidentNotification", R.string.EnableResidentNotification),
LocaleController.getString("DebugMenuClearMediaCache", R.string.DebugMenuClearMediaCache),
LocaleController.getString("DebugMenuCallSettings", R.string.DebugMenuCallSettings),
null,
@@ -481,7 +481,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
sharedPreferences.edit().putBoolean("logsEnabled", BuildVars.LOGS_ENABLED).commit();
} else if (which == 5) {
- SharedConfig.toggleInappCamera();
+ NekoConfig.toggleResidentNotification();
} else if (which == 6) {
MessagesStorage.getInstance(currentAccount).clearSentMedia();
SharedConfig.setNoSoundHintShowed(false);
diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/DuangService.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/DuangService.java
new file mode 100644
index 000000000..619f2e47a
--- /dev/null
+++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/DuangService.java
@@ -0,0 +1,53 @@
+package tw.nekomimi.nekogram;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.IBinder;
+
+import org.telegram.messenger.ApplicationLoader;
+import org.telegram.messenger.LocaleController;
+import org.telegram.messenger.R;
+import org.telegram.ui.LaunchActivity;
+
+public class DuangService extends Service {
+
+ NotificationManager systemNotificationManager = null;
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ Intent activityIntent = new Intent(this, LaunchActivity.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(getApplication(), 0, activityIntent, 0);
+
+ Notification.Builder builder;
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
+ NotificationChannel notificationChannel = new NotificationChannel("duang", "Other", NotificationManager.IMPORTANCE_DEFAULT);
+ notificationChannel.enableLights(false);
+ notificationChannel.enableVibration(false);
+ notificationChannel.setSound(null, null);
+ systemNotificationManager = (NotificationManager) ApplicationLoader.applicationContext.getSystemService(Context.NOTIFICATION_SERVICE);
+ systemNotificationManager.createNotificationChannel(notificationChannel);
+ builder = new Notification.Builder(getApplication(), "duang");
+ } else {
+ builder = new Notification.Builder(getApplication());
+
+ }
+ Notification notification = builder.setSmallIcon(R.drawable.notification).
+ setContentTitle(LocaleController.getString("NekogramRunning", R.string.NekogramRunning)).
+ setContentIntent(pendingIntent).
+ setWhen(System.currentTimeMillis()).
+ build();
+ startForeground(38264, notification);
+ return super.onStartCommand(intent, flags, startId);
+ }
+}
diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
index e274b042b..4d7016908 100644
--- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
+++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
@@ -2,6 +2,7 @@ package tw.nekomimi.nekogram;
import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import org.telegram.messenger.ApplicationLoader;
@@ -20,6 +21,7 @@ public class NekoConfig {
public static boolean transparentStatusBar = true;
public static boolean navigationBarTint = true;
public static int navigationBarColor = 2;
+ public static boolean residentNotification = false;
private static boolean configLoaded;
static {
@@ -42,6 +44,7 @@ public class NekoConfig {
editor.putBoolean("transparentStatusBar", transparentStatusBar);
editor.putBoolean("navigationBarTint", navigationBarTint);
editor.putInt("navigationBarColor", navigationBarColor);
+ editor.putBoolean("residentNotification", residentNotification);
editor.commit();
} catch (Exception e) {
@@ -67,6 +70,7 @@ public class NekoConfig {
transparentStatusBar = preferences.getBoolean("transparentStatusBar", true);
navigationBarTint = preferences.getBoolean("navigationBarTint", true);
navigationBarColor = preferences.getInt("navigationBarColor", 2);
+ residentNotification = preferences.getBoolean("residentNotification", false);
configLoaded = true;
}
}
@@ -151,4 +155,18 @@ public class NekoConfig {
editor.commit();
}
+ public static void toggleResidentNotification() {
+ residentNotification = !residentNotification;
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean("residentNotification", residentNotification);
+ editor.commit();
+ Intent duangIntent = new Intent(ApplicationLoader.applicationContext, DuangService.class);
+ if (residentNotification) {
+ ApplicationLoader.applicationContext.startService(duangIntent);
+ } else {
+ ApplicationLoader.applicationContext.stopService(duangIntent);
+ }
+ }
+
}
diff --git a/TMessagesProj/src/main/res/values-ja/strings_neko.xml b/TMessagesProj/src/main/res/values-ja/strings_neko.xml
index acc8b7a16..a37bffa9d 100644
--- a/TMessagesProj/src/main/res/values-ja/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values-ja/strings_neko.xml
@@ -33,4 +33,7 @@
黒
アクションバーの色を使う
メッセージパネルの色を使う
+ 常駐通知を表示する
+ 常駐通知を無効にする
+ Nekogram ランニング
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml
index da0e16ed5..2693be2f4 100644
--- a/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml
@@ -33,4 +33,7 @@
使用黑色
使用标题栏颜色
使用消息面板颜色
+ 请让猫咪住在通知栏里吧
+ 果然通知栏还是太挤了
+ Nekogram 正在运行
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml b/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml
index 43727e9a5..c5a5c0fc5 100644
--- a/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml
@@ -33,4 +33,7 @@
使用黑色
使用標題欄顏色
使用消息面板顏色
+ 請讓貓咪住在通知欄裡吧
+ 果然通知欄還是太擠了
+ Nekogram 正在運行
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values/strings_neko.xml b/TMessagesProj/src/main/res/values/strings_neko.xml
index de66a3432..564f45227 100644
--- a/TMessagesProj/src/main/res/values/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values/strings_neko.xml
@@ -33,4 +33,7 @@
Black
Use action bar color
Use message panel color
+ Show a resident notification
+ Disable resident notification
+ Nekogram is running
\ No newline at end of file