use onbackpressed instead of onkeydown
This commit is contained in:
parent
160115b84c
commit
b8c96d0cc0
@ -4,11 +4,11 @@
|
||||
|
||||
<group android:id="@+id/menu_group_feeds" >
|
||||
|
||||
<item
|
||||
<!-- <item
|
||||
android:id="@+id/back_to_categories"
|
||||
android:icon="@android:drawable/ic_menu_close_clear_cancel"
|
||||
android:showAsAction=""
|
||||
android:title="@string/back_to_categories"/>
|
||||
android:title="@string/back_to_categories"/> -->
|
||||
|
||||
<item
|
||||
android:id="@+id/show_feeds"
|
||||
|
@ -432,8 +432,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
}
|
||||
|
||||
if (m_isOffline) {
|
||||
Intent refresh = new Intent(this, OfflineActivity.class);
|
||||
startActivity(refresh);
|
||||
Intent offline = new Intent(MainActivity.this, OfflineActivity.class);
|
||||
startActivity(offline);
|
||||
finish();
|
||||
} else {
|
||||
List<PackageInfo> pkgs = getPackageManager().getInstalledPackages(0);
|
||||
@ -450,6 +450,12 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
if (m_enableCats && !m_prefs.getBoolean("browse_cats_like_feeds", false)) {
|
||||
m_rootTab = m_bar.newTab().setText("Categories").setTabListener(new RootTabListener());
|
||||
m_bar.addTab(m_rootTab);
|
||||
|
||||
if (m_activeCategory != null) {
|
||||
m_feedTab = m_bar.newTab().setText(m_activeCategory.title).setTabListener(new CategoryTabListener(m_activeCategory));
|
||||
m_bar.addTab(m_feedTab);
|
||||
m_bar.selectTab(m_feedTab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -565,8 +571,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
editor.putBoolean("offline_mode_active", true);
|
||||
editor.commit();
|
||||
|
||||
Intent refresh = new Intent(this, OfflineActivity.class);
|
||||
startActivity(refresh);
|
||||
Intent offline = new Intent(MainActivity.this, OfflineActivity.class);
|
||||
startActivity(offline);
|
||||
finish();
|
||||
|
||||
}
|
||||
@ -607,7 +613,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
m_prefs.getBoolean("enable_cats", false) != m_enableCats;
|
||||
|
||||
if (needRefresh) {
|
||||
Intent refresh = new Intent(this, MainActivity.class);
|
||||
Intent refresh = new Intent(MainActivity.this, MainActivity.class);
|
||||
startActivity(refresh);
|
||||
finish();
|
||||
} else if (m_sessionId != null) {
|
||||
@ -655,6 +661,53 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (m_smallScreenMode) {
|
||||
if (m_selectedArticle != null) {
|
||||
closeArticle();
|
||||
} else if (m_activeFeed != null) {
|
||||
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);
|
||||
|
||||
refreshFeeds();
|
||||
}
|
||||
m_activeFeed = null;
|
||||
|
||||
|
||||
initMainMenu();
|
||||
|
||||
} else if (m_activeCategory != null) {
|
||||
if (m_compatMode) {
|
||||
findViewById(R.id.main).setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));
|
||||
}
|
||||
|
||||
closeCategory();
|
||||
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
if (m_selectedArticle != null) {
|
||||
closeArticle();
|
||||
} else if (m_activeCategory != null) {
|
||||
closeCategory();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
|
||||
@ -705,7 +758,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
return false;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
} */
|
||||
|
||||
private void closeCategory() {
|
||||
|
||||
@ -729,7 +782,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.preferences:
|
||||
Intent intent = new Intent(this, PreferencesActivity.class);
|
||||
Intent intent = new Intent(MainActivity.this, PreferencesActivity.class);
|
||||
startActivityForResult(intent, 0);
|
||||
return true;
|
||||
case R.id.update_feeds:
|
||||
@ -750,9 +803,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
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 (hf != null) {
|
||||
Dialog dialog = new Dialog(this);
|
||||
@ -1021,7 +1074,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
m_menu.findItem(R.id.update_feeds).setVisible(true);
|
||||
} */
|
||||
|
||||
m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null);
|
||||
//m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -265,6 +265,42 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
|
||||
@ -274,14 +310,14 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
||||
} 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 { */
|
||||
} else { */ /*
|
||||
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
||||
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
|
||||
//}
|
||||
@ -303,7 +339,7 @@ public class OfflineActivity extends FragmentActivity implements OfflineServices
|
||||
return false;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
} */
|
||||
|
||||
private Cursor getArticleById(int articleId) {
|
||||
Cursor c = getReadableDb().query("articles", null, BaseColumns._ID + "=?",
|
||||
|
@ -203,7 +203,7 @@ public class OfflineDownloadService extends IntentService {
|
||||
req.execute(map);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
/* @SuppressWarnings("unchecked")
|
||||
private void switchOffline() {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this).
|
||||
@ -292,7 +292,7 @@ public class OfflineDownloadService extends IntentService {
|
||||
AlertDialog dlg = builder.create();
|
||||
dlg.show();
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
public void download() {
|
||||
if (!m_downloadInProgress) {
|
||||
|
Loading…
Reference in New Issue
Block a user