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
final ImageView imageView = (ImageView) findViewById(R.id.imageView); | |
final Matrix matrix = imageView.getImageMatrix(); | |
final float imageWidth = imageView.getDrawable().getIntrinsicWidth(); | |
final int screenWidth = getResources().getDisplayMetrics().widthPixels; | |
final float scaleRatio = screenWidth / imageWidth; | |
matrix.postScale(scaleRatio, scaleRatio); | |
imageView.setImageMatrix(matrix); |
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
if (file.getPath().endsWith(".apk")) { | |
String filePath = file.getPath(); | |
PackageInfo packageInfo = context.getPackageManager().getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES); | |
if(packageInfo != null) { | |
ApplicationInfo appInfo = packageInfo.applicationInfo; | |
if (Build.VERSION.SDK_INT >= 8) { | |
appInfo.sourceDir = filePath; | |
appInfo.publicSourceDir = filePath; | |
} | |
Drawable icon = appInfo.loadIcon(context.getPackageManager()); |
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
if (file.getPath().endsWith(".apk")) { | |
String filePath = file.getPath(); | |
PackageInfo packageInfo = context.getPackageManager().getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES); | |
if(packageInfo != null) { | |
ApplicationInfo appInfo = packageInfo.applicationInfo; | |
if (Build.VERSION.SDK_INT >= 8) { | |
appInfo.sourceDir = filePath; | |
appInfo.publicSourceDir = filePath; | |
} | |
Drawable icon = appInfo.loadIcon(context.getPackageManager()); |
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
if (file.getPath().endsWith(".apk")) { | |
String filePath = file.getPath(); | |
PackageInfo packageInfo = context.getPackageManager().getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES); | |
if(packageInfo != null) { | |
ApplicationInfo appInfo = packageInfo.applicationInfo; | |
if (Build.VERSION.SDK_INT >= 8) { | |
appInfo.sourceDir = filePath; | |
appInfo.publicSourceDir = filePath; | |
} | |
Drawable icon = appInfo.loadIcon(context.getPackageManager()); |
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
if (file.getPath().endsWith(".apk")) { | |
String filePath = file.getPath(); | |
PackageInfo packageInfo = context.getPackageManager().getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES); | |
if(packageInfo != null) { | |
ApplicationInfo appInfo = packageInfo.applicationInfo; | |
if (Build.VERSION.SDK_INT >= 8) { | |
appInfo.sourceDir = filePath; | |
appInfo.publicSourceDir = filePath; | |
} | |
Drawable icon = appInfo.loadIcon(context.getPackageManager()); |
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
int statusBarHeight = (int) Math.ceil(25 * getResources().getDisplayMetrics().density); | |
View statusBarView = new View(MyActivity.this); | |
statusBarView.setBackgroundColor(Color.GREEN); | |
WindowManager.LayoutParams params = null; | |
params = new WindowManager.LayoutParams(WindowManager.LayoutParams.FILL_PARENT,statusBarHeight,WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, PixelFormat.TRANSLUCENT); | |
params.gravity = Gravity.RIGHT | Gravity.TOP; | |
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); |
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
private void testBackupFile() throws IOException { | |
File file = new File("/data/app/fq.router2-2.apk"); | |
if (file.exists()) { | |
Log.d("command", "get file"); | |
File dir = new File("/sdcard/mikeBackUp"); | |
if (!dir.exists()) { | |
dir.mkdirs(); | |
} | |
copyFile(file, new File(dir, "FqRouter.apk")); |
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 Bitmap viewToBitmap(View view) { | |
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), | |
Bitmap.Config.ARGB_8888); | |
Canvas canvas = new Canvas(bitmap); | |
view.draw(canvas); | |
return bitmap; | |
} |
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
private Uri outputFileUri; | |
private final int FROM_CHOOSER = 0; | |
private final int FROM_CAMERA = 1; | |
private final int FROM_FILE = 2; | |
private void openImageIntent(int from) { | |
// Determine Uri of camera image to save. | |
final File root = new File(Environment.getExternalStorageDirectory() | |
+ File.separator + getString(R.string.app_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
def appendVersionNameVersionCode(variant, defaultConfig) { | |
//check if staging variant | |
if(variant.name == android.buildTypes.staging.name){ | |
if(variant.zipAlign) { | |
def file = variant.outputFile | |
def fileName = file.name.replace(".apk", "-" + defaultConfig.versionName + "-" + defaultConfig.versionCode + ".apk") | |
variant.outputFile = new File(file.parent, fileName) | |
} | |
def file = variant.packageApplication.outputFile |
NewerOlder