Migrates to the new capitalization function
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.service.logging
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.Looper
|
||||
@@ -164,6 +165,8 @@ class StackSampler(
|
||||
|
||||
companion object {
|
||||
const val SEPARATOR: String = "\r\n"
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
val TIME_FORMATTER: SimpleDateFormat = SimpleDateFormat("MM-dd HH:mm:ss.SSS")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.text.DecimalFormat
|
||||
import java.text.NumberFormat
|
||||
import java.util.Locale
|
||||
import kotlin.math.abs
|
||||
|
||||
@Preview
|
||||
@@ -257,7 +258,7 @@ fun RenderEyeGlassesPrescription(
|
||||
}
|
||||
visionPrescription.status?.let {
|
||||
Text(
|
||||
text = "Status: ${it.capitalize()}",
|
||||
text = "Status: ${it.capitalize(Locale.getDefault())}",
|
||||
modifier = Modifier.padding(4.dp).fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
@@ -358,7 +359,7 @@ fun RenderEyeGlassesPrescriptionRow(data: LensSpecification) {
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
text = data.eye?.capitalize() ?: "Unknown",
|
||||
text = data.eye?.capitalize(Locale.getDefault()) ?: "Unknown",
|
||||
modifier = Modifier.padding(4.dp).weight(1f),
|
||||
)
|
||||
VerticalDivider(thickness = DividerThickness)
|
||||
@@ -514,7 +515,7 @@ fun RenderEyeContactsPrescriptionRow(data: LensSpecification) {
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
text = data.eye?.capitalize() ?: "Unknown",
|
||||
text = data.eye?.capitalize(Locale.getDefault()) ?: "Unknown",
|
||||
modifier = Modifier.padding(4.dp).weight(1f),
|
||||
)
|
||||
VerticalDivider(thickness = DividerThickness)
|
||||
|
||||
+5
-4
@@ -43,6 +43,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Locale
|
||||
|
||||
// This allows multiple screen to be listening to tags, even the same tag
|
||||
class DiscoveryQueryState(
|
||||
@@ -113,7 +114,7 @@ class DiscoveryFilterAssembler(
|
||||
it,
|
||||
it.lowercase(),
|
||||
it.uppercase(),
|
||||
it.capitalize(),
|
||||
it.capitalize(Locale.getDefault()),
|
||||
)
|
||||
}.flatten(),
|
||||
),
|
||||
@@ -276,7 +277,7 @@ class DiscoveryFilterAssembler(
|
||||
it,
|
||||
it.lowercase(),
|
||||
it.uppercase(),
|
||||
it.capitalize(),
|
||||
it.capitalize(Locale.getDefault()),
|
||||
)
|
||||
}.flatten(),
|
||||
),
|
||||
@@ -337,7 +338,7 @@ class DiscoveryFilterAssembler(
|
||||
it,
|
||||
it.lowercase(),
|
||||
it.uppercase(),
|
||||
it.capitalize(),
|
||||
it.capitalize(Locale.getDefault()),
|
||||
)
|
||||
}.flatten(),
|
||||
),
|
||||
@@ -399,7 +400,7 @@ class DiscoveryFilterAssembler(
|
||||
it,
|
||||
it.lowercase(),
|
||||
it.uppercase(),
|
||||
it.capitalize(),
|
||||
it.capitalize(Locale.getDefault()),
|
||||
)
|
||||
}.flatten(),
|
||||
),
|
||||
|
||||
+2
-1
@@ -37,6 +37,7 @@ import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessa
|
||||
import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent
|
||||
import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent
|
||||
import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent
|
||||
import java.util.Locale
|
||||
|
||||
// This allows multiple screen to be listening to tags, even the same tag
|
||||
class HashtagQueryState(
|
||||
@@ -79,7 +80,7 @@ class HashtagFilterAssembler(
|
||||
it.hashtag,
|
||||
it.hashtag.lowercase(),
|
||||
it.hashtag.uppercase(),
|
||||
it.hashtag.capitalize(),
|
||||
it.hashtag.capitalize(Locale.getDefault()),
|
||||
)
|
||||
}.flatten()
|
||||
|
||||
|
||||
+2
-1
@@ -52,6 +52,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Locale
|
||||
|
||||
// This allows multiple screen to be listening to tags, even the same tag
|
||||
class HomeQueryState(
|
||||
@@ -176,7 +177,7 @@ class HomeFilterAssembler(
|
||||
it,
|
||||
it.lowercase(),
|
||||
it.uppercase(),
|
||||
it.capitalize(),
|
||||
it.capitalize(Locale.getDefault()),
|
||||
)
|
||||
}.flatten(),
|
||||
),
|
||||
|
||||
+2
-1
@@ -39,6 +39,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.Locale
|
||||
|
||||
val SUPPORTED_VIDEO_FEED_MIME_TYPES = listOf("image/jpeg", "image/gif", "image/png", "image/webp", "video/mp4", "video/mpeg", "video/webm", "audio/aac", "audio/mpeg", "audio/webm", "audio/wav", "image/avif")
|
||||
val SUPPORTED_VIDEO_FEED_MIME_TYPES_SET = SUPPORTED_VIDEO_FEED_MIME_TYPES.toSet()
|
||||
@@ -102,7 +103,7 @@ class VideoFilterAssembler(
|
||||
|
||||
val hashtags =
|
||||
hashToLoad
|
||||
.map { listOf(it, it.lowercase(), it.uppercase(), it.capitalize()) }
|
||||
.map { listOf(it, it.lowercase(), it.uppercase(), it.capitalize(Locale.getDefault())) }
|
||||
.flatten()
|
||||
|
||||
return listOf(
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.vitorpamplona.quartz.nip03Timestamp.ots.http.Response;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -94,7 +95,7 @@ public class Calendar implements ICalendar {
|
||||
headers.put("User-Agent", "java-opentimestamps");
|
||||
headers.put("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
URL obj = new URL(url + "/timestamp/" + Utils.bytesToHex(commitment).toLowerCase());
|
||||
URL obj = new URL(url + "/timestamp/" + Utils.bytesToHex(commitment).toLowerCase(Locale.ROOT));
|
||||
Request task = new Request(obj);
|
||||
task.setHeaders(headers);
|
||||
Response response = task.call();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.vitorpamplona.quartz.nip03Timestamp.ots;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.ots.op.OpCrypto;
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.ots.op.OpKECCAK256;
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.ots.op.OpRIPEMD160;
|
||||
@@ -11,6 +13,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Hash {
|
||||
|
||||
@@ -121,13 +124,13 @@ public class Hash {
|
||||
* @return The generated com.vitorpamplona.quartz.ots.OpCrypto object.
|
||||
*/
|
||||
public static OpCrypto getOp(String label) {
|
||||
if (label.toLowerCase().equals(new OpSHA1()._TAG_NAME())) {
|
||||
if (label.toLowerCase(Locale.ROOT).equals(new OpSHA1()._TAG_NAME())) {
|
||||
return new OpSHA1();
|
||||
} else if (label.toLowerCase().equals(new OpSHA256()._TAG_NAME())) {
|
||||
} else if (label.toLowerCase(Locale.ROOT).equals(new OpSHA256()._TAG_NAME())) {
|
||||
return new OpSHA256();
|
||||
} else if (label.toLowerCase().equals(new OpRIPEMD160()._TAG_NAME())) {
|
||||
} else if (label.toLowerCase(Locale.ROOT).equals(new OpRIPEMD160()._TAG_NAME())) {
|
||||
return new OpRIPEMD160();
|
||||
} else if (label.toLowerCase().equals(new OpKECCAK256()._TAG_NAME())) {
|
||||
} else if (label.toLowerCase(Locale.ROOT).equals(new OpKECCAK256()._TAG_NAME())) {
|
||||
return new OpKECCAK256();
|
||||
}
|
||||
|
||||
@@ -187,6 +190,7 @@ public class Hash {
|
||||
*
|
||||
* @return The output.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
String output = "com.vitorpamplona.quartz.ots.Hash\n";
|
||||
|
||||
+4
-3
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -63,7 +64,7 @@ public class OpenTimestamps {
|
||||
return "No ots file";
|
||||
}
|
||||
|
||||
String fileHash = Utils.bytesToHex(detachedTimestampFile.timestamp.msg).toLowerCase();
|
||||
String fileHash = Utils.bytesToHex(detachedTimestampFile.timestamp.msg).toLowerCase(Locale.ROOT);
|
||||
String hashOp = ((OpCrypto) detachedTimestampFile.fileHashOp)._TAG_NAME();
|
||||
|
||||
String firstLine = "File " + hashOp + " hash: " + fileHash + '\n';
|
||||
@@ -82,7 +83,7 @@ public class OpenTimestamps {
|
||||
return "No timestamp";
|
||||
}
|
||||
|
||||
String fileHash = Utils.bytesToHex(timestamp.msg).toLowerCase();
|
||||
String fileHash = Utils.bytesToHex(timestamp.msg).toLowerCase(Locale.ROOT);
|
||||
String firstLine = "Hash: " + fileHash + '\n';
|
||||
|
||||
return firstLine + "Timestamp:\n" + timestamp.strTree(0);
|
||||
@@ -270,7 +271,7 @@ public class OpenTimestamps {
|
||||
|
||||
public HashMap<VerifyResult.Chains, VerifyResult> verify(DetachedTimestampFile ots, byte[] diggest) throws Exception {
|
||||
if (!Arrays.equals(ots.fileDigest(), diggest)) {
|
||||
Log.e("OpenTimestamp", "Expected digest " + Hex.encode(ots.fileDigest()).toLowerCase());
|
||||
Log.e("OpenTimestamp", "Expected digest " + Hex.encode(ots.fileDigest()).toLowerCase(Locale.ROOT));
|
||||
Log.e("OpenTimestamp", "File does not match original!");
|
||||
throw new Exception("File does not match original!");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@@ -376,7 +377,7 @@ public class Timestamp {
|
||||
|
||||
if (attestation instanceof BitcoinBlockHeaderAttestation) {
|
||||
String tx = Utils.bytesToHex(Utils.arrayReverse(this.msg));
|
||||
builder.append(Timestamp.indention(indent) + "# Bitcoin block merkle root " + tx.toLowerCase() + "\n");
|
||||
builder.append(Timestamp.indention(indent) + "# Bitcoin block merkle root " + tx.toLowerCase(Locale.ROOT) + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -395,7 +396,7 @@ public class Timestamp {
|
||||
curPar = ((OpBinary) op).arg;
|
||||
}
|
||||
|
||||
builder.append(Timestamp.indention(indent) + " -> " + op.toString().toLowerCase() + strResult(verbosity, curPar, curRes).toLowerCase() + "\n");
|
||||
builder.append(Timestamp.indention(indent) + " -> " + op.toString().toLowerCase(Locale.ROOT) + strResult(verbosity, curPar, curRes).toLowerCase(Locale.ROOT) + "\n");
|
||||
builder.append(timestamp.strTree(indent + 1, verbosity));
|
||||
}
|
||||
} else if (this.ops.size() > 0) {
|
||||
@@ -411,7 +412,7 @@ public class Timestamp {
|
||||
curPar = ((OpBinary) op).arg;
|
||||
}
|
||||
|
||||
builder.append(Timestamp.indention(indent) + op.toString().toLowerCase() + strResult(verbosity, curPar, curRes).toLowerCase() + "\n");
|
||||
builder.append(Timestamp.indention(indent) + op.toString().toLowerCase(Locale.ROOT) + strResult(verbosity, curPar, curRes).toLowerCase(Locale.ROOT) + "\n");
|
||||
builder.append(timestamp.strTree(indent, verbosity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.vitorpamplona.quartz.nip03Timestamp.ots;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
@@ -181,7 +182,7 @@ public class Utils {
|
||||
* @return the string, with its first character converted to uppercase
|
||||
*/
|
||||
public static String toUpperFirstLetter(String string) {
|
||||
return string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase();
|
||||
return string.substring(0, 1).toUpperCase(Locale.getDefault()) + string.substring(1).toLowerCase(Locale.getDefault());
|
||||
}
|
||||
|
||||
// TODO: This is not the way to do logging. Fix later, possibly with slf4j annotation. Need to read up on the subject.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.vitorpamplona.quartz.nip03Timestamp.ots;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -32,6 +34,7 @@ public class VerifyResult implements Comparable<VerifyResult> {
|
||||
String pattern = "yyyy-MM-dd z";
|
||||
Locale locale = new Locale("en", "UK");
|
||||
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern, dateFormatSymbols);
|
||||
String string = simpleDateFormat.format(new Date(timestamp * 1000));
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.vitorpamplona.quartz.nip03Timestamp.ots.exceptions.DeserializationExc
|
||||
import com.vitorpamplona.quartz.utils.Hex;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Operations that act on a message and a single argument.
|
||||
@@ -56,7 +57,7 @@ public abstract class OpBinary extends Op implements Comparable<Op> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this._TAG_NAME() + ' ' + Hex.encode(this.arg).toLowerCase();
|
||||
return this._TAG_NAME() + ' ' + Hex.encode(this.arg).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user