Skip to content

Commit

Permalink
More cleaning prior to adding new features
Browse files Browse the repository at this point in the history
  • Loading branch information
Lloir committed Sep 27, 2023
1 parent 6c28e5e commit 5910cf6
Show file tree
Hide file tree
Showing 36 changed files with 256 additions and 259 deletions.
13 changes: 2 additions & 11 deletions app/src/main/java/com/rockethat/ornaassistant/Battle.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
package com.rockethat.ornaassistant

import android.accessibilityservice.AccessibilityService
import android.accessibilityservice.AccessibilityService.GestureResultCallback
import android.accessibilityservice.GestureDescription
import android.accessibilityservice.GestureDescription.StrokeDescription
import android.graphics.Path
import android.graphics.PointF
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import java.time.LocalDateTime
import java.util.ArrayList
import kotlin.random.Random

@RequiresApi(Build.VERSION_CODES.O)
class Battle(private val mAS: AccessibilityService) {
Expand All @@ -22,9 +14,8 @@ class Battle(private val mAS: AccessibilityService) {
}

companion object {
fun inBattle(data: ArrayList<ScreenData>): Boolean
{
return data.any { it.name == "Codex" } && data.any{ it.name == "SKILL"}
fun inBattle(data: ArrayList<ScreenData>): Boolean {
return data.any { it.name == "Codex" } && data.any { it.name == "SKILL" }
}
}
}
7 changes: 3 additions & 4 deletions app/src/main/java/com/rockethat/ornaassistant/DungeonMode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ package com.rockethat.ornaassistant

class DungeonMode {

constructor()
{
constructor() {
}

constructor(mode : Modes)
{
constructor(mode: Modes) {
mMode = mode
}

enum class Modes {
NORMAL, BOSS, ENDLESS
}

var mMode: Modes = Modes.NORMAL
var mbHard: Boolean = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class DungeonVisit(var sessionID: Long?, val name: String, var mode: DungeonMode
}

@RequiresApi(Build.VERSION_CODES.O)
fun coolDownEnds(): LocalDateTime
{
fun coolDownEnds(): LocalDateTime {
return mStarted.plusHours(coolDownHours())
}
}
25 changes: 10 additions & 15 deletions app/src/main/java/com/rockethat/ornaassistant/KingdomGauntlet.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package com.rockethat.ornaassistant

import KingdomMemberDatabaseHelper
import android.util.Log

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import com.rockethat.ornaassistant.db.KingdomGauntletDatabaseHelper
import java.time.LocalDateTime
import java.util.ArrayList
import java.util.concurrent.ConcurrentLinkedDeque
import kotlin.math.floor
import me.xdrop.fuzzywuzzy.FuzzySearch
import java.time.LocalDateTime
import java.time.ZoneOffset

class KingdomGauntlet(val mCtx: Context) {
Expand Down Expand Up @@ -186,8 +182,7 @@ class KingdomGauntlet(val mCtx: Context) {
}

@RequiresApi(Build.VERSION_CODES.O)
fun handleDiscordTimezones(data: ArrayList<ScreenData>)
{
fun handleDiscordTimezones(data: ArrayList<ScreenData>) {
val secondsToCollectTimezones: Long = 5

if (LocalDateTime.now()
Expand Down Expand Up @@ -237,12 +232,13 @@ class KingdomGauntlet(val mCtx: Context) {
}
}

if (highestRatioDiscordName.isNotBlank())
{
Log.i(TAG, "${dbItem.character} == ${highestRatioDiscordName}, ratio $highestRatio")
if (highestRatioDiscordName.isNotBlank()) {
Log.i(
TAG,
"${dbItem.character} == ${highestRatioDiscordName}, ratio $highestRatio"
)

if (highestRatio > 50)
{
if (highestRatio > 50) {
dbItem.timezone = highestRatioDiscordTZ
kmDB.updateData(dbItem)
}
Expand All @@ -257,8 +253,7 @@ class KingdomGauntlet(val mCtx: Context) {
}

@RequiresApi(Build.VERSION_CODES.O)
fun handleDiscordSleepers(data: ArrayList<ScreenData>)
{
fun handleDiscordSleepers(data: ArrayList<ScreenData>) {
if (data.size == 1 && data[0].name.contains("Sleepers")) {
val sd = data[0]
val split = sd.name.split("\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ data class KingdomGauntletFloor(
data class KingdomMember(val character: String, var floors: MutableMap<Int, KingdomGauntletFloor>) {
var immunity: Boolean = false
var endTimeLeftSeconds: Long = 0

@RequiresApi(Build.VERSION_CODES.O)
var endTime: LocalDateTime = LocalDateTime.now()
var discordName = ""
Expand Down
43 changes: 20 additions & 23 deletions app/src/main/java/com/rockethat/ornaassistant/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
package com.rockethat.ornaassistant

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.viewpager2.widget.ViewPager2
import com.rockethat.ornaassistant.ui.fragment.FragmentAdapter
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener

import android.content.Intent
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import androidx.annotation.RequiresApi
import androidx.preference.PreferenceManager
import com.rockethat.ornaassistant.ui.fragment.KingdomFragment

import android.provider.Settings.SettingNotFoundException
import android.text.TextUtils.SimpleStringSplitter
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
import com.rockethat.ornaassistant.ui.fragment.FragmentAdapter
import com.rockethat.ornaassistant.ui.fragment.KingdomFragment
import com.rockethat.ornaassistant.ui.fragment.MainFragment
import java.time.LocalDateTime
import java.time.temporal.ChronoUnit

@RequiresApi(Build.VERSION_CODES.O)
class MainActivity : AppCompatActivity() {
Expand All @@ -31,7 +27,7 @@ class MainActivity : AppCompatActivity() {
private lateinit var pager: ViewPager2
private lateinit var adapter: FragmentAdapter
private val TAG = "OrnaMainActivity"
private val ACCESSIBILITY_SERVICE_NAME = "laukas service"
private val ACCESSIBILITY_SERVICE_NAME = "Orna Assistant"

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -56,6 +52,7 @@ class MainActivity : AppCompatActivity() {
}
}
}

"Kingdom" -> {
pager.currentItem = 1
if (adapter.frags.size >= 2) {
Expand Down Expand Up @@ -110,9 +107,8 @@ class MainActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()

if (!isAccessibilityEnabled())
{
//startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
if (!isAccessibilityEnabled()) {
startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
}

when (tableLayout.selectedTabPosition) {
Expand All @@ -124,6 +120,7 @@ class MainActivity : AppCompatActivity() {
}
}
}

1 -> {
if (adapter.frags.size >= 2) {
with(adapter.frags[1] as KingdomFragment)
Expand All @@ -135,7 +132,7 @@ class MainActivity : AppCompatActivity() {
}
}

fun isAccessibilityEnabled(): Boolean {
private fun isAccessibilityEnabled(): Boolean {
var accessibilityEnabled = 0
val accessibilityFound = false
try {
Expand All @@ -155,9 +152,9 @@ class MainActivity : AppCompatActivity() {
Log.d(TAG, "Setting: $settingValue")
mStringColonSplitter.setString(settingValue)
while (mStringColonSplitter.hasNext()) {
val accessabilityService = mStringColonSplitter.next()
Log.d(TAG, "Setting: $accessabilityService")
if (accessabilityService.contains(
val accessibilityService = mStringColonSplitter.next()
Log.d(TAG, "Setting: $accessibilityService")
if (accessibilityService.contains(
packageName,
ignoreCase = true
)
Expand Down
Loading

0 comments on commit 5910cf6

Please sign in to comment.