• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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.tv.settings.accounts;
18 
19 import android.accounts.Account;
20 import android.accounts.AccountManager;
21 import android.os.Bundle;
22 import android.text.TextUtils;
23 
24 import androidx.fragment.app.Fragment;
25 
26 import com.android.tv.settings.TvSettingsActivity;
27 import com.android.tv.settings.overlay.FlavorUtils;
28 
29 /**
30  * Displays the sync settings for a given account.
31  */
32 public class AccountSyncActivity extends TvSettingsActivity {
33 
34     private static final String ARG_ACCOUNT = "account";
35     public static final String EXTRA_ACCOUNT = "account_name";
36 
37     @Override
createSettingsFragment()38     protected Fragment createSettingsFragment() {
39         String accountName = getIntent().getStringExtra(EXTRA_ACCOUNT);
40         Account account = null;
41         if (!TextUtils.isEmpty(accountName)) {
42             // Search for the account.
43             for (Account candidateAccount : AccountManager.get(this).getAccounts()) {
44                 if (candidateAccount.name.equals(accountName)) {
45                     account = candidateAccount;
46                     break;
47                 }
48             }
49         }
50         return FlavorUtils.getFeatureFactory(this).getSettingsFragmentProvider()
51             .newSettingsFragment(AccountSyncFragment.class.getName(), getArguments(account));
52     }
53 
getArguments(Account account)54     private Bundle getArguments(Account account) {
55         final Bundle b = new Bundle(1);
56         b.putParcelable(ARG_ACCOUNT, account);
57         return b;
58     }
59 }
60