2019-03-27 03:54:28 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.fenix.settings
|
|
|
|
|
|
|
|
import android.content.pm.PackageManager
|
2019-06-23 19:13:52 +02:00
|
|
|
import android.os.Build
|
|
|
|
import android.os.Build.VERSION.SDK_INT
|
2019-03-27 03:54:28 +01:00
|
|
|
import android.os.Bundle
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
2019-05-06 23:40:01 +02:00
|
|
|
import androidx.core.content.pm.PackageInfoCompat
|
2019-06-19 01:38:42 +02:00
|
|
|
import androidx.fragment.app.Fragment
|
2019-03-27 03:54:28 +01:00
|
|
|
import kotlinx.android.synthetic.main.fragment_about.*
|
2019-05-10 00:05:49 +02:00
|
|
|
import org.mozilla.fenix.BuildConfig
|
2019-03-27 03:54:28 +01:00
|
|
|
import org.mozilla.fenix.R
|
2019-05-10 00:05:49 +02:00
|
|
|
import org.mozilla.geckoview.BuildConfig as GeckoViewBuildConfig
|
2019-03-27 03:54:28 +01:00
|
|
|
|
|
|
|
class AboutFragment : Fragment() {
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
|
|
return inflater.inflate(R.layout.fragment_about, container, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
|
|
|
val appName = requireContext().resources.getString(R.string.app_name)
|
|
|
|
(activity as AppCompatActivity).title = getString(R.string.preferences_about, appName)
|
2019-06-23 19:13:52 +02:00
|
|
|
val maybeGecko = if (SDK_INT < Build.VERSION_CODES.N) {
|
|
|
|
"GV: "
|
|
|
|
} else {
|
|
|
|
" \uD83E\uDD8E "
|
2019-06-11 23:40:51 +02:00
|
|
|
}
|
2019-03-27 03:54:28 +01:00
|
|
|
|
|
|
|
val aboutText = try {
|
|
|
|
val packageInfo = requireContext().packageManager.getPackageInfo(requireContext().packageName, 0)
|
2019-06-11 23:40:51 +02:00
|
|
|
val geckoVersion = PackageInfoCompat.getLongVersionCode(packageInfo).toString() + maybeGecko +
|
2019-05-10 00:05:49 +02:00
|
|
|
GeckoViewBuildConfig.MOZ_APP_VERSION + "-" + GeckoViewBuildConfig.MOZ_APP_BUILDID
|
2019-06-24 21:52:04 +02:00
|
|
|
val componentsVersion = mozilla.components.Build.version
|
|
|
|
|
2019-03-27 03:54:28 +01:00
|
|
|
String.format(
|
2019-06-24 21:52:04 +02:00
|
|
|
"%s (Build #%s)\nAC: %s",
|
2019-03-27 03:54:28 +01:00
|
|
|
packageInfo.versionName,
|
2019-06-24 21:52:04 +02:00
|
|
|
geckoVersion,
|
|
|
|
componentsVersion
|
2019-03-27 03:54:28 +01:00
|
|
|
)
|
|
|
|
} catch (e: PackageManager.NameNotFoundException) {
|
|
|
|
""
|
|
|
|
}
|
|
|
|
|
2019-05-10 00:05:49 +02:00
|
|
|
val buildDate = BuildConfig.BUILD_DATE
|
2019-03-27 03:54:28 +01:00
|
|
|
val content = resources.getString(R.string.about_content, appName)
|
|
|
|
|
|
|
|
about_text.text = aboutText
|
|
|
|
about_content.text = content
|
|
|
|
build_date.text = buildDate
|
|
|
|
}
|
|
|
|
}
|