+++ /dev/null
-/* Copyright 2020 Braden Farmer
- *
- * 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.farmerbb.taskbar.receiver;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.view.inputmethod.InputMethodManager;
-
-public class KeyboardChangeReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showInputMethodPicker();
- }
-}
\ No newline at end of file
package com.farmerbb.taskbar.service;
import android.annotation.TargetApi;
-import android.app.KeyguardManager;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.admin.DevicePolicyManager;
-import android.content.Context;
-import android.content.Intent;
import android.content.res.Configuration;
import android.hardware.display.DisplayManager;
import android.inputmethodservice.InputMethodService;
import android.os.Build;
-import androidx.core.app.NotificationCompat;
import android.text.InputType;
import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
import com.farmerbb.taskbar.R;
-import com.farmerbb.taskbar.receiver.KeyboardChangeReceiver;
import com.farmerbb.taskbar.util.U;
-import java.util.Random;
-
public class DisableKeyboardService extends InputMethodService {
- Integer notificationId;
-
@Override
public boolean onShowInputRequested(int flags, boolean configChange) {
return false;
manager.registerDisplayListener(listener, null);
}
- @TargetApi(Build.VERSION_CODES.O)
@Override
- public void onStartInput(EditorInfo attribute, boolean restarting) {
- boolean isEditingText = attribute.inputType != InputType.TYPE_NULL;
- boolean hasHardwareKeyboard = getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
-
- if(notificationId == null && isEditingText && !hasHardwareKeyboard) {
- Intent keyboardChangeIntent = new Intent(this, KeyboardChangeReceiver.class);
- PendingIntent keyboardChangePendingIntent = PendingIntent.getBroadcast(this, 0, keyboardChangeIntent, PendingIntent.FLAG_UPDATE_CURRENT);
-
- String id = getClass().getSimpleName();
- CharSequence name = getString(R.string.tb_desktop_mode_ime_fix);
- int importance = NotificationManager.IMPORTANCE_DEFAULT;
-
- NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- nm.createNotificationChannel(new NotificationChannel(id, name, importance));
-
- NotificationCompat.Builder notification = new NotificationCompat.Builder(this, id)
- .setContentIntent(keyboardChangePendingIntent)
- .setSmallIcon(android.R.drawable.stat_sys_warning)
- .setContentTitle(getString(R.string.tb_disabling_soft_keyboard))
- .setContentText(getString(R.string.tb_tap_to_change_keyboards))
- .setOngoing(true)
- .setShowWhen(false);
-
- notificationId = new Random().nextInt();
- nm.notify(notificationId, notification.build());
-
- boolean autoShowInputMethodPicker = false;
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
- switch(devicePolicyManager.getStorageEncryptionStatus()) {
- case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
- case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_PER_USER:
- break;
- default:
- autoShowInputMethodPicker = true;
- break;
- }
- }
-
- KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
- if(keyguardManager.inKeyguardRestrictedInputMode() && autoShowInputMethodPicker) {
- InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
- imm.showInputMethodPicker();
- }
- } else if(notificationId != null && !isEditingText) {
- NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- nm.cancel(notificationId);
+ public void onDestroy() {
+ DisplayManager manager = (DisplayManager) getSystemService(DISPLAY_SERVICE);
+ manager.unregisterDisplayListener(listener);
- notificationId = null;
- }
+ super.onDestroy();
}
@Override
- public void onDestroy() {
- if(notificationId != null) {
- NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- nm.cancel(notificationId);
+ public void onStartInput(EditorInfo attribute, boolean restarting) {
+ boolean isEditingText = attribute.inputType != InputType.TYPE_NULL;
+ boolean hasHardwareKeyboard = getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
- notificationId = null;
+ if(isEditingText && !hasHardwareKeyboard) {
+ U.showToast(this, R.string.tb_desktop_mode_ime_fix_toast_alt);
+ checkIfShouldDisable();
}
-
- DisplayManager manager = (DisplayManager) getSystemService(DISPLAY_SERVICE);
- manager.unregisterDisplayListener(listener);
-
- super.onDestroy();
}
}
\ No newline at end of file
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
\ No newline at end of file
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
\ No newline at end of file
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
<string name="tb_desktop_mode_ime_fix_title">Enable input method fix</string>
<string name="tb_desktop_mode_ime_fix_summary">Fixes visual glitches caused by input methods on Android 11. Requires you to temporarily set Taskbar as your input method each time desktop mode starts.</string>
<string name="tb_desktop_mode_ime_fix_toast">Open desktop mode settings to enable a fix for visual glitches caused by input methods</string>
- <string name="tb_disabling_soft_keyboard">Disabling soft keyboard</string>
- <string name="tb_tap_to_change_keyboards">Tap to change keyboards</string>
+ <string name="tb_desktop_mode_ime_fix_toast_alt">Start desktop mode first before enabling the input method fix</string>
<string name="tb_rom">ROM</string>
</resources>
<action android:name="com.twofortyfouram.locale.intent.action.QUERY_CONDITION" />
</intent-filter>
</receiver>
- <receiver
- android:name=".receiver.KeyboardChangeReceiver"
- android:enabled="false"
- android:exported="true" />
<provider
android:name="androidx.core.content.FileProvider"