-
Notifications
You must be signed in to change notification settings - Fork 46
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
Conversation
…d add a `ViewModel` for state management
…ndroid into issues/2591
…dle-kotlin-upgrade
There was a problem hiding this 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/java/org/openobservatory/ooniprobe/activity/MainActivity.java
Outdated
Show resolved
Hide resolved
.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.
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)); | ||
} |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 | ||
} | ||
} |
There was a problem hiding this comment.
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.
...nobservatory/ooniprobe/activity/add_descriptor/adapter/AddDescriptorExpandableListAdapter.kt
Outdated
Show resolved
Hide resolved
String response = session.ooniRunFetch(ctx.ctx,id); | ||
Log.d(PESession.class.getName(), response); | ||
return new Gson().fromJson(response, OONIRunFetchResponse.class); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎻
…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>
app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java
Outdated
Show resolved
Hide resolved
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.
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:
if (runId == 0) { | |
if (runId <= 0) { |
To exclude all the numbers that don't belong to the domain
There was a problem hiding this 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.
🙏 🐳
app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/openobservatory/ooniprobe/activity/MainActivity.java
Outdated
Show resolved
Hide resolved
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>
Fixes ooni/probe#2595
Proposed Changes
intent-filter
toMainActivity
so v2 events are handled by it.descriptor
from the backend and send toAddDescriptorActivity
to be displayed.AddDescriptorActivity
doesn't lose state on configuration change.