1282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/*
2282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Copyright (C) 2011 The Android Open Source Project
3282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
4282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Licensed under the Apache License, Version 2.0 (the "License");
5282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * you may not use this file except in compliance with the License.
6282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * You may obtain a copy of the License at
7282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
8282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *      http://www.apache.org/licenses/LICENSE-2.0
9282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
10282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Unless required by applicable law or agreed to in writing, software
11282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * distributed under the License is distributed on an "AS IS" BASIS,
12282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * See the License for the specific language governing permissions and
14282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * limitations under the License.
15282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */
16282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
17282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipackage android.view.inputmethod;
18282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
19282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.layoutlib.bridge.android.BridgeIInputMethodManager;
20282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.tools.layoutlib.annotations.LayoutlibDelegate;
21282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
22282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport android.content.Context;
23282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport android.os.Looper;
24282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
25282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
26282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/**
27282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Delegate used to provide new implementation of a select few methods of {@link InputMethodManager}
28282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
29282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Through the layoutlib_create tool, the original  methods of InputMethodManager have been replaced
30282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * by calls to methods of the same name in this delegate class.
31282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
32282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */
33282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipublic class InputMethodManager_Delegate {
34282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
35282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    // ---- Overridden methods ----
36282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
37282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @LayoutlibDelegate
38282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    /*package*/ static InputMethodManager getInstance() {
39282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        synchronized (InputMethodManager.class) {
40282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            InputMethodManager imm = InputMethodManager.peekInstance();
41282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            if (imm == null) {
42282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                imm = new InputMethodManager(
43282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        new BridgeIInputMethodManager(), Looper.getMainLooper());
44282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                InputMethodManager.sInstance = imm;
45282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            }
46282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            return imm;
47282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        }
48282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
49282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski}
50