Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
fenix
Commits
49bea73a
Commit
49bea73a
authored
Sep 09, 2020
by
Matthew Finkel
Browse files
Bug 40028: Define bootstrapping events and Quick Start
parent
4e57d3c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/mozilla/fenix/tor/bootstrap/TorQuickStart.kt
0 → 100644
View file @
49bea73a
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package
org.mozilla.fenix.tor.bootstrap
import
android.content.Context
import
android.content.SharedPreferences
import
android.os.StrictMode
import
androidx.annotation.VisibleForTesting
import
mozilla.components.support.ktx.android.content.PreferencesHolder
import
mozilla.components.support.ktx.android.content.booleanPreference
import
org.mozilla.fenix.ext.application
import
org.mozilla.fenix.ext.components
class
TorQuickStart
(
val
context
:
Context
)
:
PreferencesHolder
{
override
val
preferences
:
SharedPreferences
=
context
.
components
.
strictMode
.
resetAfter
(
StrictMode
.
allowThreadDiskReads
())
{
context
.
getSharedPreferences
(
PREF_NAME_TOR_BOOTSTRAP_KEY
,
Context
.
MODE_PRIVATE
)
}
private
var
torQuickStart
by
booleanPreference
(
TOR_QUICK_START
,
default
=
false
)
fun
quickStartTor
()
=
context
.
components
.
strictMode
.
resetAfter
(
StrictMode
.
allowThreadDiskReads
())
{
torQuickStart
}
fun
enableQuickStartTor
()
{
torQuickStart
=
true
}
fun
disableQuickStartTor
()
{
torQuickStart
=
false
}
fun
setQuickStartTor
(
enabled
:
Boolean
)
=
if
(
enabled
)
{
enableQuickStartTor
()
}
else
{
disableQuickStartTor
()
}
companion
object
{
/**
* Name of the shared preferences file.
*/
private
const
val
PREF_NAME_TOR_BOOTSTRAP_KEY
=
"tor.bootstrap"
/**
* Key for [quickStartTor].
*/
@VisibleForTesting
internal
const
val
TOR_QUICK_START
=
"tor.bootstrap.quick_start_enabled"
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment