Merge branch 'master' of github.com:gothfox/Tiny-Tiny-RSS-for-Honeycomb

This commit is contained in:
Andrew Dolgov 2012-06-19 18:00:38 +04:00
commit 82035f4003
43 changed files with 594 additions and 404 deletions

View File

@ -5,7 +5,7 @@
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="C:/Users/fox/workspace/org.fox.ttrss/libs/gson-1.7.1.jar"/> <classpathentry kind="lib" path="C:/Users/fox/workspace/org.fox.ttrss/libs/gson-1.7.1.jar"/>
<classpathentry kind="lib" path="C:/Users/fox/workspace/org.fox.ttrss/libs/jsoup-1.6.1.jar"/> <classpathentry kind="lib" path="C:/Users/fox/workspace/org.fox.ttrss/libs/jsoup-1.6.1.jar"/>
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss" package="org.fox.ttrss"
android:versionCode="72" android:versionCode="73"
android:versionName="0.5.7" > android:versionName="0.6.0" >
<uses-sdk android:minSdkVersion="8" /> <uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@ -13,7 +13,7 @@
<application <application
android:allowBackup="true" android:allowBackup="true"
android:backupAgent="PrefsBackupAgent" android:backupAgent=".util.PrefsBackupAgent"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
uiOptions="splitActionBarWhenNarrow" uiOptions="splitActionBarWhenNarrow"
android:icon="@drawable/icon" android:icon="@drawable/icon"
@ -24,7 +24,7 @@
</activity> </activity>
<activity <activity
android:label="@string/app_name" android:label="@string/app_name"
android:name=".OfflineActivity" > android:name=".offline.OfflineActivity" >
</activity> </activity>
<activity <activity
android:label="@string/app_name" android:label="@string/app_name"
@ -42,15 +42,15 @@
<service <service
android:enabled="true" android:enabled="true"
android:name=".OfflineDownloadService" /> android:name=".offline.OfflineDownloadService" />
<service <service
android:enabled="true" android:enabled="true"
android:name=".OfflineUploadService" /> android:name=".offline.OfflineUploadService" />
<service <service
android:enabled="true" android:enabled="true"
android:name=".ImageCacheService" /> android:name=".util.ImageCacheService" />
<service android:name="BillingService" /> <service android:name=".billing.BillingService" />
<meta-data <meta-data
android:name="com.google.android.backup.api_key" android:name="com.google.android.backup.api_key"

Binary file not shown.

View File

@ -8,4 +8,4 @@
# project structure. # project structure.
# Project target. # Project target.
target=android-14 target=android-15

View File

@ -1,8 +1,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main" android:id="@+id/main"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" > android:layout_height="fill_parent" >
<LinearLayout <LinearLayout
android:id="@+id/loading_container" android:id="@+id/loading_container"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -16,12 +16,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="@string/loading_message" /> android:text="@string/loading_message" />
<ProgressBar <ProgressBar
android:id="@+id/loading_progress" android:id="@+id/loading_progress"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout
@ -48,4 +47,4 @@
android:layout_height="match_parent" > android:layout_height="match_parent" >
</FrameLayout> </FrameLayout>
</FrameLayout> </LinearLayout>

View File

@ -15,17 +15,12 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider; import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.ClientContext; import org.apache.http.client.protocol.ClientContext;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpContext;
import org.fox.ttrss.util.EasySSLSocketFactory;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;

View File

@ -1,12 +1,13 @@
package org.fox.ttrss; package org.fox.ttrss;
import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.Attachment;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
@ -14,32 +15,27 @@ import org.jsoup.select.Elements;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
public class ArticleFragment extends Fragment { public class ArticleFragment extends Fragment {
@SuppressWarnings("unused") @SuppressWarnings("unused")

View File

@ -2,6 +2,8 @@ package org.fox.ttrss;
import java.util.ArrayList; import java.util.ArrayList;
import org.fox.ttrss.types.Article;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;

View File

@ -1,10 +1,12 @@
package org.fox.ttrss; package org.fox.ttrss;
import org.fox.ttrss.types.Article;
import org.fox.ttrss.util.FragmentStatePagerAdapter;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -55,7 +57,7 @@ public class ArticlePager extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.article_pager, container, false); View view = inflater.inflate(R.layout.article_pager, container, false);
m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager()); m_adapter = new PagerAdapter(getActivity().getFragmentManager());
ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager); ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager);
@ -94,7 +96,7 @@ public class ArticlePager extends Fragment {
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
m_hf = (HeadlinesFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.headlines_fragment); m_hf = (HeadlinesFragment) getActivity().getFragmentManager().findFragmentById(R.id.headlines_fragment);
m_onlineServices = (OnlineServices)activity; m_onlineServices = (OnlineServices)activity;
} }

View File

@ -1,7 +1,7 @@
package org.fox.ttrss; package org.fox.ttrss;
import android.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;

View File

@ -7,13 +7,15 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.fox.ttrss.types.FeedCategory;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater; import android.view.LayoutInflater;

View File

@ -2,6 +2,9 @@ package org.fox.ttrss;
import java.util.ArrayList; import java.util.ArrayList;
import org.fox.ttrss.types.Feed;
import org.fox.ttrss.types.FeedCategory;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;

View File

@ -2,6 +2,8 @@ package org.fox.ttrss;
import java.util.ArrayList; import java.util.ArrayList;
import org.fox.ttrss.types.Feed;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;

View File

@ -7,7 +7,6 @@ import java.io.InputStream;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@ -21,18 +20,16 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider; import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.ClientContext; import org.apache.http.client.protocol.ClientContext;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpContext;
import org.fox.ttrss.types.Feed;
import org.fox.ttrss.types.FeedCategory;
import org.fox.ttrss.util.EasySSLSocketFactory;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
@ -43,7 +40,6 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;

View File

@ -1,6 +1,5 @@
package org.fox.ttrss; package org.fox.ttrss;
import java.io.File;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@ -12,9 +11,13 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.Attachment;
import org.fox.ttrss.types.Feed;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -23,7 +26,6 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.text.Html; import android.text.Html;
import android.text.Html.ImageGetter; import android.text.Html.ImageGetter;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;

View File

@ -1,9 +0,0 @@
package org.fox.ttrss;
public class Label {
int id;
String caption;
String fg_color;
String bg_color;
boolean checked;
}

View File

@ -6,9 +6,24 @@ import java.util.List;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import org.fox.ttrss.billing.BillingHelper;
import org.fox.ttrss.billing.BillingService;
import org.fox.ttrss.offline.OfflineActivity;
import org.fox.ttrss.offline.OfflineDownloadService;
import org.fox.ttrss.offline.OfflineUploadService;
import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.Feed;
import org.fox.ttrss.types.FeedCategory;
import org.fox.ttrss.types.Label;
import org.fox.ttrss.util.AppRater;
import org.fox.ttrss.util.DatabaseHelper;
import android.animation.LayoutTransition; import android.animation.LayoutTransition;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -24,9 +39,6 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log; import android.util.Log;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -48,7 +60,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
public class MainActivity extends FragmentActivity implements OnlineServices { public class MainActivity extends Activity implements OnlineServices {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
private SharedPreferences m_prefs; private SharedPreferences m_prefs;
@ -63,7 +75,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
private boolean m_smallScreenMode; private boolean m_smallScreenMode;
private boolean m_unreadOnly = true; private boolean m_unreadOnly = true;
private boolean m_unreadArticlesOnly = true; private boolean m_unreadArticlesOnly = true;
private boolean m_compatMode = false;
private boolean m_enableCats = false; private boolean m_enableCats = false;
private int m_apiLevel = 0; private int m_apiLevel = 0;
private boolean m_isLoggingIn = false; private boolean m_isLoggingIn = false;
@ -133,7 +144,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
}; };
public void updateHeadlines() { public void updateHeadlines() {
HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment frag = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (frag != null) { if (frag != null) {
frag.notifyUpdated(); frag.notifyUpdated();
@ -351,7 +362,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
private synchronized void refreshFeeds() { private synchronized void refreshFeeds() {
if (m_sessionId != null) { if (m_sessionId != null) {
FeedsFragment frag = (FeedsFragment) getSupportFragmentManager() FeedsFragment frag = (FeedsFragment) getFragmentManager()
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
Log.d(TAG, "Refreshing feeds..."); Log.d(TAG, "Refreshing feeds...");
@ -364,7 +375,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
private synchronized void refreshHeadlines() { private synchronized void refreshHeadlines() {
if (m_sessionId != null) { if (m_sessionId != null) {
HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment frag = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
Log.d(TAG, "Refreshing headlines..."); Log.d(TAG, "Refreshing headlines...");
@ -377,7 +388,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
private synchronized void refreshCategories() { private synchronized void refreshCategories() {
if (m_sessionId != null) { if (m_sessionId != null) {
FeedCategoriesFragment frag = (FeedCategoriesFragment) getSupportFragmentManager() FeedCategoriesFragment frag = (FeedCategoriesFragment) getFragmentManager()
.findFragmentById(R.id.cats_fragment); .findFragmentById(R.id.cats_fragment);
Log.d(TAG, "Refreshing categories..."); Log.d(TAG, "Refreshing categories...");
@ -407,7 +418,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
* = unread; * = unread;
* *
* HeadlinesFragment frag = * HeadlinesFragment frag =
* (HeadlinesFragment)getSupportFragmentManager().findFragmentById * (HeadlinesFragment)getFragmentManager().findFragmentById
* (R.id.headlines_fragment); * (R.id.headlines_fragment);
* *
* if (frag != null) frag.refresh(false); } * if (frag != null) frag.refresh(false); }
@ -435,8 +446,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_prefs = PreferenceManager m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext()); .getDefaultSharedPreferences(getApplicationContext());
m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) { if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme); setTheme(R.style.DarkTheme);
} else { } else {
@ -463,7 +472,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_enableCats = m_prefs.getBoolean("enable_cats", false); m_enableCats = m_prefs.getBoolean("enable_cats", false);
m_smallScreenMode = m_compatMode || (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != m_smallScreenMode = (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) !=
Configuration.SCREENLAYOUT_SIZE_XLARGE; Configuration.SCREENLAYOUT_SIZE_XLARGE;
setContentView(R.layout.main); setContentView(R.layout.main);
@ -481,18 +490,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
Log.d(TAG, "m_isOffline=" + m_isOffline); Log.d(TAG, "m_isOffline=" + m_isOffline);
Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode); Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode);
Log.d(TAG, "m_compatMode=" + m_compatMode);
if (!m_compatMode) { LayoutTransition transitioner = new LayoutTransition();
if (android.os.Build.VERSION.SDK_INT < 14 || android.os.Build.VERSION.SDK_INT == 15) { ((ViewGroup) findViewById(R.id.main)).setLayoutTransition(transitioner);
if (!m_smallScreenMode) {
LayoutTransition transitioner = new LayoutTransition(); m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
((ViewGroup) findViewById(R.id.main)).setLayoutTransition(transitioner);
}
}
m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
}
if (m_isOffline) { if (m_isOffline) {
Intent offline = new Intent(MainActivity.this, Intent offline = new Intent(MainActivity.this,
@ -754,7 +756,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_activeCategory = null; m_activeCategory = null;
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager() FeedCategoriesFragment cf = (FeedCategoriesFragment) getFragmentManager()
.findFragmentById(R.id.cats_fragment); .findFragmentById(R.id.cats_fragment);
if (cf != null) { if (cf != null) {
@ -767,7 +769,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
} }
private void deselectAllArticles() { private void deselectAllArticles() {
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment hf = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (hf != null) { if (hf != null) {
@ -797,11 +799,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
findViewById(R.id.cats_fragment) findViewById(R.id.cats_fragment)
.setVisibility(View.VISIBLE); .setVisibility(View.VISIBLE);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.headlines_fragment, new HeadlinesFragment()); ft.replace(R.id.headlines_fragment, new HeadlinesFragment());
ft.commit(); ft.commit();
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager() FeedCategoriesFragment cf = (FeedCategoriesFragment) getFragmentManager()
.findFragmentById(R.id.cats_fragment); .findFragmentById(R.id.cats_fragment);
if (cf != null) { if (cf != null) {
@ -816,14 +818,14 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
findViewById(R.id.feeds_fragment).setVisibility( findViewById(R.id.feeds_fragment).setVisibility(
View.VISIBLE); View.VISIBLE);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.headlines_fragment, new HeadlinesFragment()); ft.replace(R.id.headlines_fragment, new HeadlinesFragment());
ft.commit(); ft.commit();
refreshFeeds(); refreshFeeds();
} }
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager() FeedsFragment ff = (FeedsFragment) getFragmentManager()
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
if (ff != null) { if (ff != null) {
@ -855,7 +857,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
findViewById(R.id.headlines_fragment).setVisibility( findViewById(R.id.headlines_fragment).setVisibility(
View.INVISIBLE); View.INVISIBLE);
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager() FeedsFragment ff = (FeedsFragment) getFragmentManager()
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
if (ff != null) { if (ff != null) {
@ -864,7 +866,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_activeFeed = null; m_activeFeed = null;
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.headlines_fragment, new HeadlinesFragment()); ft.replace(R.id.headlines_fragment, new HeadlinesFragment());
ft.commit(); ft.commit();
@ -880,7 +882,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
final HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() final HeadlinesFragment hf = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
switch (item.getItemId()) { switch (item.getItemId()) {
@ -925,44 +927,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
return true; return true;
case android.R.id.home: case android.R.id.home:
goBack(false); goBack(false);
return true;
case R.id.search:
if (hf != null && m_compatMode) {
Dialog dialog = new Dialog(this);
final EditText edit = new EditText(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.search)
.setPositiveButton(getString(R.string.search),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
String query = edit.getText().toString().trim();
hf.setSearchQuery(query);
}
})
.setNegativeButton(getString(R.string.cancel),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
//
}
}).setView(edit);
dialog = builder.create();
dialog.show();
}
return true; return true;
case R.id.preferences: case R.id.preferences:
Intent intent = new Intent(MainActivity.this, Intent intent = new Intent(MainActivity.this,
@ -1276,7 +1240,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_selectedArticle = null; m_selectedArticle = null;
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.article_fragment, new DummyFragment()); ft.replace(R.id.article_fragment, new DummyFragment());
ft.commit(); ft.commit();
@ -1303,7 +1267,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_menu.setGroupVisible(R.id.menu_group_logged_in, true); m_menu.setGroupVisible(R.id.menu_group_logged_in, true);
m_menu.setGroupVisible(R.id.menu_group_logged_out, false); m_menu.setGroupVisible(R.id.menu_group_logged_out, false);
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment hf = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
int numSelected = 0; int numSelected = 0;
@ -1312,12 +1276,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
numSelected = hf.getSelectedArticles().size(); numSelected = hf.getSelectedArticles().size();
if (numSelected != 0) { if (numSelected != 0) {
if (m_compatMode) { if (m_headlinesActionMode == null)
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true); m_headlinesActionMode = startActionMode(m_headlinesActionModeCallback);
} else {
if (m_headlinesActionMode == null)
m_headlinesActionMode = startActionMode(m_headlinesActionModeCallback);
}
} else if (m_selectedArticle != null) { } else if (m_selectedArticle != null) {
m_menu.setGroupVisible(R.id.menu_group_article, true); m_menu.setGroupVisible(R.id.menu_group_article, true);
@ -1328,40 +1288,38 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
search.setEnabled(m_apiLevel >= 2); search.setEnabled(m_apiLevel >= 2);
if (!m_compatMode) { SearchView searchView = (SearchView) search.getActionView();
SearchView searchView = (SearchView) search.getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { private String query = "";
private String query = "";
@Override
public boolean onQueryTextSubmit(String query) {
HeadlinesFragment frag = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment);
@Override if (frag != null) {
public boolean onQueryTextSubmit(String query) { frag.setSearchQuery(query);
HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager() this.query = query;
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText.equals("") && !newText.equals(this.query)) {
HeadlinesFragment frag = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (frag != null) { if (frag != null) {
frag.setSearchQuery(query); frag.setSearchQuery(newText);
this.query = query; this.query = newText;
} }
return false;
} }
@Override return false;
public boolean onQueryTextChange(String newText) { }
if (newText.equals("") && !newText.equals(this.query)) {
HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager()
.findFragmentById(R.id.headlines_fragment);
if (frag != null) {
frag.setSearchQuery(newText);
this.query = newText;
}
}
return false;
}
}); });
}
} else { } else {
m_menu.setGroupVisible(R.id.menu_group_feeds, true); m_menu.setGroupVisible(R.id.menu_group_feeds, true);
@ -1371,33 +1329,29 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
m_headlinesActionMode.finish(); m_headlinesActionMode.finish();
} }
if (!m_compatMode) { if (m_activeFeed != null) {
getActionBar().setTitle(m_activeFeed.title);
if (m_activeFeed != null) { } else if (m_activeCategory != null) {
getActionBar().setTitle(m_activeFeed.title); getActionBar().setTitle(m_activeCategory.title);
} else if (m_activeCategory != null) { } else {
getActionBar().setTitle(m_activeCategory.title); getActionBar().setTitle(R.string.app_name);
} else {
getActionBar().setTitle(R.string.app_name);
}
if (!m_smallScreenMode) {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null);
} else {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeFeed != null || m_activeCategory != null);
}
if (android.os.Build.VERSION.SDK_INT >= 14) {
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
if (m_selectedArticle != null) {
Log.d(TAG, "setting up share provider");
shareProvider.setShareIntent(getShareIntent(m_selectedArticle));
}
}
} }
if (!m_smallScreenMode) {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null);
} else {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeFeed != null || m_activeCategory != null);
}
if (android.os.Build.VERSION.SDK_INT >= 14) {
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
if (m_selectedArticle != null) {
Log.d(TAG, "setting up share provider");
shareProvider.setShareIntent(getShareIntent(m_selectedArticle));
}
}
m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1); m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1);
m_menu.findItem(R.id.donate).setVisible(BillingHelper.isBillingSupported()); m_menu.findItem(R.id.donate).setVisible(BillingHelper.isBillingSupported());
@ -1509,7 +1463,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (hasPendingOfflineData()) if (hasPendingOfflineData())
syncOfflineData(); syncOfflineData();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
if (m_enableCats) { if (m_enableCats) {
FeedCategoriesFragment frag = new FeedCategoriesFragment(); FeedCategoriesFragment frag = new FeedCategoriesFragment();
@ -1615,7 +1569,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (m_menu != null) { if (m_menu != null) {
MenuItem search = m_menu.findItem(R.id.search); MenuItem search = m_menu.findItem(R.id.search);
if (search != null && !m_compatMode) { if (search != null) {
SearchView sv = (SearchView) search.getActionView(); SearchView sv = (SearchView) search.getActionView();
sv.setQuery("", false); sv.setQuery("", false);
} }
@ -1623,12 +1577,12 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
HeadlinesFragment hf = new HeadlinesFragment(); HeadlinesFragment hf = new HeadlinesFragment();
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getFragmentManager()
.beginTransaction(); .beginTransaction();
ft.replace(R.id.headlines_fragment, hf); ft.replace(R.id.headlines_fragment, hf);
ft.commit(); ft.commit();
} else { } else {
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment hf = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (hf != null) { if (hf != null) {
hf.refresh(true); hf.refresh(true);
@ -1648,7 +1602,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
FeedsFragment frag = new FeedsFragment(); FeedsFragment frag = new FeedsFragment();
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getFragmentManager()
.beginTransaction(); .beginTransaction();
ft.replace(R.id.feeds_fragment, frag); ft.replace(R.id.feeds_fragment, frag);
ft.commit(); ft.commit();
@ -1663,7 +1617,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (m_menu != null) { if (m_menu != null) {
MenuItem search = m_menu.findItem(R.id.search); MenuItem search = m_menu.findItem(R.id.search);
if (search != null && !m_compatMode) { if (search != null) {
SearchView sv = (SearchView) search.getActionView(); SearchView sv = (SearchView) search.getActionView();
sv.setQuery("", false); sv.setQuery("", false);
} }
@ -1671,7 +1625,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
HeadlinesFragment frag = new HeadlinesFragment(); HeadlinesFragment frag = new HeadlinesFragment();
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getFragmentManager()
.beginTransaction(); .beginTransaction();
ft.replace(R.id.headlines_fragment, frag); ft.replace(R.id.headlines_fragment, frag);
ft.commit(); ft.commit();
@ -1691,7 +1645,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
initMainMenu(); initMainMenu();
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment hf = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (hf != null) { if (hf != null) {
@ -1715,7 +1669,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
frag = new ArticleFragment(article); frag = new ArticleFragment(article);
} }
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.article_fragment, frag); ft.replace(R.id.article_fragment, frag);
ft.commit(); ft.commit();
@ -1810,11 +1764,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo(); .getMenuInfo();
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment hf = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager() FeedsFragment ff = (FeedsFragment) getFragmentManager()
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager() FeedCategoriesFragment cf = (FeedCategoriesFragment) getFragmentManager()
.findFragmentById(R.id.cats_fragment); .findFragmentById(R.id.cats_fragment);
switch (item.getItemId()) { switch (item.getItemId()) {
@ -1972,7 +1926,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
@Override @Override
public Article getRelativeArticle(Article article, RelativeArticle ra) { public Article getRelativeArticle(Article article, RelativeArticle ra) {
HeadlinesFragment frag = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment frag = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (frag != null) { if (frag != null) {
ArticleList articles = frag.getAllArticles(); ArticleList articles = frag.getAllArticles();
@ -2006,7 +1960,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
switch (keyCode) { switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) { if (action == KeyEvent.ACTION_DOWN) {
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment hf = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (hf != null && m_activeFeed != null) { if (hf != null && m_activeFeed != null) {
@ -2033,7 +1987,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
return true; return true;
case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_UP) { if (action == KeyEvent.ACTION_UP) {
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager() HeadlinesFragment hf = (HeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (hf != null && m_activeFeed != null) { if (hf != null && m_activeFeed != null) {

View File

@ -1,5 +1,9 @@
package org.fox.ttrss; package org.fox.ttrss;
import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.Feed;
import org.fox.ttrss.types.FeedCategory;
public interface OnlineServices { public interface OnlineServices {
public enum RelativeArticle { BEFORE, AFTER }; public enum RelativeArticle { BEFORE, AFTER };

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.billing;
public class BillingConstants { public class BillingConstants {

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.billing;
import java.util.ArrayList; import java.util.ArrayList;
@ -12,8 +12,9 @@ import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import com.android.vending.billing.IMarketBillingService; import com.android.vending.billing.IMarketBillingService;
import org.fox.ttrss.BillingSecurity.VerifiedPurchase;
import org.fox.ttrss.BillingConstants.ResponseCode; import org.fox.ttrss.billing.BillingConstants.ResponseCode;
import org.fox.ttrss.billing.BillingSecurity.VerifiedPurchase;
public class BillingHelper { public class BillingHelper {
@ -34,7 +35,7 @@ public class BillingHelper {
mCompletedHandler = handler; mCompletedHandler = handler;
} }
protected static boolean isBillingSupported() { public static boolean isBillingSupported() {
if (amIDead()) { if (amIDead()) {
return false; return false;
} }
@ -67,7 +68,7 @@ public class BillingHelper {
* @param activityContext * @param activityContext
* @param itemId * @param itemId
*/ */
protected static void requestPurchase(Context activityContext, String itemId){ public static void requestPurchase(Context activityContext, String itemId){
if (amIDead()) { if (amIDead()) {
return; return;
} }

View File

@ -1,18 +1,18 @@
package org.fox.ttrss; package org.fox.ttrss.billing;
import static org.fox.ttrss.BillingConstants.*;
import java.util.ArrayList;
import static org.fox.ttrss.billing.BillingConstants.ACTION_NOTIFY;
import static org.fox.ttrss.billing.BillingConstants.ACTION_PURCHASE_STATE_CHANGED;
import static org.fox.ttrss.billing.BillingConstants.ACTION_RESPONSE_CODE;
import static org.fox.ttrss.billing.BillingConstants.INAPP_REQUEST_ID;
import static org.fox.ttrss.billing.BillingConstants.INAPP_RESPONSE_CODE;
import static org.fox.ttrss.billing.BillingConstants.INAPP_SIGNATURE;
import static org.fox.ttrss.billing.BillingConstants.INAPP_SIGNED_DATA;
import static org.fox.ttrss.billing.BillingConstants.NOTIFICATION_ID;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Message;
import android.util.Log; import android.util.Log;
import org.fox.ttrss.BillingConstants;
import org.fox.ttrss.BillingSecurity.VerifiedPurchase;
public class BillingReceiver extends BroadcastReceiver { public class BillingReceiver extends BroadcastReceiver {
private static final String TAG = "BillingService"; private static final String TAG = "BillingService";

View File

@ -1,6 +1,6 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
package org.fox.ttrss; package org.fox.ttrss.billing;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.KeyFactory; import java.security.KeyFactory;
@ -21,7 +21,7 @@ import org.json.JSONObject;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import org.fox.ttrss.BillingConstants.PurchaseState; import org.fox.ttrss.billing.BillingConstants.PurchaseState;
import org.fox.ttrss.util.Base64; import org.fox.ttrss.util.Base64;
import org.fox.ttrss.util.Base64DecoderException; import org.fox.ttrss.util.Base64DecoderException;

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.billing;
import android.app.Service; import android.app.Service;
import android.content.ComponentName; import android.content.ComponentName;

View File

@ -1,10 +1,25 @@
package org.fox.ttrss; package org.fox.ttrss.offline;
import org.fox.ttrss.DummyFragment;
import org.fox.ttrss.MainActivity;
import org.fox.ttrss.OnlineServices;
import org.fox.ttrss.PreferencesActivity;
import org.fox.ttrss.R;
import org.fox.ttrss.OnlineServices.RelativeArticle; import org.fox.ttrss.OnlineServices.RelativeArticle;
import org.fox.ttrss.R.anim;
import org.fox.ttrss.R.id;
import org.fox.ttrss.R.layout;
import org.fox.ttrss.R.menu;
import org.fox.ttrss.R.string;
import org.fox.ttrss.R.style;
import org.fox.ttrss.util.DatabaseHelper;
import android.animation.LayoutTransition; import android.animation.LayoutTransition;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -18,9 +33,6 @@ import android.database.sqlite.SQLiteStatement;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log; import android.util.Log;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -36,7 +48,7 @@ import android.widget.SearchView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
public class OfflineActivity extends FragmentActivity implements public class OfflineActivity extends Activity implements
OfflineServices { OfflineServices {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
@ -46,7 +58,6 @@ public class OfflineActivity extends FragmentActivity implements
private boolean m_smallScreenMode; private boolean m_smallScreenMode;
private boolean m_unreadOnly = true; private boolean m_unreadOnly = true;
private boolean m_unreadArticlesOnly = true; private boolean m_unreadArticlesOnly = true;
private boolean m_compatMode = false;
private boolean m_enableCats = false; private boolean m_enableCats = false;
private int m_activeFeedId = 0; private int m_activeFeedId = 0;
@ -99,8 +110,6 @@ public class OfflineActivity extends FragmentActivity implements
m_prefs = PreferenceManager m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext()); .getDefaultSharedPreferences(getApplicationContext());
m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) { if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme); setTheme(R.style.DarkTheme);
} else { } else {
@ -124,24 +133,21 @@ public class OfflineActivity extends FragmentActivity implements
m_enableCats = m_prefs.getBoolean("enable_cats", false); m_enableCats = m_prefs.getBoolean("enable_cats", false);
m_smallScreenMode = m_compatMode || (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != m_smallScreenMode = (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) !=
Configuration.SCREENLAYOUT_SIZE_XLARGE; Configuration.SCREENLAYOUT_SIZE_XLARGE;
setContentView(R.layout.main); setContentView(R.layout.main);
Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode); Log.d(TAG, "m_smallScreenMode=" + m_smallScreenMode);
Log.d(TAG, "m_compatMode=" + m_compatMode);
if (!m_compatMode) { if (android.os.Build.VERSION.SDK_INT < 14 /* || android.os.Build.VERSION.SDK_INT == 15 */) {
if (android.os.Build.VERSION.SDK_INT < 14 /* || android.os.Build.VERSION.SDK_INT == 15 */) { if (!m_smallScreenMode) {
if (!m_smallScreenMode) { LayoutTransition transitioner = new LayoutTransition();
LayoutTransition transitioner = new LayoutTransition(); ((ViewGroup) findViewById(R.id.main)).setLayoutTransition(transitioner);
((ViewGroup) findViewById(R.id.main)).setLayoutTransition(transitioner);
}
} }
m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
} }
m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
initMainMenu(); initMainMenu();
@ -190,7 +196,7 @@ public class OfflineActivity extends FragmentActivity implements
} }
if (m_activeFeedId == 0) { if (m_activeFeedId == 0) {
FragmentTransaction ft = getSupportFragmentManager() FragmentTransaction ft = getFragmentManager()
.beginTransaction(); .beginTransaction();
OfflineFeedsFragment frag = new OfflineFeedsFragment(); OfflineFeedsFragment frag = new OfflineFeedsFragment();
ft.replace(R.id.feeds_fragment, frag); ft.replace(R.id.feeds_fragment, frag);
@ -337,14 +343,14 @@ public class OfflineActivity extends FragmentActivity implements
// } // }
m_activeFeedId = 0; m_activeFeedId = 0;
OfflineFeedsFragment ff = (OfflineFeedsFragment) getSupportFragmentManager() OfflineFeedsFragment ff = (OfflineFeedsFragment) getFragmentManager()
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
if (ff != null) { if (ff != null) {
ff.setSelectedFeedId(0); ff.setSelectedFeedId(0);
} }
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.headlines_fragment, new OfflineHeadlinesFragment()); ft.replace(R.id.headlines_fragment, new OfflineHeadlinesFragment());
ft.commit(); ft.commit();
@ -361,14 +367,14 @@ public class OfflineActivity extends FragmentActivity implements
findViewById(R.id.headlines_fragment).setVisibility(View.INVISIBLE); findViewById(R.id.headlines_fragment).setVisibility(View.INVISIBLE);
m_activeFeedId = 0; m_activeFeedId = 0;
OfflineFeedsFragment ff = (OfflineFeedsFragment) getSupportFragmentManager() OfflineFeedsFragment ff = (OfflineFeedsFragment) getFragmentManager()
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
if (ff != null) { if (ff != null) {
ff.setSelectedFeedId(0); ff.setSelectedFeedId(0);
} }
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.headlines_fragment, new OfflineHeadlinesFragment()); ft.replace(R.id.headlines_fragment, new OfflineHeadlinesFragment());
ft.commit(); ft.commit();
@ -466,7 +472,7 @@ public class OfflineActivity extends FragmentActivity implements
} }
private void refreshHeadlines() { private void refreshHeadlines() {
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager() OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (ohf != null) { if (ohf != null) {
@ -476,50 +482,12 @@ public class OfflineActivity extends FragmentActivity implements
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
final OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager() final OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
goBack(false); goBack(false);
return true;
case R.id.search:
if (ohf != null && m_compatMode) {
Dialog dialog = new Dialog(this);
final EditText edit = new EditText(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.search)
.setPositiveButton(getString(R.string.search),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
String query = edit.getText().toString().trim();
ohf.setSearchQuery(query);
}
})
.setNegativeButton(getString(R.string.cancel),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
//
}
}).setView(edit);
dialog = builder.create();
dialog.show();
}
return true; return true;
case R.id.preferences: case R.id.preferences:
Intent intent = new Intent(this, PreferencesActivity.class); Intent intent = new Intent(this, PreferencesActivity.class);
@ -689,7 +657,7 @@ public class OfflineActivity extends FragmentActivity implements
} }
private void refreshFeeds() { private void refreshFeeds() {
OfflineFeedsFragment frag = (OfflineFeedsFragment) getSupportFragmentManager() OfflineFeedsFragment frag = (OfflineFeedsFragment) getFragmentManager()
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
if (frag != null) { if (frag != null) {
@ -717,7 +685,7 @@ public class OfflineActivity extends FragmentActivity implements
m_selectedArticleId = 0; m_selectedArticleId = 0;
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.article_fragment, new DummyFragment()); ft.replace(R.id.article_fragment, new DummyFragment());
ft.commit(); ft.commit();
@ -746,12 +714,8 @@ public class OfflineActivity extends FragmentActivity implements
m_menu.setGroupVisible(R.id.menu_group_article, false); m_menu.setGroupVisible(R.id.menu_group_article, false);
if (numSelected != 0) { if (numSelected != 0) {
if (m_compatMode) { if (m_headlinesActionMode == null)
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true); m_headlinesActionMode = startActionMode(m_headlinesActionModeCallback);
} else {
if (m_headlinesActionMode == null)
m_headlinesActionMode = startActionMode(m_headlinesActionModeCallback);
}
} else if (m_selectedArticleId != 0) { } else if (m_selectedArticleId != 0) {
m_menu.setGroupVisible(R.id.menu_group_article, true); m_menu.setGroupVisible(R.id.menu_group_article, true);
} else if (m_activeFeedId != 0) { } else if (m_activeFeedId != 0) {
@ -759,40 +723,38 @@ public class OfflineActivity extends FragmentActivity implements
MenuItem search = m_menu.findItem(R.id.search); MenuItem search = m_menu.findItem(R.id.search);
if (!m_compatMode) { SearchView searchView = (SearchView) search.getActionView();
SearchView searchView = (SearchView) search.getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { private String query = "";
private String query = "";
@Override
public boolean onQueryTextSubmit(String query) {
OfflineHeadlinesFragment frag = (OfflineHeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment);
@Override if (frag != null) {
public boolean onQueryTextSubmit(String query) { frag.setSearchQuery(query);
OfflineHeadlinesFragment frag = (OfflineHeadlinesFragment) getSupportFragmentManager() this.query = query;
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText.equals("") && !newText.equals(this.query)) {
OfflineHeadlinesFragment frag = (OfflineHeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (frag != null) { if (frag != null) {
frag.setSearchQuery(query); frag.setSearchQuery(newText);
this.query = query; this.query = newText;
} }
return false;
} }
@Override return false;
public boolean onQueryTextChange(String newText) { }
if (newText.equals("") && !newText.equals(this.query)) { });
OfflineHeadlinesFragment frag = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentById(R.id.headlines_fragment);
if (frag != null) {
frag.setSearchQuery(newText);
this.query = newText;
}
}
return false;
}
});
}
} else { } else {
m_menu.setGroupVisible(R.id.menu_group_feeds, true); m_menu.setGroupVisible(R.id.menu_group_feeds, true);
@ -802,23 +764,20 @@ public class OfflineActivity extends FragmentActivity implements
m_headlinesActionMode.finish(); m_headlinesActionMode.finish();
} }
if (!m_compatMode) { if (m_activeFeedId != 0) {
Cursor feed = getFeedById(m_activeFeedId);
if (m_activeFeedId != 0) { if (feed != null) {
Cursor feed = getFeedById(m_activeFeedId); getActionBar().setTitle(feed.getString(feed.getColumnIndex("title")));
if (feed != null) {
getActionBar().setTitle(feed.getString(feed.getColumnIndex("title")));
}
} else {
getActionBar().setTitle(R.string.app_name);
}
if (!m_smallScreenMode) {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0);
} else {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeFeedId != 0);
} }
} else {
getActionBar().setTitle(R.string.app_name);
}
if (!m_smallScreenMode) {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0);
} else {
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeFeedId != 0);
} }
} }
} }
@ -848,9 +807,9 @@ public class OfflineActivity extends FragmentActivity implements
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo(); .getMenuInfo();
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager() OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
OfflineFeedsFragment ff = (OfflineFeedsFragment) getSupportFragmentManager() OfflineFeedsFragment ff = (OfflineFeedsFragment) getFragmentManager()
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
switch (item.getItemId()) { switch (item.getItemId()) {
@ -1013,7 +972,7 @@ public class OfflineActivity extends FragmentActivity implements
case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) { if (action == KeyEvent.ACTION_DOWN) {
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager() OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
int nextId = getRelativeArticleId(m_selectedArticleId, int nextId = getRelativeArticleId(m_selectedArticleId,
@ -1042,7 +1001,7 @@ public class OfflineActivity extends FragmentActivity implements
case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_UP) { if (action == KeyEvent.ACTION_UP) {
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager() OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
int prevId = getRelativeArticleId(m_selectedArticleId, int prevId = getRelativeArticleId(m_selectedArticleId,
@ -1145,13 +1104,13 @@ public class OfflineActivity extends FragmentActivity implements
if (m_menu != null) { if (m_menu != null) {
MenuItem search = m_menu.findItem(R.id.search); MenuItem search = m_menu.findItem(R.id.search);
if (search != null && !m_compatMode) { if (search != null) {
SearchView sv = (SearchView) search.getActionView(); SearchView sv = (SearchView) search.getActionView();
sv.setQuery("", false); sv.setQuery("", false);
} }
} }
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
OfflineHeadlinesFragment frag = new OfflineHeadlinesFragment(); OfflineHeadlinesFragment frag = new OfflineHeadlinesFragment();
ft.replace(R.id.headlines_fragment, frag); ft.replace(R.id.headlines_fragment, frag);
ft.commit(); ft.commit();
@ -1164,7 +1123,7 @@ public class OfflineActivity extends FragmentActivity implements
initMainMenu(); initMainMenu();
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager() OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getFragmentManager()
.findFragmentById(R.id.headlines_fragment); .findFragmentById(R.id.headlines_fragment);
if (hf != null) { if (hf != null) {
@ -1187,7 +1146,7 @@ public class OfflineActivity extends FragmentActivity implements
frag = new OfflineArticleFragment(articleId); frag = new OfflineArticleFragment(articleId);
} }
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.article_fragment, frag); ft.replace(R.id.article_fragment, frag);
ft.commit(); ft.commit();

View File

@ -1,28 +1,34 @@
package org.fox.ttrss; package org.fox.ttrss.offline;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import org.fox.ttrss.R;
import org.fox.ttrss.R.attr;
import org.fox.ttrss.R.id;
import org.fox.ttrss.R.layout;
import org.fox.ttrss.R.menu;
import org.fox.ttrss.util.ImageCacheService;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.Cursor; import android.database.Cursor;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.TextView; import android.widget.TextView;

View File

@ -1,13 +1,16 @@
package org.fox.ttrss; package org.fox.ttrss.offline;
import org.fox.ttrss.R;
import org.fox.ttrss.R.id;
import org.fox.ttrss.R.layout;
import org.fox.ttrss.util.FragmentStatePagerAdapter;
import android.app.Activity; import android.app.Activity;
import android.database.Cursor; import android.app.Fragment;
import android.app.FragmentManager;
import android.database.sqlite.SQLiteStatement; import android.database.sqlite.SQLiteStatement;
import android.os.Bundle; import android.os.Bundle;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -58,7 +61,7 @@ public class OfflineArticlePager extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.article_pager, container, false); View view = inflater.inflate(R.layout.article_pager, container, false);
m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager()); m_adapter = new PagerAdapter(getActivity().getFragmentManager());
ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager); ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager);
@ -101,7 +104,7 @@ public class OfflineArticlePager extends Fragment {
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
m_hf = (OfflineHeadlinesFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.headlines_fragment); m_hf = (OfflineHeadlinesFragment) getActivity().getFragmentManager().findFragmentById(R.id.headlines_fragment);
m_offlineServices = (OfflineServices)activity; m_offlineServices = (OfflineServices)activity;
} }

View File

@ -1,9 +1,18 @@
package org.fox.ttrss; package org.fox.ttrss.offline;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.MainActivity;
import org.fox.ttrss.R;
import org.fox.ttrss.R.drawable;
import org.fox.ttrss.R.string;
import org.fox.ttrss.types.Article;
import org.fox.ttrss.types.Feed;
import org.fox.ttrss.util.DatabaseHelper;
import org.fox.ttrss.util.ImageCacheService;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;

View File

@ -1,8 +1,15 @@
package org.fox.ttrss; package org.fox.ttrss.offline;
import java.io.File; import java.io.File;
import org.fox.ttrss.R;
import org.fox.ttrss.R.drawable;
import org.fox.ttrss.R.id;
import org.fox.ttrss.R.layout;
import org.fox.ttrss.R.menu;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
@ -13,8 +20,6 @@ import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SimpleCursorAdapter;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
@ -26,6 +31,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView; import android.widget.TextView;
public class OfflineFeedsFragment extends Fragment implements OnItemClickListener, OnSharedPreferenceChangeListener { public class OfflineFeedsFragment extends Fragment implements OnItemClickListener, OnSharedPreferenceChangeListener {

View File

@ -1,13 +1,20 @@
package org.fox.ttrss; package org.fox.ttrss.offline;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.TimeZone; import java.util.TimeZone;
import org.fox.ttrss.R;
import org.fox.ttrss.R.drawable;
import org.fox.ttrss.R.id;
import org.fox.ttrss.R.layout;
import org.fox.ttrss.R.menu;
import org.fox.ttrss.R.string;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.Cursor; import android.database.Cursor;
@ -17,8 +24,6 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SimpleCursorAdapter;
import android.text.Html; import android.text.Html;
import android.text.Html.ImageGetter; import android.text.Html.ImageGetter;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
@ -35,6 +40,7 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView; import android.widget.TextView;
public class OfflineHeadlinesFragment extends Fragment implements OnItemClickListener { public class OfflineHeadlinesFragment extends Fragment implements OnItemClickListener {

View File

@ -1,4 +1,7 @@
package org.fox.ttrss; package org.fox.ttrss.offline;
import org.fox.ttrss.OnlineServices;
import org.fox.ttrss.OnlineServices.RelativeArticle;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;

View File

@ -1,7 +1,14 @@
package org.fox.ttrss; package org.fox.ttrss.offline;
import java.util.HashMap; import java.util.HashMap;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.MainActivity;
import org.fox.ttrss.R;
import org.fox.ttrss.R.drawable;
import org.fox.ttrss.R.string;
import org.fox.ttrss.util.DatabaseHelper;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import android.app.IntentService; import android.app.IntentService;

View File

@ -1,25 +1,26 @@
package org.fox.ttrss; package org.fox.ttrss.types;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
// TODO: serialize Labels // TODO: serialize Labels
public class Article implements Parcelable { public class Article implements Parcelable {
int id; public int id;
boolean unread; public boolean unread;
boolean marked; public boolean marked;
boolean published; public boolean published;
int updated; public int updated;
boolean is_updated; public boolean is_updated;
String title; public String title;
String link; public String link;
int feed_id; public int feed_id;
List<String> tags; public List<String> tags;
List<Attachment> attachments; public List<Attachment> attachments;
String content; public String content;
List<List<String>> labels; public List<List<String>> labels;
public Article(Parcel in) { public Article(Parcel in) {
readFromParcel(in); readFromParcel(in);

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.types;
import java.io.File; import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -8,12 +8,12 @@ import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
public class Attachment implements Parcelable { public class Attachment implements Parcelable {
int id; public int id;
String content_url; public String content_url;
String content_type; public String content_type;
String title; public String title;
String duration; public String duration;
int post_id; public int post_id;
public Attachment(Parcel in) { public Attachment(Parcel in) {
readFromParcel(in); readFromParcel(in);

View File

@ -1,18 +1,18 @@
package org.fox.ttrss; package org.fox.ttrss.types;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
public class Feed implements Comparable<Feed>, Parcelable { public class Feed implements Comparable<Feed>, Parcelable {
String feed_url; public String feed_url;
String title; public String title;
int id; public int id;
int unread; public int unread;
boolean has_icon; public boolean has_icon;
int cat_id; public int cat_id;
int last_updated; public int last_updated;
int order_id; public int order_id;
boolean is_cat; public boolean is_cat;
public Feed(int id, String title, boolean is_cat) { public Feed(int id, String title, boolean is_cat) {
this.id = id; this.id = id;

View File

@ -1,13 +1,13 @@
package org.fox.ttrss; package org.fox.ttrss.types;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
public class FeedCategory implements Parcelable { public class FeedCategory implements Parcelable {
int id; public int id;
String title; public String title;
int unread; public int unread;
int order_id; public int order_id;
public FeedCategory(Parcel in) { public FeedCategory(Parcel in) {
readFromParcel(in); readFromParcel(in);

View File

@ -0,0 +1,9 @@
package org.fox.ttrss.types;
public class Label {
public int id;
public String caption;
public String fg_color;
public String bg_color;
public boolean checked;
}

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.util;
// From http://androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appirater // From http://androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appirater

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.util;
import android.content.Context; import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.util;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;

View File

@ -1,5 +1,5 @@
package org.fox.ttrss; package org.fox.ttrss.util;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;

View File

@ -0,0 +1,226 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fox.ttrss.util;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
/**
* Implementation of {@link android.support.v4.view.PagerAdapter} that
* uses a {@link Fragment} to manage each page. This class also handles
* saving and restoring of fragment's state.
*
* <p>This version of the pager is more useful when there are a large number
* of pages, working more like a list view. When pages are not visible to
* the user, their entire fragment may be destroyed, only keeping the saved
* state of that fragment. This allows the pager to hold on to much less
* memory associated with each visited page as compared to
* {@link FragmentPagerAdapter} at the cost of potentially more overhead when
* switching between pages.
*
* <p>When using FragmentPagerAdapter the host ViewPager must have a
* valid ID set.</p>
*
* <p>Subclasses only need to implement {@link #getItem(int)}
* and {@link #getCount()} to have a working adapter.
*
* <p>Here is an example implementation of a pager containing fragments of
* lists:
*
* {@sample development/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStatePagerSupport.java
* complete}
*
* <p>The <code>R.layout.fragment_pager</code> resource of the top-level fragment is:
*
* {@sample development/samples/Support4Demos/res/layout/fragment_pager.xml
* complete}
*
* <p>The <code>R.layout.fragment_pager_list</code> resource containing each
* individual fragment's layout is:
*
* {@sample development/samples/Support4Demos/res/layout/fragment_pager_list.xml
* complete}
*/
public abstract class FragmentStatePagerAdapter extends PagerAdapter {
private static final String TAG = "FragmentStatePagerAdapter";
private static final boolean DEBUG = false;
private final FragmentManager mFragmentManager;
private FragmentTransaction mCurTransaction = null;
private ArrayList<Fragment.SavedState> mSavedState = new ArrayList<Fragment.SavedState>();
private ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
private Fragment mCurrentPrimaryItem = null;
public FragmentStatePagerAdapter(FragmentManager fm) {
mFragmentManager = fm;
}
/**
* Return the Fragment associated with a specified position.
*/
public abstract Fragment getItem(int position);
@Override
public void startUpdate(ViewGroup container) {
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
// If we already have this item instantiated, there is nothing
// to do. This can happen when we are restoring the entire pager
// from its saved state, where the fragment manager has already
// taken care of restoring the fragments we previously had instantiated.
if (mFragments.size() > position) {
Fragment f = mFragments.get(position);
if (f != null) {
return f;
}
}
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
}
Fragment fragment = getItem(position);
if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
if (mSavedState.size() > position) {
Fragment.SavedState fss = mSavedState.get(position);
if (fss != null) {
fragment.setInitialSavedState(fss);
}
}
while (mFragments.size() <= position) {
mFragments.add(null);
}
fragment.setMenuVisibility(false);
mFragments.set(position, fragment);
mCurTransaction.add(container.getId(), fragment);
return fragment;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
Fragment fragment = (Fragment)object;
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
}
if (DEBUG) Log.v(TAG, "Removing item #" + position + ": f=" + object
+ " v=" + ((Fragment)object).getView());
while (mSavedState.size() <= position) {
mSavedState.add(null);
}
mSavedState.set(position, mFragmentManager.saveFragmentInstanceState(fragment));
mFragments.set(position, null);
mCurTransaction.remove(fragment);
}
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
Fragment fragment = (Fragment)object;
if (fragment != mCurrentPrimaryItem) {
if (mCurrentPrimaryItem != null) {
fragment.setMenuVisibility(false);
}
if (fragment != null) {
fragment.setMenuVisibility(true);
}
mCurrentPrimaryItem = fragment;
}
}
@Override
public void finishUpdate(ViewGroup container) {
if (mCurTransaction != null) {
mCurTransaction.commitAllowingStateLoss();
mCurTransaction = null;
mFragmentManager.executePendingTransactions();
}
}
@Override
public boolean isViewFromObject(View view, Object object) {
return ((Fragment)object).getView() == view;
}
@Override
public Parcelable saveState() {
Bundle state = null;
if (mSavedState.size() > 0) {
state = new Bundle();
Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
mSavedState.toArray(fss);
state.putParcelableArray("states", fss);
}
for (int i=0; i<mFragments.size(); i++) {
Fragment f = mFragments.get(i);
if (f != null) {
if (state == null) {
state = new Bundle();
}
String key = "f" + i;
mFragmentManager.putFragment(state, key, f);
}
}
return state;
}
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle)state;
bundle.setClassLoader(loader);
Parcelable[] fss = bundle.getParcelableArray("states");
mSavedState.clear();
mFragments.clear();
if (fss != null) {
for (int i=0; i<fss.length; i++) {
mSavedState.add((Fragment.SavedState)fss[i]);
}
}
Iterable<String> keys = bundle.keySet();
for (String key: keys) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = mFragmentManager.getFragment(bundle, key);
if (f != null) {
while (mFragments.size() <= index) {
mFragments.add(null);
}
f.setMenuVisibility(false);
mFragments.set(index, f);
} else {
Log.w(TAG, "Bad fragment at key " + key);
}
}
}
}
}
}

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.util;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -10,6 +10,12 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Date; import java.util.Date;
import org.fox.ttrss.MainActivity;
import org.fox.ttrss.R;
import org.fox.ttrss.R.drawable;
import org.fox.ttrss.R.string;
import org.fox.ttrss.offline.OfflineDownloadService;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.IntentService; import android.app.IntentService;
import android.app.Notification; import android.app.Notification;
@ -53,7 +59,7 @@ public class ImageCacheService extends IntentService {
m_nmgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); m_nmgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
} }
protected static boolean isUrlCached(String url) { public static boolean isUrlCached(String url) {
String hashedUrl = md5(url); String hashedUrl = md5(url);
File storage = Environment.getExternalStorageDirectory(); File storage = Environment.getExternalStorageDirectory();
@ -63,7 +69,7 @@ public class ImageCacheService extends IntentService {
return file.exists(); return file.exists();
} }
protected static String getCacheFileName(String url) { public static String getCacheFileName(String url) {
String hashedUrl = md5(url); String hashedUrl = md5(url);
File storage = Environment.getExternalStorageDirectory(); File storage = Environment.getExternalStorageDirectory();
@ -73,7 +79,7 @@ public class ImageCacheService extends IntentService {
return file.getAbsolutePath(); return file.getAbsolutePath();
} }
protected static void cleanupCache(boolean deleteAll) { public static void cleanupCache(boolean deleteAll) {
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
File storage = Environment.getExternalStorageDirectory(); File storage = Environment.getExternalStorageDirectory();
File cachePath = new File(storage.getAbsolutePath() + CACHE_PATH); File cachePath = new File(storage.getAbsolutePath() + CACHE_PATH);

View File

@ -1,4 +1,4 @@
package org.fox.ttrss; package org.fox.ttrss.util;
import android.app.backup.BackupAgentHelper; import android.app.backup.BackupAgentHelper;
import android.app.backup.SharedPreferencesBackupHelper; import android.app.backup.SharedPreferencesBackupHelper;