properly detect portrait orientation

move to ICS style of naming resources for various dpi
bump version
This commit is contained in:
Andrew Dolgov 2012-09-01 22:22:13 +04:00
parent 77352728e7
commit b826481001
15 changed files with 21 additions and 15 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss" package="org.fox.ttrss"
android:versionCode="87" android:versionCode="88"
android:versionName="0.6.11" > android:versionName="0.6.12" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11" /> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11" />

View File

@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.util.Log; import android.util.Log;
import android.view.Display;
import android.widget.Toast; import android.widget.Toast;
public class CommonActivity extends FragmentActivity { public class CommonActivity extends FragmentActivity {
@ -70,8 +71,13 @@ public class CommonActivity extends FragmentActivity {
return m_compatMode; return m_compatMode;
} }
public int getOrientation() { public boolean isPortrait() {
return getWindowManager().getDefaultDisplay().getOrientation(); Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
return width < height;
} }
public void copyToClipboard(String str) { public void copyToClipboard(String str) {

View File

@ -146,7 +146,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
//list.setEmptyView(view.findViewById(R.id.no_headlines)); //list.setEmptyView(view.findViewById(R.id.no_headlines));
registerForContextMenu(list); registerForContextMenu(list);
if (m_onlineServices.isSmallScreen() || m_onlineServices.getOrientation() % 2 != 0) if (m_onlineServices.isSmallScreen() || m_onlineServices.isPortrait())
view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0); view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0);
Log.d(TAG, "onCreateView, feed=" + m_feed); Log.d(TAG, "onCreateView, feed=" + m_feed);

View File

@ -660,7 +660,7 @@ public class MainActivity extends CommonActivity implements OnlineServices {
if (!isCompatMode()) { if (!isCompatMode()) {
if (!isSmallScreen()) { if (!isSmallScreen()) {
findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticle != null && getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE); findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticle != null && isPortrait() ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(m_selectedArticle != null ? View.VISIBLE : View.GONE); findViewById(R.id.article_fragment).setVisibility(m_selectedArticle != null ? View.VISIBLE : View.GONE);
} }
@ -1414,7 +1414,7 @@ public class MainActivity extends CommonActivity implements OnlineServices {
m_navigationAdapter.clear(); m_navigationAdapter.clear();
if (m_activeCategory != null || (m_activeFeed != null && (isSmallScreen() || getOrientation() % 2 != 0))) { if (m_activeCategory != null || (m_activeFeed != null && (isSmallScreen() || isPortrait()))) {
getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
@ -1862,11 +1862,11 @@ public class MainActivity extends CommonActivity implements OnlineServices {
ft.hide(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES)); ft.hide(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES));
ft.add(R.id.fragment_container, frag, FRAG_ARTICLE); ft.add(R.id.fragment_container, frag, FRAG_ARTICLE);
} else { } else {
findViewById(R.id.feeds_fragment).setVisibility(getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE); findViewById(R.id.feeds_fragment).setVisibility(isPortrait() ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
ft.replace(R.id.article_fragment, frag, FRAG_ARTICLE); ft.replace(R.id.article_fragment, frag, FRAG_ARTICLE);
if (getOrientation() % 2 == 0) refresh(); if (!isPortrait()) refresh();
} }
ft.commit(); ft.commit();
} }

View File

@ -25,7 +25,7 @@ public interface OnlineServices {
public boolean isSmallScreen(); public boolean isSmallScreen();
public boolean getUnreadOnly(); public boolean getUnreadOnly();
public int getApiLevel(); public int getApiLevel();
public int getOrientation(); public boolean isPortrait();
public void copyToClipboard(String str); public void copyToClipboard(String str);
} }

View File

@ -292,7 +292,7 @@ public class OfflineActivity extends CommonActivity implements
if (!isCompatMode()) { if (!isCompatMode()) {
if (!isSmallScreen()) { if (!isSmallScreen()) {
findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticleId != 0 && getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE); findViewById(R.id.feeds_fragment).setVisibility(m_selectedArticleId != 0 && isPortrait() ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(m_selectedArticleId != 0 ? View.VISIBLE : View.GONE); findViewById(R.id.article_fragment).setVisibility(m_selectedArticleId != 0 ? View.VISIBLE : View.GONE);
} }
@ -1397,7 +1397,7 @@ public class OfflineActivity extends CommonActivity implements
ft.hide(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES)); ft.hide(getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES));
ft.add(R.id.fragment_container, frag, FRAG_ARTICLE); ft.add(R.id.fragment_container, frag, FRAG_ARTICLE);
} else { } else {
findViewById(R.id.feeds_fragment).setVisibility(getOrientation() % 2 != 0 ? View.GONE : View.VISIBLE); findViewById(R.id.feeds_fragment).setVisibility(isPortrait() ? View.GONE : View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE);
ft.replace(R.id.article_fragment, frag, FRAG_ARTICLE); ft.replace(R.id.article_fragment, frag, FRAG_ARTICLE);
@ -1445,7 +1445,7 @@ public class OfflineActivity extends CommonActivity implements
m_navigationAdapter.clear(); m_navigationAdapter.clear();
if (m_activeCatId != -1 || (m_activeFeedId != 0 && (isSmallScreen() || getOrientation() % 2 != 0))) { if (m_activeCatId != -1 || (m_activeFeedId != 0 && (isSmallScreen() || isPortrait()))) {
getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

View File

@ -150,7 +150,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_offlineServices.isSmallScreen() || m_offlineServices.getOrientation() % 2 != 0) if (m_offlineServices.isSmallScreen() || m_offlineServices.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);

View File

@ -18,5 +18,5 @@ public interface OfflineServices {
public boolean isSmallScreen(); public boolean isSmallScreen();
public void setSelectedArticleId(int articleId); public void setSelectedArticleId(int articleId);
public boolean activeFeedIsCat(); public boolean activeFeedIsCat();
public int getOrientation(); public boolean isPortrait();
} }