Skip to content

Commit

Permalink
Add rs.wordpress.api:android dependency (#21108)
Browse files Browse the repository at this point in the history
* Add `rs.wordpress.api:android` dependency

* Test WordPressRs version 236-4c5b3cb5ff02fbf27877e5446a789144f86bc463

* Update WordPressRs version to trunk-28dac79a45c742da6daca6bbc93ac54aa3f2ec69

* Update Kotlin version to 1.9.24

* Update ksp version to 1.9.24-1.0.20

* Update androidxComposeCompilerVersion to 1.5.14

* Remove excluding JNA dependency from WordPressRs dependency

* Update WordPressRs version to trunk-dc3a5a5f79580935b483c031177bffa6ccd4d6d8

* Update WordPress.rs

* Perform autodiscovery in the background

This will help us understand if it’s working or not

---------

Co-authored-by: Jeremy Massel <[email protected]>
Co-authored-by: Nick Bradbury <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2024
1 parent a77d3cb commit 5712e94
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
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'
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

0 comments on commit 5712e94

Please sign in to comment.