remove tabs, menu cleanup
This commit is contained in:
parent
df3be3d4c6
commit
65c9eeb773
@ -19,13 +19,13 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/update_feeds"
|
android:id="@+id/update_feeds"
|
||||||
android:icon="@android:drawable/ic_menu_rotate"
|
android:icon="@android:drawable/ic_menu_rotate"
|
||||||
android:showAsAction="ifRoom|"
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/update_feeds"/>
|
android:title="@string/update_feeds"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/go_offline"
|
android:id="@+id/go_offline"
|
||||||
android:icon="@drawable/ic_menu_cloud"
|
android:icon="@drawable/ic_menu_cloud"
|
||||||
android:showAsAction="ifRoom|withText"
|
android:showAsAction=""
|
||||||
android:title="@string/go_offline"/>
|
android:title="@string/go_offline"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
@ -40,7 +40,6 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/go_offline"
|
android:id="@+id/go_offline"
|
||||||
android:icon="@drawable/ic_menu_cloud"
|
android:icon="@drawable/ic_menu_cloud"
|
||||||
|
|
||||||
android:title="@string/go_offline"/>
|
android:title="@string/go_offline"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
@ -60,8 +59,8 @@
|
|||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/selection_toggle_unread"
|
android:id="@+id/selection_toggle_unread"
|
||||||
android:icon="@android:drawable/ic_menu_recent_history"
|
android:icon="@drawable/ic_menu_tick"
|
||||||
android:showAsAction=""
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/selection_toggle_unread"/>
|
android:title="@string/selection_toggle_unread"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
android:title="@string/go_online"
|
android:title="@string/go_online"
|
||||||
android:visible="false"/>
|
android:visible="false"/>
|
||||||
|
|
||||||
<item
|
<!-- <item
|
||||||
android:id="@+id/back_to_categories"
|
android:id="@+id/back_to_categories"
|
||||||
android:icon="@android:drawable/ic_menu_close_clear_cancel"
|
android:icon="@android:drawable/ic_menu_close_clear_cancel"
|
||||||
android:showAsAction="ifRoom|withText"
|
android:showAsAction="ifRoom|withText"
|
||||||
android:title="@string/back_to_categories"/>
|
android:title="@string/back_to_categories"/> -->
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/show_feeds"
|
android:id="@+id/show_feeds"
|
||||||
@ -39,6 +39,7 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/headlines_select"
|
android:id="@+id/headlines_select"
|
||||||
android:icon="@drawable/ic_menu_database"
|
android:icon="@drawable/ic_menu_database"
|
||||||
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/headlines_select"/>
|
android:title="@string/headlines_select"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
@ -46,20 +47,20 @@
|
|||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/selection_toggle_unread"
|
android:id="@+id/selection_toggle_unread"
|
||||||
android:icon="@android:drawable/ic_menu_rotate"
|
android:icon="@drawable/ic_menu_tick"
|
||||||
android:showAsAction=""
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/selection_toggle_unread"/>
|
android:title="@string/selection_toggle_unread"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/selection_toggle_marked"
|
android:id="@+id/selection_toggle_marked"
|
||||||
android:icon="@drawable/ic_menu_marked"
|
android:icon="@drawable/ic_menu_marked"
|
||||||
android:showAsAction=""
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/selection_toggle_marked"/>
|
android:title="@string/selection_toggle_marked"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/selection_toggle_published"
|
android:id="@+id/selection_toggle_published"
|
||||||
android:icon="@drawable/ic_menu_rss"
|
android:icon="@drawable/ic_menu_rss"
|
||||||
android:showAsAction=""
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/selection_toggle_published"/>
|
android:title="@string/selection_toggle_published"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
@ -80,13 +81,13 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/toggle_marked"
|
android:id="@+id/toggle_marked"
|
||||||
android:icon="@drawable/ic_menu_marked"
|
android:icon="@drawable/ic_menu_marked"
|
||||||
android:showAsAction=""
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/article_toggle_marked"/>
|
android:title="@string/article_toggle_marked"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/toggle_published"
|
android:id="@+id/toggle_published"
|
||||||
android:icon="@drawable/ic_menu_rss"
|
android:icon="@drawable/ic_menu_rss"
|
||||||
android:showAsAction=""
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/article_toggle_published"/>
|
android:title="@string/article_toggle_published"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,8 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
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 final String TAG = this.getClass().getSimpleName();
|
||||||
|
|
||||||
private SharedPreferences m_prefs;
|
private SharedPreferences m_prefs;
|
||||||
@ -53,7 +54,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
m_prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
m_prefs = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(getApplicationContext());
|
||||||
|
|
||||||
m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
|
m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
|
||||||
|
|
||||||
@ -65,14 +67,15 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
NotificationManager nmgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
|
NotificationManager nmgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
nmgr.cancel(OfflineDownloadService.NOTIFY_DOWNLOADING);
|
nmgr.cancel(OfflineDownloadService.NOTIFY_DOWNLOADING);
|
||||||
|
|
||||||
m_themeName = m_prefs.getString("theme", "THEME_DARK");
|
m_themeName = m_prefs.getString("theme", "THEME_DARK");
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
m_unreadOnly = savedInstanceState.getBoolean("unreadOnly");
|
m_unreadOnly = savedInstanceState.getBoolean("unreadOnly");
|
||||||
m_unreadArticlesOnly = savedInstanceState.getBoolean("unreadArticlesOnly");
|
m_unreadArticlesOnly = savedInstanceState
|
||||||
|
.getBoolean("unreadArticlesOnly");
|
||||||
m_activeFeedId = savedInstanceState.getInt("offlineActiveFeedId");
|
m_activeFeedId = savedInstanceState.getInt("offlineActiveFeedId");
|
||||||
m_selectedArticleId = savedInstanceState.getInt("offlineArticleId");
|
m_selectedArticleId = savedInstanceState.getInt("offlineArticleId");
|
||||||
}
|
}
|
||||||
@ -84,7 +87,11 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
int width = display.getWidth();
|
int width = display.getWidth();
|
||||||
int height = display.getHeight();
|
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;
|
m_smallScreenMode = width < 960 || height < 720;
|
||||||
|
|
||||||
@ -96,7 +103,7 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
Log.d(TAG, "m_compatMode=" + m_compatMode);
|
Log.d(TAG, "m_compatMode=" + m_compatMode);
|
||||||
|
|
||||||
if (!m_compatMode) {
|
if (!m_compatMode) {
|
||||||
new TransitionHelper((LinearLayout)findViewById(R.id.main));
|
new TransitionHelper((LinearLayout) findViewById(R.id.main));
|
||||||
}
|
}
|
||||||
|
|
||||||
initMainMenu();
|
initMainMenu();
|
||||||
@ -115,14 +122,15 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
|
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
||||||
//findViewById(R.id.article_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);
|
* if (m_enableCats && m_activeCategory == null) {
|
||||||
findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
|
* findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
|
||||||
} else {
|
* findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
|
||||||
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
|
* } else {
|
||||||
} */
|
* findViewById(R.id.cats_fragment).setVisibility(View.GONE); }
|
||||||
|
*/
|
||||||
|
|
||||||
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) {
|
if (m_selectedArticleId == 0) {
|
||||||
findViewById(R.id.article_fragment).setVisibility(View.GONE);
|
findViewById(R.id.article_fragment).setVisibility(View.GONE);
|
||||||
|
|
||||||
/* if (!m_enableCats || m_activeCategory != null)
|
/*
|
||||||
findViewById(R.id.cats_fragment).setVisibility(View.GONE);
|
* if (!m_enableCats || m_activeCategory != null)
|
||||||
else
|
* findViewById(R.id.cats_fragment).setVisibility(View.GONE);
|
||||||
findViewById(R.id.feeds_fragment).setVisibility(View.GONE); */
|
* else
|
||||||
|
* findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
|
||||||
|
*/
|
||||||
|
|
||||||
findViewById(R.id.cats_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) {
|
if (m_activeFeedId == 0) {
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction ft = getSupportFragmentManager()
|
||||||
|
.beginTransaction();
|
||||||
OfflineFeedsFragment frag = new OfflineFeedsFragment();
|
OfflineFeedsFragment frag = new OfflineFeedsFragment();
|
||||||
ft.replace(R.id.feeds_fragment, frag);
|
ft.replace(R.id.feeds_fragment, frag);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
@ -183,7 +194,7 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setLoadingStatus(int status, boolean showProgress) {
|
private void setLoadingStatus(int status, boolean showProgress) {
|
||||||
TextView tv = (TextView)findViewById(R.id.loading_message);
|
TextView tv = (TextView) findViewById(R.id.loading_message);
|
||||||
|
|
||||||
if (tv != null) {
|
if (tv != null) {
|
||||||
tv.setText(status);
|
tv.setText(status);
|
||||||
@ -197,7 +208,7 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState (Bundle out) {
|
public void onSaveInstanceState(Bundle out) {
|
||||||
super.onSaveInstanceState(out);
|
super.onSaveInstanceState(out);
|
||||||
|
|
||||||
out.putBoolean("unreadOnly", m_unreadOnly);
|
out.putBoolean("unreadOnly", m_unreadOnly);
|
||||||
@ -211,10 +222,10 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
refreshViews();
|
refreshViews();
|
||||||
|
|
||||||
/*if (!m_enableCats || m_activeCategory != null )
|
/*
|
||||||
refreshFeeds();
|
* if (!m_enableCats || m_activeCategory != null ) refreshFeeds(); else
|
||||||
else
|
* refreshCategories();
|
||||||
refreshCategories(); */
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -226,8 +237,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
boolean needRefresh = !m_prefs.getString("theme", "THEME_DARK").equals(m_themeName) ||
|
boolean needRefresh = !m_prefs.getString("theme", "THEME_DARK").equals(
|
||||||
m_prefs.getBoolean("enable_cats", false) != m_enableCats;
|
m_themeName)
|
||||||
|
|| m_prefs.getBoolean("enable_cats", false) != m_enableCats;
|
||||||
|
|
||||||
if (needRefresh) {
|
if (needRefresh) {
|
||||||
Intent refresh = new Intent(this, OfflineActivity.class);
|
Intent refresh = new Intent(this, OfflineActivity.class);
|
||||||
@ -271,18 +283,22 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
closeArticle();
|
closeArticle();
|
||||||
} else if (m_activeFeedId != 0) {
|
} else if (m_activeFeedId != 0) {
|
||||||
if (m_compatMode) {
|
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);
|
* if (m_activeFeed != null && m_activeFeed.is_cat) {
|
||||||
findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
|
* findViewById
|
||||||
|
* (R.id.headlines_fragment).setVisibility(View.GONE);
|
||||||
refreshCategories();
|
* findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
|
||||||
} else { */
|
*
|
||||||
|
* refreshCategories(); } else {
|
||||||
|
*/
|
||||||
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
||||||
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
|
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
|
||||||
//}
|
// }
|
||||||
m_activeFeedId = 0;
|
m_activeFeedId = 0;
|
||||||
refreshViews();
|
refreshViews();
|
||||||
initMainMenu();
|
initMainMenu();
|
||||||
@ -300,49 +316,36 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override
|
/*
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
* @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
* (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) {
|
* if (m_activeFeed != null && m_activeFeed.is_cat) {
|
||||||
closeArticle();
|
* findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
||||||
} else if (m_activeFeedId != 0) {
|
* findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
|
||||||
if (m_compatMode) {
|
*
|
||||||
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));
|
* refreshCategories(); } else {
|
||||||
} */
|
*//*
|
||||||
|
* findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
||||||
/* if (m_activeFeed != null && m_activeFeed.is_cat) {
|
* findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); //}
|
||||||
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
* m_activeFeedId = 0; refreshViews(); initMainMenu();
|
||||||
findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);
|
*
|
||||||
|
* } else { finish(); } } else { if (m_selectedArticleId != 0) {
|
||||||
refreshCategories();
|
* closeArticle(); } else { finish(); } }
|
||||||
} else { */ /*
|
*
|
||||||
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
* return false; } return super.onKeyDown(keyCode, event); }
|
||||||
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) {
|
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);
|
new String[] { String.valueOf(articleId) }, null, null, null);
|
||||||
|
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
@ -372,13 +375,15 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
intent.putExtra(Intent.EXTRA_SUBJECT, title);
|
intent.putExtra(Intent.EXTRA_SUBJECT, title);
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, link);
|
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() {
|
private void refreshHeadlines() {
|
||||||
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
|
OfflineHeadlinesFragment ohf = (OfflineHeadlinesFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentById(R.id.headlines_fragment);
|
||||||
|
|
||||||
if (ohf != null) {
|
if (ohf != null) {
|
||||||
ohf.refresh();
|
ohf.refresh();
|
||||||
@ -387,7 +392,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
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()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.preferences:
|
case R.id.preferences:
|
||||||
@ -400,29 +406,38 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
case R.id.close_article:
|
case R.id.close_article:
|
||||||
closeArticle();
|
closeArticle();
|
||||||
return true;
|
return true;
|
||||||
case R.id.back_to_categories:
|
/* case R.id.back_to_categories:
|
||||||
//closeCategory();
|
// closeCategory();
|
||||||
return true;
|
return true; */
|
||||||
case R.id.headlines_select:
|
case R.id.headlines_select:
|
||||||
if (ohf != null) {
|
if (ohf != null) {
|
||||||
Dialog dialog = new Dialog(this);
|
Dialog dialog = new Dialog(this);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.headlines_select_dialog);
|
builder.setTitle(R.string.headlines_select_dialog);
|
||||||
|
|
||||||
builder.setSingleChoiceItems(new String[] { getString(R.string.headlines_select_all),
|
builder.setSingleChoiceItems(new String[] {
|
||||||
getString(R.string.headlines_select_unread), getString(R.string.headlines_select_none) }, 0, new DialogInterface.OnClickListener() {
|
getString(R.string.headlines_select_all),
|
||||||
|
getString(R.string.headlines_select_unread),
|
||||||
|
getString(R.string.headlines_select_none) }, 0,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case 0:
|
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.bindLong(1, m_activeFeedId);
|
||||||
stmtSelectAll.execute();
|
stmtSelectAll.execute();
|
||||||
stmtSelectAll.close();
|
stmtSelectAll.close();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
SQLiteStatement stmtSelectUnread = getWritableDb().compileStatement("UPDATE articles SET selected = 1 WHERE feed_id = ? AND unread = 1");
|
SQLiteStatement stmtSelectUnread = getWritableDb()
|
||||||
stmtSelectUnread.bindLong(1, m_activeFeedId);
|
.compileStatement(
|
||||||
|
"UPDATE articles SET selected = 1 WHERE feed_id = ? AND unread = 1");
|
||||||
|
stmtSelectUnread
|
||||||
|
.bindLong(1, m_activeFeedId);
|
||||||
stmtSelectUnread.execute();
|
stmtSelectUnread.execute();
|
||||||
stmtSelectUnread.close();
|
stmtSelectUnread.close();
|
||||||
break;
|
break;
|
||||||
@ -444,7 +459,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.headlines_mark_as_read:
|
case R.id.headlines_mark_as_read:
|
||||||
if (m_activeFeedId != 0) {
|
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.bindLong(1, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -456,7 +472,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.toggle_marked:
|
case R.id.toggle_marked:
|
||||||
if (m_selectedArticleId != 0) {
|
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.bindLong(1, m_selectedArticleId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -468,7 +486,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_unread:
|
case R.id.selection_toggle_unread:
|
||||||
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
|
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.bindLong(1, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -477,7 +497,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_marked:
|
case R.id.selection_toggle_marked:
|
||||||
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
|
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.bindLong(1, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -486,7 +508,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_published:
|
case R.id.selection_toggle_published:
|
||||||
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
|
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.bindLong(1, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -495,7 +519,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.toggle_published:
|
case R.id.toggle_published:
|
||||||
if (m_selectedArticleId != 0) {
|
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.bindLong(1, m_selectedArticleId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -504,8 +530,10 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.catchup_above:
|
case R.id.catchup_above:
|
||||||
if (m_selectedArticleId != 0 && m_activeFeedId != 0) {
|
if (m_selectedArticleId != 0 && m_activeFeedId != 0) {
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 WHERE updated >= " +
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
"(SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) AND feed_id = ?");
|
"UPDATE articles SET unread = 0 WHERE updated >= "
|
||||||
|
+ "(SELECT updated FROM articles WHERE "
|
||||||
|
+ BaseColumns._ID + " = ?) AND feed_id = ?");
|
||||||
stmt.bindLong(1, m_selectedArticleId);
|
stmt.bindLong(1, m_selectedArticleId);
|
||||||
stmt.bindLong(2, m_activeFeedId);
|
stmt.bindLong(2, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
@ -515,7 +543,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.set_unread:
|
case R.id.set_unread:
|
||||||
if (m_selectedArticleId != 0) {
|
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.bindLong(1, m_selectedArticleId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -533,13 +563,15 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId());
|
Log.d(TAG,
|
||||||
|
"onOptionsItemSelected, unhandled id=" + item.getItemId());
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshFeeds() {
|
private void refreshFeeds() {
|
||||||
OfflineFeedsFragment frag = (OfflineFeedsFragment)getSupportFragmentManager().findFragmentById(R.id.feeds_fragment);
|
OfflineFeedsFragment frag = (OfflineFeedsFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentById(R.id.feeds_fragment);
|
||||||
|
|
||||||
if (frag != null) {
|
if (frag != null) {
|
||||||
frag.refresh();
|
frag.refresh();
|
||||||
@ -548,7 +580,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
private void closeArticle() {
|
private void closeArticle() {
|
||||||
if (m_compatMode) {
|
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) {
|
if (m_smallScreenMode) {
|
||||||
@ -568,7 +601,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getSelectedArticleCount() {
|
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();
|
c.moveToFirst();
|
||||||
int selected = c.getInt(0);
|
int selected = c.getInt(0);
|
||||||
c.close();
|
c.close();
|
||||||
@ -579,58 +614,24 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
@Override
|
@Override
|
||||||
public void initMainMenu() {
|
public void initMainMenu() {
|
||||||
if (m_menu != null) {
|
if (m_menu != null) {
|
||||||
|
int numSelected = getSelectedArticleCount();
|
||||||
|
|
||||||
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
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, 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_headlines_selection, false);
|
|
||||||
|
|
||||||
if (m_selectedArticleId != 0) {
|
if (numSelected != 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);
|
|
||||||
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true);
|
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, 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 {
|
} else {
|
||||||
m_menu.setGroupVisible(R.id.menu_group_feeds, true);
|
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
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
@ -654,10 +655,13 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
||||||
|
.getMenuInfo();
|
||||||
|
|
||||||
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
|
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager()
|
||||||
OfflineFeedsFragment ff = (OfflineFeedsFragment)getSupportFragmentManager().findFragmentById(R.id.feeds_fragment);
|
.findFragmentById(R.id.headlines_fragment);
|
||||||
|
OfflineFeedsFragment ff = (OfflineFeedsFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentById(R.id.feeds_fragment);
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.browse_articles:
|
case R.id.browse_articles:
|
||||||
@ -674,7 +678,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
int feedId = ff.getFeedIdAtPosition(info.position);
|
int feedId = ff.getFeedIdAtPosition(info.position);
|
||||||
|
|
||||||
if (feedId != 0) {
|
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.bindLong(1, feedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -684,7 +689,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_unread:
|
case R.id.selection_toggle_unread:
|
||||||
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
|
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.bindLong(1, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -692,8 +699,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
} else {
|
} else {
|
||||||
int articleId = hf.getArticleIdAtPosition(info.position);
|
int articleId = hf.getArticleIdAtPosition(info.position);
|
||||||
if (articleId != 0) {
|
if (articleId != 0) {
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = NOT unread WHERE " +
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
BaseColumns._ID + " = ?");
|
"UPDATE articles SET unread = NOT unread WHERE "
|
||||||
|
+ BaseColumns._ID + " = ?");
|
||||||
stmt.bindLong(1, articleId);
|
stmt.bindLong(1, articleId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -703,7 +711,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_marked:
|
case R.id.selection_toggle_marked:
|
||||||
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
|
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.bindLong(1, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -711,8 +721,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
} else {
|
} else {
|
||||||
int articleId = hf.getArticleIdAtPosition(info.position);
|
int articleId = hf.getArticleIdAtPosition(info.position);
|
||||||
if (articleId != 0) {
|
if (articleId != 0) {
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET marked = NOT marked WHERE " +
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
BaseColumns._ID + " = ?");
|
"UPDATE articles SET marked = NOT marked WHERE "
|
||||||
|
+ BaseColumns._ID + " = ?");
|
||||||
stmt.bindLong(1, articleId);
|
stmt.bindLong(1, articleId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -722,7 +733,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_published:
|
case R.id.selection_toggle_published:
|
||||||
if (getSelectedArticleCount() > 0 && m_activeFeedId != 0) {
|
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.bindLong(1, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -730,8 +743,9 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
} else {
|
} else {
|
||||||
int articleId = hf.getArticleIdAtPosition(info.position);
|
int articleId = hf.getArticleIdAtPosition(info.position);
|
||||||
if (articleId != 0) {
|
if (articleId != 0) {
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET published = NOT published WHERE " +
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
BaseColumns._ID + " = ?");
|
"UPDATE articles SET published = NOT published WHERE "
|
||||||
|
+ BaseColumns._ID + " = ?");
|
||||||
stmt.bindLong(1, articleId);
|
stmt.bindLong(1, articleId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -750,8 +764,10 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
int articleId = hf.getArticleIdAtPosition(info.position);
|
int articleId = hf.getArticleIdAtPosition(info.position);
|
||||||
|
|
||||||
if (articleId != 0 && m_activeFeedId != 0) {
|
if (articleId != 0 && m_activeFeedId != 0) {
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 WHERE updated >= " +
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
"(SELECT updated FROM articles WHERE " + BaseColumns._ID + " = ?) AND feed_id = ?");
|
"UPDATE articles SET unread = 0 WHERE updated >= "
|
||||||
|
+ "(SELECT updated FROM articles WHERE "
|
||||||
|
+ BaseColumns._ID + " = ?) AND feed_id = ?");
|
||||||
stmt.bindLong(1, articleId);
|
stmt.bindLong(1, articleId);
|
||||||
stmt.bindLong(2, m_activeFeedId);
|
stmt.bindLong(2, m_activeFeedId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
@ -760,7 +776,8 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
|
Log.d(TAG,
|
||||||
|
"onContextItemSelected, unhandled id=" + item.getItemId());
|
||||||
return super.onContextItemSelected(item);
|
return super.onContextItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -773,16 +790,21 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||||
if (action == KeyEvent.ACTION_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 (nextId != 0 && ohf != null) {
|
||||||
if (m_prefs.getBoolean("combined_mode", false)) {
|
if (m_prefs.getBoolean("combined_mode", false)) {
|
||||||
ohf.setActiveArticleId(nextId);
|
ohf.setActiveArticleId(nextId);
|
||||||
|
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 " +
|
SQLiteStatement stmt = getWritableDb()
|
||||||
"WHERE " + BaseColumns._ID + " = ?");
|
.compileStatement(
|
||||||
|
"UPDATE articles SET unread = 0 "
|
||||||
|
+ "WHERE " + BaseColumns._ID
|
||||||
|
+ " = ?");
|
||||||
|
|
||||||
stmt.bindLong(1, nextId);
|
stmt.bindLong(1, nextId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
@ -797,16 +819,21 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||||
if (action == KeyEvent.ACTION_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 (prevId != 0 && ohf != null) {
|
||||||
if (m_prefs.getBoolean("combined_mode", false)) {
|
if (m_prefs.getBoolean("combined_mode", false)) {
|
||||||
ohf.setActiveArticleId(prevId);
|
ohf.setActiveArticleId(prevId);
|
||||||
|
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 " +
|
SQLiteStatement stmt = getWritableDb()
|
||||||
"WHERE " + BaseColumns._ID + " = ?");
|
.compileStatement(
|
||||||
|
"UPDATE articles SET unread = 0 "
|
||||||
|
+ "WHERE " + BaseColumns._ID
|
||||||
|
+ " = ?");
|
||||||
|
|
||||||
stmt.bindLong(1, prevId);
|
stmt.bindLong(1, prevId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
@ -828,33 +855,42 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRelativeArticleId(int baseId, int feedId, OnlineServices.RelativeArticle mode) {
|
public int getRelativeArticleId(int baseId, int feedId,
|
||||||
|
OnlineServices.RelativeArticle mode) {
|
||||||
|
|
||||||
Cursor c;
|
Cursor c;
|
||||||
|
|
||||||
/* if (baseId == 0) {
|
/*
|
||||||
c = getReadableDb().query("articles",
|
* if (baseId == 0) { c = getReadableDb().query("articles", null,
|
||||||
null, "feed_id = ?",
|
* "feed_id = ?", new String[] { String.valueOf(feedId) }, null, null,
|
||||||
new String[] { String.valueOf(feedId) }, null, null, "updated DESC LIMIT 1");
|
* "updated DESC LIMIT 1");
|
||||||
|
*
|
||||||
if (c.moveToFirst()) {
|
* if (c.moveToFirst()) { baseId = c.getInt(0); }
|
||||||
baseId = c.getInt(0);
|
*
|
||||||
}
|
* c.close();
|
||||||
|
*
|
||||||
c.close();
|
* return baseId; }
|
||||||
|
*/
|
||||||
return baseId;
|
|
||||||
} */
|
|
||||||
|
|
||||||
if (mode == RelativeArticle.BEFORE) {
|
if (mode == RelativeArticle.BEFORE) {
|
||||||
c = getReadableDb().query("articles",
|
c = getReadableDb().query(
|
||||||
null, "updated > (SELECT updated FROM articles WHERE "+BaseColumns._ID+" = ?) AND feed_id = ?",
|
"articles",
|
||||||
new String[] { String.valueOf(baseId), String.valueOf(feedId) }, null, null, "updated LIMIT 1");
|
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 {
|
} else {
|
||||||
c = getReadableDb().query("articles",
|
c = getReadableDb().query(
|
||||||
null, "updated < (SELECT updated FROM articles WHERE "+BaseColumns._ID+" = ?) AND feed_id = ?",
|
"articles",
|
||||||
new String[] { String.valueOf(baseId), String.valueOf(feedId) }, null, null, "updated DESC LIMIT 1");
|
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;
|
int id = 0;
|
||||||
@ -894,14 +930,16 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
initMainMenu();
|
initMainMenu();
|
||||||
|
|
||||||
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
|
OfflineHeadlinesFragment hf = (OfflineHeadlinesFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentById(R.id.headlines_fragment);
|
||||||
|
|
||||||
if (hf != null) {
|
if (hf != null) {
|
||||||
hf.setActiveArticleId(articleId);
|
hf.setActiveArticleId(articleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLiteStatement stmt = getWritableDb().compileStatement("UPDATE articles SET unread = 0 " +
|
SQLiteStatement stmt = getWritableDb().compileStatement(
|
||||||
"WHERE " + BaseColumns._ID + " = ?");
|
"UPDATE articles SET unread = 0 " + "WHERE " + BaseColumns._ID
|
||||||
|
+ " = ?");
|
||||||
|
|
||||||
stmt.bindLong(1, articleId);
|
stmt.bindLong(1, articleId);
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
@ -915,9 +953,11 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
|
|
||||||
if (m_compatMode) {
|
if (m_compatMode) {
|
||||||
if (compatAnimation == 0)
|
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
|
else
|
||||||
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, compatAnimation));
|
findViewById(R.id.main).setAnimation(
|
||||||
|
AnimationUtils.loadAnimation(this, compatAnimation));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_smallScreenMode) {
|
if (m_smallScreenMode) {
|
||||||
@ -929,7 +969,6 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
|||||||
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
|
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user