Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dslul committed Jan 23, 2022
2 parents 945b5b7 + df0817c commit 2916e91
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 21 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You can use [this tool](https://github.com/remi0s/aosp-dictionary-tools) to crea

Install java:
```sh
sudo pacman -S jdk8-openjdk jre8-openjdk jre8-openjdk-headless
sudo pacman -S jdk11-openjdk jre11-openjdk jre11-openjdk-headless
```

Install Android SDK:
Expand All @@ -41,11 +41,6 @@ Configure your SDK location in your `~/.bash_profile` or `~/.bashrc`:
export ANDROID_SDK_ROOT=~/snap/androidsdk/current/AndroidSDK/
```

Install the platform tools for your target android version:
```sh
androidsdk "platform-tools" "platforms;android-29"
```

Compile the project. This will install all dependencies, make sure to accept
licenses when prompted.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ public static void clearPrimaryClip(ClipboardManager cm) {
}
}

@TargetApi(Build.VERSION_CODES.O)
public static Long getClipTimestamp(ClipData cd) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return cd.getDescription().getTimestamp();
} else {
return null;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ public void onLongPressed() {
return;
}
final int code = key.getCode();
if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) {
if (code == Constants.CODE_SPACE&&Settings.getInstance().getCurrent().mSpaceForLangChange || code == Constants.CODE_LANGUAGE_SWITCH) {
// Long pressing the space key invokes IME switcher dialog.
if (sListener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) {
cancelKeyTracking();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package org.dslul.openboard.inputmethod.latin

import android.content.ClipboardManager
import android.content.Context
import android.os.Build
import android.text.TextUtils
import android.util.Base64
import android.util.Log
import androidx.annotation.RequiresApi
import org.dslul.openboard.inputmethod.compat.ClipboardManagerCompat
import org.dslul.openboard.inputmethod.latin.utils.JsonUtils
import java.io.File
Expand Down Expand Up @@ -45,25 +47,31 @@ class ClipboardHistoryManager(
override fun onPrimaryClipChanged() = fetchPrimaryClip()

private fun fetchPrimaryClip() {
if (!clipboardManager.hasPrimaryClip()) return
val clipData = clipboardManager.primaryClip
if (clipData != null && clipData.itemCount > 0 && clipData.getItemAt(0) != null) {
val content = clipData.getItemAt(0).coerceToText(latinIME)
if (!TextUtils.isEmpty(content)) {
val id = System.nanoTime()
val entry = ClipboardHistoryEntry(id, content)
historyEntries.add(entry)
sortHistoryEntries()
val at = historyEntries.indexOf(entry)
onHistoryChangeListener?.onClipboardHistoryEntryAdded(at)
}
val clipData = clipboardManager.primaryClip ?: return
if (clipData.itemCount == 0) return
clipData.getItemAt(0)?.let { clipItem ->
// Starting from API 30, onPrimaryClipChanged() can be called multiple times
// for the same clip. We can identify clips with their timestamps since API 26.
// We use that to prevent unwanted duplicates.
val id = ClipboardManagerCompat.getClipTimestamp(clipData)?.also { stamp ->
if (historyEntries.any { it.id == stamp }) return
} ?: System.currentTimeMillis()

val content = clipItem.coerceToText(latinIME)
if (TextUtils.isEmpty(content)) return

val entry = ClipboardHistoryEntry(id, content)
historyEntries.add(entry)
sortHistoryEntries()
val at = historyEntries.indexOf(entry)
onHistoryChangeListener?.onClipboardHistoryEntryAdded(at)
}
}

fun toggleClipPinned(clipId: Long) {
val from = historyEntries.indexOfFirst { it.id == clipId }
val historyEntry = historyEntries[from].apply {
id = System.nanoTime()
id = System.currentTimeMillis()
isPinned = !isPinned
}
sortHistoryEntries()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang

public static final String PREF_SHOW_HINTS = "pref_show_hints";

public static final String PREF_SPACE_TO_CHANGE_LANG = "prefs_long_press_keyboard_to_change_lang";

// This preference key is deprecated. Use {@link #PREF_SHOW_LANGUAGE_SWITCH_KEY} instead.
// This is being used only for the backward compatibility.
private static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class SettingsValues {
public final boolean mIncludesOtherImesInLanguageSwitchList;
public final boolean mShowsNumberRow;
public final boolean mShowsHints;
public final boolean mSpaceForLangChange;
public final boolean mShowsLanguageSwitchKey;
public final boolean mShowsEmojiKey;
public final boolean mShowsClipboardKey;
Expand Down Expand Up @@ -148,6 +149,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
mIncludesOtherImesInLanguageSwitchList = !Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS || prefs.getBoolean(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false) /* forcibly */;
mShowsNumberRow = prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW, false);
mShowsHints = prefs.getBoolean(Settings.PREF_SHOW_HINTS, true);
mSpaceForLangChange = prefs.getBoolean(Settings.PREF_SPACE_TO_CHANGE_LANG, true);
mShowsLanguageSwitchKey = prefs.getBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, false);
mShowsEmojiKey = prefs.getBoolean(Settings.PREF_SHOW_EMOJI_KEY, false);
mShowsClipboardKey = prefs.getBoolean(Settings.PREF_SHOW_CLIPBOARD_KEY, false);
Expand Down
Binary file modified app/src/main/res/raw/main_de.dict
Binary file not shown.
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@
<!-- Description of the settings to show hints -->
<string name="show_hints_summary">Show long-press hints</string>

<!-- Title of the settings to disable long press space to change language -->
<string name="prefs_long_press_keyboard_to_change_lang">Long press to change lang</string>

<!-- Title of the settings to enable keyboard resizing -->
<string name="prefs_resize_keyboard">Enable keyboard resizing</string>
<!-- Title of the settings for setting keyboard height -->
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/prefs_screen_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
android:summary="@string/show_hints_summary"
android:defaultValue="true"
android:persistent="true" />
<CheckBoxPreference
android:key="prefs_long_press_keyboard_to_change_lang"
android:title="@string/prefs_long_press_keyboard_to_change_lang"
android:persistent="true"
android:defaultValue="true" />
<CheckBoxPreference
android:key="pref_show_language_switch_key"
android:title="@string/show_language_switch_key"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.4.30'
ext.kotlin_version = '1.5.31'
repositories {
jcenter()
google()
Expand Down
Binary file modified dictionaries/de_wordlist.combined.gz
100644 → 100755
Binary file not shown.

0 comments on commit 2916e91

Please sign in to comment.