[tbb-commits] [Git][tpo/applications/tor-browser][tor-browser-128.2.0esr-14.0-1] fixup! [android] Add Tor integration and UI

morgan (@morgan) git at gitlab.torproject.org
Thu Sep 5 21:15:43 UTC 2024



morgan pushed to branch tor-browser-128.2.0esr-14.0-1 at The Tor Project / Applications / Tor Browser


Commits:
13947ad8 by clairehurst at 2024-09-05T14:41:54-06:00
fixup! [android] Add Tor integration and UI

Bug_42655: Implement "New circuit for this site" on Android

- - - - -


6 changed files:

- mobile/android/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineSession.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenu.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarMenu.kt
- + mobile/android/fenix/app/src/main/res/drawable/new_circuit.xml
- mobile/android/fenix/app/src/main/res/values/torbrowser_strings.xml


Changes:

=====================================
mobile/android/android-components/components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineSession.kt
=====================================
@@ -1808,6 +1808,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


=====================================
mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt
=====================================
@@ -16,6 +16,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.ext.getUrl
 import mozilla.components.browser.state.selector.findCustomTabOrSelectedTab
@@ -430,6 +431,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()
+                }
+            }
         }
     }
 
@@ -513,6 +521,10 @@ class DefaultBrowserToolbarMenuController(
                     "translate",
                 ),
             )
+
+            ToolbarMenu.Item.NewTorCircuit -> {
+                /* Tor doesn't use telemetry and therefore this doesn't need to be implemented */
+            }
         }
     }
 


=====================================
mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenu.kt
=====================================
@@ -16,7 +16,6 @@ import kotlinx.coroutines.flow.distinctUntilChangedBy
 import kotlinx.coroutines.flow.mapNotNull
 import kotlinx.coroutines.launch
 import mozilla.components.browser.menu.BrowserMenuHighlight
-import mozilla.components.browser.menu.BrowserMenuItem
 import mozilla.components.browser.menu.WebExtensionBrowserMenuBuilder
 import mozilla.components.browser.menu.item.BrowserMenuDivider
 import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem
@@ -32,7 +31,6 @@ import mozilla.components.browser.state.state.TabSessionState
 import mozilla.components.browser.state.store.BrowserStore
 import mozilla.components.concept.storage.BookmarksStorage
 import mozilla.components.feature.top.sites.PinnedSiteStorage
-import mozilla.components.feature.webcompat.reporter.WebCompatReporterFeature
 import mozilla.components.lib.state.ext.flowScoped
 import mozilla.components.support.ktx.android.content.getColorFromAttr
 import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged
@@ -211,6 +209,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,
@@ -409,6 +415,8 @@ open class DefaultToolbarMenu(
                 if (shouldUseBottomToolbar || !shouldShowMenuToolbar) null else menuToolbar,
                 newTabItem,
                 BrowserMenuDivider(),
+                newCircuitItem,
+                BrowserMenuDivider(),
                 bookmarksItem,
                 //historyItem,
                 downloadsItem,


=====================================
mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarMenu.kt
=====================================
@@ -55,6 +55,7 @@ interface ToolbarMenu {
         object Passwords : Item()
         object Downloads : Item()
         object NewTab : Item()
+        object NewTorCircuit : Item()
     }
 
     val menuBuilder: BrowserMenuBuilder


=====================================
mobile/android/fenix/app/src/main/res/drawable/new_circuit.xml
=====================================
@@ -0,0 +1,7 @@
+<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>


=====================================
mobile/android/fenix/app/src/main/res/values/torbrowser_strings.xml
=====================================
@@ -31,6 +31,8 @@
 
     <string name="tor_explore_privately">Explore. Privately.</string>
 
+    <string name="library_new_circuit">New circuit</string>
+
     <string name="preferences_tor_connection_settings_title">Connection</string>
     <string name="preferences_tor_network_settings">Tor Network</string>
     <string name="preferences_tor_network_settings_explanation">Tor Browser routes your traffic over the Tor Network, run by thousands of volunteers around the world.</string>



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/13947ad82b88522e46cd250c600475e27cc3e87d

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/13947ad82b88522e46cd250c600475e27cc3e87d
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240905/6aedce52/attachment-0001.htm>


More information about the tbb-commits mailing list