Skip to content

Instantly share code, notes, and snippets.

@messenger63
messenger63 / get_commit_mesages.sh
Last active April 11, 2024 13:14
Script for release notes, that check if last commit was merge, then join all messages; otherwise takes just last commit message
#!/bin/bash
# Check if the last commit is a merge commit
# by getting commit parents (for merge there would be two parents)
if [[ $(git log --format=%P -n 1 | wc -w) -gt 1 ]]; then
LAST_COMMIT=$(git rev-parse HEAD)
MERGE_HASHES=$(git log --pretty=format:%H $LAST_COMMIT~...$LAST_COMMIT)
COMMIT_MESSAGE=""
# Loop through each merge commit and extract messages
import android.annotation.TargetApi;
import android.app.Service;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputType;
import android.text.TextWatcher;
@messenger63
messenger63 / getColoredDrawable
Created April 1, 2016 09:46
getColoredDrawable
public static Drawable getColoredDrawable(@NonNull Context context, @DrawableRes int drawableRes,
@ColorRes int colorRes) {
Drawable drawable = ContextCompat.getDrawable(context, drawableRes);
int color = ContextCompat.getColor(context, colorRes);
Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(wrappedDrawable, color);
return wrappedDrawable;
}
@messenger63
messenger63 / gist:60cc556042111368d95d
Created December 10, 2015 14:09
Colored Drawable with filter
Drawable img = ContextCompat.getDrawable(mContext, item.getTimerImage());
img.setColorFilter(ContextCompat.getColor(mContext, R.color.white), PorterDuff.Mode.SRC_ATOP);
@messenger63
messenger63 / gist:73d3f9842b162256457f
Created October 21, 2015 10:34
Autoscale text for textview
import android.content.Context;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.TextView;
/**
* Text view that auto adjusts text size to fit within the view.
@messenger63
messenger63 / gist:c8c10f596ffae5f3aa5d
Created September 25, 2015 09:55
Spinner with "select one" as default
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
if (position == getCount()) {
((TextView)v.findViewById(android.R.id.text1)).setText("");
((TextView)v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
}
@messenger63
messenger63 / gist:10d8021af3a2208bb90e
Created September 21, 2015 15:03
Show decimal only for appropriate numbers (1.23 or 2)
double d1 = 1.234567;
double d2 = 2;
NumberFormat nf = new DecimalFormat("##.###");
System.out.println(nf.format(d1));
System.out.println(nf.format(d2));
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
@messenger63
messenger63 / vertical view pager
Created March 25, 2015 12:41
vertical view pager
package com.nix.betavest.activities;
/**
* Created by vlevytskyy on 18.03.2015.
*/
import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
@messenger63
messenger63 / gist:b30c40b1bbf43bb66eee
Created February 12, 2015 15:00
Tile view with same size views
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@android:color/transparent"
android:padding="5dp"
android:id="@+id/status"
android:orientation="horizontal"
android:visibility="visible"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow