diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index f26e8f51446ea23f5d9d6fc635560a04fbfb1d50..5ab7febda7d7f69d8b3ae49a5dc6d051efae3931 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -312,6 +312,8 @@ Use staging OTA server Change to OTA/Production server + You are about to connect to /e/OS test channel + It will allow you to download and install test versions of /e/OS. Those builds may be unstable, and should be used only for test purposes. Please accept only if you know what you are doing. Development tools diff --git a/src/com/android/settings/development/ChangeSourcePreferenceController.java b/src/com/android/settings/development/ChangeSourcePreferenceController.java index 7aa070378b70d63fa548b829e0094eb6ee507ec7..7c4ae9170c593c071cef13d5685a412da69bb1d3 100644 --- a/src/com/android/settings/development/ChangeSourcePreferenceController.java +++ b/src/com/android/settings/development/ChangeSourcePreferenceController.java @@ -16,6 +16,7 @@ package com.android.settings.development; +import android.app.AlertDialog; import android.content.Context; import android.provider.Settings; import android.support.annotation.VisibleForTesting; @@ -24,13 +25,19 @@ import android.support.v7.preference.Preference; import android.preference.PreferenceManager; import android.content.SharedPreferences; import android.content.ContentValues; +import android.content.ContentValues; +import android.content.Context; +import android.content.DialogInterface; + import android.database.Cursor; import android.net.Uri; import android.content.Context; import com.android.settings.core.PreferenceControllerMixin; +import com.android.settings.R; import com.android.settingslib.development.DeveloperOptionsPreferenceController; + public class ChangeSourcePreferenceController extends DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin { @@ -53,10 +60,7 @@ public class ChangeSourcePreferenceController extends DeveloperOptionsPreference return CHANGE_URL_KEY; } - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - final boolean isEnabled = (Boolean) newValue; - ((SwitchPreference) mPreference).setChecked(isEnabled); + public void updateOtaServer(){ if (count(OTAProvider.CONTENT_URI)) { ContentValues values = new ContentValues(); @@ -72,7 +76,32 @@ public class ChangeSourcePreferenceController extends DeveloperOptionsPreference values.put(OTAProvider.Status,"true"); mContext.getContentResolver().insert(OTAProvider.CONTENT_URI, values); } - return true; + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + final boolean isEnabled = (Boolean) newValue; + ((SwitchPreference) mPreference).setChecked(isEnabled); + if(retrieveStatus().equals("true")){ + updateOtaServer(); + return true; + } + new AlertDialog.Builder(mContext). + setTitle(R.string.use_ota_staging_popup_title) + .setMessage(mContext.getResources().getString(R.string.use_ota_staging_popup_message)) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int which) { + ((SwitchPreference) mPreference).setChecked(true); + updateOtaServer(); + } + }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int which) { + ((SwitchPreference) mPreference).setChecked(false); + } + }).show(); + return false; } @Override