#
# Copyright (C) 2019-Present A-Team Digital Solutions
#

from .actions import (
    build_command,
    sync_command,
    gapps_sync_command,
)
from .project_loader import load_project
from builder.actions import clean_command

class ButtonActions:
    def __init__(self, terminal, notebook):
        self.terminal = terminal
        self.notebook = notebook
    def load_project(self, rom_path, device):
        if not rom_path:
            return None
        if not device:
            return None
        return load_project(
            rom_path,
            device
        )
    def sync(self, project):
        if not project:
            return
        cmd = sync_command(project)
        self.notebook.set_current_page(4)
        self.terminal.run_project(project, cmd)
    def gapps_sync(self, project):
        if not project:
            return
        cmd = gapps_sync_command(
            project
        )
        self.notebook.set_current_page(4)
        self.terminal.run_project(project, cmd)
    def build(
        self,
        project,
        android_version,
        build_jobs,
        use_ccache
    ):
        if not project:
            return
        cmd = build_command(
            project,
            android_version,
            build_jobs,
            use_ccache
        )
        self.notebook.set_current_page(4)
        self.terminal.run_project(project, cmd)
    def clean(self, project):
        if not project:
            return
        cmd = clean_command(project)
        self.notebook.set_current_page(4)
        self.terminal.run_project(project, cmd)
