Ville Saalo avatar Ville Saalo committed 563cf9f

Styled usernames that work as links in ChangesetActivity and IssueActivity.

Comments (0)

Files changed (5)

res/layout/changeset.xml

             android:id="@+id/changeset_message"
             android:text="@string/description">
         </TextView>
-        
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:id="@+id/changeset_author"
-            android:text="@string/nothing">
-        </TextView>
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:id="@+id/changeset_branch"
-            android:text="@string/nothing">
-        </TextView>
 
     </LinearLayout>
+    
+    <TableLayout
+        android:id="@+id/changesetMetadataTable"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_margin="4dip" >
+
+        <TableRow>
+
+            <TextView
+                android:id="@+id/changeset_author_label"
+                android:layout_marginRight="4dip"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:text="@string/author_label" >
+            </TextView>
+
+            <TextView
+                android:id="@+id/changeset_author"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:text="@string/nothing" >
+            </TextView>
+        </TableRow>
+
+        <TableRow>
+
+            <TextView
+                android:id="@+id/changeset_branch_label"
+                android:layout_marginRight="4dip"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:text="@string/branch_label" >
+            </TextView>
+
+            <TextView
+                android:id="@+id/changeset_branch"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:text="@string/nothing" >
+            </TextView>
+        </TableRow>
+    </TableLayout>
 
     <LinearLayout
         android:layout_height="wrap_content"

res/layout/issue.xml

                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:text="@string/issueAuthorLabel"
-                        android:paddingRight="5dip"
-                        android:textStyle="italic" >
+                        android:paddingRight="5dip" >
                     </TextView>
 
                     <TextView
                         android:id="@+id/issueOnTimestampLabel"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:text="@string/issueOnTimestampLabel"
-                        android:textStyle="italic" >
+                        android:text="@string/nothing" >
                     </TextView>
                     
                     <TextView
                         android:id="@+id/issueTimestamp"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:text="@string/nothing"
-                        android:textStyle="italic" >
+                        android:text="@string/nothing" >
                     </TextView>
 
             </LinearLayout>

src/com/saibotd/bitbeaker/ChangesetActivity.java

 			e1.printStackTrace();
 		}
 		TextView message = (TextView) findViewById(R.id.changeset_message);
-		TextView author = (TextView) findViewById(R.id.changeset_author);
+		TextView author = Helper.renderAsLink((TextView) findViewById(R.id.changeset_author));
 		TextView branch = (TextView) findViewById(R.id.changeset_branch);
 		try {
 			final String authorName = mData.getString("author");
 			message.setText(mData.getString("message"));
-			author.setText(this.getString(R.string.author_label) + " " + authorName);
+			author.setText(authorName);
 			author.setOnClickListener(new UserProfileActivityStartingClickListener(authorName));
 			String branch_tmp = mData.getString("branch");
 			if (!branch_tmp.equals("null")) {
-				branch.setText(this.getString(R.string.branch_label) + " " + branch_tmp);
+				branch.setText(branch_tmp);
 			}
 		} catch (JSONException e) {
 			// TODO Auto-generated catch block

src/com/saibotd/bitbeaker/Helper.java

 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.graphics.Paint;
 import android.util.Base64;
 import android.util.Log;
+import android.widget.TextView;
 
 public class Helper {
 	public enum Sort {ASCENDING_CASE_SENSITIVE(1, true), DESCENDING_CASE_SENSITIVE(-1, true),
 	}
 	
 	/**
+	 * This method formats a TextView as if it was a hyperlink. This method
+	 * is useful when it's not a real HTML link but there's an OnClickListener
+	 * assigned to the TextView, taking you to some other action.
+	 * @param t The TextView whose appearance is to be changed.
+	 */
+	public static TextView renderAsLink(TextView t) {
+		t.setPaintFlags(t.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
+		t.setTextColor(Color.BLUE);
+		return t;
+	}
+	
+	/**
 	 * A class that compares two JSONObjects by the values of the given keys.
 	 * If there are more keys than sort directions, the default sorting 
 	 * direction is ascending.

src/com/saibotd/bitbeaker/IssueActivity.java

 		TextView issueType = (TextView) findViewById(R.id.issueType);
 		TextView issuePriority = (TextView) findViewById(R.id.issuePriority);
 		TextView issueAuthor = (TextView) findViewById(R.id.issueAuthor);
+		TextView issueOnTimestampLabel = (TextView) findViewById(R.id.issueOnTimestampLabel);
 		TextView issueCreationDate = (TextView) findViewById(R.id.issueTimestamp);
 		issue_data = result;
 		try {
 			issueStatus.setText(Helper.translateApiString(jsonObject.getString("status")));
 			issueType.setText(Helper.translateApiString(jsonObject.getJSONObject("metadata").getString("kind")));
 			issuePriority.setText(Helper.translateApiString(jsonObject.getString("priority")));
-			issueAuthor.setText(issueCreator + " ");
+			issueAuthor.setText(issueCreator);
 			issueAuthor.setOnClickListener(new UserProfileActivityStartingClickListener(issueCreator));
+			Helper.renderAsLink(issueAuthor);
+			issueOnTimestampLabel.setText(" " + getString(R.string.issueOnTimestampLabel));
 			issueCreationDate.setText(" " + Helper.dateFormat(jsonObject.getString("utc_created_on")));
 
 			TextView issueContent = (TextView) listViewHeader.findViewById(R.id.issue_content);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.