From 3ec6bd3a94ddbd3907410db1d9d1f329869684c3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 6 Nov 2016 16:35:45 +0100 Subject: [PATCH] convert utils to kotlin --- .../com/simplemobiletools/gallery/Utils.java | 153 ------------------ .../com/simplemobiletools/gallery/Utils.kt | 139 ++++++++++++++++ .../gallery/activities/MainActivity.java | 16 +- .../gallery/activities/MediaActivity.java | 10 +- .../activities/PhotoVideoActivity.java | 6 +- .../gallery/activities/ViewPagerActivity.java | 34 ++-- .../gallery/fragments/PhotoFragment.java | 2 +- .../gallery/fragments/VideoFragment.java | 4 +- 8 files changed, 175 insertions(+), 189 deletions(-) delete mode 100644 app/src/main/java/com/simplemobiletools/gallery/Utils.java create mode 100644 app/src/main/java/com/simplemobiletools/gallery/Utils.kt diff --git a/app/src/main/java/com/simplemobiletools/gallery/Utils.java b/app/src/main/java/com/simplemobiletools/gallery/Utils.java deleted file mode 100644 index e251b1b5b..000000000 --- a/app/src/main/java/com/simplemobiletools/gallery/Utils.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.simplemobiletools.gallery; - -import android.Manifest; -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.res.Resources; -import android.database.Cursor; -import android.net.Uri; -import android.os.Build; -import android.provider.MediaStore; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.view.Display; -import android.view.KeyCharacterMap; -import android.view.KeyEvent; -import android.view.View; -import android.view.ViewConfiguration; -import android.view.Window; -import android.webkit.MimeTypeMap; -import android.widget.Toast; - -import com.simplemobiletools.gallery.models.Medium; - -import java.io.File; - -public class Utils { - public static String getFilename(final String path) { - return path.substring(path.lastIndexOf("/") + 1); - } - - public static void showToast(Context context, int resId) { - Toast.makeText(context, context.getResources().getString(resId), Toast.LENGTH_SHORT).show(); - } - - public static int getActionBarHeight(Context context, Resources res) { - final TypedValue tv = new TypedValue(); - int height = 0; - if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { - height = TypedValue.complexToDimensionPixelSize(tv.data, res.getDisplayMetrics()); - } - return height; - } - - public static int getStatusBarHeight(Resources res) { - int id = res.getIdentifier("status_bar_height", "dimen", "android"); - if (id > 0) { - return res.getDimensionPixelSize(id); - } - return 0; - } - - public static int getNavBarHeight(Resources res) { - int id = res.getIdentifier("navigation_bar_height", "dimen", "android"); - if (id > 0) { - return res.getDimensionPixelSize(id); - } - return 0; - } - - public static boolean hasNavBar(Activity act) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - Display display = act.getWindowManager().getDefaultDisplay(); - - DisplayMetrics realDisplayMetrics = new DisplayMetrics(); - display.getRealMetrics(realDisplayMetrics); - - int realHeight = realDisplayMetrics.heightPixels; - int realWidth = realDisplayMetrics.widthPixels; - - DisplayMetrics displayMetrics = new DisplayMetrics(); - display.getMetrics(displayMetrics); - - int displayHeight = displayMetrics.heightPixels; - int displayWidth = displayMetrics.widthPixels; - - return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0; - } else { - boolean hasMenuKey = ViewConfiguration.get(act).hasPermanentMenuKey(); - boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); - return !hasMenuKey && !hasBackKey; - } - } - - public static boolean hasStoragePermission(Context cxt) { - return ContextCompat.checkSelfPermission(cxt, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; - } - - public static String getMimeType(String url) { - final String extension = MimeTypeMap.getFileExtensionFromUrl(url); - if (extension != null) { - return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); - } - return ""; - } - - public static void shareMedium(Medium medium, Activity activity) { - final String shareTitle = activity.getResources().getString(R.string.share_via); - final Intent intent = new Intent(); - final File file = new File(medium.getPath()); - final Uri uri = Uri.fromFile(file); - intent.setAction(Intent.ACTION_SEND); - intent.putExtra(Intent.EXTRA_STREAM, uri); - intent.setType(getMimeType(medium)); - activity.startActivity(Intent.createChooser(intent, shareTitle)); - } - - public static String getMimeType(Medium medium) { - if (medium.getIsVideo()) - return "video/*"; - else - return "image/*"; - } - - public static void showSystemUI(ActionBar actionbar, Window window) { - if (actionbar != null) - actionbar.show(); - - window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } - - public static void hideSystemUI(ActionBar actionbar, Window window) { - if (actionbar != null) - actionbar.hide(); - - window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | - View.SYSTEM_UI_FLAG_LOW_PROFILE | - View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_IMMERSIVE); - } - - public static String getRealPathFromURI(Context context, Uri uri) { - Cursor cursor = null; - try { - String[] projection = {MediaStore.Images.Media.DATA}; - cursor = context.getContentResolver().query(uri, projection, null, null, null); - int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); - cursor.moveToFirst(); - return cursor.getString(index); - } finally { - if (cursor != null) { - cursor.close(); - } - } - } -} diff --git a/app/src/main/java/com/simplemobiletools/gallery/Utils.kt b/app/src/main/java/com/simplemobiletools/gallery/Utils.kt new file mode 100644 index 000000000..004f29b7e --- /dev/null +++ b/app/src/main/java/com/simplemobiletools/gallery/Utils.kt @@ -0,0 +1,139 @@ +package com.simplemobiletools.gallery + +import android.Manifest +import android.app.Activity +import android.content.Context +import android.content.Intent +import android.content.pm.PackageManager +import android.content.res.Resources +import android.database.Cursor +import android.net.Uri +import android.os.Build +import android.provider.MediaStore +import android.support.v4.content.ContextCompat +import android.support.v7.app.ActionBar +import android.util.DisplayMetrics +import android.util.TypedValue +import android.view.* +import android.webkit.MimeTypeMap +import android.widget.Toast +import com.simplemobiletools.gallery.models.Medium +import java.io.File + +class Utils { + companion object { + fun getFilename(path: String): String { + return path.substring(path.lastIndexOf("/") + 1) + } + + fun showToast(context: Context, resId: Int) { + Toast.makeText(context, context.resources.getString(resId), Toast.LENGTH_SHORT).show() + } + + fun getActionBarHeight(context: Context, res: Resources): Int { + val tv = TypedValue() + var height = 0 + if (context.theme.resolveAttribute(android.R.attr.actionBarSize, tv, true)) { + height = TypedValue.complexToDimensionPixelSize(tv.data, res.displayMetrics) + } + return height + } + + fun getStatusBarHeight(res: Resources): Int { + val id = res.getIdentifier("status_bar_height", "dimen", "android") + return if (id > 0) { + res.getDimensionPixelSize(id) + } else + 0 + } + + fun getNavBarHeight(res: Resources): Int { + val id = res.getIdentifier("navigation_bar_height", "dimen", "android") + return if (id > 0) { + res.getDimensionPixelSize(id) + } else + 0 + } + + fun hasNavBar(act: Activity): Boolean { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + val display = act.windowManager.defaultDisplay + + val realDisplayMetrics = DisplayMetrics() + display.getRealMetrics(realDisplayMetrics) + + val realHeight = realDisplayMetrics.heightPixels + val realWidth = realDisplayMetrics.widthPixels + + val displayMetrics = DisplayMetrics() + display.getMetrics(displayMetrics) + + val displayHeight = displayMetrics.heightPixels + val displayWidth = displayMetrics.widthPixels + + realWidth - displayWidth > 0 || realHeight - displayHeight > 0 + } else { + val hasMenuKey = ViewConfiguration.get(act).hasPermanentMenuKey() + val hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK) + !hasMenuKey && !hasBackKey + } + } + + fun hasStoragePermission(cxt: Context): Boolean { + return ContextCompat.checkSelfPermission(cxt, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED + } + + fun getMimeType(url: String): String { + val extension = MimeTypeMap.getFileExtensionFromUrl(url) + return if (extension != null) { + MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) + } else + "" + } + + fun shareMedium(medium: Medium, activity: Activity) { + val shareTitle = activity.resources.getString(R.string.share_via) + val intent = Intent() + val file = File(medium.path) + val uri = Uri.fromFile(file) + intent.action = Intent.ACTION_SEND + intent.putExtra(Intent.EXTRA_STREAM, uri) + intent.type = getMimeType(medium) + activity.startActivity(Intent.createChooser(intent, shareTitle)) + } + + fun getMimeType(medium: Medium) = if (medium.isVideo) "video/*" else "image/*" + + fun showSystemUI(actionbar: ActionBar?, window: Window) { + actionbar?.show() + + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + } + + fun hideSystemUI(actionbar: ActionBar?, window: Window) { + actionbar?.hide() + + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or + View.SYSTEM_UI_FLAG_LOW_PROFILE or + View.SYSTEM_UI_FLAG_FULLSCREEN or + View.SYSTEM_UI_FLAG_IMMERSIVE + } + + fun getRealPathFromURI(context: Context, uri: Uri): String { + var cursor: Cursor? = null + try { + val projection = arrayOf(MediaStore.Images.Media.DATA) + cursor = context.contentResolver.query(uri, projection, null, null, null) + val index = cursor!!.getColumnIndexOrThrow(MediaStore.Images.Media.DATA) + cursor.moveToFirst() + return cursor.getString(index) + } finally { + cursor?.close() + } + } + } +} diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index 1520a9990..253aa3447 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -148,7 +148,7 @@ public class MainActivity extends SimpleActivity } private void tryloadGallery() { - if (Utils.hasStoragePermission(getApplicationContext())) { + if (Utils.Companion.hasStoragePermission(getApplicationContext())) { getDirectories(); } else { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, STORAGE_PERMISSION); @@ -163,7 +163,7 @@ public class MainActivity extends SimpleActivity if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { getDirectories(); } else { - Utils.showToast(getApplicationContext(), R.string.no_permissions); + Utils.Companion.showToast(getApplicationContext(), R.string.no_permissions); finish(); } } @@ -183,7 +183,7 @@ public class MainActivity extends SimpleActivity } private void prepareForDeleting() { - Utils.showToast(this, R.string.deleting); + Utils.Companion.showToast(this, R.string.deleting); final SparseBooleanArray items = mGridView.getCheckedItemPositions(); final int cnt = items.size(); int deletedCnt = 0; @@ -307,7 +307,7 @@ public class MainActivity extends SimpleActivity final String newDirName = dirNameET.getText().toString().trim(); if (newDirName.isEmpty()) { - Utils.showToast(getApplicationContext(), R.string.rename_folder_empty); + Utils.Companion.showToast(getApplicationContext(), R.string.rename_folder_empty); return; } @@ -316,7 +316,7 @@ public class MainActivity extends SimpleActivity final File newDir = new File(dir.getParent(), newDirName); if (dir.renameTo(newDir)) { - Utils.showToast(getApplicationContext(), R.string.renaming_folder); + Utils.Companion.showToast(getApplicationContext(), R.string.renaming_folder); alertDialog.dismiss(); mActionMode.finish(); @@ -335,7 +335,7 @@ public class MainActivity extends SimpleActivity } }); } else { - Utils.showToast(getApplicationContext(), R.string.rename_folder_error); + Utils.Companion.showToast(getApplicationContext(), R.string.rename_folder_error); } } }); @@ -404,7 +404,7 @@ public class MainActivity extends SimpleActivity final String path = data.getData().getPath(); final Uri uri = Uri.fromFile(new File(path)); if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) { - final String type = Utils.getMimeType(path); + final String type = Utils.Companion.getMimeType(path); result.setDataAndTypeAndNormalize(uri, type); result.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } else if (mIsPickImageIntent || mIsPickVideoIntent) { @@ -556,7 +556,7 @@ public class MainActivity extends SimpleActivity runOnUiThread(new Runnable() { @Override public void run() { - Utils.showToast(getApplicationContext(), R.string.rename_folder_ok); + Utils.Companion.showToast(getApplicationContext(), R.string.rename_folder_ok); } }); } diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java index 4b421ae32..f9e5ffcb8 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java @@ -100,7 +100,7 @@ public class MediaActivity extends SimpleActivity } private void tryloadGallery() { - if (Utils.hasStoragePermission(getApplicationContext())) { + if (Utils.Companion.hasStoragePermission(getApplicationContext())) { initializeGallery(); } else { finish(); @@ -124,7 +124,7 @@ public class MediaActivity extends SimpleActivity mGridView.setOnTouchListener(this); mIsSnackbarShown = false; - final String dirName = Utils.getFilename(mPath); + final String dirName = Utils.Companion.getFilename(mPath); setTitle(dirName); } @@ -257,7 +257,7 @@ public class MediaActivity extends SimpleActivity private void shareMedia() { final List selectedMedia = getSelectedMedia(); if (selectedMedia.size() <= 1) { - Utils.shareMedium(selectedMedia.get(0), this); + Utils.Companion.shareMedium(selectedMedia.get(0), this); } else { shareMedia(selectedMedia); } @@ -292,7 +292,7 @@ public class MediaActivity extends SimpleActivity } private void prepareForDeleting() { - Utils.showToast(this, R.string.deleting); + Utils.Companion.showToast(this, R.string.deleting); final SparseBooleanArray items = mGridView.getCheckedItemPositions(); final int cnt = items.size(); int deletedCnt = 0; @@ -393,7 +393,7 @@ public class MediaActivity extends SimpleActivity public void onItemClick(AdapterView parent, View view, int position, long id) { final String curItemPath = mMedia.get(position).getPath(); if (isSetWallpaperIntent()) { - Utils.showToast(this, R.string.setting_wallpaper); + Utils.Companion.showToast(this, R.string.setting_wallpaper); final int wantedWidth = getWallpaperDesiredMinimumWidth(); final int wantedHeight = getWallpaperDesiredMinimumHeight(); diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java index b83179c28..4e7d587be 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java @@ -52,7 +52,7 @@ public class PhotoVideoActivity extends SimpleActivity implements ViewPagerFragm getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, mFragment).commit(); } hideSystemUI(); - setTitle(Utils.getFilename(mUri.toString())); + setTitle(Utils.Companion.getFilename(mUri.toString())); } @Override @@ -98,10 +98,10 @@ public class PhotoVideoActivity extends SimpleActivity implements ViewPagerFragm } private void hideSystemUI() { - Utils.hideSystemUI(mActionbar, getWindow()); + Utils.Companion.hideSystemUI(mActionbar, getWindow()); } private void showSystemUI() { - Utils.showSystemUI(mActionbar, getWindow()); + Utils.Companion.showSystemUI(mActionbar, getWindow()); } } diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index 2b9429ba6..446ebef0f 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -63,7 +63,7 @@ public class ViewPagerActivity extends SimpleActivity setContentView(R.layout.activity_medium); ButterKnife.bind(this); - if (!Utils.hasStoragePermission(getApplicationContext())) { + if (!Utils.Companion.hasStoragePermission(getApplicationContext())) { finish(); return; } @@ -89,7 +89,7 @@ public class ViewPagerActivity extends SimpleActivity } if (mPath == null || mPath.isEmpty()) { - Utils.showToast(getApplicationContext(), R.string.unknown_error); + Utils.Companion.showToast(getApplicationContext(), R.string.unknown_error); finish(); return; } @@ -121,7 +121,7 @@ public class ViewPagerActivity extends SimpleActivity @Override protected void onResume() { super.onResume(); - if (!Utils.hasStoragePermission(getApplicationContext())) { + if (!Utils.Companion.hasStoragePermission(getApplicationContext())) { finish(); } } @@ -188,7 +188,7 @@ public class ViewPagerActivity extends SimpleActivity if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(chooser, EDIT_IMAGE); } else { - Utils.showToast(getApplicationContext(), R.string.no_editor_found); + Utils.Companion.showToast(getApplicationContext(), R.string.no_editor_found); } } @@ -200,19 +200,19 @@ public class ViewPagerActivity extends SimpleActivity if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(chooser, SET_WALLPAPER); } else { - Utils.showToast(getApplicationContext(), R.string.no_wallpaper_setter_found); + Utils.Companion.showToast(getApplicationContext(), R.string.no_wallpaper_setter_found); } } private void openWith() { final Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(getCurrentFile()), Utils.getMimeType(getCurrentMedium())); + intent.setDataAndType(Uri.fromFile(getCurrentFile()), Utils.Companion.getMimeType(getCurrentMedium())); final Intent chooser = Intent.createChooser(intent, getString(R.string.open_with)); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(chooser); } else { - Utils.showToast(getApplicationContext(), R.string.no_app_found); + Utils.Companion.showToast(getApplicationContext(), R.string.no_app_found); } } @@ -229,7 +229,7 @@ public class ViewPagerActivity extends SimpleActivity } } else if (requestCode == SET_WALLPAPER) { if (resultCode == RESULT_OK) { - Utils.showToast(getApplicationContext(), R.string.wallpaper_set_successfully); + Utils.Companion.showToast(getApplicationContext(), R.string.wallpaper_set_successfully); } } super.onActivityResult(requestCode, resultCode, data); @@ -237,7 +237,7 @@ public class ViewPagerActivity extends SimpleActivity private void shareMedium() { final Medium medium = getCurrentMedium(); - Utils.shareMedium(medium, this); + Utils.Companion.shareMedium(medium, this); } private void notifyDeletion() { @@ -246,7 +246,7 @@ public class ViewPagerActivity extends SimpleActivity if (mMedia.size() <= 1) { deleteFile(); } else { - Utils.showToast(this, R.string.file_deleted); + Utils.Companion.showToast(this, R.string.file_deleted); mUndoBtn.setVisibility(View.VISIBLE); mIsUndoShown = true; reloadViewPager(); @@ -320,7 +320,7 @@ public class ViewPagerActivity extends SimpleActivity final String extension = extensionET.getText().toString().trim(); if (fileName.isEmpty() || extension.isEmpty()) { - Utils.showToast(getApplicationContext(), R.string.rename_file_empty); + Utils.Companion.showToast(getApplicationContext(), R.string.rename_file_empty); return; } @@ -335,7 +335,7 @@ public class ViewPagerActivity extends SimpleActivity updateActionbarTitle(); alertDialog.dismiss(); } else { - Utils.showToast(getApplicationContext(), R.string.rename_file_error); + Utils.Companion.showToast(getApplicationContext(), R.string.rename_file_error); } } }); @@ -425,15 +425,15 @@ public class ViewPagerActivity extends SimpleActivity } private void hideSystemUI() { - Utils.hideSystemUI(mActionbar, getWindow()); + Utils.Companion.hideSystemUI(mActionbar, getWindow()); } private void showSystemUI() { - Utils.showSystemUI(mActionbar, getWindow()); + Utils.Companion.showSystemUI(mActionbar, getWindow()); } private void updateActionbarTitle() { - setTitle(Utils.getFilename(mMedia.get(mPager.getCurrentItem()).getPath())); + setTitle(Utils.Companion.getFilename(mMedia.get(mPager.getCurrentItem()).getPath())); } private Medium getCurrentMedium() { @@ -449,11 +449,11 @@ public class ViewPagerActivity extends SimpleActivity private void addUndoMargin() { final Resources res = getResources(); final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mUndoBtn.getLayoutParams(); - final int topMargin = Utils.getStatusBarHeight(res) + Utils.getActionBarHeight(getApplicationContext(), res); + final int topMargin = Utils.Companion.getStatusBarHeight(res) + Utils.Companion.getActionBarHeight(getApplicationContext(), res); int rightMargin = params.rightMargin; if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT) { - rightMargin += Utils.getNavBarHeight(res); + rightMargin += Utils.Companion.getNavBarHeight(res); } params.setMargins(params.leftMargin, topMargin, rightMargin, params.bottomMargin); diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java index b05f8b537..45124346a 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/PhotoFragment.java @@ -26,7 +26,7 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList mMedium = (Medium) getArguments().getSerializable(Constants.MEDIUM); if (mMedium.getPath().startsWith("content://")) - mMedium.setPath(Utils.getRealPathFromURI(getContext(), Uri.parse(mMedium.getPath()))); + mMedium.setPath(Utils.Companion.getRealPathFromURI(getContext(), Uri.parse(mMedium.getPath()))); if (mMedium == null) return view; diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java index 43f27becc..7f729f0ea 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java @@ -121,13 +121,13 @@ public class VideoFragment extends ViewPagerFragment private void initTimeHolder() { mTimeHolder = mView.findViewById(R.id.video_time_holder); final Resources res = getResources(); - final int height = Utils.getNavBarHeight(res); + final int height = Utils.Companion.getNavBarHeight(res); final int left = mTimeHolder.getPaddingLeft(); final int top = mTimeHolder.getPaddingTop(); int right = (int) getResources().getDimension(R.dimen.timer_padding); int bottom = 0; - if (Utils.hasNavBar(getActivity())) { + if (Utils.Companion.hasNavBar(getActivity())) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { bottom += height; } else {