// 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/ui/SettingsActivity.java
// public class SettingsActivity extends SherlockPreferenceActivity implements OnSharedPreferenceChangeListener {
// 
//     public static final String KEY_SEARCH_PERIOD = "search_period";
// 
//     private ListPreference mDashboardPeriod;
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         addPreferencesFromResource(R.xml.settings);
// 
//         ActionBar actionBar = getSupportActionBar();
//         actionBar.setDisplayHomeAsUpEnabled(true);
// 
//         mDashboardPeriod = (ListPreference) getPreferenceScreen().findPreference(KEY_SEARCH_PERIOD);
//         setSummaryListPreference(mDashboardPeriod);
//     }
// 
//     @Override
//     protected void onResume() {
//         super.onResume();
//         getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
//     }
// 
//     @Override
//     protected void onPause() {
//         super.onPause();
//         getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
//     }
// 
//     @Override
//     public boolean onOptionsItemSelected(MenuItem item) {
// 
//         switch (item.getItemId()) {
//         case android.R.id.home:
//             finish();
//             break;
//         }
// 
//         return super.onOptionsItemSelected(item);
//     }
// 
//     @Override
//     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
//         if (key.equals(KEY_SEARCH_PERIOD)) {
//             setSummaryListPreference(mDashboardPeriod);
//         }
//     }
// 
//     private void setSummaryListPreference(ListPreference listPreference) {
//         listPreference.setSummary(listPreference.getEntry());
//     }
// }


import java.io.Serializable;
import java.net.URLEncoder;
import java.util.ArrayList;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import fr.julienvermet.bugdroid.application.BugDroidApplication;
import fr.julienvermet.bugdroid.ui.SettingsActivity;
            keywords = URLEncoder.encode(keywords);
            return String.format(BUGS_QUICK_SEARCH, keywords);
        }
    }

    public static class DashboardSearch extends Search {

        private static final long serialVersionUID = -7918981619210024917L;
        int searchType;

        public DashboardSearch(String name, int requestCode, Instance instance, int searchType) {
            super(requestCode, instance);
            this.searchType = searchType;
        }

        @Override
        protected String buildQuery() {
            String username = account.username;
            switch (searchType) {
            case DASHBOARD_TO_REVIEW:
                return String.format(DASHBOARD_QUERY_TO_REVIEW, username);
            case DASHBOARD_REPORTED:
                return String.format(DASHBOARD_QUERY_REPORTED, username, username);
            case DASHBOARD_ASSIGNED:
                return String.format(DASHBOARD_QUERY_ASSIGNED, username);
            case DASHBOARD_CCD:
                return String.format(DASHBOARD_QUERY_CCD, username, username);
            case DASHBOARD_RECENTLY_FIXED:
                return String.format(DASHBOARD_QUERY_RECENTLY_FIXED, username);
            default:
// 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/ui/SettingsActivity.java
// public class SettingsActivity extends SherlockPreferenceActivity implements OnSharedPreferenceChangeListener {
// 
//     public static final String KEY_SEARCH_PERIOD = "search_period";
// 
//     private ListPreference mDashboardPeriod;
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         addPreferencesFromResource(R.xml.settings);
// 
//         ActionBar actionBar = getSupportActionBar();
//         actionBar.setDisplayHomeAsUpEnabled(true);
// 
//         mDashboardPeriod = (ListPreference) getPreferenceScreen().findPreference(KEY_SEARCH_PERIOD);
//         setSummaryListPreference(mDashboardPeriod);
//     }
// 
//     @Override
//     protected void onResume() {
//         super.onResume();
//         getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
//     }
// 
//     @Override
//     protected void onPause() {
//         super.onPause();
//         getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
//     }
// 
//     @Override
//     public boolean onOptionsItemSelected(MenuItem item) {
// 
//         switch (item.getItemId()) {
//         case android.R.id.home:
//             finish();
//             break;
//         }
// 
//         return super.onOptionsItemSelected(item);
//     }
// 
//     @Override
//     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
//         if (key.equals(KEY_SEARCH_PERIOD)) {
//             setSummaryListPreference(mDashboardPeriod);
//         }
//     }
// 
//     private void setSummaryListPreference(ListPreference listPreference) {
//         listPreference.setSummary(listPreference.getEntry());
//     }
// }


// Path: app/src/main/java/fr/julienvermet/bugdroid/model/Search.java
import java.io.Serializable;
import java.net.URLEncoder;
import java.util.ArrayList;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import fr.julienvermet.bugdroid.application.BugDroidApplication;
import fr.julienvermet.bugdroid.ui.SettingsActivity;

            keywords = URLEncoder.encode(keywords);
            return String.format(BUGS_QUICK_SEARCH, keywords);
        }
    }

    public static class DashboardSearch extends Search {

        private static final long serialVersionUID = -7918981619210024917L;
        int searchType;

        public DashboardSearch(String name, int requestCode, Instance instance, int searchType) {
            super(requestCode, instance);
            this.searchType = searchType;
        }

        @Override
        protected String buildQuery() {
            String username = account.username;
            switch (searchType) {
            case DASHBOARD_TO_REVIEW:
                return String.format(DASHBOARD_QUERY_TO_REVIEW, username);
            case DASHBOARD_REPORTED:
                return String.format(DASHBOARD_QUERY_REPORTED, username, username);
            case DASHBOARD_ASSIGNED:
                return String.format(DASHBOARD_QUERY_ASSIGNED, username);
            case DASHBOARD_CCD:
                return String.format(DASHBOARD_QUERY_CCD, username, username);
            case DASHBOARD_RECENTLY_FIXED:
                return String.format(DASHBOARD_QUERY_RECENTLY_FIXED, username);
            default:
                return "";