Skip to content

Commit

Permalink
ref: minor fixes in ContinuousScanActivity.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
VaiTon committed May 17, 2021
1 parent 3874b1b commit a479749
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 158 deletions.
Expand Up @@ -170,6 +170,7 @@ class MainActivity : BaseActivity(), NavigationDrawerListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// TODO: Are we sure we want to keep this?
if (resources.getBoolean(R.bool.portrait_only)) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
Expand Down Expand Up @@ -236,7 +237,7 @@ class MainActivity : BaseActivity(), NavigationDrawerListener {
// Add Manage Account profile if the user is connected
if (isUserSet() && getUserSession() != null) updateProfileForCurrentUser()

//Create the drawer
// Create the drawer
drawerResult = DrawerBuilder()
.withActivity(this)
.withToolbar(binding.toolbarInclude.toolbar)
Expand Down Expand Up @@ -295,6 +296,7 @@ class MainActivity : BaseActivity(), NavigationDrawerListener {
ITEM_CONTRIBUTE -> CustomTabActivityHelper.openCustomTab(this@MainActivity, customTabsIntent, contributeUri, WebViewFallback())
ITEM_INCOMPLETE_PRODUCTS -> start(this@MainActivity, SearchType.INCOMPLETE_PRODUCT, "") // Search and display the products to be completed by moving to ProductBrowsingListActivity
ITEM_OBF -> {

val otherOFAppInstalled = isApplicationInstalled(this@MainActivity, BuildConfig.OFOTHERLINKAPP)
if (otherOFAppInstalled) {
val launchIntent = packageManager.getLaunchIntentForPackage(BuildConfig.OFOTHERLINKAPP)
Expand All @@ -305,16 +307,15 @@ class MainActivity : BaseActivity(), NavigationDrawerListener {
startActivity(Intent().apply {
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
data = Uri.fromParts("package", BuildConfig.OFOTHERLINKAPP, null)

})
}
} else {
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + BuildConfig.OFOTHERLINKAPP)))
startActivity(Intent(Intent.ACTION_VIEW, "market://details?id=${BuildConfig.OFOTHERLINKAPP}".toUri()))
} catch (anfe: ActivityNotFoundException) {
startActivity(Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=${BuildConfig.OFOTHERLINKAPP}")
"https://play.google.com/store/apps/details?id=${BuildConfig.OFOTHERLINKAPP}".toUri()
))
}
}
Expand All @@ -336,7 +337,7 @@ class MainActivity : BaseActivity(), NavigationDrawerListener {
negativeText(R.string.dialog_cancel)
onPositive { _, _ -> logout() }
onNegative { dialog, _ ->
Snackbar.make(binding.root, "Cancelled", BaseTransientBottomBar.LENGTH_SHORT).show()
Snackbar.make(binding.root, "Cancelled", BaseTransientBottomBar.LENGTH_SHORT).show() // TODO: Is this useful?
dialog.dismiss()
}
show()
Expand Down Expand Up @@ -393,6 +394,8 @@ class MainActivity : BaseActivity(), NavigationDrawerListener {
//set the active profile
headerResult.activeProfile = profile
}

// FIXME: When set we cannot go to home fragment from bottom bar
if (sharedPreferences.getBoolean("startScan", false)) {
startActivity(Intent(this@MainActivity, ContinuousScanActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
Expand Down

0 comments on commit a479749

Please sign in to comment.