Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

call Html.fromHtml on html strings before displaying them as titles #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# gradle
.gradle/
build/

# ExoPlayer
ExoPlayer/

# built application files
*.apk
*.ap_
Expand Down
25 changes: 5 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,10 @@ app's look and feel.

The Android SDK for API level 16 is require to build the app.

The White House app uses the following libraries, which are all
included as submodules in `contrib/`:
The White House app uses [ExoPlayer][], release [r1.3.3][]. You need to add the source of the
library into the root directory of wh-app-android yourself, and do

* [ActionBarSherlock][] - action bar for older versions of Android
* [ViewPagerIndicator][] - paging indicators widgets
* [Undergarment][] - slide-out view (side nav) support library

To initialize the submodules, run:

git submodule update --init

The following libraries are included as source:

* [Zepto.js][]
* [Underscore.js][]
git checkout r1.3.3

### Code Style

Expand Down Expand Up @@ -124,12 +113,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.




[ActionBarSherlock]: http://actionbarsherlock.com/
[ViewPagerIndicator]: https://github.com/JakeWharton/Android-ViewPagerIndicator
[Undergarment]: https://github.com/eddieringle/android-undergarment
[Underscore.js]: http://underscorejs.org/
[Zepto.js]: http://zeptojs.com/
[ExoPlayer]: https://github.com/google/ExoPlayer
[r1.3.3]: https://github.com/google/ExoPlayer/releases/tag/r1.3.3

[style]: http://source.android.com/source/code-style.html
[forking]: https://help.github.com/articles/fork-a-repo
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/gov/whitehouse/app/wh/LiveService.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ Notification buildLiveNotification(final FeedItem item)
.setCategory(NotificationCompat.CATEGORY_RECOMMENDATION)
.setContentIntent(
PendingIntent.getActivity(this, 0, liveIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.setContentTitle("Live @ " + time.format(item.pubDate()))
.setContentText(item.title())
.setDefaults(NotificationCompat.DEFAULT_SOUND)
.setContentTitle(String.format(
getString(R.string.live_notification_title), time.format(item.pubDate())))
.setContentText(item.displayTitle())
.setDefaults(NotificationCompat.DEFAULT_SOUND)
.setExtras(new Bundle())
.setSmallIcon(R.drawable.ic_stat_wh)
.setSound(notifSound)
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/gov/whitehouse/app/wh/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,11 @@ void updateLiveEvents()
} else {
mHasLiveEvents = true;
if (feedItems.size() == 1) {
mLiveBar.setText("Live: " + feedItems.get(0).title());
mLiveBar.setText(String.format(getString(R.string.live_bar_text_single),
feedItems.get(0).displayTitle()));
} else {
mLiveBar.setText(Integer.toString(feedItems.size()) + " New Events. Watch Live!");
mLiveBar.setText(String.format(getString(R.string.live_bar_text_multiple),
Integer.toString(feedItems.size())));
}
mLiveBar.setOnClickListener(v -> {
mDrawerLayoutCallbacks.clickLive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void onStart()
if (mMenu == null) {
onCreateToolbar(getToolbar());
}
mTitle.setText(mFeedItem.title());
mTitle.setText(mFeedItem.displayTitle());
mTitle.setTypeface(Typeface.SERIF);
mPicasso.load(mFeedItem.getBestThumbnailUrl(1080))
.error(R.drawable.error_thumbnail)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ void onCryptoError(MediaCodec.CryptoException e)

}

@Override
public void onDecoderInitialized(String decoderName, long elapsedRealtimeMs, long initializationDurationMs) {

}

@Override
public
void onPlayerStateChanged(boolean playWhenReady, int playbackState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void bindArticle(FeedItemData data, int position)
} else {
mTitle.setMinLines(1);
}
mTitle.setText(data.item.title());
mTitle.setText(data.item.displayTitle());
mTitle.setTypeface(Typeface.SERIF);
mMetaContainer.setVisibility(View.VISIBLE);
if (data.shouldShowDate) {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/fragment_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

<TextView
android:id="@+id/empty"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dip"
android:layout_marginEnd="16dip"
android:layout_gravity="center"
android:gravity="center"
android:visibility="gone"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<string name="title_favorites">Favorites</string>
<string name="title_settings">Settings</string>

<string name="live_bar_text_single">Live: %1$s</string>
<string name="live_bar_text_multiple">%1$s New Events. Watch Live!</string>
<string name="live_notification_title">Live @ %1$s</string>

<string name="dashboard_config_url">http://www.whitehouse.gov/sites/default/files/feeds/config.json</string>
<string name="live_feed_url">http://www.whitehouse.gov/feed/mobile/live</string>

Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ buildscript {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'me.tatarka:gradle-retrolambda:2.4.1'
classpath 'org.robolectric:robolectric-gradle-plugin:0.14.1'
// http://stackoverflow.com/a/29777213/665632
classpath 'com.novoda:bintray-release:0.2.7'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
6 changes: 6 additions & 0 deletions data/src/main/java/gov/whitehouse/data/model/FeedItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.net.Uri;
import android.os.Parcelable;
import android.os.SystemClock;
import android.text.Html;
import android.text.Spanned;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
Expand Down Expand Up @@ -56,6 +58,10 @@ class FeedItem implements Parcelable
public abstract String
videoLink();

public Spanned displayTitle() {
return Html.fromHtml(this.title());
}

public String
getBestThumbnailUrl(int idealWidth)
{
Expand Down