Improve debuglog submission.

This commit is contained in:
Greyson Parrelli
2019-12-13 00:18:46 -05:00
parent 1faf196f82
commit 0c254c9621
38 changed files with 1575 additions and 1004 deletions

View File

@@ -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(); }
}

View File

@@ -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;
}
}

View File

@@ -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];