Skip to content

Instantly share code, notes, and snippets.

View OSemenovBoyarka's full-sized avatar

Oleksandr Semenov OSemenovBoyarka

  • Bellum AI
  • Boyarka, Ukraine
View GitHub Profile
@OSemenovBoyarka
OSemenovBoyarka / AndroidEmulatorFastfile
Created March 28, 2017 09:05
Couple methods to launch required android emulator using fastlane
# Set of lanes for control android emulators
require 'open3'
platform :android do
# time in seconds, to wait until emulator will finish launching
emulator_launch_timeout = 600 # 10 mins should be more, than enough for any relevant configuration
desc "Starts needed emulator, given though 'device_name' option, kills all others and deletes all redundant apks"
private_lane :prepare_emulator do |options|
device_name = options[:device_name]
@OSemenovBoyarka
OSemenovBoyarka / SafeTypes.h
Created November 26, 2016 17:24
Set of functions for safe extraction of parsed values from JSON/XML dictionaries
//
// SafeTypes.h
//
// Contains functions for safe values extraction from id types
//
// Created by Alexs on 17.11.16.
//
/**
* Accepts string and return string itself if it's not nil and empty string otherwise
@OSemenovBoyarka
OSemenovBoyarka / version-increment.gradle
Last active January 5, 2016 14:15
android version auto-increment
android {
def versionPropsFile = file("version.properties")
if (!versionPropsFile.canRead()) {
throw new GradleException("Could not read version.properties, please, provide this file with VERSION_NUMBER parameter")
}
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def versionNumber = versionProps['VERSION_CODE'].toInteger()
defaultConfig {
@OSemenovBoyarka
OSemenovBoyarka / parse_xml.rb
Last active September 14, 2015 16:34
Deliverfile script parses app metadata from android-like strings.xml and sets up values for deliver tool from Fastlane
###### Simple script parses app metadata from android-like strings.xml and sets up values for deliver
###### You can always last version of this script at https://gist.github.com/SemenovAlexander/0b84606fa1439ebfe802
baseLanguage = "en-US"
# Selecting all subfolder names of metadata directory as available locales
supportedLanguages = Dir.entries('metadata').select {|entry| File.directory? File.join('metadata',entry) and !(entry =='.' || entry == '..') }
# Creating variables for fields in each language, with dummy stub for base language
titleHash = {
baseLanguage => ""
@OSemenovBoyarka
OSemenovBoyarka / android_rename.gradle
Last active January 30, 2017 15:48
build.gradle extension to rename all output apks to <name>-<version>-<version_code> template
android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
def filename = output.outputFile.name.replace(".apk", "-" + variant.versionName+"-"+variant.versionCode + ".apk")
//we should replace this only for release builds, because it cause bugs in development
if (filename.contains("release")){
output.outputFile = new File(getProject().getRootDir(),
"${getProject().getName()}${File.separator}apk${File.separator}${filename}")
}
}
@OSemenovBoyarka
OSemenovBoyarka / gist:18b3250329e37a3dfd38
Created June 27, 2014 07:09
Method starts logcat to save logs to sdcard in android. Remember to kill log process when it not needed anymore
public void createLog() {
File logFile = new File(Environment.getExternalStorageDirectory() + File.separator + "FILE_NAME.log");
if (!logFile.exists()) {
try {
logFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
@OSemenovBoyarka
OSemenovBoyarka / gist:c3ec6d23199a36560357
Last active August 29, 2015 14:03
Helper class, that allows to smoothly collapse and expand view vertically in Android
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Transformation;
/**
* Helper class, that allows to smoothly collapse and expand view vertically
*/
public class ExpandCollapseAnimatorUtils {