implement most of offline menus
This commit is contained in:
parent
3fd63d640a
commit
8e3e5add77
@ -1,61 +0,0 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/main"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent" >
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/fragment_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="horizontal" >
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/feeds_fragment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="0.6"
|
|
||||||
android:background="?feedlistBackground" >
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/vertical_fragment_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="0.4"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/headlines_fragment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="0.30"
|
|
||||||
android:background="?headlinesBackgroundSolid" >
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/article_fragment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:background="?articleBackground"
|
|
||||||
android:layout_weight="0.70" >
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/loading_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:background="?loadingBackground"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/loading_message"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:text="@string/loading_message"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
@ -1,55 +0,0 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/main"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/fragment_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="horizontal" >
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/feeds_fragment"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="0.3"
|
|
||||||
android:background="?feedlistBackground" >
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/headlines_fragment"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="0.4"
|
|
||||||
android:background="?headlinesBackground" >
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/article_fragment"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="0.6"
|
|
||||||
android:background="?articleBackground" >
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/loading_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?loadingBackground"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/loading_message"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:text="@string/loading_message"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
@ -1,5 +1,5 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/online"
|
android:id="@+id/login"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent" >
|
android:layout_height="fill_parent" >
|
||||||
|
|
@ -1,27 +0,0 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/main"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent" >
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/loading_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/loading_message"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:text="@string/loading_message" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/fragment_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" >
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -23,11 +23,11 @@
|
|||||||
android:title="@string/menu_all_feeds"/>
|
android:title="@string/menu_all_feeds"/>
|
||||||
</group>
|
</group>
|
||||||
<group android:id="@+id/menu_group_headlines" >
|
<group android:id="@+id/menu_group_headlines" >
|
||||||
<item
|
<!-- <item
|
||||||
android:id="@+id/go_online"
|
android:id="@+id/go_online"
|
||||||
android:icon="@drawable/ic_menu_cloud"
|
android:icon="@drawable/ic_menu_cloud"
|
||||||
android:title="@string/go_online"
|
android:title="@string/go_online"
|
||||||
android:visible="false"/>
|
android:visible="false"/> -->
|
||||||
<item
|
<item
|
||||||
android:id="@+id/search"
|
android:id="@+id/search"
|
||||||
android:actionViewClass="android.widget.SearchView"
|
android:actionViewClass="android.widget.SearchView"
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<item name="feedlistBackground">@drawable/ics_divider_vertical</item>
|
<item name="feedlistBackground">@drawable/ics_divider_vertical</item>
|
||||||
<item name="unreadCounterColor">#303030</item>
|
<item name="unreadCounterColor">#303030</item>
|
||||||
<item name="headlinesBackground">@drawable/headlines_dark</item>
|
<item name="headlinesBackground">@drawable/headlines_dark</item>
|
||||||
<item name="headlinesBackgroundSolid">@android:color/transparent</item>
|
<item name="headlinesBackgroundSolid">@drawable/headlines_dark</item>
|
||||||
<item name="articleBackground">@android:color/black</item>
|
<item name="articleBackground">@android:color/black</item>
|
||||||
<item name="headlineSelectedBackground">@drawable/headline_row_selected_dark</item>
|
<item name="headlineSelectedBackground">@drawable/headline_row_selected_dark</item>
|
||||||
<item name="headlineSelectedBackgroundSolid">@color/ics_cyan</item>
|
<item name="headlineSelectedBackgroundSolid">@color/ics_cyan</item>
|
||||||
|
@ -104,7 +104,7 @@ public class ArticlePager extends Fragment {
|
|||||||
|
|
||||||
if (article.unread) {
|
if (article.unread) {
|
||||||
article.unread = false;
|
article.unread = false;
|
||||||
m_onlineServices.saveArticleUnread(article);
|
m_activity.saveArticleUnread(article);
|
||||||
}
|
}
|
||||||
m_onlineServices.onArticleSelected(article, false);
|
m_onlineServices.onArticleSelected(article, false);
|
||||||
|
|
||||||
|
@ -4,11 +4,7 @@ import org.fox.ttrss.types.Article;
|
|||||||
import org.fox.ttrss.types.ArticleList;
|
import org.fox.ttrss.types.ArticleList;
|
||||||
|
|
||||||
public interface HeadlinesEventListener {
|
public interface HeadlinesEventListener {
|
||||||
|
|
||||||
boolean getUnreadArticlesOnly();
|
|
||||||
void onArticleListSelectionChange(ArticleList m_selectedArticles);
|
void onArticleListSelectionChange(ArticleList m_selectedArticles);
|
||||||
void onArticleSelected(Article article);
|
void onArticleSelected(Article article);
|
||||||
void saveArticleUnread(Article article);
|
|
||||||
void onArticleSelected(Article article, boolean open);
|
void onArticleSelected(Article article, boolean open);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
private ArticleList m_articles = TinyApplication.getInstance().m_loadedArticles;
|
private ArticleList m_articles = TinyApplication.getInstance().m_loadedArticles;
|
||||||
private ArticleList m_selectedArticles = new ArticleList();
|
private ArticleList m_selectedArticles = new ArticleList();
|
||||||
private HeadlinesEventListener m_listener;
|
private HeadlinesEventListener m_listener;
|
||||||
|
|
||||||
private OnlineActivity m_activity;
|
private OnlineActivity m_activity;
|
||||||
|
|
||||||
private ImageGetter m_dummyGetter = new ImageGetter() {
|
private ImageGetter m_dummyGetter = new ImageGetter() {
|
||||||
@ -363,7 +362,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
};
|
};
|
||||||
|
|
||||||
final String sessionId = m_activity.getSessionId();
|
final String sessionId = m_activity.getSessionId();
|
||||||
final boolean showUnread = m_listener.getUnreadArticlesOnly();
|
final boolean showUnread = m_activity.getUnreadArticlesOnly();
|
||||||
final boolean isCat = m_feed.is_cat;
|
final boolean isCat = m_feed.is_cat;
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
Log.d(TAG, "m_isOffline=" + isOffline);
|
Log.d(TAG, "m_isOffline=" + isOffline);
|
||||||
|
|
||||||
setContentView(R.layout.online);
|
setContentView(R.layout.login);
|
||||||
|
|
||||||
if (isOffline) {
|
if (isOffline) {
|
||||||
switchOfflineSuccess();
|
switchOfflineSuccess();
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.fox.ttrss.offline;
|
package org.fox.ttrss.offline;
|
||||||
|
|
||||||
import javax.crypto.spec.OAEPParameterSpec;
|
|
||||||
|
|
||||||
import org.fox.ttrss.CommonActivity;
|
import org.fox.ttrss.CommonActivity;
|
||||||
import org.fox.ttrss.PreferencesActivity;
|
import org.fox.ttrss.PreferencesActivity;
|
||||||
import org.fox.ttrss.R;
|
import org.fox.ttrss.R;
|
||||||
@ -10,20 +8,23 @@ import android.app.AlertDialog;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteStatement;
|
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.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.ActionMode;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.SearchView;
|
||||||
|
import android.widget.ShareActionProvider;
|
||||||
|
|
||||||
public class OfflineActivity extends CommonActivity {
|
public class OfflineActivity extends CommonActivity {
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
@ -32,6 +33,38 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
protected Menu m_menu;
|
protected Menu m_menu;
|
||||||
protected boolean m_unreadOnly;
|
protected boolean m_unreadOnly;
|
||||||
|
|
||||||
|
private ActionMode m_headlinesActionMode;
|
||||||
|
private HeadlinesActionModeCallback m_headlinesActionModeCallback;
|
||||||
|
|
||||||
|
private class HeadlinesActionModeCallback implements ActionMode.Callback {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
|
deselectAllArticles();
|
||||||
|
m_headlinesActionMode = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
|
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.headlines_action_menu, menu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||||
|
onOptionsItemSelected(item);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
m_prefs = PreferenceManager
|
m_prefs = PreferenceManager
|
||||||
@ -45,7 +78,7 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.online);
|
setContentView(R.layout.login);
|
||||||
|
|
||||||
setLoadingStatus(R.string.blank, false);
|
setLoadingStatus(R.string.blank, false);
|
||||||
findViewById(R.id.loading_container).setVisibility(View.GONE);
|
findViewById(R.id.loading_container).setVisibility(View.GONE);
|
||||||
@ -67,6 +100,11 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
m_unreadOnly = savedInstanceState.getBoolean("unreadOnly");
|
m_unreadOnly = savedInstanceState.getBoolean("unreadOnly");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isCompatMode()) {
|
||||||
|
m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -198,7 +236,7 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.share_article:
|
case R.id.share_article:
|
||||||
if (oap != null && android.os.Build.VERSION.SDK_INT < 14) {
|
if (android.os.Build.VERSION.SDK_INT < 14 && oap != null && android.os.Build.VERSION.SDK_INT < 14) {
|
||||||
int articleId = oap.getSelectedArticleId();
|
int articleId = oap.getSelectedArticleId();
|
||||||
|
|
||||||
shareArticle(articleId);
|
shareArticle(articleId);
|
||||||
@ -326,6 +364,68 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
|
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
|
||||||
m_menu.setGroupVisible(R.id.menu_group_article, false);
|
m_menu.setGroupVisible(R.id.menu_group_article, false);
|
||||||
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
||||||
|
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
||||||
|
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
|
||||||
|
|
||||||
|
OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||||
|
|
||||||
|
if (af != null) {
|
||||||
|
Log.d(TAG, "setting up share provider");
|
||||||
|
shareProvider.setShareIntent(getShareIntent(getArticleById(af.getSelectedArticleId())));
|
||||||
|
|
||||||
|
if (!isSmallScreen()) {
|
||||||
|
m_menu.findItem(R.id.share_article).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCompatMode()) {
|
||||||
|
MenuItem search = m_menu.findItem(R.id.search);
|
||||||
|
|
||||||
|
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
|
if (hf != null) {
|
||||||
|
if (hf.getSelectedArticleCount() > 0 && m_headlinesActionMode == null) {
|
||||||
|
m_headlinesActionMode = startActionMode(m_headlinesActionModeCallback);
|
||||||
|
} else if (hf.getSelectedArticleCount() == 0 && m_headlinesActionMode != null) {
|
||||||
|
m_headlinesActionMode.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchView searchView = (SearchView) search.getActionView();
|
||||||
|
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||||
|
private String query = "";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextSubmit(String query) {
|
||||||
|
OfflineHeadlinesFragment frag = (OfflineHeadlinesFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
|
if (frag != null) {
|
||||||
|
frag.setSearchQuery(query);
|
||||||
|
this.query = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextChange(String newText) {
|
||||||
|
if (newText.equals("") && !newText.equals(this.query)) {
|
||||||
|
OfflineHeadlinesFragment frag = (OfflineHeadlinesFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
|
if (frag != null) {
|
||||||
|
frag.setSearchQuery(newText);
|
||||||
|
this.query = newText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +498,7 @@ public class OfflineActivity extends CommonActivity {
|
|||||||
Intent intent = getShareIntent(article);
|
Intent intent = getShareIntent(article);
|
||||||
|
|
||||||
startActivity(Intent.createChooser(intent,
|
startActivity(Intent.createChooser(intent,
|
||||||
getString(R.id.share_article)));
|
getString(R.string.share_article)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ public class OfflineArticlePager extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_searchQuery.equals("")) {
|
if (m_searchQuery.equals("")) {
|
||||||
return m_listener.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||||
new String[] { "articles."+BaseColumns._ID, "feeds.title AS feed_title" }, feedClause,
|
new String[] { "articles."+BaseColumns._ID, "feeds.title AS feed_title" }, feedClause,
|
||||||
new String[] { String.valueOf(m_feedId) }, null, null, "updated DESC");
|
new String[] { String.valueOf(m_feedId) }, null, null, "updated DESC");
|
||||||
} else {
|
} else {
|
||||||
return m_listener.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||||
new String[] { "articles."+BaseColumns._ID },
|
new String[] { "articles."+BaseColumns._ID },
|
||||||
feedClause + " AND (articles.title LIKE '%' || ? || '%' OR content LIKE '%' || ? || '%')",
|
feedClause + " AND (articles.title LIKE '%' || ? || '%' OR content LIKE '%' || ? || '%')",
|
||||||
new String[] { String.valueOf(m_feedId), m_searchQuery, m_searchQuery }, null, null, "updated DESC");
|
new String[] { String.valueOf(m_feedId), m_searchQuery, m_searchQuery }, null, null, "updated DESC");
|
||||||
|
@ -47,7 +47,7 @@ public class OfflineDownloadService extends Service {
|
|||||||
public static final String INTENT_ACTION_CANCEL = "org.fox.ttrss.intent.action.Cancel";
|
public static final String INTENT_ACTION_CANCEL = "org.fox.ttrss.intent.action.Cancel";
|
||||||
|
|
||||||
private static final int OFFLINE_SYNC_SEQ = 40;
|
private static final int OFFLINE_SYNC_SEQ = 40;
|
||||||
private static final int OFFLINE_SYNC_MAX = 120 /*500*/;
|
private static final int OFFLINE_SYNC_MAX = 500;
|
||||||
|
|
||||||
private SQLiteDatabase m_writableDb;
|
private SQLiteDatabase m_writableDb;
|
||||||
private SQLiteDatabase m_readableDb;
|
private SQLiteDatabase m_readableDb;
|
||||||
|
@ -229,6 +229,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initMenu();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,15 +3,6 @@ package org.fox.ttrss.offline;
|
|||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
public interface OfflineHeadlinesEventListener {
|
public interface OfflineHeadlinesEventListener {
|
||||||
|
|
||||||
void onArticleSelected(int articleId, boolean open);
|
void onArticleSelected(int articleId, boolean open);
|
||||||
void onArticleSelected(int articleId);
|
void onArticleSelected(int articleId);
|
||||||
|
|
||||||
SQLiteDatabase getReadableDb();
|
|
||||||
SQLiteDatabase getWritableDb();
|
|
||||||
boolean isSmallScreen();
|
|
||||||
boolean isPortrait();
|
|
||||||
void initMenu();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
private ArticleListAdapter m_adapter;
|
private ArticleListAdapter m_adapter;
|
||||||
|
|
||||||
private OfflineHeadlinesEventListener m_listener;
|
private OfflineHeadlinesEventListener m_listener;
|
||||||
|
private OfflineActivity m_activity;
|
||||||
|
|
||||||
private ImageGetter m_dummyGetter = new ImageGetter() {
|
private ImageGetter m_dummyGetter = new ImageGetter() {
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSelectedArticleCount() {
|
public int getSelectedArticleCount() {
|
||||||
Cursor c = m_listener.getReadableDb().query("articles",
|
Cursor c = m_activity.getReadableDb().query("articles",
|
||||||
new String[] { "COUNT(*)" }, "selected = 1", null, null, null, null);
|
new String[] { "COUNT(*)" }, "selected = 1", null, null, null, null);
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
int selected = c.getInt(0);
|
int selected = c.getInt(0);
|
||||||
@ -101,38 +102,82 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
.getMenuInfo();
|
.getMenuInfo();
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.set_labels:
|
|
||||||
if (true) {
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.article_set_note:
|
|
||||||
if (true) {
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case R.id.article_link_copy:
|
case R.id.article_link_copy:
|
||||||
if (true) {
|
if (true) {
|
||||||
|
int articleId = getArticleIdAtPosition(info.position);
|
||||||
|
|
||||||
|
Cursor article = m_activity.getArticleById(articleId);
|
||||||
|
|
||||||
|
if (article != null) {
|
||||||
|
m_activity.copyToClipboard(article.getString(article.getColumnIndex("link")));
|
||||||
|
article.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_marked:
|
case R.id.selection_toggle_marked:
|
||||||
if (true) {
|
if (getSelectedArticleCount() > 0) {
|
||||||
|
SQLiteStatement stmt = m_activity.getWritableDb()
|
||||||
|
.compileStatement(
|
||||||
|
"UPDATE articles SET marked = NOT marked WHERE selected = 1");
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
} else {
|
||||||
|
int articleId = getArticleIdAtPosition(info.position);
|
||||||
|
|
||||||
|
SQLiteStatement stmt = m_activity.getWritableDb().compileStatement(
|
||||||
|
"UPDATE articles SET marked = NOT marked WHERE "
|
||||||
|
+ BaseColumns._ID + " = ?");
|
||||||
|
stmt.bindLong(1, articleId);
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
}
|
}
|
||||||
|
refresh();
|
||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_published:
|
case R.id.selection_toggle_published:
|
||||||
if (true) {
|
if (getSelectedArticleCount() > 0) {
|
||||||
|
SQLiteStatement stmt = m_activity.getWritableDb()
|
||||||
|
.compileStatement(
|
||||||
|
"UPDATE articles SET published = NOT published WHERE selected = 1");
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
} else {
|
||||||
|
int articleId = getArticleIdAtPosition(info.position);
|
||||||
|
|
||||||
|
SQLiteStatement stmt = m_activity.getWritableDb().compileStatement(
|
||||||
|
"UPDATE articles SET published = NOT published WHERE "
|
||||||
|
+ BaseColumns._ID + " = ?");
|
||||||
|
stmt.bindLong(1, articleId);
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
}
|
}
|
||||||
|
refresh();
|
||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_unread:
|
case R.id.selection_toggle_unread:
|
||||||
if (true) {
|
if (getSelectedArticleCount() > 0) {
|
||||||
|
SQLiteStatement stmt = m_activity.getWritableDb()
|
||||||
|
.compileStatement(
|
||||||
|
"UPDATE articles SET unread = NOT unread WHERE selected = 1");
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
} else {
|
||||||
|
int articleId = getArticleIdAtPosition(info.position);
|
||||||
|
|
||||||
|
SQLiteStatement stmt = m_activity.getWritableDb().compileStatement(
|
||||||
|
"UPDATE articles SET unread = NOT unread WHERE "
|
||||||
|
+ BaseColumns._ID + " = ?");
|
||||||
|
stmt.bindLong(1, articleId);
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
}
|
}
|
||||||
|
refresh();
|
||||||
return true;
|
return true;
|
||||||
case R.id.share_article:
|
case R.id.share_article:
|
||||||
if (true) {
|
if (true) {
|
||||||
|
int articleId = getArticleIdAtPosition(info.position);
|
||||||
|
m_activity.shareArticle(articleId);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.catchup_above:
|
case R.id.catchup_above:
|
||||||
if (true) {
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
|
Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
|
||||||
@ -155,6 +200,9 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
menu.setHeaderTitle(c.getString(c.getColumnIndex("title")));
|
menu.setHeaderTitle(c.getString(c.getColumnIndex("title")));
|
||||||
//c.close();
|
//c.close();
|
||||||
menu.setGroupVisible(R.id.menu_group_single_article, true);
|
menu.setGroupVisible(R.id.menu_group_single_article, true);
|
||||||
|
|
||||||
|
menu.findItem(R.id.set_labels).setVisible(false);
|
||||||
|
menu.findItem(R.id.article_set_note).setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
@ -189,7 +237,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
m_searchQuery = (String) savedInstanceState.getCharSequence("searchQuery");
|
m_searchQuery = (String) savedInstanceState.getCharSequence("searchQuery");
|
||||||
m_feedIsCat = savedInstanceState.getBoolean("feedIsCat");
|
m_feedIsCat = savedInstanceState.getBoolean("feedIsCat");
|
||||||
} else {
|
} else {
|
||||||
m_listener.getWritableDb().execSQL("UPDATE articles SET selected = 0 ");
|
m_activity.getWritableDb().execSQL("UPDATE articles SET selected = 0 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.headlines_fragment, container, false);
|
View view = inflater.inflate(R.layout.headlines_fragment, container, false);
|
||||||
@ -205,7 +253,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
list.setEmptyView(view.findViewById(R.id.no_headlines));
|
list.setEmptyView(view.findViewById(R.id.no_headlines));
|
||||||
registerForContextMenu(list);
|
registerForContextMenu(list);
|
||||||
|
|
||||||
if (m_listener.isSmallScreen() || m_listener.isPortrait())
|
if (m_activity.isSmallScreen() || m_activity.isPortrait())
|
||||||
view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0);
|
view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0);
|
||||||
|
|
||||||
getActivity().setProgressBarIndeterminateVisibility(false);
|
getActivity().setProgressBarIndeterminateVisibility(false);
|
||||||
@ -223,11 +271,11 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_searchQuery.equals("")) {
|
if (m_searchQuery.equals("")) {
|
||||||
return m_listener.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||||
new String[] { "articles.*", "feeds.title AS feed_title" }, feedClause,
|
new String[] { "articles.*", "feeds.title AS feed_title" }, feedClause,
|
||||||
new String[] { String.valueOf(m_feedId) }, null, null, "updated DESC");
|
new String[] { String.valueOf(m_feedId) }, null, null, "updated DESC");
|
||||||
} else {
|
} else {
|
||||||
return m_listener.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
return m_activity.getReadableDb().query("articles LEFT JOIN feeds ON (feed_id = feeds."+BaseColumns._ID+")",
|
||||||
new String[] { "articles.*", "feeds.title AS feed_title" },
|
new String[] { "articles.*", "feeds.title AS feed_title" },
|
||||||
feedClause + " AND (articles.title LIKE '%' || ? || '%' OR content LIKE '%' || ? || '%')",
|
feedClause + " AND (articles.title LIKE '%' || ? || '%' OR content LIKE '%' || ? || '%')",
|
||||||
new String[] { String.valueOf(m_feedId), m_searchQuery, m_searchQuery }, null, null, "updated DESC");
|
new String[] { String.valueOf(m_feedId), m_searchQuery, m_searchQuery }, null, null, "updated DESC");
|
||||||
@ -238,6 +286,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
m_listener = (OfflineHeadlinesEventListener) activity;
|
m_listener = (OfflineHeadlinesEventListener) activity;
|
||||||
|
m_activity = (OfflineActivity) activity;
|
||||||
|
|
||||||
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||||
m_combinedMode = m_prefs.getBoolean("combined_mode", false);
|
m_combinedMode = m_prefs.getBoolean("combined_mode", false);
|
||||||
@ -254,7 +303,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
|
|
||||||
int articleId = cursor.getInt(0);
|
int articleId = cursor.getInt(0);
|
||||||
|
|
||||||
if (!m_listener.isSmallScreen()) {
|
if (!m_activity.isSmallScreen()) {
|
||||||
m_activeArticleId = articleId;
|
m_activeArticleId = articleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +440,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
SQLiteStatement stmtUpdate = m_listener.getWritableDb().compileStatement("UPDATE articles SET marked = NOT marked " +
|
SQLiteStatement stmtUpdate = m_activity.getWritableDb().compileStatement("UPDATE articles SET marked = NOT marked " +
|
||||||
"WHERE " + BaseColumns._ID + " = ?");
|
"WHERE " + BaseColumns._ID + " = ?");
|
||||||
|
|
||||||
stmtUpdate.bindLong(1, articleId);
|
stmtUpdate.bindLong(1, articleId);
|
||||||
@ -412,7 +461,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
SQLiteStatement stmtUpdate = m_listener.getWritableDb().compileStatement("UPDATE articles SET published = NOT published " +
|
SQLiteStatement stmtUpdate = m_activity.getWritableDb().compileStatement("UPDATE articles SET published = NOT published " +
|
||||||
"WHERE " + BaseColumns._ID + " = ?");
|
"WHERE " + BaseColumns._ID + " = ?");
|
||||||
|
|
||||||
stmtUpdate.bindLong(1, articleId);
|
stmtUpdate.bindLong(1, articleId);
|
||||||
@ -490,7 +539,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
CheckBox cb = (CheckBox)view;
|
CheckBox cb = (CheckBox)view;
|
||||||
|
|
||||||
SQLiteStatement stmtUpdate = m_listener.getWritableDb().compileStatement("UPDATE articles SET selected = ? " +
|
SQLiteStatement stmtUpdate = m_activity.getWritableDb().compileStatement("UPDATE articles SET selected = ? " +
|
||||||
"WHERE " + BaseColumns._ID + " = ?");
|
"WHERE " + BaseColumns._ID + " = ?");
|
||||||
|
|
||||||
stmtUpdate.bindLong(1, cb.isChecked() ? 1 : 0);
|
stmtUpdate.bindLong(1, cb.isChecked() ? 1 : 0);
|
||||||
@ -500,7 +549,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
|||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
m_listener.initMenu();
|
m_activity.initMenu();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user