// Path: smssync/src/main/java/org/addhen/smssync/presentation/App.java
// public class App extends BaseApplication {
// 
//     private static AppComponent mAppComponent;
// 
//     private static TwitterClient mTwitter;
// 
//     private static App mApp;
// 
// 
//     public static synchronized TwitterClient getTwitterInstance() {
//         if (mTwitter == null) {
//             mTwitter = new TwitterBuilder(mApp,
//                     BuildConfig.TWITTER_CONSUMER_KEY,
//                     BuildConfig.TWITTER_CONSUMER_SECRET)
//                     .build();
//         }
//         return mTwitter;
//     }
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         initializeInjector();
//         mApp = this;
//         Timber.plant(new FirebaseCrashTree());
//     }
// 
//     private void initializeInjector() {
//         mAppComponent = AppComponent.Initializer.init(this);
//     }
// 
//     public static AppComponent getAppComponent() {
//         return mAppComponent;
//     }
// 
//     /**
//      * Return the application tracker
//      */
//     public static AppTracker getInstance() {
//         return TrackerResolver.getInstance();
//     }
// }


import org.addhen.smssync.R;
import org.addhen.smssync.data.PrefsFactory;
import org.addhen.smssync.presentation.App;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.DialogPreference.TargetFragment;
import android.support.v7.preference.ListPreferenceDialogFragmentCompat;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceDialogFragmentCompat;
import android.view.View;
import android.widget.TimePicker;
/*
 * Copyright (c) 2010 - 2015 Ushahidi Inc
 * All rights reserved
 * Contact: team@ushahidi.com
 * Website: http://www.ushahidi.com
 * GNU Lesser General Public License Usage
 * This file may be used under the terms of the GNU Lesser
 * General Public License version 3 as published by the Free Software
 * Foundation and appearing in the file LICENSE.LGPL included in the
 * packaging of this file. Please review the following information to
 * ensure the GNU Lesser General Public License version 3 requirements
 * will be met: http://www.gnu.org/licenses/lgpl.html.
 *
 * If you have questions regarding the use of this file, please contact
 * Ushahidi developers at team@ushahidi.com.
 */

package org.addhen.smssync.presentation.view.ui.widget;



/**
 * @author Ushahidi Team <team@ushahidi.com>
 */
public class TimePreferenceFragmentDialog extends PreferenceDialogFragmentCompat implements
        TargetFragment {

    public static final String DIALOG_FRAGMENT_TAG
            = "android.support.v7.preference.PreferenceFragment.DIALOG";

    // Fist picker field
    private int lastHour = 0;

    // Second picker field
    private int lastMinute = 0;

    private TimePicker picker = null;

    private PrefsFactory prefs;

    private ListPreferenceDialogFragmentCompat mListPreferenceDialogFragmentCompat;

    public TimePreferenceFragmentDialog() {

    }

    public static TimePreferenceFragmentDialog newInstance(String key) {
        TimePreferenceFragmentDialog fragment = new TimePreferenceFragmentDialog();
        Bundle bundle = new Bundle(1);
        bundle.putString("key", key);
        fragment.setArguments(bundle);
        return fragment;
    }

    protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
        super.onPrepareDialogBuilder(builder);
        TimePreference preference = this.getTimePreference();
        builder.setPositiveButton(R.string.ok, (dialog, which) -> {
            saveSelectedTime(preference);
            dialog.dismiss();
        });
    }


    @Override
    protected View onCreateDialogView(Context context) {
// Path: smssync/src/main/java/org/addhen/smssync/presentation/App.java
// public class App extends BaseApplication {
// 
//     private static AppComponent mAppComponent;
// 
//     private static TwitterClient mTwitter;
// 
//     private static App mApp;
// 
// 
//     public static synchronized TwitterClient getTwitterInstance() {
//         if (mTwitter == null) {
//             mTwitter = new TwitterBuilder(mApp,
//                     BuildConfig.TWITTER_CONSUMER_KEY,
//                     BuildConfig.TWITTER_CONSUMER_SECRET)
//                     .build();
//         }
//         return mTwitter;
//     }
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         initializeInjector();
//         mApp = this;
//         Timber.plant(new FirebaseCrashTree());
//     }
// 
//     private void initializeInjector() {
//         mAppComponent = AppComponent.Initializer.init(this);
//     }
// 
//     public static AppComponent getAppComponent() {
//         return mAppComponent;
//     }
// 
//     /**
//      * Return the application tracker
//      */
//     public static AppTracker getInstance() {
//         return TrackerResolver.getInstance();
//     }
// }


// Path: smssync/src/main/java/org/addhen/smssync/presentation/view/ui/widget/TimePreferenceFragmentDialog.java
import org.addhen.smssync.R;
import org.addhen.smssync.data.PrefsFactory;
import org.addhen.smssync.presentation.App;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.DialogPreference.TargetFragment;
import android.support.v7.preference.ListPreferenceDialogFragmentCompat;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceDialogFragmentCompat;
import android.view.View;
import android.widget.TimePicker;

/*
 * Copyright (c) 2010 - 2015 Ushahidi Inc
 * All rights reserved
 * Contact: team@ushahidi.com
 * Website: http://www.ushahidi.com
 * GNU Lesser General Public License Usage
 * This file may be used under the terms of the GNU Lesser
 * General Public License version 3 as published by the Free Software
 * Foundation and appearing in the file LICENSE.LGPL included in the
 * packaging of this file. Please review the following information to
 * ensure the GNU Lesser General Public License version 3 requirements
 * will be met: http://www.gnu.org/licenses/lgpl.html.
 *
 * If you have questions regarding the use of this file, please contact
 * Ushahidi developers at team@ushahidi.com.
 */

package org.addhen.smssync.presentation.view.ui.widget;



/**
 * @author Ushahidi Team <team@ushahidi.com>
 */
public class TimePreferenceFragmentDialog extends PreferenceDialogFragmentCompat implements
        TargetFragment {

    public static final String DIALOG_FRAGMENT_TAG
            = "android.support.v7.preference.PreferenceFragment.DIALOG";

    // Fist picker field
    private int lastHour = 0;

    // Second picker field
    private int lastMinute = 0;

    private TimePicker picker = null;

    private PrefsFactory prefs;

    private ListPreferenceDialogFragmentCompat mListPreferenceDialogFragmentCompat;

    public TimePreferenceFragmentDialog() {

    }

    public static TimePreferenceFragmentDialog newInstance(String key) {
        TimePreferenceFragmentDialog fragment = new TimePreferenceFragmentDialog();
        Bundle bundle = new Bundle(1);
        bundle.putString("key", key);
        fragment.setArguments(bundle);
        return fragment;
    }

    protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
        super.onPrepareDialogBuilder(builder);
        TimePreference preference = this.getTimePreference();
        builder.setPositiveButton(R.string.ok, (dialog, which) -> {
            saveSelectedTime(preference);
            dialog.dismiss();
        });
    }


    @Override
    protected View onCreateDialogView(Context context) {
        prefs = App.getAppComponent().prefsFactory();