Module: DroidAdbs::IME

Defined in:
lib/droid_adbs/commons/ime.rb

Class Method Summary collapse

Class Method Details

.get_ime_listArray

Returns Array of IME ID list.

Examples:

[
  "com.agilebits.onepassword/.filling.FillingInputMethodService",
  "com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService"
]

Returns:

  • (Array)

    Array of IME ID list



15
16
17
18
# File 'lib/droid_adbs/commons/ime.rb', line 15

def get_ime_list
  string = get_ime_with_string
  parse_ime_list(string)
end

.get_ime_with_stringString

Returns message from adb command as pure string.

Returns:

  • (String)

    message from adb command as pure string.



5
6
7
# File 'lib/droid_adbs/commons/ime.rb', line 5

def get_ime_with_string
  `#{::DroidAdbs.shell} ime list`.strip
end

.parse_ime_list(ime_lists) ⇒ Array

Returns Array of IME ID list.

Examples:

[
  "com.agilebits.onepassword/.filling.FillingInputMethodService",
  "com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService"
]

Parameters:

  • ime_lists (String)

Returns:

  • (Array)

    Array of IME ID list



35
36
37
# File 'lib/droid_adbs/commons/ime.rb', line 35

def parse_ime_list(ime_lists)
  ime_lists.each_line.map { |line| line.chomp.scan(/\A\S+:\z/).first }.compact.map(&:chop)
end

.set_ime(ime_id) ⇒ String

Returns message from adb command. If it succeeded to set IME, then it returns “Input method com.google.android.inputmethod.japanese/.MozcService selected” If it failed to set IME because of no ID, then it returns “Error: Unknown id: ime_id”.

Parameters:

  • ime_id (String)

    ID provided by IME such as “com.google.android.inputmethod.japanese/.MozcService”

Returns:

  • (String)

    message from adb command. If it succeeded to set IME, then it returns “Input method com.google.android.inputmethod.japanese/.MozcService selected” If it failed to set IME because of no ID, then it returns “Error: Unknown id: ime_id”



24
25
26
# File 'lib/droid_adbs/commons/ime.rb', line 24

def set_ime(ime_id)
  `#{::DroidAdbs.shell} ime set #{ime_id}`.strip
end