Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
/ AmazWare Public archive

Commit

Permalink
Floating button code moved
Browse files Browse the repository at this point in the history
  • Loading branch information
Keddnyo committed Mar 9, 2022
1 parent ba905c2 commit 7dc5c29
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "io.github.keddnyo.amazware"
minSdk 21
targetSdk 32
versionCode 5
versionName "1.3.1"
versionCode 6
versionName "1.3.2"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,41 @@ class Firmwarehouse : AppCompatActivity() {
init(true)
}

@SuppressLint("SetJavaScriptEnabled")
fun init(common: Boolean) {
override fun onResume() {
super.onResume()

val sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(this)
val darkMode = DarkMode().switch(this) // Set theme
val webView = findViewById<WebView>(R.id.webView)
val webSettings = webView?.settings
val refresh = findViewById<SwipeRefreshLayout>(R.id.cloud_refresh)
val floatingButton = findViewById<FloatingActionButton>(R.id.favouriteButtonFirmwarehouse)

refresh.isRefreshing = true

if ((sharedPreferences.getString("deviceSource", "") != "")
) {
floatingButton.visibility = View.VISIBLE
} else {
floatingButton.visibility = View.GONE
}

floatingButton.setOnClickListener {
init(false) // Loading favourite device page
}

floatingButton.setOnLongClickListener {
init(true) // Loading the main page
true
}
}

@SuppressLint("SetJavaScriptEnabled")
fun init(common: Boolean) {
val darkMode = DarkMode().switch(this) // Set theme
val webView = findViewById<WebView>(R.id.webView)
val webSettings = webView?.settings
val refresh = findViewById<SwipeRefreshLayout>(R.id.cloud_refresh)

refresh.isRefreshing = true

webView.clearHistory()
webView.clearCache(true)
webSettings!!.javaScriptEnabled = true

if (common) {
Expand Down Expand Up @@ -122,15 +138,6 @@ class Firmwarehouse : AppCompatActivity() {
webView.reload()
refresh.isRefreshing = false
}

floatingButton.setOnClickListener {
init(false) // Loading favourite device page
}

floatingButton.setOnLongClickListener {
init(true) // Loading the main page
true
}
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand Down

0 comments on commit 7dc5c29

Please sign in to comment.