code cleanup
This commit is contained in:
parent
4137563fb1
commit
4d665ea264
6 changed files with 28 additions and 18 deletions
|
|
@ -10,6 +10,7 @@ import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
|
@ -138,6 +139,15 @@ public class WordFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getFormattedTotalLines(String suffix) {
|
||||||
|
if (getTotalLines() > 1000000) {
|
||||||
|
return String.format(Locale.ROOT, "%1.2fM %s", getTotalLines() / 1000000.0, suffix);
|
||||||
|
} else {
|
||||||
|
return getTotalLines() / 1000 + "k " + suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setTotalLines(String rawProperty, String rawValue) {
|
private void setTotalLines(String rawProperty, String rawValue) {
|
||||||
if (!rawProperty.equals("words")) {
|
if (!rawProperty.equals("words")) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -161,6 +171,11 @@ public class WordFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getFormattedSize() {
|
||||||
|
return String.format(Locale.ROOT, "%1.2f Mb", getSize() / 1048576.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setSize(String rawProperty, String rawValue) {
|
private void setSize(String rawProperty, String rawValue) {
|
||||||
if (!rawProperty.equals("size")) {
|
if (!rawProperty.equals("size")) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,4 @@ public class WordPairStore extends BaseSyncStore {
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class InputModeValidator {
|
||||||
Language validLanguage = LanguageCollection.getLanguage(context, validLanguageIds.get(0));
|
Language validLanguage = LanguageCollection.getLanguage(context, validLanguageIds.get(0));
|
||||||
validLanguage = validLanguage != null ? validLanguage : LanguageCollection.getDefault(context);
|
validLanguage = validLanguage != null ? validLanguage : LanguageCollection.getDefault(context);
|
||||||
|
|
||||||
Logger.w("validateLanguage", error + " Enforcing language: " + validLanguage.getId());
|
Logger.d("validateLanguage", error + " Enforcing language: " + validLanguage.getId());
|
||||||
|
|
||||||
return validLanguage;
|
return validLanguage;
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +51,7 @@ public class InputModeValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newModeId != oldModeId) {
|
if (newModeId != oldModeId) {
|
||||||
Logger.w("validateMode", "Invalid input mode: " + oldModeId + " Enforcing: " + newModeId);
|
Logger.d("validateMode", "Invalid input mode: " + oldModeId + " Enforcing: " + newModeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newModeId;
|
return newModeId;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ public class PreferenceSearchWords extends ItemTextInput {
|
||||||
|
|
||||||
private ConsumerCompat<ArrayList<String>> onWords;
|
private ConsumerCompat<ArrayList<String>> onWords;
|
||||||
private ConsumerCompat<Long> onTotalWords;
|
private ConsumerCompat<Long> onTotalWords;
|
||||||
private SettingsStore settings;
|
|
||||||
|
|
||||||
@NonNull private String lastSearchTerm = "";
|
@NonNull private String lastSearchTerm = "";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,21 +44,20 @@ public class PreferenceSwitchLanguage extends SwitchPreferenceCompat {
|
||||||
|
|
||||||
|
|
||||||
private String generateSummary(Activity activity, NaturalLanguage language) {
|
private String generateSummary(Activity activity, NaturalLanguage language) {
|
||||||
String summary = language.getLocale().getDisplayLanguage();
|
StringBuilder summary = new StringBuilder(language.getLocale().getDisplayLanguage());
|
||||||
|
|
||||||
String wordsString = activity.getString(R.string.language_selection_words);
|
|
||||||
WordFile wordFile = new WordFile(activity, language.getDictionaryFile(), activity.getAssets());
|
WordFile wordFile = new WordFile(activity, language.getDictionaryFile(), activity.getAssets());
|
||||||
if (wordFile.getTotalLines() > 1000000) {
|
summary
|
||||||
summary += String.format(", %1.2fM %s", wordFile.getTotalLines() / 1000000.0, wordsString);
|
.append(", ")
|
||||||
} else {
|
.append(
|
||||||
summary += ", " + wordFile.getTotalLines() / 1000 + "k " + wordsString;
|
wordFile.getFormattedTotalLines(activity.getString(R.string.language_selection_words))
|
||||||
}
|
);
|
||||||
|
|
||||||
if (BuildConfig.LITE) {
|
if (BuildConfig.LITE) {
|
||||||
summary += String.format(", %1.2f Mb", wordFile.getSize() / 1048576.0);
|
summary.append(", ").append(wordFile.getFormattedSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
return summary;
|
return summary.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ abstract public class SwipeableKey extends SoftKey {
|
||||||
private boolean isHolding = false;
|
private boolean isHolding = false;
|
||||||
private boolean isSwipingX = false;
|
private boolean isSwipingX = false;
|
||||||
private boolean isSwipingY = false;
|
private boolean isSwipingY = false;
|
||||||
private boolean hasSwiped = false;
|
private boolean notSwiped = false;
|
||||||
|
|
||||||
private float startX;
|
private float startX;
|
||||||
private float startY;
|
private float startY;
|
||||||
|
|
@ -124,7 +124,7 @@ abstract public class SwipeableKey extends SoftKey {
|
||||||
|
|
||||||
|
|
||||||
private void onRelease(MotionEvent event) {
|
private void onRelease(MotionEvent event) {
|
||||||
hasSwiped = !isSwipingY && !isSwipingX;
|
notSwiped = !isSwipingY && !isSwipingX;
|
||||||
|
|
||||||
if (isSwipingY) {
|
if (isSwipingY) {
|
||||||
isSwipingY = false;
|
isSwipingY = false;
|
||||||
|
|
@ -142,5 +142,5 @@ abstract public class SwipeableKey extends SoftKey {
|
||||||
protected void handleSwipeY(float position, float delta) {}
|
protected void handleSwipeY(float position, float delta) {}
|
||||||
protected void handleEndSwipeX(float position, float delta) {}
|
protected void handleEndSwipeX(float position, float delta) {}
|
||||||
protected void handleEndSwipeY(float position, float delta) {}
|
protected void handleEndSwipeY(float position, float delta) {}
|
||||||
protected boolean notSwiped() { return hasSwiped; }
|
protected boolean notSwiped() { return notSwiped; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue