-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add download wallpaper screen and edit set wallpaper screen
- Loading branch information
Showing
28 changed files
with
413 additions
and
82 deletions.
There are no files selected for viewing
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
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
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
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/oguzdogdu/wallies/presentation/downloadphoto/DownloadPhotoFragment.kt
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.oguzdogdu.wallies.presentation.downloadphoto | ||
|
||
import android.app.DownloadManager | ||
import android.content.Context | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.os.Environment | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.navigation.fragment.navArgs | ||
import com.oguzdogdu.wallies.R | ||
import com.oguzdogdu.wallies.core.BaseBottomSheetDialogFragment | ||
import com.oguzdogdu.wallies.databinding.FragmentDownloadPhotoBinding | ||
import com.oguzdogdu.wallies.presentation.setwallpaper.SetWallpaperFragmentArgs | ||
import com.oguzdogdu.wallies.util.downloadImage | ||
import com.oguzdogdu.wallies.util.showToast | ||
import java.io.File | ||
|
||
class DownloadPhotoFragment : BaseBottomSheetDialogFragment<FragmentDownloadPhotoBinding>(FragmentDownloadPhotoBinding::inflate) { | ||
|
||
private val args: DownloadPhotoFragmentArgs by navArgs() | ||
|
||
override fun initListeners() { | ||
super.initListeners() | ||
binding.apply { | ||
buttonRawQuality.setOnClickListener { | ||
downloadImageFromWeb(args.raw) | ||
} | ||
buttonFullQuality.setOnClickListener { | ||
downloadImageFromWeb(args.high) | ||
} | ||
buttonMediumQuality.setOnClickListener { | ||
downloadImageFromWeb(args.medium) | ||
} | ||
buttonLowQuality.setOnClickListener { | ||
downloadImageFromWeb(args.low) | ||
} | ||
} | ||
} | ||
|
||
|
||
private fun downloadImageFromWeb(url: String?) { | ||
val directory : String = requireContext().getString(R.string.app_name) | ||
val fileName = "${args.imageTitle}.jpg" | ||
if (url != null) { | ||
requireContext().downloadImage(url, directory, fileName) | ||
} | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.