Skip to content

Commit

Permalink
Merge branch 'master' into 1966-deprecated-in-java
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored May 1, 2024
2 parents ef74bc4 + e984c0c commit 483c090
Show file tree
Hide file tree
Showing 80 changed files with 395 additions and 407 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies {
})
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.fragment:fragment-ktx:1.7.0-beta01'
implementation 'androidx.fragment:fragment-ktx:1.8.0-alpha02'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.28'
Expand Down Expand Up @@ -89,13 +89,13 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.5.2'
implementation 'me.aflak.libraries:bluetooth:1.3.9'
implementation 'com.caverock:androidsvg-aar:1.4'
implementation "androidx.core:core-ktx:1.12.0"
implementation "androidx.core:core-ktx:1.13.0"
implementation 'com.android.support:multidex:1.0.3'
implementation 'me.toptas.fancyshowcase:fancyshowcaseview:1.3.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.connectbot:sshlib:2.2.9'

def lifecycle_version = "2.8.0-alpha03"
def lifecycle_version = "2.8.0-beta01"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
Expand Down
13 changes: 4 additions & 9 deletions app/src/main/kotlin/io/treehouses/remote/InitialActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,30 @@ package io.treehouses.remote
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.widget.Toolbar
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import androidx.preference.PreferenceManager
import io.treehouses.remote.callback.BackPressReceiver
import io.treehouses.remote.databinding.ActivityInitial2Binding
import io.treehouses.remote.fragments.CommunityFragment
import io.treehouses.remote.fragments.dialogfragments.FeedbackDialogFragment
import io.treehouses.remote.fragments.DiscoverFragment
import io.treehouses.remote.fragments.SettingsFragment
import io.treehouses.remote.callback.BackPressReceiver
import io.treehouses.remote.databinding.ActivityInitial2Binding
import io.treehouses.remote.fragments.ShowBluetoothFileFragment
import io.treehouses.remote.fragments.dialogfragments.FeedbackDialogFragment
import io.treehouses.remote.ui.home.HomeFragment
import io.treehouses.remote.utils.DialogUtils
import io.treehouses.remote.utils.GPSService

class InitialActivity : BaseInitialActivity() {

@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
bind = ActivityInitial2Binding.inflate(layoutInflater)
Expand Down Expand Up @@ -120,8 +115,8 @@ class InitialActivity : BaseInitialActivity() {
bind.navView.setNavigationItemSelectedListener(this)
}

@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
override fun onBackPressed() {
super.onBackPressed()
if (bind.drawerLayout.isDrawerOpen(GravityCompat.START)) bind.drawerLayout.closeDrawer(GravityCompat.START)
else {
val f = supportFragmentManager.findFragmentById(R.id.fragment_container)
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/io/treehouses/remote/IntroActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class IntroActivity : AppCompatActivity() {
}
class IntroSlideWelcome(val listener: IntroPagerListener) : Fragment() {
private lateinit var welcomeBind: IntroScreenWelcomeBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
welcomeBind = IntroScreenWelcomeBinding.inflate(inflater, container, false)
return welcomeBind.root
}
Expand All @@ -67,7 +67,7 @@ class IntroActivity : AppCompatActivity() {

class IntroSlideDownload(val listener: IntroPagerListener) : Fragment() {
private lateinit var downloadBind: IntroScreenDownloadBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
downloadBind = IntroScreenDownloadBinding.inflate(inflater, container, false)
return downloadBind.root
}
Expand All @@ -84,7 +84,7 @@ class IntroActivity : AppCompatActivity() {

class IntroSlideBluetooth(val listener: IntroPagerListener) : Fragment() {
private lateinit var bluetoothBind: IntroScreenBluetoothBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
bluetoothBind = IntroScreenBluetoothBinding.inflate(inflater, container, false)
return bluetoothBind.root
}
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/kotlin/io/treehouses/remote/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.content.res.Configuration
import android.os.Build
import android.os.IBinder
import android.util.DisplayMetrics
import android.view.WindowManager
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.preference.PreferenceManager
import androidx.preference.SeekBarPreference
import com.parse.Parse
import io.treehouses.remote.network.BluetoothChatService
import io.treehouses.remote.utils.SaveUtils
import io.treehouses.remote.utils.logD
import io.treehouses.remote.utils.logE
import java.util.*

class MainApplication : Application() {
var logSent = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
package io.treehouses.remote

import android.os.Build

/**
* @author Kenny Root
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ package io.treehouses.remote
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.util.DisplayMetrics
import android.util.TypedValue
import android.view.WindowManager
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.PreferenceManager
Expand Down Expand Up @@ -54,9 +51,7 @@ class SplashScreenActivity : AppCompatActivity() {
wm.defaultDisplay.getMetrics(metrics)
metrics.scaledDensity = configuration.fontScale * metrics.density

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
baseContext.applicationContext.createConfigurationContext(it)
}
baseContext.applicationContext.createConfigurationContext(it)
baseContext.resources.displayMetrics.setTo(metrics)

}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/io/treehouses/remote/Tutorials.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ object Tutorials {
show(a, b, c, d, e, f)
}

public fun fancyShowCaseViewBuilderSkippable(activity: FragmentActivity, view: View, title: String, focusShape: FocusShape = FocusShape.CIRCLE): FancyShowCaseView.Builder {
fun fancyShowCaseViewBuilderSkippable(activity: FragmentActivity, view: View, title: String, focusShape: FocusShape = FocusShape.CIRCLE): FancyShowCaseView.Builder {
return fancyShowCaseViewBuilder(activity, view, title, focusShape)
.customView(R.layout.tutorial, object : OnViewInflateListener {
override fun onViewInflated(view: View) {
Expand All @@ -192,7 +192,7 @@ object Tutorials {
})
}

public fun fancyShowCaseViewBuilder(activity: FragmentActivity, view: View, title: String, focusShape: FocusShape = FocusShape.CIRCLE): FancyShowCaseView.Builder {
fun fancyShowCaseViewBuilder(activity: FragmentActivity, view: View, title: String, focusShape: FocusShape = FocusShape.CIRCLE): FancyShowCaseView.Builder {
return FancyShowCaseView.Builder(activity)
.focusOn(view)
.title(title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import io.treehouses.remote.callback.DeviceDeleteListener
import io.treehouses.remote.pojo.DeviceInfo

class RPIListAdapter(private val mContext: Context, private val data: List<DeviceInfo>) : ArrayAdapter<DeviceInfo?>(mContext, 0, data) {
public var deviceListener: DeviceDeleteListener? = null
var deviceListener: DeviceDeleteListener? = null
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
// Get the data item for this position
var newView = convertView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ import android.view.ViewGroup
import android.widget.BaseExpandableListAdapter
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.fragment.app.FragmentActivity
import io.treehouses.remote.R
import io.treehouses.remote.Tutorials
import io.treehouses.remote.callback.HomeInteractListener
import io.treehouses.remote.pojo.NetworkListItem
import io.treehouses.remote.utils.logD

class SystemListAdapter(val context: Context, list: List<NetworkListItem>) : BaseExpandableListAdapter() {
private val list: List<NetworkListItem>
private val inflater: LayoutInflater
private val inflater: LayoutInflater = LayoutInflater.from(context)
private var listener: HomeInteractListener? = null
private val views: MutableList<View>
private val groupHeader: MutableList<View>
Expand Down Expand Up @@ -60,12 +57,15 @@ class SystemListAdapter(val context: Context, list: List<NetworkListItem>) : Bas
return false
}

override fun getGroupView(i: Int, b: Boolean, convertView: View?, parent: ViewGroup): View {
val newView: View?
newView = inflater.inflate(R.layout.list_group, parent, false)
val listHeader = newView.findViewById<TextView>(R.id.lblListHeader)
listHeader.text = getGroup(i).toString()
groupHeader.add(newView)
override fun getGroupView(i: Int, b: Boolean, convertView: View?, parent: ViewGroup): View? {
val newView: View? = inflater.inflate(R.layout.list_group, parent, false)
val listHeader = newView?.findViewById<TextView>(R.id.lblListHeader)
if (listHeader != null) {
listHeader.text = getGroup(i).toString()
}
if (newView != null) {
groupHeader.add(newView)
}
return newView
}

Expand Down Expand Up @@ -104,7 +104,6 @@ class SystemListAdapter(val context: Context, list: List<NetworkListItem>) : Bas
}

init {
inflater = LayoutInflater.from(context)
this.list = list
views = mutableListOf()
groupHeader = mutableListOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ViewHolderSSH2FA internal constructor(v: View, private val c: Context, lis

private fun openAuthenticator(key:String){
val uri:String = "otpauth://totp/" + "pi@treehouses" + "?secret=" + key + "&issuer=treehouses"
val intent:Intent = Intent(Intent.ACTION_VIEW, Uri.parse(uri))
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(uri))

if (Utils.checkAppIsInstalled(c, v, intent, arrayOf("No Authenticator Client Installed on your Device", "Install", "https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2"))) return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ViewHolderVnc internal constructor(v: View, context: Context, listener: Ho
init {
listener.sendMessage(context.getString(R.string.TREEHOUSES_VNC))
val btnStartConfig = v.findViewById<Button>(R.id.btn_start_config)
vnc = v.findViewById<Switch>(R.id.switchVnc)
vnc = v.findViewById(R.id.switchVnc)
editTextIp = v.findViewById(R.id.editTextIp)
btnStartConfig.setOnClickListener { openVnc(context, v, editTextIp) }
vnc.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package io.treehouses.remote.bases

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import androidx.fragment.app.DialogFragment
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import io.treehouses.remote.R
import io.treehouses.remote.callback.HomeInteractListener

open class BaseBottomSheetDialog : BottomSheetDialogFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import android.os.Message
import android.widget.Toast
import androidx.fragment.app.Fragment
import io.treehouses.remote.Constants
import io.treehouses.remote.R
import io.treehouses.remote.network.BluetoothChatService
import io.treehouses.remote.callback.HomeInteractListener
import io.treehouses.remote.network.BluetoothChatService
import io.treehouses.remote.utils.DialogUtils
import io.treehouses.remote.utils.logE
import java.lang.NullPointerException

open class BaseFragment : Fragment() {
var lastMessage = " ";
var lastMessage = " "
open lateinit var mChatService: BluetoothChatService
var mBluetoothAdapter: BluetoothAdapter? = null
lateinit var listener: HomeInteractListener
Expand Down Expand Up @@ -80,8 +78,7 @@ open class BaseFragment : Fragment() {
open fun setupChat() {}
open fun getMessage(msg: Message) {}

public fun writeMessage(msg: String)
{
fun writeMessage(msg: String) {
lastMessage = msg
listener.sendMessage(msg)
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/io/treehouses/remote/bases/BaseSSH.kt
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ open class BaseSSH : ConnectionMonitor, InteractiveCallback, AuthAgentCallback {
if (useAuthAgent != "no") it.requestAuthAgentForwarding(this)
it.requestPTY(emulation, columns, rows, width, height, null)
it.startShell()
stdin = it.getStdin()
stdout = it.getStdout()
stderr = it.getStderr()
stdin = it.stdin
stdout = it.stdout
stderr = it.stderr

}
isSessionOpen = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ open class BaseSSHConfig: BaseFragment(), RVButtonClickListener, OnHostStatusCha

override fun onButtonClick(position: Int) {
val edit = EditHostDialogFragment()
edit.setOnDismissListener(DialogInterface.OnDismissListener { setUpAdapter() })
edit.setOnDismissListener { setUpAdapter() }
edit.arguments = Bundle().apply { putString(EditHostDialogFragment.SELECTED_HOST_URI, pastHosts[position].uri.toString())}
edit.show(childFragmentManager, "EditHost")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ open class BaseTerminalBridge : VDUDisplay {
synchronized(localOutput) {
for (line in output.split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()) {
var line = line
if (line.length > 0 && line[line.length - 1] == '\r') {
if (line.isNotEmpty() && line[line.length - 1] == '\r') {
line = line.substring(0, line.length - 1)
}
val s = "$line\r\n"
Expand Down Expand Up @@ -316,14 +316,14 @@ open class BaseTerminalBridge : VDUDisplay {
* and pasting clipboard.
*/
fun injectString(string: String?) {
if (string == null || string.length == 0) return
val injectStringThread = Thread(Runnable {
if (string.isNullOrEmpty()) return
val injectStringThread = Thread {
try {
transport!!.write(string.toByteArray(charset(host!!.encoding)))
} catch (e: Exception) {
logE("Couldn't inject string to remote host: $e")
}
})
}
injectStringThread.name = "InjectString"
injectStringThread.start()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class FragmentViewModel(application: Application) : AndroidViewModel(applic
/**
* Monitors connection Status (has the specific connection state)
*/
private val _connectionStatus = MutableLiveData<Int>(Constants.STATE_NONE)
private val _connectionStatus = MutableLiveData(Constants.STATE_NONE)
val connectionStatus : LiveData<Int>
get() = _connectionStatus

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.treehouses.remote.bases

import android.Manifest
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.PackageManager
import android.location.LocationManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import java.text.SimpleDateFormat
import java.util.*

class AboutFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val view: View = inflater.inflate(R.layout.fragment_about, container, false)

setHyperlinks(view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import io.treehouses.remote.databinding.FragmentCommunityBinding

class CommunityFragment : BaseFragment(), BackPressReceiver {
private lateinit var bind: FragmentCommunityBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
bind = FragmentCommunityBinding.inflate(inflater, container, false)
return bind.root
}
Expand Down
Loading

0 comments on commit 483c090

Please sign in to comment.