Search in sources :

Example 1 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project kotlin by JetBrains.

the class LintClient method getTargets.

/**
     * Returns all the {@link IAndroidTarget} versions installed in the user's SDK install
     * area.
     *
     * @return all the installed targets
     */
@NonNull
public IAndroidTarget[] getTargets() {
    if (mTargets == null) {
        AndroidSdkHandler sdkHandler = getSdk();
        if (sdkHandler != null) {
            ProgressIndicator logger = getRepositoryLogger();
            Collection<IAndroidTarget> targets = sdkHandler.getAndroidTargetManager(logger).getTargets(logger);
            mTargets = targets.toArray(new IAndroidTarget[targets.size()]);
        } else {
            mTargets = new IAndroidTarget[0];
        }
    }
    return mTargets;
}
Also used : ProgressIndicator(com.android.repository.api.ProgressIndicator) AndroidSdkHandler(com.android.sdklib.repositoryv2.AndroidSdkHandler) IAndroidTarget(com.android.sdklib.IAndroidTarget) NonNull(com.android.annotations.NonNull)

Example 2 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class UnresolvedDependenciesReporter method report.

private void report(@NotNull String dependency, @NotNull Module module, @Nullable VirtualFile buildFile) {
    String group = "Unresolved Android dependencies";
    GradleCoordinate coordinate = GradleCoordinate.parseCoordinateString(dependency);
    RepoPackage constraintPackage = null;
    if (coordinate != null) {
        ProgressIndicator indicator = new StudioLoggerProgressIndicator(getClass());
        reloadRemoteSdkWithModalProgress();
        Collection<RemotePackage> remotePackages = getRemotePackages(indicator);
        constraintPackage = findBestPackageMatching(coordinate, remotePackages);
    }
    List<NotificationHyperlink> quickFixes = new ArrayList<>();
    if (dependency.startsWith("com.android.support.constraint:constraint-layout:") && !canGetConstraintLayoutFromSdkManager(module)) {
        quickFixes.add(new FixAndroidGradlePluginVersionHyperlink());
    } else if (constraintPackage != null) {
        quickFixes.add(new InstallArtifactHyperlink(constraintPackage.getPath()));
    } else if (dependency.startsWith("com.android.support")) {
        quickFixes.add(new InstallRepositoryHyperlink(ANDROID));
    } else if (dependency.startsWith("com.google.android")) {
        quickFixes.add(new InstallRepositoryHyperlink(GOOGLE));
    } else {
        group = "Unresolved dependencies";
        Project project = module.getProject();
        if (isOfflineBuildModeEnabled(project)) {
            quickFixes.add(new DisableOfflineModeHyperlink());
        }
    }
    String text = "Failed to resolve: " + dependency;
    SyncMessage message;
    if (buildFile != null) {
        PositionInFile position = findDependencyPosition(dependency, buildFile);
        message = new SyncMessage(module.getProject(), group, ERROR, position, text);
        String hyperlinkText = position.line > -1 ? "Show in File" : "Open File";
        quickFixes.add(new OpenFileHyperlink(buildFile.getPath(), hyperlinkText, position.line, position.column));
    } else {
        message = new SyncMessage(group, ERROR, NonNavigatable.INSTANCE, text);
    }
    if (IdeInfo.getInstance().isAndroidStudio()) {
        if (coordinate != null) {
            quickFixes.add(new ShowDependencyInProjectStructureHyperlink(module, coordinate));
        }
    }
    message.add(quickFixes);
    getSyncMessages(module).report(message);
}
Also used : GradleCoordinate(com.android.ide.common.repository.GradleCoordinate) ArrayList(java.util.ArrayList) PositionInFile(com.android.tools.idea.gradle.util.PositionInFile) StringUtil.unquoteString(com.intellij.openapi.util.text.StringUtil.unquoteString) SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) Project(com.intellij.openapi.project.Project) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) RemotePackage(com.android.repository.api.RemotePackage) RepoPackage(com.android.repository.api.RepoPackage)

Example 3 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class FirstRunWizard method init.

@Override
public void init() {
    File initialSdkLocation = FirstRunWizardDefaults.getInitialSdkLocation(myMode);
    ConsolidatedProgressStep progressStep = new FirstRunProgressStep();
    myComponentsPath = new InstallComponentsPath(myMode, initialSdkLocation, progressStep, true);
    if (myMode == FirstRunWizardMode.NEW_INSTALL) {
        boolean sdkExists = false;
        if (initialSdkLocation.isDirectory()) {
            AndroidSdkHandler sdkHandler = AndroidSdkHandler.getInstance(initialSdkLocation);
            ProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
            sdkExists = ((AndroidSdkHandler) sdkHandler).getLocalPackage(SdkConstants.FD_TOOLS, progress) != null;
        }
        addPath(new SingleStepPath(new FirstRunWelcomeStep(sdkExists)));
    }
    if (myMode == FirstRunWizardMode.NEW_INSTALL) {
        if (initialSdkLocation.getPath().isEmpty()) {
            // We don't have a default path specified, have to do custom install.
            myState.put(KEY_CUSTOM_INSTALL, true);
        } else {
            addPath(new SingleStepPath(new InstallationTypeWizardStep(KEY_CUSTOM_INSTALL)));
        }
        addPath(new SingleStepPath(new SelectThemeStep(KEY_CUSTOM_INSTALL)));
    }
    if (myMode == FirstRunWizardMode.MISSING_SDK) {
        addPath(new SingleStepPath(new MissingSdkAlertStep()));
    }
    addPath(myComponentsPath);
    if (SystemInfo.isLinux && myMode == FirstRunWizardMode.NEW_INSTALL) {
        addPath(new SingleStepPath(new LinuxHaxmInfoStep()));
    }
    if (myMode != FirstRunWizardMode.INSTALL_HANDOFF) {
        addPath(new SingleStepPath(new LicenseAgreementStep(getDisposable())));
    }
    addPath(new SingleStepPath(progressStep));
    super.init();
}
Also used : SingleStepPath(com.android.tools.idea.wizard.dynamic.SingleStepPath) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) LicenseAgreementStep(com.android.tools.idea.sdk.wizard.legacy.LicenseAgreementStep) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) File(java.io.File)

Example 4 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class IdeSdks method isJdk7Supported.

public boolean isJdk7Supported(@Nullable AndroidSdkData sdkData) {
    if (sdkData != null) {
        ProgressIndicator progress = new StudioLoggerProgressIndicator(Jdks.class);
        LocalPackage info = sdkData.getSdkHandler().getLocalPackage(SdkConstants.FD_PLATFORM_TOOLS, progress);
        if (info != null) {
            Revision revision = info.getVersion();
            if (revision.getMajor() >= 19) {
                JavaSdk jdk = JavaSdk.getInstance();
                Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(jdk);
                if (sdk != null) {
                    JavaSdkVersion version = jdk.getVersion(sdk);
                    if (version != null && version.isAtLeast(JavaSdkVersion.JDK_1_7)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) LocalPackage(com.android.repository.api.LocalPackage) Revision(com.android.repository.Revision) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) SdkPaths.validateAndroidSdk(com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk)

Example 5 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class AvdWizardUtils method emulatorSupportsWebp.

@VisibleForTesting
static boolean emulatorSupportsWebp(@NotNull AndroidSdkHandler sdkHandler) {
    ProgressIndicator log = new StudioLoggerProgressIndicator(AvdWizardUtils.class);
    LocalPackage sdkPackage = sdkHandler.getLocalPackage(FD_EMULATOR, log);
    if (sdkPackage == null) {
        sdkPackage = sdkHandler.getLocalPackage(FD_TOOLS, log);
    }
    if (sdkPackage != null) {
        Revision version = sdkPackage.getVersion();
        // >= 25.2.3?
        if (version.getMajor() > 25 || version.getMajor() == 25 && (version.getMinor() > 2 || version.getMinor() == 2 && version.getMicro() >= 3)) {
            return true;
        }
    }
    return false;
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) LocalPackage(com.android.repository.api.LocalPackage) Revision(com.android.repository.Revision) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) VisibleForTesting(com.android.annotations.VisibleForTesting)

Aggregations

ProgressIndicator (com.android.repository.api.ProgressIndicator)10 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)7 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)4 LocalPackage (com.android.repository.api.LocalPackage)3 ArrayList (java.util.ArrayList)3 Revision (com.android.repository.Revision)2 RemotePackage (com.android.repository.api.RemotePackage)2 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)2 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)2 NotNull (org.jetbrains.annotations.NotNull)2 NonNull (com.android.annotations.NonNull)1 VisibleForTesting (com.android.annotations.VisibleForTesting)1 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)1 ProgressIndicatorAdapter (com.android.repository.api.ProgressIndicatorAdapter)1 RepoPackage (com.android.repository.api.RepoPackage)1 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)1 AndroidVersion (com.android.sdklib.AndroidVersion)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 AndroidSdkHandler (com.android.sdklib.repositoryv2.AndroidSdkHandler)1 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)1