Skip to content

Instantly share code, notes, and snippets.

View martarodriguezm's full-sized avatar

Marta Rodriguez martarodriguezm

View GitHub Profile
@martarodriguezm
martarodriguezm / BorderedCircleTransformation.java
Last active September 17, 2018 11:17 — forked from berkkaraoglu/BorderedCircleTransform.java
BorderedCircleTransform for Picasso modified to pass borderColor and BorderRadius as input parameters
View BorderedCircleTransformation.java
package marta.rodriguez.transformations;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.v4.graphics.ColorUtils;
import com.squareup.picasso.Transformation;
@martarodriguezm
martarodriguezm / Android6SettingsPermissions.java
Created October 16, 2015 06:43
Code snippet to asko for system settings permission
View Android6SettingsPermissions.java
new AlertDialog.Builder(this)
.setMessage(R.string.write_settings_title)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
intent.setData(Uri.parse("package:" + getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
@martarodriguezm
martarodriguezm / Android6Permissions.java
Created October 16, 2015 06:19
Code snippet for the new Android 6 permissions
View Android6Permissions.java
private void checkWriteStoragePermission() {
//FROM AN ACTIVITY
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}
//FROM A FRAGMENT
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
FragmentCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}
View RestorePurchases.h
#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>
@interface RestorePurchases : UIViewController <SKProductsRequestDelegate, SKPaymentTransactionObserver, SKRequestDelegate, UIActionSheetDelegate>
@end
@martarodriguezm
martarodriguezm / CountryHelper.java
Last active August 29, 2015 14:26
Helper created for European Union regulation about cookies. It checks if android device is from one of the European Union countries to show the corresponding message.
View CountryHelper.java
import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;
import java.util.Arrays;
import java.util.Locale;
/**
* Created by marta on 29/7/15.
*/
@martarodriguezm
martarodriguezm / Google Play Api - Apk Upload.md
Last active October 28, 2021 00:15
This python script uploads an apk file into Google Play Store using Android Play Publisher API
View Google Play Api - Apk Upload.md

In Google Developer Console inside your app project, on the Credentials section, you must create a new "Service Account" "Client ID", if you have not already. And download the p12 file. You need the service account key file, generated in the Google APIs Console into the same directory and rename it to key.p12.

On Google Play Developer Console you have to give permissions to "YOUR_SERVICE_ACCOUNT_EMAIL@developer.gserviceaccount.com" for uploading apks.

Installation

Download Google APIs Client Library for Python (google-api-python-client): https://code.google.com/p/google-api-python-client/ or use pip:

$ pip install google-api-python-client
View MyApp.java
public class MyApp extends Application {
@Override
public void onCreate() {
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
}
}