package com.makeeasy.dpandstatus;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.util.DisplayMetrics;
import android.view.Display;

import androidx.appcompat.app.AlertDialog;

import com.google.android.gms.ads.AdSize;

public class Constant {
    public static final String OK = "ok";
    public static final String CID = "cid";
    public static final String NID = "nid";
    public static final String POSTS = "posts";
    public static final String SHEETS = "SHEETS";
    public static final String STATUS = "status";
    public static final String IMG_TITLE = "news_title";
    public static final String IMG_DATE = "news_date";
    public static final String IMG_LINK = "news_image";
    public static final String POST_COUNT = "post_count";
    public static final String CATEGORYARRAY = "categories";
    public static final String CATEGORY_NAME = "category_name";
    public static final String CATEGORY_IMAGE = "category_image";
    public static final String BASE_URL = "https://namaltech.net/admin/dp/";
    public static final String API_KEY = "cda11j7cyZBgPhJANq9nxvi3EMXpmUHFOew5bCQDLo4k6Rdu0I";
    public static final String CATEGORY_URL = BASE_URL + "api/get_category_index?api_key=" + API_KEY;
    public static final String PHOTOS_URL = BASE_URL + "api/get_category_posts?api_key=" + API_KEY + "&id=";
    public static final String CONTACT_US_TEXT = "Contact Us: contact@dpstatus.com";
    public static final String SHARE_TEXT = "Let me recommend this app. Download Now- https://play.google.com/store/apps/details?id=";
    public static final String POLICY_LINK = "https://google.com/?q=privacy%20policy";

    public static void alertBox(Context ctx,String msg, String btn,DialogInterface.OnClickListener listener) {
        AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
        builder.setCancelable(false);builder.setMessage(msg);
        builder.setPositiveButton(btn,listener);
        builder.create().show();
    }
    public static void alertBox(Context ctx,String msg) {
        AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
        builder.setCancelable(false);builder.setMessage(msg);
        builder.setPositiveButton("OK", (dialog, i) -> dialog.dismiss());
        builder.create().show();
    }
    public static AdSize getAdSize(Activity activity) {
        Display display = activity.getWindowManager().getDefaultDisplay();
        DisplayMetrics outMetrics = new DisplayMetrics();
        display.getMetrics(outMetrics);
        float widthPixels = outMetrics.widthPixels;
        float density = outMetrics.density;
        int adWidth = (int) (widthPixels / density);
        return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(activity,adWidth);
    }
    public static boolean isConnected(Context ctx) {
        ConnectivityManager connectivityManager = ((ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE));
        return connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isConnected();
    }
}
