diff --git a/.editorconfig b/.editorconfig index 6e60abda..bb87f8f1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,7 +17,7 @@ insert_final_newline = true charset = utf-8 # Tab indentation -[makefile,Makefile] +[Makefile] indent_style = tab ## PEP 0008 https://www.python.org/dev/peps/pep-0008/ [*.py] diff --git a/.gitignore b/.gitignore index 98c65c20..657dfecc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ /local.properties /.idea/workspace.xml /.idea/libraries -.DS_Store /build* app/*.apk diff --git a/app/build.gradle b/app/build.gradle index 49720089..68e9e47d 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,14 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 33 - defaultConfig { applicationId "ch.logixisland.anuto" - minSdkVersion 17 - targetSdkVersion 33 - versionCode 32 - versionName "0.11" + compileSdk 34 + minSdkVersion 23 + targetSdkVersion 35 + versionCode 33 + versionName "0.12" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { @@ -30,6 +29,6 @@ android { dependencies { testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test:rules:1.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test:rules:1.6.1' } diff --git a/app/src/androidTest/java/ch/logixisland/anuto/DefaultGameSimulator.java b/app/src/androidTest/java/ch/logixisland/anuto/DefaultGameSimulator.java index d05da1c6..94db3f71 100755 --- a/app/src/androidTest/java/ch/logixisland/anuto/DefaultGameSimulator.java +++ b/app/src/androidTest/java/ch/logixisland/anuto/DefaultGameSimulator.java @@ -125,7 +125,6 @@ private void tryEnhanceTower() { while (iterator.hasNext()) { Tower tower = iterator.next(); - final int tier = mTowerTiers.getTowerTier(tower); // check if enhancing is possible if (!tower.isEnhanceable()) { diff --git a/app/src/androidTest/java/ch/logixisland/anuto/IntegrationTest.java b/app/src/androidTest/java/ch/logixisland/anuto/IntegrationTest.java index e6c17bb9..4fc426b4 100755 --- a/app/src/androidTest/java/ch/logixisland/anuto/IntegrationTest.java +++ b/app/src/androidTest/java/ch/logixisland/anuto/IntegrationTest.java @@ -1,7 +1,7 @@ package ch.logixisland.anuto; +import androidx.test.ext.junit.rules.ActivityScenarioRule; import androidx.test.filters.LargeTest; -import androidx.test.rule.ActivityTestRule; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Rule; @@ -15,7 +15,7 @@ public class IntegrationTest { @Rule - public ActivityTestRule mActivityRule = new ActivityTestRule<>(GameActivity.class); + public ActivityScenarioRule mActivityRule = new ActivityScenarioRule<>(GameActivity.class); @Test public void integrationTest() { diff --git a/app/src/main/java/ch/logixisland/anuto/business/game/GameState.java b/app/src/main/java/ch/logixisland/anuto/business/game/GameState.java index d390ba36..d9bc86f2 100755 --- a/app/src/main/java/ch/logixisland/anuto/business/game/GameState.java +++ b/app/src/main/java/ch/logixisland/anuto/business/game/GameState.java @@ -23,7 +23,7 @@ public interface Listener { private boolean mGameStarted = false; private int mFinalScore = 0; - private List mListeners = new CopyOnWriteArrayList<>(); + private final List mListeners = new CopyOnWriteArrayList<>(); public GameState(ScoreBoard scoreBoard, HighScores highScores, TowerSelector towerSelector) { mScoreBoard = scoreBoard; diff --git a/app/src/main/java/ch/logixisland/anuto/business/game/MapInfo.java b/app/src/main/java/ch/logixisland/anuto/business/game/MapInfo.java index d2c539c4..fec0aa28 100755 --- a/app/src/main/java/ch/logixisland/anuto/business/game/MapInfo.java +++ b/app/src/main/java/ch/logixisland/anuto/business/game/MapInfo.java @@ -2,9 +2,9 @@ public class MapInfo { - private String mMapId; - private int mMapNameResId; - private int mMapDataResId; + private final String mMapId; + private final int mMapNameResId; + private final int mMapDataResId; MapInfo(String mapId, int mapNameResId, int mapDataResId) { mMapId = mapId; diff --git a/app/src/main/java/ch/logixisland/anuto/business/game/SaveGameRepository.java b/app/src/main/java/ch/logixisland/anuto/business/game/SaveGameRepository.java index 54d60e7e..81156b9f 100644 --- a/app/src/main/java/ch/logixisland/anuto/business/game/SaveGameRepository.java +++ b/app/src/main/java/ch/logixisland/anuto/business/game/SaveGameRepository.java @@ -1,6 +1,5 @@ package ch.logixisland.anuto.business.game; -import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -54,7 +53,6 @@ public List getSaveGameInfos() { public SaveGameInfo createSaveGame(Bitmap screenshot, int score, int wave, int lives) { Date date = new Date(); - @SuppressLint("SimpleDateFormat") SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); File folder = new File(mContext.getFilesDir() + File.separator + "savegame" + File.separator diff --git a/app/src/main/java/ch/logixisland/anuto/business/tower/TowerInfo.java b/app/src/main/java/ch/logixisland/anuto/business/tower/TowerInfo.java index 66b35943..3d227d69 100755 --- a/app/src/main/java/ch/logixisland/anuto/business/tower/TowerInfo.java +++ b/app/src/main/java/ch/logixisland/anuto/business/tower/TowerInfo.java @@ -9,19 +9,19 @@ public class TowerInfo { - private int mValue; - private int mLevel; - private int mLevelMax; - private boolean mEnhanceable; - private int mEnhanceCost; - private boolean mUpgradeable; - private int mUpgradeCost; - private boolean mSellable; - private boolean mCanLockTarget; + private final int mValue; + private final int mLevel; + private final int mLevelMax; + private final boolean mEnhanceable; + private final int mEnhanceCost; + private final boolean mUpgradeable; + private final int mUpgradeCost; + private final boolean mSellable; + private final boolean mCanLockTarget; private boolean mDoesLockTarget; - private boolean mHasStrategy; + private final boolean mHasStrategy; private TowerStrategy mStrategy; - private List mProperties; + private final List mProperties; public TowerInfo(Tower tower, int credits, boolean controlsEnabled) { mValue = tower.getValue(); diff --git a/app/src/main/java/ch/logixisland/anuto/business/tower/TowerInserter.java b/app/src/main/java/ch/logixisland/anuto/business/tower/TowerInserter.java index 3ba29a43..4ba71f5f 100755 --- a/app/src/main/java/ch/logixisland/anuto/business/tower/TowerInserter.java +++ b/app/src/main/java/ch/logixisland/anuto/business/tower/TowerInserter.java @@ -31,7 +31,7 @@ public interface Listener { private Tower mInsertedTower; private Plateau mCurrentPlateau; - private Collection mListeners = new CopyOnWriteArrayList<>(); + private final Collection mListeners = new CopyOnWriteArrayList<>(); public TowerInserter(GameEngine gameEngine, GameState gameState, EntityRegistry entityRegistry, TowerSelector towerSelector, TowerAging towerAging, ScoreBoard scoreBoard) { diff --git a/app/src/main/java/ch/logixisland/anuto/business/tower/TowerSelector.java b/app/src/main/java/ch/logixisland/anuto/business/tower/TowerSelector.java index 95d15e30..f8488d73 100755 --- a/app/src/main/java/ch/logixisland/anuto/business/tower/TowerSelector.java +++ b/app/src/main/java/ch/logixisland/anuto/business/tower/TowerSelector.java @@ -38,7 +38,7 @@ public interface Listener { private TowerInfo mTowerInfo; private Tower mSelectedTower; - private Collection mListeners = new CopyOnWriteArrayList<>(); + private final Collection mListeners = new CopyOnWriteArrayList<>(); public TowerSelector(GameEngine gameEngine, ScoreBoard scoreBoard) { mGameEngine = gameEngine; diff --git a/app/src/main/java/ch/logixisland/anuto/business/wave/WaveAttender.java b/app/src/main/java/ch/logixisland/anuto/business/wave/WaveAttender.java index 0835e8aa..a7a8e22a 100755 --- a/app/src/main/java/ch/logixisland/anuto/business/wave/WaveAttender.java +++ b/app/src/main/java/ch/logixisland/anuto/business/wave/WaveAttender.java @@ -28,7 +28,7 @@ class WaveAttender implements Enemy.Listener { private final List mPaths; private final Collection mRemainingEnemies = new ArrayList<>(); - private int mWaveNumber; + private final int mWaveNumber; private int mWaveStartTickCount; private int mExtend; @@ -78,7 +78,7 @@ void modifyEnemyReward(float modifier) { } void modifyWaveReward(float modifier) { - mWaveReward *= modifier; + mWaveReward = (int) ((float) mWaveReward * modifier); } void start() { diff --git a/app/src/main/java/ch/logixisland/anuto/engine/logic/map/GameMap.java b/app/src/main/java/ch/logixisland/anuto/engine/logic/map/GameMap.java index 1696fbc7..418d7fc6 100755 --- a/app/src/main/java/ch/logixisland/anuto/engine/logic/map/GameMap.java +++ b/app/src/main/java/ch/logixisland/anuto/engine/logic/map/GameMap.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import ch.logixisland.anuto.util.container.KeyValueStore; diff --git a/app/src/main/java/ch/logixisland/anuto/engine/logic/map/MapPath.java b/app/src/main/java/ch/logixisland/anuto/engine/logic/map/MapPath.java index 57e3bcf0..5a1b23f0 100755 --- a/app/src/main/java/ch/logixisland/anuto/engine/logic/map/MapPath.java +++ b/app/src/main/java/ch/logixisland/anuto/engine/logic/map/MapPath.java @@ -1,6 +1,5 @@ package ch.logixisland.anuto.engine.logic.map; -import java.util.Collections; import java.util.List; import ch.logixisland.anuto.util.math.Vector2; diff --git a/app/src/main/java/ch/logixisland/anuto/engine/logic/map/WaveInfo.java b/app/src/main/java/ch/logixisland/anuto/engine/logic/map/WaveInfo.java index 66d2d0bb..e70b83b3 100755 --- a/app/src/main/java/ch/logixisland/anuto/engine/logic/map/WaveInfo.java +++ b/app/src/main/java/ch/logixisland/anuto/engine/logic/map/WaveInfo.java @@ -1,7 +1,6 @@ package ch.logixisland.anuto.engine.logic.map; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import ch.logixisland.anuto.util.container.KeyValueStore; diff --git a/app/src/main/java/ch/logixisland/anuto/engine/logic/persistence/GamePersister.java b/app/src/main/java/ch/logixisland/anuto/engine/logic/persistence/GamePersister.java index 4da0b43e..237cc35e 100755 --- a/app/src/main/java/ch/logixisland/anuto/engine/logic/persistence/GamePersister.java +++ b/app/src/main/java/ch/logixisland/anuto/engine/logic/persistence/GamePersister.java @@ -7,7 +7,7 @@ public class GamePersister { - private List mPersisterList = new ArrayList<>(); + private final List mPersisterList = new ArrayList<>(); public void registerPersister(Persister persister) { mPersisterList.add(persister); diff --git a/app/src/main/java/ch/logixisland/anuto/engine/theme/ThemeManager.java b/app/src/main/java/ch/logixisland/anuto/engine/theme/ThemeManager.java index 18ff5aea..d767be3f 100755 --- a/app/src/main/java/ch/logixisland/anuto/engine/theme/ThemeManager.java +++ b/app/src/main/java/ch/logixisland/anuto/engine/theme/ThemeManager.java @@ -22,9 +22,9 @@ public interface Listener { private final Renderer mRenderer; private Theme mTheme; - private List mAvailableThemes = new ArrayList<>(); + private final List mAvailableThemes = new ArrayList<>(); - private List mListeners = new CopyOnWriteArrayList<>(); + private final List mListeners = new CopyOnWriteArrayList<>(); public ThemeManager(Context context, Renderer renderer) { mRenderer = renderer; diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/AreaObserver.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/AreaObserver.java index a70a4d17..d434590c 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/AreaObserver.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/AreaObserver.java @@ -2,8 +2,6 @@ import java.util.HashSet; import java.util.Iterator; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; import ch.logixisland.anuto.engine.logic.GameEngine; import ch.logixisland.anuto.engine.logic.entity.Entity; @@ -14,8 +12,8 @@ public class AreaObserver implements Entity.Listener { - private Vector2 mPosition; - private float mRange; + private final Vector2 mPosition; + private final float mRange; private boolean mFinished; private final GameEngine mGameEngine; diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/BouncingLaser.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/BouncingLaser.java index 27d02748..8d33e08d 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/BouncingLaser.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/BouncingLaser.java @@ -25,7 +25,7 @@ public class BouncingLaser extends Effect { private final static int ALPHA_STEP = (int) (ALPHA_START / (GameEngine.TARGET_FRAME_RATE * VISIBLE_EFFECT_DURATION)); private class LaserDrawable implements Drawable { - private Paint mPaint; + private final Paint mPaint; private int mAlpha = ALPHA_START; private LaserDrawable() { @@ -56,15 +56,15 @@ public void draw(Canvas canvas) { } } - private float mDamage; - private int mBounceCount; - public float mMaxBounceDist; + private final float mDamage; + private final int mBounceCount; + public final float mMaxBounceDist; private Enemy mOrigin; - private Enemy mTarget; + private final Enemy mTarget; private Vector2 mTargetPos; private Collection mPrevTargets; - private LaserDrawable mDrawObject; + private final LaserDrawable mDrawObject; public BouncingLaser(Entity origin, Vector2 position, Enemy target, float damage) { this(origin, position, target, damage, 0, 0); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/Effect.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/Effect.java index f37ceff9..67ad3580 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/Effect.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/Effect.java @@ -12,7 +12,7 @@ enum State { Ended } - private Entity mOrigin; + private final Entity mOrigin; private TickTimer mTimer; private State mState; diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/Explosion.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/Explosion.java index 9db0fbf5..65ff6067 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/Explosion.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/Explosion.java @@ -22,7 +22,7 @@ public class Explosion extends Effect { private final static int ALPHA_STEP = (int) (ALPHA_START / (GameEngine.TARGET_FRAME_RATE * EFFECT_DURATION)); private class ExplosionDrawable implements Drawable { - private Paint mPaint; + private final Paint mPaint; private int mAlpha = ALPHA_START; private ExplosionDrawable() { @@ -52,11 +52,11 @@ public void draw(Canvas canvas) { } } - private float mDamage; - private float mRadius; + private final float mDamage; + private final float mRadius; - private ExplosionDrawable mDrawObject; - private Sound mSound; + private final ExplosionDrawable mDrawObject; + private final Sound mSound; public Explosion(Entity origin, Vector2 position, float damage, float radius) { super(origin, EFFECT_DURATION); @@ -103,9 +103,4 @@ protected void effectBegin() { enemy.damage(mDamage, getOrigin()); } } - - @Override - protected void effectEnd() { - - } } diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/GlueEffect.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/GlueEffect.java index 3ed44c50..c5fadba8 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/GlueEffect.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/GlueEffect.java @@ -25,13 +25,13 @@ private static class StaticData { SpriteTemplate mSpriteTemplate; } - private float mAngle; - private float mIntensity; - private int mAlphaStep; - private AreaObserver mAreaObserver; + private final float mAngle; + private final float mIntensity; + private final int mAlphaStep; + private final AreaObserver mAreaObserver; - private Paint mPaint; - private StaticSprite mSprite; + private final Paint mPaint; + private final StaticSprite mSprite; public GlueEffect(Entity origin, Vector2 position, float intensity, float duration) { super(origin, duration); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/HealEffect.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/HealEffect.java index ca9793a0..0559ccdc 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/HealEffect.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/HealEffect.java @@ -39,12 +39,12 @@ public void draw(Canvas canvas) { } } - private float mRange; + private final float mRange; private float mDrawRadius; - private float mHealAmount; + private final float mHealAmount; - private Drawable mDrawable; - private Collection mHealedEnemies; + private final Drawable mDrawable; + private final Collection mHealedEnemies; private StaticData mStaticData; public HealEffect(Entity origin, Vector2 position, float amount, float radius, Collection healedEnemies) { diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/StraightLaser.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/StraightLaser.java index bea908b3..06797028 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/StraightLaser.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/StraightLaser.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.concurrent.CopyOnWriteArrayList; import ch.logixisland.anuto.engine.logic.GameEngine; import ch.logixisland.anuto.engine.logic.entity.Entity; @@ -29,7 +28,7 @@ public class StraightLaser extends Effect { private final static int ALPHA_STEP = (int) (ALPHA_START / (GameEngine.TARGET_FRAME_RATE * VISIBLE_EFFECT_DURATION)); private class LaserDrawable implements Drawable { - private Paint mPaint; + private final Paint mPaint; private int mAlpha = ALPHA_START; public LaserDrawable() { @@ -60,11 +59,11 @@ public void draw(Canvas canvas) { } } - private float mDamage; - private Vector2 mLaserTo; - private Collection mStunnedFliers = new ArrayList<>(); + private final float mDamage; + private final Vector2 mLaserTo; + private final Collection mStunnedFliers = new ArrayList<>(); - private LaserDrawable mDrawObject; + private final LaserDrawable mDrawObject; public StraightLaser(Entity origin, Vector2 position, Vector2 laserTo, float damage) { super(origin, EFFECT_DURATION); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/TeleportEffect.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/TeleportEffect.java index 155c037f..d51f5f8f 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/TeleportEffect.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/TeleportEffect.java @@ -38,10 +38,10 @@ public void draw(Canvas canvas) { private Enemy mTarget; - private float mDistance; - private Vector2 mMoveDirection; - private float mMoveStep; - private TeleportDrawable mDrawObject; + private final float mDistance; + private final Vector2 mMoveDirection; + private final float mMoveStep; + private final TeleportDrawable mDrawObject; private StaticData mStaticData; public TeleportEffect(Entity origin, Vector2 position, Enemy target, float distance) { diff --git a/app/src/main/java/ch/logixisland/anuto/entity/effect/TeleportedMarker.java b/app/src/main/java/ch/logixisland/anuto/entity/effect/TeleportedMarker.java index f4a6936d..27f76f76 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/effect/TeleportedMarker.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/effect/TeleportedMarker.java @@ -50,7 +50,7 @@ public void draw(Canvas canvas) { private final Entity mMarked; private StaticData mStaticData; - private MarkerDrawable mDrawable; + private final MarkerDrawable mDrawable; public TeleportedMarker(Entity marked) { super(marked); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Blob.java b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Blob.java index 58ffdfec..526631b7 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Blob.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Blob.java @@ -49,7 +49,7 @@ public void tick() { } } - private ReplicatedSprite mSprite; + private final ReplicatedSprite mSprite; private Blob(GameEngine gameEngine) { super(gameEngine, ENEMY_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Enemy.java b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Enemy.java index f8156440..88579ff2 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Enemy.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Enemy.java @@ -33,7 +33,7 @@ public interface Listener { void enemyRemoved(Enemy enemy); } - private EnemyProperties mEnemyProperties; + private final EnemyProperties mEnemyProperties; private float mHealth; private float mMaxHealth; private float mSpeedModifier; @@ -44,7 +44,7 @@ public interface Listener { private boolean mBeingTeleported; private boolean mWasTeleported; - private HealthBar mHealthBar; + private final HealthBar mHealthBar; private final List mListeners = new CopyOnWriteArrayList<>(); @@ -238,7 +238,7 @@ public void sendBack(float dist) { Vector2 pos = getPosition(); while (index > 0) { - Vector2 wp = mWayPoints.get(index);; + Vector2 wp = mWayPoints.get(index); float toWpDist = pos.distanceTo(wp); if (dist > toWpDist) { diff --git a/app/src/main/java/ch/logixisland/anuto/entity/enemy/EnemyProperties.java b/app/src/main/java/ch/logixisland/anuto/entity/enemy/EnemyProperties.java index 1e94e352..768f866c 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/enemy/EnemyProperties.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/enemy/EnemyProperties.java @@ -14,7 +14,7 @@ public class EnemyProperties { public static class Builder { - private EnemyProperties mResult = new EnemyProperties(); + private final EnemyProperties mResult = new EnemyProperties(); public Builder setHealth(int health) { mResult.mHealth = health; diff --git a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Flyer.java b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Flyer.java index f6d3a3a2..d65e813b 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Flyer.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Flyer.java @@ -52,7 +52,7 @@ public void tick() { private float mAngle; - private ReplicatedSprite mSprite; + private final ReplicatedSprite mSprite; private Flyer(GameEngine gameEngine) { super(gameEngine, ENEMY_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Healer.java b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Healer.java index 54647915..31fffcd9 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Healer.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Healer.java @@ -2,7 +2,6 @@ import android.graphics.Canvas; -import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -97,9 +96,9 @@ public void tick() { } } - private StaticData mStaticData; + private final StaticData mStaticData; - private ReplicatedSprite mSprite; + private final ReplicatedSprite mSprite; private Healer(GameEngine gameEngine) { super(gameEngine, ENEMY_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Soldier.java b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Soldier.java index 6f05394d..fc8ac179 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Soldier.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Soldier.java @@ -47,7 +47,7 @@ public void tick() { } } - private ReplicatedSprite mSprite; + private final ReplicatedSprite mSprite; private Soldier(GameEngine gameEngine) { super(gameEngine, ENEMY_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Sprinter.java b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Sprinter.java index 1f653f96..9a4f9f62 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/enemy/Sprinter.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/enemy/Sprinter.java @@ -56,8 +56,8 @@ public void tick() { } private float mAngle; - private StaticData mStatic; - private ReplicatedSprite mSprite; + private final StaticData mStatic; + private final ReplicatedSprite mSprite; private Sprinter(GameEngine gameEngine) { super(gameEngine, ENEMY_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/plateau/BasicPlateau.java b/app/src/main/java/ch/logixisland/anuto/entity/plateau/BasicPlateau.java index 8f80de1b..d4216b7c 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/plateau/BasicPlateau.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/plateau/BasicPlateau.java @@ -34,7 +34,7 @@ private static class StaticData { SpriteTemplate mSpriteTemplate; } - private StaticSprite mSprite; + private final StaticSprite mSprite; private BasicPlateau(GameEngine gameEngine) { super(gameEngine); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/shot/CanonShot.java b/app/src/main/java/ch/logixisland/anuto/entity/shot/CanonShot.java index a36379a2..89794fac 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/shot/CanonShot.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/shot/CanonShot.java @@ -26,10 +26,10 @@ private static class StaticData { } private float mAngle; - private float mDamage; - private TargetTracker mTracker; + private final float mDamage; + private final TargetTracker mTracker; - private StaticSprite mSprite; + private final StaticSprite mSprite; public CanonShot(Entity origin, Vector2 position, Enemy target, float damage) { super(origin); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/shot/CanonShotMg.java b/app/src/main/java/ch/logixisland/anuto/entity/shot/CanonShotMg.java index 844e5905..790f680d 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/shot/CanonShotMg.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/shot/CanonShotMg.java @@ -24,10 +24,10 @@ private static class StaticData { public SpriteTemplate mSpriteTemplate; } - private float mAngle; - private float mDamage; + private final float mAngle; + private final float mDamage; - private StaticSprite mSprite; + private final StaticSprite mSprite; public CanonShotMg(Entity origin, Vector2 position, Vector2 direction, float damage) { super(origin); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/shot/GlueShot.java b/app/src/main/java/ch/logixisland/anuto/entity/shot/GlueShot.java index c6e56110..0b5f1084 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/shot/GlueShot.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/shot/GlueShot.java @@ -25,13 +25,13 @@ private static class StaticData { public SpriteTemplate mSpriteTemplate; } - private float mIntensity; + private final float mIntensity; - private float mDuration; - private Vector2 mTarget; - private AnimatedSprite mSprite; + private final float mDuration; + private final Vector2 mTarget; + private final AnimatedSprite mSprite; - private Sound mSound; + private final Sound mSound; public GlueShot(Entity origin, Vector2 position, Vector2 target, float intensity, float duration) { super(origin); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/shot/Mine.java b/app/src/main/java/ch/logixisland/anuto/entity/shot/Mine.java index 3dfa4358..b6e99743 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/shot/Mine.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/shot/Mine.java @@ -37,12 +37,12 @@ private static class StaticData { SpriteTemplate mSpriteTemplate; } - private float mDamage; - private float mRadius; + private final float mDamage; + private final float mRadius; private float mAngle; private boolean mFlying; private float mRotationStep; - private SampledFunction mHeightScalingFunction; + private final SampledFunction mHeightScalingFunction; private Vector2 mTarget; private StaticSprite mSpriteFlying; @@ -106,10 +106,6 @@ private void createAssets() { mSpriteMine.setIndex(index); } - public Vector2 getTarget() { - return mTarget; - } - @Override public Object initStatic() { StaticData s = new StaticData(); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/shot/MortarShot.java b/app/src/main/java/ch/logixisland/anuto/entity/shot/MortarShot.java index 56683899..f6f680f0 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/shot/MortarShot.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/shot/MortarShot.java @@ -28,12 +28,12 @@ private static class StaticData { SpriteTemplate mSpriteTemplate; } - private float mDamage; - private float mRadius; - private float mAngle; - private SampledFunction mHeightScalingFunction; + private final float mDamage; + private final float mRadius; + private final float mAngle; + private final SampledFunction mHeightScalingFunction; - private StaticSprite mSprite; + private final StaticSprite mSprite; public MortarShot(Entity origin, Vector2 position, Vector2 target, float damage, float radius) { super(origin); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/shot/Rocket.java b/app/src/main/java/ch/logixisland/anuto/entity/shot/Rocket.java index e067aab7..0ee0e199 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/shot/Rocket.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/shot/Rocket.java @@ -27,13 +27,13 @@ private static class StaticData { SpriteTemplate mSpriteTemplateFire; } - private float mDamage; - private float mRadius; + private final float mDamage; + private final float mRadius; private float mAngle; - private TargetTracker mTracker; + private final TargetTracker mTracker; - private StaticSprite mSprite; - private AnimatedSprite mSpriteFire; + private final StaticSprite mSprite; + private final AnimatedSprite mSpriteFire; public Rocket(Entity origin, Vector2 position, float damage, float radius) { super(origin); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/shot/Shot.java b/app/src/main/java/ch/logixisland/anuto/entity/shot/Shot.java index 73d5857f..e69d59f0 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/shot/Shot.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/shot/Shot.java @@ -7,7 +7,7 @@ public abstract class Shot extends Entity { - private Entity mOrigin; + private final Entity mOrigin; private float mSpeed; private Vector2 mDirection; private boolean mEnabled = true; diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/BouncingLaser.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/BouncingLaser.java index 9cf7b80f..0e7c11ea 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/BouncingLaser.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/BouncingLaser.java @@ -65,9 +65,9 @@ private static class StaticData { private float mAngle = 90f; private final Aimer mAimer = new Aimer(this); - private StaticSprite mSpriteBase; - private StaticSprite mSpriteCanon; - private Sound mSound; + private final StaticSprite mSpriteBase; + private final StaticSprite mSpriteCanon; + private final Sound mSound; private BouncingLaser(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/Canon.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/Canon.java index 83e0233a..f00ca8b4 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/Canon.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/Canon.java @@ -68,12 +68,12 @@ private static class StaticData { private boolean mReboundActive; private final Aimer mAimer = new Aimer(this); - private SampledFunction mReboundFunction; + private final SampledFunction mReboundFunction; - private StaticSprite mSpriteBase; - private StaticSprite mSpriteCanon; + private final StaticSprite mSpriteBase; + private final StaticSprite mSpriteCanon; - private Sound mSound; + private final Sound mSound; private Canon(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/DualCanon.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/DualCanon.java index 716d61f3..88e6e181 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/DualCanon.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/DualCanon.java @@ -76,10 +76,10 @@ private static class SubCanon { private SubCanon[] mCanons = new SubCanon[2]; private final Aimer mAimer = new Aimer(this); - private StaticSprite mSpriteBase; - private StaticSprite mSpriteTower; + private final StaticSprite mSpriteBase; + private final StaticSprite mSpriteTower; - private Sound mSound; + private final Sound mSound; private DualCanon(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/GlueGun.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/GlueGun.java index 1ff07eef..1c4fa1ba 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/GlueGun.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/GlueGun.java @@ -69,9 +69,9 @@ private static class StaticData { private boolean mRebounding = false; private final Aimer mAimer = new Aimer(this); - private StaticSprite mSpriteBase; - private AnimatedSprite mSpriteCanon; - private Sound mSound; + private final StaticSprite mSpriteBase; + private final AnimatedSprite mSpriteCanon; + private final Sound mSound; private GlueGun(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/GlueTower.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/GlueTower.java index c660c2ca..ce17e716 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/GlueTower.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/GlueTower.java @@ -85,11 +85,11 @@ public void draw(SpriteInstance sprite, Canvas canvas) { private float mGlueIntensity; private boolean mShooting; private float mCanonOffset; - private SubCanon[] mCanons = new SubCanon[8]; - private Collection mTargets = new ArrayList<>(); - private StaticSprite mSpriteBase; + private final SubCanon[] mCanons = new SubCanon[8]; + private final Collection mTargets = new ArrayList<>(); + private final StaticSprite mSpriteBase; - private StaticSprite mSpriteTower; + private final StaticSprite mSpriteTower; private final TickTimer mUpdateTimer = TickTimer.createInterval(0.1f); private GlueTower(GameEngine gameEngine) { diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/MachineGun.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/MachineGun.java index 0d4e6d2d..30b1418b 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/MachineGun.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/MachineGun.java @@ -62,12 +62,12 @@ private static class StaticData { SpriteTemplate mSpriteTemplateCanon; } - private float mBaseReloadTime; + private final float mBaseReloadTime; private float mAngle = 90f; - private StaticSprite mSpriteBase; - private AnimatedSprite mSpriteCanon; + private final StaticSprite mSpriteBase; + private final AnimatedSprite mSpriteCanon; private int mShotCount = 0; - private Sound mSound; + private final Sound mSound; private final Aimer mAimer = new Aimer(this); private MachineGun(GameEngine gameEngine) { diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/MineLayer.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/MineLayer.java index 24349f1c..7497f80a 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/MineLayer.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/MineLayer.java @@ -94,15 +94,15 @@ private static class StaticData { public SpriteTemplate mSpriteTemplate; } - private float mAngle; + private final float mAngle; private int mMaxMineCount; private float mExplosionRadius; private boolean mShooting; private Collection mSections; - private Collection mMines = new ArrayList<>(); + private final Collection mMines = new ArrayList<>(); - private AnimatedSprite mSprite; - private Sound mSound; + private final AnimatedSprite mSprite; + private final Sound mSound; private final Entity.Listener mMineListener = new Entity.Listener() { @Override diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/Mortar.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/Mortar.java index 101292b0..e7019501 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/Mortar.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/Mortar.java @@ -70,9 +70,9 @@ private static class StaticData { private boolean mRebounding = false; private final Aimer mAimer = new Aimer(this); - private StaticSprite mSpriteBase; - private AnimatedSprite mSpriteCanon; - private Sound mSound; + private final StaticSprite mSpriteBase; + private final AnimatedSprite mSpriteCanon; + private final Sound mSound; private Mortar(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/RocketLauncher.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/RocketLauncher.java index de1caaf5..c603ca8f 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/RocketLauncher.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/RocketLauncher.java @@ -62,12 +62,12 @@ private static class StaticData { private float mExplosionRadius; private float mAngle = 90f; private Rocket mRocket; - private TickTimer mRocketLoadTimer; + private final TickTimer mRocketLoadTimer; private final Aimer mAimer = new Aimer(this); - private StaticSprite mSprite; - private StaticSprite mSpriteRocket; // used for preview only - private Sound mSound; + private final StaticSprite mSprite; + private final StaticSprite mSpriteRocket; // used for preview only + private final Sound mSound; private RocketLauncher(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/SimpleLaser.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/SimpleLaser.java index faca4fe1..1b288d0f 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/SimpleLaser.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/SimpleLaser.java @@ -62,9 +62,9 @@ private static class StaticData { private float mAngle = 90f; private final Aimer mAimer = new Aimer(this); - private StaticSprite mSpriteBase; - private StaticSprite mSpriteCanon; - private Sound mSound; + private final StaticSprite mSpriteBase; + private final StaticSprite mSpriteCanon; + private final Sound mSound; private SimpleLaser(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/StraightLaser.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/StraightLaser.java index 1fc6a345..8d6d9155 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/StraightLaser.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/StraightLaser.java @@ -60,9 +60,9 @@ private static class StaticData { private float mAngle = 90f; private final Aimer mAimer = new Aimer(this); - private StaticSprite mSpriteBase; - private StaticSprite mSpriteCanon; - private Sound mSound; + private final StaticSprite mSpriteBase; + private final StaticSprite mSpriteCanon; + private final Sound mSound; private StraightLaser(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/Teleporter.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/Teleporter.java index 7683910f..a0f8bdb3 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/Teleporter.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/Teleporter.java @@ -62,9 +62,9 @@ private static class StaticData { private float mTeleportDistance; private final Aimer mAimer = new Aimer(this); - private StaticSprite mSpriteBase; - private StaticSprite mSpriteTower; - private Sound mSound; + private final StaticSprite mSpriteBase; + private final StaticSprite mSpriteTower; + private final Sound mSound; private Teleporter(GameEngine gameEngine) { super(gameEngine, TOWER_PROPERTIES); @@ -169,8 +169,6 @@ public List getTowerInfoValues() { @Override public StreamIterator getPossibleTargets() { - StaticData s = (StaticData) getStaticData(); - return super.getPossibleTargets() .filter(enemy -> !enemy.isBeingTeleported() && !enemy.wasTeleported()); } diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/Tower.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/Tower.java index 39a25b88..b22b4f64 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/Tower.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/Tower.java @@ -22,7 +22,7 @@ public interface Listener { void propertiesChanged(); } - private TowerProperties mTowerProperties; + private final TowerProperties mTowerProperties; private boolean mBuilt; private int mValue; @@ -35,7 +35,7 @@ public interface Listener { private Plateau mPlateau; - private TickTimer mReloadTimer; + private final TickTimer mReloadTimer; private RangeIndicator mRangeIndicator; private LevelIndicator mLevelIndicator; diff --git a/app/src/main/java/ch/logixisland/anuto/entity/tower/TowerProperties.java b/app/src/main/java/ch/logixisland/anuto/entity/tower/TowerProperties.java index 71b9bea3..26ccf701 100755 --- a/app/src/main/java/ch/logixisland/anuto/entity/tower/TowerProperties.java +++ b/app/src/main/java/ch/logixisland/anuto/entity/tower/TowerProperties.java @@ -21,7 +21,7 @@ public class TowerProperties { public static class Builder { - private TowerProperties mResult = new TowerProperties(); + private final TowerProperties mResult = new TowerProperties(); public Builder setValue(int value) { mResult.mValue = value; diff --git a/app/src/main/java/ch/logixisland/anuto/util/StringUtils.java b/app/src/main/java/ch/logixisland/anuto/util/StringUtils.java index 30af3aed..1defa8dd 100755 --- a/app/src/main/java/ch/logixisland/anuto/util/StringUtils.java +++ b/app/src/main/java/ch/logixisland/anuto/util/StringUtils.java @@ -11,8 +11,8 @@ private StringUtils() { } - private static DecimalFormat fmt0 = new DecimalFormat("0"); - private static DecimalFormat fmt1 = new DecimalFormat("0.0"); + private static final DecimalFormat fmt0 = new DecimalFormat("0"); + private static final DecimalFormat fmt1 = new DecimalFormat("0.0"); public static String formatSuffix(int value) { return formatSuffix(value, true); diff --git a/app/src/main/java/ch/logixisland/anuto/util/container/KeyValueStore.java b/app/src/main/java/ch/logixisland/anuto/util/container/KeyValueStore.java index 93163c0c..cdb3fd1d 100755 --- a/app/src/main/java/ch/logixisland/anuto/util/container/KeyValueStore.java +++ b/app/src/main/java/ch/logixisland/anuto/util/container/KeyValueStore.java @@ -1,6 +1,5 @@ package ch.logixisland.anuto.util.container; -import android.annotation.SuppressLint; import android.content.res.Resources; import org.json.JSONArray; @@ -11,7 +10,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -24,10 +23,9 @@ public class KeyValueStore { - @SuppressLint("SimpleDateFormat") - private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); - private JSONObject mJsonObject; + private final JSONObject mJsonObject; public KeyValueStore() { mJsonObject = new JSONObject(); @@ -38,15 +36,10 @@ protected KeyValueStore(JSONObject jsonObject) { } public static KeyValueStore fromResources(Resources resources, int resourceId) { - InputStream stream = resources.openRawResource(resourceId); - - try { + try (InputStream stream = resources.openRawResource(resourceId)) { return fromStream(stream); - } finally { - try { - stream.close(); - } catch (IOException ignored) { - } + } catch (IOException e) { + throw new RuntimeException(e); } } @@ -54,7 +47,7 @@ public static KeyValueStore fromStream(InputStream input) { try { char[] buffer = new char[1024]; StringBuilder stringBuilder = new StringBuilder(); - InputStreamReader reader = new InputStreamReader(input, Charset.forName("UTF-8")); + InputStreamReader reader = new InputStreamReader(input, StandardCharsets.UTF_8); while (true) { int count = reader.read(buffer, 0, buffer.length); @@ -73,7 +66,7 @@ public static KeyValueStore fromStream(InputStream input) { public void toStream(OutputStream output) { try { - output.write(mJsonObject.toString().getBytes(Charset.forName("UTF-8"))); + output.write(mJsonObject.toString().getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/app/src/main/java/ch/logixisland/anuto/util/container/SafeCollection.java b/app/src/main/java/ch/logixisland/anuto/util/container/SafeCollection.java index 0cceb63e..7945547f 100755 --- a/app/src/main/java/ch/logixisland/anuto/util/container/SafeCollection.java +++ b/app/src/main/java/ch/logixisland/anuto/util/container/SafeCollection.java @@ -142,7 +142,6 @@ public Object[] toArray() { @Override public T1[] toArray(T1[] array) { - //noinspection SuspiciousToArrayCall return mItems.toArray(array); } diff --git a/app/src/main/java/ch/logixisland/anuto/util/iterator/FilteringIterator.java b/app/src/main/java/ch/logixisland/anuto/util/iterator/FilteringIterator.java index 6c32a153..51aef919 100644 --- a/app/src/main/java/ch/logixisland/anuto/util/iterator/FilteringIterator.java +++ b/app/src/main/java/ch/logixisland/anuto/util/iterator/FilteringIterator.java @@ -2,8 +2,8 @@ class FilteringIterator extends LazyIterator { - private Predicate mFilter; - private StreamIterator mOriginal; + private final Predicate mFilter; + private final StreamIterator mOriginal; FilteringIterator(StreamIterator original, Predicate filter) { mOriginal = original; diff --git a/app/src/main/java/ch/logixisland/anuto/util/iterator/MappingIterator.java b/app/src/main/java/ch/logixisland/anuto/util/iterator/MappingIterator.java index 479700ce..b30f07b9 100644 --- a/app/src/main/java/ch/logixisland/anuto/util/iterator/MappingIterator.java +++ b/app/src/main/java/ch/logixisland/anuto/util/iterator/MappingIterator.java @@ -2,8 +2,8 @@ class MappingIterator extends StreamIterator { - private Function mMapper; - private StreamIterator mOriginal; + private final Function mMapper; + private final StreamIterator mOriginal; MappingIterator(StreamIterator original, Function mapper) { mOriginal = original; diff --git a/app/src/main/java/ch/logixisland/anuto/view/game/TowerInfoFragment.java b/app/src/main/java/ch/logixisland/anuto/view/game/TowerInfoFragment.java index 2ec60e6d..09c18b2e 100755 --- a/app/src/main/java/ch/logixisland/anuto/view/game/TowerInfoFragment.java +++ b/app/src/main/java/ch/logixisland/anuto/view/game/TowerInfoFragment.java @@ -32,8 +32,8 @@ public class TowerInfoFragment extends AnutoFragment implements View.OnClickList private Handler mHandler; private TextView txt_level; - private TextView[] txt_property = new TextView[6]; - private TextView[] txt_property_text = new TextView[6]; + private final TextView[] txt_property = new TextView[6]; + private final TextView[] txt_property_text = new TextView[6]; private Button btn_strategy; private Button btn_lock_target; diff --git a/app/src/main/java/ch/logixisland/anuto/view/load/LoadGameActivity.java b/app/src/main/java/ch/logixisland/anuto/view/load/LoadGameActivity.java index 87e4b2a4..37cf7b0f 100644 --- a/app/src/main/java/ch/logixisland/anuto/view/load/LoadGameActivity.java +++ b/app/src/main/java/ch/logixisland/anuto/view/load/LoadGameActivity.java @@ -19,7 +19,7 @@ public class LoadGameActivity extends AnutoActivity implements AdapterView.OnItemClickListener, ViewTreeObserver.OnScrollChangedListener { - public static int CONTEXT_MENU_DELETE_ID = 0; + public static final int CONTEXT_MENU_DELETE_ID = 0; private final GameLoader mGameLoader; private final SaveGameRepository mSaveGameRepository; diff --git a/app/src/main/java/ch/logixisland/anuto/view/load/SaveGamesAdapter.java b/app/src/main/java/ch/logixisland/anuto/view/load/SaveGamesAdapter.java index e667bef0..3c0fce9d 100644 --- a/app/src/main/java/ch/logixisland/anuto/view/load/SaveGamesAdapter.java +++ b/app/src/main/java/ch/logixisland/anuto/view/load/SaveGamesAdapter.java @@ -24,8 +24,6 @@ public class SaveGamesAdapter extends BaseAdapter { - private static final Map sThumbCache = new HashMap<>(); - private final WeakReference mActivityRef; private final List mSaveGameInfos; @@ -35,11 +33,11 @@ public class SaveGamesAdapter extends BaseAdapter { } static private class ViewHolder { - ImageView img_thumb; - TextView txt_datetime; - TextView txt_score; - TextView txt_waveNumber; - TextView txt_lives; + final ImageView img_thumb; + final TextView txt_datetime; + final TextView txt_score; + final TextView txt_waveNumber; + final TextView txt_lives; ViewHolder(View view) { img_thumb = view.findViewById(R.id.img_thumb); diff --git a/app/src/main/java/ch/logixisland/anuto/view/map/MapsAdapter.java b/app/src/main/java/ch/logixisland/anuto/view/map/MapsAdapter.java index 4a2e3093..301092b9 100755 --- a/app/src/main/java/ch/logixisland/anuto/view/map/MapsAdapter.java +++ b/app/src/main/java/ch/logixisland/anuto/view/map/MapsAdapter.java @@ -36,9 +36,9 @@ class MapsAdapter extends BaseAdapter { } static private class ViewHolder { - ImageView img_thumb; - TextView txt_name; - TextView txt_highscore; + final ImageView img_thumb; + final TextView txt_name; + final TextView txt_highscore; ViewHolder(View view) { img_thumb = view.findViewById(R.id.img_thumb); diff --git a/app/src/main/java/ch/logixisland/anuto/view/stats/EnemiesAdapter.java b/app/src/main/java/ch/logixisland/anuto/view/stats/EnemiesAdapter.java index b5102669..c0946754 100644 --- a/app/src/main/java/ch/logixisland/anuto/view/stats/EnemiesAdapter.java +++ b/app/src/main/java/ch/logixisland/anuto/view/stats/EnemiesAdapter.java @@ -28,7 +28,7 @@ public class EnemiesAdapter extends BaseAdapter { private final List mEnemies; private final WeakReference mActivityRef; - private Theme mTheme; + private final Theme mTheme; public EnemiesAdapter(Activity activity, Theme theme, EntityRegistry entityRegistry) { mActivityRef = new WeakReference<>(activity); @@ -41,13 +41,13 @@ public EnemiesAdapter(Activity activity, Theme theme, EntityRegistry entityRegis } static private class ViewHolder { - ImageView img_enemy; - TextView txt_name; - TextView txt_health; - TextView txt_speed; - TextView txt_reward; - TextView txt_weak_against; - TextView txt_strong_against; + final ImageView img_enemy; + final TextView txt_name; + final TextView txt_health; + final TextView txt_speed; + final TextView txt_reward; + final TextView txt_weak_against; + final TextView txt_strong_against; ViewHolder(View view) { img_enemy = view.findViewById(R.id.img_enemy); @@ -120,11 +120,11 @@ public View getView(int position, View convertView, ViewGroup parent) { viewHolder.txt_reward.setText(tmp); tmp = TextUtils.join("\n", enemyProperties.getWeakAgainst()); - viewHolder.txt_weak_against.setText(tmp.length() > 0 ? tmp : activity.getString(R.string.none)); + viewHolder.txt_weak_against.setText(!tmp.isEmpty() ? tmp : activity.getString(R.string.none)); viewHolder.txt_weak_against.setTextColor(mTheme.getColor(R.attr.weakAgainstColor)); tmp = TextUtils.join("\n", enemyProperties.getStrongAgainst()); - viewHolder.txt_strong_against.setText(tmp.length() > 0 ? tmp : activity.getString(R.string.none)); + viewHolder.txt_strong_against.setText(!tmp.isEmpty() ? tmp : activity.getString(R.string.none)); viewHolder.txt_strong_against.setTextColor(mTheme.getColor(R.attr.strongAgainstColor)); Bitmap bmp = createPreviewBitmap(enemy); diff --git a/app/src/main/java/ch/logixisland/anuto/view/stats/EnemyStatsActivity.java b/app/src/main/java/ch/logixisland/anuto/view/stats/EnemyStatsActivity.java index d0ad2421..c0a6662b 100644 --- a/app/src/main/java/ch/logixisland/anuto/view/stats/EnemyStatsActivity.java +++ b/app/src/main/java/ch/logixisland/anuto/view/stats/EnemyStatsActivity.java @@ -14,13 +14,11 @@ public class EnemyStatsActivity extends AnutoActivity implements ThemeManager.Listener { - private Context mAppContext; - private Theme mTheme; - private EntityRegistry mEntityRegistry; + private final Theme mTheme; + private final EntityRegistry mEntityRegistry; public EnemyStatsActivity() { AnutoApplication app = AnutoApplication.getInstance(); - mAppContext = app.getApplicationContext(); mTheme = app.getGameFactory().getGameEngine().getThemeManager().getTheme(); mEntityRegistry = app.getGameFactory().getEntityRegistry(); } diff --git a/build.gradle b/build.gradle index daa78829..ec06610a 100755 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:8.0.2' + classpath 'com.android.tools.build:gradle:8.5.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index 98241225..2f4f8ad1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ -android.defaults.buildfeatures.buildconfig=true android.enableJetifier=true android.nonFinalResIds=false android.nonTransitiveRClass=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 824c04b6..8ff016ee 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip