Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #911 from farkam135/ivButtonSuggestsCalibration
Browse files Browse the repository at this point in the history
Iv button suggests calibration
  • Loading branch information
nahojjjen authored Apr 27, 2018
2 parents 495419d + 5bd2dac commit 2b27739
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/kamron/pogoiv/Pokefly.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ public IBinder onBind(Intent intent) {
return null;
}

public ScreenWatcher getScreenWatcher() {
return screenWatcher;
}

public IVPopupButton getIvButton() {
return ivButton;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,13 @@ protected void onHandleIntent(Intent intent) {

mainThreadHandler.post(new Runnable() {
@Override public void run() {
if (pokefly != null && pokefly.getIvButton() != null) {
pokefly.getIvButton().setShown(false, false); // Hide IV button: it might interfere
if (pokefly != null
&& pokefly.getScreenWatcher() != null
&& pokefly.getIvButton() != null) {
// Hide IV button: it might interfere
pokefly.getIvButton().setShown(false, false);
// Cancel pending quick IV previews: they might get the IV button to show again
pokefly.getScreenWatcher().cancelPendingScreenScan();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kamron.pogoiv.pokeflycomponents;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PixelFormat;
Expand All @@ -14,11 +15,14 @@
import android.view.View;
import android.view.WindowManager;

import com.kamron.pogoiv.GoIVSettings;
import com.kamron.pogoiv.Pokefly;
import com.kamron.pogoiv.R;
import com.kamron.pogoiv.scanlogic.IVCombination;
import com.kamron.pogoiv.scanlogic.ScanResult;

import static com.kamron.pogoiv.pokeflycomponents.GoIVNotificationManager.ACTION_RECALIBRATE_SCANAREA;

/**
* Created by johan on 2017-07-06.
* <p>
Expand All @@ -30,6 +34,7 @@
public class IVPopupButton extends android.support.v7.widget.AppCompatButton {

private final Pokefly pokefly;
private boolean shouldRecalibrate = false;

public static final WindowManager.LayoutParams layoutParams;

Expand Down Expand Up @@ -101,6 +106,8 @@ private void resetButtonLook() {
* @param scanResult what data to base the look on.
*/
public void showQuickIVPreviewLook(@NonNull ScanResult scanResult) {
shouldRecalibrate = false;

IVCombination lowest = scanResult.getLowestIVCombination();
IVCombination highest = scanResult.getHighestIVCombination();

Expand Down Expand Up @@ -221,21 +228,32 @@ public void showError() {
int black = ResourcesCompat.getColor(getResources(), R.color.p_error, null);
setGradientColor(black, black);

setText("?");
GoIVSettings settings = GoIVSettings.getInstance(pokefly);
if (settings.hasManualScanCalibration() && settings.hasUpToDateManualScanCalibration()) {
setText("?");
} else {
shouldRecalibrate = true;
setText(R.string.button_recalibrate);
}
}

/**
* The class which defines what happens when the IVPopupButton is clicked.
*/
private class OnIVClick implements OnTouchListener {

@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
@Override public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
setVisibility(GONE);
pokefly.requestScan();
pokefly.setIVButtonClickedStates();
if (shouldRecalibrate) {
shouldRecalibrate = false;
pokefly.startService(new Intent(pokefly, GoIVNotificationManager.NotificationActionService.class)
.setAction(ACTION_RECALIBRATE_SCANAREA));
} else {
setVisibility(GONE);
pokefly.requestScan();
pokefly.setIVButtonClickedStates();
}
return true;
}
return false;
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<string name="token_max_length">Lunghezza massima:</string>
<string name="clipboard_token_list_available">Lista completa di tutti i tipi di token disponibili</string>
<string name="clipboard_token_description_title">Descrizione del token selezionato</string>
<string name="button_recalibrate">"Calibra GoIV"</string>
<string name="ocr_calibration_screenshot_mode">Il prossimo screenshot verrà usato per ricalibrare GoIV!</string>
<string name="ocr_calibration_result_description">Questo è il risultato della calibrazione automatica, ogni zona di interesse correttamente rilevata è stata sottolineata.</string>
<string name="ocr_calibration_save">Salva calibrazione</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<string name="token_max_length">Max length:</string>
<string name="clipboard_token_list_available">Full list of available token types</string>
<string name="clipboard_token_description_title">Selected token description</string>
<string name="button_recalibrate">"Calibrate GoIV"</string>
<string name="ocr_calibration_screenshot_mode">"The next screenshot taken will be used to recalibrate GoIV!"</string>
<string name="ocr_calibration_result_description">This is the result of the automatic calibration, each field of interest that was detected has been marked.</string>
<string name="ocr_calibration_save">Save calibration</string>
Expand Down

0 comments on commit 2b27739

Please sign in to comment.