Skip to content

Commit

Permalink
✨ Better Deeplinking
Browse files Browse the repository at this point in the history
  • Loading branch information
ejaz4 committed Jan 15, 2022
1 parent 51af630 commit 62f25e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
1 change: 0 additions & 1 deletion app/src/main/java/co/dothq/browser/BrowserActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import co.dothq.browser.subactivities.AddressBar
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.GeckoView
import java.net.MalformedURLException
import java.net.URL


Expand Down
21 changes: 15 additions & 6 deletions app/src/main/java/co/dothq/browser/BrowserDelegates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package co.dothq.browser

import android.app.Activity
import android.content.Context
import android.graphics.drawable.Drawable
import android.net.Uri
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import co.dothq.browser.managers.StorageManager
Expand All @@ -25,11 +23,14 @@ class BrowserDelegates {
if (area == "main") {
val activity: Activity = (context as Activity)
val contextualIdIcon = activity.findViewById<ImageView>(R.id.contextIdentityIcon)
val deeplinkContextualIdIcon = activity.findViewById<ImageView>(R.id.deeplinkContextIdentityIcon)



if (securityInfo.isSecure) contextualIdIcon.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.ic_secure_filled))
if (!securityInfo.isSecure) contextualIdIcon.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.ic_unsecure_filled))
if (securityInfo.isSecure) {
contextualIdIcon.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.ic_secure_filled))
} else {
contextualIdIcon.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.ic_unsecure_filled))
}

StorageManager().set(applicationCtx, "contextualIdentity", securityInfo.isSecure, "appValues");
}
Expand Down Expand Up @@ -60,20 +61,28 @@ class BrowserDelegates {
)

val uri: Uri = url.toString().toUri();
val host = uri.host.toString();
var host = uri.host.toString();

if (host.startsWith("www.")) {
host = host.replace("www.", "")
}

val path = url.toString().replace("${uri.scheme}://${uri.host}", "");

if (area == "main") {
val activity: Activity = (context as Activity)

activity.findViewById<TextView>(R.id.addressBarDomain).text =
host.toString();
activity.findViewById<TextView>(R.id.deeplinkAddressBarDomain).text =
host.toString();

if (path != "/") activity.findViewById<TextView>(R.id.addressBarPath).text = path
if (path == "/") activity.findViewById<TextView>(R.id.addressBarPath).text = ""

if (path == "about:blank") {
activity.findViewById<TextView>(R.id.addressBarDomain).text = ""
activity.findViewById<TextView>(R.id.deeplinkAddressBarDomain).text = ""
activity.findViewById<TextView>(R.id.addressBarPath).text = ""
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
android:orientation="vertical">

<ImageView
android:id="@+id/contextIdentityIcon"
android:id="@+id/deeplinkContextIdentityIcon"
android:layout_width="14dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand All @@ -85,7 +85,7 @@
android:text="Title" />

<TextView
android:id="@+id/textView5"
android:id="@+id/deeplinkAddressBarDomain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="URL"
Expand Down

0 comments on commit 62f25e7

Please sign in to comment.