Skip to content

Commit

Permalink
Adding an mShouldFinish boolean to WPActionBarActivity so that we can…
Browse files Browse the repository at this point in the history
… track which activities should finish after a new activity is started from the Menu Drawer. Fixes #428

Also added an experimental new flat WP icon for the ActionBar. I think I like it.
  • Loading branch information
roundhill committed Mar 12, 2013
1 parent 5e7df10 commit 8fad226
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ res/drawable-hdpi/ab_icon_navigation_down.png -text
res/drawable-hdpi/ab_icon_navigation_up.png -text
res/drawable-hdpi/ab_icon_save.png -text
res/drawable-hdpi/ab_icon_share.png -text
res/drawable-hdpi/ab_icon_wp.png -text
res/drawable-hdpi/ab_solid_wordpress.9.png -text
res/drawable-hdpi/ab_stacked_solid_wordpress.9.png -text
res/drawable-hdpi/ab_transparent_wordpress.9.png -text
Expand Down Expand Up @@ -77,6 +78,7 @@ res/drawable-hdpi/wp_small_toggle.9.png -text
res/drawable-hdpi/wp_statusbar_icon.png -text
res/drawable-large-mdpi/wp_logo_actionbar.png -text
res/drawable-ldpi-v11/notification_icon.png -text
res/drawable-ldpi/ab_icon_wp.png -text
res/drawable-ldpi/app_icon.png -text
res/drawable-ldpi/notification_icon.png -text
res/drawable-mdpi-v11/notification_icon.png -text
Expand All @@ -86,6 +88,7 @@ res/drawable-mdpi/ab_icon_navigation_up.png -text
res/drawable-mdpi/ab_icon_save.png -text
res/drawable-mdpi/ab_icon_share.png -text
res/drawable-mdpi/ab_icon_web.png -text
res/drawable-mdpi/ab_icon_wp.png -text
res/drawable-mdpi/ab_solid_wordpress.9.png -text
res/drawable-mdpi/ab_stacked_solid_wordpress.9.png -text
res/drawable-mdpi/ab_transparent_wordpress.9.png -text
Expand Down Expand Up @@ -116,6 +119,7 @@ res/drawable-xhdpi/ab_icon_navigation_up.png -text
res/drawable-xhdpi/ab_icon_save.png -text
res/drawable-xhdpi/ab_icon_share.png -text
res/drawable-xhdpi/ab_icon_web.png -text
res/drawable-xhdpi/ab_icon_wp.png -text
res/drawable-xhdpi/ab_solid_wordpress.9.png -text
res/drawable-xhdpi/ab_stacked_solid_wordpress.9.png -text
res/drawable-xhdpi/ab_transparent_wordpress.9.png -text
Expand Down
3 changes: 2 additions & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
</activity>
<activity
android:name="org.wordpress.android.ui.DashboardActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTask" />
<activity
android:name="org.wordpress.android.ui.reader.ReaderPagerActivity"
android:configChanges="orientation|keyboardHidden|screenSize" />
Expand Down
Binary file added res/drawable-hdpi/ab_icon_wp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-ldpi/ab_icon_wp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ab_icon_wp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ab_icon_wp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions res/layout-sw720dp/comments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
android:id="@+id/commentFragmentContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/action_bar_height">
android:orientation="horizontal">
<FrameLayout
android:layout_weight="1"
android:layout_width="0dp"
Expand Down
2 changes: 2 additions & 0 deletions res/values-v14/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
</style>

<style name="wordpress_solid_ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="android:icon">@drawable/ab_icon_wp</item>
<item name="icon">@drawable/ab_icon_wp</item>
<item name="android:background">@drawable/ab_solid_wordpress</item>
<item name="background">@drawable/ab_solid_wordpress</item>

Expand Down
3 changes: 2 additions & 1 deletion res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<style name="wordpress_solid_ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/ab_solid_wordpress</item>
<item name="background">@drawable/ab_solid_wordpress</item>

<item name="android:icon">@drawable/ab_icon_wp</item>
<item name="icon">@drawable/ab_icon_wp</item>
<item name="backgroundStacked">@drawable/ab_stacked_solid_wordpress</item>

<item name="backgroundSplit">@drawable/ab_bottom_solid_wordpress</item>
Expand Down
25 changes: 22 additions & 3 deletions src/org/wordpress/android/ui/WPActionBarActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public abstract class WPActionBarActivity extends SherlockFragmentActivity imple
protected MenuDrawer menuDrawer;
private static int[] blogIDs;
protected boolean isAnimatingRefreshButton;
protected boolean mShouldFinish;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -67,10 +68,14 @@ public void onCreate(Bundle savedInstanceState) {
@Override
protected void onPause() {
super.onPause();
overridePendingTransition(0, 0);

if (isAnimatingRefreshButton) {
isAnimatingRefreshButton = false;
}
if (mShouldFinish) {
overridePendingTransition(0, 0);
finish();
}
}

@Override
Expand Down Expand Up @@ -115,16 +120,20 @@ protected void createMenuDrawer(int contentView) {
LinearLayout postsButton = (LinearLayout) findViewById(R.id.menu_posts_btn);
postsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
menuDrawer.closeMenu();
if (!(WPActionBarActivity.this instanceof PostsActivity))
mShouldFinish = true;
Intent i = new Intent(WPActionBarActivity.this, PostsActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
menuDrawer.closeMenu();
startActivityWithDelay(i);
}
});

LinearLayout pagesButton = (LinearLayout) findViewById(R.id.menu_pages_btn);
pagesButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (!(WPActionBarActivity.this instanceof PostsActivity))
mShouldFinish = true;
Intent i = new Intent(WPActionBarActivity.this, PostsActivity.class);
i.putExtra("id", WordPress.currentBlog.getId());
i.putExtra("isNew", true);
Expand All @@ -138,6 +147,8 @@ public void onClick(View v) {
LinearLayout commentsButton = (LinearLayout) findViewById(R.id.menu_comments_btn);
commentsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (!(WPActionBarActivity.this instanceof CommentsActivity))
mShouldFinish = true;
Intent i = new Intent(WPActionBarActivity.this, CommentsActivity.class);
i.putExtra("id", WordPress.currentBlog.getId());
i.putExtra("isNew", true);
Expand All @@ -150,6 +161,7 @@ public void onClick(View v) {
LinearLayout picButton = (LinearLayout) findViewById(R.id.menu_quickphoto_btn);
picButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mShouldFinish = false;
PackageManager pm = WPActionBarActivity.this.getPackageManager();
Intent i = new Intent(WPActionBarActivity.this, EditPostActivity.class);
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
Expand All @@ -166,6 +178,7 @@ public void onClick(View v) {
LinearLayout videoButton = (LinearLayout) findViewById(R.id.menu_quickvideo_btn);
videoButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mShouldFinish = false;
PackageManager pm = WPActionBarActivity.this.getPackageManager();
Intent i = new Intent(WPActionBarActivity.this, EditPostActivity.class);
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
Expand All @@ -182,6 +195,8 @@ public void onClick(View v) {
LinearLayout statsButton = (LinearLayout) findViewById(R.id.menu_stats_btn);
statsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (!(WPActionBarActivity.this instanceof ViewWebStatsActivity))
mShouldFinish = true;
Intent i = new Intent(WPActionBarActivity.this, ViewWebStatsActivity.class);
i.putExtra("id", WordPress.currentBlog.getId());
i.putExtra("isNew", true);
Expand All @@ -194,6 +209,7 @@ public void onClick(View v) {
LinearLayout dashboardButton = (LinearLayout) findViewById(R.id.menu_dashboard_btn);
dashboardButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mShouldFinish = false;
Intent i = new Intent(WPActionBarActivity.this, DashboardActivity.class);
i.putExtra("loadAdmin", true);
i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
Expand All @@ -205,8 +221,8 @@ public void onClick(View v) {
LinearLayout settingsButton = (LinearLayout) findViewById(R.id.menu_settings_btn);
settingsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mShouldFinish = false;
Intent i = new Intent(WPActionBarActivity.this, PreferencesActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
menuDrawer.closeMenu();
startActivityWithDelay(i);
}
Expand All @@ -215,6 +231,8 @@ public void onClick(View v) {
LinearLayout readButton = (LinearLayout) findViewById(R.id.menu_reader_btn);
readButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (!(WPActionBarActivity.this instanceof ReaderPagerActivity))
mShouldFinish = true;
int readerBlogID = WordPress.wpDB.getWPCOMBlogID();
if (WordPress.currentBlog.isDotcomFlag()) {
Intent i = new Intent(WPActionBarActivity.this, ReaderPagerActivity.class);
Expand Down Expand Up @@ -342,6 +360,7 @@ public void setupCurrentBlog() {
// no blogs are configured, so display new account activity
if (currentBlog == null) {
Log.d(TAG, "No accounts configured. Sending user to set up an account");
mShouldFinish = false;
Intent i = new Intent(this, NewAccountActivity.class);
startActivityForResult(i, ADD_ACCOUNT_REQUEST);
return;
Expand Down
3 changes: 1 addition & 2 deletions src/org/wordpress/android/ui/reader/ReaderPagerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ public void onClick(View v) {

@Override
protected void onPause() {
super.onPause();
if (refreshMenuItem != null && isAnimatingRefreshButton)
this.stopAnimatingButton();

super.onPause();
}

@Override
Expand Down

0 comments on commit 8fad226

Please sign in to comment.