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

ask notification perm in focus quest #21

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
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
65 changes: 0 additions & 65 deletions .androidide/editor/openedFiles.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nethical.digipaws.fragments.quests;

import android.Manifest;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand All @@ -9,9 +10,12 @@
import android.view.View;
import android.view.ViewGroup;

import androidx.core.content.ContextCompat;
import android.content.pm.PackageManager;
import androidx.fragment.app.Fragment;


import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import nethical.digipaws.R;
import nethical.digipaws.services.FocusModeTimerService;
import nethical.digipaws.utils.SurvivalModeManager;
Expand All @@ -38,6 +42,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
hollowTimer.setTitle("Start");
if( ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED){
makeNotificationPermissionDialog().create().show();
}

hollowTimer.setOnClickListener((v)->{
if(isQuestRunning){
return;
Expand Down Expand Up @@ -73,4 +81,18 @@ public void onReceive(Context context, Intent intent) {
}
};

private MaterialAlertDialogBuilder makeNotificationPermissionDialog(){
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.missing_permission)
.setMessage(R.string.notification_notif_permission)
.setNeutralButton("Provide",(dialog,which)->{
requestPermissions(
new String[]{Manifest.permission.POST_NOTIFICATIONS},
0);

});
return builder;
}


}
Loading