// Path: app/src/main/java/pl/srw/billcalculator/data/ApplicationRepo.java
// @Singleton
// public class ApplicationRepo {
// 
//     private static final String PREFERENCE_KEY_FIRST_LAUNCH = "first_launch";
//     private static final String PREFERENCE_KEY_HELP_SHOWN = "help_shown";
//     private final SharedPreferences prefs;
// 
//     @Inject
//     ApplicationRepo(@Named(GLOBAL_SHARED_PREFS) SharedPreferences prefs) {
//         this.prefs = prefs;
//     }
// 
//     public boolean isFirstLaunch() {
//         return prefs.getString(PREFERENCE_KEY_FIRST_LAUNCH, "").isEmpty();
//     }
// 
//     public void markFirstLaunch() {
//         prefs.edit().putString(PREFERENCE_KEY_FIRST_LAUNCH, new Date().toString()).apply();
//     }
// 
//     public boolean wasHelpShown() {
//         return prefs.contains(PREFERENCE_KEY_HELP_SHOWN);
//     }
// 
//     public void markHelpShown() {
//         prefs.edit().putBoolean(PREFERENCE_KEY_HELP_SHOWN, true).apply();
//     }
// }
// 
// Path: app/src/main/java/pl/srw/billcalculator/util/analytics/Analytics.java
// public class Analytics {
// 
//     private static boolean ENABLED = false;
// 
//     public static void enable(Context context) {
// //        Fabric.with(context, new Crashlytics(), new Answers());
// //        ENABLED = true;
//     }
//     /**
//      * Logs user viewed content. This will be used to see statistics
//      */
//     public static void contentView(@ContentType String contentId, Object... args) {
//         Timber.i("Content viewed: " + contentId + " " + Arrays.toString(args));
// //        if (!ENABLED) return;
// 
// //        ContentViewEvent event = new ContentViewEvent();
// //        event.putContentId(contentId);
// //        for (int i = 0; i < getEvenLength(contentId, args); i+=2) {
// //            event.putCustomAttribute(args[i].toString(), args[i + 1].toString());
// //        }
// //        Answers.getInstance().logContentView(event);
//     }
// 
//     /**
//      * Logs event happened. This will be used to see statistics
//      */
//     public static void event(@EventType String type, Object... args) {
//         Timber.i("Event: " + type + " " + Arrays.toString(args));
// //        if (!ENABLED) return;
// 
// //        CustomEvent customEvent = new CustomEvent(type);
// //        for (int i = 0; i < getEvenLength(type, args); i+=2) {
// //            customEvent.putCustomAttribute(args[i].toString(), args[i + 1].toString());
// //        }
// //        Answers.getInstance().logCustom(customEvent);
//     }
// 
//     /**
//      * Logs unexpected event happened. This will be used to see statistics
//      */
//     public static void warning(String event) {
//         event(EventType.UNEXPECTED, "case", event);
//     }
// 
//     /**
//      * Logs unexpected event happened. This will be used to see statistics
//      */
//     public static void warning(String event, String key, Object value) {
//         event(EventType.UNEXPECTED, "case", event, key, value);
//     }
// 
//     private static int getEvenLength(String id, Object[] args) {
//         if (args.length % 2 != 0) {
//             warning("Args length not even", "Args not even for", id);
//             return args.length - 1;
//         }
//         return args.length;
//     }
// }


import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.KeyEvent;
import javax.inject.Inject;
import pl.srw.billcalculator.R;
import pl.srw.billcalculator.data.ApplicationRepo;
import pl.srw.billcalculator.di.Dependencies;
import pl.srw.billcalculator.settings.SettingsActivity;
import pl.srw.billcalculator.util.analytics.Analytics;
import pl.srw.billcalculator.util.analytics.EventType;
package pl.srw.billcalculator.dialog;




public class CheckPricesDialogFragment extends DialogFragment {

    @Inject ApplicationRepo dataRepo;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Dependencies.INSTANCE.inject(this);
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setIcon(R.drawable.ic_check_circle_black_24dp)
                .setTitle(R.string.check_prices_info_title)
                .setMessage(R.string.check_price_info_message)
                .setPositiveButton(R.string.check_prices_info_ok, positiveClickListener())
                .setNegativeButton(R.string.check_prices_info_cancel, negativeClickListener())
                .setOnKeyListener(backButtonListener());
        return builder.create();
    }

    private DialogInterface.OnClickListener positiveClickListener() {
        return (dialog, which) -> {
            Analytics.event(EventType.CHECK_PRICES, "proceed", true);
            SettingsActivity.start(getContext());
            markDialogProcessed();
        };
    }

    private DialogInterface.OnClickListener negativeClickListener() {
        return (dialog, which) -> {
// Path: app/src/main/java/pl/srw/billcalculator/data/ApplicationRepo.java
// @Singleton
// public class ApplicationRepo {
// 
//     private static final String PREFERENCE_KEY_FIRST_LAUNCH = "first_launch";
//     private static final String PREFERENCE_KEY_HELP_SHOWN = "help_shown";
//     private final SharedPreferences prefs;
// 
//     @Inject
//     ApplicationRepo(@Named(GLOBAL_SHARED_PREFS) SharedPreferences prefs) {
//         this.prefs = prefs;
//     }
// 
//     public boolean isFirstLaunch() {
//         return prefs.getString(PREFERENCE_KEY_FIRST_LAUNCH, "").isEmpty();
//     }
// 
//     public void markFirstLaunch() {
//         prefs.edit().putString(PREFERENCE_KEY_FIRST_LAUNCH, new Date().toString()).apply();
//     }
// 
//     public boolean wasHelpShown() {
//         return prefs.contains(PREFERENCE_KEY_HELP_SHOWN);
//     }
// 
//     public void markHelpShown() {
//         prefs.edit().putBoolean(PREFERENCE_KEY_HELP_SHOWN, true).apply();
//     }
// }
// 
// Path: app/src/main/java/pl/srw/billcalculator/util/analytics/Analytics.java
// public class Analytics {
// 
//     private static boolean ENABLED = false;
// 
//     public static void enable(Context context) {
// //        Fabric.with(context, new Crashlytics(), new Answers());
// //        ENABLED = true;
//     }
//     /**
//      * Logs user viewed content. This will be used to see statistics
//      */
//     public static void contentView(@ContentType String contentId, Object... args) {
//         Timber.i("Content viewed: " + contentId + " " + Arrays.toString(args));
// //        if (!ENABLED) return;
// 
// //        ContentViewEvent event = new ContentViewEvent();
// //        event.putContentId(contentId);
// //        for (int i = 0; i < getEvenLength(contentId, args); i+=2) {
// //            event.putCustomAttribute(args[i].toString(), args[i + 1].toString());
// //        }
// //        Answers.getInstance().logContentView(event);
//     }
// 
//     /**
//      * Logs event happened. This will be used to see statistics
//      */
//     public static void event(@EventType String type, Object... args) {
//         Timber.i("Event: " + type + " " + Arrays.toString(args));
// //        if (!ENABLED) return;
// 
// //        CustomEvent customEvent = new CustomEvent(type);
// //        for (int i = 0; i < getEvenLength(type, args); i+=2) {
// //            customEvent.putCustomAttribute(args[i].toString(), args[i + 1].toString());
// //        }
// //        Answers.getInstance().logCustom(customEvent);
//     }
// 
//     /**
//      * Logs unexpected event happened. This will be used to see statistics
//      */
//     public static void warning(String event) {
//         event(EventType.UNEXPECTED, "case", event);
//     }
// 
//     /**
//      * Logs unexpected event happened. This will be used to see statistics
//      */
//     public static void warning(String event, String key, Object value) {
//         event(EventType.UNEXPECTED, "case", event, key, value);
//     }
// 
//     private static int getEvenLength(String id, Object[] args) {
//         if (args.length % 2 != 0) {
//             warning("Args length not even", "Args not even for", id);
//             return args.length - 1;
//         }
//         return args.length;
//     }
// }


// Path: app/src/main/java/pl/srw/billcalculator/dialog/CheckPricesDialogFragment.java
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.KeyEvent;
import javax.inject.Inject;
import pl.srw.billcalculator.R;
import pl.srw.billcalculator.data.ApplicationRepo;
import pl.srw.billcalculator.di.Dependencies;
import pl.srw.billcalculator.settings.SettingsActivity;
import pl.srw.billcalculator.util.analytics.Analytics;
import pl.srw.billcalculator.util.analytics.EventType;

package pl.srw.billcalculator.dialog;




public class CheckPricesDialogFragment extends DialogFragment {

    @Inject ApplicationRepo dataRepo;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Dependencies.INSTANCE.inject(this);
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setIcon(R.drawable.ic_check_circle_black_24dp)
                .setTitle(R.string.check_prices_info_title)
                .setMessage(R.string.check_price_info_message)
                .setPositiveButton(R.string.check_prices_info_ok, positiveClickListener())
                .setNegativeButton(R.string.check_prices_info_cancel, negativeClickListener())
                .setOnKeyListener(backButtonListener());
        return builder.create();
    }

    private DialogInterface.OnClickListener positiveClickListener() {
        return (dialog, which) -> {
            Analytics.event(EventType.CHECK_PRICES, "proceed", true);
            SettingsActivity.start(getContext());
            markDialogProcessed();
        };
    }

    private DialogInterface.OnClickListener negativeClickListener() {
        return (dialog, which) -> {
            Analytics.event(EventType.CHECK_PRICES, "proceed", false);