16caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott/*
26caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * Copyright (C) 2016 The Android Open Source Project
36caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott *
46caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * Licensed under the Apache License, Version 2.0 (the "License");
56caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * you may not use this file except in compliance with the License.
66caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * You may obtain a copy of the License at
76caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott *
86caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott *      http://www.apache.org/licenses/LICENSE-2.0
96caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott *
106caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * Unless required by applicable law or agreed to in writing, software
116caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * distributed under the License is distributed on an "AS IS" BASIS,
126caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * See the License for the specific language governing permissions and
146caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott * limitations under the License.
156caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott */
1669c182afb0e6d82a341a28b4317aa703af768906Gary Maipackage com.android.contacts.model.account;
176caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott
18fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerottimport android.content.Context;
19fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott
20fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerottpublic class DeviceLocalAccountType extends FallbackAccountType {
21fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott
22fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott    private final boolean mGroupsEditable;
23fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott
24fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott    public DeviceLocalAccountType(Context context, boolean groupsEditable) {
25fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott        super(context);
26fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott        mGroupsEditable = groupsEditable;
27fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott    }
28fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott
29fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott    public DeviceLocalAccountType(Context context) {
30fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott        this(context, false);
31fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott    }
326caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott
33fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott    @Override
34fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott    public boolean isGroupMembershipEditable() {
35fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott        return mGroupsEditable;
36fac695a36b227f5591eac064ded8e8dad3398400Marcus Hagerott    }
3775895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott
3875895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott    @Override
3975895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott    public AccountInfo wrapAccount(Context context, AccountWithDataSet account) {
4075895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott        // Use the "Device" type label for the name as well because on OEM phones the "name" is
4175895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott        // not always user-friendly
4275895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott        return new AccountInfo(
4375895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott                new AccountDisplayInfo(account, getDisplayLabel(context), getDisplayLabel(context),
4475895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott                        getDisplayIcon(context), true), this);
4575895e73379aa26a3d4135c772af4ecb8a79b4c9Marcus Hagerott    }
466caf23f93b68818a2b8dae63578dbb942b901d2aMarcus Hagerott}
47