www.fgks.org   »   [go: up one dir, main page]

Skip to content

Commit

Permalink
Merge branch 'master' of github.com:guardianproject/orbot
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Mar 22, 2023
2 parents 79b343c + 8708a26 commit 2d7bc4e
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 140 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Tor Frequently Asked Questions:
https://support.torproject.org/faq/

***********************************************
Copyright (c) 2009-2013, Nathan Freitas, The Guardian Project
**Copyright (c) 2009-2023, Nathan Freitas, The Guardian Project**
* https://guardianproject.info/
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class ConfigConnectionBottomSheet(private val callbacks: ConnectionHelperCallbac

private fun askTor () {

var dLeft = activity?.getDrawable(R.drawable.ic_faq)
val dLeft = activity?.getDrawable(R.drawable.ic_faq)
btnAskTor.text = getString(R.string.asking)
btnAskTor.setCompoundDrawablesWithIntrinsicBounds(dLeft, null, null, null)

Expand Down Expand Up @@ -197,16 +197,16 @@ class ConfigConnectionBottomSheet(private val callbacks: ConnectionHelperCallbac

// Try to get country code from TelephonyManager service
val tm = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
if (tm != null) {
// Query first getSimCountryIso()
countryCode = tm.simCountryIso
if (countryCode != null && countryCode.length == 2)
return countryCode.lowercase(Locale.getDefault())

countryCode = tm.networkCountryIso
if (countryCode != null && countryCode.length == 2)
return countryCode.lowercase(Locale.getDefault())
}

// Query first getSimCountryIso()
countryCode = tm.simCountryIso
if (countryCode != null && countryCode.length == 2)
return countryCode.lowercase(Locale.getDefault())

countryCode = tm.networkCountryIso
if (countryCode != null && countryCode.length == 2)
return countryCode.lowercase(Locale.getDefault())


// If network country not available (tablets maybe), get country code from Locale class
countryCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Expand All @@ -222,7 +222,7 @@ class ConfigConnectionBottomSheet(private val callbacks: ConnectionHelperCallbac

private fun setPreferenceForSmartConnect() {

var dLeft = activity?.getDrawable(R.drawable.ic_green_check)
val dLeft = activity?.getDrawable(R.drawable.ic_green_check)
btnAskTor.setCompoundDrawablesWithIntrinsicBounds(dLeft, null, null, null)

circumventionApiBridges?.let {
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/org/torproject/android/ConnectFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks, ExitNodeDialogFra
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
var view = inflater.inflate(R.layout.fragment_connect, container, false)
val view = inflater.inflate(R.layout.fragment_connect, container, false)
view?.let {

tvTitle = it.findViewById(R.id.tvTitle)
Expand Down Expand Up @@ -139,12 +139,12 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks, ExitNodeDialogFra
return false
}

public fun stopTorAndVpn() {
fun stopTorAndVpn() {
sendIntentToService(OrbotConstants.ACTION_STOP)
sendIntentToService(OrbotConstants.ACTION_STOP_VPN)
}

public fun sendNewnymSignal() {
fun sendNewnymSignal() {
sendIntentToService(TorControlCommands.SIGNAL_NEWNYM)
ivOnion.animate().alpha(0f).duration = 500
Handler().postDelayed({ ivOnion.animate().alpha(1f).duration = 500 }, 600)
Expand All @@ -157,7 +157,7 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks, ExitNodeDialogFra
private fun startTorAndVpnDelay(@Suppress("SameParameterValue") ms: Long) = Handler(Looper.getMainLooper()).postDelayed({startTorAndVpn()}, ms)


public fun startTorAndVpn() {
fun startTorAndVpn() {
val vpnIntent = VpnService.prepare(requireActivity())
if (vpnIntent != null && (!Prefs.isPowerUserMode())) {
startActivityForResult(vpnIntent, OrbotActivity.REQUEST_CODE_VPN)
Expand All @@ -171,7 +171,7 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks, ExitNodeDialogFra
}
}

public fun refreshMenuList (context: Context) {
fun refreshMenuList (context: Context) {

val listItems = arrayListOf(OrbotMenuAction(R.string.btn_change_exit, 0) {openExitNodeDialog()},
OrbotMenuAction(R.string.btn_refresh, R.drawable.ic_refresh) {sendNewnymSignal()},
Expand Down Expand Up @@ -212,7 +212,7 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks, ExitNodeDialogFra
}


public fun doLayoutNoInternet(context : Context) {
fun doLayoutNoInternet(context : Context) {

ivOnion.setImageResource(R.drawable.nointernet)

Expand All @@ -233,7 +233,7 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks, ExitNodeDialogFra

}

public fun doLayoutOn(context : Context) {
fun doLayoutOn(context : Context) {

ivOnion.setImageResource(R.drawable.orbion)

Expand All @@ -256,7 +256,7 @@ class ConnectFragment : Fragment(), ConnectionHelperCallbacks, ExitNodeDialogFra
}
}

public fun doLayoutOff() {
fun doLayoutOff() {

ivOnion.setImageResource(R.drawable.orbioff)
(ivOnion.layoutParams as ViewGroup.MarginLayoutParams).topMargin = 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ class CustomBridgeBottomSheet(private val callbacks: ConnectionHelperCallbacks):
}

private fun updateUi() {
if (etBridges.text.isEmpty() || !etBridges.text.contains(bridgeStatement)) {
btnAction.isEnabled = false
} else {
btnAction.isEnabled = true
}
btnAction.isEnabled =
!(etBridges.text.isEmpty() || !etBridges.text.contains(bridgeStatement))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class KindessConfigBottomSheet(): OrbotBottomSheetDialogFragment() {
v.findViewById<View>(R.id.tvCancel).setOnClickListener { dismiss() }
btnAction = v.findViewById(R.id.btnAction)

var configWifi = v.findViewById<SwitchCompat>(R.id.swKindnessConfigWifi)
var configCharging = v.findViewById<SwitchCompat>(R.id.swKindnessConfigCharging)
val configWifi = v.findViewById<SwitchCompat>(R.id.swKindnessConfigWifi)
val configCharging = v.findViewById<SwitchCompat>(R.id.swKindnessConfigCharging)

btnAction.setOnClickListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class KindnessFragment : Fragment() {
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
var view = inflater.inflate(R.layout.fragment_kindness, container, false)
val view = inflater.inflate(R.layout.fragment_kindness, container, false)
tvAlltimeTotal = view.findViewById<TextView>(R.id.tvAlltimeTotal)
tvWeeklyTotal = view.findViewById<TextView>(R.id.tvWeeklyTotal)
swVolunteerMode = view.findViewById<SwitchCompat>(R.id.swVolunteerMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class MoatBottomSheet(private val callbacks: ConnectionHelperCallbacks): OrbotBo
}

private fun displayError(exception: Exception, response: JSONObject?) {
Log.d("bim", "DISPLAY ERROR: $exception")
Log.d("MoatBottomSheet", "DISPLAY ERROR: $exception")
}

private fun onBridgeRequestSuccess(bridges: String) {
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/torproject/android/MoreFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class MoreFragment : Fragment() {
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
var view = inflater.inflate(R.layout.fragment_more, container, false)
val view = inflater.inflate(R.layout.fragment_more, container, false)

var tvVersion = view.findViewById<TextView>(R.id.tvVersion)
val tvVersion = view.findViewById<TextView>(R.id.tvVersion)
tvVersion.text = "Tor v" + getTorVersion()


Expand Down Expand Up @@ -107,8 +107,8 @@ class MoreFragment : Fragment() {
.setAction(OrbotConstants.ACTION_STOP)
.putExtra(OrbotConstants.ACTION_STOP_FOREGROUND_TASK, true)
sendIntentToService(OrbotConstants.ACTION_STOP_VPN)
requireActivity()?.startService(killIntent)
requireActivity()?.finish()
requireActivity().startService(killIntent)
requireActivity().finish()
}

private fun sendIntentToService(intent: Intent) = ContextCompat.startForegroundService(requireActivity(), intent)
Expand Down
38 changes: 11 additions & 27 deletions app/src/main/java/org/torproject/android/OrbotActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import android.widget.*
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.localbroadcastmanager.content.LocalBroadcastManager
Expand All @@ -28,9 +27,9 @@ class OrbotActivity : AppCompatActivity() {
private lateinit var bottomNavigationView: BottomNavigationView

private lateinit var logBottomSheet: LogBottomSheet
public lateinit var fragConnect : ConnectFragment
lateinit var fragConnect : ConnectFragment

public var previousReceivedTorStatus: String? = null
var previousReceivedTorStatus: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -67,25 +66,23 @@ class OrbotActivity : AppCompatActivity() {

private fun sendIntentToService(intent: Intent) = ContextCompat.startForegroundService(this, intent)
private fun sendIntentToService(action: String) = sendIntentToService(
android.content.Intent(
this,
org.torproject.android.service.OrbotService::class.java
).apply {
android.content.Intent(this, org.torproject.android.service.OrbotService::class.java)
.apply {
this.action = action
})

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_CODE_VPN && resultCode == RESULT_OK) {
fragConnect?.startTorAndVpn()
fragConnect.startTorAndVpn()
} else if (requestCode == REQUEST_CODE_SETTINGS && resultCode == RESULT_OK) {
Prefs.setDefaultLocale(data?.getStringExtra("locale"))
(application as OrbotApp).setLocale()
finish()
startActivity(Intent(this, OrbotActivity::class.java))
} else if (requestCode == REQUEST_VPN_APP_SELECT && resultCode == RESULT_OK) {
sendIntentToService(OrbotConstants.ACTION_RESTART_VPN) // is this enough todo?
fragConnect?.refreshMenuList(this)
fragConnect.refreshMenuList(this)
}
}

Expand All @@ -111,13 +108,13 @@ class OrbotActivity : AppCompatActivity() {
if (Prefs.getConnectionPathway().equals(Prefs.PATHWAY_SMART)) {
shouldDoOffLayout = false
}
if (shouldDoOffLayout) fragConnect?.doLayoutOff()
if (shouldDoOffLayout) fragConnect.doLayoutOff()
}
else
fragConnect?.doLayoutOff()
fragConnect.doLayoutOff()
}
OrbotConstants.STATUS_STARTING -> fragConnect?.doLayoutStarting(this@OrbotActivity)
OrbotConstants.STATUS_ON -> fragConnect?.doLayoutOn(this@OrbotActivity)
OrbotConstants.STATUS_STARTING -> fragConnect.doLayoutStarting(this@OrbotActivity)
OrbotConstants.STATUS_ON -> fragConnect.doLayoutOn(this@OrbotActivity)
OrbotConstants.STATUS_STOPPING -> {}
}

Expand All @@ -142,28 +139,15 @@ class OrbotActivity : AppCompatActivity() {
}
}










companion object {
const val REQUEST_CODE_VPN = 1234
const val REQUEST_CODE_SETTINGS = 2345
const val REQUEST_VPN_APP_SELECT = 2432
val CAN_DO_APP_ROUTING = PermissionManager.isLollipopOrHigher()
}



public fun showLog() {
fun showLog() {
logBottomSheet.show(supportFragmentManager, OrbotActivity::class.java.simpleName)

}


}
6 changes: 1 addition & 5 deletions app/src/main/res/layout/activity_orbot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
android:layout_height="match_parent"
android:backgroundTint="@color/new_background"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
>
xmlns:app="http://schemas.android.com/apk/res-auto">

<fragment
android:id="@+id/nav_fragment"
Expand All @@ -33,6 +31,4 @@
app:itemIconTint="@color/bottom_nav_color"
/>



</androidx.constraintlayout.widget.ConstraintLayout>
28 changes: 18 additions & 10 deletions app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
<string name="volunteer_mode_subtitle">Помогнете на други да бъдат свързани</string>
<string name="btn_start_vpn">Пускане на VPN</string>
<string name="connected_title">Свързани</string>
<string name="btn_configure">Настройки</string>
<string name="btn_configure">Настройки на връзката</string>
<string name="btn_tor_off">Изключване на Тор</string>
<string name="btn_refresh">Презареждане</string>
<string name="btn_use_custom_bridge">Използване на потребителски мост</string>
Expand All @@ -231,7 +231,7 @@
<string name="volunteer_mode_weekly_label">Общо седмично</string>
<string name="volunteer_mode_alltime_label">Общо за цялото време</string>
<string name="smart_connect">Интелигентна връзка (подразбирано)</string>
<string name="snowflake">Снежинка</string>
<string name="snowflake">Снежинка (оригинална)</string>
<string name="snowflake_subtitle">Връзката се осъществява през доброволци на Тор. Заобикаля някои забрани на Тор.</string>
<string name="custom_bridge">Потребителски мост</string>
<string name="connect">Свързване</string>
Expand All @@ -243,17 +243,14 @@
<string name="ports_not_set">Няма зададени портове</string>
<string name="volunteer_mode_subtitle_desc">Режимът на доброта дава възможност устройството ви да бъде използвано като мост. Така други потребители могат да ползват Тор, на места където е забранен.
\n
\n– Не изразходва батерията
\n
\n– Не забавя връзката с интернет
\n
\n– Работи само през безжична мрежа
\n
\n– Може да бъде спрян по всяко време</string>
\n• не изразходва батерията
\n• не забавя връзката с интернет
\n• работи само през безжична мрежа
\n• може да бъде спрян по всяко време</string>
<string name="smart_connect_subtitle">Orbot се опитва да осъществи връзка по всички възможни начини: директен, Снежинка, мост.</string>
<string name="direct_connect">Директна връзка с Тор</string>
<string name="direct_connect_subtitle">Най-добрия начин за свързване с Тор. Използвайте ако Тор не е забранен.</string>
<string name="get_a_bridge">Получаване на мост от Тор (Obfs4)</string>
<string name="get_a_bridge">Мост от Тор (Obfs4)</string>
<string name="custom_bridge_subtitle">Най-голяма вероятност да поддържа непрекъсната връзка с Тор при сериозни забрани на Тор. Изисква адрес на мост от човек, на когото имате доверие.</string>
<string name="get_a_bridge_subtitle">Прикрива трафика ви. Заобикаля някои забрани на Тор.</string>
<string name="having_trouble">Има проблем</string>
Expand All @@ -272,4 +269,15 @@
<string name="title_choose_apps">Избор на приложения</string>
<string name="hide_apps">Скрийте приложенията от наблюдение на мрежата и получете достъп, когато са блокирани.</string>
<string name="log_copied">Дневникът е копиран</string>
<string name="snowflake_amp">Снежинка (AMP)</string>
<string name="action_use">Използване</string>
<string name="asking">ЗАПИТВАНЕ…</string>
<string name="no_interent_title">Свържете се с интернет</string>
<string name="hello_blank_fragment">Празен низ</string>
<string name="kindness_adjust_title">Настройка на работата…</string>
<string name="no_internet_subtitle">За да използвате Orbot е необходим достъп до интернет.</string>
<string name="not_sure">Не сте сигурни\?</string>
<string name="ask_tor">Попитайте Тор</string>
<string name="many_ways">Има много начини за достъп до Тор. Някои може да работят по-добре от други.</string>
<string name="kindess_config_detail">Настройте как и кога устройството ви да бъде използвано като посредник на Снежинка за другите потребители на мрежата на Тор.</string>
</resources>

0 comments on commit 2d7bc4e

Please sign in to comment.