am 15480481: Add keyboard shadow
* commit '15480481be790c913b0117d0841565efd399cd01': Add keyboard shadowmain
commit
8e5dac104f
|
@ -21,7 +21,8 @@
|
||||||
<com.android.inputmethod.latin.InputView
|
<com.android.inputmethod.latin.InputView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
style="?attr/inputViewStyle">
|
||||||
<include
|
<include
|
||||||
android:id="@+id/main_keyboard_frame"
|
android:id="@+id/main_keyboard_frame"
|
||||||
layout="@layout/main_keyboard_frame" />
|
layout="@layout/main_keyboard_frame" />
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2014, 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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<style
|
||||||
|
name="InputView.LXX"
|
||||||
|
parent="InputView"
|
||||||
|
>
|
||||||
|
<item name="android:elevation">8dp</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<declare-styleable name="KeyboardTheme">
|
<declare-styleable name="KeyboardTheme">
|
||||||
|
<!-- InputView style -->
|
||||||
|
<attr name="inputViewStyle" format="reference" />
|
||||||
<!-- Keyboard style -->
|
<!-- Keyboard style -->
|
||||||
<attr name="keyboardStyle" format="reference" />
|
<attr name="keyboardStyle" format="reference" />
|
||||||
<!-- KeyboardView style -->
|
<!-- KeyboardView style -->
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<style name="KeyboardIcons" />
|
<style name="KeyboardIcons" />
|
||||||
|
<style name="InputView" />
|
||||||
<!-- Default theme values -->
|
<!-- Default theme values -->
|
||||||
<style name="Keyboard">
|
<style name="Keyboard">
|
||||||
<item name="rowHeight">25%p</item>
|
<item name="rowHeight">25%p</item>
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<style
|
||||||
|
name="InputView.Holo"
|
||||||
|
parent="InputView"
|
||||||
|
/>
|
||||||
<!-- Holo KeyboardView theme (ICS and KLP) -->
|
<!-- Holo KeyboardView theme (ICS and KLP) -->
|
||||||
<style
|
<style
|
||||||
name="KeyboardView.Holo"
|
name="KeyboardView.Holo"
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<style name="KeyboardTheme.ICS" parent="KeyboardIcons.Holo">
|
<style name="KeyboardTheme.ICS" parent="KeyboardIcons.Holo">
|
||||||
|
<item name="inputViewStyle">@style/InputView.Holo</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard.ICS</item>
|
<item name="keyboardStyle">@style/Keyboard.ICS</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.ICS</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.ICS</item>
|
||||||
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.ICS</item>
|
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.ICS</item>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<style name="KeyboardTheme.KLP" parent="KeyboardIcons.Holo">
|
<style name="KeyboardTheme.KLP" parent="KeyboardIcons.Holo">
|
||||||
|
<item name="inputViewStyle">@style/InputView.Holo</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard.KLP</item>
|
<item name="keyboardStyle">@style/Keyboard.KLP</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.KLP</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.KLP</item>
|
||||||
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.KLP</item>
|
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.KLP</item>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<style name="KeyboardTheme.LXX_Dark" parent="KeyboardIcons.LXX_Dark">
|
<style name="KeyboardTheme.LXX_Dark" parent="KeyboardIcons.LXX_Dark">
|
||||||
|
<item name="inputViewStyle">@style/InputView.LXX</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard.LXX_Dark</item>
|
<item name="keyboardStyle">@style/Keyboard.LXX_Dark</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.LXX_Dark</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.LXX_Dark</item>
|
||||||
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.LXX_Dark</item>
|
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.LXX_Dark</item>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<style name="KeyboardTheme.LXX_Light" parent="KeyboardIcons.LXX_Light">
|
<style name="KeyboardTheme.LXX_Light" parent="KeyboardIcons.LXX_Light">
|
||||||
|
<item name="inputViewStyle">@style/InputView.LXX</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard.LXX_Light</item>
|
<item name="keyboardStyle">@style/Keyboard.LXX_Light</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.LXX_Light</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.LXX_Light</item>
|
||||||
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.LXX_Light</item>
|
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.LXX_Light</item>
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<style
|
||||||
|
name="InputView.LXX"
|
||||||
|
parent="InputView"
|
||||||
|
/>
|
||||||
<!-- LXX KeyboardView theme (LXX_Light and LXX_Dark) -->
|
<!-- LXX KeyboardView theme (LXX_Light and LXX_Dark) -->
|
||||||
<style
|
<style
|
||||||
name="KeyboardView.LXX"
|
name="KeyboardView.LXX"
|
||||||
|
|
|
@ -31,9 +31,6 @@ public final class ViewCompatUtils {
|
||||||
private static final Method METHOD_setPaddingRelative = CompatUtils.getMethod(
|
private static final Method METHOD_setPaddingRelative = CompatUtils.getMethod(
|
||||||
View.class, "setPaddingRelative",
|
View.class, "setPaddingRelative",
|
||||||
int.class, int.class, int.class, int.class);
|
int.class, int.class, int.class, int.class);
|
||||||
// Note that View.setElevation(float) has been introduced in API level 21.
|
|
||||||
private static final Method METHOD_setElevation = CompatUtils.getMethod(
|
|
||||||
View.class, "setElevation", float.class);
|
|
||||||
// Note that View.setTextAlignment(int) has been introduced in API level 17.
|
// Note that View.setTextAlignment(int) has been introduced in API level 17.
|
||||||
private static final Method METHOD_setTextAlignment = CompatUtils.getMethod(
|
private static final Method METHOD_setTextAlignment = CompatUtils.getMethod(
|
||||||
View.class, "setTextAlignment", int.class);
|
View.class, "setTextAlignment", int.class);
|
||||||
|
@ -58,10 +55,6 @@ public final class ViewCompatUtils {
|
||||||
CompatUtils.invoke(view, null, METHOD_setPaddingRelative, start, top, end, bottom);
|
CompatUtils.invoke(view, null, METHOD_setPaddingRelative, start, top, end, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setElevation(final View view, final float elevation) {
|
|
||||||
CompatUtils.invoke(view, null, METHOD_setElevation, elevation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// These TEXT_ALIGNMENT_* constants have been introduced in API 17.
|
// These TEXT_ALIGNMENT_* constants have been introduced in API 17.
|
||||||
public static final int TEXT_ALIGNMENT_INHERIT = 0;
|
public static final int TEXT_ALIGNMENT_INHERIT = 0;
|
||||||
public static final int TEXT_ALIGNMENT_GRAVITY = 1;
|
public static final int TEXT_ALIGNMENT_GRAVITY = 1;
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 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 com.android.inputmethod.compat;
|
||||||
|
|
||||||
|
import android.inputmethodservice.InputMethodService;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class ViewOutlineProviderCompatUtils {
|
||||||
|
private ViewOutlineProviderCompatUtils() {
|
||||||
|
// This utility class is not publicly instantiable.
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface InsetsUpdater {
|
||||||
|
public void setInsets(final InputMethodService.Insets insets);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final InsetsUpdater EMPTY_INSETS_UPDATER = new InsetsUpdater() {
|
||||||
|
@Override
|
||||||
|
public void setInsets(final InputMethodService.Insets insets) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static InsetsUpdater setInsetsOutlineProvider(final View view) {
|
||||||
|
if (BuildCompatUtils.EFFECTIVE_SDK_INT < BuildCompatUtils.VERSION_CODES_LXX) {
|
||||||
|
return EMPTY_INSETS_UPDATER;
|
||||||
|
}
|
||||||
|
return ViewOutlineProviderCompatUtilsLXX.setInsetsOutlineProvider(view);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 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 com.android.inputmethod.compat;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.graphics.Outline;
|
||||||
|
import android.inputmethodservice.InputMethodService;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewOutlineProvider;
|
||||||
|
|
||||||
|
import com.android.inputmethod.compat.ViewOutlineProviderCompatUtils.InsetsUpdater;
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.L)
|
||||||
|
class ViewOutlineProviderCompatUtilsLXX {
|
||||||
|
private ViewOutlineProviderCompatUtilsLXX() {
|
||||||
|
// This utility class is not publicly instantiable.
|
||||||
|
}
|
||||||
|
|
||||||
|
static InsetsUpdater setInsetsOutlineProvider(final View view) {
|
||||||
|
final InsetsOutlineProvider provider = new InsetsOutlineProvider(view);
|
||||||
|
view.setOutlineProvider(provider);
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class InsetsOutlineProvider extends ViewOutlineProvider
|
||||||
|
implements InsetsUpdater {
|
||||||
|
private final View mView;
|
||||||
|
private static final int NO_DATA = -1;
|
||||||
|
private int mLastVisibleTopInsets = NO_DATA;
|
||||||
|
|
||||||
|
public InsetsOutlineProvider(final View view) {
|
||||||
|
mView = view;
|
||||||
|
view.setOutlineProvider(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInsets(final InputMethodService.Insets insets) {
|
||||||
|
final int visibleTopInsets = insets.visibleTopInsets;
|
||||||
|
if (mLastVisibleTopInsets != visibleTopInsets) {
|
||||||
|
mLastVisibleTopInsets = visibleTopInsets;
|
||||||
|
mView.invalidateOutline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getOutline(final View view, final Outline outline) {
|
||||||
|
if (mLastVisibleTopInsets == NO_DATA) {
|
||||||
|
// Call default implementation.
|
||||||
|
ViewOutlineProvider.BACKGROUND.getOutline(view, outline);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: Revisit this when floating/resize keyboard is supported.
|
||||||
|
outline.setRect(
|
||||||
|
view.getLeft(), mLastVisibleTopInsets, view.getRight(), view.getBottom());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,8 @@ import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.compat.CursorAnchorInfoCompatWrapper;
|
import com.android.inputmethod.compat.CursorAnchorInfoCompatWrapper;
|
||||||
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
||||||
|
import com.android.inputmethod.compat.ViewOutlineProviderCompatUtils;
|
||||||
|
import com.android.inputmethod.compat.ViewOutlineProviderCompatUtils.InsetsUpdater;
|
||||||
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
|
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
|
||||||
import com.android.inputmethod.event.Event;
|
import com.android.inputmethod.event.Event;
|
||||||
import com.android.inputmethod.event.HardwareEventDecoder;
|
import com.android.inputmethod.event.HardwareEventDecoder;
|
||||||
|
@ -154,6 +156,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
// TODO: Move these {@link View}s to {@link KeyboardSwitcher}.
|
// TODO: Move these {@link View}s to {@link KeyboardSwitcher}.
|
||||||
private View mInputView;
|
private View mInputView;
|
||||||
|
private InsetsUpdater mInsetsUpdater;
|
||||||
private SuggestionStripView mSuggestionStripView;
|
private SuggestionStripView mSuggestionStripView;
|
||||||
private TextView mExtractEditText;
|
private TextView mExtractEditText;
|
||||||
|
|
||||||
|
@ -754,6 +757,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
public void setInputView(final View view) {
|
public void setInputView(final View view) {
|
||||||
super.setInputView(view);
|
super.setInputView(view);
|
||||||
mInputView = view;
|
mInputView = view;
|
||||||
|
mInsetsUpdater = ViewOutlineProviderCompatUtils.setInsetsOutlineProvider(view);
|
||||||
updateSoftInputWindowLayoutParameters();
|
updateSoftInputWindowLayoutParameters();
|
||||||
mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view);
|
mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view);
|
||||||
if (hasSuggestionStripView()) {
|
if (hasSuggestionStripView()) {
|
||||||
|
@ -1191,6 +1195,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// no visual element will be shown on the screen.
|
// no visual element will be shown on the screen.
|
||||||
outInsets.touchableInsets = inputHeight;
|
outInsets.touchableInsets = inputHeight;
|
||||||
outInsets.visibleTopInsets = inputHeight;
|
outInsets.visibleTopInsets = inputHeight;
|
||||||
|
mInsetsUpdater.setInsets(outInsets);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int suggestionsHeight = (!mKeyboardSwitcher.isShowingEmojiPalettes()
|
final int suggestionsHeight = (!mKeyboardSwitcher.isShowingEmojiPalettes()
|
||||||
|
@ -1211,6 +1216,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
outInsets.contentTopInsets = visibleTopY;
|
outInsets.contentTopInsets = visibleTopY;
|
||||||
outInsets.visibleTopInsets = visibleTopY;
|
outInsets.visibleTopInsets = visibleTopY;
|
||||||
|
mInsetsUpdater.setInsets(outInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startShowingInputView(final boolean needsToLoadKeyboard) {
|
public void startShowingInputView(final boolean needsToLoadKeyboard) {
|
||||||
|
|
Loading…
Reference in New Issue