From 52aa080cf1d5bc284c4c2b532365493bf8412bd2 Mon Sep 17 00:00:00 2001 From: suraj Date: Mon, 25 Nov 2024 12:21:10 +0530 Subject: [PATCH] removing silent --- app/src/main/AndroidManifest.xml | 4 +- .../suggestions/SuggestionStripView.java | 52 +++++++++---------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7420a0c76..ae2734060 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,8 +7,8 @@ SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only - - + + diff --git a/app/src/main/java/org/oscar/kb/latin/suggestions/SuggestionStripView.java b/app/src/main/java/org/oscar/kb/latin/suggestions/SuggestionStripView.java index 4afb4fbc1..08a52db66 100644 --- a/app/src/main/java/org/oscar/kb/latin/suggestions/SuggestionStripView.java +++ b/app/src/main/java/org/oscar/kb/latin/suggestions/SuggestionStripView.java @@ -1,18 +1,12 @@ package org.oscar.kb.latin.suggestions; -import static android.app.ProgressDialog.show; -import static androidx.core.content.ContextCompat.getSystemService; -import static androidx.core.content.ContextCompat.startActivity; + import static org.oscar.kb.latin.utils.ToolbarUtilsKt.createToolbarKey; import static org.oscar.kb.latin.utils.ToolbarUtilsKt.getCodeForToolbarKey; import static org.oscar.kb.latin.utils.ToolbarUtilsKt.getCodeForToolbarKeyLongClick; -import android.content.res.Configuration; import android.app.NotificationManager; import android.media.AudioManager; -import android.media.Ringtone; -import android.media.RingtoneManager; -import android.net.Uri; import android.os.Handler; import android.os.Looper; import android.widget.Button; @@ -63,7 +57,6 @@ import com.google.firebase.FirebaseApp; import com.google.firebase.crashlytics.FirebaseCrashlytics; -import org.oscar.kb.AIEngine.AIOutputEvent; import org.oscar.kb.AIEngine.OnTextUpdatedListener; import org.oscar.kb.AIEngine.SummarizeErrorEvent; import org.oscar.kb.AIEngine.SummarizeViewModel; @@ -428,8 +421,9 @@ public SuggestionStripView(final Context context, final AttributeSet attrs, fina timerTextView = findViewById(R.id.timerTextView); cancel = findViewById(R.id.et_cancel); done = findViewById(R.id.et_done); - audioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); - currentmode = audioManager.getRingerMode(); + +// audioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); +// currentmode = audioManager.getRingerMode(); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); @@ -458,21 +452,23 @@ public void onClick(View v) { startTimer(); // Starts the timer startRecord(); vibrate(); - NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !notificationManager.isNotificationPolicyAccessGranted()) { - // Ask for permission to modify Do Not Disturb settings - Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Add this line - getContext().startActivity(intent); - } else { - // Permission granted, modify ringer mode - audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); - Toast.makeText(getContext(), "Silent Mode Activated..", Toast.LENGTH_SHORT).show(); +// NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !notificationManager.isNotificationPolicyAccessGranted()) { +// // Ask for permission to modify Do Not Disturb settings +// Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS); +// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Add this line +// getContext().startActivity(intent); +// +// } else { +// // Permission granted, modify ringer mode +// audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); +// Toast.makeText(getContext(), "Silent Mode Activated..", Toast.LENGTH_SHORT).show(); +// +// audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); +// Toast.makeText(getContext(), "Vibrate Mode Activated..", Toast.LENGTH_SHORT).show(); +// } - audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); - Toast.makeText(getContext(), "Vibrate Mode Activated..", Toast.LENGTH_SHORT).show(); - } } }); cancel.setOnClickListener(new OnClickListener() { @@ -489,8 +485,9 @@ public void onClick(View v) { isCancelled = true; tempRecognizedText = null; // Optionally clear the temporary text aiOutput.setText(""); // Optionally clear the TextView - audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); - Toast.makeText(getContext(), "Ringtone Mode Activated..", Toast.LENGTH_SHORT).show(); + +// audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); +// Toast.makeText(getContext(), "Ringtone Mode Activated..", Toast.LENGTH_SHORT).show(); } }); done.setOnClickListener(new View.OnClickListener() { @@ -506,8 +503,9 @@ public void onClick(View v) { ivDelete.setVisibility(View.VISIBLE); stopRecord(); isCancelled = false; - audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); - Toast.makeText(getContext(), "Ringtone Mode Activated..", Toast.LENGTH_SHORT).show(); + +// audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); +// Toast.makeText(getContext(), "Ringtone Mode Activated..", Toast.LENGTH_SHORT).show(); aiOutput.setText(""); // Save user input