// Path: mobile/src/main/java/ch/liip/timeforcoffee/widget/SnackBars.java
// public class SnackBars {
// 
//     public static void showNetworkError(Activity activity, View.OnClickListener listener) {
//         Snackbar snackbar = Snackbar
//                 .make(activity.findViewById(R.id.content), activity.getResources().getString(R.string.network_error), Snackbar.LENGTH_INDEFINITE)
//                 .setAction(activity.getResources().getString(R.string.retry), listener);
// 
//         snackbar.show();
//     }
// 
//     public static void showLocalisationServiceOff(final Activity activity) {
//         Snackbar snackbar = Snackbar
//                 .make(activity.findViewById(R.id.content), activity.getResources().getString(R.string.location_service_off), Snackbar.LENGTH_INDEFINITE)
//                 .setAction(activity.getResources().getString(R.string.activate), new View.OnClickListener() {
//                     @Override
//                     public void onClick(View view) {
//                         activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
//                     }
//                 });
// 
//         snackbar.show();
//     }
// 
//     public static void showLocalisationServiceSetToDeviceOnly(final Activity activity) {
//         Snackbar snackbar = Snackbar
//                 .make(activity.findViewById(R.id.content), activity.getResources().getString(R.string.location_service_gps_only), Snackbar.LENGTH_INDEFINITE)
//                 .setAction(activity.getResources().getString(R.string.location_service_gps_only_settings), new View.OnClickListener() {
//                     @Override
//                     public void onClick(View view) {
//                         activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
//                     }
//                 });
// 
//         snackbar.show();
//     }
// 
//     public static void showLocalisationSettings(final Activity activity) {
//         Snackbar snackbar = Snackbar
//                 .make(activity.findViewById(R.id.content), activity.getResources().getString(R.string.permission_no_location), Snackbar.LENGTH_INDEFINITE)
//                 .setAction(activity.getResources().getString(R.string.grant), new View.OnClickListener() {
//                     @Override
//                     public void onClick(View view) {
//                         Intent intent = new Intent();
//                         intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
//                         Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
//                         intent.setData(uri);
//                         activity.startActivity(intent);
//                     }
//                 });
// 
//         snackbar.show();
//     }
// }


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import ch.liip.timeforcoffee.R;
import ch.liip.timeforcoffee.widget.SnackBars;
package ch.liip.timeforcoffee.helper;



/**
 * Created by nicolas on 06/03/16.
 */
public class PermissionsChecker {
    Context context;

    public PermissionsChecker(Context context) {
        this.context = context;
    }

    public boolean LacksPermission(String permission) {
        return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_DENIED;
    }

    public void RequestPermission(final Activity activity, final String permission, final int requestCode, String message) {
        //Returns true if the app has requested this permission previously and the user denied the request.
        //Return false if first time that permission is request or user checked "never ask again"
        if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
            AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.AppCompatAlertDialogStyle);
            builder.setMessage(message);
            builder.setPositiveButton(activity.getResources().getString(R.string.permission_allow), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
                }
            });
            builder.setNegativeButton(activity.getResources().getString(R.string.permission_dont_allow), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
// Path: mobile/src/main/java/ch/liip/timeforcoffee/widget/SnackBars.java
// public class SnackBars {
// 
//     public static void showNetworkError(Activity activity, View.OnClickListener listener) {
//         Snackbar snackbar = Snackbar
//                 .make(activity.findViewById(R.id.content), activity.getResources().getString(R.string.network_error), Snackbar.LENGTH_INDEFINITE)
//                 .setAction(activity.getResources().getString(R.string.retry), listener);
// 
//         snackbar.show();
//     }
// 
//     public static void showLocalisationServiceOff(final Activity activity) {
//         Snackbar snackbar = Snackbar
//                 .make(activity.findViewById(R.id.content), activity.getResources().getString(R.string.location_service_off), Snackbar.LENGTH_INDEFINITE)
//                 .setAction(activity.getResources().getString(R.string.activate), new View.OnClickListener() {
//                     @Override
//                     public void onClick(View view) {
//                         activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
//                     }
//                 });
// 
//         snackbar.show();
//     }
// 
//     public static void showLocalisationServiceSetToDeviceOnly(final Activity activity) {
//         Snackbar snackbar = Snackbar
//                 .make(activity.findViewById(R.id.content), activity.getResources().getString(R.string.location_service_gps_only), Snackbar.LENGTH_INDEFINITE)
//                 .setAction(activity.getResources().getString(R.string.location_service_gps_only_settings), new View.OnClickListener() {
//                     @Override
//                     public void onClick(View view) {
//                         activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
//                     }
//                 });
// 
//         snackbar.show();
//     }
// 
//     public static void showLocalisationSettings(final Activity activity) {
//         Snackbar snackbar = Snackbar
//                 .make(activity.findViewById(R.id.content), activity.getResources().getString(R.string.permission_no_location), Snackbar.LENGTH_INDEFINITE)
//                 .setAction(activity.getResources().getString(R.string.grant), new View.OnClickListener() {
//                     @Override
//                     public void onClick(View view) {
//                         Intent intent = new Intent();
//                         intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
//                         Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
//                         intent.setData(uri);
//                         activity.startActivity(intent);
//                     }
//                 });
// 
//         snackbar.show();
//     }
// }


// Path: mobile/src/main/java/ch/liip/timeforcoffee/helper/PermissionsChecker.java
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import ch.liip.timeforcoffee.R;
import ch.liip.timeforcoffee.widget.SnackBars;

package ch.liip.timeforcoffee.helper;



/**
 * Created by nicolas on 06/03/16.
 */
public class PermissionsChecker {
    Context context;

    public PermissionsChecker(Context context) {
        this.context = context;
    }

    public boolean LacksPermission(String permission) {
        return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_DENIED;
    }

    public void RequestPermission(final Activity activity, final String permission, final int requestCode, String message) {
        //Returns true if the app has requested this permission previously and the user denied the request.
        //Return false if first time that permission is request or user checked "never ask again"
        if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
            AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.AppCompatAlertDialogStyle);
            builder.setMessage(message);
            builder.setPositiveButton(activity.getResources().getString(R.string.permission_allow), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
                }
            });
            builder.setNegativeButton(activity.getResources().getString(R.string.permission_dont_allow), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    SnackBars.showLocalisationSettings(activity);