From 8c19ec257c8df6cc13a19e4df674423ec4644cc1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 25 Nov 2011 11:47:07 +0300 Subject: [PATCH] fix article timestamp in headlines displayed in UTC use custom back button handling to prevent backstack idiocy --- src/org/fox/ttrss/HeadlinesFragment.java | 3 ++- src/org/fox/ttrss/MainActivity.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 2055e6ae..36aa0b7b 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.TimeZone; import org.jsoup.Jsoup; @@ -26,7 +27,6 @@ import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.CompoundButton; -import android.widget.ToggleButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ImageView; import android.widget.ListView; @@ -339,6 +339,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener { if (dv != null) { Date d = new Date((long)article.updated * 1000); DateFormat df = new SimpleDateFormat("MMM dd, HH:mm"); + df.setTimeZone(TimeZone.getDefault()); dv.setText(df.format(d)); } diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index c7dd18c9..f689c851 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -11,6 +11,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; +import android.view.KeyEvent; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -175,6 +176,22 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect } } + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + Log.d(TAG, "Overriding back button"); + + if (m_selectedArticle != null) { + closeArticle(); + } else { + finish(); + } + + return false; + } + return super.onKeyDown(keyCode, event); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) {