Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Copy over intent parserr
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanWang committed Jun 23, 2023
1 parent 544f99f commit ffd6a68
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.core.view.WindowCompat
import com.google.common.flogger.FluentLogger
import com.pitchedapps.frost.R
import com.pitchedapps.frost.compose.FrostTheme
import com.pitchedapps.frost.tabselector.TabSelectorScreen
import com.pitchedapps.frost.web.state.FrostWebStore
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
Expand Down Expand Up @@ -52,9 +51,9 @@ class MainActivity : ComponentActivity() {
// tabs = tabs,
// )

TabSelectorScreen()
// TabSelectorScreen()

// MainScreenWebView()
MainScreenWebView()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,51 @@
*/
package com.pitchedapps.frost.overlay

import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat
import com.google.common.flogger.FluentLogger
import com.pitchedapps.frost.compose.FrostTheme
import dagger.hilt.android.AndroidEntryPoint
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull

@AndroidEntryPoint
class WebOverlayActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
logger.atInfo().log("onCreate overlay activity")
WindowCompat.setDecorFitsSystemWindows(window, false)

setContent { FrostTheme { WebOverlayScreen() } }
}

/**
* Attempts to parse the action url Returns [true] if no action exists or if the action has been
* consumed, [false] if we need to notify the user of a bad action
*
* TODO Check if share action needs to be merged? Looks like this is both for sharing out of Frost
* and sharing into Frost
*/
private fun Intent.parseActionSend(): Boolean {
if (action != Intent.ACTION_SEND || type != "text/plain") return true
val text = getStringExtra(Intent.EXTRA_TEXT) ?: return true
val url = text.toHttpUrlOrNull()?.toString()
return if (url == null) {
logger.atInfo().log("Attempted to share a non-url")
logger.atFinest().log("Shared text %s", text)
// finish?
finish()
// intent.putExtra(ARG_URL, FbItem.FEED.url)
false
} else {
logger.atInfo().log("Sharing url through overlay")
logger.atFinest().log("Shared url %s", url)
// putExtra(ARG_URL, "${FB_URL_BASE}sharer/sharer.php?u=$url")
true
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2023 Allan Wang
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.pitchedapps.frost.overlay

import androidx.compose.runtime.Composable

@Composable fun WebOverlayScreen() {}

0 comments on commit ffd6a68

Please sign in to comment.