1. Frederik Hahne
  2. bitbeaker

Commits

Ville Saalo  committed c133e8a

Replacing code that uses API level greater than the minimum level that we support.

  • Participants
  • Parent commits e56e6ed
  • Branches default

Comments (0)

Files changed (1)

File src/com/saibotd/bitbeaker/activities/LauncherActivity.java

View file
  • Ignore whitespace
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import com.saibotd.bitbeaker.Helper;
-import com.saibotd.bitbeaker.R;
-import com.saibotd.bitbeaker.R.string;
-
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
 
+import com.saibotd.bitbeaker.Helper;
+import com.saibotd.bitbeaker.R;
+
 public class LauncherActivity extends MyActivity {
 	private enum Mode {CHANGESETS, MAIN_PAGE, ISSUE, OTHER};
 	private Bundle b;
 		}
 		
 		// user's RSS news feed
-		if (segments.size() == 3 && segments.get(1).equals("rss") && data.getQueryParameterNames().contains("token")) {
-			b.putString("token", data.getQueryParameter("token"));
+		final String token = getToken(data);
+		if (segments.size() == 3 && segments.get(1).equals("rss") && token != null) {
+			b.putString("token", token);
 
 			Intent intent = new Intent(this, NewsfeedActivity.class);
 			intent.putExtras(b);
 		}
 	}
 
+	/**
+	 * Extracts the user's unique token from the URI, based on the assumption
+	 * that it's the only parameter found in it.
+	 * 
+	 * @param data The URI with the token
+	 * @return The token, or null if couldn't be extracted.
+	 */
+	private String getToken(Uri data) {
+		if (data == null) {
+			return null;
+		}
+		String[] parts = data.toString().split("=");
+		if (parts.length == 2 && parts[0].endsWith("token")) {
+			return parts[1];
+		}
+		return null;
+	}
+
 	@Override
 	public void asyncLoaderDone(String result) {
 		super.asyncLoaderDone(result);