mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 06:28:00 +01:00
fix #440, upgrade to Android Studio 3
This commit is contained in:
parent
932fc628a3
commit
add3760ed2
7 changed files with 57 additions and 60 deletions
|
@ -3,13 +3,13 @@ apply plugin: 'kotlin-android'
|
|||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "26.0.2"
|
||||
compileSdkVersion 27
|
||||
buildToolsVersion "27.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.simplemobiletools.gallery"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 26
|
||||
targetSdkVersion 27
|
||||
versionCode 142
|
||||
versionName "2.17.4"
|
||||
}
|
||||
|
@ -36,19 +36,22 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
leakCanaryVersion = '1.5.4'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.36.1'
|
||||
compile 'com.simplemobiletools:commons:2.37.1'
|
||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
|
||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
compile 'com.google.code.gson:gson:2.8.2'
|
||||
compile 'it.sephiroth.android.exif:library:1.0.1'
|
||||
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.8'
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
|
||||
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
|
||||
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
|
||||
debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
||||
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
|
||||
}
|
||||
|
||||
buildscript {
|
||||
|
|
|
@ -34,15 +34,15 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
|
|||
return fragment
|
||||
}
|
||||
|
||||
override fun getItemPosition(item: Any?) = PagerAdapter.POSITION_NONE
|
||||
override fun getItemPosition(item: Any) = PagerAdapter.POSITION_NONE
|
||||
|
||||
override fun instantiateItem(container: ViewGroup?, position: Int): Any {
|
||||
override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
||||
val fragment = super.instantiateItem(container, position) as ViewPagerFragment
|
||||
mFragments.put(position, fragment)
|
||||
return fragment
|
||||
}
|
||||
|
||||
override fun destroyItem(container: ViewGroup?, position: Int, any: Any?) {
|
||||
override fun destroyItem(container: ViewGroup, position: Int, any: Any) {
|
||||
mFragments.remove(position)
|
||||
super.destroyItem(container, position, any)
|
||||
}
|
||||
|
|
|
@ -53,31 +53,31 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
isFragmentVisible = true
|
||||
}
|
||||
|
||||
medium = arguments.getSerializable(MEDIUM) as Medium
|
||||
medium = arguments!!.getSerializable(MEDIUM) as Medium
|
||||
if (medium.path.startsWith("content://")) {
|
||||
val originalPath = medium.path
|
||||
medium.path = context.getRealPathFromURI(Uri.parse(originalPath)) ?: medium.path
|
||||
medium.path = context!!.getRealPathFromURI(Uri.parse(originalPath)) ?: medium.path
|
||||
|
||||
if (medium.path.isEmpty()) {
|
||||
var out: FileOutputStream? = null
|
||||
try {
|
||||
var inputStream = context.contentResolver.openInputStream(Uri.parse(originalPath))
|
||||
var inputStream = context!!.contentResolver.openInputStream(Uri.parse(originalPath))
|
||||
val exif = ExifInterface()
|
||||
exif.readExif(inputStream, ExifInterface.Options.OPTION_ALL)
|
||||
val tag = exif.getTag(ExifInterface.TAG_ORIENTATION)
|
||||
val orientation = tag?.getValueAsInt(-1) ?: -1
|
||||
inputStream = context.contentResolver.openInputStream(Uri.parse(originalPath))
|
||||
inputStream = context!!.contentResolver.openInputStream(Uri.parse(originalPath))
|
||||
val original = BitmapFactory.decodeStream(inputStream)
|
||||
val rotated = rotateViaMatrix(original, orientation)
|
||||
exif.setTagValue(ExifInterface.TAG_ORIENTATION, 1)
|
||||
exif.removeCompressedThumbnail()
|
||||
|
||||
val file = File(context.externalCacheDir, Uri.parse(originalPath).lastPathSegment)
|
||||
val file = File(context!!.externalCacheDir, Uri.parse(originalPath).lastPathSegment)
|
||||
out = FileOutputStream(file)
|
||||
rotated.compress(Bitmap.CompressFormat.JPEG, 100, out)
|
||||
medium.path = file.absolutePath
|
||||
} catch (e: Exception) {
|
||||
activity.toast(R.string.unknown_error_occurred)
|
||||
activity!!.toast(R.string.unknown_error_occurred)
|
||||
return view
|
||||
} finally {
|
||||
out?.close()
|
||||
|
@ -97,13 +97,13 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
storedShowExtendedDetails = context.config.showExtendedDetails
|
||||
storedExtendedDetails = context.config.extendedDetails
|
||||
storedShowExtendedDetails = context!!.config.showExtendedDetails
|
||||
storedExtendedDetails = context!!.config.extendedDetails
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (wasInit && (context.config.showExtendedDetails != storedShowExtendedDetails || context.config.extendedDetails != storedExtendedDetails)) {
|
||||
if (wasInit && (context!!.config.showExtendedDetails != storedShowExtendedDetails || context!!.config.extendedDetails != storedExtendedDetails)) {
|
||||
checkExtendedDetails()
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
private fun loadGif() {
|
||||
try {
|
||||
gifDrawable = if (medium.path.startsWith("content://") || medium.path.startsWith("file://")) {
|
||||
GifDrawable(context.contentResolver, Uri.parse(medium.path))
|
||||
GifDrawable(context!!.contentResolver, Uri.parse(medium.path))
|
||||
} else {
|
||||
GifDrawable(medium.path)
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
} else {
|
||||
val options = RequestOptions()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.transform(GlideRotateTransformation(context, degrees))
|
||||
.transform(GlideRotateTransformation(context!!, degrees))
|
||||
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
|
@ -271,9 +271,9 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
if (context == null)
|
||||
return 2f
|
||||
|
||||
return if (context.portrait && bitmapAspectRatio <= 1f) {
|
||||
return if (context!!.portrait && bitmapAspectRatio <= 1f) {
|
||||
ViewPagerActivity.screenHeight / height.toFloat()
|
||||
} else if (!context.portrait && bitmapAspectRatio >= 1f) {
|
||||
} else if (!context!!.portrait && bitmapAspectRatio >= 1f) {
|
||||
ViewPagerActivity.screenWidth / width.toFloat()
|
||||
} else {
|
||||
2f
|
||||
|
@ -286,7 +286,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
|
||||
private fun checkExtendedDetails() {
|
||||
if (context.config.showExtendedDetails) {
|
||||
if (context!!.config.showExtendedDetails) {
|
||||
view.photo_details.apply {
|
||||
text = getMediumExtendedDetails(medium)
|
||||
setTextColor(context.config.textColor)
|
||||
|
@ -305,8 +305,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
context.isKitkatPlus()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !activity.isDestroyed) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !activity!!.isDestroyed) {
|
||||
Glide.with(context).clear(view.gif_view)
|
||||
}
|
||||
}
|
||||
|
@ -331,9 +330,4 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshBitmap() {
|
||||
view.subsampling_view.beGone()
|
||||
loadBitmap()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
mView = inflater.inflate(R.layout.pager_video_item, container, false)
|
||||
mTimeHolder = mView.video_time_holder
|
||||
medium = arguments.getSerializable(MEDIUM) as Medium
|
||||
medium = arguments!!.getSerializable(MEDIUM) as Medium
|
||||
|
||||
// setMenuVisibility is not called at VideoActivity (third party intent)
|
||||
if (!mIsFragmentVisible && activity is VideoActivity) {
|
||||
|
@ -77,7 +77,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
mCurrTime = savedInstanceState.getInt(PROGRESS)
|
||||
}
|
||||
|
||||
mIsFullscreen = activity.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
mIsFullscreen = activity!!.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
checkFullscreen()
|
||||
wasInit = true
|
||||
|
||||
|
@ -86,11 +86,11 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity.updateTextColors(mView.video_holder)
|
||||
mView.video_volume_controller.beVisibleIf(context.config.allowVideoGestures)
|
||||
mView.video_brightness_controller.beVisibleIf(context.config.allowVideoGestures)
|
||||
activity!!.updateTextColors(mView.video_holder)
|
||||
mView.video_volume_controller.beVisibleIf(context!!.config.allowVideoGestures)
|
||||
mView.video_brightness_controller.beVisibleIf(context!!.config.allowVideoGestures)
|
||||
|
||||
if (context.config.showExtendedDetails != mStoredShowExtendedDetails || context.config.extendedDetails != mStoredExtendedDetails) {
|
||||
if (context!!.config.showExtendedDetails != mStoredShowExtendedDetails || context!!.config.extendedDetails != mStoredExtendedDetails) {
|
||||
checkExtendedDetails()
|
||||
}
|
||||
}
|
||||
|
@ -98,8 +98,8 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
override fun onPause() {
|
||||
super.onPause()
|
||||
pauseVideo()
|
||||
mStoredShowExtendedDetails = context.config.showExtendedDetails
|
||||
mStoredExtendedDetails = context.config.extendedDetails
|
||||
mStoredShowExtendedDetails = context!!.config.showExtendedDetails
|
||||
mStoredExtendedDetails = context!!.config.extendedDetails
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -238,17 +238,17 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
mView.video_holder
|
||||
}
|
||||
|
||||
private fun getCurrentVolume() = context.audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
private fun getCurrentVolume() = context!!.audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
|
||||
private fun getCurrentBrightness() = Settings.System.getInt(activity.contentResolver, Settings.System.SCREEN_BRIGHTNESS)
|
||||
private fun getCurrentBrightness() = Settings.System.getInt(activity!!.contentResolver, Settings.System.SCREEN_BRIGHTNESS)
|
||||
|
||||
private fun volumePercentChanged(percent: Int) {
|
||||
val stream = AudioManager.STREAM_MUSIC
|
||||
val maxVolume = context.audioManager.getStreamMaxVolume(stream)
|
||||
val maxVolume = context!!.audioManager.getStreamMaxVolume(stream)
|
||||
val percentPerPoint = 100 / maxVolume
|
||||
val addPoints = percent / percentPerPoint
|
||||
val newVolume = Math.min(maxVolume, Math.max(0, mTouchDownVolume + addPoints))
|
||||
context.audioManager.setStreamVolume(stream, newVolume, 0)
|
||||
context!!.audioManager.setStreamVolume(stream, newVolume, 0)
|
||||
|
||||
val absolutePercent = ((newVolume / maxVolume.toFloat()) * 100).toInt()
|
||||
mView.slide_info.apply {
|
||||
|
@ -274,9 +274,9 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
alpha = 1f
|
||||
}
|
||||
|
||||
val attributes = activity.window.attributes
|
||||
val attributes = activity!!.window.attributes
|
||||
attributes.screenBrightness = absolutePercent / 100f
|
||||
activity.window.attributes = attributes
|
||||
activity!!.window.attributes = attributes
|
||||
|
||||
mSlideInfoFadeHandler.removeCallbacksAndMessages(null)
|
||||
mSlideInfoFadeHandler.postDelayed({
|
||||
|
@ -286,7 +286,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
private fun initTimeHolder() {
|
||||
val res = resources
|
||||
val height = context.navigationBarHeight
|
||||
val height = context!!.navigationBarHeight
|
||||
val left = mTimeHolder.paddingLeft
|
||||
val top = mTimeHolder.paddingTop
|
||||
var right = res.getDimension(R.dimen.timer_padding).toInt()
|
||||
|
@ -297,7 +297,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
bottom += height
|
||||
} else {
|
||||
right += height
|
||||
bottom += context.navigationBarHeight
|
||||
bottom += context!!.navigationBarHeight
|
||||
}
|
||||
mTimeHolder.setPadding(left, top, right, bottom)
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
private fun hasNavBar(): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
val display = context.windowManager.defaultDisplay
|
||||
val display = context!!.windowManager.defaultDisplay
|
||||
|
||||
val realDisplayMetrics = DisplayMetrics()
|
||||
display.getRealMetrics(realDisplayMetrics)
|
||||
|
@ -342,7 +342,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
|
||||
private fun setupTimer() {
|
||||
activity.runOnUiThread(object : Runnable {
|
||||
activity!!.runOnUiThread(object : Runnable {
|
||||
override fun run() {
|
||||
if (mMediaPlayer != null && !mIsDragged && mIsPlaying) {
|
||||
mCurrTime = mMediaPlayer!!.currentPosition / 1000
|
||||
|
@ -401,14 +401,14 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
mPlayOnPrepare = true
|
||||
}
|
||||
mView.video_play_outline.setImageDrawable(null)
|
||||
activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
activity!!.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
|
||||
private fun pauseVideo() {
|
||||
mIsPlaying = false
|
||||
mMediaPlayer?.pause()
|
||||
mView.video_play_outline.setImageDrawable(resources.getDrawable(R.drawable.img_play_outline_big))
|
||||
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
activity!!.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
|
||||
private fun initMediaPlayer() {
|
||||
|
@ -470,7 +470,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
setupTimeHolder()
|
||||
setProgress(mCurrTime)
|
||||
|
||||
if (mIsFragmentVisible && (context.config.autoplayVideos || mPlayOnPrepare))
|
||||
if (mIsFragmentVisible && (context!!.config.autoplayVideos || mPlayOnPrepare))
|
||||
playVideo()
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
return
|
||||
}
|
||||
|
||||
if (listener?.videoEnded() == false && context.config.loopVideos) {
|
||||
if (listener?.videoEnded() == false && context!!.config.loopVideos) {
|
||||
playVideo()
|
||||
} else {
|
||||
mSeekBar!!.progress = mSeekBar!!.max
|
||||
|
@ -516,7 +516,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
|
||||
val videoProportion = mMediaPlayer!!.videoWidth.toFloat() / mMediaPlayer!!.videoHeight.toFloat()
|
||||
val display = activity.windowManager.defaultDisplay
|
||||
val display = activity!!.windowManager.defaultDisplay
|
||||
val screenWidth: Int
|
||||
val screenHeight: Int
|
||||
|
||||
|
@ -545,7 +545,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
|
||||
private fun checkExtendedDetails() {
|
||||
if (context.config.showExtendedDetails) {
|
||||
if (context!!.config.showExtendedDetails) {
|
||||
mView.video_details.apply {
|
||||
text = getMediumExtendedDetails(medium)
|
||||
setTextColor(context.config.textColor)
|
||||
|
|
|
@ -27,7 +27,7 @@ abstract class ViewPagerFragment : Fragment() {
|
|||
val path = "${file.parent.trimEnd('/')}/"
|
||||
val exif = android.media.ExifInterface(medium.path)
|
||||
val details = StringBuilder()
|
||||
val detailsFlag = context.config.extendedDetails
|
||||
val detailsFlag = context!!.config.extendedDetails
|
||||
if (detailsFlag and EXT_NAME != 0) {
|
||||
medium.name.let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.3'
|
||||
classpath 'com.android.tools.build:gradle:3.0.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Fri Mar 03 19:10:52 CET 2017
|
||||
#Tue Nov 07 16:59:29 CET 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||
|
|
Loading…
Reference in a new issue