chrome tabs: preload stuff on wifi
This commit is contained in:
parent
acea00ebd7
commit
ac590d08ed
@ -3,6 +3,7 @@ package org.fox.ttrss;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.BadParcelableException;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
@ -121,7 +122,7 @@ public class ArticlePager extends Fragment {
|
||||
article.unread = false;
|
||||
m_activity.saveArticleUnread(article);
|
||||
} */
|
||||
|
||||
|
||||
m_listener.onArticleSelected(article, false);
|
||||
|
||||
//Log.d(TAG, "Page #" + position + "/" + m_adapter.getCount());
|
||||
|
@ -6,11 +6,14 @@ import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
@ -218,6 +221,22 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
|
||||
});
|
||||
}
|
||||
|
||||
protected void preloadUriIfAllowed(Uri uri) {
|
||||
boolean enableCustomTabs = m_prefs.getBoolean("enable_custom_tabs", true);
|
||||
|
||||
if (m_customTabClient != null && enableCustomTabs) {
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo info = cm.getActiveNetworkInfo();
|
||||
|
||||
if (info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI) {
|
||||
CustomTabsSession session = getCustomTabSession();
|
||||
session.mayLaunchUrl(uri, null, null);
|
||||
|
||||
//toast("Preloading: " + uri.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openUriWithCustomTab(Uri uri) {
|
||||
if (m_customTabClient != null) {
|
||||
TypedValue tvBackground = new TypedValue();
|
||||
|
@ -5,6 +5,7 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
@ -18,6 +19,8 @@ import org.fox.ttrss.types.Article;
|
||||
import org.fox.ttrss.types.ArticleList;
|
||||
import org.fox.ttrss.types.Feed;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class DetailActivity extends OnlineActivity implements HeadlinesEventListener {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
protected ArticleList m_articles = new ArticleList();
|
||||
@ -218,7 +221,13 @@ public class DetailActivity extends OnlineActivity implements HeadlinesEventList
|
||||
saveArticleUnread(article);
|
||||
}
|
||||
|
||||
if (!getSupportActionBar().isShowing()) getSupportActionBar().show();
|
||||
try {
|
||||
preloadUriIfAllowed(Uri.parse(article.link));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!getSupportActionBar().isShowing()) getSupportActionBar().show();
|
||||
|
||||
if (open) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user