// Path: app/src/main/java/com/nilhcem/droidconde/receiver/BootReceiver.java
// @DebugLog
// public class BootReceiver extends BroadcastReceiver {
// 
//     @Inject SessionsReminder sessionsReminder;
// 
//     public BootReceiver() {
//     }
// 
//     public static void enable(Context context) {
//         setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
//     }
// 
//     public static void disable(Context context) {
//         setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
//     }
// 
//     private static void setActivationState(Context context, int state) {
//         ComponentName componentName = new ComponentName(context, BootReceiver.class);
//         PackageManager pm = context.getPackageManager();
//         pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
//     }
// 
//     @Override
//     public void onReceive(Context context, Intent intent) {
//         DroidconApp.get(context).component().inject(this);
//         sessionsReminder.enableSessionReminder();
//     }
// }
// 
// Path: app/src/main/java/com/nilhcem/droidconde/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
// 
//     private final Context context;
//     private final SessionsDao sessionsDao;
//     private final SharedPreferences preferences;
//     private final AlarmManager alarmManager;
// 
//     @Inject
//     public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
//         this.context = app;
//         this.sessionsDao = sessionsDao;
//         this.preferences = preferences;
//         alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
//     }
// 
//     public boolean isEnabled() {
//         return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
//     }
// 
//     public void enableSessionReminder() {
//         performOnSelectedSessions(this::addSessionReminder);
//     }
// 
//     public void disableSessionReminder() {
//         performOnSelectedSessions(this::removeSessionReminder);
//     }
// 
//     public void addSessionReminder(@NonNull Session session) {
//         if (!isEnabled()) {
//             Timber.d("SessionsReminder is not enable, skip adding session");
//             return;
//         }
// 
//         PendingIntent intent = createSessionReminderIntent(session);
//         LocalDateTime now = LocalDateTime.now();
//         LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
//         if (!sessionStartTime.isAfter(now)) {
//             Timber.w("Do not set reminder for passed session");
//             return;
//         }
//         Timber.d("Setting reminder on %s", sessionStartTime);
//         App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
//     }
// 
//     public void removeSessionReminder(@NonNull Session session) {
//         Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
//         createSessionReminderIntent(session).cancel();
//     }
// 
//     private PendingIntent createSessionReminderIntent(@NonNull Session session) {
//         Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
//         return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
//     }
// 
//     private void performOnSelectedSessions(Action1<? super Session> onNext) {
//         sessionsDao.getSelectedSessions()
//                 .flatMap(Observable::from)
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(Schedulers.computation())
//                 .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
//     }
// }
// 
// Path: app/src/main/java/com/nilhcem/droidconde/ui/BasePresenter.java
// public abstract class BasePresenter<V> {
// 
//     protected final V view;
// 
//     public BasePresenter(V view) {
//         this.view = view;
//     }
// }
// 
// Path: app/src/main/java/com/nilhcem/droidconde/utils/App.java
// public final class App {
// 
//     private App() {
//         throw new UnsupportedOperationException();
//     }
// 
//     public static boolean isCompatible(int apiLevel) {
//         return android.os.Build.VERSION.SDK_INT >= apiLevel;
//     }
// 
//     public static String getVersion() {
//         String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
//         if (BuildConfig.INTERNAL_BUILD) {
//             version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
//         }
//         return version;
//     }
// 
//     public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
//         if (isCompatible(Build.VERSION_CODES.KITKAT)) {
//             alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
//         } else {
//             alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
//         }
//     }
// 
//     @Nullable
//     public static String getPhotoUrl(@Nullable Session session) {
//         String photoUrl = null;
//         if (session != null) {
//             List<Speaker> speakers = session.getSpeakers();
//             if (speakers != null && !speakers.isEmpty()) {
//                 photoUrl = speakers.get(0).getPhoto();
//             }
//         }
//         return photoUrl;
//     }
// }


import android.content.Context;
import com.nilhcem.droidconde.receiver.BootReceiver;
import com.nilhcem.droidconde.receiver.reminder.SessionsReminder;
import com.nilhcem.droidconde.ui.BasePresenter;
import com.nilhcem.droidconde.utils.App;
package com.nilhcem.droidconde.ui.settings;



public class SettingsPresenter extends BasePresenter<SettingsMvp.View> implements SettingsMvp.Presenter {

    private final Context context;
    private final SessionsReminder sessionsReminder;

// Path: app/src/main/java/com/nilhcem/droidconde/receiver/BootReceiver.java
// @DebugLog
// public class BootReceiver extends BroadcastReceiver {
// 
//     @Inject SessionsReminder sessionsReminder;
// 
//     public BootReceiver() {
//     }
// 
//     public static void enable(Context context) {
//         setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
//     }
// 
//     public static void disable(Context context) {
//         setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
//     }
// 
//     private static void setActivationState(Context context, int state) {
//         ComponentName componentName = new ComponentName(context, BootReceiver.class);
//         PackageManager pm = context.getPackageManager();
//         pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
//     }
// 
//     @Override
//     public void onReceive(Context context, Intent intent) {
//         DroidconApp.get(context).component().inject(this);
//         sessionsReminder.enableSessionReminder();
//     }
// }
// 
// Path: app/src/main/java/com/nilhcem/droidconde/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
// 
//     private final Context context;
//     private final SessionsDao sessionsDao;
//     private final SharedPreferences preferences;
//     private final AlarmManager alarmManager;
// 
//     @Inject
//     public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
//         this.context = app;
//         this.sessionsDao = sessionsDao;
//         this.preferences = preferences;
//         alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
//     }
// 
//     public boolean isEnabled() {
//         return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
//     }
// 
//     public void enableSessionReminder() {
//         performOnSelectedSessions(this::addSessionReminder);
//     }
// 
//     public void disableSessionReminder() {
//         performOnSelectedSessions(this::removeSessionReminder);
//     }
// 
//     public void addSessionReminder(@NonNull Session session) {
//         if (!isEnabled()) {
//             Timber.d("SessionsReminder is not enable, skip adding session");
//             return;
//         }
// 
//         PendingIntent intent = createSessionReminderIntent(session);
//         LocalDateTime now = LocalDateTime.now();
//         LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
//         if (!sessionStartTime.isAfter(now)) {
//             Timber.w("Do not set reminder for passed session");
//             return;
//         }
//         Timber.d("Setting reminder on %s", sessionStartTime);
//         App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
//     }
// 
//     public void removeSessionReminder(@NonNull Session session) {
//         Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
//         createSessionReminderIntent(session).cancel();
//     }
// 
//     private PendingIntent createSessionReminderIntent(@NonNull Session session) {
//         Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
//         return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
//     }
// 
//     private void performOnSelectedSessions(Action1<? super Session> onNext) {
//         sessionsDao.getSelectedSessions()
//                 .flatMap(Observable::from)
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(Schedulers.computation())
//                 .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
//     }
// }
// 
// Path: app/src/main/java/com/nilhcem/droidconde/ui/BasePresenter.java
// public abstract class BasePresenter<V> {
// 
//     protected final V view;
// 
//     public BasePresenter(V view) {
//         this.view = view;
//     }
// }
// 
// Path: app/src/main/java/com/nilhcem/droidconde/utils/App.java
// public final class App {
// 
//     private App() {
//         throw new UnsupportedOperationException();
//     }
// 
//     public static boolean isCompatible(int apiLevel) {
//         return android.os.Build.VERSION.SDK_INT >= apiLevel;
//     }
// 
//     public static String getVersion() {
//         String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
//         if (BuildConfig.INTERNAL_BUILD) {
//             version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
//         }
//         return version;
//     }
// 
//     public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
//         if (isCompatible(Build.VERSION_CODES.KITKAT)) {
//             alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
//         } else {
//             alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
//         }
//     }
// 
//     @Nullable
//     public static String getPhotoUrl(@Nullable Session session) {
//         String photoUrl = null;
//         if (session != null) {
//             List<Speaker> speakers = session.getSpeakers();
//             if (speakers != null && !speakers.isEmpty()) {
//                 photoUrl = speakers.get(0).getPhoto();
//             }
//         }
//         return photoUrl;
//     }
// }


// Path: app/src/main/java/com/nilhcem/droidconde/ui/settings/SettingsPresenter.java
import android.content.Context;
import com.nilhcem.droidconde.receiver.BootReceiver;
import com.nilhcem.droidconde.receiver.reminder.SessionsReminder;
import com.nilhcem.droidconde.ui.BasePresenter;
import com.nilhcem.droidconde.utils.App;

package com.nilhcem.droidconde.ui.settings;



public class SettingsPresenter extends BasePresenter<SettingsMvp.View> implements SettingsMvp.Presenter {

    private final Context context;
    private final SessionsReminder sessionsReminder;

    public SettingsPresenter(Context context, SettingsMvp.View view, SessionsReminder sessionsReminder) {