• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 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.email.activity.setup;
18 
19 import com.android.email.provider.EmailContent;
20 import com.android.email.provider.EmailContent.AccountColumns;
21 
22 import android.content.ContentValues;
23 import android.content.Context;
24 
25 public class AccountSettingsUtils {
26 
27     /**
28      * Commits the UI-related settings of an account to the provider.  This is static so that it
29      * can be used by the various account activities.  If the account has never been saved, this
30      * method saves it; otherwise, it just saves the settings.
31      * @param context the context of the caller
32      * @param account the account whose settings will be committed
33      */
commitSettings(Context context, EmailContent.Account account)34     public static void commitSettings(Context context, EmailContent.Account account) {
35         if (!account.isSaved()) {
36             account.save(context);
37         } else {
38             ContentValues cv = new ContentValues();
39             cv.put(AccountColumns.IS_DEFAULT, account.mIsDefault);
40             cv.put(AccountColumns.DISPLAY_NAME, account.getDisplayName());
41             cv.put(AccountColumns.SENDER_NAME, account.getSenderName());
42             cv.put(AccountColumns.SYNC_INTERVAL, account.mSyncInterval);
43             cv.put(AccountColumns.RINGTONE_URI, account.mRingtoneUri);
44             cv.put(AccountColumns.FLAGS, account.mFlags);
45             cv.put(AccountColumns.SYNC_LOOKBACK, account.mSyncLookback);
46             account.update(context, cv);
47         }
48     }
49 }
50