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 fun saveImageToStorage() { | |
try { | |
val uri: Uri? | |
val fileName = "Screenshot_${Calendar.getInstance().time}.jpg" | |
val imageOutStream: OutputStream? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { | |
val values = ContentValues() | |
values.put(MediaStore.Images.Media.DISPLAY_NAME, fileName) | |
values.put(MediaStore.Images.Media.MIME_TYPE, "image/*") | |
values.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES) | |
uri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values) |
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
// original link : https://androidexplained.github.io/android/android11/scoped-storage/2020/09/29/file-saving-android-11.html | |
private fun openDocumentToSavePDF() { | |
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply { | |
addCategory(Intent.CATEGORY_OPENABLE) | |
type = "application/pdf" | |
val fileName = "Screenshot_${Calendar.getInstance().time}.pdf" | |
putExtra(Intent.EXTRA_TITLE, fileName) | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.DIRECTORY_DOCUMENTS) |
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
// Get external storage public directory file path | |
// original thread https://stackoverflow.com/questions/61406818/filenotfoundexception-open-failed-eperm-operation-not-permitted-during-saving | |
ContextWrapper cw = new ContextWrapper(mContext); | |
String fullPath = cw.getExternalFilesDir(Environment.DIRECTORY_MUSIC).toString(); | |
File directory = cw.getExternalFilesDir(Environment.DIRECTORY_MUSIC); |
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
// add this line in defaultConfig | |
ndk { | |
abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a' , 'arm64-v8a' | |
} |
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
package com.rahul.android.material.support.views; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.drawable.GradientDrawable; | |
import android.os.Build; | |
import android.util.AttributeSet; | |
import androidx.annotation.NonNull; | |
import androidx.annotation.Nullable; |
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 void setThemeTransparentBar(AppCompatActivity activity, AppBarLayout appBarLayout, Toolbar toolbar, RecyclerView recyclerView) { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
if (appBarLayout == null || toolbar == null || recyclerView == null) return; | |
int color = ContextCompat.getColor(activity.getApplicationContext(), R.color.bar_transparent); | |
appBarLayout.setBackgroundColor(color); | |
toolbar.setBackgroundColor(Color.TRANSPARENT); |
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.graphics.* | |
import androidx.core.graphics.ColorUtils | |
import androidx.exifinterface.media.ExifInterface | |
import java.io.File | |
import java.nio.ByteBuffer | |
import java.nio.ByteOrder | |
abstract class ImageUtils { | |
companion object { |
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
/* | |
To remove Webview inflation error | |
*/ | |
public class MyWebView extends WebView { | |
public MyWebView(Context context) { | |
super(getFixedContext(context)); | |
} | |
public MyWebView(Context context, AttributeSet attrs) { | |
super(getFixedContext(context), attrs); |
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
Material Desing for Android | |
https://dev.materialdesignicons.com/getting-started/android | |
Github : https://github.com/code-mc/material-icon-lib |
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
// TODO call this method in AspectRation item clicked. where original size aspect ration is 0 | |
private void resetCropView(){ | |
mGestureCropImageView.postRotate(-mGestureCropImageView.getCurrentAngle()); | |
mGestureCropImageView.zoomInImage(mGestureCropImageView.getMinScale()); | |
} |