Skip to content

Commit

Permalink
Merge branch 'trunk' into feature/notifications_refresh_p2
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonis Lilis committed Jun 7, 2024
2 parents 5493500 + 11f13c8 commit 3f7e49f
Show file tree
Hide file tree
Showing 39 changed files with 431 additions and 353 deletions.
2 changes: 1 addition & 1 deletion .buildkite/beta-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#3.4.2

steps:
#################
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/code-freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#3.4.2

steps:
- label: "Code Freeze"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/complete-code-freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#3.4.2

steps:
- label: "Complete Code Freeze"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/finalize-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#3.4.2

steps:
- label: "Finalize release"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/new-beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#3.4.2

steps:
- label: "New Beta Release"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &ci_toolkit
automattic/a8c-ci-toolkit#2.18.2
automattic/a8c-ci-toolkit#3.4.2
- &test_collector
test-collector#v1.8.0
- &test_collector_common_params
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/release-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#3.4.2

steps:
#################
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/update-release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#3.4.2

steps:
- label: "Update release notes"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-danger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
dangermattic:
if: ${{ (github.event.pull_request.draft == false) }}
uses: Automattic/dangermattic/.github/workflows/reusable-retry-buildkite-step-on-events.yml@v1.1.0
uses: Automattic/dangermattic/.github/workflows/reusable-retry-buildkite-step-on-events.yml@v1.1.2
with:
org-slug: "automattic"
pipeline-slug: "wordpress-android"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
check-labels-on-issues:
uses: Automattic/dangermattic/.github/workflows/reusable-check-labels-on-issues.yml@v1.0.0
uses: Automattic/dangermattic/.github/workflows/reusable-check-labels-on-issues.yml@v1.1.2
with:
label-format-list: '[
"^\[.+\]",
Expand Down
20 changes: 11 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ GEM
no_proxy_fix
octokit (>= 4.0)
terminal-table (>= 1, < 4)
danger-dangermattic (1.0.2)
danger-dangermattic (1.1.1)
danger (~> 9.4)
danger-plugin-api (~> 1.0)
danger-rubocop (~> 0.12)
rubocop (~> 1.61)
danger-rubocop (~> 0.13)
rubocop (~> 1.63)
danger-plugin-api (1.0.0)
danger (> 2.0)
danger-rubocop (0.12.0)
danger-rubocop (0.13.0)
danger
rubocop (~> 1.0)
declarative (0.0.20)
Expand Down Expand Up @@ -259,30 +259,31 @@ GEM
optparse (0.4.0)
os (1.1.4)
parallel (1.24.0)
parser (3.3.1.0)
parser (3.3.2.0)
ast (~> 2.4.1)
racc
plist (3.7.1)
progress_bar (1.3.3)
highline (>= 1.6, < 3)
options (~> 2.3.0)
public_suffix (5.0.5)
racc (1.7.3)
racc (1.8.0)
rainbow (3.1.1)
rake (13.2.1)
rake-compiler (1.2.7)
rake
rchardet (1.8.0)
regexp_parser (2.9.1)
regexp_parser (2.9.2)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.6)
rexml (3.2.8)
strscan (>= 3.0.9)
rmagick (4.3.0)
rouge (2.0.7)
rubocop (1.63.5)
rubocop (1.64.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand Down Expand Up @@ -310,6 +311,7 @@ GEM
simctl (1.6.10)
CFPropertyList
naturally
strscan (3.1.0)
terminal-notifier (2.0.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
Expand Down
40 changes: 7 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 foo@email.com, you will only be able to login with foo@email.com.
Using another account like bar@email.com 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:
Expand All @@ -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
Expand Down
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)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ class ChooseSiteViewHolder(private val binding: ItemChooseSiteBinding) : Recycle
}

private fun handleAvatar(site: SiteRecord) {
imageManager.loadImageWithCorners(
binding.avatar, site.blavatarType, site.blavatarUrl,
itemView.context.resources.getDimensionPixelSize(R.dimen.blavatar_sz) / 2
)
imageManager.load(binding.avatar, site.blavatarType, site.blavatarUrl)
val isDarkTheme = itemView.resources.configuration.isDarkTheme()
val borderColor = ContextCompat.getColor(
itemView.context,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui.media.services;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.wordpress.android.fluxc.model.PostModel;
Expand All @@ -14,7 +15,7 @@ public interface MediaUploadReadyListener {
// TODO: We're passing a SiteModel parameter here in order to debug a crash on SaveStoryGutenbergBlockUseCase.
// Once that's done, the parameter should be replaced with a site url String, like it was before.
// See: https://git.io/JqfhK
PostModel replaceMediaFileWithUrlInPost(@Nullable PostModel post, String localMediaId, MediaFile mediaFile,
PostModel replaceMediaFileWithUrlInPost(@Nullable PostModel post, @NonNull String localMediaId, MediaFile mediaFile,
@Nullable SiteModel site);
PostModel markMediaUploadFailedInPost(@Nullable PostModel post, String localMediaId, MediaFile mediaFile);
}
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ public static boolean shouldShowGutenbergEditor(boolean isNewPost, String postCo
}

public static String replaceMediaFileWithUrlInGutenbergPost(@NonNull String postContent,
String localMediaId, MediaFile mediaFile, String siteUrl) {
@NonNull String localMediaId, MediaFile mediaFile,
String siteUrl) {
if (mediaFile != null && contentContainsGutenbergBlocks(postContent)) {
MediaUploadCompletionProcessor processor = new MediaUploadCompletionProcessor(localMediaId, mediaFile,
siteUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import com.google.gson.JsonObject
import org.jsoup.nodes.Document
import org.wordpress.android.util.helpers.MediaFile

class AudioBlockProcessor(localId: String?, mediaFile: MediaFile?) : BlockProcessor(localId, mediaFile) {
class AudioBlockProcessor(localId: String, mediaFile: MediaFile) : BlockProcessor(localId, mediaFile) {
override fun processBlockContentDocument(document: Document?): Boolean {
val audioElements = document?.select(AUDIO_TAG)

audioElements?.let { elements ->
for (element in elements) {
// replaces the src attribute's local url with the remote counterpart.
element.attr(SRC_ATTRIBUTE, mRemoteUrl)
element.attr(SRC_ATTRIBUTE, remoteUrl)
}
return true
}
Expand All @@ -21,9 +21,9 @@ class AudioBlockProcessor(localId: String?, mediaFile: MediaFile?) : BlockProces
override fun processBlockJsonAttributes(jsonAttributes: JsonObject?): Boolean {
val id = jsonAttributes?.get(ID_ATTRIBUTE)

return if (id != null && !id.isJsonNull && id.asString == mLocalId) {
return if (id != null && !id.isJsonNull && id.asString == localId) {
jsonAttributes.apply {
addIntPropertySafely(this, ID_ATTRIBUTE, mRemoteId)
addIntPropertySafely(this, ID_ATTRIBUTE, remoteId)
}
true
} else {
Expand Down
Loading

0 comments on commit 3f7e49f

Please sign in to comment.