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
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ dependencies {

android {

compileSdkVersion 18
buildToolsVersion "18.0.1"
compileSdkVersion 19
buildToolsVersion "19"

defaultConfig {
packageName "org.wordpress.android"
versionName "2.5"
versionCode 83
versionName "2.5.1"
versionCode 84
minSdkVersion 9
targetSdkVersion 18
targetSdkVersion 19
}

sourceSets {
Expand Down
5 changes: 5 additions & 0 deletions src/org/wordpress/android/WordPress.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ public void authenticate(WPRestClient.Request request) {
// get the access token from api key field
token = blog.getApi_key();

// valid oauth tokens are 64 chars
if (token != null && token.length() < 64 && !blog.isDotcomFlag()) {
token = null;
}

// if there is no access token, but this is the dotcom flag
if (token == null && (blog.isDotcomFlag() &&
blog.getUsername().equals(settings.getString(WPCOM_USERNAME_PREFERENCE, "")))) {
Expand Down
12 changes: 12 additions & 0 deletions src/org/wordpress/android/models/Blog.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,16 @@ public boolean isPhotonCapable() {
public boolean hasValidJetpackCredentials() {
return !TextUtils.isEmpty(getDotcom_username()) && !TextUtils.isEmpty(getDotcom_password());
}

/**
* Get the WordPress.com blog ID
* Stored in blogId for WP.com, api_blogId for Jetpack
* @return WP.com blogId string, potentially null for Jetpack sites
*/
public String getDotComBlogId() {
if (isDotcomFlag())
return String.valueOf(getBlogId());
else
return getApi_blogid();
}
}
7 changes: 0 additions & 7 deletions src/org/wordpress/android/ui/stats/StatsAbsViewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,4 @@ protected StatsViewType getViewType() {
}

public abstract String getTitle();

protected String getCurrentBlogId() {
if (WordPress.getCurrentBlog() != null)
return String.valueOf(WordPress.getCurrentBlog().getBlogId());
return null;
}

}
21 changes: 8 additions & 13 deletions src/org/wordpress/android/ui/stats/StatsActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.wordpress.android.ui.stats;

import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
Expand All @@ -12,27 +16,26 @@
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.android.volley.VolleyError;

import org.json.JSONException;
import org.json.JSONObject;
import org.xmlrpc.android.ApiHelper;
import org.xmlrpc.android.XMLRPCCallback;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;

import org.wordpress.android.R;
import org.wordpress.android.WordPress;
Expand All @@ -42,14 +45,6 @@
import org.wordpress.android.ui.WPActionBarActivity;
import org.wordpress.android.util.StatsRestHelper;
import org.wordpress.android.util.Utils;
import org.xmlrpc.android.ApiHelper;
import org.xmlrpc.android.XMLRPCCallback;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;

import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;

/**
* The native stats activity, accessible via the menu drawer.
Expand Down
4 changes: 3 additions & 1 deletion src/org/wordpress/android/ui/stats/StatsCursorFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.support.v4.content.Loader;
import android.support.v4.widget.CursorAdapter;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -128,7 +129,8 @@ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (WordPress.getCurrentBlog() == null)
return null;

String blogId = String.valueOf(WordPress.getCurrentBlog().getBlogId());
String blogId = WordPress.getCurrentBlog().getDotComBlogId();
if (TextUtils.isEmpty(blogId)) blogId = "0";
CursorLoader cursorLoader = new CursorLoader(getActivity(), getUri(), null, "blogId=?", new String[] { blogId }, null);
return cursorLoader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.text.Html;
import android.text.TextUtils;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -153,7 +154,8 @@ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (WordPress.getCurrentBlog() == null)
return null;

String blogId = String.valueOf(WordPress.getCurrentBlog().getBlogId());
String blogId = WordPress.getCurrentBlog().getDotComBlogId();
if (TextUtils.isEmpty(blogId)) blogId = "0";

Uri uri = getGroupUri();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -85,13 +86,17 @@ public void onResume() {
private void refreshSummary() {
if (WordPress.getCurrentBlog() == null)
return;

final String blogId = String.valueOf(WordPress.getCurrentBlog().getBlogId());

String blogId = WordPress.getCurrentBlog().getDotComBlogId();
if (TextUtils.isEmpty(blogId))
blogId = "0";

final String statsBlogId = blogId;
new AsyncTask<Void, Void, StatsSummary>() {

@Override
protected StatsSummary doInBackground(Void... params) {
return StatUtils.getSummary(blogId);
return StatUtils.getSummary(statsBlogId);
}

protected void onPostExecute(final StatsSummary result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -237,8 +238,9 @@ public void onActivityCreated(Bundle savedInstanceState) {
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (WordPress.getCurrentBlog() == null)
return null;

String blogId = String.valueOf(WordPress.getCurrentBlog().getBlogId());

String blogId = WordPress.getCurrentBlog().getDotComBlogId();
if (TextUtils.isEmpty(blogId)) blogId = "0";
StatsBarChartUnit unit = getBarChartUnit();
return new CursorLoader(getActivity(), getUri(), null, "blogId=? AND unit=?", new String[] { blogId, unit.name() }, null);
}
Expand Down