Skip to content

Commit

Permalink
Merge branch 'tytydraco:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ssense1337 authored Jul 24, 2023
2 parents 8a8af6a + 76f040b commit e77c1bb
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 68 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ We also have a Telegram server here: https://t.me/ladb_support.

# Privacy Policy

LADB does not send any device data outside of the app. Your data is not collected or processed.
LADB does not send any device data outside the app. Your data is not collected or processed.
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.draco.ladb"
minSdk 26
targetSdk 33
versionCode 41
versionName "2.2.1"
versionCode 43
versionName "2.3.1"

ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
Expand Down Expand Up @@ -57,16 +57,16 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'androidx.fragment:fragment-ktx:1.5.6'
implementation 'androidx.fragment:fragment-ktx:1.6.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'

implementation 'com.github.javiersantos:PiracyChecker:1.2.8'

implementation 'com.google.android.material:material:1.7.0'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.1'
}
16 changes: 0 additions & 16 deletions app/src/main/java/com/draco/ladb/utils/ADB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -249,22 +249,6 @@ class ADB(private val context: Context) {
return processBuilder.start()!!
}

/**
* Execute a script
*/
fun sendScript(code: String) {
/* Store script locally */
val internalScript = File(scriptPath).apply {
bufferedWriter().use {
it.write(code)
}
deleteOnExit()
}

/* Execute the script here */
sendToShellProcess("sh ${internalScript.absolutePath}")
}

/**
* Send commands directly to the shell process
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,8 @@ class MainActivityViewModel(application: Application) : AndroidViewModel(applica
fun needsToPair(): Boolean {
val context = getApplication<Application>().applicationContext

if (!sharedPreferences.getBoolean(context.getString(R.string.paired_key), false) &&
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
) {
return true
}

return false
return !sharedPreferences.getBoolean(context.getString(R.string.paired_key), false) &&
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
}

fun setPairedBefore(value: Boolean) {
Expand All @@ -125,31 +120,6 @@ class MainActivityViewModel(application: Application) : AndroidViewModel(applica
}
}

/**
* Return the contents of the script from the intent
*/
fun getScriptFromIntent(intent: Intent): String? {
val context = getApplication<Application>().applicationContext

return when (intent.type) {
"text/x-sh" -> {
val extra = if (Build.VERSION.SDK_INT >= 33) {
intent.getParcelableExtra(Intent.EXTRA_STREAM, Parcelable::class.java).toString()
} else {
intent.getParcelableExtra<Parcelable?>(Intent.EXTRA_STREAM).toString()
}

val uri = Uri.parse(extra)
context.contentResolver.openInputStream(uri)?.bufferedReader().use {
it?.readText()
}
}

"text/plain" -> intent.getStringExtra(Intent.EXTRA_TEXT)
else -> null
}
}

/**
* Read the content of the ABD output file
*/
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/draco/ladb/views/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.FileProvider
import androidx.core.content.edit
import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import com.draco.ladb.BuildConfig
import com.draco.ladb.R
import com.draco.ladb.databinding.ActivityMainBinding
Expand Down Expand Up @@ -48,6 +50,7 @@ class MainActivity : AppCompatActivity() {
.setView(R.layout.dialog_pair)
.setPositiveButton(R.string.pair, null)
.setNegativeButton(R.string.help, null)
.setNeutralButton(R.string.skip, null)

binding.command.setOnKeyListener { _, keyCode, keyEvent ->
if (keyCode == KeyEvent.KEYCODE_ENTER && keyEvent.action == KeyEvent.ACTION_DOWN) {
Expand Down Expand Up @@ -176,7 +179,14 @@ class MainActivity : AppCompatActivity() {
)
.show()
}
}

getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
PreferenceManager.getDefaultSharedPreferences(context).edit(true) {
putBoolean(getString(R.string.auto_shell_key), false)
}
dismiss()
callback?.invoke(true)
}
}
}
Expand Down
29 changes: 21 additions & 8 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,29 @@
<string name="cancel">Cancel</string>
<string name="done">Done</string>
<string name="pair">Pair</string>
<string name="skip">Skip</string>
<string name="dismiss">Dismiss</string>

<string name="delete_confirm">Are you sure you want to delete this?</string>

<string name="snackbar_intent_failed">Intent failed to start</string>
<string name="snackbar_file_opened">Executing script from file</string>

<string name="developer_url">https://www.github.com/tytydraco</string>
<string name="source_url">https://www.github.com/tytydraco/LADB</string>
<string name="contact_url">mailto:[email protected]</string>
<string name="tutorial_url">https://www.xda-developers.com/debloat-your-phone-run-adb-shell-commands-no-root-no-pc</string>
<string name="tutorial_url">https://www.xda-developers.com/debloat-your-phone-run-adb-shell-commands-no-root-no-pc
</string>

<string name="paired_key">paired</string>
<string name="port_hint">Port</string>

<string name="code_hint">Pairing code</string>

<string name="pair_title">Pairing information</string>
<string name="pair_message">You must connect this device to LADB using a pairing code from the \"Wireless debugging\" page in the Developer Settings page. If you have not done this before, click \"Help\" for a tutorial.</string>
<string name="pair_message">You must connect this device to LADB using a pairing code from the \"Wireless
debugging\" page in the Developer Settings page. If you have not done this before, click \"Help\" for a
tutorial.
</string>

<string name="settings">Settings</string>
<string name="troubleshooting">Troubleshooting</string>
Expand All @@ -49,11 +53,15 @@
<string name="restart_key">restart</string>

<string name="auto_shell_title">Pair &amp; shell</string>
<string name="auto_shell_summary">Automatically enter an ADB shell; disable to enter a regular, non-adb shell without pairing</string>
<string name="auto_shell_summary">Automatically enter an ADB shell; disable to enter a regular, non-adb shell
without pairing
</string>
<string name="auto_shell_key">auto_shell</string>

<string name="buffer_size_title">Buffer size</string>
<string name="buffer_size_summary">The size of the screen output buffer. Increasing this value will show more output on the screen at once at the cost of performance. (Default: 16384)</string>
<string name="buffer_size_summary">The size of the screen output buffer. Increasing this value will show more output
on the screen at once at the cost of performance. (Default: 16384)
</string>
<string name="buffer_size_key">buffer_size</string>

<string name="startup_command_title">Startup command</string>
Expand All @@ -65,10 +73,16 @@
<string name="tutorial_key">tutorial</string>

<string name="error_waiting_title">Stuck on \"Waiting\"</string>
<string name="error_waiting_summary">Either you entered the pairing information incorrectly, or your device is not being detected. First, ensure that Wireless Debugging is actually enabled. If that does not work, Try the \"Factory reset\" setting in LADB to try pairing again.</string>
<string name="error_waiting_summary">Either you entered the pairing information incorrectly, or your device is not
being detected. First, ensure that Wireless Debugging is actually enabled. If that does not work, Try the
\"Factory reset\" setting in LADB to try pairing again.
</string>

<string name="error_no_wireless_debugging_title">No \"Wireless Debugging\" toggle</string>
<string name="error_no_wireless_debugging_summary">Your device does not natively support Wireless Debugging, which is required by LADB. Alternatively, you can use a PC to enable this feature, even on unsupported devices. It will last until the next reboot. Connect the device to a PC and type: adb tcpip 5555</string>
<string name="error_no_wireless_debugging_summary">Your device does not natively support Wireless Debugging, which
is required by LADB. Alternatively, you can use a PC to enable this feature, even on unsupported devices. It
will last until the next reboot. Connect the device to a PC and type: adb tcpip 5555
</string>

<string name="developer_title">Developer</string>
<string name="developer_summary">Tyler Nijmeh</string>
Expand All @@ -86,6 +100,5 @@
<string name="licenses_summary">View the open source licenses</string>
<string name="licenses_key">licenses</string>

<string name="pref_file" translatable="false">preferences</string>
<string name="pref_key_verified" translatable="false">verified</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<item name="android:paddingVertical">12dp</item>
</style>

<style name="BookmarkCardView" parent="Widget.Material3.CardView.Elevated">
<style name="BookmarkCardView">
<item name="android:layout_marginTop">@dimen/bookmark_card_margin</item>
<item name="android:layout_marginHorizontal">@dimen/bookmark_card_margin</item>
<item name="android:layout_gravity">center_vertical</item>
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.8.10"
ext.kotlin_version = "1.8.20"
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:7.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.6'

Expand All @@ -23,6 +23,6 @@ allprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 03 20:49:13 PDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit e77c1bb

Please sign in to comment.