Skip to content

Commit

Permalink
removing silent
Browse files Browse the repository at this point in the history
  • Loading branch information
surajsahani committed Nov 25, 2024
1 parent 24fa78a commit 52aa080
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />-->
<!-- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />-->

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_USER_DICTIONARY" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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
Expand Down

0 comments on commit 52aa080

Please sign in to comment.