You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
add more Java APIs needed for OctoDroid
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
package android.text;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class Html {
|
||||
|
||||
public static interface ImageGetter {
|
||||
public Drawable getDrawable(String source);
|
||||
}
|
||||
|
||||
public static Spanned fromHtml(String source) {
|
||||
return new SpannableString(source.replace("<br/>", "\n")
|
||||
.replace("<br>", "\n")
|
||||
|
||||
@@ -330,4 +330,12 @@ public class TextUtils {
|
||||
private static Object sLock = new Object();
|
||||
|
||||
private static char[] sTemp = null;
|
||||
|
||||
public static int getTrimmedLength(CharSequence s) {
|
||||
return s.toString().trim().length();
|
||||
}
|
||||
|
||||
public static String htmlEncode(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
12
src/api-impl/android/text/format/DateUtils.java
Normal file
12
src/api-impl/android/text/format/DateUtils.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package android.text.format;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class DateUtils {
|
||||
|
||||
public static CharSequence getRelativeTimeSpanString(Context context, long millis, boolean withPreposition) {
|
||||
return new Date(millis).toString();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,18 @@ import android.content.Context;
|
||||
public class Formatter {
|
||||
|
||||
public static String formatShortFileSize(Context context, long size) {
|
||||
return String.valueOf(size);
|
||||
return formatFileSize(context, size);
|
||||
}
|
||||
|
||||
public static String formatFileSize(Context context, long size) {
|
||||
if (size > 1024 * 1024 * 1024) {
|
||||
return String.format("%.1f GiB", size / 1024.0 / 1024.0 / 1024.0);
|
||||
} else if (size > 1024 * 1024) {
|
||||
return String.format("%.1f MiB", size / 1024.0 / 1024.0);
|
||||
} else if (size > 1024) {
|
||||
return String.format("%.1f KiB", size / 1024.0);
|
||||
} else {
|
||||
return String.format("%d B", size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,17 @@ import android.graphics.drawable.Drawable;
|
||||
|
||||
public class ImageSpan extends DynamicDrawableSpan {
|
||||
|
||||
public ImageSpan(Drawable d) {}
|
||||
private Drawable drawable;
|
||||
|
||||
public ImageSpan(Drawable d) {
|
||||
drawable = d;
|
||||
}
|
||||
|
||||
public ImageSpan(Drawable d, String source) {
|
||||
drawable = d;
|
||||
}
|
||||
|
||||
public Drawable getDrawable() {
|
||||
return drawable;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user