Home | History | Annotate | Download | only in accounts
      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.inputmethod.latin.accounts;
     18 
     19 import android.support.annotation.NonNull;
     20 
     21 import javax.annotation.Nullable;
     22 
     23 /**
     24  * Handles changes to account used to sign in to the keyboard.
     25  * e.g. account switching/sign-in/sign-out from the keyboard
     26  * user toggling the sync preference.
     27  */
     28 public class AccountStateChangedListener {
     29 
     30     /**
     31      * Called when the current account being used in keyboard is signed out.
     32      *
     33      * @param oldAccount the account that was signed out of.
     34      */
     35     public static void onAccountSignedOut(@NonNull String oldAccount) {
     36     }
     37 
     38     /**
     39      * Called when the user signs-in to the keyboard.
     40      * This may be called when the user switches accounts to sign in with a different account.
     41      *
     42      * @param oldAccount the previous account that was being used for sign-in.
     43      *        May be null for a fresh sign-in.
     44      * @param newAccount the account being used for sign-in.
     45      */
     46     public static void onAccountSignedIn(@Nullable String oldAccount, @NonNull String newAccount) {
     47     }
     48 
     49     /**
     50      * Called when the user toggles the sync preference.
     51      *
     52      * @param account the account being used for sync.
     53      * @param syncEnabled indicates whether sync has been enabled or not.
     54      */
     55     public static void onSyncPreferenceChanged(@Nullable String account, boolean syncEnabled) {
     56     }
     57 
     58     /**
     59      * Forces an immediate sync to happen.
     60      * This should only be used for debugging purposes.
     61      *
     62      * @param account the account to use for sync.
     63      */
     64     public static void forceSync(@Nullable String account) {
     65     }
     66 
     67     /**
     68      * Forces an immediate deletion of user's data.
     69      * This should only be used for debugging purposes.
     70      *
     71      * @param account the account to use for sync.
     72      */
     73     public static void forceDelete(@Nullable String account) {
     74     }
     75 }
     76