1 /*
2  * Copyright (C) 2023 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.settings.dashboard.profileselector;
18 
19 import android.hardware.input.InputDeviceIdentifier;
20 import android.os.Bundle;
21 import android.provider.Settings;
22 
23 import androidx.fragment.app.Fragment;
24 
25 import com.android.settings.R;
26 import com.android.settings.inputmethod.NewKeyboardLayoutEnabledLocalesFragment;
27 
28 /**
29  * When current user has work profile, this fragment used following fragments to represent the
30  * enabled IMEs keyboard layout settings page.
31  *
32  * <p>{@link NewKeyboardLayoutEnabledLocalesFragment} used to show both of personal/work user
33  * enabled IMEs and their physical keyboard layouts.</p>
34  */
35 public final class ProfileSelectPhysicalKeyboardFragment extends ProfileSelectFragment {
36 
37     private InputDeviceIdentifier mInputDeviceIdentifier;
38 
39     @Override
onCreate(Bundle icicle)40     public void onCreate(Bundle icicle) {
41         super.onCreate(icicle);
42         Bundle arguments = getArguments();
43         mInputDeviceIdentifier =
44                 arguments.getParcelable(Settings.EXTRA_INPUT_DEVICE_IDENTIFIER);
45     }
46 
47     @Override
getPreferenceScreenResId()48     protected int getPreferenceScreenResId() {
49         return R.xml.keyboard_settings_enabled_locales_list;
50     }
51 
52     @Override
getFragments()53     public Fragment[] getFragments() {
54         Bundle bundle = new Bundle();
55         bundle.putParcelable(Settings.EXTRA_INPUT_DEVICE_IDENTIFIER, mInputDeviceIdentifier);
56         return ProfileSelectFragment.getFragments(
57                 getContext(),
58                 bundle,
59                 NewKeyboardLayoutEnabledLocalesFragment::new,
60                 NewKeyboardLayoutEnabledLocalesFragment::new,
61                 NewKeyboardLayoutEnabledLocalesFragment::new);
62     }
63 }
64