1 /*
2  * Copyright (C) 2024 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.localepicker;
18 
19 import android.app.GrammaticalInflectionManager;
20 import android.content.Context;
21 
22 import androidx.annotation.NonNull;
23 
24 /**
25  * A helper used to get, set, and cache system grammatical gender.
26  */
27 public class TermsOfAddressHelper {
28 
29     private int mSystemGrammaticalGender;
30     private GrammaticalInflectionManager mGrammaticalInflectionManager;
31 
TermsOfAddressHelper(@onNull Context context)32     public TermsOfAddressHelper(@NonNull Context context) {
33         mGrammaticalInflectionManager = context.getSystemService(
34                 GrammaticalInflectionManager.class);
35         mSystemGrammaticalGender = mGrammaticalInflectionManager.getSystemGrammaticalGender();
36     }
37 
38     /**
39      * set system grammatical gender
40      *
41      * @param gender system grammatical gender
42      */
setSystemGrammaticalGender(int gender)43     public void setSystemGrammaticalGender(int gender) {
44         mGrammaticalInflectionManager.setSystemWideGrammaticalGender(gender);
45         mSystemGrammaticalGender = gender;
46     }
47 
48     /**
49      * get system grammatical gender
50      */
getSystemGrammaticalGender()51     public int getSystemGrammaticalGender() {
52         return mSystemGrammaticalGender;
53     }
54 }
55