OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 package org.appspot.apprtc; | 11 package org.appspot.apprtc; |
12 | 12 |
13 import android.app.Activity; | 13 import android.app.Activity; |
14 import android.content.SharedPreferences; | 14 import android.content.SharedPreferences; |
15 import android.content.SharedPreferences.OnSharedPreferenceChangeListener; | 15 import android.content.SharedPreferences.OnSharedPreferenceChangeListener; |
16 import android.os.Bundle; | 16 import android.os.Bundle; |
17 import android.preference.ListPreference; | 17 import android.preference.ListPreference; |
18 import android.preference.Preference; | 18 import android.preference.Preference; |
19 | 19 |
20 import org.webrtc.Camera2Enumerator; | 20 import org.webrtc.Camera2Enumerator; |
21 import org.webrtc.voiceengine.WebRtcAudioUtils; | 21 import org.webrtc.voiceengine.WebRtcAudioUtils; |
22 | 22 |
23 /** | 23 /** |
24 * Settings activity for AppRTC. | 24 * Settings activity for AppRTC. |
25 */ | 25 */ |
26 public class SettingsActivity extends Activity | 26 public class SettingsActivity extends Activity implements OnSharedPreferenceChan geListener { |
27 implements OnSharedPreferenceChangeListener{ | |
28 private SettingsFragment settingsFragment; | 27 private SettingsFragment settingsFragment; |
29 private String keyprefVideoCall; | 28 private String keyprefVideoCall; |
30 private String keyprefCamera2; | 29 private String keyprefCamera2; |
31 private String keyprefResolution; | 30 private String keyprefResolution; |
32 private String keyprefFps; | 31 private String keyprefFps; |
33 private String keyprefCaptureQualitySlider; | 32 private String keyprefCaptureQualitySlider; |
34 private String keyprefMaxVideoBitrateType; | 33 private String keyprefMaxVideoBitrateType; |
35 private String keyprefMaxVideoBitrateValue; | 34 private String keyprefMaxVideoBitrateValue; |
36 private String keyPrefVideoCodec; | 35 private String keyPrefVideoCodec; |
37 private String keyprefHwCodec; | 36 private String keyprefHwCodec; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 keyprefDisableBuiltInNS = getString(R.string.pref_disable_built_in_ns_key); | 77 keyprefDisableBuiltInNS = getString(R.string.pref_disable_built_in_ns_key); |
79 keyprefEnableLevelControl = getString(R.string.pref_enable_level_control_key ); | 78 keyprefEnableLevelControl = getString(R.string.pref_enable_level_control_key ); |
80 keyprefSpeakerphone = getString(R.string.pref_speakerphone_key); | 79 keyprefSpeakerphone = getString(R.string.pref_speakerphone_key); |
81 | 80 |
82 keyPrefRoomServerUrl = getString(R.string.pref_room_server_url_key); | 81 keyPrefRoomServerUrl = getString(R.string.pref_room_server_url_key); |
83 keyPrefDisplayHud = getString(R.string.pref_displayhud_key); | 82 keyPrefDisplayHud = getString(R.string.pref_displayhud_key); |
84 keyPrefTracing = getString(R.string.pref_tracing_key); | 83 keyPrefTracing = getString(R.string.pref_tracing_key); |
85 | 84 |
86 // Display the fragment as the main content. | 85 // Display the fragment as the main content. |
87 settingsFragment = new SettingsFragment(); | 86 settingsFragment = new SettingsFragment(); |
88 getFragmentManager().beginTransaction() | 87 getFragmentManager() |
88 .beginTransaction() | |
89 .replace(android.R.id.content, settingsFragment) | 89 .replace(android.R.id.content, settingsFragment) |
90 .commit(); | 90 .commit(); |
91 } | 91 } |
92 | 92 |
93 @Override | 93 @Override |
94 protected void onResume() { | 94 protected void onResume() { |
95 super.onResume(); | 95 super.onResume(); |
96 // Set summary to be the user-description for the selected value | 96 // Set summary to be the user-description for the selected value |
97 SharedPreferences sharedPreferences = | 97 SharedPreferences sharedPreferences = |
98 settingsFragment.getPreferenceScreen().getSharedPreferences(); | 98 settingsFragment.getPreferenceScreen().getSharedPreferences(); |
(...skipping 21 matching lines...) Expand all Loading... | |
120 updateSummaryB(sharedPreferences, keyprefDisableBuiltInAGC); | 120 updateSummaryB(sharedPreferences, keyprefDisableBuiltInAGC); |
121 updateSummaryB(sharedPreferences, keyprefDisableBuiltInNS); | 121 updateSummaryB(sharedPreferences, keyprefDisableBuiltInNS); |
122 updateSummaryB(sharedPreferences, keyprefEnableLevelControl); | 122 updateSummaryB(sharedPreferences, keyprefEnableLevelControl); |
123 updateSummaryList(sharedPreferences, keyprefSpeakerphone); | 123 updateSummaryList(sharedPreferences, keyprefSpeakerphone); |
124 | 124 |
125 updateSummary(sharedPreferences, keyPrefRoomServerUrl); | 125 updateSummary(sharedPreferences, keyPrefRoomServerUrl); |
126 updateSummaryB(sharedPreferences, keyPrefDisplayHud); | 126 updateSummaryB(sharedPreferences, keyPrefDisplayHud); |
127 updateSummaryB(sharedPreferences, keyPrefTracing); | 127 updateSummaryB(sharedPreferences, keyPrefTracing); |
128 | 128 |
129 if (!Camera2Enumerator.isSupported(this)) { | 129 if (!Camera2Enumerator.isSupported(this)) { |
130 Preference camera2Preference = | 130 Preference camera2Preference = settingsFragment.findPreference(keyprefCame ra2); |
131 settingsFragment.findPreference(keyprefCamera2); | |
132 | 131 |
133 camera2Preference.setSummary(getString(R.string.pref_camera2_not_supported )); | 132 camera2Preference.setSummary(getString(R.string.pref_camera2_not_supported )); |
134 camera2Preference.setEnabled(false); | 133 camera2Preference.setEnabled(false); |
135 } | 134 } |
136 | 135 |
137 // Disable forcing WebRTC based AEC so it won't affect our value. | 136 // Disable forcing WebRTC based AEC so it won't affect our value. |
138 // Otherwise, if it was enabled, isAcousticEchoCancelerSupported would alway s return false. | 137 // Otherwise, if it was enabled, isAcousticEchoCancelerSupported would alway s return false. |
139 WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(false); | 138 WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(false); |
140 if (!WebRtcAudioUtils.isAcousticEchoCancelerSupported()) { | 139 if (!WebRtcAudioUtils.isAcousticEchoCancelerSupported()) { |
141 Preference disableBuiltInAECPreference = | 140 Preference disableBuiltInAECPreference = |
(...skipping 24 matching lines...) Expand all Loading... | |
166 | 165 |
167 @Override | 166 @Override |
168 protected void onPause() { | 167 protected void onPause() { |
169 super.onPause(); | 168 super.onPause(); |
170 SharedPreferences sharedPreferences = | 169 SharedPreferences sharedPreferences = |
171 settingsFragment.getPreferenceScreen().getSharedPreferences(); | 170 settingsFragment.getPreferenceScreen().getSharedPreferences(); |
172 sharedPreferences.unregisterOnSharedPreferenceChangeListener(this); | 171 sharedPreferences.unregisterOnSharedPreferenceChangeListener(this); |
173 } | 172 } |
174 | 173 |
175 @Override | 174 @Override |
176 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, | 175 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key) { |
magjed_webrtc
2016/09/28 13:45:05
revert
| |
177 String key) { | 176 if (key.equals(keyprefResolution) || key.equals(keyprefFps) |
178 if (key.equals(keyprefResolution) | 177 || key.equals(keyprefMaxVideoBitrateType) || key.equals(keyPrefVideoCode c) |
179 || key.equals(keyprefFps) | 178 || key.equals(keyprefStartAudioBitrateType) || key.equals(keyPrefAudioCo dec) |
180 || key.equals(keyprefMaxVideoBitrateType) | |
181 || key.equals(keyPrefVideoCodec) | |
182 || key.equals(keyprefStartAudioBitrateType) | |
183 || key.equals(keyPrefAudioCodec) | |
184 || key.equals(keyPrefRoomServerUrl)) { | 179 || key.equals(keyPrefRoomServerUrl)) { |
185 updateSummary(sharedPreferences, key); | 180 updateSummary(sharedPreferences, key); |
186 } else if (key.equals(keyprefMaxVideoBitrateValue) | 181 } else if (key.equals(keyprefMaxVideoBitrateValue) |
187 || key.equals(keyprefStartAudioBitrateValue)) { | 182 || key.equals(keyprefStartAudioBitrateValue)) { |
188 updateSummaryBitrate(sharedPreferences, key); | 183 updateSummaryBitrate(sharedPreferences, key); |
189 } else if (key.equals(keyprefVideoCall) | 184 } else if (key.equals(keyprefVideoCall) || key.equals(keyprefCamera2) |
190 || key.equals(keyprefCamera2) | 185 || key.equals(keyPrefTracing) || key.equals(keyprefCaptureQualitySlider) |
191 || key.equals(keyPrefTracing) | 186 || key.equals(keyprefHwCodec) || key.equals(keyprefCaptureToTexture) |
192 || key.equals(keyprefCaptureQualitySlider) | 187 || key.equals(keyprefNoAudioProcessing) || key.equals(keyprefAecDump) |
193 || key.equals(keyprefHwCodec) | 188 || key.equals(keyprefOpenSLES) || key.equals(keyprefDisableBuiltInAEC) |
194 || key.equals(keyprefCaptureToTexture) | 189 || key.equals(keyprefDisableBuiltInAGC) || key.equals(keyprefDisableBuil tInNS) |
195 || key.equals(keyprefNoAudioProcessing) | 190 || key.equals(keyprefEnableLevelControl) || key.equals(keyPrefDisplayHud )) { |
196 || key.equals(keyprefAecDump) | |
197 || key.equals(keyprefOpenSLES) | |
198 || key.equals(keyprefDisableBuiltInAEC) | |
199 || key.equals(keyprefDisableBuiltInAGC) | |
200 || key.equals(keyprefDisableBuiltInNS) | |
201 || key.equals(keyprefEnableLevelControl) | |
202 || key.equals(keyPrefDisplayHud)) { | |
203 updateSummaryB(sharedPreferences, key); | 191 updateSummaryB(sharedPreferences, key); |
204 } else if (key.equals(keyprefSpeakerphone)) { | 192 } else if (key.equals(keyprefSpeakerphone)) { |
205 updateSummaryList(sharedPreferences, key); | 193 updateSummaryList(sharedPreferences, key); |
206 } | 194 } |
207 if (key.equals(keyprefMaxVideoBitrateType)) { | 195 if (key.equals(keyprefMaxVideoBitrateType)) { |
208 setVideoBitrateEnable(sharedPreferences); | 196 setVideoBitrateEnable(sharedPreferences); |
209 } | 197 } |
210 if (key.equals(keyprefStartAudioBitrateType)) { | 198 if (key.equals(keyprefStartAudioBitrateType)) { |
211 setAudioBitrateEnable(sharedPreferences); | 199 setAudioBitrateEnable(sharedPreferences); |
212 } | 200 } |
213 } | 201 } |
214 | 202 |
215 private void updateSummary(SharedPreferences sharedPreferences, String key) { | 203 private void updateSummary(SharedPreferences sharedPreferences, String key) { |
216 Preference updatedPref = settingsFragment.findPreference(key); | 204 Preference updatedPref = settingsFragment.findPreference(key); |
217 // Set summary to be the user-description for the selected value | 205 // Set summary to be the user-description for the selected value |
218 updatedPref.setSummary(sharedPreferences.getString(key, "")); | 206 updatedPref.setSummary(sharedPreferences.getString(key, "")); |
219 } | 207 } |
220 | 208 |
221 private void updateSummaryBitrate( | 209 private void updateSummaryBitrate(SharedPreferences sharedPreferences, String key) { |
222 SharedPreferences sharedPreferences, String key) { | |
223 Preference updatedPref = settingsFragment.findPreference(key); | 210 Preference updatedPref = settingsFragment.findPreference(key); |
224 updatedPref.setSummary(sharedPreferences.getString(key, "") + " kbps"); | 211 updatedPref.setSummary(sharedPreferences.getString(key, "") + " kbps"); |
225 } | 212 } |
226 | 213 |
227 private void updateSummaryB(SharedPreferences sharedPreferences, String key) { | 214 private void updateSummaryB(SharedPreferences sharedPreferences, String key) { |
228 Preference updatedPref = settingsFragment.findPreference(key); | 215 Preference updatedPref = settingsFragment.findPreference(key); |
229 updatedPref.setSummary(sharedPreferences.getBoolean(key, true) | 216 updatedPref.setSummary(sharedPreferences.getBoolean(key, true) |
230 ? getString(R.string.pref_value_enabled) | 217 ? getString(R.string.pref_value_enabled) |
231 : getString(R.string.pref_value_disabled)); | 218 : getString(R.string.pref_value_disabled)); |
232 } | 219 } |
233 | 220 |
234 private void updateSummaryList(SharedPreferences sharedPreferences, String key ) { | 221 private void updateSummaryList(SharedPreferences sharedPreferences, String key ) { |
235 ListPreference updatedPref = (ListPreference) settingsFragment.findPreferenc e(key); | 222 ListPreference updatedPref = (ListPreference) settingsFragment.findPreferenc e(key); |
236 updatedPref.setSummary(updatedPref.getEntry()); | 223 updatedPref.setSummary(updatedPref.getEntry()); |
237 } | 224 } |
238 | 225 |
239 private void setVideoBitrateEnable(SharedPreferences sharedPreferences) { | 226 private void setVideoBitrateEnable(SharedPreferences sharedPreferences) { |
240 Preference bitratePreferenceValue = | 227 Preference bitratePreferenceValue = |
241 settingsFragment.findPreference(keyprefMaxVideoBitrateValue); | 228 settingsFragment.findPreference(keyprefMaxVideoBitrateValue); |
242 String bitrateTypeDefault = getString(R.string.pref_maxvideobitrate_default) ; | 229 String bitrateTypeDefault = getString(R.string.pref_maxvideobitrate_default) ; |
243 String bitrateType = sharedPreferences.getString( | 230 String bitrateType = |
244 keyprefMaxVideoBitrateType, bitrateTypeDefault); | 231 sharedPreferences.getString(keyprefMaxVideoBitrateType, bitrateTypeDefau lt); |
245 if (bitrateType.equals(bitrateTypeDefault)) { | 232 if (bitrateType.equals(bitrateTypeDefault)) { |
246 bitratePreferenceValue.setEnabled(false); | 233 bitratePreferenceValue.setEnabled(false); |
247 } else { | 234 } else { |
248 bitratePreferenceValue.setEnabled(true); | 235 bitratePreferenceValue.setEnabled(true); |
249 } | 236 } |
250 } | 237 } |
251 | 238 |
252 private void setAudioBitrateEnable(SharedPreferences sharedPreferences) { | 239 private void setAudioBitrateEnable(SharedPreferences sharedPreferences) { |
253 Preference bitratePreferenceValue = | 240 Preference bitratePreferenceValue = |
254 settingsFragment.findPreference(keyprefStartAudioBitrateValue); | 241 settingsFragment.findPreference(keyprefStartAudioBitrateValue); |
255 String bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_defaul t); | 242 String bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_defaul t); |
256 String bitrateType = sharedPreferences.getString( | 243 String bitrateType = |
257 keyprefStartAudioBitrateType, bitrateTypeDefault); | 244 sharedPreferences.getString(keyprefStartAudioBitrateType, bitrateTypeDef ault); |
258 if (bitrateType.equals(bitrateTypeDefault)) { | 245 if (bitrateType.equals(bitrateTypeDefault)) { |
259 bitratePreferenceValue.setEnabled(false); | 246 bitratePreferenceValue.setEnabled(false); |
260 } else { | 247 } else { |
261 bitratePreferenceValue.setEnabled(true); | 248 bitratePreferenceValue.setEnabled(true); |
262 } | 249 } |
263 } | 250 } |
264 } | 251 } |
OLD | NEW |