// Path: app/src/main/java/com/knight/arch/api/FirService.java
// public interface FirService {
//     @GET("/apps/latest/{id}")
//     Observable<FirVersion> checkVersion(@Path("id") String app_id, @Query(value = "api_token") String api_token);
// }
// 
// Path: app/src/main/java/com/knight/arch/model/FirVersion.java
// public class FirVersion {
// 
//     @Expose
//     private String name;
//     @Expose
//     private Integer version;
//     @SerializedName("changelog")
//     @Expose
//     private String changeLog;
//     @Expose
//     private String versionShort;
//     @Expose
//     private String installUrl;
//     @SerializedName("update_url")
//     @Expose
//     private String updateUrl;
// 
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public Integer getVersion() {
//         return version;
//     }
// 
//     public void setVersion(Integer version) {
//         this.version = version;
//     }
// 
//     public String getChangeLog() {
//         return changeLog;
//     }
// 
//     public void setChangeLog(String changeLog) {
//         this.changeLog = changeLog;
//     }
// 
//     public String getVersionShort() {
//         return versionShort;
//     }
// 
//     public void setVersionShort(String versionShort) {
//         this.versionShort = versionShort;
//     }
// 
//     public String getInstallUrl() {
//         return installUrl;
//     }
// 
//     public void setInstallUrl(String installUrl) {
//         this.installUrl = installUrl;
//     }
// 
//     public String getUpdateUrl() {
//         return updateUrl;
//     }
// 
//     public void setUpdateUrl(String updateUrl) {
//         this.updateUrl = updateUrl;
//     }
// }
// 
// Path: app/src/main/java/com/knight/arch/module/Injector.java
// public abstract interface Injector {
//   public abstract List<Object> getModules();
// 
//   public abstract void inject(Object target);
// 
//   public abstract ObjectGraph plus(Object[] modules);
// }


import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.widget.Toast;
import com.knight.arch.BuildConfig;
import com.knight.arch.R;
import com.knight.arch.api.FirService;
import com.knight.arch.model.FirVersion;
import com.knight.arch.module.Injector;
import com.umeng.analytics.MobclickAgent;
import javax.inject.Inject;
import de.psdev.licensesdialog.LicensesDialog;
import rx.Subscriber;
import rx.android.app.AppObservable;
                        } else {
                            Toast.makeText(getActivity(), R.string.msg_this_is_latest_version, Toast.LENGTH_SHORT).show();
                            dialog.dismiss();
                        }
                    }
                });
    }

    private void showNewVersionFoundDialog(final FirVersion newFirVersion) {
        new AlertDialog.Builder(getActivity())
                .setTitle(R.string.title_new_version_found)
                .setMessage(getString(R.string.msg_new_version_found, newFirVersion.getVersionShort(), newFirVersion.getVersion(), newFirVersion.getChangeLog()))
                .setPositiveButton(R.string.btn_dialog_update, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent downloadPageIntent = new Intent(Intent.ACTION_VIEW);
                        downloadPageIntent.setData(Uri.parse(newFirVersion.getUpdateUrl()));
                        getActivity().startActivity(downloadPageIntent);
                    }
                })
                .setNegativeButton(android.R.string.cancel, null)
                .create()
                .show();
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (!injected) {
            injected = true;
// Path: app/src/main/java/com/knight/arch/api/FirService.java
// public interface FirService {
//     @GET("/apps/latest/{id}")
//     Observable<FirVersion> checkVersion(@Path("id") String app_id, @Query(value = "api_token") String api_token);
// }
// 
// Path: app/src/main/java/com/knight/arch/model/FirVersion.java
// public class FirVersion {
// 
//     @Expose
//     private String name;
//     @Expose
//     private Integer version;
//     @SerializedName("changelog")
//     @Expose
//     private String changeLog;
//     @Expose
//     private String versionShort;
//     @Expose
//     private String installUrl;
//     @SerializedName("update_url")
//     @Expose
//     private String updateUrl;
// 
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public Integer getVersion() {
//         return version;
//     }
// 
//     public void setVersion(Integer version) {
//         this.version = version;
//     }
// 
//     public String getChangeLog() {
//         return changeLog;
//     }
// 
//     public void setChangeLog(String changeLog) {
//         this.changeLog = changeLog;
//     }
// 
//     public String getVersionShort() {
//         return versionShort;
//     }
// 
//     public void setVersionShort(String versionShort) {
//         this.versionShort = versionShort;
//     }
// 
//     public String getInstallUrl() {
//         return installUrl;
//     }
// 
//     public void setInstallUrl(String installUrl) {
//         this.installUrl = installUrl;
//     }
// 
//     public String getUpdateUrl() {
//         return updateUrl;
//     }
// 
//     public void setUpdateUrl(String updateUrl) {
//         this.updateUrl = updateUrl;
//     }
// }
// 
// Path: app/src/main/java/com/knight/arch/module/Injector.java
// public abstract interface Injector {
//   public abstract List<Object> getModules();
// 
//   public abstract void inject(Object target);
// 
//   public abstract ObjectGraph plus(Object[] modules);
// }


// Path: app/src/main/java/com/knight/arch/ui/fragment/SettingsFragment.java
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.widget.Toast;
import com.knight.arch.BuildConfig;
import com.knight.arch.R;
import com.knight.arch.api.FirService;
import com.knight.arch.model.FirVersion;
import com.knight.arch.module.Injector;
import com.umeng.analytics.MobclickAgent;
import javax.inject.Inject;
import de.psdev.licensesdialog.LicensesDialog;
import rx.Subscriber;
import rx.android.app.AppObservable;

                        } else {
                            Toast.makeText(getActivity(), R.string.msg_this_is_latest_version, Toast.LENGTH_SHORT).show();
                            dialog.dismiss();
                        }
                    }
                });
    }

    private void showNewVersionFoundDialog(final FirVersion newFirVersion) {
        new AlertDialog.Builder(getActivity())
                .setTitle(R.string.title_new_version_found)
                .setMessage(getString(R.string.msg_new_version_found, newFirVersion.getVersionShort(), newFirVersion.getVersion(), newFirVersion.getChangeLog()))
                .setPositiveButton(R.string.btn_dialog_update, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent downloadPageIntent = new Intent(Intent.ACTION_VIEW);
                        downloadPageIntent.setData(Uri.parse(newFirVersion.getUpdateUrl()));
                        getActivity().startActivity(downloadPageIntent);
                    }
                })
                .setNegativeButton(android.R.string.cancel, null)
                .create()
                .show();
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (!injected) {
            injected = true;
            Injector injector = (Injector) getActivity();