-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from emreesen27/about-page
[DEV][about feature is completed]
- Loading branch information
Showing
28 changed files
with
672 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
.cxx | ||
local.properties | ||
app/release/ | ||
app/google-services.json |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
/build | ||
/build | ||
google-services.json |
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
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/sn/snfilemanager/feature/about/AboutFragment.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,45 @@ | ||
package com.sn.snfilemanager.feature.about | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import androidx.navigation.fragment.findNavController | ||
import com.sn.snfilemanager.core.base.BaseFragment | ||
import com.sn.snfilemanager.core.extensions.click | ||
import com.sn.snfilemanager.core.extensions.startActivitySafely | ||
import com.sn.snfilemanager.databinding.FragmentAboutBinding | ||
import com.sn.snfilemanager.view.dialog.license.LicenseDialog | ||
|
||
class AboutFragment : BaseFragment<FragmentAboutBinding, AboutViewModel>() { | ||
override fun getViewModelClass() = AboutViewModel::class.java | ||
|
||
override fun getViewBinding() = FragmentAboutBinding.inflate(layoutInflater) | ||
|
||
companion object { | ||
const val GITHUB_URL = | ||
"https://github.com/emreesen27/Android-Sn-File-Manager" | ||
const val PRIVACY_URL = | ||
"https://github.com/emreesen27/Android-Sn-File-Manager/blob/develop/PRIVACY.md" | ||
} | ||
|
||
override fun setupViews() { | ||
binding.vm = viewModel | ||
binding.lifecycleOwner = viewLifecycleOwner | ||
initClicks() | ||
} | ||
|
||
private fun initClicks() { | ||
binding.toolbar.setNavigationOnClickListener { findNavController().popBackStack() } | ||
binding.btnGithub.click { openUrl(GITHUB_URL) } | ||
binding.btnLicense.click { showLicensesDialog() } | ||
binding.btnPrivacy.click { openUrl(PRIVACY_URL) } | ||
} | ||
|
||
private fun showLicensesDialog() { | ||
LicenseDialog().show(childFragmentManager, LicenseDialog.TAG) | ||
} | ||
|
||
private fun openUrl(url: String) { | ||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | ||
context?.startActivitySafely(intent) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/sn/snfilemanager/feature/about/AboutViewModel.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,19 @@ | ||
package com.sn.snfilemanager.feature.about | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.sn.snfilemanager.BuildConfig | ||
|
||
class AboutViewModel : ViewModel() { | ||
private val _versionLiveData: MutableLiveData<String> = MutableLiveData() | ||
val versionLiveData: LiveData<String> = _versionLiveData | ||
|
||
init { | ||
getVersion() | ||
} | ||
|
||
private fun getVersion() { | ||
_versionLiveData.value = BuildConfig.VERSION_NAME | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/sn/snfilemanager/feature/settings/SettingsToolbar.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,26 @@ | ||
package com.sn.snfilemanager.feature.settings | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import androidx.navigation.findNavController | ||
import androidx.preference.Preference | ||
import androidx.preference.PreferenceViewHolder | ||
import com.google.android.material.appbar.MaterialToolbar | ||
import com.sn.snfilemanager.R | ||
|
||
class SettingsToolbar | ||
@JvmOverloads | ||
constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0, | ||
) : Preference(context, attrs, defStyleAttr) { | ||
override fun onBindViewHolder(holder: PreferenceViewHolder) { | ||
super.onBindViewHolder(holder) | ||
|
||
val toolbar = holder.findViewById(R.id.toolbar_settings) as MaterialToolbar | ||
toolbar.setNavigationOnClickListener { | ||
toolbar.findNavController().popBackStack() | ||
} | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/sn/snfilemanager/view/dialog/license/License.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,7 @@ | ||
package com.sn.snfilemanager.view.dialog.license | ||
|
||
data class License( | ||
val name: String, | ||
val url: String, | ||
val license: String, | ||
) |
95 changes: 95 additions & 0 deletions
95
app/src/main/java/com/sn/snfilemanager/view/dialog/license/LicenseAdapter.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,95 @@ | ||
package com.sn.snfilemanager.view.dialog.license | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.sn.snfilemanager.core.extensions.click | ||
import com.sn.snfilemanager.core.extensions.startActivitySafely | ||
import com.sn.snfilemanager.databinding.ItemLicenseBinding | ||
|
||
class LicenseAdapter(private val context: Context) : | ||
RecyclerView.Adapter<LicenseAdapter.LicenseViewHolder>() { | ||
private val licenses: List<License> = | ||
listOf( | ||
License( | ||
"Glide", | ||
"https://github.com/bumptech/glide", | ||
"https://github.com/bumptech/glide/blob/master/LICENSE", | ||
), | ||
License( | ||
"Nested Progress", | ||
"https://github.com/emreesen27/Android-Nested-Progress", | ||
"https://github.com/emreesen27/Android-Nested-Progress/blob/master/LICENSE", | ||
), | ||
License( | ||
"Toasty", | ||
"https://github.com/GrenderG/Toasty", | ||
"https://github.com/GrenderG/Toasty/blob/master/LICENSE", | ||
), | ||
License( | ||
"Lottie Android", | ||
"https://github.com/airbnb/lottie-android", | ||
"https://github.com/airbnb/lottie-android/blob/master/LICENSE", | ||
), | ||
License( | ||
"Ssp", | ||
"https://github.com/intuit/ssp", | ||
"https://github.com/intuit/ssp/blob/master/LICENSE", | ||
), | ||
License( | ||
"Android Animation", | ||
"https://github.com/gayanvoice/android-animations", | ||
"https://github.com/gayanvoice/android-animations/blob/master/LICENSE", | ||
), | ||
) | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): LicenseAdapter.LicenseViewHolder { | ||
val binding = | ||
ItemLicenseBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return LicenseViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder( | ||
holder: LicenseAdapter.LicenseViewHolder, | ||
position: Int, | ||
) { | ||
holder.bind(licenses[position]) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return licenses.size | ||
} | ||
|
||
inner class LicenseViewHolder(private val binding: ItemLicenseBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
init { | ||
binding.mtvGithub.click { | ||
if (adapterPosition != RecyclerView.NO_POSITION) { | ||
val clickedLicense = licenses[adapterPosition] | ||
openUrl(clickedLicense.url) | ||
} | ||
} | ||
binding.mtvLicense.click { | ||
if (adapterPosition != RecyclerView.NO_POSITION) { | ||
val clickedLicense = licenses[adapterPosition] | ||
openUrl(clickedLicense.license) | ||
} | ||
} | ||
} | ||
|
||
fun bind(model: License) { | ||
binding.mtvName.text = model.name | ||
} | ||
} | ||
|
||
private fun openUrl(url: String) { | ||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | ||
context.startActivitySafely(intent) | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/sn/snfilemanager/view/dialog/license/LicenseDialog.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.sn.snfilemanager.view.dialog.license | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.fragment.app.DialogFragment | ||
import com.sn.snfilemanager.R | ||
import com.sn.snfilemanager.core.extensions.click | ||
import com.sn.snfilemanager.databinding.DialogLicenseBinding | ||
|
||
class LicenseDialog : DialogFragment() { | ||
companion object { | ||
const val TAG = "LICENSE_DIALOG" | ||
} | ||
|
||
private val binding: DialogLicenseBinding by lazy { | ||
DialogLicenseBinding.inflate(layoutInflater) | ||
} | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
dialog?.window?.setLayout( | ||
ConstraintLayout.LayoutParams.MATCH_PARENT, | ||
ConstraintLayout.LayoutParams.MATCH_PARENT, | ||
) | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setStyle(STYLE_NO_TITLE, R.style.DialogTheme_transparent) | ||
dialog?.window?.setBackgroundDrawableResource(R.drawable.dialog_rounded) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.recycler.adapter = LicenseAdapter(requireContext()) | ||
binding.ivClose.click { dismiss() } | ||
} | ||
} |
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,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="48dp" | ||
android:height="48dp" | ||
android:viewportWidth="128" | ||
android:viewportHeight="128"> | ||
<path | ||
android:fillColor="@color/main_color" | ||
android:pathData="M64,64m-64,0a64,64 0,1 1,128 0a64,64 0,1 1,-128 0" /> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M32.5,43H104c0,-2.2 -1.8,-4 -4,-4H47.5l-1.3,-2.1c-0.7,-1.2 -2,-1.9 -3.4,-1.9H28c-2.2,0 -4,1.8 -4,4v20v25.7l4.6,-38.1C28.8,44.5 30.5,43 32.5,43z" /> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M108.5,47h-72c-2,0 -3.7,1.5 -4,3.5l-5,42c-0.3,2.4 1.6,4.5 4,4.5h71.9c2,0 3.7,-1.5 4,-3.5l5,-42C112.7,49.1 110.9,47 108.5,47z" /> | ||
</vector> |
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="6dp" | ||
android:height="6dp" | ||
android:tint="@color/first_text_color" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="@color/first_text_color" | ||
android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2z" /> | ||
</vector> |
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,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="#00000000" | ||
android:fillType="evenOdd" | ||
android:pathData="M12,2C6.475,2 2,6.475 2,12C2,16.425 4.863,20.163 8.837,21.487C9.337,21.575 9.525,21.275 9.525,21.013C9.525,20.775 9.512,19.987 9.512,19.15C7,19.612 6.35,18.538 6.15,17.975C6.037,17.688 5.55,16.8 5.125,16.563C4.775,16.375 4.275,15.913 5.113,15.9C5.9,15.887 6.463,16.625 6.65,16.925C7.55,18.438 8.988,18.013 9.563,17.75C9.65,17.1 9.913,16.663 10.2,16.413C7.975,16.163 5.65,15.3 5.65,11.475C5.65,10.387 6.037,9.488 6.675,8.788C6.575,8.538 6.225,7.512 6.775,6.137C6.775,6.137 7.613,5.875 9.525,7.162C10.325,6.938 11.175,6.825 12.025,6.825C12.875,6.825 13.725,6.938 14.525,7.162C16.438,5.863 17.275,6.137 17.275,6.137C17.825,7.512 17.475,8.538 17.375,8.788C18.013,9.488 18.4,10.375 18.4,11.475C18.4,15.313 16.063,16.163 13.837,16.413C14.2,16.725 14.512,17.325 14.512,18.263C14.512,19.6 14.5,20.675 14.5,21.013C14.5,21.275 14.688,21.587 15.188,21.487C17.173,20.817 18.898,19.542 20.12,17.84C21.342,16.138 22,14.095 22,12C22,6.475 17.525,2 12,2Z" | ||
android:strokeWidth="1.3" | ||
android:strokeColor="@color/first_text_color" | ||
android:strokeLineJoin="round" | ||
tools:ignore="VectorPath" /> | ||
</vector> |
Oops, something went wrong.