Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions res/layout/reader_listitem_post_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:layout_marginLeft="@dimen/reader_list_margin"
android:layout_marginRight="@dimen/reader_list_margin"
android:layout_marginTop="@dimen/reader_margin_large"
Expand Down
2 changes: 1 addition & 1 deletion res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dimen name="reader_margin_large">12dp</dimen>

<!-- left/right margin for posts in both list and detail views -->
<dimen name="reader_list_margin_normal">4dp</dimen>
<dimen name="reader_list_margin_normal">8dp</dimen>
<dimen name="reader_list_margin_landscape">48dp</dimen>
<dimen name="reader_list_margin_tablet">48dp</dimen>
<dimen name="reader_list_margin_landscape_tablet">96dp</dimen>
Expand Down
112 changes: 1 addition & 111 deletions src/org/wordpress/android/ui/reader_native/NativeReaderActivity.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package org.wordpress.android.ui.reader_native;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.Window;

import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;

import net.simonvt.menudrawer.MenuDrawer;

import org.wordpress.android.Constants;
import org.wordpress.android.R;
import org.wordpress.android.datasets.ReaderDatabase;
Expand All @@ -26,83 +20,33 @@
import org.wordpress.android.ui.reader_native.actions.ReaderUserActions;
import org.wordpress.android.util.NetworkUtils;
import org.wordpress.android.util.ReaderLog;
import org.wordpress.android.util.SysUtils;
import org.wordpress.android.util.ToastUtils;

/*
* created by nbradbury
* this activity serves as the host for ReaderPostListFragment
*/

public class NativeReaderActivity extends WPActionBarActivity implements ReaderPostListFragment.OnFirstVisibleItemChangeListener {
public class NativeReaderActivity extends WPActionBarActivity {
private static final String TAG_FRAGMENT_POST_LIST = "reader_post_list";
private static final String KEY_INITIAL_UPDATE = "initial_update";
private static final String KEY_HAS_PURGED = "has_purged";

// ActionBar alpha
protected static final int ALPHA_NONE = 0;
protected static final int ALPHA_LEVEL_1 = 245;
protected static final int ALPHA_LEVEL_2 = 230;
protected static final int ALPHA_LEVEL_3 = 215;
protected static final int ALPHA_LEVEL_4 = 200;
protected static final int ALPHA_LEVEL_5 = 185;

private int mCurrentActionBarAlpha = 0;
private int mPrevActionBarAlpha = 0;

private MenuItem mRefreshMenuItem;
private boolean mHasPerformedInitialUpdate = false;
private boolean mHasPerformedPurge = false;

/*
* enable translucent ActionBar on ICS+ (buggy/unsupported on older versions)
*/
protected static boolean isTranslucentActionBarEnabled() {
return (SysUtils.isGteAndroid4());
}

@SuppressLint("NewApi")
protected static void enableTranslucentActionBar(Activity activity) {
activity.getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

boolean isTranslucentActionBarEnabled = isTranslucentActionBarEnabled();
if (isTranslucentActionBarEnabled)
enableTranslucentActionBar(this);

setContentView(R.layout.reader_activity_main);

getSupportActionBar().setDisplayShowTitleEnabled(false);
setSupportProgressBarVisibility(false);

createMenuDrawer(R.layout.reader_activity_main);

if (isTranslucentActionBarEnabled && super.mMenuDrawer!=null) {
// disable ActionBar translucency when drawer is opening, restore it when closing
super.mMenuDrawer.setOnDrawerStateChangeListener(new MenuDrawer.OnDrawerStateChangeListener() {
@Override
public void onDrawerStateChange(int oldState, int newState) {
switch (newState) {
case MenuDrawer.STATE_OPENING :
mPrevActionBarAlpha = mCurrentActionBarAlpha;
setActionBarAlpha(ALPHA_NONE);
break;
case MenuDrawer.STATE_CLOSING:
setActionBarAlpha(mPrevActionBarAlpha);
break;
}
}
@Override
public void onDrawerSlide(float openRatio, int offsetPixels) {
// nop
}
});
}

if (savedInstanceState != null) {
mHasPerformedInitialUpdate = savedInstanceState.getBoolean(KEY_INITIAL_UPDATE);
mHasPerformedPurge = savedInstanceState.getBoolean(KEY_HAS_PURGED);
Expand Down Expand Up @@ -169,21 +113,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
break;

// user just returned from the login screen
/*case ReaderConst.INTENT_LOGIN :
if (isResultOK) {
if (readerFragment!=null) {
readerFragment.updateTagList();
readerFragment.updatePostsWithCurrentTag(ReaderActions.RequestDataAction.LOAD_NEWER);
} else {
showPostListFragment();
}
} else {
// login failed, so app is done
finish();
}
break;*/

// user just returned from post detail, reload the displayed post if it changed (will
// only be RESULT_OK if changed)
case Constants.INTENT_READER_POST_DETAIL:
Expand Down Expand Up @@ -287,43 +216,4 @@ private ReaderPostListFragment getPostListFragment() {
return null;
return ((ReaderPostListFragment) fragment);
}

/*
* called from post list - makes the ActionBar increasingly translucent as user scrolls
* through the first few posts in the list
*/
@Override
public void onFirstVisibleItemChanged(int firstVisibleItem) {
switch (firstVisibleItem) {
case 0:
setActionBarAlpha(ALPHA_LEVEL_1);
break;
case 1:
setActionBarAlpha(ALPHA_LEVEL_2);
break;
case 2 :
setActionBarAlpha(ALPHA_LEVEL_3);
break;
case 3 :
setActionBarAlpha(ALPHA_LEVEL_4);
break;
default:
setActionBarAlpha(ALPHA_LEVEL_5);
break;
}
}

protected void setActionBarAlpha(int alpha) {
if (alpha==mCurrentActionBarAlpha || !isTranslucentActionBarEnabled())
return;

// solid background if no alpha, otherwise create color drawable with alpha applied
// (source color is based on R.color.blue_new_kid)
if (alpha==ALPHA_NONE) {
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.blue_new_kid));
} else {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.argb(alpha, 46, 162, 204)));
}
mCurrentActionBarAlpha = alpha;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.wordpress.android.ui.reader_native;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
Expand All @@ -16,6 +16,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.view.inputmethod.EditorInfo;
Expand Down Expand Up @@ -199,9 +200,9 @@ private boolean isCommentAdapterEmpty() {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

boolean isTranslucentActionBarEnabled = NativeReaderActivity.isTranslucentActionBarEnabled();
if (isTranslucentActionBarEnabled)
NativeReaderActivity.enableTranslucentActionBar(this);
boolean isFullScreenSupported = isFullScreenSupported();
if (isFullScreenSupported)
enableActionBarOverlay();

mInflater = getLayoutInflater();
setContentView(R.layout.reader_activity_post_detail);
Expand All @@ -212,12 +213,8 @@ public void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

if (isTranslucentActionBarEnabled) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.argb(NativeReaderActivity.ALPHA_LEVEL_3, 46, 162, 204)));

// add a header to the listView that's the same height as the ActionBar - this moves
// the actual content of the listView below the ActionBar, but enables it to scroll under
// the translucent ActionBar layout
if (isFullScreenSupported) {
// add a header to the listView that's the same height as the ActionBar
final int actionbarHeight = DisplayUtils.getActionBarHeight(this);
RelativeLayout headerFake = new RelativeLayout(this);
headerFake.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, actionbarHeight));
Expand All @@ -243,7 +240,6 @@ public void onCreate(Bundle savedInstanceState) {
mLayoutIcons = (ViewGroup) findViewById(R.id.layout_actions);
mLayoutLikes = (ViewGroup) findViewById(R.id.layout_likes);


// setup the webView - note that JavaScript is disabled since it's a security risk:
// http://developer.android.com/training/articles/security-tips.html#WebView
mWebView = (WebView) findViewById(R.id.webView);
Expand Down Expand Up @@ -318,12 +314,16 @@ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
}

/*
* auto-hiding the ActionBar and icon bar is jittery/buggy when the translucent ActionBar
* isn't enabled (which it won't be on pre-ICS devices), so disable full-screen mode
* when the translucent ActionBar isn't enabled
* auto-hiding the ActionBar and icon bar is jittery/buggy on Gingerbread (and probably other
* pre-ICS devices), and requires the ActionBar overlay (ICS or later)
*/
private boolean isFullScreenSupported() {
return NativeReaderActivity.isTranslucentActionBarEnabled();
return (SysUtils.isGteAndroid4());
}

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
protected void enableActionBarOverlay() {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
}

/*
Expand Down
Loading