diff --git a/app/src/main/java/com/rockethat/ornaassistant/Battle.kt b/app/src/main/java/com/rockethat/ornaassistant/Battle.kt index 84bad95..7699966 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/Battle.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/Battle.kt @@ -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) { @@ -22,9 +14,8 @@ class Battle(private val mAS: AccessibilityService) { } companion object { - fun inBattle(data: ArrayList): Boolean - { - return data.any { it.name == "Codex" } && data.any{ it.name == "SKILL"} + fun inBattle(data: ArrayList): Boolean { + return data.any { it.name == "Codex" } && data.any { it.name == "SKILL" } } } } diff --git a/app/src/main/java/com/rockethat/ornaassistant/DungeonMode.kt b/app/src/main/java/com/rockethat/ornaassistant/DungeonMode.kt index 3cd73f9..36f0c89 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/DungeonMode.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/DungeonMode.kt @@ -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 diff --git a/app/src/main/java/com/rockethat/ornaassistant/DungeonVisit.kt b/app/src/main/java/com/rockethat/ornaassistant/DungeonVisit.kt index e8aa9e3..592ad2e 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/DungeonVisit.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/DungeonVisit.kt @@ -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()) } } \ No newline at end of file diff --git a/app/src/main/java/com/rockethat/ornaassistant/KingdomGauntlet.kt b/app/src/main/java/com/rockethat/ornaassistant/KingdomGauntlet.kt index eab192e..01c4ac5 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/KingdomGauntlet.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/KingdomGauntlet.kt @@ -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) { @@ -186,8 +182,7 @@ class KingdomGauntlet(val mCtx: Context) { } @RequiresApi(Build.VERSION_CODES.O) - fun handleDiscordTimezones(data: ArrayList) - { + fun handleDiscordTimezones(data: ArrayList) { val secondsToCollectTimezones: Long = 5 if (LocalDateTime.now() @@ -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) } @@ -257,8 +253,7 @@ class KingdomGauntlet(val mCtx: Context) { } @RequiresApi(Build.VERSION_CODES.O) - fun handleDiscordSleepers(data: ArrayList) - { + fun handleDiscordSleepers(data: ArrayList) { if (data.size == 1 && data[0].name.contains("Sleepers")) { val sd = data[0] val split = sd.name.split("\n") diff --git a/app/src/main/java/com/rockethat/ornaassistant/KingdomMember.kt b/app/src/main/java/com/rockethat/ornaassistant/KingdomMember.kt index b5d6945..d374006 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/KingdomMember.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/KingdomMember.kt @@ -25,6 +25,7 @@ data class KingdomGauntletFloor( data class KingdomMember(val character: String, var floors: MutableMap) { var immunity: Boolean = false var endTimeLeftSeconds: Long = 0 + @RequiresApi(Build.VERSION_CODES.O) var endTime: LocalDateTime = LocalDateTime.now() var discordName = "" diff --git a/app/src/main/java/com/rockethat/ornaassistant/MainActivity.kt b/app/src/main/java/com/rockethat/ornaassistant/MainActivity.kt index 43b8f74..576b440 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/MainActivity.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/MainActivity.kt @@ -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() { @@ -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) @@ -56,6 +52,7 @@ class MainActivity : AppCompatActivity() { } } } + "Kingdom" -> { pager.currentItem = 1 if (adapter.frags.size >= 2) { @@ -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) { @@ -124,6 +120,7 @@ class MainActivity : AppCompatActivity() { } } } + 1 -> { if (adapter.frags.size >= 2) { with(adapter.frags[1] as KingdomFragment) @@ -135,7 +132,7 @@ class MainActivity : AppCompatActivity() { } } - fun isAccessibilityEnabled(): Boolean { + private fun isAccessibilityEnabled(): Boolean { var accessibilityEnabled = 0 val accessibilityFound = false try { @@ -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 ) diff --git a/app/src/main/java/com/rockethat/ornaassistant/MainState.kt b/app/src/main/java/com/rockethat/ornaassistant/MainState.kt index b767179..efe49b4 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/MainState.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/MainState.kt @@ -1,37 +1,37 @@ package com.rockethat.ornaassistant +import android.Manifest import android.accessibilityservice.AccessibilityService import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context +import android.content.SharedPreferences +import android.content.pm.PackageManager import android.graphics.Rect +import android.media.AudioAttributes +import android.net.Uri import android.os.Build import android.util.Log import android.view.View import android.view.WindowManager import androidx.annotation.RequiresApi -import com.rockethat.ornaassistant.db.DungeonVisitDatabaseHelper -import com.rockethat.ornaassistant.overlays.InviterOverlay -import java.time.LocalDateTime -import java.util.* -import com.rockethat.ornaassistant.overlays.KGOverlay -import com.rockethat.ornaassistant.overlays.SessionOverlay -import android.content.SharedPreferences -import android.content.pm.PackageManager -import android.media.AudioAttributes -import android.net.Uri import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat import androidx.preference.PreferenceManager +import androidx.work.* +import com.rockethat.ornaassistant.db.DungeonVisitDatabaseHelper import com.rockethat.ornaassistant.ornaviews.OrnaViewDungeonEntry import com.rockethat.ornaassistant.overlays.AssessOverlay +import com.rockethat.ornaassistant.overlays.InviterOverlay +import com.rockethat.ornaassistant.overlays.KGOverlay +import com.rockethat.ornaassistant.overlays.SessionOverlay import org.json.JSONObject +import java.time.LocalDateTime +import java.util.* import java.util.concurrent.LinkedBlockingDeque -import kotlin.concurrent.thread -import androidx.work.* import java.util.concurrent.TimeUnit -import android.Manifest +import kotlin.concurrent.thread @RequiresApi(Build.VERSION_CODES.O) @@ -125,8 +125,7 @@ class MainState( @RequiresApi(Build.VERSION_CODES.O) private fun handleOrnaData(data: ArrayList) { - if (Battle.inBattle(data)) - { + if (Battle.inBattle(data)) { mInBattle = LocalDateTime.now() if (mKGOverlay.isVisible()) mKGOverlay.hide() } @@ -144,8 +143,7 @@ class MainState( mSessionOverlay.hide() } mSession = WayvesselSession(name, mCtx) - if (mSharedPreference.getBoolean("nWayvessel", true)) - { + if (mSharedPreference.getBoolean("nWayvessel", true)) { scheduleWayvesselNotification(60) } if (mDungeonVisit != null) { @@ -244,14 +242,11 @@ class MainState( OrnaViewUpdateType.DUNGEON_ENTERED -> { if (mDungeonVisit == null) { val view: OrnaViewDungeonEntry = mCurrentView as OrnaViewDungeonEntry - if (mOnholdVisits.containsKey(view.mDungeonName)) - { + if (mOnholdVisits.containsKey(view.mDungeonName)) { Log.i(TAG, "Reloading on hold visit to ${view.mDungeonName}.") mDungeonVisit = mOnholdVisits[view.mDungeonName] mOnholdVisits.remove(view.mDungeonName) - } - else - { + } else { var sessionID: Long? = null if (mSession != null) { sessionID = mSession!!.mID @@ -266,6 +261,7 @@ class MainState( mSessionOverlay.update(mSession, mDungeonVisit) } } + OrnaViewUpdateType.DUNGEON_NEW_DUNGEON -> { if (mDungeonVisit != null) { Log.i(TAG, "Putting on hold visit to ${mDungeonVisit!!.name}.") @@ -273,12 +269,14 @@ class MainState( mDungeonVisit = null } } + OrnaViewUpdateType.DUNGEON_MODE_CHANGED -> { if (mDungeonVisit != null) { val view: OrnaViewDungeonEntry = mCurrentView as OrnaViewDungeonEntry mDungeonVisit!!.mode = view.mMode } } + OrnaViewUpdateType.DUNGEON_GODFORGE -> if (mDungeonVisit != null) mDungeonVisit!!.godforges++ OrnaViewUpdateType.DUNGEON_DONE -> if (mDungeonVisit != null) { if (mSession == null) { @@ -286,6 +284,7 @@ class MainState( } dungeonDone = true } + OrnaViewUpdateType.DUNGEON_FAIL -> if (mDungeonVisit != null) { if (mSession == null) { mSessionOverlay.hide() @@ -293,8 +292,10 @@ class MainState( dungeonDone = true dungeonFailed = true } + OrnaViewUpdateType.DUNGEON_NEW_FLOOR -> if (mDungeonVisit != null) mDungeonVisit!!.floor = (data as Int).toLong() + OrnaViewUpdateType.DUNGEON_EXPERIENCE -> { if (mDungeonVisit != null) mDungeonVisit!!.experience += data as Int if (mSession != null) mSession!!.experience += data as Int @@ -302,6 +303,7 @@ class MainState( mSessionOverlay.update(mSession, mDungeonVisit) } } + OrnaViewUpdateType.DUNGEON_ORNS -> { if (mDungeonVisit != null) mDungeonVisit!!.orns += data as Int if (mSession != null) mSession!!.orns += data as Int @@ -309,6 +311,7 @@ class MainState( mSessionOverlay.update(mSession, mDungeonVisit) } } + OrnaViewUpdateType.DUNGEON_GOLD -> { if (mDungeonVisit != null) mDungeonVisit!!.gold += data as Int if (mSession != null) mSession!!.gold += data as Int @@ -316,14 +319,17 @@ class MainState( mSessionOverlay.update(mSession, mDungeonVisit) } } + OrnaViewUpdateType.NOTIFICATIONS_INVITERS -> { if (mSharedPreference.getBoolean("invites", true)) { mInviterOverlay.update(data as MutableMap) } } + OrnaViewUpdateType.KINGDOM_GAUNTLET_LIST -> { updateKG(data as List) } + OrnaViewUpdateType.ITEM_ASSESS_RESULTS -> { mAssessOverlay.update(data as JSONObject) } @@ -349,8 +355,7 @@ class MainState( new.updateItems(items) mKingdomGauntlet.diffFloors(new, uniqueThis, uniqueOther) - if (dtNow.isBefore(mInBattle.plusSeconds(2))) - { + if (dtNow.isBefore(mInBattle.plusSeconds(2))) { // Player has been recently in battle, do nothing return } @@ -379,7 +384,11 @@ class MainState( Log.i(TAG, "One floor was removed!") // One floor was removed var lastFloor = 0 - items.forEach { it.floors.forEach{f -> if (lastFloor < f.key) lastFloor = f.key} } + items.forEach { + it.floors.forEach { f -> + if (lastFloor < f.key) lastFloor = f.key + } + } val otherMember = uniqueOther.firstOrNull { it.floors.containsKey(lastFloor) } if (otherMember != null) { @@ -396,8 +405,7 @@ class MainState( otherMember ) - if (mSharedPreference.getBoolean("nKGShuffle", true)) - { + if (mSharedPreference.getBoolean("nKGShuffle", true)) { scheduleShuffleNotification(20) } } @@ -472,12 +480,12 @@ class MainState( } } - private fun getRandomShuffleChannel() : String { + private fun getRandomShuffleChannel(): String { return mShuffleNotificationChannelNames[(mShuffleNotificationChannelNames.indices).random()] } - private fun getRandomShuffleSound() : String { + private fun getRandomShuffleSound(): String { return "android.resource://" + mCtx.packageName + "/" + mShuffleRes[(mShuffleRes.indices).random()] } @@ -522,8 +530,14 @@ class MainState( override fun doWork(): Result { // Check if the app has the required permissions - val hasInternetPermission = ContextCompat.checkSelfPermission(context, Manifest.permission.INTERNET) == PackageManager.PERMISSION_GRANTED - val hasVibratePermission = ContextCompat.checkSelfPermission(context, Manifest.permission.VIBRATE) == PackageManager.PERMISSION_GRANTED + val hasInternetPermission = ContextCompat.checkSelfPermission( + context, + Manifest.permission.INTERNET + ) == PackageManager.PERMISSION_GRANTED + val hasVibratePermission = ContextCompat.checkSelfPermission( + context, + Manifest.permission.VIBRATE + ) == PackageManager.PERMISSION_GRANTED if (hasInternetPermission && hasVibratePermission) { val channelID = inputData.getString("channelID") diff --git a/app/src/main/java/com/rockethat/ornaassistant/MyAccessibilityService.kt b/app/src/main/java/com/rockethat/ornaassistant/MyAccessibilityService.kt index 905d08e..ecc6655 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/MyAccessibilityService.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/MyAccessibilityService.kt @@ -2,21 +2,15 @@ package com.rockethat.ornaassistant import android.accessibilityservice.AccessibilityService import android.content.Context -import android.util.Log -import android.view.accessibility.AccessibilityEvent -import android.view.accessibility.AccessibilityNodeInfo -import android.view.WindowManager import android.graphics.Rect import android.os.Build +import android.util.Log import android.view.LayoutInflater +import android.view.WindowManager +import android.view.accessibility.AccessibilityEvent +import android.view.accessibility.AccessibilityNodeInfo import androidx.annotation.RequiresApi -import kotlin.collections.ArrayList import kotlin.system.measureTimeMillis -import android.net.Uri -import androidx.core.app.ActivityCompat.startActivityForResult - -import android.content.Intent -import androidx.core.app.ActivityCompat class MyAccessibilityService() : AccessibilityService() { @@ -106,8 +100,7 @@ class MyAccessibilityService() : AccessibilityService() { ): Boolean { var done = false if (mNodeInfo == null) return done - if (depth > 250) - { + if (depth > 250) { return true } diff --git a/app/src/main/java/com/rockethat/ornaassistant/ScreenData.kt b/app/src/main/java/com/rockethat/ornaassistant/ScreenData.kt index a368b2d..3dbdaa5 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ScreenData.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ScreenData.kt @@ -4,5 +4,9 @@ import android.graphics.Rect import android.view.accessibility.AccessibilityNodeInfo data class ScreenData( - val name: String, val position: Rect, val time: Long, val depth: Int, val mNodeInfo: AccessibilityNodeInfo? + val name: String, + val position: Rect, + val time: Long, + val depth: Int, + val mNodeInfo: AccessibilityNodeInfo? ) diff --git a/app/src/main/java/com/rockethat/ornaassistant/SettingsActivity.kt b/app/src/main/java/com/rockethat/ornaassistant/SettingsActivity.kt index 29fb39d..82eeca8 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/SettingsActivity.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/SettingsActivity.kt @@ -1,7 +1,7 @@ package com.rockethat.ornaassistant -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity import com.rockethat.ornaassistant.ui.fragment.SettingFragment class SettingsActivity : AppCompatActivity() { diff --git a/app/src/main/java/com/rockethat/ornaassistant/VolleySingleton.kt b/app/src/main/java/com/rockethat/ornaassistant/VolleySingleton.kt index e956ac3..c48538a 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/VolleySingleton.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/VolleySingleton.kt @@ -1,4 +1,5 @@ package com.rockethat.ornaassistant + import android.content.Context import com.android.volley.Request import com.android.volley.RequestQueue @@ -16,11 +17,13 @@ class VolleySingleton constructor(context: Context) { } } } + private val requestQueue: RequestQueue by lazy { // applicationContext is key, it keeps you from leaking the // Activity or BroadcastReceiver if someone passes one in. Volley.newRequestQueue(context.applicationContext) } + fun addToRequestQueue(req: Request) { requestQueue.add(req) } diff --git a/app/src/main/java/com/rockethat/ornaassistant/WayvesselSession.kt b/app/src/main/java/com/rockethat/ornaassistant/WayvesselSession.kt index e383b3a..d3d9a75 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/WayvesselSession.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/WayvesselSession.kt @@ -19,8 +19,7 @@ class WayvesselSession(val name: String, val mCtx: Context?) { var mDungeonsVisited = 0 init { - if (mCtx != null) - { + if (mCtx != null) { val db = WayvesselSessionDatabaseHelper(mCtx) mID = db.insertData(this) db.close() @@ -33,8 +32,7 @@ class WayvesselSession(val name: String, val mCtx: Context?) { fun finish() { mDurationSeconds = ChronoUnit.SECONDS.between(mStarted, LocalDateTime.now()) - if (mCtx != null) - { + if (mCtx != null) { val db = WayvesselSessionDatabaseHelper(mCtx) db.updateData(mID.toString(), this) } diff --git a/app/src/main/java/com/rockethat/ornaassistant/db/DungeonVisitDatabaseHelper.kt b/app/src/main/java/com/rockethat/ornaassistant/db/DungeonVisitDatabaseHelper.kt index 0c74991..9d97a56 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/db/DungeonVisitDatabaseHelper.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/db/DungeonVisitDatabaseHelper.kt @@ -50,8 +50,7 @@ class DungeonVisitDatabaseHelper(context: Context) : * to upgrade to the new schema version. */ override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { - if (oldVersion == 2 && newVersion == 3) - { + if (oldVersion == 2 && newVersion == 3) { db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_13 INTEGER DEFAULT 0"); } } @@ -64,7 +63,10 @@ class DungeonVisitDatabaseHelper(context: Context) : fun insertData(entry: DungeonVisit) { val db = this.writableDatabase val contentValues = ContentValues() - contentValues.put(COL_2, entry.mStarted.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000) + contentValues.put( + COL_2, + entry.mStarted.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000 + ) contentValues.put(COL_3, entry.mDurationSeconds) contentValues.put(COL_4, if (entry.sessionID != null) entry.sessionID else -1) contentValues.put(COL_5, entry.name) @@ -88,7 +90,10 @@ class DungeonVisitDatabaseHelper(context: Context) : val db = this.writableDatabase val contentValues = ContentValues() contentValues.put(COL_1, id) - contentValues.put(COL_2, entry.mStarted.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000) + contentValues.put( + COL_2, + entry.mStarted.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000 + ) contentValues.put(COL_3, entry.mDurationSeconds) contentValues.put(COL_4, if (entry.sessionID != null) entry.sessionID else -1) contentValues.put(COL_5, entry.name) @@ -148,7 +153,8 @@ class DungeonVisitDatabaseHelper(context: Context) : val mode = DungeonMode(DungeonMode.Modes.valueOf(type)) mode.mbHard = hard val visit = DungeonVisit(sessionId, name, mode) - visit.mStarted = LocalDateTime.ofInstant(Instant.ofEpochSecond(started), ZoneId.systemDefault()) + visit.mStarted = + LocalDateTime.ofInstant(Instant.ofEpochSecond(started), ZoneId.systemDefault()) visit.mDurationSeconds = duration visit.orns = orns visit.gold = gold @@ -184,11 +190,11 @@ class DungeonVisitDatabaseHelper(context: Context) : fun getVisitsForSession(session: Long): ArrayList { val db = this.writableDatabase return toEntries( - db.rawQuery( - "SELECT * FROM $TABLE_NAME " + - "WHERE session='$session' ", - null - ) + db.rawQuery( + "SELECT * FROM $TABLE_NAME " + + "WHERE session='$session' ", + null + ) ) } diff --git a/app/src/main/java/com/rockethat/ornaassistant/db/KingdomGauntletDatabaseHelper.kt b/app/src/main/java/com/rockethat/ornaassistant/db/KingdomGauntletDatabaseHelper.kt index 8652f5e..5c2ef22 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/db/KingdomGauntletDatabaseHelper.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/db/KingdomGauntletDatabaseHelper.kt @@ -46,10 +46,13 @@ class KingdomGauntletDatabaseHelper(context: Context) : * It Will insert data to SQLIte database. */ @RequiresApi(Build.VERSION_CODES.O) - fun insertData(dt: LocalDateTime, name: String ) { + fun insertData(dt: LocalDateTime, name: String) { val db = this.writableDatabase val contentValues = ContentValues() - contentValues.put(COL_1, dt.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000) + contentValues.put( + COL_1, + dt.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000 + ) contentValues.put(COL_2, name) db.insert(TABLE_NAME, null, contentValues) } @@ -86,7 +89,8 @@ class KingdomGauntletDatabaseHelper(context: Context) : val started = cur.getLong(col++) val name = cur.getString(col++) - val startedDt = LocalDateTime.ofInstant(Instant.ofEpochSecond(started), ZoneId.systemDefault()) + val startedDt = + LocalDateTime.ofInstant(Instant.ofEpochSecond(started), ZoneId.systemDefault()) list.add(KingdomMemberDatabaseItem(startedDt, name)) } @@ -108,7 +112,11 @@ class KingdomGauntletDatabaseHelper(context: Context) : } @RequiresApi(Build.VERSION_CODES.O) - fun getEntriesBetween(start: LocalDateTime, end: LocalDateTime, name: String): List { + fun getEntriesBetween( + start: LocalDateTime, + end: LocalDateTime, + name: String + ): List { val startUnix = start.toEpochSecond(ZoneOffset.UTC) val endUnix = end.toEpochSecond(ZoneOffset.UTC) val db = this.writableDatabase @@ -124,7 +132,10 @@ class KingdomGauntletDatabaseHelper(context: Context) : } @RequiresApi(Build.VERSION_CODES.O) - fun getEntriesBetween(start: LocalDateTime, end: LocalDateTime): List { + fun getEntriesBetween( + start: LocalDateTime, + end: LocalDateTime + ): List { val startUnix = start.toEpochSecond(ZoneOffset.UTC) val endUnix = end.toEpochSecond(ZoneOffset.UTC) val db = this.writableDatabase diff --git a/app/src/main/java/com/rockethat/ornaassistant/db/KingdomMemberDatabaseHelper.kt b/app/src/main/java/com/rockethat/ornaassistant/db/KingdomMemberDatabaseHelper.kt index 2112c23..e35da3a 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/db/KingdomMemberDatabaseHelper.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/db/KingdomMemberDatabaseHelper.kt @@ -5,13 +5,7 @@ import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper import android.os.Build import androidx.annotation.RequiresApi -import com.rockethat.ornaassistant.KingdomGauntletFloor import com.rockethat.ornaassistant.KingdomMember -import com.rockethat.ornaassistant.WayvesselSession -import com.rockethat.ornaassistant.db.DungeonVisitDatabaseHelper -import com.rockethat.ornaassistant.db.WayvesselSessionDatabaseHelper -import java.time.LocalDateTime -import java.time.ZoneOffset class KingdomMemberDatabaseHelper(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, VERSION) { @@ -27,8 +21,7 @@ class KingdomMemberDatabaseHelper(context: Context) : } override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { - if (oldVersion == 1 && newVersion == 2) - { + if (oldVersion == 1 && newVersion == 2) { db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_3 INTEGER DEFAULT 1000"); } } @@ -66,17 +59,19 @@ class KingdomMemberDatabaseHelper(context: Context) : val db = this.writableDatabase val existing = getEntry(entry.character) - if (existing != null && existing.discordName == entry.discordName && existing.timezone == entry.timezone) - { + if (existing != null && existing.discordName == entry.discordName && existing.timezone == entry.timezone) { return false - } - else - { + } else { val contentValues = ContentValues() contentValues.put(COL_1, entry.character.replace("'", "''")) contentValues.put(COL_2, entry.discordName.replace("'", "''")) contentValues.put(COL_3, entry.timezone) - db.update(TABLE_NAME, contentValues, "ign = ?", arrayOf(entry.character.replace("'", "''"))) + db.update( + TABLE_NAME, + contentValues, + "ign = ?", + arrayOf(entry.character.replace("'", "''")) + ) } return true diff --git a/app/src/main/java/com/rockethat/ornaassistant/db/WayvesselSessionDatabaseHelper.kt b/app/src/main/java/com/rockethat/ornaassistant/db/WayvesselSessionDatabaseHelper.kt index a64975f..6982e0c 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/db/WayvesselSessionDatabaseHelper.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/db/WayvesselSessionDatabaseHelper.kt @@ -55,7 +55,8 @@ class WayvesselSessionDatabaseHelper(context: Context) : fun insertData(entry: WayvesselSession): Long { val db = this.writableDatabase val contentValues = ContentValues() - val started = entry.mStarted.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000 + val started = + entry.mStarted.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000 contentValues.put(COL_2, started) contentValues.put(COL_3, entry.mDurationSeconds) contentValues.put(COL_4, entry.name) @@ -64,15 +65,18 @@ class WayvesselSessionDatabaseHelper(context: Context) : contentValues.put(COL_7, entry.experience) db.insert(TABLE_NAME, null, contentValues) - val entries = toEntries(db.rawQuery( - "SELECT * FROM $TABLE_NAME " + - "WHERE started = $started " + - "AND duration = ${entry.mDurationSeconds} " + - "AND name = '${entry.name}' " + - "AND orns = ${entry.orns} " + - "AND gold = ${entry.gold} " + - "AND experience = ${entry.experience} ", - null)) + val entries = toEntries( + db.rawQuery( + "SELECT * FROM $TABLE_NAME " + + "WHERE started = $started " + + "AND duration = ${entry.mDurationSeconds} " + + "AND name = '${entry.name}' " + + "AND orns = ${entry.orns} " + + "AND gold = ${entry.gold} " + + "AND experience = ${entry.experience} ", + null + ) + ) return if (entries.size == 1) { entries.first().mID @@ -90,7 +94,10 @@ class WayvesselSessionDatabaseHelper(context: Context) : val db = this.writableDatabase val contentValues = ContentValues() contentValues.put(COL_1, id) - contentValues.put(COL_2, entry.mStarted.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000) + contentValues.put( + COL_2, + entry.mStarted.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000 + ) contentValues.put(COL_3, entry.mDurationSeconds) contentValues.put(COL_4, entry.name) contentValues.put(COL_5, entry.orns) @@ -138,7 +145,8 @@ class WayvesselSessionDatabaseHelper(context: Context) : val experience = cur.getLong(col++) val session = WayvesselSession(name, id) - session.mStarted = LocalDateTime.ofInstant(Instant.ofEpochSecond(started), ZoneId.systemDefault()) + session.mStarted = + LocalDateTime.ofInstant(Instant.ofEpochSecond(started), ZoneId.systemDefault()) session.mDurationSeconds = duration session.orns = orns session.gold = gold @@ -171,12 +179,12 @@ class WayvesselSessionDatabaseHelper(context: Context) : fun getLastNSessionsFor(name: String, n: Int): ArrayList { val db = this.writableDatabase return toEntries( - db.rawQuery( - "SELECT * FROM $TABLE_NAME " + - "WHERE name='${name.replace("'", "''")}' " + - "ORDER BY ID DESC LIMIT $n ", - null - ) + db.rawQuery( + "SELECT * FROM $TABLE_NAME " + + "WHERE name='${name.replace("'", "''")}' " + + "ORDER BY ID DESC LIMIT $n ", + null + ) ) } diff --git a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaView.kt b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaView.kt index 6794876..3f67251 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaView.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaView.kt @@ -3,8 +3,12 @@ package com.rockethat.ornaassistant import android.content.Context import android.view.ViewGroup import android.view.WindowManager -import com.rockethat.ornaassistant.ornaviews.* -import java.util.ArrayList +import com.rockethat.ornaassistant.ornaviews.OrnaViewDungeonEntry +import com.rockethat.ornaassistant.ornaviews.OrnaViewInventory +import com.rockethat.ornaassistant.ornaviews.OrnaViewItem +import com.rockethat.ornaassistant.ornaviews.OrnaViewKingdomGauntlet +import com.rockethat.ornaassistant.ornaviews.OrnaViewNotifications +import com.rockethat.ornaassistant.ornaviews.OrnaViewWayvessel object OrnaViewFactory { fun create( @@ -30,27 +34,35 @@ object OrnaViewFactory { data.any { it.name == "ACQUIRED" } -> { OrnaViewType.ITEM } + data.any { it.name == "New" } -> { OrnaViewType.INVENTORY } + data.any { it.name == "Notifications" } -> { OrnaViewType.NOTIFICATIONS } + data.any { it.name.lowercase().contains("this wayvessel is active") } -> { OrnaViewType.WAYVESSEL } + data.any { it.name.lowercase().contains("special dungeon") } -> { OrnaViewType.DUNGEON_ENTRY } + data.any { it.name.lowercase().contains("world dungeon") } -> { OrnaViewType.DUNGEON_ENTRY } + data.any { it.name.lowercase().contains("losses:") } -> { OrnaViewType.KINGDOM_GAUNTLET } - data.any {it.name.startsWith("Battle a series of opponents")} -> { + + data.any { it.name.startsWith("Battle a series of opponents") } -> { OrnaViewType.DUNGEON_ENTRY } + else -> { null } diff --git a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewDungeonEntry.kt b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewDungeonEntry.kt index b76dedd..1f4dd65 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewDungeonEntry.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewDungeonEntry.kt @@ -3,8 +3,11 @@ package com.rockethat.ornaassistant.ornaviews import android.content.Context import android.util.Log import android.view.WindowManager -import com.rockethat.ornaassistant.* -import java.util.ArrayList +import com.rockethat.ornaassistant.DungeonMode +import com.rockethat.ornaassistant.OrnaView +import com.rockethat.ornaassistant.OrnaViewType +import com.rockethat.ornaassistant.OrnaViewUpdateType +import com.rockethat.ornaassistant.ScreenData class OrnaViewDungeonEntry(data: ArrayList, wm: WindowManager, ctx: Context) : OrnaView(OrnaViewType.DUNGEON_ENTRY, wm, ctx) { @@ -138,8 +141,7 @@ class OrnaViewDungeonEntry(data: ArrayList, wm: WindowManager, ctx: updateMap[OrnaViewUpdateType.DUNGEON_MODE_CHANGED] = null } - if (mbEntered) - { + if (mbEntered) { if (data.any { it.name.lowercase().contains("godforged") }) { Log.d(this.javaClass.toString().split(".").last(), this.toString()) updateMap[OrnaViewUpdateType.DUNGEON_GODFORGE] = null @@ -147,7 +149,10 @@ class OrnaViewDungeonEntry(data: ArrayList, wm: WindowManager, ctx: if (data.any { it.name.lowercase().contains("complete") }) { if (!mVictoryScreenHandledForFloor && mbEntered) { - Log.d(this.javaClass.toString().split(".").last(), this.toString() + " complete!") + Log.d( + this.javaClass.toString().split(".").last(), + this.toString() + " complete!" + ) parseLoot(data, updateMap) mVictoryScreenHandledForFloor = true } @@ -168,7 +173,10 @@ class OrnaViewDungeonEntry(data: ArrayList, wm: WindowManager, ctx: if (data.any { it.name.lowercase().contains("victory") }) { if (!mVictoryScreenHandledForFloor) { - Log.d(this.javaClass.toString().split(".").last(), this.toString() + " victory!") + Log.d( + this.javaClass.toString().split(".").last(), + this.toString() + " victory!" + ) parseLoot(data, updateMap) mVictoryScreenHandledForFloor = true } @@ -187,8 +195,10 @@ class OrnaViewDungeonEntry(data: ArrayList, wm: WindowManager, ctx: when (item.name) { " experience" -> updateMap[OrnaViewUpdateType.DUNGEON_EXPERIENCE] = numberValue + " party experience" -> updateMap[OrnaViewUpdateType.DUNGEON_EXPERIENCE] = numberValue + " gold" -> updateMap[OrnaViewUpdateType.DUNGEON_GOLD] = numberValue " orns" -> updateMap[OrnaViewUpdateType.DUNGEON_ORNS] = numberValue } diff --git a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewInventory.kt b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewInventory.kt index 97932b4..3ad7d4d 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewInventory.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewInventory.kt @@ -5,7 +5,6 @@ import android.view.WindowManager import com.rockethat.ornaassistant.OrnaView import com.rockethat.ornaassistant.OrnaViewType import com.rockethat.ornaassistant.ScreenData -import java.util.ArrayList class OrnaViewInventory(data: ArrayList, wm: WindowManager, ctx: Context) : OrnaView(OrnaViewType.INVENTORY, wm, ctx) { diff --git a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewItem.kt b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewItem.kt index 8de0ec2..5313b60 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewItem.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewItem.kt @@ -13,10 +13,14 @@ import androidx.core.view.isVisible import com.android.volley.DefaultRetryPolicy import com.android.volley.Request import com.android.volley.toolbox.JsonObjectRequest -import com.rockethat.ornaassistant.* +import com.rockethat.ornaassistant.OrnaView +import com.rockethat.ornaassistant.OrnaViewType +import com.rockethat.ornaassistant.OrnaViewUpdateType +import com.rockethat.ornaassistant.ScreenData +import com.rockethat.ornaassistant.VolleySingleton +import com.rockethat.ornaassistant.startsWithUppercaseLetter import org.json.JSONObject import org.json.JSONTokener -import java.util.ArrayList import java.util.Locale class OrnaViewItem(data: ArrayList, wm: WindowManager, ctx: Context) : @@ -31,8 +35,7 @@ class OrnaViewItem(data: ArrayList, wm: WindowManager, ctx: Context) data: ArrayList, updateResults: (MutableMap) -> Unit ): Boolean { - if (itemName == null) - { + if (itemName == null) { val cleanedData = data .filter { it.name.startsWithUppercaseLetter() } .filterNot { it.name.startsWith("Inventory") } @@ -141,8 +144,7 @@ class OrnaViewItem(data: ArrayList, wm: WindowManager, ctx: Context) val nameData = data.firstOrNull() var name = nameData?.name nameLocation = nameData?.position - if (name!!.contains("You are")) - { + if (name!!.contains("You are")) { name = data[1].name nameLocation = data[1].position } diff --git a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewKingdomGauntlet.kt b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewKingdomGauntlet.kt index 56753f8..26bafba 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewKingdomGauntlet.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewKingdomGauntlet.kt @@ -1,12 +1,14 @@ package com.rockethat.ornaassistant.ornaviews import android.content.Context -import android.os.Build import android.util.Log import android.view.WindowManager -import androidx.annotation.RequiresApi -import com.rockethat.ornaassistant.* -import java.util.ArrayList +import com.rockethat.ornaassistant.KingdomGauntletFloor +import com.rockethat.ornaassistant.KingdomMember +import com.rockethat.ornaassistant.OrnaView +import com.rockethat.ornaassistant.OrnaViewType +import com.rockethat.ornaassistant.OrnaViewUpdateType +import com.rockethat.ornaassistant.ScreenData class OrnaViewKingdomGauntlet(data: ArrayList, wm: WindowManager, ctx: Context) : OrnaView(OrnaViewType.KINGDOM_GAUNTLET, wm, ctx) { @@ -37,8 +39,7 @@ class OrnaViewKingdomGauntlet(data: ArrayList, wm: WindowManager, ct var highestDepth = 0 - if (data.any{it.name.equals("Allies")}) - { + if (data.any { it.name.equals("Allies") }) { // workaround for allies view return true } diff --git a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewNotifications.kt b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewNotifications.kt index 5dbc792..580f3c1 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewNotifications.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewNotifications.kt @@ -7,7 +7,6 @@ import com.rockethat.ornaassistant.OrnaView import com.rockethat.ornaassistant.OrnaViewType import com.rockethat.ornaassistant.OrnaViewUpdateType import com.rockethat.ornaassistant.ScreenData -import java.util.ArrayList class OrnaViewNotifications(data: ArrayList, wm: WindowManager, ctx: Context) : OrnaView(OrnaViewType.NOTIFICATIONS, wm, ctx) { diff --git a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewWayvessel.kt b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewWayvessel.kt index d5a4796..c8391de 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewWayvessel.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ornaviews/OrnaViewWayvessel.kt @@ -5,7 +5,6 @@ import android.view.WindowManager import com.rockethat.ornaassistant.OrnaView import com.rockethat.ornaassistant.OrnaViewType import com.rockethat.ornaassistant.ScreenData -import java.util.ArrayList class OrnaViewWayvessel(data: ArrayList, wm: WindowManager, ctx: Context) : OrnaView(OrnaViewType.WAYVESSEL, wm, ctx) { diff --git a/app/src/main/java/com/rockethat/ornaassistant/overlays/InviterOverlay.kt b/app/src/main/java/com/rockethat/ornaassistant/overlays/InviterOverlay.kt index cc05d13..c3d8370 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/overlays/InviterOverlay.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/overlays/InviterOverlay.kt @@ -1,28 +1,22 @@ package com.rockethat.ornaassistant.overlays import android.content.Context -import android.graphics.PixelFormat import android.graphics.Rect import android.os.Build -import android.view.Gravity import android.view.View import android.view.WindowManager import androidx.annotation.RequiresApi import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.rockethat.ornaassistant.KingdomMember import com.rockethat.ornaassistant.R import com.rockethat.ornaassistant.db.DungeonVisitDatabaseHelper import com.rockethat.ornaassistant.db.WayvesselSessionDatabaseHelper -import com.rockethat.ornaassistant.viewadapters.KGAdapter -import com.rockethat.ornaassistant.viewadapters.KGItem import com.rockethat.ornaassistant.viewadapters.NotificationsAdapter import com.rockethat.ornaassistant.viewadapters.NotificationsItem import java.time.Duration import java.time.LocalDateTime import java.time.temporal.TemporalField import java.time.temporal.WeekFields -import java.time.temporal.WeekFields.ISO import java.util.* import java.util.concurrent.atomic.AtomicBoolean diff --git a/app/src/main/java/com/rockethat/ornaassistant/overlays/KGOverlay.kt b/app/src/main/java/com/rockethat/ornaassistant/overlays/KGOverlay.kt index 4bcc92e..f3633a0 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/overlays/KGOverlay.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/overlays/KGOverlay.kt @@ -8,7 +8,6 @@ import android.view.WindowManager import androidx.annotation.RequiresApi import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.rockethat.ornaassistant.KingdomGauntletFloor import com.rockethat.ornaassistant.KingdomMember import com.rockethat.ornaassistant.R import com.rockethat.ornaassistant.viewadapters.KGAdapter @@ -53,7 +52,7 @@ class KGOverlay( "Seen" ) ) - val nowUTC = OffsetDateTime.now( ZoneOffset.UTC ) + val nowUTC = OffsetDateTime.now(ZoneOffset.UTC) data.forEach { it -> var sleeptime = "" if (it.endTimeLeftSeconds > 0) { @@ -63,8 +62,7 @@ class KGOverlay( } var localTime = "" - if (it.timezone < 1000) - { + if (it.timezone < 1000) { val time = nowUTC.plusHours(it.timezone.toLong()) localTime = "${time.hour}.${time.minute.toString().padStart(2, '0')}" } diff --git a/app/src/main/java/com/rockethat/ornaassistant/overlays/Overlay.kt b/app/src/main/java/com/rockethat/ornaassistant/overlays/Overlay.kt index c0419e6..5928b90 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/overlays/Overlay.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/overlays/Overlay.kt @@ -1,18 +1,16 @@ package com.rockethat.ornaassistant.overlays +import android.annotation.SuppressLint import android.content.Context import android.graphics.PixelFormat +import android.os.* +import android.util.Log import android.view.Gravity +import android.view.MotionEvent import android.view.View +import android.view.View.OnTouchListener import android.view.WindowManager -import androidx.annotation.RequiresApi -import android.util.Log import java.util.concurrent.atomic.AtomicBoolean -import android.annotation.SuppressLint -import android.view.MotionEvent -import android.view.View.OnTouchListener -import android.os.* -import android.os.HandlerThread import kotlin.math.abs import kotlin.math.pow import kotlin.math.sqrt @@ -74,12 +72,10 @@ open class Overlay( mPos.eventStartX = x mPos.eventStartY = y mPos.moveEvents = 0 - } - else { + } else { val dist = move(x, y) - if ((event.action == MotionEvent.ACTION_UP) && (dist < 20.0)){ - if (dist < 20.0) - { + if ((event.action == MotionEvent.ACTION_UP) && (dist < 20.0)) { + if (dist < 20.0) { hide() } } diff --git a/app/src/main/java/com/rockethat/ornaassistant/overlays/SessionOverlay.kt b/app/src/main/java/com/rockethat/ornaassistant/overlays/SessionOverlay.kt index 4c504ee..16c373e 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/overlays/SessionOverlay.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/overlays/SessionOverlay.kt @@ -1,27 +1,12 @@ package com.rockethat.ornaassistant.overlays import android.content.Context -import android.graphics.PixelFormat -import android.graphics.Rect import android.os.Build -import android.os.Handler -import android.os.Looper -import android.view.Gravity import android.view.View import android.view.WindowManager import android.widget.TextView import androidx.annotation.RequiresApi -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import com.rockethat.ornaassistant.* -import com.rockethat.ornaassistant.db.DungeonVisitDatabaseHelper -import com.rockethat.ornaassistant.db.WayvesselSessionDatabaseHelper -import com.rockethat.ornaassistant.viewadapters.KGAdapter -import com.rockethat.ornaassistant.viewadapters.KGItem -import com.rockethat.ornaassistant.viewadapters.NotificationsAdapter -import com.rockethat.ornaassistant.viewadapters.NotificationsItem -import java.time.Duration -import java.time.LocalDateTime class SessionOverlay( mWM: WindowManager, diff --git a/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/FragmentAdapter.kt b/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/FragmentAdapter.kt index 8dbb648..8c30e04 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/FragmentAdapter.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/FragmentAdapter.kt @@ -1,13 +1,13 @@ package com.rockethat.ornaassistant.ui.fragment -import android.view.View import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.Lifecycle import androidx.viewpager2.adapter.FragmentStateAdapter -class FragmentAdapter(fragmentManager: FragmentManager, - lifecycle: Lifecycle +class FragmentAdapter( + fragmentManager: FragmentManager, + lifecycle: Lifecycle ) : FragmentStateAdapter(fragmentManager, lifecycle) { var frags = mutableListOf() override fun getItemCount(): Int = 2 diff --git a/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/KingdomFragment.kt b/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/KingdomFragment.kt index 3410ce2..4441454 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/KingdomFragment.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/KingdomFragment.kt @@ -6,13 +6,13 @@ import android.content.ClipboardManager import android.content.Context import android.os.Build import android.os.Bundle -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.TextView import androidx.annotation.RequiresApi +import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.rockethat.ornaassistant.KingdomMember @@ -20,8 +20,8 @@ import com.rockethat.ornaassistant.R import com.rockethat.ornaassistant.db.KingdomGauntletDatabaseHelper import com.rockethat.ornaassistant.ui.viewadapters.KingdomSeenAdapter import com.rockethat.ornaassistant.ui.viewadapters.KingdomSeenItem -import org.json.JSONTokener import org.json.JSONObject +import org.json.JSONTokener import java.time.LocalDateTime // TODO: Rename parameter arguments, choose names that match diff --git a/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/MainFragment.kt b/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/MainFragment.kt index 7b163af..005beef 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/MainFragment.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/MainFragment.kt @@ -1,6 +1,5 @@ package com.rockethat.ornaassistant.ui.fragment -import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.content.res.Configuration @@ -8,28 +7,23 @@ import android.graphics.Color import android.os.Build import android.os.Bundle import android.provider.Settings -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import com.rockethat.ornaassistant.R import android.widget.Button import androidx.annotation.RequiresApi +import androidx.fragment.app.Fragment +import androidx.preference.PreferenceManager import com.github.mikephil.charting.charts.BarChart import com.github.mikephil.charting.components.AxisBase import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.data.* import com.github.mikephil.charting.formatter.ValueFormatter +import com.rockethat.ornaassistant.DungeonVisit +import com.rockethat.ornaassistant.R import com.rockethat.ornaassistant.db.DungeonVisitDatabaseHelper import java.time.LocalDate -import android.content.res.Resources.Theme - -import android.util.TypedValue -import androidx.preference.PreferenceManager -import com.google.android.material.color.MaterialColors -import com.rockethat.ornaassistant.DungeonVisit - // TODO: Rename parameter arguments, choose names that match // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER diff --git a/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/SettingFragment.kt b/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/SettingFragment.kt index 29658c0..3762d28 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/SettingFragment.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ui/fragment/SettingFragment.kt @@ -1,10 +1,10 @@ package com.rockethat.ornaassistant.ui.fragment +import android.content.SharedPreferences import android.os.Bundle -import com.rockethat.ornaassistant.R import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceManager -import android.content.SharedPreferences +import com.rockethat.ornaassistant.R class SettingFragment : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/com/rockethat/ornaassistant/ui/viewadapters/KingdomSeenAdapter.kt b/app/src/main/java/com/rockethat/ornaassistant/ui/viewadapters/KingdomSeenAdapter.kt index fcd0188..3014f2b 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/ui/viewadapters/KingdomSeenAdapter.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/ui/viewadapters/KingdomSeenAdapter.kt @@ -1,15 +1,10 @@ package com.rockethat.ornaassistant.ui.viewadapters +import android.view.LayoutInflater import android.view.View +import android.view.ViewGroup import android.widget.TextView import androidx.recyclerview.widget.RecyclerView -import android.content.Context -import android.graphics.Color -import android.graphics.Typeface - -import android.view.LayoutInflater - -import android.view.ViewGroup import com.rockethat.ornaassistant.R class KingdomSeenAdapter( diff --git a/app/src/main/java/com/rockethat/ornaassistant/viewadapters/AssessAdapter.kt b/app/src/main/java/com/rockethat/ornaassistant/viewadapters/AssessAdapter.kt index 15d403e..06eb7eb 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/viewadapters/AssessAdapter.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/viewadapters/AssessAdapter.kt @@ -1,16 +1,13 @@ package com.rockethat.ornaassistant.viewadapters -import android.view.View -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView import android.content.Context import android.graphics.Color import android.graphics.Typeface -import android.util.Log - import android.view.LayoutInflater - +import android.view.View import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView import com.rockethat.ornaassistant.R class AssessAdapter( @@ -26,6 +23,7 @@ class AssessAdapter( RecyclerView.ViewHolder(itemView), View.OnClickListener { val cols = mutableListOf() + init { itemView.setOnClickListener(this) cols.clear() @@ -106,14 +104,14 @@ class AssessAdapter( // Set item views based on your views and data model var i = 0 for (col in item.cols) { - if (i < holder.cols.size) { + if (i < holder.cols.size) { holder.cols[i].text = col holder.cols[i].visibility = View.VISIBLE } i++ } - while (i < holder.cols.size) { + while (i < holder.cols.size) { holder.cols[i].visibility = View.GONE i++ } diff --git a/app/src/main/java/com/rockethat/ornaassistant/viewadapters/KGAdapter.kt b/app/src/main/java/com/rockethat/ornaassistant/viewadapters/KGAdapter.kt index b1d5dcc..aee8abc 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/viewadapters/KGAdapter.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/viewadapters/KGAdapter.kt @@ -1,15 +1,13 @@ package com.rockethat.ornaassistant.viewadapters -import android.view.View -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView import android.content.Context import android.graphics.Color import android.graphics.Typeface - import android.view.LayoutInflater - +import android.view.View import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView import com.rockethat.ornaassistant.R class KGAdapter( diff --git a/app/src/main/java/com/rockethat/ornaassistant/viewadapters/NotificationsAdapter.kt b/app/src/main/java/com/rockethat/ornaassistant/viewadapters/NotificationsAdapter.kt index 7589d38..9b550ec 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/viewadapters/NotificationsAdapter.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/viewadapters/NotificationsAdapter.kt @@ -14,7 +14,8 @@ class NotificationsAdapter( private val itemClickListener: () -> Unit ) : RecyclerView.Adapter() { - inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener { + inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), + View.OnClickListener { init { itemView.setOnClickListener(this) } diff --git a/app/src/main/java/com/rockethat/ornaassistant/viewadapters/NotificationsItem.kt b/app/src/main/java/com/rockethat/ornaassistant/viewadapters/NotificationsItem.kt index 9ba1d2b..3d6ab60 100644 --- a/app/src/main/java/com/rockethat/ornaassistant/viewadapters/NotificationsItem.kt +++ b/app/src/main/java/com/rockethat/ornaassistant/viewadapters/NotificationsItem.kt @@ -1,13 +1,15 @@ package com.rockethat.ornaassistant.viewadapters -class NotificationsItem(val inviter: String, - val N: String, - val VoG: String, - val D: String, - val BG: String, - val UW: String, - val CG: String, - val cooldown: String, - val statusBad: Boolean) { +class NotificationsItem( + val inviter: String, + val N: String, + val VoG: String, + val D: String, + val BG: String, + val UW: String, + val CG: String, + val cooldown: String, + val statusBad: Boolean +) { } \ No newline at end of file