Commits

Ville Saalo committed d470970

On the repository page, when printing some info if the repository is a fork of some other repository, make that parent repository into a link.

Comments (0)

Files changed (3)

src/com/saibotd/bitbeaker/Helper.java

 	 * @return HTML link, e.g. '<a href="http://www.example.com/">http://www.example.com/</a>'.
 	 */
 	public static String getHtmlLink(String url) {
-		return getHtmlLink(url, url);
-	}
-	
-	/**
-	 * Turns the given URL and text into an HTML link
-	 * @param url An URL, 'http://www.example.com/', for example
-	 * @param text The link text, e.g. 'Click here!'
-	 * @return HTML link, e.g. '<a href="http://www.example.com/">Click here!</a>'.
-	 */
-	public static String getHtmlLink(String url, String text) {
-		return "<a href=\"" + url + "\">" + text + "</a>";
+		return "<a href=\"" + url + "\">" + url + "</a>";
 	}
 }

src/com/saibotd/bitbeaker/RepositoryActivity.java

 import android.content.Intent;
 import android.os.Bundle;
 import android.text.Html;
+import android.text.method.LinkMovementMethod;
 import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 				setTitle(repository.getString("name"));
 				StringBuilder desc = new StringBuilder();
 				if (Boolean.parseBoolean(repository.getString("is_fork"))) {
-					final JSONObject fork = repository.getJSONObject("fork_of");
-					final String owner = fork.getString("owner");
-					final String slug = fork.getString("slug");
-					final String ownerUrl = "https://www.bitbucket.org/" + owner + "/";
-					final String slugUrl = ownerUrl + slug + "/";
+					final JSONObject original = repository.getJSONObject("fork_of");
+					final String owner = original.getString("owner");
+					final String slug = original.getString("slug");
+					final String slugUrl = "https://bitbucket.org/" + owner + "/" + slug;
 					desc.append("(").append(this.getString(R.string.fork_of)).append(" ");
-					desc.append(owner);
-					desc.append(" / ");
-					desc.append(slug);
-					if (!Helper.isJsonEmpty(fork.getString("description"))) {
-						desc.append(": <i>" + fork.getString("description") + "</i>");
+					desc.append(Helper.getHtmlLink(slugUrl));
+					if (!Helper.isJsonEmpty(original.getString("description"))) {
+						desc.append(": <i>" + original.getString("description") + "</i>");
 					}
 					desc.append(")<br>");
-					Log.d("RepositoryActivity", "ownerUrl: '"+ownerUrl+"'");
-					Log.d("RepositoryActivity", "slugUrl : '"+slugUrl+"'");
 				}
 				if (!Helper.isJsonEmpty(repository.getString("description"))) {
 					desc.append(repository.getString("description"));
 				if (!Helper.isJsonEmpty(repository.getString("website"))) {
 					desc.append("<br>").append(Helper.getHtmlLink(repository.getString("website")));
 				}
-				Log.d("RepositoryActivity", "repoUrl : '"+repository.getString("website")+"'");
+				repositoryDescription.setMovementMethod(LinkMovementMethod.getInstance());
 				repositoryDescription.setText(Html.fromHtml(desc.toString()));
 				if (!Helper.isJsonEmpty(repository.getString("logo"))) {
 					executeAsyncImageLoader(icon, repository.getString("logo"));

src/com/saibotd/bitbeaker/tests/HelperTest.java

 		assertFalse(Helper.isImage(null));
 	}
 	
-	public void test_getPlainHtmlLink_with_URL_only() {
+	public void test_getPlainHtmlLink() {
 		assertEquals("<a href=\"http://www.example.com/foobar\">http://www.example.com/foobar</a>", 
 					Helper.getHtmlLink("http://www.example.com/foobar"));
 	}
-	
-	public void test_getPlainHtmlLink_with_URL_and_text() {
-		assertEquals("<a href=\"https://www.example.com/foobar\">Click for foobar</a>", 
-					Helper.getHtmlLink("https://www.example.com/foobar", "Click for foobar"));
-	}
 }