GameTextInput.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2021 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. package textinput;
  17. import android.text.Editable;
  18. import android.text.Spanned;
  19. import android.view.inputmethod.EditorInfo;
  20. /*
  21. * Singleton GameTextInput class with helper methods.
  22. */
  23. public final class GameTextInput {
  24. public final static void copyEditorInfo(EditorInfo from, EditorInfo to) {
  25. if (from == null || to == null)
  26. return;
  27. if (from.hintText != null) {
  28. to.hintText = from.hintText;
  29. }
  30. to.inputType = from.inputType;
  31. to.imeOptions = from.imeOptions;
  32. to.label = from.label;
  33. to.initialCapsMode = from.initialCapsMode;
  34. to.privateImeOptions = from.privateImeOptions;
  35. if (from.packageName != null) {
  36. to.packageName = from.packageName;
  37. }
  38. to.fieldId = from.fieldId;
  39. if (from.fieldName != null) {
  40. to.fieldName = from.fieldName;
  41. }
  42. to.initialSelStart = from.initialSelStart;
  43. to.initialSelEnd = from.initialSelEnd;
  44. }
  45. public static final class Pair {
  46. int first, second;
  47. Pair(int f, int s) {
  48. first = f;
  49. second = s;
  50. }
  51. }
  52. private GameTextInput() {}
  53. }