Skip to content

Commit

Permalink
Refresh button moved, code reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Jan 12, 2022
1 parent dfde5fe commit 43a5191
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 144 deletions.
4 changes: 2 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 48 additions & 19 deletions app/src/main/java/ru/tech/easysearch/activity/BrowserActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import android.os.Bundle
import android.util.Patterns
import android.view.KeyEvent
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.animation.AnimationUtils
import android.webkit.URLUtil
import android.webkit.ValueCallback
import android.widget.FrameLayout
Expand Down Expand Up @@ -65,6 +66,11 @@ import ru.tech.easysearch.helper.adblock.AdBlocker.getDomain
import ru.tech.easysearch.helper.client.ChromeClient
import ru.tech.easysearch.helper.client.WebClient
import ru.tech.easysearch.helper.interfaces.DesktopInterface
import ru.tech.easysearch.helper.utils.anim.AnimUtils.assignAnimations
import ru.tech.easysearch.helper.utils.anim.AnimUtils.fadeIn
import ru.tech.easysearch.helper.utils.anim.AnimUtils.fadeOut
import ru.tech.easysearch.helper.utils.anim.AnimUtils.getAnimInstance
import ru.tech.easysearch.helper.utils.anim.AnimUtils.setAnimListener
import ru.tech.easysearch.helper.utils.save.SaveUtils.addToHomeScreen
import ru.tech.easysearch.helper.utils.save.SaveUtils.saveAsPDF

Expand All @@ -86,6 +92,9 @@ class BrowserActivity : AppCompatActivity(), DesktopInterface {

var backwardBrowser: ImageButton? = null
var forwardBrowser: ImageButton? = null
var reloadButton: ImageSwitcher? = null
var cancelReload: ImageView? = null
private var startReload: ImageView? = null
private var goMoreButton: ImageSwitcher? = null
var webViewContainer: FrameLayout? = null
private var homeBrowser: ImageButton? = null
Expand All @@ -102,9 +111,10 @@ class BrowserActivity : AppCompatActivity(), DesktopInterface {
Functions.doInBackground {
AdBlocker.createAdList(this)
}
assignAnimations()
if (openedTabs.isEmpty()) loadOpenedTabs(progressBar)
}

@SuppressLint("SetJavaScriptEnabled", "ClickableViewAccessibility")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -132,6 +142,9 @@ class BrowserActivity : AppCompatActivity(), DesktopInterface {
currentWindows = findViewById(R.id.windowsBrowser)
root = findViewById(R.id.main_root)
browser = findViewById(R.id.webBrowser)
reloadButton = findViewById(R.id.reload)
startReload = findViewById(R.id.start)
cancelReload = findViewById(R.id.cancel)

val chromeClient = ChromeClient(this, progressBar!!, browser!!)
browser!!.webViewClient = WebClient(this, progressBar!!)
Expand Down Expand Up @@ -168,36 +181,39 @@ class BrowserActivity : AppCompatActivity(), DesktopInterface {
}
}

goMoreButton?.inAnimation = AnimationUtils.loadAnimation(
this,
R.anim.fade_in
)
goMoreButton?.outAnimation = AnimationUtils.loadAnimation(
this,
R.anim.fade_out
)
if (fadeIn == null) assignAnimations()

goMoreButton?.inAnimation = fadeIn
goMoreButton?.outAnimation = fadeOut

reloadButton?.inAnimation = fadeIn
reloadButton?.outAnimation = fadeOut

searchView?.setOnFocusChangeListener { _, focused ->
if (lastUrl == "") lastUrl = browser?.url!!

val observableAnimFadeIn = getAnimInstance(true)
val observableAnimFadeOut = getAnimInstance(false)

observableAnimFadeIn.setAnimListener(endAction = { reloadButton?.visibility = VISIBLE })

observableAnimFadeOut.setAnimListener(endAction = { reloadButton?.visibility = GONE })

when (focused) {
true -> {
reloadButton?.startAnimation(observableAnimFadeOut)
goMoreButton?.showNext()
goMoreButton?.setOnClickListener {
onGetUri(searchView!!, searchView!!.text.toString())
}
if (!clickedGo) {
searchView?.setText(lastUrl)
}
if (!clickedGo) searchView?.setText(lastUrl)
searchView?.selectAll()
}
false -> {
reloadButton?.startAnimation(observableAnimFadeIn)
goMoreButton?.showPrevious()
goMoreButton?.setOnClickListener {
showMore()
}
if (!clickedGo) {
searchView?.setText(lastUrl.getDomain())
}
goMoreButton?.setOnClickListener { showMore() }
if (!clickedGo) searchView?.setText(lastUrl.getDomain())
}
}
}
Expand Down Expand Up @@ -246,6 +262,19 @@ class BrowserActivity : AppCompatActivity(), DesktopInterface {
sideMenu!!.show()
}

reloadButton?.setOnClickListener {
when (reloadButton?.currentView) {
startReload -> {
browser?.reload()
reloadButton?.showNext()
}
cancelReload -> {
browser?.stopLoading()
reloadButton?.showPrevious()
}
}
}

updateGestures()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package ru.tech.easysearch.custom.popup.smart

import android.annotation.SuppressLint
import android.content.Context
import android.view.Gravity.BOTTOM
import android.view.Gravity.TOP
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.divider.MaterialDivider
import com.google.android.material.switchmaterial.SwitchMaterial
Expand Down Expand Up @@ -37,6 +42,7 @@ class SmartPopupMenuAdapter(
if (popupMenuItem.icon != null) {
holder.bind(popupMenuItem)

holder.image.visibility = VISIBLE
holder.image.setImageDrawable(popupMenuItem.icon)
holder.text.text = popupMenuItem.title

Expand All @@ -50,8 +56,14 @@ class SmartPopupMenuAdapter(
}
} else holder.switcher.visibility = GONE

if (popupMenuItem.showDivider) holder.divider.visibility = VISIBLE
else holder.divider.visibility = GONE
if (popupMenuItem.showDivider) {
(holder.divider.layoutParams as FrameLayout.LayoutParams).apply {
gravity =
if ((context as? BrowserActivity)?.root is CoordinatorLayout) TOP
else BOTTOM
}
holder.divider.visibility = VISIBLE
} else holder.divider.visibility = GONE

} else {
holder.image.visibility = GONE
Expand All @@ -69,8 +81,10 @@ class SmartPopupMenuAdapter(
this.smartPopupMenuItemClickListener = smartPopupMenuItemClickListener
}

@SuppressLint("NotifyDataSetChanged")
fun attachList(menuList: Array<out SmartPopupMenuItem>) {
for (i in menuList) this.menuList.add(i)
notifyDataSetChanged()
}

inner class PopupViewHolder(view: View) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ object SharedPreferencesAccess {

const val EYE_PROTECTION = "eye"
const val AD_BLOCK = "adblock"
const val IMAGE_LOADING = "imgload"
const val HIDE_PANELS = "hdpnls"
const val IMAGE_LOADING = "imageLoading"
const val HIDE_PANELS = "hidePanels"
const val LOCATION_ACCESS = "location"
const val CAMERA_ACCESS = "camera"
const val MIC_ACCESS = "mic"
const val SAVE_HISTORY = "svhist"
const val SAVE_TABS = "savetabsenbl"
const val SAVE_HISTORY = "saveHistory"
const val SAVE_TABS = "saveTabs"
const val COOKIES = "cookies"
const val JS = "javascript"
const val POPUPS = "popupmessages"
const val DOM_STORAGE = "domstorage"
const val POPUPS = "popupMessages"
const val DOM_STORAGE = "DOMStorage"
const val GET = 1
const val SET = 2

Expand All @@ -36,7 +36,7 @@ object SharedPreferencesAccess {

fun getSetting(context: Context, key: String): Boolean {
return context.getSharedPreferences(mainSharedPrefsKey, Context.MODE_PRIVATE)
.getBoolean(key, !(key == HIDE_PANELS || key == EYE_PROTECTION))
.getBoolean(key, key != EYE_PROTECTION)
}

fun setSetting(context: Context, key: String, value: Boolean) {
Expand Down
Loading

0 comments on commit 43a5191

Please # to comment.