import 'dart:convert';

import 'package:keyboard/data/bean/keyboard_info.dart';
import 'package:keyboard_android/keyboard_android.dart';

class KeyboardAndroidService {
  final _plugin = KeyboardAndroid();

  Future<void> initPlugin() async {
    await _plugin.initPlugin();
  }

  void enableFloatingWindow(bool enable) {
    _plugin.enableFloatingWindow(enable);
  }

  void jumpFloatingWindowSetting() {
    _plugin.jumpFloatingWindowSetting();
  }

  Future<bool> hasFloatingWindowPermission() {
    return _plugin.hasFloatingWindowPermission();
  }

  void openInputMethodSettings() {
    _plugin.openInputMethodSettings();
  }

  Future<bool> isTargetKeyboardEnabled() {
    return _plugin.isTargetKeyboardEnabled();
  }

  Future<bool> isDefaultKeyboard() {
    return _plugin.isDefaultKeyboard();
  }

  updateKeyboardInfo(KeyboardInfo keyboardInfo) {
    _plugin.updateKeyboardInfo(jsonEncode(keyboardInfo));
  }

  void refreshCharacterList() {
    _plugin.refreshCharacterList();
  }

  void refreshData() {
    _plugin.refreshData();
  }
}
