forked from wordpress-mobile/WordPress-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/trunk' into merge/25.0-final-int…
…o-trunk
- Loading branch information
Showing
95 changed files
with
1,637 additions
and
757 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
jobs: | ||
dangermattic: | ||
if: ${{ (github.event.pull_request.draft == false) }} | ||
uses: Automattic/dangermattic/.github/workflows/[email protected].0 | ||
uses: Automattic/dangermattic/.github/workflows/[email protected].2 | ||
with: | ||
org-slug: "automattic" | ||
pipeline-slug: "wordpress-android" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,41 +16,8 @@ If you're a developer wanting to contribute, read on. | |
|
||
Notes: | ||
|
||
* To use WordPress.com features (login to WordPress.com, access Reader and Stats, etc) you need a WordPress.com OAuth2 ID and secret. Please read the [OAuth2 Authentication](#oauth2-authentication) section. | ||
* While loading/building the app in Android Studio ignore the prompt to update the gradle plugin version as that will probably introduce build errors. On the other hand, feel free to update if you are planning to work on ensuring the compatibility of the newer version. | ||
|
||
|
||
## OAuth2 Authentication ## | ||
|
||
In order to use WordPress.com functions you will need a client ID and | ||
a client secret key. These details will be used to authenticate your | ||
application and verify that the API calls being made are valid. You can | ||
create an application or view details for your existing applications with | ||
our [WordPress.com applications manager][5]. | ||
|
||
When creating your application, you should select "Native client" for the application type. | ||
The "**Website URL**", "**Redirect URLs**", and "**Javascript Origins**" fields are required but not used for | ||
the mobile apps. Just use "**[https://localhost](https://localhost)**". | ||
|
||
Once you've created your application in the [applications manager][5], you'll | ||
need to edit the `./gradle.properties` file and change the | ||
`wp.oauth.app_id` and `wp.oauth.app_secret` fields. Then you can compile and | ||
run the app on a device or an emulator and try to login with a WordPress.com | ||
account. Note that authenticating to WordPress.com via Google is not supported | ||
in development builds of the app, only in the official release. | ||
|
||
Note that credentials created with our [WordPress.com applications manager][5] | ||
allow login only and not signup. New accounts must be created using the [official app][1] | ||
or [on the web](https://wordpress.com/start). Login is restricted to the WordPress.com | ||
account with which the credentials were created. In other words, if the credentials | ||
were created with [email protected], you will only be able to login with [email protected]. | ||
Using another account like [email protected] will cause the `Client cannot use "password" grant_type` error. | ||
|
||
For security reasons, some account-related actions aren't supported for development | ||
builds when using a WordPress.com account with 2-factor authentication enabled. | ||
|
||
Read more about [OAuth2][6] and the [WordPress.com REST endpoint][7]. | ||
|
||
## Build and Test ## | ||
|
||
To build, install, and test the project from the command line: | ||
|
@@ -61,6 +28,13 @@ To build, install, and test the project from the command line: | |
$ ./gradlew :WordPress:testWordPressVanillaDebugUnitTest # assemble, install and run unit tests | ||
$ ./gradlew :WordPress:connectedWordPressVanillaDebugAndroidTest # assemble, install and run Android tests | ||
|
||
## Running the app ## | ||
|
||
You can use your own WordPress site for developing and testing the app. If you don't have one, you can create a temporary test site for free at https://jurassic.ninja/. | ||
On the app start up screen, choose "Enter your existing site address" and enter the URL of your site and your credentials. | ||
|
||
Note: Access to WordPress.com features is temporarily disabled in the development environment. | ||
|
||
## Directory structure ## | ||
. | ||
├── libs # dependencies used to build debug variants | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
WordPress/src/main/java/org/wordpress/android/datasets/AsyncTaskHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.wordpress.android.datasets | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.withContext | ||
|
||
/** | ||
* Helper class to handle async tasks by using coroutines | ||
* @see <a href="https://github.com/wordpress-mobile/WordPress-Android/pull/20937">Introduction</a> | ||
*/ | ||
object AsyncTaskHandler { | ||
/** | ||
* Load data in the background and handle the result on the main thread | ||
*/ | ||
@JvmStatic | ||
fun <T> load(backgroundTask: () -> T, callback: AsyncTaskCallback<T>) { | ||
CoroutineScope(Dispatchers.IO).launch { | ||
// handle the background task | ||
val result = backgroundTask() | ||
|
||
withContext(Dispatchers.Main) { | ||
// handle the result on the main thread | ||
callback.onTaskFinished(result) | ||
} | ||
} | ||
} | ||
|
||
interface AsyncTaskCallback<T> { | ||
fun onTaskFinished(result: T) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.