Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ android {
}
buildFeatures {
viewBinding true
buildConfig true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down
2 changes: 1 addition & 1 deletion app/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
android.defaults.buildfeatures.buildconfig=true
# SPDX-License-Identifier: MIT
android.enableJetifier=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
</intent-filter>
</activity>

<service android:name=".EasySSHFSService"
android:foregroundServiceType="connectedDevice"/>
<service
android:name=".EasySSHFSService"
android:foregroundServiceType="connectedDevice" />

<receiver
android:name=".OnBootReceiver"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/cpp/stub.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
void stub() noexcept {}
// SPDX-License-Identifier: MIT

[[maybe_unused]] void stub() noexcept {}
12 changes: 4 additions & 8 deletions app/src/main/java/ru/nsu/bobrofon/easysshfs/EasySSHFSActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ class EasySSHFSActivity : AppCompatActivity(), NavigationDrawerFragment.Navigati
)[EasySSHFSViewModel::class.java]

AppLog.instance().addMessage(
"EasySSHFS ${BuildConfig.VERSION_NAME} "
+ "(${BuildConfig.VERSION_CODE}) ${BuildConfig.BUILD_TYPE}"
"EasySSHFS ${BuildConfig.VERSION_NAME} " + "(${BuildConfig.VERSION_CODE}) ${BuildConfig.BUILD_TYPE}"
)
VersionUpdater(applicationContext).update()

Expand All @@ -83,8 +82,7 @@ class EasySSHFSActivity : AppCompatActivity(), NavigationDrawerFragment.Navigati
navigationDrawerFragment =
supportFragmentManager.findFragmentById(R.id.navigation_drawer) as NavigationDrawerFragment
navigationDrawerFragment.setUp(
R.id.navigation_drawer,
findViewById<View>(R.id.drawer_layout) as DrawerLayout
R.id.navigation_drawer, findViewById<View>(R.id.drawer_layout) as DrawerLayout
)

ensureAllPermissionsGranted()
Expand Down Expand Up @@ -124,8 +122,7 @@ class EasySSHFSActivity : AppCompatActivity(), NavigationDrawerFragment.Navigati

val permissions = allPermissions.filter {
ContextCompat.checkSelfPermission(
applicationContext,
it
applicationContext, it
) != PackageManager.PERMISSION_GRANTED
}

Expand All @@ -142,8 +139,7 @@ class EasySSHFSActivity : AppCompatActivity(), NavigationDrawerFragment.Navigati
}

override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>, grantResults: IntArray
requestCode: Int, permissions: Array<String>, grantResults: IntArray
) {
if (requestCode == PERMISSION_REQUEST_CODE) {
for (i in permissions.indices) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import android.widget.ArrayAdapter
import android.widget.ListView
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.core.content.edit
import androidx.core.view.GravityCompat
import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
Expand Down Expand Up @@ -54,7 +55,7 @@ class NavigationDrawerFragment : EasySSHFSFragment(), DrawerStatus {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Read in the flag indicating whether or not the user has demonstrated awareness of the
// Read in the flag indicating whether the user has demonstrated awareness of the
// drawer.
val sp = PreferenceManager.getDefaultSharedPreferences(requireContext())
userLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false)
Expand Down Expand Up @@ -87,9 +88,7 @@ class NavigationDrawerFragment : EasySSHFSFragment(), DrawerStatus {
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
drawerListView =
inflater.inflate(R.layout.fragment_navigation_drawer, container, false) as ListView
Expand Down Expand Up @@ -128,7 +127,7 @@ class NavigationDrawerFragment : EasySSHFSFragment(), DrawerStatus {
actionBar.setDisplayHomeAsUpEnabled(true)
actionBar.setHomeButtonEnabled(true)

// ActionBarDrawerToggle ties together the the proper interactions
// ActionBarDrawerToggle ties together the proper interactions
// between the navigation drawer and the action bar app icon.
drawerToggle = object : ActionBarDrawerToggle(
activity, /* host Activity */
Expand Down Expand Up @@ -156,7 +155,7 @@ class NavigationDrawerFragment : EasySSHFSFragment(), DrawerStatus {
// the navigation drawer automatically in the future.
userLearnedDrawer = true
val sp = PreferenceManager.getDefaultSharedPreferences(requireContext())
sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply()
sp.edit { putBoolean(PREF_USER_LEARNED_DRAWER, true) }
}

// Show the global app actions in the action bar. See also
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/ru/nsu/bobrofon/easysshfs/ShellBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ object ShellBuilder {
}

private fun isMagiskV27x(): Boolean {
val sh = Builder.create()
.setFlags(Shell.FLAG_NON_ROOT_SHELL)
.build()
val sh = Builder.create().setFlags(Shell.FLAG_NON_ROOT_SHELL).build()

// The result should be something like this:
// $ su -v 2>/dev/null
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/ru/nsu/bobrofon/easysshfs/VersionUpdater.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Build
import android.system.Os
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.core.content.edit
import ru.nsu.bobrofon.easysshfs.log.AppLog
import ru.nsu.bobrofon.easysshfs.mountpointlist.MountPointsList
import ru.nsu.bobrofon.easysshfs.mountpointlist.mountpoint.MountPoint
Expand Down Expand Up @@ -35,9 +36,9 @@ class VersionUpdater(
update02to03()
}

val prefsEditor = settings.edit()
prefsEditor.putInt("version", currentVersion)
prefsEditor.apply()
settings.edit {
putInt("version", currentVersion)
}
}

private fun update02to03() {
Expand Down Expand Up @@ -127,7 +128,7 @@ class VersionUpdater(
} else {
Reflected.Os.lstat(path)
}
} catch (e: Exception) {
} catch (_: Exception) {
// ErrnoException is only available since API 21
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class LogFragment : EasySSHFSFragment(), LogChangeObserver {


override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
Log.i(TAG, "onCreateView")
super.onCreateView(inflater, container, savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ interface LogChangeObserver {
fun onLogChanged(logView: LogView)
}

internal class LogObservable(private val logView: LogView) :
Observable<LogChangeObserver>() {
internal class LogObservable(private val logView: LogView) : Observable<LogChangeObserver>() {

override fun registerObserver(observer: LogChangeObserver) {
super.registerObserver(observer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ru.nsu.bobrofon.easysshfs.mountpointlist

import android.content.Context
import android.util.Log
import androidx.core.content.edit
import com.topjohnwu.superuser.Shell
import org.json.JSONArray
import org.json.JSONException
Expand Down Expand Up @@ -76,8 +77,9 @@ class MountPointsList(
selJson.put(item.json())
}

val prefsEditor = settings.edit()
prefsEditor.putString(STORAGE_FILE, selJson.toString()).apply()
settings.edit {
putString(STORAGE_FILE, selJson.toString())
}
autoMountObservable.notifyChanged(isAutoMountEnabled)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
import ru.nsu.bobrofon.easysshfs.EasySSHFSFragment
import ru.nsu.bobrofon.easysshfs.R
import ru.nsu.bobrofon.easysshfs.mountpointlist.MountpointFragment.OnFragmentInteractionListener
import ru.nsu.bobrofon.easysshfs.mountpointlist.mountpoint.MountPointsArrayAdapter
import ru.nsu.bobrofon.easysshfs.mountpointlist.mountpoint.MountStateChangeObserver

Expand All @@ -34,9 +33,7 @@ class MountpointFragment : EasySSHFSFragment(), AdapterView.OnItemClickListener,
private lateinit var mountPointsList: MountPointsList

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View? {
val context = requireContext()
val shell = shell!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.*
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.activity.result.contract.ActivityResultContracts.GetContent
import androidx.activity.result.contract.ActivityResultContracts.OpenDocumentTree
import androidx.annotation.RequiresApi
import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle

import ru.nsu.bobrofon.easysshfs.EasySSHFSActivity
import ru.nsu.bobrofon.easysshfs.EasySSHFSFragment
import ru.nsu.bobrofon.easysshfs.R
Expand Down Expand Up @@ -50,8 +54,7 @@ class EditFragment : EasySSHFSFragment() {
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
super.onCreateView(inflater, container, savedInstanceState)

Expand Down Expand Up @@ -150,30 +153,29 @@ class EditFragment : EasySSHFSFragment() {
}
}

override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
when (menuItem.itemId) {
R.id.action_save -> {
saveAction()
true
}

R.id.action_delete -> {
deleteAction()
true
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = when (menuItem.itemId) {
R.id.action_save -> {
saveAction()
true
}

R.id.action_mount -> {
mountAction()
true
}
R.id.action_delete -> {
deleteAction()
true
}

R.id.action_umount -> {
umountAction()
true
}
R.id.action_mount -> {
mountAction()
true
}

else -> false
R.id.action_umount -> {
umountAction()
true
}

else -> false
}
}

private fun saveAction() {
Expand Down Expand Up @@ -222,26 +224,24 @@ class EditFragment : EasySSHFSFragment() {
}

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
private val localDirPicker =
registerForActivityResult(OpenDocumentTree()) { uri: Uri? ->
uri?.let { setLocalPath(it) }
}
private val localDirPicker = registerForActivityResult(OpenDocumentTree()) { uri: Uri? ->
uri?.let { setLocalPath(it) }
}

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
private fun selectLocalDir() {
localDirPicker.launch(/* starting location */ null)
}

private val identityFilePicker =
registerForActivityResult(object : GetContent() {
override fun createIntent(context: Context, input: String): Intent {
val intent = super.createIntent(context, input)
intent.addCategory(Intent.CATEGORY_OPENABLE)
return Intent.createChooser(intent, "Select IdentityFile")
}
}) { uri: Uri? ->
uri?.let { setIdentityFile(it) }
private val identityFilePicker = registerForActivityResult(object : GetContent() {
override fun createIntent(context: Context, input: String): Intent {
val intent = super.createIntent(context, input)
intent.addCategory(Intent.CATEGORY_OPENABLE)
return Intent.createChooser(intent, "Select IdentityFile")
}
}) { uri: Uri? ->
uri?.let { setIdentityFile(it) }
}

private fun selectIdentityFile() {
identityFilePicker.launch("*/*")
Expand Down
Loading
Loading