Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5.5.2 #3

Merged
merged 56 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0d0d74b
Adds integers.xml generator and moves pokebattler generator
nahojjjen Oct 28, 2018
e0566de
[Rf] change line-brake code.
udnp May 14, 2020
bf10ff7
Merge branch 'moveAndUpdateDevMethods' into pr/gradle-task-update-dat…
udnp May 21, 2020
a7d6556
provide Gradle task updateDatabase extended from the branch origin/mo…
udnp May 27, 2020
4a3e78e
[C] revert to avoid conflicting with origin/master.
udnp Jun 22, 2020
d100cbb
First update for level 50
xZise Dec 1, 2020
c90e2fe
Fixed level 50 power up values
xZise Dec 5, 2020
c339f08
Add candy XL costs to the power up fraction
xZise Dec 5, 2020
386229e
Define Gastrodon devolution number
xZise Oct 3, 2019
96f5816
Add button to manually restart appraisal
xZise Dec 1, 2020
0ac4e07
Update GAME_MASTER parser classes
lramati Dec 24, 2020
c1f76fd
Update and refactor GAME_MASTER parsing code
lramati Dec 24, 2020
cbd1ca7
A whole bunch of gradle changes I needed to make to compile?
lramati Dec 24, 2020
2ea8dd6
Updated XML Resources
lramati Dec 24, 2020
7c8ad81
Small python script that was helpful for writing GAME_MASTER json par…
lramati Dec 24, 2020
6b18cfb
Add VS Code to gitignore
lramati Dec 24, 2020
09fe1b9
Merge branch 'master' into fix_GAME_MASTER_parse
lramati Dec 24, 2020
350f829
Unbreak checkstyle rules
lramati Dec 25, 2020
99fee71
Fix a lot of checkstyle stuff in devMethods, also get rid of a bunch …
lramati Dec 25, 2020
204d334
Fix integers.xml generation
lramati Dec 25, 2020
6109161
Merge remote-tracking branch 'lramati/fix_GAME_MASTER_parse' into bey…
xZise Dec 25, 2020
3762032
Generate pokemon.xml files as well
xZise Dec 28, 2020
68ff5dc
Comments in forms.xml are now in the right place
lramati Dec 28, 2020
3593c7e
Zygarde will no longer overwrite Yveltal's stats
lramati Dec 28, 2020
d0fa8d1
New integers.xml with stats for Yveltal
lramati Dec 28, 2020
8b5e2a8
Move pokemon names CSV into project, omit pokemon without stats
lramati Dec 28, 2020
202e31d
Resources from new devMethods script
lramati Dec 28, 2020
aa3db9e
Fix OutOfBounds error in PokeInfoCalculator.populatePokemon
lramati Dec 28, 2020
db1560c
Forgot to shift index in candyname array
lramati Dec 28, 2020
c93fad5
devMethods style changes
lramati Dec 29, 2020
776a67f
Properly limit pokemon level limit below level 40
xZise Dec 25, 2020
a93741d
Restore selected Pokemon
xZise Dec 29, 2020
93726bd
Update IV prediction on inputting manually
xZise Dec 29, 2020
eba1046
Fix evolutionCandyCost resource by dropping old candyToEvolve field
lramati Dec 29, 2020
aa57281
Fix Gastrodon's devolutionNumber by checking all forms for parentId
lramati Dec 29, 2020
77d92d7
Hack in support for two OCR attempts at candy name
lramati Jan 16, 2021
17922ab
Some Null saftey
lramati Jan 16, 2021
4bf2f33
Disable pokespam because its super broken
lramati Jan 17, 2021
f323a37
Add logic for candy offsets to field scanner
lramati Jan 17, 2021
da77f23
handle edge case when scanning bad fields
lramati Jan 17, 2021
4f55d85
bump version
lramati Jan 17, 2021
98e475c
Workaround to get default form on multiform pokes
lramati Jan 17, 2021
8809e1f
Change strings files to recommend Caterpie for recalibration
lramati Jan 18, 2021
833b684
Bump targetSdk version because appstore says so
lramati Jan 19, 2021
291fd9a
Attempts were made to get targetsdk=29 to work
lramati Jan 19, 2021
4d01b73
Change output directory for APKs.
Jan 20, 2021
905151a
add .aab bundle files to gitignore
lramati Jan 21, 2021
cf98b5d
API version 29 compliance part 1
lramati Jan 21, 2021
9e27a2f
Merge pull request #1 from jimmywan/jw.change_output_dir
lramati Jan 25, 2021
71985cb
Revert "jw.change_output_dir"
lramati Jan 25, 2021
00390d3
Merge pull request #2 from lramati/revert-1-jw.change_output_dir
lramati Jan 25, 2021
8a09286
Don't "fix" deprecated code without testing
lramati Jan 25, 2021
1c57fed
Split pokefly launch across two intents
lramati Jan 25, 2021
da730fb
Bump version to 5.5.2
lramati Jan 25, 2021
6efe8d2
Launch Pokemon Go in screenshot mode too
lramati Jan 26, 2021
e28170a
service.startForeground has different args in v29+
lramati Jan 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Built application files
*.apk
*.aab
*.ap_

# Files for the ART/Dalvik VM
Expand Down Expand Up @@ -44,3 +45,6 @@ fabric.properties

# OS files
.DS_Store

# VS Code
.vscode
16 changes: 9 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
* Apply plugins and other Gradle scripts
*/
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
//apply plugin: 'io.fabric'
apply from: '../checkstyle/checkstyle.gradle'

/**
Expand Down Expand Up @@ -71,7 +71,7 @@ android {
* Android SDK and build-tools version
* Update (both Gradle and local SDK) whenever possible
*/
compileSdkVersion 28
compileSdkVersion 30

/**
* Build configurations for APK
Expand All @@ -81,9 +81,9 @@ android {
*/
defaultConfig {
minSdkVersion 19 /*Dont change this unless you know why*/
targetSdkVersion 28 /*Dont change this unless you know why*/
versionCode 66
versionName "5.4.5"
targetSdkVersion 29 /*Dont change this unless you know why*/
versionCode 69
versionName "5.5.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down Expand Up @@ -204,6 +204,10 @@ dependencies {
implementation 'com.android.support:palette-v7:27.1.1'
implementation project(':openCVLibrary330')

/* for devMethods.thirdparty.pokebattler, temporally set for All Builds */
// implementation 'org.json:json:20160810' //used to generate moveset list
implementation 'com.squareup.okhttp3:okhttp:3.7.0'//used to generate moveset list

/**
* Online Build Dependencies
*/
Expand All @@ -227,8 +231,6 @@ dependencies {
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
testImplementation 'org.json:json:20160810' //used to generate moveset list
testImplementation 'com.squareup.okhttp3:okhttp:3.7.0'//used to generate moveset list
}

/**
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@

<service
android:name=".Pokefly"
android:exported="true"/>
android:exported="true"
android:foregroundServiceType="mediaProjection"/>
<service
android:name=".updater.DownloadUpdateService"
android:exported="false"/>
Expand Down Expand Up @@ -79,4 +80,4 @@
android:theme="@style/AppTheme.NoActionBar.fullscreen"/>
</application>

</manifest>
</manifest>
3 changes: 2 additions & 1 deletion app/src/main/java/com/kamron/pogoiv/GoIVSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ public boolean isAutoUpdateEnabled() {
}

public boolean isPokeSpamEnabled() {
return prefs.getBoolean(POKESPAM_ENABLED, false);
//return prefs.getBoolean(POKESPAM_ENABLED, false);
return false; // Disabling PokeSpam because of Beyond Update
}

public boolean shouldAutoOpenExpandedAppraise() {
Expand Down
77 changes: 51 additions & 26 deletions app/src/main/java/com/kamron/pogoiv/Pokefly.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
Expand Down Expand Up @@ -63,6 +62,8 @@

import java.io.File;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
Expand All @@ -77,7 +78,9 @@ public class Pokefly extends Service {

public static final String ACTION_UPDATE_UI = "com.kamron.pogoiv.ACTION_UPDATE_UI";
private static final String ACTION_SEND_INFO = "com.kamron.pogoiv.ACTION_SEND_INFO";
public static final String ACTION_REQUEST_SCREEN_GRABBER = "com.kamron.pogoiv.ACTION_REQUEST_SCREEN_GRABBER";
private static final String ACTION_START = "com.kamron.pogoiv.ACTION_START";
private static final String ACTION_BEGIN = "com.kamron.pogoiv.ACTION_BEGIN";
public static final String ACTION_STOP = "com.kamron.pogoiv.ACTION_STOP";

private static final String KEY_TRAINER_LEVEL = "key_trainer_level";
Expand Down Expand Up @@ -198,14 +201,20 @@ public static Intent createStartIntent(@NonNull Context context, int trainerLeve
return intent;
}

public static Intent createBeginIntent(@NonNull Context context) {
Intent intent = new Intent(context, Pokefly.class);
intent.setAction(ACTION_BEGIN);
return intent;
}

public static Intent createNoInfoIntent() {
return new Intent(ACTION_SEND_INFO);
}

public static void populateInfoIntent(Intent intent, ScanData scanData, @NonNull Optional<String> filePath) {
intent.putExtra(KEY_SEND_INFO_NAME, scanData.getPokemonName());
intent.putExtra(KEY_SEND_INFO_TYPE, scanData.getPokemonType());
intent.putExtra(KEY_SEND_INFO_CANDY, scanData.getCandyName());
intent.putExtra(KEY_SEND_INFO_CANDY, scanData.getCandyNames().toArray());
intent.putExtra(KEY_SEND_INFO_GENDER, scanData.getPokemonGender());
intent.putExtra(KEY_SEND_INFO_HP, scanData.getPokemonHP());
intent.putExtra(KEY_SEND_INFO_CP, scanData.getPokemonCP());
Expand Down Expand Up @@ -304,34 +313,49 @@ public int onStartCommand(Intent intent, int flags, int startId) {
ivPreviewPrinter = new IVPreviewPrinter(this);
clipboardTokenHandler = new ClipboardTokenHandler(this);

if (ACTION_STOP.equals(intent.getAction())) {
if (android.os.Build.VERSION.SDK_INT >= 24) {
stopForeground(STOP_FOREGROUND_DETACH);
}
stopSelf();
goIVNotificationManager.showPausedNotification();
switch (intent.getAction()) {
case ACTION_STOP:
if (android.os.Build.VERSION.SDK_INT >= 24) {
stopForeground(STOP_FOREGROUND_DETACH);
}
stopSelf();
goIVNotificationManager.showPausedNotification();
break;
case ACTION_START:
GoIVSettings.reloadPreferences(this);
trainerLevel = intent.getIntExtra(KEY_TRAINER_LEVEL, Data.MINIMUM_TRAINER_LEVEL);

} else if (ACTION_START.equals(intent.getAction())) {
GoIVSettings.reloadPreferences(this);
trainerLevel = intent.getIntExtra(KEY_TRAINER_LEVEL, Data.MINIMUM_TRAINER_LEVEL);
setupDisplaySizeInfo();

setupDisplaySizeInfo();
createFlyingComponents();

createFlyingComponents();
goIVNotificationManager.showRunningNotification();

startedInManualScreenshotMode = GoIVSettings.getInstance(this).isManualScreenshotModeEnabled();
/* Assumes MainActivity initialized ScreenGrabber before starting this service. */
if (!startedInManualScreenshotMode) {
screen = ScreenGrabber.getInstance();
startedInManualScreenshotMode = GoIVSettings.getInstance(this).isManualScreenshotModeEnabled();
if (!startedInManualScreenshotMode) {
// Ask MainActivity to create a ScreenGrabber for us, and wait for it to finish
LocalBroadcastManager.getInstance(this)
.sendBroadcast(new Intent(ACTION_REQUEST_SCREEN_GRABBER));
} else {
appraisalManager = new AppraisalManager(null, this);
screenShotHelper = ScreenShotHelper.start(Pokefly.this);
}
break;
case ACTION_BEGIN:
try {
screen = ScreenGrabber.getInstance();
} catch (Exception e) {
// If for some reason MainActivity failed to make the ScreenGrabber, stop the service.
// In this case we delete the notification to pretend it was never there in the first place.
if (android.os.Build.VERSION.SDK_INT >= 24) {
stopForeground(STOP_FOREGROUND_REMOVE);
}
stopSelf();
}
appraisalManager = new AppraisalManager(screen, this);
screenWatcher = new ScreenWatcher(this, fractionManager, appraisalManager);
screenWatcher.watchScreen();

} else {
appraisalManager = new AppraisalManager(null, this);
screenShotHelper = ScreenShotHelper.start(Pokefly.this);
}
goIVNotificationManager.showRunningNotification();
break;
}
//We have intent data, it's possible this service will be killed and we would want to recreate it
//https://github.com/farkam135/GoIV/issues/477
Expand Down Expand Up @@ -475,7 +499,7 @@ private void createArcPointer() {
*/
public void setArcPointer(double pokeLevel) {

int index = Data.maxPokeLevelToIndex(pokeLevel);
int index = Data.levelToLevelIdx(pokeLevel);

//If the pokemon is overleveled (Raid catch or weather modifier the arc indicator will be stuck at max)
if (index >= Data.arcX.length) {
Expand Down Expand Up @@ -828,7 +852,8 @@ public void onReceive(Context context, Intent intent) {

String pokemonName = intent.getStringExtra(KEY_SEND_INFO_NAME);
String pokemonType = intent.getStringExtra(KEY_SEND_INFO_TYPE);
String candyName = intent.getStringExtra(KEY_SEND_INFO_CANDY);
List<String> candyNames = Arrays.asList(intent.getStringArrayExtra(KEY_SEND_INFO_CANDY));


@SuppressWarnings("unchecked") Optional<String> lScreenShotFile =
(Optional<String>) intent.getSerializableExtra(KEY_SEND_SCREENSHOT_FILE);
Expand Down Expand Up @@ -871,7 +896,7 @@ public void onReceive(Context context, Intent intent) {
new LevelRange(estimatedPokemonLevelMin, estimatedPokemonLevelMax),
pokemonName,
pokemonType,
candyName,
candyNames,
pokemonGender,
pokemonHP,
pokemonCP,
Expand Down
73 changes: 45 additions & 28 deletions app/src/main/java/com/kamron/pogoiv/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ public class MainActivity extends AppCompatActivity {
}
};

private final BroadcastReceiver screenGrabberInitializer = new BroadcastReceiver() {
@SuppressWarnings("checkstyle:EmptyCatchBlock")
@Override public void onReceive(Context context, Intent intent) {
initScreenGrabber();
}
};

private final BroadcastReceiver pokeflyStateChanged = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Expand Down Expand Up @@ -266,11 +273,22 @@ private void updateAppBar(Class<? extends Fragment> newSectionClass) {
private void initiateUserScreenSettings() {
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
rawDisplayMetrics = new DisplayMetrics();
//noinspection ConstantConditions
Display display = windowManager.getDefaultDisplay();
display.getRealMetrics(rawDisplayMetrics);
}

/**
* Initializes ScreenGrabber once Pokefly has been started
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void initScreenGrabber() {
// Request screen capture permissions, then, when ready, Pokefly will be started
MainFragment.updateLaunchButtonText(this, R.string.accept_screen_capture, null);
MediaProjectionManager projectionManager =
(MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
startActivityForResult(projectionManager.createScreenCaptureIntent(), SCREEN_CAPTURE_REQ_CODE);
}

/**
* Checks for any published updates if auto-updater settings is on and deletes previous updates.
*/
Expand Down Expand Up @@ -318,16 +336,11 @@ private void stopGoIV() {

@SuppressLint("NewApi")
private void startGoIV() {
startPokeFly();

boolean screenshotMode = GoIVSettings.getInstance(this).isManualScreenshotModeEnabled();
if (screenshotMode) {
startPokeFly();

} else { // Start screen capture then, when ready, Pokefly will be started
MainFragment.updateLaunchButtonText(this, R.string.accept_screen_capture, null);
MediaProjectionManager projectionManager =
(MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
//noinspection ConstantConditions
startActivityForResult(projectionManager.createScreenCaptureIntent(), SCREEN_CAPTURE_REQ_CODE);
startPoGoIfSettingOn();
}
}

Expand Down Expand Up @@ -382,11 +395,14 @@ protected void onResume() {
initRecalibrationAlertBadge();
LocalBroadcastManager.getInstance(this).registerReceiver(showUpdateDialog,
new IntentFilter(ACTION_SHOW_UPDATE_DIALOG));
LocalBroadcastManager.getInstance(this).registerReceiver(screenGrabberInitializer,
new IntentFilter(Pokefly.ACTION_REQUEST_SCREEN_GRABBER));
}

@Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(showUpdateDialog);
LocalBroadcastManager.getInstance(this).unregisterReceiver(screenGrabberInitializer);
super.onPause();
}

Expand All @@ -396,8 +412,6 @@ protected void onPause() {
private void startPokeFly() {
MainFragment.updateLaunchButtonText(this, R.string.main_starting, false);

startPoGoIfSettingOn();

Intent intent = Pokefly
.createStartIntent(this, GoIVSettings.getInstance(this).getLevel());
startService(intent);
Expand Down Expand Up @@ -430,24 +444,27 @@ public void onDestroy() {
@TargetApi(Build.VERSION_CODES.M)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
updateLaunchButtonText(false, null);
if (Settings.canDrawOverlays(this)) {
runStartButtonLogic(); // We have obtained the overlay permission: start GoIV!
}

} else if (requestCode == SCREEN_CAPTURE_REQ_CODE) {
if (resultCode == RESULT_OK) {
MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(
Context.MEDIA_PROJECTION_SERVICE);
//noinspection ConstantConditions
MediaProjection mProjection = projectionManager.getMediaProjection(resultCode, data);
screen = ScreenGrabber.init(mProjection, rawDisplayMetrics);

startPokeFly();
} else {
switch (requestCode) {
case OVERLAY_PERMISSION_REQ_CODE:
updateLaunchButtonText(false, null);
}
if (Settings.canDrawOverlays(this)) {
runStartButtonLogic(); // We have obtained the overlay permission: start GoIV!
}
break;
case SCREEN_CAPTURE_REQ_CODE:
if (resultCode == RESULT_OK) {
MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(
Context.MEDIA_PROJECTION_SERVICE);
MediaProjection mProjection = projectionManager.getMediaProjection(resultCode, data);
screen = ScreenGrabber.init(mProjection, rawDisplayMetrics);
startService(Pokefly.createBeginIntent(this));
} else {
updateLaunchButtonText(false, null);
}
// Launching Pokemon Go here might be a little slower, that right after starting Pokefly, but we need
// the MainActivity instance alive to answer the intent from Pokefly
startPoGoIfSettingOn();
break;
}
}

Expand Down
Loading