Skip to content

Instantly share code, notes, and snippets.

package su.whs.watl_issue_029;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@suwhs
suwhs / gist:fd046416544fee5180a723f338ac4454
Last active January 7, 2017 07:15
Preload hyphenation patterns
new AsyncTask<Void,Void,Void>() {
@Override
protected void onPreExecute() {
// set application state 'rules loading', if nesessary (or do something else)
}
@Override
protected Void doInBackground(Void... params) {
/** loading patterns from assets **/
@suwhs
suwhs / additional_bidirectional_paragraph_split.java
Created September 17, 2016 13:00
Split bidirectional text to avoid mixed ltr/rtl lines (workaround for wATL 1.2.1)
public Spanned workaround(CharSequence string) {
SpannableStringBuilder ssb = new SpannableStringBuilder(string);
Bidi bidi = new Bidi(string.toString(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
List<Integer> inserts = new ArrayList<Integer>();
if (bidi.isMixed()) {
for (int run = 0; run < bidi.getRunCount(); run++) {
int end = bidi.getRunLimit(run);
inserts.add(end);
}
Collections.reverse(inserts);
@suwhs
suwhs / HyphenationRulesDownloader.java
Created December 3, 2015 10:18
hyphenation rules downloiader
package ....;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@suwhs
suwhs / NotificationService.java
Created November 5, 2015 18:59
Android: Catch Other Apps Notifcations With Accessibility Service
package su.whs.notifications;
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Notification;
import android.view.accessibility.AccessibilityEvent;
public class NotificationService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
@suwhs
suwhs / AssetGifDrawable.java
Created September 3, 2015 21:58
LazyDrawable - abstract class with support preview and full drawable loading on demand, AssetGifDrawable - example implementation that show animated gif, and required classes
/*
* Copyright 2015 whs.su
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@suwhs
suwhs / gradle.md
Last active January 4, 2021 22:17
5 steps for bintray-upload build.gradle (for jcenter)

add bintray and maven plugin to buildscript dependencies (project's build.gradle)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.2'
 classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' // ADD THIS LINE