diff --git a/app/build.gradle b/app/build.gradle index 143e03b..82d191b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "espero.jiofibatterynotifier" minSdkVersion 17 targetSdkVersion 29 - versionCode 7 - versionName "1.7" + versionCode 8 + versionName "1.8" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index d1dfc2d..b48255c 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "properties": [], - "versionCode": 7, - "versionName": "1.7", + "versionCode": 8, + "versionName": "1.8", "enabled": true, "outputFile": "app-release.apk" } diff --git a/app/src/main/java/espero/jiofibatterynotifier/Services/JioFiService.java b/app/src/main/java/espero/jiofibatterynotifier/Services/JioFiService.java index 8d870df..bc0c87f 100644 --- a/app/src/main/java/espero/jiofibatterynotifier/Services/JioFiService.java +++ b/app/src/main/java/espero/jiofibatterynotifier/Services/JioFiService.java @@ -11,12 +11,14 @@ import android.content.IntentFilter; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.media.MediaPlayer; import android.media.RingtoneManager; import android.net.Uri; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.IBinder; +import android.os.Vibrator; import android.util.Log; import android.widget.Toast; @@ -55,6 +57,10 @@ public JioFiService() { @Override public void onDestroy() { try { + if (mp != null) { + mp.stop(); + mp = null; + } if(thread != null && thread.isAlive()){ thread.interrupt(); thread = null; @@ -79,6 +85,9 @@ public IBinder onBind(Intent intent) { @Override public void onCreate() { super.onCreate(); + mp = MediaPlayer.create(this, R.raw.low); + mp.setLooping(false); + mp.setVolume(0.5f, 0.5f); sharedPrefMain = new SharedPrefMain(this); Log.d(TAG_FOREGROUND_SERVICE, "My foreground service onCreate()."); IntentFilter intentFilter = new IntentFilter(); @@ -335,12 +344,31 @@ private Notification getNotification(String msg, int small_icon, boolean playSou .setContentIntent(pendingIntent).setOnlyAlertOnce(true); if(sharedPrefMain.getBoolean("alerts") && playSound && ((System.currentTimeMillis() - sharedPrefMain.getLong("notif")) > (1000 * 60 * 5))){ sharedPrefMain.setLong("notif", System.currentTimeMillis()); - showAlert(msg); + alert(); +// showAlert(msg); } return notificationBuilder.build(); } + private MediaPlayer mp; + + private void alert() { + if (sharedPrefMain.getBoolean("vibrate")) { + Vibrator vibrator; + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + vibrator.vibrate(500); + } + if (sharedPrefMain.getBoolean("sound")) { + try { + if (mp != null) { + mp.start(); + } + } catch (Exception e) { + } + } + } + private void updateNotification(String msg, int icon, boolean playSOund){ if(!checkWifiOnAndConnected()){ msg = "JioFi Not Connected"; diff --git a/app/src/main/res/layout/custom_message_contact.xml b/app/src/main/res/layout/custom_message_contact.xml index b7639b5..2979d7d 100755 --- a/app/src/main/res/layout/custom_message_contact.xml +++ b/app/src/main/res/layout/custom_message_contact.xml @@ -14,7 +14,7 @@ android:layout_gravity="center" android:layout_marginTop="10dp" android:fontFamily="sans-serif" - android:text="Android JioFi Battery Notifier 1.7" + android:text="Android JioFi Battery Notifier 1.8" android:textAlignment="center" android:textColor="#000" android:textSize="18sp" />