Skip to content

Commit

Permalink
Merge pull request rapidpro#79 from rapidpro/privacy_policy
Browse files Browse the repository at this point in the history
Add privacy policy link
  • Loading branch information
rowanseymour authored Jan 13, 2023
2 parents 9003559 + b70cc6e commit 21c9c1e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.Instrumentation;
import android.content.Intent;
import android.view.MenuItem;

import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -179,12 +180,33 @@ public void loginIfStep2Successful() throws IOException, InterruptedException {
}

/**
* @see BaseActivity#sendBugReport()
* @see BaseActivity#onActionPrivacy(MenuItem) ()
* <p>
* tested here because we need a IntentsTestRule based test
*/
@Test
public void sendBugReport() throws IOException {
public void onActionPrivacy() throws IOException {
mockServerResponse(io.rapidpro.surveyor.test.R.raw.org_surveyor_get, "text/html", 200);

// mock the intent to pick an app to send the bug report too
intending(hasAction(Intent.ACTION_VIEW)).respondWith(new Instrumentation.ActivityResult(Activity.RESULT_OK, null));

rule.launchActivity(null);

openOptionsMenu();
onView(withText("Privacy")).perform(click());

// check intent was launched
intended(hasAction(Intent.ACTION_VIEW));
}

/**
* @see BaseActivity#onActionBugReport(MenuItem) ()
* <p>
* tested here because we need a IntentsTestRule based test
*/
@Test
public void onActionBugReport() throws IOException {
mockServerResponse(io.rapidpro.surveyor.test.R.raw.org_surveyor_get, "text/html", 200);

// mock the intent to pick an app to send the bug report too
Expand All @@ -193,8 +215,7 @@ public void sendBugReport() throws IOException {
rule.launchActivity(null);

openOptionsMenu();
onView(withText("Bug Report"))
.perform(click());
onView(withText("Bug Report")).perform(click());

// check intent was launched
intended(hasAction(Intent.ACTION_CHOOSER));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ public void onConfirm() {
}
}

/**
* User clicked "Privacy" menu option
*
* @param item the menu item
*/
public void onActionPrivacy(MenuItem item) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.privacy_url))));
}

/**
* User clicked "Bug Report" menu option
*
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
android:onClick="onActionLogout"
android:visible="false"
app:showAsAction="never" />
<item
android:id="@+id/action_privacy"
android:orderInCategory="1"
android:title="@string/action_privacy"
android:onClick="onActionPrivacy"
app:showAsAction="never" />
<item
android:id="@+id/action_bug_report"
android:orderInCategory="1"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<resources>
<string name="app_name">Surveyor</string>
<string name="support_email">[email protected]</string>
<string name="privacy_url">https://app.rapidpro.io/policy/</string>

<!-- activity titles -->
<string name="title_activity_login">Sign in</string>
Expand All @@ -17,6 +18,7 @@
<string name="action_settings">Settings</string>
<string name="action_logout">Logout</string>
<string name="action_refresh">Refresh</string>
<string name="action_privacy">Privacy</string>
<string name="action_bug_report">Bug Report</string>
<string name="action_save">Save</string>
<string name="action_discard">Discard</string>
Expand Down

0 comments on commit 21c9c1e

Please sign in to comment.