Commit ecd31d76 authored by clairehurst's avatar clairehurst 🌱 Committed by Pier Angelo Vendrame
Browse files

TB 42655 [android]: Implement "New circuit for this site" on Android

parent 8ae1c5a8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1574,6 +1574,10 @@ class GeckoEngineSession(
        geckoSession.translationsSessionDelegate = GeckoTranslateSessionDelegate(this)
    }

    fun newTorCircuit() {
        geckoSession.newTorCircuit()
    }

    companion object {
        internal const val PROGRESS_START = 25
        internal const val PROGRESS_STOP = 100
+12 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import mozilla.appservices.places.BookmarkRoot
import mozilla.components.browser.engine.gecko.GeckoEngineSession
import mozilla.components.browser.state.action.EngineAction
import mozilla.components.browser.state.action.ShareResourceAction
import mozilla.components.browser.state.ext.getUrl
@@ -446,6 +447,13 @@ class DefaultBrowserToolbarMenuController(
                    BrowserFragmentDirections.actionBrowserFragmentToTranslationsDialogFragment()
                navController.navigateSafe(R.id.browserFragment, directions)
            }

            ToolbarMenu.Item.NewTorCircuit -> {
                currentSession?.let {
                    sessionUseCases.reload.invoke(it.id)
                    (it.engineState.engineSession as GeckoEngineSession).newTorCircuit()
                }
            }
        }
    }

@@ -576,6 +584,10 @@ class DefaultBrowserToolbarMenuController(
                    "translate",
                ),
            )

            ToolbarMenu.Item.NewTorCircuit -> {
                /* Tor doesn't use telemetry and therefore this doesn't need to be implemented */
            }
        }
    }

+10 −0
Original line number Diff line number Diff line
@@ -228,6 +228,14 @@ open class DefaultToolbarMenu(
        onItemTapped.invoke(ToolbarMenu.Item.NewTab)
    }

    private val newCircuitItem = BrowserMenuImageText(
        context.getString(R.string.library_new_circuit),
        R.drawable.new_circuit,
        primaryTextColor(),
    ) {
        onItemTapped.invoke(ToolbarMenu.Item.NewTorCircuit)
    }

    private val historyItem = BrowserMenuImageText(
        context.getString(R.string.library_history),
        R.drawable.ic_history,
@@ -434,6 +442,8 @@ open class DefaultToolbarMenu(
                if (shouldUseBottomToolbar) null else menuToolbar,
                newTabItem,
                BrowserMenuDivider(),
                newCircuitItem,
                BrowserMenuDivider(),
                bookmarksItem,
                if (context.settings().shouldDisableNormalMode) null else historyItem,
                downloadsItem,
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ interface ToolbarMenu {
        object Passwords : Item()
        object Downloads : Item()
        object NewTab : Item()
        object NewTorCircuit : Item()
    }

    val menuBuilder: BrowserMenuBuilder
+7 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="16dp" android:viewportHeight="16" android:viewportWidth="16" android:width="16dp">

    <path android:fillColor="#5B5B66" android:fillType="evenOdd" android:pathData="M10.599,2.897C9.522,2.349 8.298,2.155 7.104,2.344C6.642,2.417 6.195,2.546 5.769,2.726C5.822,2.91 5.85,3.105 5.85,3.307C5.85,4.48 4.898,5.432 3.725,5.432C2.551,5.432 1.6,4.48 1.6,3.307C1.6,2.133 2.551,1.182 3.725,1.182C4.238,1.182 4.708,1.363 5.075,1.666C5.654,1.399 6.271,1.21 6.908,1.109C8.363,0.879 9.854,1.115 11.167,1.784C12.479,2.452 13.547,3.52 14.216,4.832C14.885,6.145 15.121,7.635 14.891,9.09C14.837,9.431 14.517,9.664 14.176,9.61C13.835,9.556 13.602,9.236 13.656,8.895C13.845,7.701 13.651,6.477 13.102,5.4C12.553,4.322 11.677,3.446 10.599,2.897ZM4.65,3.307C4.65,3.818 4.235,4.232 3.725,4.232C3.214,4.232 2.8,3.818 2.8,3.307C2.8,2.796 3.214,2.382 3.725,2.382C4.235,2.382 4.65,2.796 4.65,3.307Z"/>

    <path android:fillColor="#5B5B66" android:fillType="evenOdd" android:pathData="M1.824,6.39C2.165,6.444 2.398,6.764 2.344,7.105C2.155,8.299 2.349,9.523 2.898,10.6C3.447,11.678 4.323,12.554 5.401,13.103C6.478,13.651 7.702,13.845 8.896,13.656C9.356,13.583 9.803,13.455 10.227,13.276C10.173,13.088 10.144,12.891 10.144,12.686C10.144,11.512 11.096,10.561 12.269,10.561C13.443,10.561 14.394,11.512 14.394,12.686C14.394,13.86 13.443,14.811 12.269,14.811C11.76,14.811 11.293,14.632 10.927,14.333C10.347,14.601 9.73,14.79 9.092,14.891C7.637,15.121 6.146,14.885 4.833,14.216C3.52,13.548 2.453,12.481 1.784,11.168C1.115,9.855 0.879,8.365 1.109,6.91C1.163,6.569 1.483,6.336 1.824,6.39ZM13.194,12.686C13.194,13.197 12.78,13.611 12.269,13.611C11.759,13.611 11.344,13.197 11.344,12.686C11.344,12.175 11.759,11.761 12.269,11.761C12.78,11.761 13.194,12.175 13.194,12.686Z"/>

</vector>