mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Improve debuglog submission.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
/**
|
||||
* Just like {@link java.util.concurrent.TimeUnit}, but for bytes.
|
||||
*/
|
||||
public enum ByteUnit {
|
||||
|
||||
BYTES {
|
||||
public long toBytes(long d) { return d; }
|
||||
public long toKilobytes(long d) { return d/1024; }
|
||||
public long toMegabytes(long d) { return toKilobytes(d)/1024; }
|
||||
public long toGigabytes(long d) { return toMegabytes(d)/1024; }
|
||||
},
|
||||
|
||||
KILOBYTES {
|
||||
public long toBytes(long d) { return d * 1024; }
|
||||
public long toKilobytes(long d) { return d; }
|
||||
public long toMegabytes(long d) { return d/1024; }
|
||||
public long toGigabytes(long d) { return toMegabytes(d)/1024; }
|
||||
},
|
||||
|
||||
MEGABYTES {
|
||||
public long toBytes(long d) { return toKilobytes(d) * 1024; }
|
||||
public long toKilobytes(long d) { return d * 1024; }
|
||||
public long toMegabytes(long d) { return d; }
|
||||
public long toGigabytes(long d) { return d/1024; }
|
||||
},
|
||||
|
||||
GIGABYTES {
|
||||
public long toBytes(long d) { return toKilobytes(d) * 1024; }
|
||||
public long toKilobytes(long d) { return toMegabytes(d) * 1024; }
|
||||
public long toMegabytes(long d) { return d * 1024; }
|
||||
public long toGigabytes(long d) { return d; }
|
||||
};
|
||||
|
||||
public long toBytes(long d) { throw new AbstractMethodError(); }
|
||||
public long toKilobytes(long d) { throw new AbstractMethodError(); }
|
||||
public long toMegabytes(long d) { throw new AbstractMethodError(); }
|
||||
public long toGigabytes(long d) { throw new AbstractMethodError(); }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
public class DefaultValueLiveData<T> extends MutableLiveData<T> {
|
||||
|
||||
private final T defaultValue;
|
||||
|
||||
public DefaultValueLiveData(@NonNull T defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull T getValue() {
|
||||
T value = super.getValue();
|
||||
return value != null ? value : defaultValue;
|
||||
}
|
||||
}
|
||||
@@ -266,6 +266,10 @@ public class ViewUtil {
|
||||
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), padding);
|
||||
}
|
||||
|
||||
public static void setPadding(@NonNull View view, int padding) {
|
||||
view.setPadding(padding, padding, padding, padding);
|
||||
}
|
||||
|
||||
public static boolean isPointInsideView(@NonNull View view, float x, float y) {
|
||||
int[] location = new int[2];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user