CS 442 Assignment 5 – News Gateway solution

$29.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (2 votes)

Uses: Service, Broadcasts & Receivers, Drawer Layout, Fragments, ViewPager, Internet, APIs
App Highlights:
• This app displays current news articles from a wide variety of news sources covering a range of news
categories.
• NewsAPI.org will be used to acquire the news sources and news articles.
• Selecting a news source will display up to 10 top stories from that news source
• Selecting a news category will limit the news source choices to only those offering that category of news.
• News articles are viewed by swiping right to read the next article, and left to go back to the previous article
• You will not need to develop separate landscape layouts
• The user can go to the complete extended article on the news source’s website by clicking on the article
title, text, or image content.
• You must add a professional looking launcher icon to your app.
NO LATE SUBMISSIONS WILL BE ACCEPTED FOR THIS ASSIGNMENT
Application Architecture:
Broadcast Request
For News Article
Data
Broadcast
News Article Data
NewsAPI.org
Service
App/Activity
Receives Broadcast
Requests for News
Article Receives News
Articles
API GET
via
Runnable
JSON Data
Request List of News
Sources via Runnable
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 2 of 10
A) News Data:
Acquiring news source and news article data will be done via the NewsAPI.org news aggregation service. This service
allows you to download news sources (all or by news type/category) and news articles (by news source)
NOTE: You MUST sign up get an API key in order to access the NewsAPI.org services. Your API KEY must be
supplied with NewsAPI.org queries. You can do this by registering at:
https://newsapi.org/register
Register with a first name, an email address, a password, select “individual”, and agree to the terms and click
Submit to register and get your API key (the key is displayed to you right after you click the Submit button).
The API:
The NewsAPI.org service offers 2 API calls – one to get news sources (organizations offering news – CNN, Time,
etc.) and one to get top news articles from a selected news source.
1) News Sources Query Format (to be used in our assignment):
To get all sources:
https://newsapi.org/v2/sources?language=en&country=us&category=________&apiKey=________
NOTE, using an empty string for the category returns sources for all categories. (Do not use “all”, it will not
work.)
For example, if your category was “business” and your API Key was “ABC123xyz”, the URL would be:
https://newsapi.org/v2/sources?language=en&country=us&category= business &apiKey= ABC123xyz
2) News Article Query Format (to be used in our assignment):
https://newsapi.org/v2/top-headlines?sources=______&language=en&apiKey=______
For example, if your API Key was “ABC123xyz” and you wanted “cnn” news, the URL would be:
https://newsapi.org/v2/top-headlines?sources=cnn&language=en&apiKey=ABC123xyz
NOTE, be sure to use the source’s “id” and not the source’s string “name”.
NOTE: This API requires the “User-Agent” request property be provided with connection requests. The value
this property is set to does not matter, but it must be set (See example below):

connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(“GET”);
connection.addRequestProperty(“User-Agent”,””);

NO LATE SUBMISSIONS WILL BE ACCEPTED FOR THIS ASSIGNMENT
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 3 of 10
1) NewsAPI.org Sources Query Results Example:
https://newsapi.org/v2/sources?language=en&country=us&category=&apiKey= ABC123xyz
The above query will return results for all sources since the category is empty: category=
The results come in the form of a JSON Object that contains a JSON Array of source entries as shown below. Each
entry represents an individual news source. The highlighted fields below each define a source. Example:
{
“status”: “ok”,
“sources”: [{
“id”: “abc-news”,
“name”: “ABC News”,
“description”: “Your trusted source for breaking news, analysis, exclusive
interviews, headlines, and videos at ABCNews.com.”,
“url”: “https://abcnews.go.com”,
“category”: “general”,
“language”: “en”,
“country”: “us”
}, {
“id”: “al-jazeera-english”,
“name”: “Al Jazeera English”,
“description”: “News, analysis from the Middle East and worldwide, multimedia and
interactives, opinions, documentaries, podcasts, long reads and
broadcast schedule.”,
“url”: “http://www.aljazeera.com”,
“category”: “general”,
“language”: “en”,
“country”: “us”
}, {
“id”: “ars-technica”,
“name”: “Ars Technica”,
“description”: “The PC enthusiast’s resource. Power users and the tools they love,
without computing religion.”,
“url”: “http://arstechnica.com”,
“category”: “technology”,
“language”: “en”,
“country”: “us”
}, {
. . .
}]
}
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 4 of 10
2) NewsAPI.org Articles Query Results Example:
https://newsapi.org/v2/top-headlines?sources=cnn&language=en&apiKey=ABC123xyz
The results come in the form of a JSON Object that contains a JSON Array of article entries as shown below. Each
entry represents an individual news article. The highlighted fields below each define a story. Example:
{
“status”: “ok”,
“totalResults”: 10,
“articles”: [{
“source”: {
“id”: “cnn”,
“name”: “CNN”
},
“author”: “Maeve Reston and Stephen Collinson, CNN”,
“title”: “President-elect Joe Biden seeks to unite nation with victory speech”,
“description”: “President-elect Joe Biden speaks to a deeply divided nation Saturday
night, making a plea for unity after four years of turmoil and
conflict fomented by President Donald Trump.”,
“url”: “http://us.cnn.com/2020/11/07/politics/biden-victory-speech-2020-
election/index.html”,
“urlToImage”: “https://cdn.cnn.com/cnnnext/dam/assets/201107192144-biden-event-1107-
super-tease.jpg”,
“publishedAt”: “2020-11-08T01:18:14Z”,
“content”: “(CNN)President-elect Joe Biden will speak to a deeply divided nation
tonight, making a plea for unity and understanding after four years of
turmoil and conflict fomented by President Donald Trump, wh… [+8553
chars]”
}, {
“source”: {
“id”: “cnn”,
“name”: “CNN”
},
“author”: null,
“title”: “Presidential Election Results and Electoral Map 2020”,
“description”: “View maps and real-time presidential election results for the 2020 US
election. For more information, visit cnn.com/election.”,
“url”: “https://www.cnn.com/election/2020/results/president?iid=politics
_election_bop#mapmode=lead”,
“urlToImage”: “https://politics-static.cnn.io/2020/dev-static-assets/images/share/ge
/results/president.jpg”,
“publishedAt”: “2020-11-03T23:37:22.0160245Z”,
“content”: null
}, {
. . .
}]
}
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 5 of 10
B) Application Behavior Diagrams:
1) Overview
A News Source (i.e., “cnn”)
can be selected by opening
the “drawer” and selecting a
source
This drawer content is
dynamically created – NOT
hardcoded with values.
News sources will vary over
time.
A News category (i.e.,
“business”) can be selected
using the options menu.
This menu is dynamically
created – NOT hardcoded
with values. Category
values will vary over time.
A news-related background
image is shown before any
articles are loaded
The selected news source is
displayed in the Navigation Bar
News articles from the selected
source are displayed in a “view
pager” allowing left & rightswipe navigation between
articles.
Article count is maintained at
the bottom of the screen
News Article Headline (can be null/blank)
News Article Image (can be null/blank)
News Article Date (Provided in “Z” format)
News Article Author(s) (can be null/blank)
News Article Text (can be null/blank)
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 6 of 10
2) Selecting a news source (available sources will vary over time):
3) Swipe Right (or Left) to scroll through articles from the selected new source: Scroll
Swipe
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 7 of 10
4) Select a news category from the options menu to limit the news source choices to only those offering that
category of news.
5) Click on article content (title/image/text) to go to extended article on the news source web site
News sources list
with “technology”
category (the
sources will vary
over time)
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 8 of 10
C) Application Content:
ViewPager
NewsService ServiceReceiver
ServiceThread
News Source Request
News Story LIst
News Source
Downloader
NewsReceiver MainActivity
category
News Article
Downloader
Source Story LIst
Source LIst NewsFragment
NewsFragment
NewsFragment
NewsFragment
NewsFragment
NO LATE SUBMISSIONS WILL BE ACCEPTED FOR THIS ASSIGNMENT
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 9 of 10
D) Extra Credit (2 options, do none, do 1, or do both):
1) Up to 25 points of extra credit will be awarded if you save and restore the app state when
transitioning between portrait and landscape layouts to ensure a smooth user experience. Without
this, the app reverts to the start state upon rotation. If this is done properly, the current category
selection, the current source list (in the drawer), and the displayed articles will be maintained upon
device orientation change.
2) Up to 25 points of extra credit will be awarded if you display the news categories in the options menu
different colors, and then color the news sources in the drawer according to their category:
Options menu example: Drawer list of news sources: example
Assignment Assistance
The TAs for our course are available to assist you with your assignment if needed. Questions on assignment
requirements and course concepts can be sent to the instructor.
NO LATE SUBMISSIONS WILL BE ACCEPTED FOR THIS ASSIGNMENT
CS 442 Mobile Applications
Development (Android Section)
© Christopher Hield 10 of 10
Submissions & Grading
1) Submissions must consist of your zipped project folder (please execute Build =>Clean Project before
generating the zip file).
2) Submissions should reflect the concepts and practices we cover in class, and the requirements
specified in this document.
3) NO LATE SUBMISSIONS WILL BE ACCEPTED FOR THIS ASSIGNMENT
4) Grading will be based upon the presence and proper functionality of all features and behaviors
described in this document.
NOTE
This assignment is worth 450 points. This means (for example) that if you get 89% on this
assignment, your recorded score will be:
(89% * 450 points = 401 points)
If you do not understand anything in this handout, please ask.
Otherwise the assumption is that you understand the content.
Unsure? Ask!
NO LATE SUBMISSIONS WILL BE ACCEPTED FOR THIS ASSIGNMENT