1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.car.settings.common; 18 19 import android.annotation.Nullable; 20 import android.content.Intent; 21 import android.net.Uri; 22 import android.os.Bundle; 23 import android.os.UserHandle; 24 import android.provider.Settings; 25 import android.text.TextUtils; 26 27 import androidx.fragment.app.Fragment; 28 29 import com.android.car.settings.R; 30 import com.android.car.settings.accessibility.AccessibilitySettingsFragment; 31 import com.android.car.settings.accessibility.CaptionsSettingsFragment; 32 import com.android.car.settings.accounts.ChooseAccountFragment; 33 import com.android.car.settings.applications.ApplicationDetailsFragment; 34 import com.android.car.settings.applications.ApplicationsSettingsFragment; 35 import com.android.car.settings.applications.AppsFragment; 36 import com.android.car.settings.applications.assist.AssistantAndVoiceFragment; 37 import com.android.car.settings.applications.defaultapps.DefaultAutofillPickerFragment; 38 import com.android.car.settings.applications.specialaccess.AlarmsAndReminderFragment; 39 import com.android.car.settings.applications.specialaccess.ModifySystemSettingsFragment; 40 import com.android.car.settings.applications.specialaccess.NotificationAccessFragment; 41 import com.android.car.settings.applications.specialaccess.PremiumSmsAccessFragment; 42 import com.android.car.settings.applications.specialaccess.SpecialAccessSettingsFragment; 43 import com.android.car.settings.applications.specialaccess.UsageAccessFragment; 44 import com.android.car.settings.applications.specialaccess.WifiControlFragment; 45 import com.android.car.settings.bluetooth.BluetoothSettingsFragment; 46 import com.android.car.settings.datetime.DatetimeSettingsFragment; 47 import com.android.car.settings.display.DisplaySettingsFragment; 48 import com.android.car.settings.inputmethod.KeyboardFragment; 49 import com.android.car.settings.language.LanguagePickerFragment; 50 import com.android.car.settings.language.LanguagesAndInputFragment; 51 import com.android.car.settings.location.LocationSettingsFragment; 52 import com.android.car.settings.network.MobileNetworkFragment; 53 import com.android.car.settings.network.MobileNetworkListFragment; 54 import com.android.car.settings.network.NetworkAndInternetFragment; 55 import com.android.car.settings.notifications.NotificationsFragment; 56 import com.android.car.settings.privacy.PrivacySettingsFragment; 57 import com.android.car.settings.privacy.VehicleDataFragment; 58 import com.android.car.settings.profiles.ProfileDetailsFragment; 59 import com.android.car.settings.security.SecuritySettingsFragment; 60 import com.android.car.settings.sound.RingtonePickerFragment; 61 import com.android.car.settings.sound.SoundSettingsFragment; 62 import com.android.car.settings.storage.StorageSettingsFragment; 63 import com.android.car.settings.system.AboutSettingsFragment; 64 import com.android.car.settings.system.LegalInformationFragment; 65 import com.android.car.settings.system.ResetOptionsFragment; 66 import com.android.car.settings.system.SystemSettingsFragment; 67 import com.android.car.settings.tts.TextToSpeechOutputFragment; 68 import com.android.car.settings.units.UnitsSettingsFragment; 69 import com.android.car.settings.wifi.AddWifiFragment; 70 import com.android.car.settings.wifi.WifiSettingsFragment; 71 import com.android.car.settings.wifi.WifiTetherFragment; 72 import com.android.car.settings.wifi.preferences.WifiPreferencesFragment; 73 74 /** 75 * Top level settings class, containing static instances of CarSettings activities. 76 */ 77 public class CarSettingActivities { 78 79 private static final Logger LOG = new Logger(CarSettingActivities.class); 80 81 /** 82 * Homepage Activity. 83 */ 84 public static class HomepageActivity extends BaseCarSettingsActivity { 85 @Nullable 86 @Override getInitialFragment()87 protected Fragment getInitialFragment() { 88 try { 89 return getSupportFragmentManager().getFragmentFactory().instantiate( 90 getClassLoader(), getString(R.string.config_homepage_fragment_class)); 91 } catch (Fragment.InstantiationException e) { 92 LOG.e("Unable to instantiate homepage fragment", e); 93 return null; 94 } 95 } 96 97 @Override shouldFocusContentOnLaunch()98 protected boolean shouldFocusContentOnLaunch() { 99 // Focus should stay with the top-level menu for the HomepageActivity. 100 return false; 101 } 102 } 103 104 // Homepage sub-sections 105 106 /** 107 * Display Settings Activity. 108 */ 109 public static class DisplaySettingsActivity extends BaseCarSettingsActivity { 110 @Nullable 111 @Override getInitialFragment()112 protected Fragment getInitialFragment() { 113 return new DisplaySettingsFragment(); 114 } 115 } 116 117 /** 118 * Sound Settings Activity. 119 */ 120 public static class SoundSettingsActivity extends BaseCarSettingsActivity { 121 @Nullable 122 @Override getInitialFragment()123 protected Fragment getInitialFragment() { 124 return new SoundSettingsFragment(); 125 } 126 } 127 128 /** 129 * Ringtone Picker Activity. 130 */ 131 public static class RingtonePickerActivity extends BaseCarSettingsActivity { 132 @Nullable 133 @Override getInitialFragment()134 protected Fragment getInitialFragment() { 135 Bundle args = getIntent().getExtras().deepCopy(); 136 Fragment fragment = new RingtonePickerFragment(); 137 fragment.setArguments(args); 138 return fragment; 139 } 140 } 141 142 /** 143 * Network and Internet Activity. 144 */ 145 public static class NetworkAndInternetActivity extends BaseCarSettingsActivity { 146 @Nullable 147 @Override getInitialFragment()148 protected Fragment getInitialFragment() { 149 return new NetworkAndInternetFragment(); 150 } 151 } 152 153 /** 154 * Bluetooth Settings Activity. 155 */ 156 public static class BluetoothSettingsActivity extends BaseCarSettingsActivity { 157 @Nullable 158 @Override getInitialFragment()159 protected Fragment getInitialFragment() { 160 return new BluetoothSettingsFragment(); 161 } 162 } 163 164 /** 165 * Units Settings Activity. 166 */ 167 public static class UnitsSettingsActivity extends BaseCarSettingsActivity { 168 @Nullable 169 @Override getInitialFragment()170 protected Fragment getInitialFragment() { 171 return new UnitsSettingsFragment(); 172 } 173 } 174 175 /** 176 * Location Settings Activity. 177 */ 178 public static class LocationSettingsActivity extends BaseCarSettingsActivity { 179 @Nullable 180 @Override getInitialFragment()181 protected Fragment getInitialFragment() { 182 return new LocationSettingsFragment(); 183 } 184 } 185 186 /** 187 * Apps Activity. 188 */ 189 public static class AppsActivity extends BaseCarSettingsActivity { 190 @Nullable 191 @Override getInitialFragment()192 protected Fragment getInitialFragment() { 193 return new AppsFragment(); 194 } 195 } 196 197 /** 198 * Notifications Activity. 199 */ 200 public static class NotificationsActivity extends BaseCarSettingsActivity { 201 @Nullable 202 @Override getInitialFragment()203 protected Fragment getInitialFragment() { 204 return new NotificationsFragment(); 205 } 206 } 207 208 /** 209 * Datetime Settings Activity. 210 */ 211 public static class DatetimeSettingsActivity extends BaseCarSettingsActivity { 212 @Nullable 213 @Override getInitialFragment()214 protected Fragment getInitialFragment() { 215 return new DatetimeSettingsFragment(); 216 } 217 } 218 219 /** 220 * Profile Details Activity. 221 */ 222 public static class ProfileDetailsActivity extends BaseCarSettingsActivity { 223 @Nullable 224 @Override getInitialFragment()225 protected Fragment getInitialFragment() { 226 return ProfileDetailsFragment.newInstance(UserHandle.myUserId()); 227 } 228 } 229 230 /** 231 * Privacy Settings Activity. 232 */ 233 public static class PrivacySettingsActivity extends BaseCarSettingsActivity { 234 @Nullable 235 @Override getInitialFragment()236 protected Fragment getInitialFragment() { 237 return new PrivacySettingsFragment(); 238 } 239 } 240 241 /** 242 * Vehicle Data Activity. 243 */ 244 public static class VehicleDataActivity extends BaseCarSettingsActivity { 245 @Nullable 246 @Override getInitialFragment()247 protected Fragment getInitialFragment() { 248 return new VehicleDataFragment(); 249 } 250 } 251 252 /** 253 * Storage Settings Activity. 254 */ 255 public static class StorageSettingsActivity extends BaseCarSettingsActivity { 256 @Nullable 257 @Override getInitialFragment()258 protected Fragment getInitialFragment() { 259 return new StorageSettingsFragment(); 260 } 261 } 262 263 /** 264 * Security Settings Activity. 265 */ 266 public static class SecuritySettingsActivity extends BaseCarSettingsActivity { 267 @Nullable 268 @Override getInitialFragment()269 protected Fragment getInitialFragment() { 270 return new SecuritySettingsFragment(); 271 } 272 } 273 274 /** 275 * Assistant & voice Settings Activity. 276 */ 277 public static class AssistantAndVoiceSettingsActivity extends BaseCarSettingsActivity { 278 @Nullable 279 @Override getInitialFragment()280 protected Fragment getInitialFragment() { 281 return new AssistantAndVoiceFragment(); 282 } 283 } 284 285 /** 286 * System Settings Activity. 287 */ 288 public static class SystemSettingsActivity extends BaseCarSettingsActivity { 289 @Nullable 290 @Override getInitialFragment()291 protected Fragment getInitialFragment() { 292 return new SystemSettingsFragment(); 293 } 294 } 295 296 // Network & internet sub-sections 297 298 /** 299 * Wifi Settings Activity. 300 */ 301 public static class WifiSettingsActivity extends BaseCarSettingsActivity { 302 @Nullable 303 @Override getInitialFragment()304 protected Fragment getInitialFragment() { 305 return new WifiSettingsFragment(); 306 } 307 } 308 309 /** 310 * Wifi Hotspot and Tethering Activity. 311 */ 312 public static class WifiTetherActivity extends BaseCarSettingsActivity { 313 @Nullable 314 @Override getInitialFragment()315 protected Fragment getInitialFragment() { 316 return new WifiTetherFragment(); 317 } 318 } 319 320 /** 321 * Mobile Network Activity. 322 */ 323 public static class MobileNetworkActivity extends BaseCarSettingsActivity { 324 @Nullable 325 @Override getInitialFragment()326 protected Fragment getInitialFragment() { 327 return MobileNetworkFragment.newInstance( 328 getIntent().getIntExtra("network_sub_id", Integer.MIN_VALUE)); 329 } 330 } 331 332 /** 333 * Mobile Network List Activity. 334 */ 335 public static class MobileNetworkListActivity extends BaseCarSettingsActivity { 336 @Nullable 337 @Override getInitialFragment()338 protected Fragment getInitialFragment() { 339 return new MobileNetworkListFragment(); 340 } 341 } 342 343 // Apps & Notifications sub-sections 344 345 /** 346 * Application Settings Activity. 347 */ 348 public static class ApplicationsSettingsActivity extends BaseCarSettingsActivity { 349 @Nullable 350 @Override getInitialFragment()351 protected Fragment getInitialFragment() { 352 return new ApplicationsSettingsFragment(); 353 } 354 } 355 356 /** 357 * Application Special Access Settings Activity. 358 */ 359 public static class SpecialAccessSettingsActivity extends BaseCarSettingsActivity { 360 @Nullable 361 @Override getInitialFragment()362 protected Fragment getInitialFragment() { 363 return new SpecialAccessSettingsFragment(); 364 } 365 } 366 367 // System sub-sections 368 369 /** 370 * Languages and Input Activity. 371 */ 372 public static class LanguagesAndInputActivity extends BaseCarSettingsActivity { 373 @Nullable 374 @Override getInitialFragment()375 protected Fragment getInitialFragment() { 376 return new LanguagesAndInputFragment(); 377 } 378 } 379 380 /** 381 * About Settings Activity. 382 */ 383 public static class AboutSettingsActivity extends BaseCarSettingsActivity { 384 @Nullable 385 @Override getInitialFragment()386 protected Fragment getInitialFragment() { 387 return new AboutSettingsFragment(); 388 } 389 } 390 391 /** 392 * Legal Information Activity. 393 */ 394 public static class LegalInformationActivity extends BaseCarSettingsActivity { 395 @Nullable 396 @Override getInitialFragment()397 protected Fragment getInitialFragment() { 398 return new LegalInformationFragment(); 399 } 400 } 401 402 /** 403 * Reset Options Activity. 404 */ 405 public static class ResetOptionsActivity extends BaseCarSettingsActivity { 406 @Nullable 407 @Override getInitialFragment()408 protected Fragment getInitialFragment() { 409 return new ResetOptionsFragment(); 410 } 411 } 412 413 // Wi-fi sub-sections 414 415 /** 416 * Add Wifi Network Activity. 417 */ 418 public static class AddWifiActivity extends BaseCarSettingsActivity { 419 @Nullable 420 @Override getInitialFragment()421 protected Fragment getInitialFragment() { 422 return new AddWifiFragment(); 423 } 424 } 425 426 /** 427 * Wifi Preferences Activity. 428 */ 429 public static class WifiPreferencesActivity extends BaseCarSettingsActivity { 430 @Nullable 431 @Override getInitialFragment()432 protected Fragment getInitialFragment() { 433 return new WifiPreferencesFragment(); 434 } 435 } 436 437 // App Info sub-sections 438 439 /** 440 * Application Details Activity. 441 * Intent required to include package string as Settings.EXTRA_APP_PACKAGE extra. 442 */ 443 public static class ApplicationsDetailsActivity extends BaseCarSettingsActivity { 444 @Nullable 445 @Override getInitialFragment()446 protected Fragment getInitialFragment() { 447 Intent intent = getIntent(); 448 String pkg = intent.getStringExtra(Settings.EXTRA_APP_PACKAGE); 449 if (TextUtils.isEmpty(pkg)) { 450 LOG.w("No package provided for application detailed intent"); 451 Uri uri = intent.getData(); 452 if (uri == null) { 453 LOG.w("No uri provided for application detailed intent"); 454 return null; 455 } 456 pkg = uri.getSchemeSpecificPart(); 457 } 458 return ApplicationDetailsFragment.getInstance(pkg); 459 } 460 } 461 462 // Special app access sub-section 463 464 /** 465 * App Modify System Settings Access Activity. 466 */ 467 public static class ModifySystemSettingsActivity extends BaseCarSettingsActivity { 468 @Nullable 469 @Override getInitialFragment()470 protected Fragment getInitialFragment() { 471 return new ModifySystemSettingsFragment(); 472 } 473 } 474 475 /** 476 * App Notification Access Activity. 477 */ 478 public static class NotificationAccessActivity extends BaseCarSettingsActivity { 479 @Nullable 480 @Override getInitialFragment()481 protected Fragment getInitialFragment() { 482 return new NotificationAccessFragment(); 483 } 484 } 485 486 /** 487 * App Premium SMS Access Activity. 488 */ 489 public static class PremiumSmsAccessActivity extends BaseCarSettingsActivity { 490 @Nullable 491 @Override getInitialFragment()492 protected Fragment getInitialFragment() { 493 return new PremiumSmsAccessFragment(); 494 } 495 } 496 497 /** 498 * App Usage Access Activity. 499 */ 500 public static class UsageAccessActivity extends BaseCarSettingsActivity { 501 @Nullable 502 @Override getInitialFragment()503 protected Fragment getInitialFragment() { 504 return new UsageAccessFragment(); 505 } 506 } 507 508 /** 509 * App Wifi Control Access Activity. 510 */ 511 public static class WifiControlActivity extends BaseCarSettingsActivity { 512 @Nullable 513 @Override getInitialFragment()514 protected Fragment getInitialFragment() { 515 return new WifiControlFragment(); 516 } 517 } 518 519 // Account sub-section 520 521 /** 522 * Choose Account Activity. 523 */ 524 public static class ChooseAccountActivity extends BaseCarSettingsActivity { 525 @Nullable 526 @Override getInitialFragment()527 protected Fragment getInitialFragment() { 528 return new ChooseAccountFragment(); 529 } 530 } 531 532 // Languages & input sub-section 533 534 /** 535 * Language Picker Activity. 536 */ 537 public static class LanguagePickerActivity extends BaseCarSettingsActivity { 538 @Nullable 539 @Override getInitialFragment()540 protected Fragment getInitialFragment() { 541 return new LanguagePickerFragment(); 542 } 543 } 544 545 /** 546 * Default Autofill Picker Activity. 547 */ 548 public static class DefaultAutofillPickerActivity extends BaseCarSettingsActivity { 549 @Nullable 550 @Override getInitialFragment()551 protected Fragment getInitialFragment() { 552 return new DefaultAutofillPickerFragment(); 553 } 554 } 555 556 /** 557 * Keyboard Activity. 558 */ 559 public static class KeyboardActivity extends BaseCarSettingsActivity { 560 @Nullable 561 @Override getInitialFragment()562 protected Fragment getInitialFragment() { 563 return new KeyboardFragment(); 564 } 565 } 566 567 /** 568 * Text to Speech Output Activity. 569 */ 570 public static class TextToSpeechOutputActivity extends BaseCarSettingsActivity { 571 @Nullable 572 @Override getInitialFragment()573 protected Fragment getInitialFragment() { 574 return new TextToSpeechOutputFragment(); 575 } 576 } 577 578 /** 579 * Accessibility Activity. 580 */ 581 public static class AccessibilityActivity extends BaseCarSettingsActivity { 582 @Nullable 583 @Override getInitialFragment()584 protected Fragment getInitialFragment() { 585 return new AccessibilitySettingsFragment(); 586 } 587 } 588 589 /** 590 * Captions Activity. 591 */ 592 public static class CaptionsActivity extends BaseCarSettingsActivity { 593 @Nullable 594 @Override getInitialFragment()595 protected Fragment getInitialFragment() { 596 return new CaptionsSettingsFragment(); 597 } 598 } 599 600 /** 601 * Alarms and reminders settings activity. 602 */ 603 public static class AlarmsAndRemindersActivity extends BaseCarSettingsActivity { 604 @Nullable 605 @Override getInitialFragment()606 protected Fragment getInitialFragment() { 607 return new AlarmsAndReminderFragment(); 608 } 609 } 610 } 611