This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getVersionCode(Context ctx) { | |
int versionCode = 0; | |
try { | |
PackageInfo pInfo = ctx.getPackageManager().getPackageInfo( | |
ctx.getPackageName(), 0); | |
versionCode = pInfo.versionCode; | |
} catch (PackageManager.NameNotFoundException e) { | |
e.printStackTrace(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getDeviceUniqueId(Context ctx) { | |
return Settings.Secure.getString(ctx.getContentResolver(), | |
Settings.Secure.ANDROID_ID); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void hideKeyboards(Activity activity) { | |
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService | |
(Activity.INPUT_METHOD_SERVICE); | |
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); | |
} | |
public static void showKeyboard(Activity activity) { | |
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context | |
.INPUT_METHOD_SERVICE); | |
imm.toggleSoftInput(0, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This method helps getting the right langauage ISO code, which suppose to be | |
* according to ISO-639-1, BUT, on some devices it still returns the deprecated ISO-639. | |
* <BR> | |
* Languages codes that are translated in this method: | |
* <ul> | |
* <li>Hebrew: IW -> HE | |
* <li>Indonesian: IN -> ID | |
* <li>Yiddish: JI -> YI | |
* </ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class UnbindingHelper { | |
/** | |
* Removes the reference to the activity from every view in a view hierarchy (listeners, | |
* images etc.). | |
* This method should be called in the onDestroy() method of each activity | |
* | |
* @param viewID normally the id of the root layout | |
* <p/> | |
* see http://code.google.com/p/android/issues/detail?id=8488 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void activateStrictModeFull(){ | |
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() | |
.detectAll() | |
.penaltyLog() | |
.build()); | |
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() | |
.detectAll() | |
.penaltyLog() | |
.build()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.provider.Settings; | |
import android.util.Base64; | |
import javax.crypto.Cipher; | |
import javax.crypto.SecretKey; | |
import javax.crypto.SecretKeyFactory; | |
import javax.crypto.spec.PBEKeySpec; | |
import javax.crypto.spec.PBEParameterSpec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.0' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ignoring all of the external "org" libraries | |
# (for example org.apache & org.jackson) | |
-keep class org.** { *; } | |
-dontwarn org.** | |
# Have more? Simply add them like the one above, | |
# and change to the desired package name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
defaultConfig { | |
... | |
// Fetch the version according to git latest tag and "how far are we from last tag" | |
def longVersionName = "git -C ${rootDir} describe --tags --long".execute().text.trim() | |
def (fullVersionTag, versionBuild, gitSha) = longVersionName.tokenize('-') | |
def(versionMajor, versionMinor, versionPatch) = fullVersionTag.tokenize('.') | |
// Set the version name | |
versionName "$versionMajor.$versionMinor.$versionPatch($versionBuild)" |
OlderNewer