[New Designs] Implement add link flow#642
Conversation
…d add a `ViewModel` for state management
…ndroid into issues/2591
…dle-kotlin-upgrade
bassosimone
left a comment
There was a problem hiding this comment.
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! 🙏
| .build().show(getSupportFragmentManager(), null); | ||
| if (Intent.ACTION_VIEW.equals(intent.getAction())) { | ||
| Uri uri = intent.getData(); | ||
| if (uri == null) return; |
There was a problem hiding this comment.
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)); | ||
| } |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
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); | ||
| } |
…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>
bassosimone
left a comment
There was a problem hiding this comment.
We're getting there! 🙏
|
|
||
|
|
||
| private static Locale sLocale; | ||
| public static Locale sLocale; |
There was a problem hiding this comment.
Given how this class is structured, I would suggest adding a public getter here instead
| else -> false | ||
| } | ||
| } | ||
| binding.bottomBar.setOnMenuItemClickListener(bottomBarOnMenuItemClickListener) |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
If you want to stick with returning an integer pattern, this would probably be:
| if (runId == 0) { | |
| if (runId <= 0) { |
To exclude all the numbers that don't belong to the domain
bassosimone
left a comment
There was a problem hiding this comment.
LGTM with the understanding that you would apply the provided suggestions to avoid misleading the reader about the structure of OONI Run v2 links.
🙏 🐳
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 | |-|-| | | -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>
Fixes ooni/probe#2595
Proposed Changes
intent-filtertoMainActivityso v2 events are handled by it.descriptorfrom the backend and send toAddDescriptorActivityto be displayed.AddDescriptorActivitydoesn't lose state on configuration change.