/// <summary> /// Creates the text encoding preference. /// </summary> private void CreateTextEncodingPreference() { // clear information about text encodings _encodingEntries.Clear(); _encodingEntryValues.Clear(); // get the preference for text encoding list _textEncodingListPreference = FindPreference("list_encodings") as Android.Support.V7.Preferences.ListPreference; // if text encoding list preference is found if (_textEncodingListPreference != null) { // add "Default" value to the text encoding _encodingEntries.AddRange(_textEncodingListPreference.GetEntries()); _encodingEntryValues.AddRange(_textEncodingListPreference.GetEntryValues()); // for each available encoding foreach (KeyValuePair <string, EncodingInfo> encoding in Utils.AvailableEncodings) { // add encoding name to the encoding list _encodingEntries.Add(string.Format("{0}: {1}", encoding.Value.CodePage, encoding.Value.Name)); _encodingEntryValues.Add(encoding.Key); } // add information about available text encodings to the list preference with text encodings _textEncodingListPreference.SetEntries(_encodingEntries.ToArray()); _textEncodingListPreference.SetEntryValues(_encodingEntryValues.ToArray()); } }
/// <summary> /// Refreshes the preference fragment view. /// </summary> private void RefreshUI() { base.PreferenceScreen.RemoveAll(); AddPreferencesFromResource(Resource.Xml.settings_page); // get the preference for camera preview sizes list _cameraPreviewSizesListPreference = FindPreference("list_camera_preview_sizes") as Android.Support.V7.Preferences.ListPreference; // if camera preview size list preference is found if (_cameraPreviewSizesListPreference != null) { // add the camera preview sizes to the list preference with camera preview sizes _cameraPreviewSizesListPreference.SetEntries(_sizeEntries.ToArray()); _cameraPreviewSizesListPreference.SetEntryValues(_sizeEntryValues.ToArray()); // set the "Auto" value as the default value _cameraPreviewSizesListPreference.SetValueIndex(0); } // get the preference for text encoding list _textEncodingListPreference = FindPreference("list_encodings") as Android.Support.V7.Preferences.ListPreference; // if text encoding list preference is found if (_textEncodingListPreference != null) { // add the encoding to the list preference with text encodings _textEncodingListPreference.SetEntries(_encodingEntries.ToArray()); _textEncodingListPreference.SetEntryValues(_encodingEntryValues.ToArray()); // set the "Default" value as the default value _textEncodingListPreference.SetValueIndex(0); } }
/// <summary> /// Creates the camera preview size preference. /// </summary> private void CreateCameraPreviewSizePreference() { // clear information about camera preview sizes _sizeEntries.Clear(); _sizeEntryValues.Clear(); // get the preference for camera preview sizes list _cameraPreviewSizesListPreference = FindPreference("list_camera_preview_sizes") as Android.Support.V7.Preferences.ListPreference; // if camera preview size list preference is found if (_cameraPreviewSizesListPreference != null) { // add "Auto" value to the camera preview sizes _sizeEntries.AddRange(_cameraPreviewSizesListPreference.GetEntries()); _sizeEntryValues.AddRange(_cameraPreviewSizesListPreference.GetEntryValues()); // if camera controller is not emtpy and camera preview size list is not empty if (CameraController != null && CameraController.CameraPreviewSizes != null) { int sizeIndex = 0; // for each camera preview size foreach (Camera.Size size in CameraController.CameraPreviewSizes) { // add camera preview size to the camera preview sizes _sizeEntries.Add(string.Format("{0}x{1}", size.Width, size.Height)); _sizeEntryValues.Add(sizeIndex.ToString()); sizeIndex++; } } // add the camera preview sizes to the list preference with camera preview sizes _cameraPreviewSizesListPreference.SetEntries(_sizeEntries.ToArray()); _cameraPreviewSizesListPreference.SetEntryValues(_sizeEntryValues.ToArray()); // if camera preview size is not selected if (CameraController.СameraPreviewSize == null) { // set the "Auto" value as the default value _cameraPreviewSizesListPreference.SetValueIndex(0); } } }