Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: When permissions are denied initially nothing happens on mic icon click #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import android.os.Environment;
import android.os.IBinder;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Chronometer;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -236,6 +238,9 @@ public void onSingleClick(View v) {
if (PermissionsHelper.checkAndRequestPermissions(
RecordFragment.this, MY_PERMISSIONS_REQUEST_RECORD_AUDIO)) {
startRecording();
} else {
Toast.makeText(getActivity(), getString(R.string.error_no_permission_granted_record), Toast.LENGTH_LONG).show();
openAppSettings();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a handler for the RECORD button. I assume that the PAUSE/RESUME button is affected by the same issue, so it would be good if you apply your fix in both places. Though I didn't test permissions request after click on RESUME button. So not sure. But I suggest you to make changes in PermissionsHelper.checkAndRequestPermissions method, which is invoked after a click on RECORD button as well as a click on RESUME button.

}
} else {
stopRecording();
Expand All @@ -244,6 +249,15 @@ public void onSingleClick(View v) {
};
}

private void openAppSettings() {
Intent intent = new Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", requireActivity().getPackageName(), null)
);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}

private Intent getStartServiceIntent() {
return MyIntentBuilder
.getInstance(requireActivity(), RecordingService.class)
Expand Down