diff --git a/app/build.gradle b/app/build.gradle
index 09d7acdd575626674da13dd663424299d9519296..a4fbe95e0f35b51d9e84e8ef77d55f10cbfdbcf1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -116,6 +116,9 @@ dependencies {
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.2.1"
+ //logger
+ implementation 'com.jakewharton.timber:timber:5.0.1'
+
// Retrofit
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
diff --git a/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt b/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt
new file mode 100644
index 0000000000000000000000000000000000000000..48292b895af3a5f5e9e6fc8d3b42ef4907b5746d
--- /dev/null
+++ b/app/src/main/java/foundation/e/apps/settings/LongPressPreference.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019-2022 E FOUNDATION
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package foundation.e.apps.settings
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import androidx.preference.Preference
+import androidx.preference.PreferenceViewHolder
+
+/**
+ * Custom class to enable long pressing preferences.
+ * Inspired from: https://www.joehxblog.com/how-to-add-a-long-click-to-an-androidx-preference
+ */
+class LongPressPreference : Preference {
+
+ private var longClickListener: View.OnLongClickListener = View.OnLongClickListener { v -> true }
+
+ constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
+ context,
+ attrs,
+ defStyle
+ )
+
+ constructor(context: Context, attrs: AttributeSet? = null) : super(context, attrs)
+
+ override fun onBindViewHolder(holder: PreferenceViewHolder) {
+ super.onBindViewHolder(holder)
+ val itemView: View = holder.itemView
+ itemView.setOnLongClickListener(longClickListener)
+ }
+
+ fun setOnLongClickListener(longClickBody: (view: View?) -> Boolean) {
+ this.longClickListener = View.OnLongClickListener { v -> longClickBody(v) }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt b/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt
index 562ec459bc6f0d5f220483bffb124bdc0a52b6ce..4f632a755ca4400d9ff364c467cca89e4c671f28 100644
--- a/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt
+++ b/app/src/main/java/foundation/e/apps/settings/SettingsFragment.kt
@@ -18,10 +18,12 @@
package foundation.e.apps.settings
+import android.content.ClipboardManager
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
+import android.widget.Toast
import androidx.fragment.app.viewModels
import androidx.navigation.findNavController
import androidx.preference.Preference
@@ -31,13 +33,16 @@ import coil.load
import com.aurora.gplayapi.data.models.AuthData
import com.google.gson.Gson
import dagger.hilt.android.AndroidEntryPoint
+import foundation.e.apps.BuildConfig
import foundation.e.apps.MainActivity
import foundation.e.apps.MainActivityViewModel
import foundation.e.apps.R
+import foundation.e.apps.utils.modules.CommonUtilsFunctions
import foundation.e.apps.databinding.CustomPreferenceBinding
import foundation.e.apps.setup.signin.SignInViewModel
import foundation.e.apps.updates.manager.UpdatesWorkManager
import foundation.e.apps.utils.enums.User
+import timber.log.Timber
import javax.inject.Inject
@AndroidEntryPoint
@@ -51,6 +56,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
@Inject
lateinit var gson: Gson
+ @Inject
+ lateinit var clipboardManager: ClipboardManager
+
companion object {
private const val TAG = "SettingsFragment"
}
@@ -91,6 +99,29 @@ class SettingsFragment : PreferenceFragmentCompat() {
backToMainActivity()
true
}
+
+ val versionInfo = findPreference("versionInfo")
+ versionInfo?.apply {
+ summary = BuildConfig.VERSION_NAME
+ setOnLongClickListener {
+
+ val osVersion = CommonUtilsFunctions.getSystemProperty("ro.lineage.version")
+ val appVersionLabel = getString(R.string.app_version_label)
+ var contents = "$appVersionLabel: $summary"
+ if (!osVersion.isNullOrBlank()) {
+ contents += "\n${context.getString(R.string.os_version)}: $osVersion"
+ }
+
+ CommonUtilsFunctions.copyTextToClipboard(
+ clipboardManager,
+ appVersionLabel,
+ contents
+ )
+ Toast.makeText(context, R.string.copied, Toast.LENGTH_SHORT).show()
+
+ true
+ }
+ }
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
diff --git a/app/src/main/java/foundation/e/apps/utils/modules/CommonUtilsFunctions.kt b/app/src/main/java/foundation/e/apps/utils/modules/CommonUtilsFunctions.kt
new file mode 100644
index 0000000000000000000000000000000000000000..5253d57aead0c6c92982f99978fb7174fd510294
--- /dev/null
+++ b/app/src/main/java/foundation/e/apps/utils/modules/CommonUtilsFunctions.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019-2022 E FOUNDATION
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package foundation.e.apps.utils.modules
+
+import android.annotation.SuppressLint
+import android.content.ClipData
+import android.content.ClipboardManager
+
+object CommonUtilsFunctions {
+
+ /**
+ * Copy anything to system clipboard.
+ * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5653
+ */
+ fun copyTextToClipboard(
+ clipboard: ClipboardManager,
+ label: String,
+ text: String,
+ ) {
+ // https://developer.android.com/guide/topics/text/copy-paste#Copying
+ val clip = ClipData.newPlainText(label, text)
+ clipboard.setPrimaryClip(clip)
+ }
+
+ @SuppressLint("PrivateApi")
+ fun getSystemProperty(key: String?): String? {
+ var value: String? = null
+ try {
+ value = Class.forName("android.os.SystemProperties")
+ .getMethod("get", String::class.java).invoke(null, key) as String
+ } catch (e: java.lang.Exception) {
+ e.printStackTrace()
+ }
+ return value
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/foundation/e/apps/utils/modules/CommonUtilsModule.kt b/app/src/main/java/foundation/e/apps/utils/modules/CommonUtilsModule.kt
index 8b2b6e000b306e72daf6acd14b18b9736ca4c0b0..5cb06f511ccad71f659b41c25d7e234ae60b7634 100644
--- a/app/src/main/java/foundation/e/apps/utils/modules/CommonUtilsModule.kt
+++ b/app/src/main/java/foundation/e/apps/utils/modules/CommonUtilsModule.kt
@@ -18,6 +18,9 @@
package foundation.e.apps.utils.modules
+import android.annotation.SuppressLint
+import android.content.ClipData
+import android.content.ClipboardManager
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
@@ -34,6 +37,8 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
+import foundation.e.apps.BuildConfig
+import foundation.e.apps.R
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
@@ -162,4 +167,10 @@ object CommonUtilsModule {
fun getIOCoroutineScope(): CoroutineScope {
return CoroutineScope(SupervisorJob() + Dispatchers.IO)
}
+
+ @Singleton
+ @Provides
+ fun provideClipboardService(@ApplicationContext context: Context): ClipboardManager {
+ return context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
+ }
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 38407f25e9744a719792f2f8deac0f00a077234e..c59d187296f259045f4615a730fd5755884da361 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -64,6 +64,10 @@
Show all apps
Show only open-source apps
Show only PWAs
+ About
+ App Lounge version
+ /e/ OS version
+ Copied
Account
Terms of Services
Anonymous
diff --git a/app/src/main/res/xml/settings_preferences.xml b/app/src/main/res/xml/settings_preferences.xml
index 5e560831a62f39c4e15aaad2b0ff28399b0fd5ae..9bb9435d911065b43eed9f2d363201013b0637b3 100644
--- a/app/src/main/res/xml/settings_preferences.xml
+++ b/app/src/main/res/xml/settings_preferences.xml
@@ -16,7 +16,9 @@
~ along with this program. If not, see .
-->
-
+
+
+
+
+
+
\ No newline at end of file