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

Add rs.wordpress.api:android dependency #21108

Merged
merged 12 commits into from
Sep 4, 2024
Merged
3 changes: 3 additions & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ repositories {
includeGroup "com.automattic"
includeGroup "com.automattic.tracks"
includeGroup "com.gravatar"
includeGroup "rs.wordpress.api"
}
}
maven {
Expand Down Expand Up @@ -521,6 +522,8 @@ dependencies {
implementation "com.google.dagger:hilt-android:$gradle.ext.daggerVersion"
ksp "com.google.dagger:hilt-compiler:$gradle.ext.daggerVersion"

implementation("rs.wordpress.api:android:$wordPressRsVersion")

testImplementation("androidx.arch.core:core-testing:$androidxArchCoreVersion", {
exclude group: 'com.android.support', module: 'support-compat'
exclude group: 'com.android.support', module: 'support-annotations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;

import androidx.annotation.NonNull;
Expand All @@ -20,6 +21,7 @@

import org.wordpress.android.R;
import org.wordpress.android.analytics.AnalyticsTracker;
import org.wordpress.android.analytics.AnalyticsTracker.Stat;
import org.wordpress.android.fluxc.model.SiteModel;
import org.wordpress.android.fluxc.network.MemorizingTrustManager;
import org.wordpress.android.fluxc.store.AccountStore.AuthEmailPayloadScheme;
Expand Down Expand Up @@ -652,6 +654,16 @@ public void gotXmlRpcEndpoint(String inputSiteAddress, String endpointAddress) {
LoginUsernamePasswordFragment loginUsernamePasswordFragment =
LoginUsernamePasswordFragment.newInstance(inputSiteAddress, endpointAddress, null, null, false);
slideInFragment(loginUsernamePasswordFragment, true, LoginUsernamePasswordFragment.TAG);

// In the background, run the API discovery test to see if we can add this site for the REST API
try {
String authorizationUrl = mViewModel.runApiDiscoveryTest(inputSiteAddress);
Log.d("WP_RS", "Found authorization URL: " + authorizationUrl);
AnalyticsTracker.track(Stat.BACKGROUND_REST_AUTODISCOVERY_SUCCESSFUL);
} catch (Exception ex) {
Log.e("WP_RS", "Unable to find authorization URL:" + ex.getMessage());
AnalyticsTracker.track(Stat.BACKGROUND_REST_AUTODISCOVERY_FAILED);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package org.wordpress.android.ui.accounts
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.runBlocking
import org.wordpress.android.fluxc.store.AccountStore.AuthEmailPayloadScheme
import org.wordpress.android.fluxc.store.SiteStore.ConnectSiteInfoPayload
import org.wordpress.android.ui.accounts.LoginNavigationEvents.ShowNoJetpackSites
import org.wordpress.android.ui.accounts.LoginNavigationEvents.ShowSiteAddressError
import org.wordpress.android.util.BuildConfigWrapper
import org.wordpress.android.viewmodel.Event
import rs.wordpress.api.kotlin.WpLoginClient
import javax.inject.Inject
import kotlin.text.RegexOption.IGNORE_CASE

Expand All @@ -31,4 +33,9 @@ class LoginViewModel @Inject constructor(private val buildConfigWrapper: BuildCo
} else {
AuthEmailPayloadScheme.WORDPRESS
}

fun runApiDiscoveryTest(input: String) = runBlocking {
val urlDiscovery = WpLoginClient().apiDiscovery(input)
urlDiscovery.getOrThrow().apiDetails.findApplicationPasswordsAuthenticationUrl()
}
}
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ext {
wordPressFluxCVersion = 'trunk-94d25d35fb4bf58a2e90741a6a5d56b8c6c3ce42'
wordPressLoginVersion = '1.16.0'
wordPressPersistentEditTextVersion = '1.0.2'
wordPressRsVersion = 'trunk-50f703a7f677084157d02f05d4d477d7eaf960b1'
wordPressUtilsVersion = '3.14.0'
indexosMediaForMobileVersion = '43a9026f0973a2f0a74fa813132f6a16f7499c3a'
gravatarVersion = '1.0.0'
Expand All @@ -43,7 +44,7 @@ ext {
androidxArchCoreVersion = '2.2.0'
androidxCameraVersion = '1.3.4'
androidxComposeBomVersion = '2024.08.00'
androidxComposeCompilerVersion = '1.5.9'
androidxComposeCompilerVersion = '1.5.14'
androidxComposeNavigationVersion = '2.7.7'
androidxCardviewVersion = '1.0.0'
androidxConstraintlayoutVersion = '2.1.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,9 @@ public enum Stat {
VOICE_TO_CONTENT_BUTTON_DONE_TAPPED,
VOICE_TO_CONTENT_BUTTON_UPGRADE_TAPPED,
VOICE_TO_CONTENT_BUTTON_CLOSE_TAPPED,
VOICE_TO_CONTENT_BUTTON_RECORDING_LIMIT_REACHED;

VOICE_TO_CONTENT_BUTTON_RECORDING_LIMIT_REACHED,
BACKGROUND_REST_AUTODISCOVERY_SUCCESSFUL,
BACKGROUND_REST_AUTODISCOVERY_FAILED;
/*
* Please set the event name in the enum only if the new Stat's name in lower case does not match it.
* In that case you also need to add the event in the `AnalyticsTrackerNosaraTest.specialNames` map.
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement {
gradle.ext.kotlinVersion = '1.9.22'
gradle.ext.kspVersion = '1.9.22-1.0.17'
gradle.ext.kotlinVersion = '1.9.24'
Copy link
Contributor

@nbradbury nbradbury Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to update the kotlinVersion and kspVersion in this PR? That seems like something that should be handled separately.

Likewise with androidxComposeCompilerVersion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was bumped to align with the https://github.com/automattic/wordpress-rs project,t which used very slightly newer versions

gradle.ext.kspVersion = '1.9.24-1.0.20'
gradle.ext.agpVersion = '8.5.1'
gradle.ext.googleServicesVersion = '4.3.15'
gradle.ext.navigationVersion = '2.7.7'
Expand Down
Loading