Commit 60a6dd1e authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Merge branch 'adding_feature_purpose' into 'master'

Adding feature purpose

See merge request e/apps/GmsCore!28
parents 990f8722 1a3dc7f7
Pipeline #101174 passed with stage
in 11 minutes and 44 seconds
......@@ -16,6 +16,9 @@ import org.microg.gms.gcm.getGcmServiceInfo
import org.microg.gms.snet.getSafetyNetServiceInfo
import org.microg.nlp.client.UnifiedLocationClient
import org.microg.tools.ui.ResourceSettingsFragment
import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Intent
class SettingsFragment : ResourceSettingsFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
......@@ -41,6 +44,10 @@ class SettingsFragment : ResourceSettingsFragment() {
findNavController().navigate(requireContext(), NearbyPreferencesIntegration.exposureNotificationNavigationId)
true
}
findPreference<Preference>(PREF_EXPOSURE_INSTALL)?.onPreferenceClickListener = Preference.OnPreferenceClickListener {
startApplication("foundation.e.apps")
true
}
findPreference<Preference>(PREF_ABOUT)!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
findNavController().navigate(requireContext(), R.id.openAbout)
true
......@@ -55,6 +62,32 @@ class SettingsFragment : ResourceSettingsFragment() {
}
}
private fun launchComponent(packageName: String, name: String) {
val launch_intent = Intent("android.intent.action.MAIN")
launch_intent.addCategory("android.intent.category.LAUNCHER")
launch_intent.component = ComponentName(packageName, name)
launch_intent.putExtra("open_search", true)
launch_intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
requireActivity().startActivity(launch_intent)
}
fun startApplication(application_name: String?) {
try {
val intent = Intent("android.intent.action.MAIN")
intent.addCategory("android.intent.category.LAUNCHER")
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
val resolveinfo_list = requireActivity().packageManager.queryIntentActivities(intent, 0)
for (info in resolveinfo_list) {
if (info.activityInfo.packageName == application_name) {
launchComponent(info.activityInfo.packageName, info.activityInfo.name)
break
}
}
} catch (e: ActivityNotFoundException) {
e.message
}
}
private suspend fun updateDetails() {
if (getGcmServiceInfo(requireContext()).configuration.enabled) {
val database = GcmDatabase(context)
......@@ -74,6 +107,9 @@ class SettingsFragment : ResourceSettingsFragment() {
findPreference<Preference>(PREF_EXPOSURE)?.isVisible = NearbyPreferencesIntegration.isAvailable
findPreference<Preference>(PREF_EXPOSURE)?.icon = NearbyPreferencesIntegration.getIcon(requireContext())
findPreference<Preference>(PREF_EXPOSURE)?.summary = NearbyPreferencesIntegration.getExposurePreferenceSummary(requireContext())
println("MicroG_Status::-"+ NearbyPreferencesIntegration.isAvailable)
}
companion object {
......@@ -83,6 +119,7 @@ class SettingsFragment : ResourceSettingsFragment() {
const val PREF_UNIFIEDNLP = "pref_unifiednlp"
const val PREF_CHECKIN = "pref_checkin"
const val PREF_EXPOSURE = "pref_exposure"
const val PREF_EXPOSURE_INSTALL = "pref_exposure_install"
}
init {
......
......@@ -65,6 +65,7 @@ This can take a couple of minutes."</string>
<string name="service_status_manual">Manual</string>
<string name="service_status_enabled_short">On</string>
<string name="service_status_disabled_short">Off</string>
<string name="pref_exposure_install_summary">Tap to add support for Exposure Notifications</string>
<string name="games_title">Google Play Games</string>
<string name="games_info_title"><xliff:g example="F-Droid">%1$s</xliff:g> would like to use Play Games</string>
......
......@@ -66,6 +66,11 @@
android:key="pref_exposure"
android:title="@string/service_name_exposure"
app:isPreferenceVisible="false" />
<Preference
android:key="pref_exposure_install"
android:title="@string/service_name_exposure"
android:summary="@string/pref_exposure_install_summary">
</Preference>
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_category_no_label">
<Preference
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment