Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions 5calls/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:scheme="https"
android:host="5calls.org"
android:pathPrefix="/issue/" />
</intent-filter>
</activity>
<activity android:name=".controller.IssueActivity"
android:launchMode="singleTop"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ public boolean hasContacts() {
return !mContacts.isEmpty();
}

public List<Issue> getAllIssues() {
return mAllIssues;
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class MainActivity extends AppCompatActivity implements IssuesAdapter.Cal
private static final String KEY_SHOW_LOW_ACCURACY_WARNING = "showLowAccuracyWarning";
private final AccountManager accountManager = AccountManager.Instance;

private String mPendingDeepLinkIssueId = null;

private ArrayAdapter<String> mFilterAdapter;
private String mFilterText = "";
private String mSearchText = "";
Expand Down Expand Up @@ -137,6 +139,8 @@ protected void onCreate(Bundle savedInstanceState) {
FiveCallsApplication.analyticsManager().trackPageview("/", this);
}

handleDeepLink(intent);

setContentView(binding.getRoot());

setSupportActionBar(binding.toolbar);
Expand Down Expand Up @@ -284,6 +288,13 @@ protected void onDestroy() {
super.onDestroy();
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
handleDeepLink(intent);
}

@Override
protected void onResume() {
super.onResume();
Expand Down Expand Up @@ -457,6 +468,7 @@ public void onIssuesReceived(List<Issue> issues) {
mIssuesAdapter.setAllIssues(issues, IssuesAdapter.NO_ERROR);
mIssuesAdapter.setFilterAndSearch(mFilterText, mSearchText);
binding.swipeContainer.setRefreshing(false);
handlePendingDeepLink();
}
};

Expand Down Expand Up @@ -754,4 +766,47 @@ public void onDismissed(Snackbar transientBottomBar, int event) {
}
});
}

private void handleDeepLink(Intent intent) {
if (intent == null || intent.getData() == null) {
return;
}

Uri data = intent.getData();
if (data.getHost() != null && data.getHost().equals("5calls.org")) {
List<String> pathSegments = data.getPathSegments();
if (pathSegments.size() >= 2 && pathSegments.get(0).equals("issue")) {
mPendingDeepLinkIssueId = pathSegments.get(1);
}
}
}

private void handlePendingDeepLink() {
if (mPendingDeepLinkIssueId == null) {
return;
}

String issueId = mPendingDeepLinkIssueId;
mPendingDeepLinkIssueId = null;

Issue targetIssue = null;
for (Issue issue : mIssuesAdapter.getAllIssues()) {
if (issue.id.equals(issueId)) {
targetIssue = issue;
break;
}
}

if (targetIssue != null) {
if (!targetIssue.active) {
hideSnackbars();
showSnackbar(R.string.issue_inactive, Snackbar.LENGTH_LONG);
} else {
startIssueActivity(this, targetIssue);
}
} else {
hideSnackbars();
showSnackbar(R.string.issue_not_found, Snackbar.LENGTH_LONG);
}
}
}
6 changes: 6 additions & 0 deletions 5calls/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@
<!-- Error message shown on the address text field when a user tries to submit an empty address [CHAR_LIMIT=50] -->
<string name="error_address_empty">Enter an address or zip code</string>

<!-- Error message shown when a deep link issue is not found [CHAR_LIMIT=150] -->
<string name="issue_not_found">This issue isn\'t relevant anymore</string>

<!-- Error message shown when a deep link issue is inactive [CHAR_LIMIT=150] -->
<string name="issue_inactive">This issue is no longer active</string>

<!-- Menu option to share your stats / impact [CHAR_LIMIT=50] -->
<string name="menu_share">Share</string>

Expand Down
Loading