|
1
|
+/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
4
|
+
|
1
|
5
|
package org.mozilla.fenix.tor
|
2
|
6
|
|
3
|
7
|
import android.os.Bundle
|
... |
... |
@@ -8,15 +12,11 @@ import android.view.ViewGroup |
8
|
12
|
import androidx.fragment.app.Fragment
|
9
|
13
|
import org.mozilla.fenix.R
|
10
|
14
|
import org.mozilla.fenix.components.Components
|
11
|
|
-import org.mozilla.fenix.databinding.FragmentHomeBinding
|
12
|
|
-import org.mozilla.fenix.databinding.FragmentTorConnectionAssistBinding
|
13
|
15
|
import org.mozilla.fenix.databinding.TorBootstrapLoggerBinding
|
14
|
|
-import org.mozilla.fenix.databinding.TorNetworkSettingsBetaConnectionFeaturesBinding
|
15
|
|
-import org.mozilla.fenix.ext.components
|
16
|
16
|
import org.mozilla.fenix.ext.requireComponents
|
17
|
17
|
import org.mozilla.fenix.tor.view.TorBootstrapLoggerViewHolder
|
18
|
18
|
|
19
|
|
-class TorLogsFragment(): Fragment(), TorLogs {
|
|
19
|
+class TorLogsFragment : Fragment(), TorLogs {
|
20
|
20
|
|
21
|
21
|
private var entries = mutableListOf<String>()
|
22
|
22
|
internal var _binding: TorBootstrapLoggerBinding? = null
|
... |
... |
@@ -35,15 +35,17 @@ class TorLogsFragment(): Fragment(), TorLogs { |
35
|
35
|
|
36
|
36
|
components.torController.registerTorLogListener(this)
|
37
|
37
|
|
38
|
|
- val currentEntries = components.torController.logEntries
|
39
|
|
- .filter { it.second != null }
|
|
38
|
+ val currentEntries = components.torController.logEntries.filter { it.second != null }
|
40
|
39
|
.filter { !(it.second!!.startsWith("Circuit") && it.first == "ON") }
|
41
|
40
|
// Keep synchronized with format in onTorStatusUpdate
|
42
|
41
|
.flatMap { listOf("(${it.first}) '${it.second}'") }
|
43
|
42
|
val entriesLen = currentEntries.size
|
44
|
|
- val subListOffset = if (entriesLen > TorBootstrapLoggerViewHolder.MAX_NEW_ENTRIES) TorBootstrapLoggerViewHolder.MAX_NEW_ENTRIES else entriesLen
|
45
|
|
- entries = currentEntries.subList((entriesLen - subListOffset), entriesLen) as MutableList<String>
|
46
|
|
- val initLog = "---------------" + getString(R.string.tor_initializing_log) + "---------------"
|
|
43
|
+ val subListOffset =
|
|
44
|
+ if (entriesLen > TorBootstrapLoggerViewHolder.MAX_NEW_ENTRIES) TorBootstrapLoggerViewHolder.MAX_NEW_ENTRIES else entriesLen
|
|
45
|
+ entries =
|
|
46
|
+ currentEntries.subList((entriesLen - subListOffset), entriesLen) as MutableList<String>
|
|
47
|
+ val initLog =
|
|
48
|
+ "---------------" + getString(R.string.tor_initializing_log) + "---------------"
|
47
|
49
|
entries.add(0, initLog)
|
48
|
50
|
|
49
|
51
|
with(binding.torBootstrapLogEntries) {
|