Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35a53942 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

update controllers to start to work with progression. Start to load...

update controllers to start to work with progression. Start to load preparation process from config file
parent ea5f5db5
Loading
Loading
Loading
Loading
+85 −14
Original line number Diff line number Diff line
@@ -23,16 +23,15 @@ import ecorp.easy.installer.controllers.stepControllers.CustomExecutableControll
import ecorp.easy.installer.controllers.stepControllers.CustomStepController;
import ecorp.easy.installer.controllers.stepControllers.StepController;
import ecorp.easy.installer.controllers.stepControllers.Stoppable;
import ecorp.easy.installer.helpers.DeviceHelper;
import ecorp.easy.installer.models.Phone;
import ecorp.easy.installer.models.Progression;
import ecorp.easy.installer.models.StepTree;
import ecorp.easy.installer.models.steps.BasicStep;
import ecorp.easy.installer.models.steps.IStep;
import ecorp.easy.installer.tasks.CommandExecutionTask;
import ecorp.easy.installer.utils.UiUtils;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.text.ParseException;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.fxml.Initializable;
@@ -80,7 +79,7 @@ public class MainWindowController implements Initializable {
        logger.info("initialize()");
        this.i18n = rb;
        disableNextButton(false); //just for test
        loadSubScene();
        //loadSubScene();
        DoubleProperty fontSize = new SimpleDoubleProperty(0);
        
        fontSize.bind(root.widthProperty().add(root.heightProperty()).divide(123.2)); //72 = 1440 (default width): 20 (default font size). 51.2 = 1024 / 20        
@@ -90,16 +89,14 @@ public class MainWindowController implements Initializable {
        
        StepController.setParentController(this);
        
        //getDefaultPreparationProcess
        //TMP
        HashMap<String, IStep> preparationSteps = new HashMap<>();
        preparationSteps.put(Progression.PREPARATION_FIRST_STEP_KEY, new BasicStep("welcome", "p1", 0));
        preparationSteps.put("p1", new BasicStep("connectDevice", "p2", 1));
        preparationSteps.put("p2", new BasicStep("enableDevOption", "p3", 2));
        preparationSteps.put("p3", new BasicStep("enableUsbDebugging", "p4", 3));
        preparationSteps.put("p4", new BasicStep("deviceDetection", "p5", 4));
        preparationSteps.put("p5", new BasicStep("sourceDownload", "p6", 5));
        this.progression = new Progression(new StepTree(7, preparationSteps));
        try{
            this.progression = new Progression(DeviceHelper.loadStepTree("FP3", true) );            
        }catch(IOException | NullPointerException | NumberFormatException | ParseException e){
            logger.error(e.getClass().getSimpleName());
        }

        loadSubScenev2();
        
    }
    
@@ -116,7 +113,10 @@ public class MainWindowController implements Initializable {
    /**
     * Event happening when using click on "NextButton"
     */
    public void onNextBtnClick(){ loadSubScene(); }
    public void onNextBtnClick(){ 
        progression.updateProgressionBySuccess();
        loadSubScenev2();
    }
    
    /**
     * Define if nextButton is disable or not
@@ -167,8 +167,79 @@ public class MainWindowController implements Initializable {
        this.titleLabel.setText(i18n.getString(titleKey));
    }
    
    
    
    
    public void loadSubScenev2(){
        logger.info("loadSubScenev2("+currentSubRootId+")");
        
        StepController controller = null;
        String fxmlName = "";
        String title ="installationTitle";

        //@TODO change to include preparationprocess
        final IStep step = progression.getCurrentProcess().getSteps().get(progression.getCurrentStepKey());

        logger.debug("step : {} ", step.getType());
        switch(step.getType()){
            case "askAccount":
                fxmlName = "6-2-eAccount.fxml";
                break;
            case "enableOemUnlock":
                fxmlName = "6-3-unlockOEM.fxml";
                break;
            case "custom":
                controller = new CustomStepController();
                fxmlName ="customStep.fxml";
                break;
            case "custom-executable":
                controller = new CustomExecutableController();
                fxmlName ="customStep.fxml";
                break;
            case "executable":
                //no interface there
                break;
            case "load":
                fxmlName = "loadStep.fxml";
                break;
            case "welcome":
                fxmlName = "1-beforeYouBegin.fxml";
                title= "before_mTitle";
                break;
            case "connectDevice":
                fxmlName = "2-connectDevice.fxml";
                title = "connect_mTitle";
                break;
            case "deviceDetection":
                fxmlName = "4-deviceDetected.fxml";
                title = "detect_mTitle";
                break;
            case "downloadSources":
                fxmlName = "5-downloadSrc.fxml";
                title = "download_mTitle";
                break;
            default:
                //no interface there
                break;
        }


        if(!fxmlName.isBlank()) {
            if (currentSubRootId == null)
                currentSubRootId = loadSubUI(fxmlName, title, null).getId();
            else
                changeView(fxmlName, title, controller);
        }
        else
            logger.error("No interface to load!");
                    
    }
    
    
    
    /**
     * Load different group of controls depending of the current step (of whole process)
     * @deprecated 
     */
    public void loadSubScene(){
        logger.info("loadSubScene("+currentSubRootId+")");
+5 −3
Original line number Diff line number Diff line
@@ -42,9 +42,11 @@ public class CustomStepController extends StepController<ICustomStep>{
        new Locale.Builder()
       .setRegion("en")
       .setLanguage("EN")
       .setVariant(parentController.getPhone().getInternalCode())
       .setVariant("0008" /*parentController.getPhone().getInternalCode()*/) //@TODOneed to byPass that while we don't have this information
       .build());
    
    
    
    private int currentEmphasizedInstruction = 0; 
    private int instructionsCount;

@@ -77,7 +79,7 @@ public class CustomStepController extends StepController<ICustomStep>{
        instructionsCount = instructions.size();

        
        globalProgressMgr = new FlashGlobalProgressManager(parentController.getProgression().getFlashingProcess().getStepsCount());
        globalProgressMgr = new FlashGlobalProgressManager(parentController.getProgression().getCurrentProcess().getStepsCount());
        for(int i = 0;i < step.getStepNumber(); i++){
            globalProgressMgr.updateProgression();
        }
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ public class DeviceDetectionController extends StepController<BasicStep>{
                phone.setInternalCode(DeviceHelper.getDeviceInternalcode(phone.getAdbDevice()));

                try{
                    parentController.getProgression().setFlashingProcess(DeviceHelper.loadStepTree(phone.getAdbDevice()));
                    parentController.getProgression().setFlashingProcess(DeviceHelper.loadStepTree(phone.getAdbDevice(), false));
                    
                    
                    //@TODO: temporarily just replace "downloadStep" in Progression.preparationprocess
+2 −6
Original line number Diff line number Diff line
@@ -81,12 +81,8 @@ public class StepController<S extends IStep> implements Initializable{
     */
    protected void onStepEnd(){
        System.out.println("onStepEnd() load: "+step.getNextStepKey());
        parentController.getProgression().setCurrentStepKey(step.getNextStepKey());
        //@ToDo The below part would depend of the current process.
        if(step.getNextStepKey().equals(Progression.LAST_STEP_KEY)){
            parentController.getProgression().setFlashed();
        }
        parentController.loadSubScene();
        parentController.getProgression().updateProgressionBySuccess(); //not big fan of this method...
        parentController.loadSubScenev2();
        

        //Question is: Should I call this only if we are at the last step