remove tabs, menu cleanup

This commit is contained in:
Andrew Dolgov 2011-12-07 11:29:19 +03:00
parent df3be3d4c6
commit 65c9eeb773
4 changed files with 1213 additions and 1359 deletions

View File

@ -19,13 +19,13 @@
<item
android:id="@+id/update_feeds"
android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction="ifRoom|"
android:showAsAction="ifRoom"
android:title="@string/update_feeds"/>
<item
android:id="@+id/go_offline"
android:icon="@drawable/ic_menu_cloud"
android:showAsAction="ifRoom|withText"
android:showAsAction=""
android:title="@string/go_offline"/>
<item
@ -40,7 +40,6 @@
<item
android:id="@+id/go_offline"
android:icon="@drawable/ic_menu_cloud"
android:title="@string/go_offline"/>
<item
@ -60,8 +59,8 @@
<item
android:id="@+id/selection_toggle_unread"
android:icon="@android:drawable/ic_menu_recent_history"
android:showAsAction=""
android:icon="@drawable/ic_menu_tick"
android:showAsAction="ifRoom"
android:title="@string/selection_toggle_unread"/>
<item

View File

@ -9,11 +9,11 @@
android:title="@string/go_online"
android:visible="false"/>
<item
<!-- <item
android:id="@+id/back_to_categories"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:showAsAction="ifRoom|withText"
android:title="@string/back_to_categories"/>
android:title="@string/back_to_categories"/> -->
<item
android:id="@+id/show_feeds"
@ -39,6 +39,7 @@
<item
android:id="@+id/headlines_select"
android:icon="@drawable/ic_menu_database"
android:showAsAction="ifRoom"
android:title="@string/headlines_select"/>
</group>
@ -46,20 +47,20 @@
<item
android:id="@+id/selection_toggle_unread"
android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction=""
android:icon="@drawable/ic_menu_tick"
android:showAsAction="ifRoom"
android:title="@string/selection_toggle_unread"/>
<item
android:id="@+id/selection_toggle_marked"
android:icon="@drawable/ic_menu_marked"
android:showAsAction=""
android:showAsAction="ifRoom"
android:title="@string/selection_toggle_marked"/>
<item
android:id="@+id/selection_toggle_published"
android:icon="@drawable/ic_menu_rss"
android:showAsAction=""
android:showAsAction="ifRoom"
android:title="@string/selection_toggle_published"/>
<item
@ -80,13 +81,13 @@
<item
android:id="@+id/toggle_marked"
android:icon="@drawable/ic_menu_marked"
android:showAsAction=""
android:showAsAction="ifRoom"
android:title="@string/article_toggle_marked"/>
<item
android:id="@+id/toggle_published"
android:icon="@drawable/ic_menu_rss"
android:showAsAction=""
android:showAsAction="ifRoom"
android:title="@string/article_toggle_published"/>
<item

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,8 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.LinearLayout;
import android.widget.TextView;
public class OfflineActivity extends FragmentActivity implements OfflineServices {
public class OfflineActivity extends FragmentActivity implements
OfflineServices {
private final String TAG = this.getClass().getSimpleName();
private SharedPreferences m_prefs;
@ -53,7 +54,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
@Override
public void onCreate(Bundle savedInstanceState) {
m_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
@ -72,7 +74,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
if (savedInstanceState != null) {
m_unreadOnly = savedInstanceState.getBoolean("unreadOnly");
m_unreadArticlesOnly = savedInstanceState.getBoolean("unreadArticlesOnly");
m_unreadArticlesOnly = savedInstanceState
.getBoolean("unreadArticlesOnly");
m_activeFeedId = savedInstanceState.getInt("offlineActiveFeedId");
m_selectedArticleId = savedInstanceState.getInt("offlineArticleId");
}
@ -84,7 +87,11 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
int width = display.getWidth();
int height = display.getHeight();
if (height > width) { int tmp = height; width = tmp; height = width; }
if (height > width) {
int tmp = height;
width = tmp;
height = width;
}
m_smallScreenMode = width < 960 || height < 720;
@ -117,12 +124,13 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
// findViewById(R.id.article_fragment).setVisibility(View.GONE);
/*if (m_enableCats && m_activeCategory == null) {
findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
} else {
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
} */
/*
* if (m_enableCats && m_activeCategory == null) {
* findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
* findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
* } else {
* findViewById(R.id.cats_fragment).setVisibility(View.GONE); }
*/
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
}
@ -130,10 +138,12 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
if (m_selectedArticleId == 0) {
findViewById(R.id.article_fragment).setVisibility(View.GONE);
/* if (!m_enableCats || m_activeCategory != null)
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
else
findViewById(R.id.feeds_fragment).setVisibility(View.GONE); */
/*
* if (!m_enableCats || m_activeCategory != null)
* findViewById(R.id.cats_fragment).setVisibility(View.GONE);
* else
* findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
*/
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
@ -144,7 +154,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
}
if (m_activeFeedId == 0) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
OfflineFeedsFragment frag = new OfflineFeedsFragment();
ft.replace(R.id.feeds_fragment, frag);
ft.commit();
@ -211,10 +222,10 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
refreshViews();
/*if (!m_enableCats || m_activeCategory != null )
refreshFeeds();
else
refreshCategories(); */
/*
* if (!m_enableCats || m_activeCategory != null ) refreshFeeds(); else
* refreshCategories();
*/
}
@Override
@ -226,8 +237,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
public void onResume() {
super.onResume();
boolean needRefresh = !m_prefs.getString("theme", "THEME_DARK").equals(m_themeName) ||
m_prefs.getBoolean("enable_cats", false) != m_enableCats;
boolean needRefresh = !m_prefs.getString("theme", "THEME_DARK").equals(
m_themeName)
|| m_prefs.getBoolean("enable_cats", false) != m_enableCats;
if (needRefresh) {
Intent refresh = new Intent(this, OfflineActivity.class);
@ -271,15 +283,19 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
closeArticle();
} else if (m_activeFeedId != 0) {
if (m_compatMode) {
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));
findViewById(R.id.main).setAnimation(
AnimationUtils.loadAnimation(this,
R.anim.slide_right));
}
/* if (m_activeFeed != null && m_activeFeed.is_cat) {
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
refreshCategories();
} else { */
/*
* if (m_activeFeed != null && m_activeFeed.is_cat) {
* findViewById
* (R.id.headlines_fragment).setVisibility(View.GONE);
* findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
*
* refreshCategories(); } else {
*/
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
// }
@ -300,49 +316,36 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
}
/* @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
/*
* @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if
* (keyCode == KeyEvent.KEYCODE_BACK) {
*
* if (m_smallScreenMode) { if (m_selectedArticleId != 0) { closeArticle();
* } else if (m_activeFeedId != 0) { if (m_compatMode) {
* findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this,
* R.anim.slide_right)); }
*/
if (m_smallScreenMode) {
if (m_selectedArticleId != 0) {
closeArticle();
} else if (m_activeFeedId != 0) {
if (m_compatMode) {
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));
} */
/* if (m_activeFeed != null && m_activeFeed.is_cat) {
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
refreshCategories();
} else { */ /*
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
//}
m_activeFeedId = 0;
refreshViews();
initMainMenu();
} else {
finish();
}
} else {
if (m_selectedArticleId != 0) {
closeArticle();
} else {
finish();
}
}
return false;
}
return super.onKeyDown(keyCode, event);
} */
/*
* if (m_activeFeed != null && m_activeFeed.is_cat) {
* findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
* findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
*
* refreshCategories(); } else {
*//*
* findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
* findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); //}
* m_activeFeedId = 0; refreshViews(); initMainMenu();
*
* } else { finish(); } } else { if (m_selectedArticleId != 0) {
* closeArticle(); } else { finish(); } }
*
* return false; } return super.onKeyDown(keyCode, event); }
*/
private Cursor getArticleById(int articleId) {
Cursor c = getReadableDb().query("articles", null, BaseColumns._ID + "=?",
Cursor c = getReadableDb().query("articles", null,
BaseColumns._ID + "=?",
new String[] { String.valueOf(articleId) }, null, null, null);
c.moveToFirst();
@ -372,13 +375,15 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
intent.putExtra(Intent.EXTRA_SUBJECT, title);
intent.putExtra(Intent.EXTRA_TEXT, link);
startActivity(Intent.createChooser(intent, getString(R.id.share_article)));
startActivity(Intent.createChooser(intent,
getString(R.id.share_article)));
}
}
private void refreshHeadlines() {
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentById(R.id.headlines_fragment);
if (ohf != null) {
ohf.refresh();
@ -387,7 +392,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
@Override
public boolean onOptionsItemSelected(MenuItem item) {
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentById(R.id.headlines_fragment);
switch (item.getItemId()) {
case R.id.preferences:
@ -400,29 +406,38 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
case R.id.close_article:
closeArticle();
return true;
case R.id.back_to_categories:
/* case R.id.back_to_categories:
// closeCategory();
return true;
return true; */
case R.id.headlines_select:
if (ohf != null) {
Dialog dialog = new Dialog(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.headlines_select_dialog);
builder.setSingleChoiceItems(new String[] { getString(R.string.headlines_select_all),
getString(R.string.headlines_select_unread), getString(R.string.headlines_select_none) }, 0, new DialogInterface.OnClickListener() {
builder.setSingleChoiceItems(new String[] {
getString(R.string.headlines_select_all),
getString(R.string.headlines_select_unread),
getString(R.string.headlines_select_none) }, 0,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
public void onClick(DialogInterface dialog,
int which) {
switch (which) {
case 0:
SQLiteStatement stmtSelectAll = getWritableDb().compileStatement("UPDATE articles SET selected = 1 WHERE feed_id = ?");
SQLiteStatement stmtSelectAll = getWritableDb()
.compileStatement(
"UPDATE articles SET selected = 1 WHERE feed_id = ?");
stmtSelectAll.bindLong(1, m_activeFeedId);
stmtSelectAll.execute();
stmtSelectAll.close();
break;
case 1:
SQLiteStatement stmtSelectUnread = getWritableDb().compileStatement("UPDATE articles SET selected = 1 WHERE feed_id = ? AND unread = 1");
stmtSelectUnread.bindLong(1, m_activeFeedId);
SQLiteStatement stmtSelectUnread = getWritableDb()
.compileStatement(
"UPDATE articles SET selected = 1 WHERE feed_id = ? AND unread = 1");
stmtSelectUnread
.bindLong(1, m_activeFeedId);
stmtSelectUnread.execute();
stmtSelectUnread.close();
break;
@ -444,7 +459,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.headlines_mark_as_read:
if (m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 WHERE feed_id = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET unread = 0 WHERE feed_id = ?");
stmt.bindLong(1, m_activeFeedId);
stmt.execute();
stmt.close();
@ -456,7 +472,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.toggle_marked:
if (m_selectedArticleId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET marked = NOT marked WHERE " + BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET marked = NOT marked WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, m_selectedArticleId);
stmt.execute();
stmt.close();
@ -468,7 +486,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.selection_toggle_unread:
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = NOT unread WHERE selected = 1 AND feed_id = ?");
SQLiteStatement stmt = getWritableDb()
.compileStatement(
"UPDATE articles SET unread = NOT unread WHERE selected = 1 AND feed_id = ?");
stmt.bindLong(1, m_activeFeedId);
stmt.execute();
stmt.close();
@ -477,7 +497,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.selection_toggle_marked:
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET marked = NOT marked WHERE selected = 1 AND feed_id = ?");
SQLiteStatement stmt = getWritableDb()
.compileStatement(
"UPDATE articles SET marked = NOT marked WHERE selected = 1 AND feed_id = ?");
stmt.bindLong(1, m_activeFeedId);
stmt.execute();
stmt.close();
@ -486,7 +508,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.selection_toggle_published:
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET published = NOT published WHERE selected = 1 AND feed_id = ?");
SQLiteStatement stmt = getWritableDb()
.compileStatement(
"UPDATE articles SET published = NOT published WHERE selected = 1 AND feed_id = ?");
stmt.bindLong(1, m_activeFeedId);
stmt.execute();
stmt.close();
@ -495,7 +519,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.toggle_published:
if (m_selectedArticleId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET published = NOT published WHERE " + BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET published = NOT published WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, m_selectedArticleId);
stmt.execute();
stmt.close();
@ -504,8 +530,10 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.catchup_above:
if (m_selectedArticleId != 0 && m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 WHERE updated >= " +
"(SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) AND feed_id = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET unread = 0 WHERE updated >= "
+ "(SELECT updated FROM articles WHERE "
+ BaseColumns._ID + " = ?) AND feed_id = ?");
stmt.bindLong(1, m_selectedArticleId);
stmt.bindLong(2, m_activeFeedId);
stmt.execute();
@ -515,7 +543,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.set_unread:
if (m_selectedArticleId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 1 WHERE " + BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET unread = 1 WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, m_selectedArticleId);
stmt.execute();
stmt.close();
@ -533,13 +563,15 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
default:
Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId());
Log.d(TAG,
"onOptionsItemSelected, unhandled id=" + item.getItemId());
return super.onOptionsItemSelected(item);
}
}
private void refreshFeeds() {
OfflineFeedsFragment frag = (OfflineFeedsFragment)getSupportFragmentManager().findFragmentById(R.id.feeds_fragment);
OfflineFeedsFragment frag = (OfflineFeedsFragment) getSupportFragmentManager()
.findFragmentById(R.id.feeds_fragment);
if (frag != null) {
frag.refresh();
@ -548,7 +580,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
private void closeArticle() {
if (m_compatMode) {
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));
findViewById(R.id.main).setAnimation(
AnimationUtils.loadAnimation(this, R.anim.slide_right));
}
if (m_smallScreenMode) {
@ -568,7 +601,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
}
private int getSelectedArticleCount() {
Cursor c = getReadableDb().query("articles", new String[] { "COUNT(*)" }, "selected = 1", null, null, null, null);
Cursor c = getReadableDb().query("articles",
new String[] { "COUNT(*)" }, "selected = 1", null, null, null,
null);
c.moveToFirst();
int selected = c.getInt(0);
c.close();
@ -579,58 +614,24 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
@Override
public void initMainMenu() {
if (m_menu != null) {
int numSelected = getSelectedArticleCount();
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
m_menu.setGroupVisible(R.id.menu_group_headlines, 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_headlines_selection, false);
if (m_selectedArticleId != 0) {
m_menu.setGroupVisible(R.id.menu_group_article, true);
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
if (m_smallScreenMode) {
m_menu.setGroupVisible(R.id.menu_group_headlines, false);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
} else {
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
}
} else {
if (m_activeFeedId != 0) {
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
if (hf != null) {
if (getSelectedArticleCount() != 0) {
m_menu.setGroupVisible(R.id.menu_group_headlines, false);
if (numSelected != 0) {
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true);
} else {
} else if (m_selectedArticleId != 0) {
m_menu.setGroupVisible(R.id.menu_group_article, true);
} else if (m_activeFeedId != 0 /*|| m_activeCategory != null */) {
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
}
} else {
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
}
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
} else {
m_menu.setGroupVisible(R.id.menu_group_feeds, true);
}
if (!m_smallScreenMode || m_activeFeedId == 0) {
m_menu.findItem(R.id.show_feeds).setVisible(true);
}
//m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null);
m_menu.findItem(R.id.back_to_categories).setVisible(false);
}
}
}
@Override
public void onPause() {
@ -654,10 +655,13 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
OfflineFeedsFragment ff = (OfflineFeedsFragment)getSupportFragmentManager().findFragmentById(R.id.feeds_fragment);
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentById(R.id.headlines_fragment);
OfflineFeedsFragment ff = (OfflineFeedsFragment) getSupportFragmentManager()
.findFragmentById(R.id.feeds_fragment);
switch (item.getItemId()) {
case R.id.browse_articles:
@ -674,7 +678,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
int feedId = ff.getFeedIdAtPosition(info.position);
if (feedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 WHERE feed_id = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET unread = 0 WHERE feed_id = ?");
stmt.bindLong(1, feedId);
stmt.execute();
stmt.close();
@ -684,7 +689,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.selection_toggle_unread:
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = NOT unread WHERE selected = 1 AND feed_id = ?");
SQLiteStatement stmt = getWritableDb()
.compileStatement(
"UPDATE articles SET unread = NOT unread WHERE selected = 1 AND feed_id = ?");
stmt.bindLong(1, m_activeFeedId);
stmt.execute();
stmt.close();
@ -692,8 +699,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
} else {
int articleId = hf.getArticleIdAtPosition(info.position);
if (articleId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = NOT unread WHERE " +
BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET unread = NOT unread WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
stmt.close();
@ -703,7 +711,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.selection_toggle_marked:
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET marked = NOT marked WHERE selected = 1 AND feed_id = ?");
SQLiteStatement stmt = getWritableDb()
.compileStatement(
"UPDATE articles SET marked = NOT marked WHERE selected = 1 AND feed_id = ?");
stmt.bindLong(1, m_activeFeedId);
stmt.execute();
stmt.close();
@ -711,8 +721,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
} else {
int articleId = hf.getArticleIdAtPosition(info.position);
if (articleId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET marked = NOT marked WHERE " +
BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET marked = NOT marked WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
stmt.close();
@ -722,7 +733,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
return true;
case R.id.selection_toggle_published:
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET published = NOT published WHERE selected = 1 AND feed_id = ?");
SQLiteStatement stmt = getWritableDb()
.compileStatement(
"UPDATE articles SET published = NOT published WHERE selected = 1 AND feed_id = ?");
stmt.bindLong(1, m_activeFeedId);
stmt.execute();
stmt.close();
@ -730,8 +743,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
} else {
int articleId = hf.getArticleIdAtPosition(info.position);
if (articleId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET published = NOT published WHERE " +
BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET published = NOT published WHERE "
+ BaseColumns._ID + " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
stmt.close();
@ -750,8 +764,10 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
int articleId = hf.getArticleIdAtPosition(info.position);
if (articleId != 0 && m_activeFeedId != 0) {
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 WHERE updated >= " +
"(SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) AND feed_id = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET unread = 0 WHERE updated >= "
+ "(SELECT updated FROM articles WHERE "
+ BaseColumns._ID + " = ?) AND feed_id = ?");
stmt.bindLong(1, articleId);
stmt.bindLong(2, m_activeFeedId);
stmt.execute();
@ -760,7 +776,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
}
return true;
default:
Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
Log.d(TAG,
"onContextItemSelected, unhandled id=" + item.getItemId());
return super.onContextItemSelected(item);
}
}
@ -773,16 +790,21 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) {
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentById(R.id.headlines_fragment);
int nextId = getRelativeArticleId(m_selectedArticleId, m_activeFeedId, RelativeArticle.AFTER);
int nextId = getRelativeArticleId(m_selectedArticleId,
m_activeFeedId, RelativeArticle.AFTER);
if (nextId != 0 && ohf != null) {
if (m_prefs.getBoolean("combined_mode", false)) {
ohf.setActiveArticleId(nextId);
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 " +
"WHERE " + BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb()
.compileStatement(
"UPDATE articles SET unread = 0 "
+ "WHERE " + BaseColumns._ID
+ " = ?");
stmt.bindLong(1, nextId);
stmt.execute();
@ -797,16 +819,21 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_UP) {
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentById(R.id.headlines_fragment);
int prevId = getRelativeArticleId(m_selectedArticleId, m_activeFeedId, RelativeArticle.BEFORE);
int prevId = getRelativeArticleId(m_selectedArticleId,
m_activeFeedId, RelativeArticle.BEFORE);
if (prevId != 0 && ohf != null) {
if (m_prefs.getBoolean("combined_mode", false)) {
ohf.setActiveArticleId(prevId);
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 " +
"WHERE " + BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb()
.compileStatement(
"UPDATE articles SET unread = 0 "
+ "WHERE " + BaseColumns._ID
+ " = ?");
stmt.bindLong(1, prevId);
stmt.execute();
@ -828,33 +855,42 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
}
@Override
public int getRelativeArticleId(int baseId, int feedId, OnlineServices.RelativeArticle mode) {
public int getRelativeArticleId(int baseId, int feedId,
OnlineServices.RelativeArticle mode) {
Cursor c;
/* if (baseId == 0) {
c = getReadableDb().query("articles",
null, "feed_id = ?",
new String[] { String.valueOf(feedId) }, null, null, "updated DESC LIMIT 1");
if (c.moveToFirst()) {
baseId = c.getInt(0);
}
c.close();
return baseId;
} */
/*
* if (baseId == 0) { c = getReadableDb().query("articles", null,
* "feed_id = ?", new String[] { String.valueOf(feedId) }, null, null,
* "updated DESC LIMIT 1");
*
* if (c.moveToFirst()) { baseId = c.getInt(0); }
*
* c.close();
*
* return baseId; }
*/
if (mode == RelativeArticle.BEFORE) {
c = getReadableDb().query("articles",
null, "updated > (SELECT updated FROM articles WHERE "+BaseColumns._ID+" = ?) AND feed_id = ?",
new String[] { String.valueOf(baseId), String.valueOf(feedId) }, null, null, "updated LIMIT 1");
c = getReadableDb().query(
"articles",
null,
"updated > (SELECT updated FROM articles WHERE "
+ BaseColumns._ID + " = ?) AND feed_id = ?",
new String[] { String.valueOf(baseId),
String.valueOf(feedId) }, null, null,
"updated LIMIT 1");
} else {
c = getReadableDb().query("articles",
null, "updated < (SELECT updated FROM articles WHERE "+BaseColumns._ID+" = ?) AND feed_id = ?",
new String[] { String.valueOf(baseId), String.valueOf(feedId) }, null, null, "updated DESC LIMIT 1");
c = getReadableDb().query(
"articles",
null,
"updated < (SELECT updated FROM articles WHERE "
+ BaseColumns._ID + " = ?) AND feed_id = ?",
new String[] { String.valueOf(baseId),
String.valueOf(feedId) }, null, null,
"updated DESC LIMIT 1");
}
int id = 0;
@ -894,14 +930,16 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
initMainMenu();
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager()
.findFragmentById(R.id.headlines_fragment);
if (hf != null) {
hf.setActiveArticleId(articleId);
}
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 " +
"WHERE " + BaseColumns._ID + " = ?");
SQLiteStatement stmt = getWritableDb().compileStatement(
"UPDATE articles SET unread = 0 " + "WHERE " + BaseColumns._ID
+ " = ?");
stmt.bindLong(1, articleId);
stmt.execute();
@ -915,9 +953,11 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
if (m_compatMode) {
if (compatAnimation == 0)
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_left));
findViewById(R.id.main).setAnimation(
AnimationUtils.loadAnimation(this, R.anim.slide_left));
else
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, compatAnimation));
findViewById(R.id.main).setAnimation(
AnimationUtils.loadAnimation(this, compatAnimation));
}
if (m_smallScreenMode) {
@ -929,7 +969,6 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
}
}
@Override