Commit 3bc0432e authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Don't allow apps without a "LAUNCHER" activity to be opened

parent 564224fb
......@@ -28,6 +28,7 @@ import io.eelo.appinstaller.application.model.data.FullData
import io.eelo.appinstaller.applicationmanager.ApplicationManager
import io.eelo.appinstaller.applicationmanager.ApplicationManagerServiceConnection
import io.eelo.appinstaller.applicationmanager.ApplicationManagerServiceConnectionCallback
import io.eelo.appinstaller.utils.Common
import io.eelo.appinstaller.utils.Common.toMiB
import io.eelo.appinstaller.utils.Constants
import io.eelo.appinstaller.utils.Constants.APPLICATION_DESCRIPTION_KEY
......@@ -440,6 +441,14 @@ class ApplicationActivity : AppCompatActivity(), ApplicationStateListener,
Execute({}, {
app_install.text = resources.getString(state.installButtonTextId)
when (state) {
State.INSTALLED -> {
app_install.setBackgroundResource(R.drawable.app_install_border)
app_install.setTextColor(resources.getColor(android.R.color.primary_text_dark))
app_install.isEnabled =
Common.appHasLaunchActivity(this, application.packageName)
app_size.visibility = View.VISIBLE
app_download_container.visibility = View.GONE
}
State.DOWNLOADING -> {
app_install.setBackgroundResource(R.drawable.app_install_border_simple)
app_install.setTextColor(resources.getColor(android.R.color.primary_text_light))
......
......@@ -78,6 +78,10 @@ class ApplicationViewHolder(private val activity: Activity, private val view: Vi
Execute({}, {
installButton.text = activity.getString(state.installButtonTextId)
when (state) {
State.INSTALLED -> {
installButton.isEnabled =
Common.appHasLaunchActivity(activity, application!!.packageName)
}
State.INSTALLING -> {
installButton.isEnabled = false
}
......
......@@ -61,6 +61,10 @@ class SmallApplicationViewHolder(private val activity: Activity, private val vie
Execute({}, {
installButton.text = activity.getString(state.installButtonTextId)
when (state) {
State.INSTALLED -> {
installButton.isEnabled =
Common.appHasLaunchActivity(activity, application!!.packageName)
}
State.INSTALLING -> {
installButton.isEnabled = false
}
......
......@@ -58,4 +58,8 @@ object Common {
}
return false
}
fun appHasLaunchActivity(context: Context, packageName: String): Boolean {
return (context.packageManager.getLaunchIntentForPackage(packageName) != null)
}
}
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