diff options
| author | Xavier Ducrohet <xav@android.com> | 2011-07-12 12:35:50 -0700 |
|---|---|---|
| committer | Xavier Ducrohet <xav@android.com> | 2011-07-12 12:35:50 -0700 |
| commit | 96131eef3869f2be1300e1620f5c3874b41bb534 (patch) | |
| tree | 8c378e7302477213510655ec5b9bae290de9f744 /tools/layoutlib/bridge/src/android/view | |
| parent | 0a49635b171f3ba366b1a7ebf28791c4661829bd (diff) | |
| download | frameworks_base-96131eef3869f2be1300e1620f5c3874b41bb534.zip frameworks_base-96131eef3869f2be1300e1620f5c3874b41bb534.tar.gz frameworks_base-96131eef3869f2be1300e1620f5c3874b41bb534.tar.bz2 | |
LayoutLib: updated fake accessbility manager and ensure there's an InputMethodManager
We had replaced the accessibility Manager but it lacked some new API. Obvisouly
this is fragile and should be fixed, but this works for now.
After fixing this there was another issue with the lack of InputMethodManager.
To fix this I had to create an implementation of IInputMethodManager which
normally comes from a binder object.
I may want to do a similar trick with the accessibility manager later.
Change-Id: I28c6494e333f39072f348d0199124efac93256a5
Diffstat (limited to 'tools/layoutlib/bridge/src/android/view')
| -rw-r--r-- | tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java | 42 | ||||
| -rw-r--r-- | tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java | 49 |
2 files changed, 91 insertions, 0 deletions
diff --git a/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java b/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java index 251c053..1fd7836 100644 --- a/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java +++ b/tools/layoutlib/bridge/src/android/view/accessibility/AccessibilityManager.java @@ -16,8 +16,11 @@ package android.view.accessibility; +import android.accessibilityservice.AccessibilityServiceInfo; import android.content.Context; import android.content.pm.ServiceInfo; +import android.view.IWindow; +import android.view.View; import java.util.Collections; import java.util.List; @@ -38,6 +41,19 @@ public final class AccessibilityManager { private static AccessibilityManager sInstance = new AccessibilityManager(); /** + * Listener for the accessibility state. + */ + public interface AccessibilityStateChangeListener { + + /** + * Called back on change in the accessibility state. + * + * @param enabled Whether accessibility is enabled. + */ + public void onAccessibilityStateChanged(boolean enabled); + } + + /** * Get an AccessibilityManager instance (create one if necessary). * * @hide @@ -92,4 +108,30 @@ public final class AccessibilityManager { List<ServiceInfo> services = null; return Collections.unmodifiableList(services); } + + public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() { + // normal implementation does this in some case, so let's do the same + // (unmodifiableList wrapped around null). + List<AccessibilityServiceInfo> services = null; + return Collections.unmodifiableList(services); + } + + public boolean addAccessibilityStateChangeListener( + AccessibilityStateChangeListener listener) { + return true; + } + + public boolean removeAccessibilityStateChangeListener( + AccessibilityStateChangeListener listener) { + return true; + } + + public int addAccessibilityInteractionConnection(IWindow windowToken, + IAccessibilityInteractionConnection connection) { + return View.NO_ID; + } + + public void removeAccessibilityInteractionConnection(IWindow windowToken) { + } + } diff --git a/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java new file mode 100644 index 0000000..ec7a67e --- /dev/null +++ b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.inputmethod; + +import com.android.layoutlib.bridge.android.BridgeIInputMethodManager; +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; + +import android.os.Looper; + + +/** + * Delegate used to provide new implementation of a select few methods of {@link InputMethodManager} + * + * Through the layoutlib_create tool, the original methods of InputMethodManager have been replaced + * by calls to methods of the same name in this delegate class. + * + */ +public class InputMethodManager_Delegate { + + // ---- Overridden methods ---- + + @LayoutlibDelegate + /*package*/ static InputMethodManager getInstance(Looper mainLooper) { + synchronized (InputMethodManager.mInstanceSync) { + if (InputMethodManager.mInstance != null) { + return InputMethodManager.mInstance; + } + + InputMethodManager.mInstance = new InputMethodManager(new BridgeIInputMethodManager(), + mainLooper); + } + return InputMethodManager.mInstance; + + } +} |
