mirror of
https://github.com/gsantner/dandelion
synced 2024-12-22 10:58:01 +01:00
Re add metadata module
This commit is contained in:
parent
fe4d646c47
commit
bf6bdbd821
4 changed files with 36 additions and 13 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "metadata"]
|
||||
path = metadata
|
||||
url = https://github.com/diaspora-for-android/dandelion-metadata-latest.git
|
|
@ -22,6 +22,7 @@ import android.text.Html;
|
|||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
|
@ -76,11 +77,18 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils {
|
|||
}
|
||||
|
||||
|
||||
public void showSnackBar(@StringRes int stringId, boolean showLong) {
|
||||
Snackbar.make(_activity.findViewById(android.R.id.content), stringId,
|
||||
public void showSnackBar(@StringRes int stringResId, boolean showLong) {
|
||||
Snackbar.make(_activity.findViewById(android.R.id.content), stringResId,
|
||||
showLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void showSnackBar(@StringRes int stringResId, boolean showLong, @StringRes int actionResId, View.OnClickListener listener) {
|
||||
Snackbar.make(_activity.findViewById(android.R.id.content), stringResId,
|
||||
showLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT)
|
||||
.setAction(actionResId, listener)
|
||||
.show();
|
||||
}
|
||||
|
||||
public void hideSoftKeyboard() {
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
if (_activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) {
|
||||
|
|
|
@ -371,13 +371,13 @@ public class ContextUtils {
|
|||
return bitmap;
|
||||
}
|
||||
|
||||
public Bitmap loadImageFromFilesystem(String imagePath, int maxDimen) {
|
||||
public Bitmap loadImageFromFilesystem(File imagePath, int maxDimen) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(imagePath, options);
|
||||
BitmapFactory.decodeFile(imagePath.getAbsolutePath(), options);
|
||||
options.inSampleSize = calculateInSampleSize(options, maxDimen);
|
||||
options.inJustDecodeBounds = false;
|
||||
return BitmapFactory.decodeFile(imagePath, options);
|
||||
return BitmapFactory.decodeFile(imagePath.getAbsolutePath(), options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,7 +388,7 @@ public class ContextUtils {
|
|||
* @return the scaling factor that needs to be applied to the bitmap
|
||||
*/
|
||||
public int calculateInSampleSize(BitmapFactory.Options options, int maxDimen) {
|
||||
// Raw height and width of image
|
||||
// Raw height and width of conf
|
||||
int height = options.outHeight;
|
||||
int width = options.outWidth;
|
||||
int inSampleSize = 1;
|
||||
|
@ -407,18 +407,29 @@ public class ContextUtils {
|
|||
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||
}
|
||||
|
||||
public File writeImageToFileJpeg(String path, String filename, Bitmap image) {
|
||||
return writeImageToFile(path, filename, image, Bitmap.CompressFormat.JPEG, 95);
|
||||
public File writeImageToFileJpeg(File imageFile, Bitmap image) {
|
||||
return writeImageToFile(imageFile, image, Bitmap.CompressFormat.JPEG, 95);
|
||||
}
|
||||
|
||||
public File writeImageToFile(String path, String filename, Bitmap image, CompressFormat format, int quality) {
|
||||
File imageFile = new File(path);
|
||||
if (imageFile.exists() || imageFile.mkdirs()) {
|
||||
imageFile = new File(path, filename);
|
||||
|
||||
public File writeImageToFileDetectFormat(File imageFile, Bitmap image, int quality) {
|
||||
CompressFormat format = CompressFormat.JPEG;
|
||||
String lc = imageFile.getAbsolutePath().toLowerCase();
|
||||
if (lc.endsWith(".png")) {
|
||||
format = CompressFormat.PNG;
|
||||
}
|
||||
if (lc.endsWith(".webp")) {
|
||||
format = CompressFormat.WEBP;
|
||||
}
|
||||
return writeImageToFile(imageFile, image, format, quality);
|
||||
}
|
||||
|
||||
public File writeImageToFile(File imageFile, Bitmap image, CompressFormat format, int quality) {
|
||||
File folder = new File(imageFile.getParent());
|
||||
if (folder.exists() || folder.mkdirs()) {
|
||||
FileOutputStream stream = null;
|
||||
try {
|
||||
stream = new FileOutputStream(imageFile); // overwrites this image every time
|
||||
stream = new FileOutputStream(imageFile); // overwrites this conf every time
|
||||
image.compress(format, quality, stream);
|
||||
return imageFile;
|
||||
} catch (FileNotFoundException ignored) {
|
||||
|
|
1
metadata
Submodule
1
metadata
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 0f83b91174b5dc0eb72479fd0d63e5e7c0bd40cc
|
Loading…
Reference in a new issue