// Path: app/src/main/java/fr/julienvermet/bugdroid/application/BugDroidApplication.java
// public class BugDroidApplication extends Application implements OnSharedPreferenceChangeListener {
// 
//     // Android
//     public static Context mContext;
//     private static SharedPreferences mPrefs;
// 
//     // Objects
//     public static Instance mCurrentInstance;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         mContext = getApplicationContext();
//         mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
//         mPrefs.registerOnSharedPreferenceChangeListener(this);
// 
//         setDefaultInstance();
//     }
// 
//     private static void setDefaultInstance() {
// 
//         int instanceId = mPrefs.getInt(InstancesListFragment.INSTANCE_ID, -1);
//         int accountId = mPrefs.getInt(InstancesListFragment.ACCOUNT_ID, -1);
// 
//         Account account = null;
// 
//         if (accountId >= 0) {
//             Uri uriAccount = Uri.withAppendedPath(Accounts.CONTENT_URI, String.valueOf(accountId));
//             Cursor cursorAccount = mContext.getContentResolver().query(uriAccount, Accounts.PROJECTION, null,
//                 null, null);
//             if (cursorAccount.getCount() > 0) {
//                 cursorAccount.moveToFirst();
//                 account = Account.toAccount(cursorAccount);
//             }
//             cursorAccount.close();
//         }
// 
//         if (instanceId >= 0) {
//             Uri uri = Uri.withAppendedPath(Instances.CONTENT_URI, String.valueOf(instanceId));
//             Cursor cursorInstance = mContext.getContentResolver().query(uri, Instances.PROJECTION, null,
//                 null, null);
//             if (cursorInstance.getCount() > 0) {
//                 cursorInstance.moveToFirst();
//                 mCurrentInstance = Instance.toInstance(cursorInstance);
//                 mCurrentInstance.account = account;
//             }
//             cursorInstance.close();
//         }
//     }
// 
//     @Override
//     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
//         if (key.equals(InstancesListFragment.ACCOUNT_ID) || key.equals(InstancesListFragment.INSTANCE_ID)) {
//             setDefaultInstance();
//         }
//     }
// 
//     @Override
//     public void onTerminate() {
//         super.onTerminate();
//         mPrefs.unregisterOnSharedPreferenceChangeListener(this);
//     }
// }


import fr.julienvermet.bugdroid.provider.BugDroidContent.Bugs;
import fr.julienvermet.bugdroid.provider.BugDroidContent.Bugs.Columns;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import com.google.gson.annotations.SerializedName;
import fr.julienvermet.bugdroid.R;
import fr.julienvermet.bugdroid.application.BugDroidApplication;
        bug.qaContact = new User();
        bug.qaContact.name = cursor.getString(cursor.getColumnIndexOrThrow(Columns.QA_CONTACT_NAME.getName()));
        bug.qaContact.realName = cursor.getString(cursor.getColumnIndexOrThrow(Columns.QA_CONTACT_REAL_NAME.getName()));
        bug.ref = cursor.getString(cursor.getColumnIndexOrThrow(Columns.REF.getName()));
        bug.resolution = cursor.getString(cursor.getColumnIndexOrThrow(Columns.RESOLUTION.getName()));
        bug.severity = cursor.getString(cursor.getColumnIndexOrThrow(Columns.SEVERITY.getName()));
        bug.status = cursor.getString(cursor.getColumnIndexOrThrow(Columns.STATUS.getName()));
        bug.summary = cursor.getString(cursor.getColumnIndexOrThrow(Columns.SUMMARY.getName()));
        bug.targetMilestone = cursor.getString(cursor.getColumnIndexOrThrow(Columns.TARGET_MILESTONE.getName()));
        bug.version = cursor.getString(cursor.getColumnIndexOrThrow(Columns.VERSION.getName()));
        bug.whiteboard = cursor.getString(cursor.getColumnIndexOrThrow(Columns.WHITEBOARD.getName()));
        return bug;
    }

    @Override
    public String toString() {

        Context context = BugDroidApplication.mContext;
        Resources res = context.getResources();

        StringBuffer string = new StringBuffer();
        string.append(res.getString(R.string.bug_title) + ":" + summary + "\n");
        string.append(res.getString(R.string.bug_status) + ":" + status + "\n");
        string.append(res.getString(R.string.bug_resolution) + ":" + resolution + "\n");
        string.append(res.getString(R.string.bug_product) + ":" + product + "\n");
        string.append(res.getString(R.string.bug_component) + ":" + component + "\n");
        string.append(res.getString(R.string.bug_version) + ":" + version + "\n");
        string.append(res.getString(R.string.bug_platform) + ":" + platform + "\n");
        string.append(res.getString(R.string.bug_importance) + ":" + severity + "\n");
        string.append(res.getString(R.string.bug_assigned_to) + ":" + assignedTo.toString() + "\n");
// Path: app/src/main/java/fr/julienvermet/bugdroid/application/BugDroidApplication.java
// public class BugDroidApplication extends Application implements OnSharedPreferenceChangeListener {
// 
//     // Android
//     public static Context mContext;
//     private static SharedPreferences mPrefs;
// 
//     // Objects
//     public static Instance mCurrentInstance;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         mContext = getApplicationContext();
//         mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
//         mPrefs.registerOnSharedPreferenceChangeListener(this);
// 
//         setDefaultInstance();
//     }
// 
//     private static void setDefaultInstance() {
// 
//         int instanceId = mPrefs.getInt(InstancesListFragment.INSTANCE_ID, -1);
//         int accountId = mPrefs.getInt(InstancesListFragment.ACCOUNT_ID, -1);
// 
//         Account account = null;
// 
//         if (accountId >= 0) {
//             Uri uriAccount = Uri.withAppendedPath(Accounts.CONTENT_URI, String.valueOf(accountId));
//             Cursor cursorAccount = mContext.getContentResolver().query(uriAccount, Accounts.PROJECTION, null,
//                 null, null);
//             if (cursorAccount.getCount() > 0) {
//                 cursorAccount.moveToFirst();
//                 account = Account.toAccount(cursorAccount);
//             }
//             cursorAccount.close();
//         }
// 
//         if (instanceId >= 0) {
//             Uri uri = Uri.withAppendedPath(Instances.CONTENT_URI, String.valueOf(instanceId));
//             Cursor cursorInstance = mContext.getContentResolver().query(uri, Instances.PROJECTION, null,
//                 null, null);
//             if (cursorInstance.getCount() > 0) {
//                 cursorInstance.moveToFirst();
//                 mCurrentInstance = Instance.toInstance(cursorInstance);
//                 mCurrentInstance.account = account;
//             }
//             cursorInstance.close();
//         }
//     }
// 
//     @Override
//     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
//         if (key.equals(InstancesListFragment.ACCOUNT_ID) || key.equals(InstancesListFragment.INSTANCE_ID)) {
//             setDefaultInstance();
//         }
//     }
// 
//     @Override
//     public void onTerminate() {
//         super.onTerminate();
//         mPrefs.unregisterOnSharedPreferenceChangeListener(this);
//     }
// }


// Path: app/src/main/java/fr/julienvermet/bugdroid/model/Bug.java
import fr.julienvermet.bugdroid.provider.BugDroidContent.Bugs;
import fr.julienvermet.bugdroid.provider.BugDroidContent.Bugs.Columns;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import com.google.gson.annotations.SerializedName;
import fr.julienvermet.bugdroid.R;
import fr.julienvermet.bugdroid.application.BugDroidApplication;

        bug.qaContact = new User();
        bug.qaContact.name = cursor.getString(cursor.getColumnIndexOrThrow(Columns.QA_CONTACT_NAME.getName()));
        bug.qaContact.realName = cursor.getString(cursor.getColumnIndexOrThrow(Columns.QA_CONTACT_REAL_NAME.getName()));
        bug.ref = cursor.getString(cursor.getColumnIndexOrThrow(Columns.REF.getName()));
        bug.resolution = cursor.getString(cursor.getColumnIndexOrThrow(Columns.RESOLUTION.getName()));
        bug.severity = cursor.getString(cursor.getColumnIndexOrThrow(Columns.SEVERITY.getName()));
        bug.status = cursor.getString(cursor.getColumnIndexOrThrow(Columns.STATUS.getName()));
        bug.summary = cursor.getString(cursor.getColumnIndexOrThrow(Columns.SUMMARY.getName()));
        bug.targetMilestone = cursor.getString(cursor.getColumnIndexOrThrow(Columns.TARGET_MILESTONE.getName()));
        bug.version = cursor.getString(cursor.getColumnIndexOrThrow(Columns.VERSION.getName()));
        bug.whiteboard = cursor.getString(cursor.getColumnIndexOrThrow(Columns.WHITEBOARD.getName()));
        return bug;
    }

    @Override
    public String toString() {

        Context context = BugDroidApplication.mContext;
        Resources res = context.getResources();

        StringBuffer string = new StringBuffer();
        string.append(res.getString(R.string.bug_title) + ":" + summary + "\n");
        string.append(res.getString(R.string.bug_status) + ":" + status + "\n");
        string.append(res.getString(R.string.bug_resolution) + ":" + resolution + "\n");
        string.append(res.getString(R.string.bug_product) + ":" + product + "\n");
        string.append(res.getString(R.string.bug_component) + ":" + component + "\n");
        string.append(res.getString(R.string.bug_version) + ":" + version + "\n");
        string.append(res.getString(R.string.bug_platform) + ":" + platform + "\n");
        string.append(res.getString(R.string.bug_importance) + ":" + severity + "\n");
        string.append(res.getString(R.string.bug_assigned_to) + ":" + assignedTo.toString() + "\n");
        string.append(res.getString(R.string.bug_qa_contact) + ":" + qaContact.toString() + "\n");