]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Some lint fixes.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sat, 11 Apr 2020 23:29:56 +0000 (01:29 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sat, 11 Apr 2020 23:36:34 +0000 (01:36 +0200)
13 files changed:
Util
build.gradle
res/values-eu/strings.xml
res/values/strings.xml
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/DictionaryInfo.java
src/com/hughes/android/dictionary/DictionaryManagerActivity.java
src/com/hughes/android/dictionary/HtmlDisplayActivity.java
src/com/hughes/android/dictionary/engine/Dictionary.java
src/com/hughes/android/dictionary/engine/HtmlEntry.java
src/com/hughes/android/dictionary/engine/Index.java
src/com/hughes/android/dictionary/engine/Language.java
src/com/hughes/android/util/PersistentObjectCache.java

diff --git a/Util b/Util
index 272a7b504cb85b8dc2bba3718725b547750434b1..7efaa369d15e363663e1c226c433569acb1050c0 160000 (submodule)
--- a/Util
+++ b/Util
@@ -1 +1 @@
-Subproject commit 272a7b504cb85b8dc2bba3718725b547750434b1
+Subproject commit 7efaa369d15e363663e1c226c433569acb1050c0
index 7458e941b3acd81f7d14788cd3e6c953d48f5614..378cc827cb057bdbed50f4f2095ffceab1f7a858 100644 (file)
@@ -76,6 +76,6 @@ android {
         applicationId 'de.reimardoeffinger.quickdic'
         targetSdkVersion 29
         resConfigs "de", "es", "eu", "fr", "it", "ja", "pt", "pt-rBR", "ru", "zh-rCN"
         applicationId 'de.reimardoeffinger.quickdic'
         targetSdkVersion 29
         resConfigs "de", "es", "eu", "fr", "it", "ja", "pt", "pt-rBR", "ru", "zh-rCN"
-        minSdkVersion 10
+        minSdkVersion 10
     }
 }
     }
 }
index 338b1567981f1598e7db146d0619e3749c8a6ae1..abda508ecb0a7a3c1c5caef4b8c66530ca0fba90 100644 (file)
@@ -43,7 +43,7 @@
 
     <!-- DictionaryActivity -->
     <string name="searchText">Bilatu testua</string>
 
     <!-- DictionaryActivity -->
     <string name="searchText">Bilatu testua</string>
-    <string name="selectDictionary">Hautatu hiztegia...</string>
+    <string name="selectDictionary">Hautatu hiztegia</string>
     <string name="addToWordList">Gehitu hitzen zerrendara: %s</string>
     <string name="searchForSelection">Bilatu: %s</string>
     <string name="failedAddingToWordList">Akatsa hitz zerrendara gehitzean: %s</string>
     <string name="addToWordList">Gehitu hitzen zerrendara: %s</string>
     <string name="searchForSelection">Bilatu: %s</string>
     <string name="failedAddingToWordList">Akatsa hitz zerrendara gehitzean: %s</string>
index 20d74767c71243033fe529404d422a788295e3c2..e0740712b714262a4791c94532de126242e55e67 100644 (file)
@@ -2,7 +2,6 @@
 <resources>
 
     <string name="app_name" translatable="false">QuickDic</string>
 <resources>
 
     <string name="app_name" translatable="false">QuickDic</string>
-    <string name="thanksForUpdatingVersion" translatable="false">5.1.0</string>
 
     <!-- Global. -->
     <string name="about">About QuickDic</string>
 
     <!-- Global. -->
     <string name="about">About QuickDic</string>
index 837097adecae3df96ad8e5157e6bd73734dcc90b..02286155532c187bf366a1cf86ffcdec1e034db6 100644 (file)
@@ -846,7 +846,7 @@ public class DictionaryActivity extends AppCompatActivity {
 
                 final LinearLayout result = new LinearLayout(parent.getContext());
 
 
                 final LinearLayout result = new LinearLayout(parent.getContext());
 
-                for (int i = 0; dictionaryInfo.indexInfos != null && i < dictionaryInfo.indexInfos.size(); ++i) {
+                for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {
                     final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i);
                     final View button = IsoUtils.INSTANCE.createButton(parent.getContext(),
                             indexInfo, application.languageButtonPixels);
                     final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i);
                     final View button = IsoUtils.INSTANCE.createButton(parent.getContext(),
                             indexInfo, application.languageButtonPixels);
index 0df04c43256d74a14b1c325a593598d6dcc7d75b..4a135202322014530939e5d3e94822b4334eb931 100644 (file)
@@ -63,7 +63,7 @@ public class DictionaryInfo implements Serializable {
     }
 
     public boolean isValid() {
     }
 
     public boolean isValid() {
-        return indexInfos != null && !indexInfos.isEmpty();
+        return !indexInfos.isEmpty();
     }
 
     public StringBuilder append(final StringBuilder result) {
     }
 
     public StringBuilder append(final StringBuilder result) {
index b046a604dc1856af0d4d127eaa66a2969ef10a52..f9a084f706f69deec2c7d956f4dcd16dde0e8e27 100644 (file)
@@ -303,7 +303,7 @@ public class DictionaryManagerActivity extends AppCompatActivity {
     }
 
     @Override
     }
 
     @Override
-    public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
         readableCheckAndError(false);
 
         application.backgroundUpdateDictionaries(dictionaryUpdater);
         readableCheckAndError(false);
 
         application.backgroundUpdateDictionaries(dictionaryUpdater);
index 7a8a7e89c4a286561b0753e2ac4a0f302b766318..f8899b4cbdaadf0398e5bfaf237a2408e864eb45 100644 (file)
@@ -32,6 +32,7 @@ import com.hughes.util.StringUtil;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 
 public final class HtmlDisplayActivity extends AppCompatActivity {
 
 
 public final class HtmlDisplayActivity extends AppCompatActivity {
 
@@ -101,12 +102,8 @@ public final class HtmlDisplayActivity extends AppCompatActivity {
             fontSizeSp = 14;
         }
         webView.getSettings().setDefaultFontSize(fontSizeSp);
             fontSizeSp = 14;
         }
         webView.getSettings().setDefaultFontSize(fontSizeSp);
-        try {
-            // No way to get pure UTF-8 data into WebView
-            html = Base64.encodeToString(html.getBytes("UTF-8"), Base64.DEFAULT);
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException("Missing UTF-8 support?!", e);
-        }
+        // No way to get pure UTF-8 data into WebView
+        html = Base64.encodeToString(html.getBytes(StandardCharsets.UTF_8), Base64.DEFAULT);
         // Use loadURL to allow specifying a charset
         webView.loadUrl("data:text/html;charset=utf-8;base64," + html);
         webView.activity = this;
         // Use loadURL to allow specifying a charset
         webView.loadUrl("data:text/html;charset=utf-8;base64," + html);
         webView.activity = this;
index 82ba2cfa6d90c319c1cbcb8d01e6950dbab19402..fef86bd6577f023a535fe6d528cdcd83a660f341 100644 (file)
@@ -31,6 +31,7 @@ import java.io.PrintStream;
 import java.io.RandomAccessFile;
 import java.nio.channels.Channels;
 import java.nio.channels.FileChannel;
 import java.io.RandomAccessFile;
 import java.nio.channels.Channels;
 import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -214,7 +215,7 @@ public class Dictionary implements RAFSerializable<Dictionary> {
             out.seek(dataPos);
             out.writeShort(h.entrySource.index());
             out.writeUTF(h.title);
             out.seek(dataPos);
             out.writeShort(h.entrySource.index());
             out.writeUTF(h.title);
-            byte[] data = h.getHtml().getBytes("UTF-8");
+            byte[] data = h.getHtml().getBytes(StandardCharsets.UTF_8);
             out.writeInt(data.length);
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             GZIPOutputStream gzout = new GZIPOutputStream(baos);
             out.writeInt(data.length);
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             GZIPOutputStream gzout = new GZIPOutputStream(baos);
index 8dcf905175f5f5e01b983a7fd288f2a80a998ae1..f279a3d8f8fa14071dd89bd2ba29d86c8ba15a23 100644 (file)
@@ -13,6 +13,7 @@ import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.lang.ref.SoftReference;
 import java.nio.channels.FileChannel;
 import java.io.UnsupportedEncodingException;
 import java.lang.ref.SoftReference;
 import java.nio.channels.FileChannel;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.regex.Pattern;
 
 import java.util.List;
 import java.util.regex.Pattern;
 
@@ -44,7 +45,7 @@ public class HtmlEntry extends AbstractEntry implements Comparable<HtmlEntry> {
     }
 
     private void writeData(DataOutput raf) throws IOException {
     }
 
     private void writeData(DataOutput raf) throws IOException {
-        final byte[] bytes = getHtml().getBytes("UTF-8");
+        final byte[] bytes = getHtml().getBytes(StandardCharsets.UTF_8);
         StringUtil.writeVarInt(raf, bytes.length);
         raf.write(bytes);
     }
         StringUtil.writeVarInt(raf, bytes.length);
         raf.write(bytes);
     }
@@ -264,11 +265,7 @@ public class HtmlEntry extends AbstractEntry implements Comparable<HtmlEntry> {
                 return html;
             }
             if (data != null) {
                 return html;
             }
             if (data != null) {
-                try {
-                    html = new String(data.get(index), "UTF-8");
-                } catch (UnsupportedEncodingException e) {
-                    throw new RuntimeException("Dictionary HTML data corrupted", e);
-                }
+                html = new String(data.get(index), StandardCharsets.UTF_8);
                 htmlRef = new SoftReference<>(html);
                 return html;
             }
                 htmlRef = new SoftReference<>(html);
                 return html;
             }
@@ -285,7 +282,7 @@ public class HtmlEntry extends AbstractEntry implements Comparable<HtmlEntry> {
             }
             try {
                 final byte[] bytes = StringUtil.unzipFully(zipBytes, numBytes);
             }
             try {
                 final byte[] bytes = StringUtil.unzipFully(zipBytes, numBytes);
-                html = new String(bytes, "UTF-8");
+                html = new String(bytes, StandardCharsets.UTF_8);
             } catch (IOException e) {
                 throw new RuntimeException("Dictionary HTML data corrupted", e);
             }
             } catch (IOException e) {
                 throw new RuntimeException("Dictionary HTML data corrupted", e);
             }
index e8d9789920a017cdc994296178a04653f869e534..b58384d1d4981849cb7966c9ca923e507c8d6bae 100644 (file)
@@ -125,9 +125,6 @@ public final class Index implements RAFSerializable<Index> {
         sortLanguage = Language.lookup(languageCode);
         normalizerRules = raf.readUTF();
         swapPairEntries = raf.readBoolean();
         sortLanguage = Language.lookup(languageCode);
         normalizerRules = raf.readUTF();
         swapPairEntries = raf.readBoolean();
-        if (sortLanguage == null) {
-            throw new IOException("Unsupported language: " + languageCode);
-        }
         if (dict.dictFileVersion >= 2) {
             mainTokenCount = raf.readInt();
         }
         if (dict.dictFileVersion >= 2) {
             mainTokenCount = raf.readInt();
         }
index 4bef67c6a9462ef9cc836fabf6f22d02000e91b8..1822d937ec7c2f5b9183c78fcbc11af656a52932 100644 (file)
@@ -66,7 +66,7 @@ public class Language {
             return new Comparator<Object>() {
                 @Override
                 public int compare(Object o, Object t1) {
             return new Comparator<Object>() {
                 @Override
                 public int compare(Object o, Object t1) {
-                    return String.class.cast(o).compareToIgnoreCase(String.class.cast(t1));
+                    return ((String)o).compareToIgnoreCase((String)t1);
                 }
             };
         // TODO: consider if this should be cached - but must be thread-safe
                 }
             };
         // TODO: consider if this should be cached - but must be thread-safe
index 17be956b10563cc1ebb20ae723434af4e8cf8038..7ac07458f2cd30ceb23b1e840d7d21859f2a9c45 100644 (file)
@@ -43,7 +43,7 @@ public class PersistentObjectCache {
     private final File dir;
     private final Map<String, Object> objects = new HashMap<>();
 
     private final File dir;
     private final Map<String, Object> objects = new HashMap<>();
 
-    class ConstrainedOIS extends ObjectInputStream {
+    static class ConstrainedOIS extends ObjectInputStream {
         ConstrainedOIS(InputStream in) throws IOException {
             super(in);
         }
         ConstrainedOIS(InputStream in) throws IOException {
             super(in);
         }