Add preference to open custom tab for searching apps
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -41,6 +41,8 @@ object Constants {
|
||||
|
||||
const val URL_DISPENSER = "https://auroraoss.com/api/auth"
|
||||
|
||||
const val PLAY_QUERY_URL = "https://play.google.com/store/search?q="
|
||||
|
||||
//ACCOUNTS
|
||||
const val ACCOUNT_SIGNED_IN = "ACCOUNT_SIGNED_IN"
|
||||
const val ACCOUNT_SIGNED_TIMESTAMP = "ACCOUNT_SIGNED_TIMESTAMP"
|
||||
@@ -51,4 +53,4 @@ object Constants {
|
||||
const val PAGE_TYPE = "PAGE_TYPE"
|
||||
const val TOP_CHART_TYPE = "TOP_CHART_TYPE"
|
||||
const val TOP_CHART_CATEGORY = "TOP_CHART_CATEGORY"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,14 @@ import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
import androidx.core.app.ShareCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import com.aurora.Constants
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
import com.aurora.store.MainActivity
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.util.Log
|
||||
import com.aurora.store.util.Preferences
|
||||
import com.aurora.store.view.ui.details.AppDetailsActivity
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
val Context.inflater: LayoutInflater
|
||||
@@ -50,11 +52,26 @@ val Context.inflater: LayoutInflater
|
||||
val Context.displayMetrics: DisplayMetrics
|
||||
get() = resources.displayMetrics
|
||||
|
||||
fun Context.browse(url: String) {
|
||||
fun Context.browse(url: String, showOpenInAuroraAction: Boolean = false) {
|
||||
try {
|
||||
CustomTabsIntent.Builder()
|
||||
.build()
|
||||
.launchUrl(this, Uri.parse(url))
|
||||
val customTabsIntent = CustomTabsIntent.Builder()
|
||||
if (showOpenInAuroraAction) {
|
||||
val icon =
|
||||
ContextCompat.getDrawable(this, R.drawable.ic_open_in_new)?.toBitmap()
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
Intent(this, AppDetailsActivity::class.java),
|
||||
PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
customTabsIntent.setActionButton(
|
||||
icon!!,
|
||||
this.getString(R.string.open_in_aurora),
|
||||
pendingIntent,
|
||||
true
|
||||
)
|
||||
}
|
||||
customTabsIntent.build().launchUrl(this, Uri.parse(url))
|
||||
} catch (e: Exception) {
|
||||
Log.e(e.message)
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ object Preferences {
|
||||
|
||||
const val PREFERENCE_UPDATES_EXTENDED = "PREFERENCE_UPDATES_EXTENDED"
|
||||
|
||||
const val PREFERENCE_ADVANCED_SEARCH_IN_CTT = "PREFERENCE_ADVANCED_SEARCH_IN_CTT"
|
||||
|
||||
const val PREFERENCE_UNIQUE_GROUP_IDS = "PREFERENCE_UNIQUE_GROUP_IDS"
|
||||
|
||||
private var prefs: SharedPreferences? = null
|
||||
|
||||
@@ -28,12 +28,14 @@ import android.view.inputmethod.EditorInfo
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.aurora.Constants
|
||||
import com.aurora.extensions.browse
|
||||
import com.aurora.extensions.close
|
||||
import com.aurora.extensions.getEmptyActivityBundle
|
||||
import com.aurora.extensions.open
|
||||
import com.aurora.extensions.showKeyboard
|
||||
import com.aurora.gplayapi.SearchSuggestEntry
|
||||
import com.aurora.store.databinding.ActivitySearchSuggestionBinding
|
||||
import com.aurora.store.util.Preferences
|
||||
import com.aurora.store.view.epoxy.views.SearchSuggestionViewModel_
|
||||
import com.aurora.store.view.ui.commons.BaseActivity
|
||||
import com.aurora.store.view.ui.downloads.DownloadActivity
|
||||
@@ -149,8 +151,12 @@ class SearchSuggestionActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private fun search(query: String) {
|
||||
val intent = Intent(this, SearchResultsActivity::class.java)
|
||||
intent.putExtra(Constants.STRING_EXTRA, query)
|
||||
startActivity(intent, getEmptyActivityBundle())
|
||||
if (Preferences.getBoolean(this, Preferences.PREFERENCE_ADVANCED_SEARCH_IN_CTT)) {
|
||||
this.browse("${Constants.PLAY_QUERY_URL}$query", true)
|
||||
} else {
|
||||
val intent = Intent(this, SearchResultsActivity::class.java)
|
||||
intent.putExtra(Constants.STRING_EXTRA, query)
|
||||
startActivity(intent, getEmptyActivityBundle())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user