Skip to content

Instantly share code, notes, and snippets.

@hector6872
hector6872 / copyToUSB.sh
Created October 31, 2017 19:02
copyToUSB.sh
#!/bin/bash
SOURCE=$1
if [[ -z $SOURCE ]]; then
echo "Usage: $0 [source]" >&2
exit
fi
sudo mkdir -p /mnt/sd1
@hector6872
hector6872 / android-26-sources.md
Created September 12, 2017 13:28 — forked from cketti/android-26-sources.md
Build your own android-26 sources

If you are annoyed that "Sources for Android 26" are not yet available via SDK manager, this might be for you:

  1. Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build

mkdir -p frameworks/base
@hector6872
hector6872 / SupportVersion.java
Created September 11, 2017 09:43
SupportVersion
public class SupportVersion {
private SupportVersion() {
}
public static boolean isLollipopOrAbove() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
}
public static boolean isMarshmallowOrAbove() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
@hector6872
hector6872 / StringSpan.java
Created August 30, 2017 07:53
StringSpan - String.format that works with Android Spannables
// based on: https://github.com/george-steel/android-utils/blob/master/src/org/oshkimaadziig/george/androidutils/SpanFormatter.java
public class StringSpan {
private static final Pattern PATTERN = Pattern.compile("%([^a-zA-z%]*)([[a-zA-Z%]&&[^tT]]|[tT][a-zA-Z])");
private StringSpan() {
}
public static CharSequence format(@NonNull CharSequence format, Object... args) {
return format(Locale.getDefault(), format, args);
@hector6872
hector6872 / demo-mode.sh
Last active January 31, 2023 16:34
Demo Mode for the Android System UI - screenshots - bash script
#!/usr/bin/env sh
# export PATH=$PATH:~/Library/Android/sdk/platform-tools/
case $1 in
"enter")
adb shell settings put global sysui_demo_allowed 1
# display time 12:00
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1200
# display full mobile data without type
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 4 -e datatype false
@hector6872
hector6872 / DashedLineView.java
Last active July 5, 2017 16:06
DashedLineView
public class DashedLineView extends View {
private static final int DEFAULT_COLOR = Color.BLACK;
private static final float DEFAULT_DASH = 4f;
private static final float DEFAULT_GAP = 2f;
private static final float DEFAULT_PHASE = 0f;
private final Paint paint = new Paint();
private final Path path = new Path();
private float dash;
@hector6872
hector6872 / UidUtils.java
Last active July 6, 2017 08:39
UidUtils
public enum UidUtils {
INSTANCE;
private final static String DEFAULT_ID = "anonymous";
private String androidId = DEFAULT_ID;
private String advertisingId = "";
private boolean limitAdTrackingEnabled = false;
public final class Network {
private Network() {
}
public static @NonNull String doGetRequest(@NonNull String service, @NonNull String resource,
@NonNull List<Pair<String, String>> params, @NonNull List<Pair<String, String>> headers) throws IOException {
HttpURLConnection httpURLConnection = null;
try {
URL url = new URL(
service + "/" + Uri.encode(resource) + (params.isEmpty() ? "" : "&" + convertPairToParamString(params)));
public class GifImageView extends ImageView {
private static final long DEFAULT_MOVIE_VIEW_DURATION = TimeUnit.SECONDS.toMillis(1);
private Movie movie;
private long movieStart;
private int movieCurrentAnimationTime;
private boolean running = false;
private boolean visible = true;
@hector6872
hector6872 / DRMVPFrameLayoutView.java
Last active November 29, 2024 12:05
DRMVPFrameLayoutView example for DaRealMVP library - https://github.com/hector6872/DaRealMVP
public abstract class DRMVPFrameLayoutView<P extends DRMVPPresenter<V>, V extends DRMVPView> extends FrameLayout {
private P presenter;
public DRMVPFrameLayoutView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public DRMVPFrameLayoutView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();