1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-22 04:12:08 +01:00

Re add metadata module

This commit is contained in:
Gregor Santner 2017-09-23 20:33:28 +02:00
parent fe4d646c47
commit bf6bdbd821
4 changed files with 36 additions and 13 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "metadata"]
path = metadata
url = https://github.com/diaspora-for-android/dandelion-metadata-latest.git

View file

@ -22,6 +22,7 @@ import android.text.Html;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; 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) { public void showSnackBar(@StringRes int stringResId, boolean showLong) {
Snackbar.make(_activity.findViewById(android.R.id.content), stringId, Snackbar.make(_activity.findViewById(android.R.id.content), stringResId,
showLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT).show(); 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() { public void hideSoftKeyboard() {
InputMethodManager inputMethodManager = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager inputMethodManager = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (_activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) { if (_activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) {

View file

@ -371,13 +371,13 @@ public class ContextUtils {
return bitmap; return bitmap;
} }
public Bitmap loadImageFromFilesystem(String imagePath, int maxDimen) { public Bitmap loadImageFromFilesystem(File imagePath, int maxDimen) {
BitmapFactory.Options options = new BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true; options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(imagePath, options); BitmapFactory.decodeFile(imagePath.getAbsolutePath(), options);
options.inSampleSize = calculateInSampleSize(options, maxDimen); options.inSampleSize = calculateInSampleSize(options, maxDimen);
options.inJustDecodeBounds = false; 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 * @return the scaling factor that needs to be applied to the bitmap
*/ */
public int calculateInSampleSize(BitmapFactory.Options options, int maxDimen) { 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 height = options.outHeight;
int width = options.outWidth; int width = options.outWidth;
int inSampleSize = 1; int inSampleSize = 1;
@ -407,18 +407,29 @@ public class ContextUtils {
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
} }
public File writeImageToFileJpeg(String path, String filename, Bitmap image) { public File writeImageToFileJpeg(File imageFile, Bitmap image) {
return writeImageToFile(path, filename, image, Bitmap.CompressFormat.JPEG, 95); 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; FileOutputStream stream = null;
try { try {
stream = new FileOutputStream(imageFile); // overwrites this image every time stream = new FileOutputStream(imageFile); // overwrites this conf every time
image.compress(format, quality, stream); image.compress(format, quality, stream);
return imageFile; return imageFile;
} catch (FileNotFoundException ignored) { } catch (FileNotFoundException ignored) {

1
metadata Submodule

@ -0,0 +1 @@
Subproject commit 0f83b91174b5dc0eb72479fd0d63e5e7c0bd40cc