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

[New Designs] Implement add link flow #642

Merged
merged 65 commits into from
Feb 16, 2024
Merged

[New Designs] Implement add link flow #642

merged 65 commits into from
Feb 16, 2024

Conversation

aanorbel
Copy link
Member

@aanorbel aanorbel commented Dec 11, 2023

Fixes ooni/probe#2595

Proposed Changes

  • Add intent-filter to MainActivity so v2 events are handled by it.
  • Load descriptor from the backend and send to AddDescriptorActivity to be displayed.
    • Ensure AddDescriptorActivity doesn't lose state on configuration change.

@aanorbel aanorbel marked this pull request as ready for review December 19, 2023 11:27
Copy link
Contributor

@bassosimone bassosimone left a comment

Choose a reason for hiding this comment

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

For now, I mainly have change requests related to make the code more documented, clear, and easy to understand. Thank you for putting this branch together! 🙏

app/src/main/AndroidManifest.xml Show resolved Hide resolved
.build().show(getSupportFragmentManager(), null);
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
if (uri == null) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind not using this style where we collapse if and clause in a single line? I tend to prefer expanding it into N lines with { and } because it's more readable. (Kotlin has better facilities for being compact and they read easy, while I'd rather stick on scholastic Java for Java code, which risks being more tricky.)

runId = Long.parseLong(uri.getPathSegments().get(0));
} else if ("run.test.ooni.org".equals(host)) {
runId = Long.parseLong(uri.getPathSegments().get(1));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, add a comment here for the else case mentioning we handle it below

runId = Long.parseLong(uri.getPathSegments().get(1));
}
} catch (Exception e) {
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, add a comment mentioning we handle all errors below.

Also, do we want to document that this exception occurred using third-party services?

fun finishActivity() {
finishActivity.value = true
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should configure the kotlin editor to add an empty line at EOF.

String response = session.ooniRunFetch(ctx.ctx,id);
Log.d(PESession.class.getName(), response);
return new Gson().fromJson(response, OONIRunFetchResponse.class);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🎻

aanorbel and others added 5 commits December 20, 2023 08:05
…escriptor/AddDescriptorActivity.kt

Co-authored-by: Simone Basso <bassosimone@gmail.com>
…tils.java

Co-authored-by: Simone Basso <bassosimone@gmail.com>
…escriptor/AddDescriptorActivity.kt

Co-authored-by: Simone Basso <bassosimone@gmail.com>
…escriptor/AddDescriptorActivity.kt

Co-authored-by: Simone Basso <bassosimone@gmail.com>
@aanorbel aanorbel requested a review from bassosimone December 20, 2023 10:28
Copy link
Contributor

@bassosimone bassosimone left a comment

Choose a reason for hiding this comment

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

We're getting there! 🙏

@@ -9,8 +9,7 @@

public class LocaleUtils {


private static Locale sLocale;
public static Locale sLocale;
Copy link
Contributor

Choose a reason for hiding this comment

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

Given how this class is structured, I would suggest adding a public getter here instead

else -> false
}
}
binding.bottomBar.setOnMenuItemClickListener(bottomBarOnMenuItemClickListener)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe split this long block of code by adding blank lines and brief comments?

* Get the run id from the intent.
* The run id can be in two different formats.
* <p>
* 1. ooni://runv2/<link_id>
Copy link
Contributor

Choose a reason for hiding this comment

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

If javadoc is intepreting HTML tags, maybe <link_id> will be interpreted, can we check?

* @param uri The intent data.
* @return The run id if the intent contains a link with a valid `link_id`.
*/
private long getRunId(Uri uri) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we return an optional rather than using a sentinel value here? I think this would be a bit more robust and would clarify a bit more the possibility that a value is out of range.

long runId = getRunId(uri);

// If the intent contains a link, but the `link_id` is zero, or the link is not supported, do nothing.
if (runId == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to stick with returning an integer pattern, this would probably be:

Suggested change
if (runId == 0) {
if (runId <= 0) {

To exclude all the numbers that don't belong to the domain

Copy link
Contributor

@bassosimone bassosimone left a comment

Choose a reason for hiding this comment

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

LGTM with the understanding that you would apply the provided suggestions to avoid misleading the reader about the structure of OONI Run v2 links.

🙏 🐳

aanorbel and others added 7 commits December 22, 2023 11:38
Co-authored-by: Simone Basso <bassosimone@gmail.com>
## Proposed Changes

  - Add supported icons in project and track.
…#653)

Fixes # <issue>

## Proposed Changes

- Adds uninstall button
- Adds setting for auto-update
- Updates preferences to properly save autorun settings
…erent screen (#657)

## Proposed Changes

- Add `OoniRunV2Activity` to handle all incoming OONI Run v2 `Intents`
- Update `AndroidManifest.xml` to launch `OoniRunV2Activity` when OONI
Run v2 `Intents` are received.
  - Clean `MainActivity`
- Override `onBackPressed` and `finish` in `AddDescriptorActivity` to
ensure activity always launches `MainActivity` when closed


|.| Possible Areas of  Improvement |
|-|-|
|
![Screenshot_20240125_205311](https://github.com/ooni/probe-android/assets/17911892/595a9100-9fd6-4baf-b9d0-f0f024402fa7)|
-Improve on error messages. <br/> - Merge with `AddDescriptorActivity`
to make a single activity with 2 fragments for each of the views
(requires a bit of core rewrite). |

---------

Co-authored-by: Simone Basso <bassosimone@gmail.com>
@aanorbel aanorbel changed the base branch from dev/design-update to dev/ooni-run-v2 February 16, 2024 09:52
@aanorbel aanorbel merged commit c459e1c into dev/ooni-run-v2 Feb 16, 2024
4 of 6 checks passed
@aanorbel aanorbel deleted the issues/2595 branch February 16, 2024 09:53
@aanorbel aanorbel mentioned this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants