Skip to content
This repository
Browse code

Update Copyright

Signed-off-by: Eddie Ringle <eddie@eringle.net>
  • Loading branch information...
commit 963846d70e2c53a5d71c7147b377e94a5b3e1e63 1 parent 87343a9
Eddie Ringle authored

Showing 48 changed files with 1,485 additions and 1,394 deletions. Show diff stats Hide diff stats

  1. 3  COPYING
  2. 2  res/values/strings.xml
  3. 177  src/com/github/droidfu/adapters/ListAdapterWithProgress.java
  4. 23  src/net/idlesoft/android/apps/github/HubroidApplication.java
  5. 30  src/net/idlesoft/android/apps/github/activities/Branch.java
  6. 113  src/net/idlesoft/android/apps/github/activities/BranchTree.java
  7. 101  src/net/idlesoft/android/apps/github/activities/BranchesList.java
  8. 327  src/net/idlesoft/android/apps/github/activities/Commit.java
  9. 86  src/net/idlesoft/android/apps/github/activities/CommitChangeViewer.java
  10. 131  src/net/idlesoft/android/apps/github/activities/CommitsList.java
  11. 81  src/net/idlesoft/android/apps/github/activities/CreateIssue.java
  12. 108  src/net/idlesoft/android/apps/github/activities/Dashboard.java
  13. 45  src/net/idlesoft/android/apps/github/activities/DiffFilesList.java
  14. 158  src/net/idlesoft/android/apps/github/activities/FileViewer.java
  15. 6  src/net/idlesoft/android/apps/github/activities/Hubroid.java
  16. 42  src/net/idlesoft/android/apps/github/activities/Issues.java
  17. 12  src/net/idlesoft/android/apps/github/activities/Login.java
  18. 65  src/net/idlesoft/android/apps/github/activities/NetworkList.java
  19. 36  src/net/idlesoft/android/apps/github/activities/NewsFeed.java
  20. 12  src/net/idlesoft/android/apps/github/activities/Profile.java
  21. 21  src/net/idlesoft/android/apps/github/activities/Repositories.java
  22. 146  src/net/idlesoft/android/apps/github/activities/Repository.java
  23. 6  src/net/idlesoft/android/apps/github/activities/Search.java
  24. 108  src/net/idlesoft/android/apps/github/activities/SingleActivityItem.java
  25. 321  src/net/idlesoft/android/apps/github/activities/SingleIssue.java
  26. 21  src/net/idlesoft/android/apps/github/activities/Users.java
  27. 23  src/net/idlesoft/android/apps/github/activities/tabs/ClosedIssues.java
  28. 18  src/net/idlesoft/android/apps/github/activities/tabs/Followers.java
  29. 18  src/net/idlesoft/android/apps/github/activities/tabs/Following.java
  30. 26  src/net/idlesoft/android/apps/github/activities/tabs/MyRepos.java
  31. 23  src/net/idlesoft/android/apps/github/activities/tabs/OpenIssues.java
  32. 68  src/net/idlesoft/android/apps/github/activities/tabs/SearchRepos.java
  33. 68  src/net/idlesoft/android/apps/github/activities/tabs/SearchUsers.java
  34. 29  src/net/idlesoft/android/apps/github/activities/tabs/WatchedRepos.java
  35. 38  src/net/idlesoft/android/apps/github/adapters/ActivityFeedAdapter.java
  36. 10  src/net/idlesoft/android/apps/github/adapters/BranchListAdapter.java
  37. 8  src/net/idlesoft/android/apps/github/adapters/BranchTreeListAdapter.java
  38. 28  src/net/idlesoft/android/apps/github/adapters/CommitListAdapter.java
  39. 20  src/net/idlesoft/android/apps/github/adapters/FollowersFollowingListAdapter.java
  40. 8  src/net/idlesoft/android/apps/github/adapters/ForkListAdapter.java
  41. 27  src/net/idlesoft/android/apps/github/adapters/GravatarListAdapter.java
  42. 10  src/net/idlesoft/android/apps/github/adapters/IssueCommentsAdapter.java
  43. 8  src/net/idlesoft/android/apps/github/adapters/IssuesListAdapter.java
  44. 22  src/net/idlesoft/android/apps/github/adapters/JsonListAdapter.java
  45. 11  src/net/idlesoft/android/apps/github/adapters/RepositoriesListAdapter.java
  46. 19  src/net/idlesoft/android/apps/github/adapters/SearchUsersListAdapter.java
  47. 29  src/net/idlesoft/android/apps/github/utils/GravatarCache.java
  48. 187  src/net/idlesoft/android/apps/github/utils/NewsFeedHelpers.java
3  COPYING
... ...
@@ -1,5 +1,4 @@
1  
-Copyright (c) 2011 Idlesoft LLC.
2  
-All rights reserved.
  1
+Copyright (c) 2011 Eddie Ringle.
3 2
  
4 3
 Redistribution and use in source and binary forms, with or
5 4
 without modification, are permitted provided that the following
2  res/values/strings.xml
@@ -5,7 +5,7 @@
5 5
     <string name="app_version">2.0-beta2</string>
6 6
 
7 7
 	<!-- Splash/Login Activity -->
8  
-	<string name="copyright">Copyright © 2011 Idlesoft</string>
  8
+	<string name="copyright">Copyright © 2011 Eddie Ringle</string>
9 9
 
10 10
 	<!-- Repositories Activity -->
11 11
 	<string name="my_repos">Repositories</string>
177  src/com/github/droidfu/adapters/ListAdapterWithProgress.java
@@ -15,9 +15,6 @@
15 15
 
16 16
 package com.github.droidfu.adapters;
17 17
 
18  
-import java.util.ArrayList;
19  
-import java.util.List;
20  
-
21 18
 import android.app.Activity;
22 19
 import android.app.ExpandableListActivity;
23 20
 import android.app.ListActivity;
@@ -26,39 +23,59 @@
26 23
 import android.widget.AbsListView;
27 24
 import android.widget.BaseAdapter;
28 25
 
  26
+import java.util.ArrayList;
  27
+import java.util.List;
  28
+
29 29
 public abstract class ListAdapterWithProgress<T> extends BaseAdapter {
30 30
 
  31
+    private final ArrayList<T> data = new ArrayList<T>();
  32
+
31 33
     private boolean isLoadingData;
32 34
 
  35
+    private AbsListView listView;
  36
+
33 37
     private View progressView;
34 38
 
35  
-    private ArrayList<T> data = new ArrayList<T>();
  39
+    public ListAdapterWithProgress(final Activity activity, final AbsListView listView,
  40
+            final int progressDrawableResourceId) {
  41
+        this.listView = listView;
  42
+        this.progressView = activity.getLayoutInflater().inflate(progressDrawableResourceId,
  43
+                listView, false);
  44
+    }
36 45
 
37  
-    private AbsListView listView;
  46
+    public ListAdapterWithProgress(final ExpandableListActivity activity,
  47
+            final int progressDrawableResourceId) {
  48
+        this(activity, activity.getExpandableListView(), progressDrawableResourceId);
  49
+    }
38 50
 
39  
-    public ListAdapterWithProgress(ListActivity activity, int progressDrawableResourceId) {
  51
+    public ListAdapterWithProgress(final ListActivity activity, final int progressDrawableResourceId) {
40 52
         this(activity, activity.getListView(), progressDrawableResourceId);
41 53
     }
42 54
 
43  
-    public ListAdapterWithProgress(ExpandableListActivity activity, int progressDrawableResourceId) {
44  
-        this(activity, activity.getExpandableListView(), progressDrawableResourceId);
  55
+    public void addAll(final List<T> items) {
  56
+        data.addAll(items);
  57
+        notifyDataSetChanged();
45 58
     }
46 59
 
47  
-    public ListAdapterWithProgress(Activity activity, AbsListView listView,
48  
-            int progressDrawableResourceId) {
49  
-        this.listView = listView;
50  
-        this.progressView = activity.getLayoutInflater().inflate(progressDrawableResourceId,
51  
-            listView, false);
  60
+    public void addAll(final List<T> items, final boolean redrawList) {
  61
+        data.addAll(items);
  62
+        if (redrawList) {
  63
+            notifyDataSetChanged();
  64
+        }
52 65
     }
53 66
 
54  
-    public AbsListView getListView() {
55  
-        return listView;
  67
+    @Override
  68
+    public boolean areAllItemsEnabled() {
  69
+        return false;
56 70
     }
57 71
 
58  
-    public View getProgressView() {
59  
-        return progressView;
  72
+    public void clear() {
  73
+        data.clear();
  74
+        notifyDataSetChanged();
60 75
     }
61 76
 
  77
+    protected abstract View doGetView(int position, View convertView, ViewGroup parent);
  78
+
62 79
     /**
63 80
      * {@inheritDoc}
64 81
      * <p>
@@ -77,16 +94,15 @@ public int getCount() {
77 94
         return size;
78 95
     }
79 96
 
80  
-    /**
81  
-     * {@inheritDoc}
82  
-     * <p>
83  
-     * Don't use this to check for the presence of actual data items; use
84  
-     * {@link #hasItems()} instead.
85  
-     * </p>
86  
-     */
87  
-    @Override
88  
-    public boolean isEmpty() {
89  
-        return getCount() == 0 && !isLoadingData;
  97
+    public ArrayList<T> getData() {
  98
+        return data;
  99
+    }
  100
+
  101
+    public T getItem(final int position) {
  102
+        if (data == null) {
  103
+            return null;
  104
+        }
  105
+        return data.get(position);
90 106
     }
91 107
 
92 108
     /**
@@ -100,53 +116,27 @@ public int getItemCount() {
100 116
         return 0;
101 117
     }
102 118
 
103  
-    /**
104  
-     * @return true if there are actual data items, ignoring the progress item.
105  
-     */
106  
-    public boolean hasItems() {
107  
-        return data != null && !data.isEmpty();
108  
-    }
109  
-
110  
-    public T getItem(int position) {
111  
-        if (data == null) {
112  
-            return null;
113  
-        }
114  
-        return data.get(position);
115  
-    }
116  
-
117  
-    public long getItemId(int position) {
  119
+    public long getItemId(final int position) {
118 120
         return position;
119 121
     }
120 122
 
121 123
     @Override
122  
-    public boolean isEnabled(int position) {
  124
+    public int getItemViewType(final int position) {
123 125
         if (isPositionOfProgressElement(position)) {
124  
-            return false;
  126
+            return IGNORE_ITEM_VIEW_TYPE;
125 127
         }
126  
-        return true;
127  
-    }
128  
-
129  
-    @Override
130  
-    public boolean areAllItemsEnabled() {
131  
-        return false;
132  
-    }
133  
-
134  
-    public void setIsLoadingData(boolean isLoadingData) {
135  
-        setIsLoadingData(isLoadingData, true);
  128
+        return 0;
136 129
     }
137 130
 
138  
-    public void setIsLoadingData(boolean isLoadingData, boolean redrawList) {
139  
-        this.isLoadingData = isLoadingData;
140  
-        if (redrawList) {
141  
-            notifyDataSetChanged();
142  
-        }
  131
+    public AbsListView getListView() {
  132
+        return listView;
143 133
     }
144 134
 
145  
-    public boolean isLoadingData() {
146  
-        return isLoadingData;
  135
+    public View getProgressView() {
  136
+        return progressView;
147 137
     }
148 138
 
149  
-    public final View getView(int position, View convertView, ViewGroup parent) {
  139
+    public final View getView(final int position, final View convertView, final ViewGroup parent) {
150 140
         if (isPositionOfProgressElement(position)) {
151 141
             return progressView;
152 142
         }
@@ -154,48 +144,59 @@ public final View getView(int position, View convertView, ViewGroup parent) {
154 144
         return doGetView(position, convertView, parent);
155 145
     }
156 146
 
157  
-    protected abstract View doGetView(int position, View convertView, ViewGroup parent);
  147
+    @Override
  148
+    public int getViewTypeCount() {
  149
+        return 2;
  150
+    }
158 151
 
159  
-    private boolean isPositionOfProgressElement(int position) {
160  
-        return isLoadingData && position == data.size();
  152
+    /**
  153
+     * @return true if there are actual data items, ignoring the progress item.
  154
+     */
  155
+    public boolean hasItems() {
  156
+        return (data != null) && !data.isEmpty();
161 157
     }
162 158
 
  159
+    /**
  160
+     * {@inheritDoc}
  161
+     * <p>
  162
+     * Don't use this to check for the presence of actual data items; use
  163
+     * {@link #hasItems()} instead.
  164
+     * </p>
  165
+     */
163 166
     @Override
164  
-    public int getItemViewType(int position) {
  167
+    public boolean isEmpty() {
  168
+        return (getCount() == 0) && !isLoadingData;
  169
+    }
  170
+
  171
+    @Override
  172
+    public boolean isEnabled(final int position) {
165 173
         if (isPositionOfProgressElement(position)) {
166  
-            return IGNORE_ITEM_VIEW_TYPE;
  174
+            return false;
167 175
         }
168  
-        return 0;
  176
+        return true;
169 177
     }
170 178
 
171  
-    @Override
172  
-    public int getViewTypeCount() {
173  
-        return 2;
  179
+    public boolean isLoadingData() {
  180
+        return isLoadingData;
174 181
     }
175 182
 
176  
-    public ArrayList<T> getData() {
177  
-        return data;
  183
+    private boolean isPositionOfProgressElement(final int position) {
  184
+        return isLoadingData && (position == data.size());
178 185
     }
179 186
 
180  
-    public void addAll(List<T> items) {
181  
-        data.addAll(items);
  187
+    public void remove(final int position) {
  188
+        data.remove(position);
182 189
         notifyDataSetChanged();
183 190
     }
184 191
 
185  
-    public void addAll(List<T> items, boolean redrawList) {
186  
-        data.addAll(items);
  192
+    public void setIsLoadingData(final boolean isLoadingData) {
  193
+        setIsLoadingData(isLoadingData, true);
  194
+    }
  195
+
  196
+    public void setIsLoadingData(final boolean isLoadingData, final boolean redrawList) {
  197
+        this.isLoadingData = isLoadingData;
187 198
         if (redrawList) {
188 199
             notifyDataSetChanged();
189 200
         }
190 201
     }
191  
-
192  
-    public void clear() {
193  
-        data.clear();
194  
-        notifyDataSetChanged();
195  
-    }
196  
-
197  
-    public void remove(int position) {
198  
-        data.remove(position);
199  
-        notifyDataSetChanged();
200  
-    }
201  
-}
  202
+}
23  src/net/idlesoft/android/apps/github/HubroidApplication.java
... ...
@@ -1,3 +1,11 @@
  1
+/**
  2
+ * Hubroid - A GitHub app for Android
  3
+ *
  4
+ * Copyright (c) 2011 Eddie Ringle.
  5
+ *
  6
+ * Licensed under the New BSD License.
  7
+ */
  8
+
1 9
 package net.idlesoft.android.apps.github;
2 10
 
3 11
 import android.app.Application;
@@ -6,19 +14,14 @@
6 14
 public class HubroidApplication extends Application {
7 15
     private static final boolean DEVELOPER_MODE = true;
8 16
 
  17
+    @Override
9 18
     public void onCreate() {
10 19
         /* Enable Strict Mode if DEVELOPER_MODE is set */
11 20
         if (DEVELOPER_MODE) {
12  
-            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
13  
-                    .detectAll()
14  
-                    .permitDiskReads()
15  
-                    .penaltyLog()
16  
-                    .build());
17  
-            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
18  
-                    .detectAll()
19  
-                    .penaltyLog()
20  
-                    .penaltyDeath()
21  
-                    .build());
  21
+            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll()
  22
+                    .permitDiskReads().penaltyLog().build());
  23
+            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog()
  24
+                    .penaltyDeath().build());
22 25
         }
23 26
         super.onCreate();
24 27
     }
30  src/net/idlesoft/android/apps/github/activities/Branch.java
... ...
@@ -1,13 +1,15 @@
1 1
 /**
2 2
  * Hubroid - A GitHub app for Android
3  
- * 
4  
- * Copyright (c) 2011 Idlesoft LLC.
5  
- * 
  3
+ *
  4
+ * Copyright (c) 2011 Eddie Ringle.
  5
+ *
6 6
  * Licensed under the New BSD License.
7 7
  */
8 8
 
9 9
 package net.idlesoft.android.apps.github.activities;
10 10
 
  11
+import com.flurry.android.FlurryAgent;
  12
+
11 13
 import net.idlesoft.android.apps.github.R;
12 14
 
13 15
 import org.idlesoft.libraries.ghapi.GitHubAPI;
@@ -20,16 +22,18 @@
20 22
 import android.view.View;
21 23
 import android.view.View.OnClickListener;
22 24
 import android.widget.AdapterView;
23  
-import android.widget.AdapterView.OnItemClickListener;
24 25
 import android.widget.ArrayAdapter;
25 26
 import android.widget.ImageButton;
26 27
 import android.widget.ListView;
27 28
 import android.widget.TextView;
28  
-
29  
-import com.flurry.android.FlurryAgent;
  29
+import android.widget.AdapterView.OnItemClickListener;
30 30
 
31 31
 public class Branch extends Activity {
32  
-    private GitHubAPI mGapi = new GitHubAPI();
  32
+    private String mBranchName;
  33
+
  34
+    private String mBranchSha;
  35
+
  36
+    private final GitHubAPI mGapi = new GitHubAPI();
33 37
 
34 38
     public Intent mIntent;
35 39
 
@@ -45,10 +49,6 @@
45 49
 
46 50
     private String mUsername;
47 51
 
48  
-    private String mBranchName;
49  
-
50  
-    private String mBranchSha;
51  
-
52 52
     @Override
53 53
     public void onCreate(final Bundle icicle) {
54 54
         super.onCreate(icicle);
@@ -81,10 +81,14 @@ public void onClick(final View v) {
81 81
             branchName.setText(mBranchName);
82 82
             branchSha.setText(mBranchSha);
83 83
 
84  
-            infoList.setAdapter(new ArrayAdapter<String>(Branch.this, R.layout.branch_info_item, R.id.tv_branchInfoItem_text1, new String[]{"Commit Log", "View Branch's Tree"}));
  84
+            infoList.setAdapter(new ArrayAdapter<String>(Branch.this, R.layout.branch_info_item,
  85
+                    R.id.tv_branchInfoItem_text1, new String[] {
  86
+                            "Commit Log", "View Branch's Tree"
  87
+                    }));
85 88
             infoList.setOnItemClickListener(new OnItemClickListener() {
86 89
                 @Override
87  
-                public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
  90
+                public void onItemClick(final AdapterView<?> parent, final View v,
  91
+                        final int position, final long id) {
88 92
                     if (position == 0) {
89 93
                         mIntent = new Intent(Branch.this, CommitsList.class);
90 94
                         mIntent.putExtra("repo_owner", mRepositoryOwner);
113  src/net/idlesoft/android/apps/github/activities/BranchTree.java
... ...
@@ -1,18 +1,20 @@
1 1
 /**
2 2
  * Hubroid - A GitHub app for Android
3  
- * 
4  
- * Copyright (c) 2011 Idlesoft LLC.
5  
- * 
  3
+ *
  4
+ * Copyright (c) 2011 Eddie Ringle.
  5
+ *
6 6
  * Licensed under the New BSD License.
7 7
  */
8 8
 
9 9
 package net.idlesoft.android.apps.github.activities;
10 10
 
  11
+import com.flurry.android.FlurryAgent;
  12
+
11 13
 import net.idlesoft.android.apps.github.R;
12 14
 import net.idlesoft.android.apps.github.adapters.BranchTreeListAdapter;
13 15
 
14  
-import org.idlesoft.libraries.ghapi.APIAbstract.Response;
15 16
 import org.idlesoft.libraries.ghapi.GitHubAPI;
  17
+import org.idlesoft.libraries.ghapi.APIAbstract.Response;
16 18
 import org.json.JSONArray;
17 19
 import org.json.JSONException;
18 20
 import org.json.JSONObject;
@@ -25,92 +27,94 @@
25 27
 import android.view.View;
26 28
 import android.view.View.OnClickListener;
27 29
 import android.widget.AdapterView;
28  
-import android.widget.AdapterView.OnItemClickListener;
29 30
 import android.widget.ImageButton;
30 31
 import android.widget.ListView;
31 32
 import android.widget.TextView;
32  
-import android.widget.Toast;
33  
-
34  
-import com.flurry.android.FlurryAgent;
  33
+import android.widget.AdapterView.OnItemClickListener;
35 34
 
36 35
 public class BranchTree extends Activity {
37  
-    private GitHubAPI mGapi = new GitHubAPI();
38  
-
39  
-    public Intent mIntent;
40  
-
41  
-    public JSONArray mJson;
42  
-
43  
-    private String mPassword;
44  
-
45  
-    private SharedPreferences mPrefs;
46  
-
47  
-    private String mRepositoryName;
48  
-
49  
-    private String mRepositoryOwner;
50  
-
51  
-    private String mUsername;
52  
-
53  
-    private String mBranchName;
54  
-
55  
-    private String mBranchSha;
56  
-
57  
-    private BranchTreeListAdapter mAdapter;
58  
-
59  
-    private ListView mListView;
60  
-
61  
-    private LoadTreeTask mLoadTreeTask;
62  
-
63 36
     private static class LoadTreeTask extends AsyncTask<Void, Void, Void> {
64 37
         public BranchTree activity;
65 38
 
66  
-        protected void onPreExecute() {
67  
-            activity.mAdapter.setIsLoadingData(true);
68  
-        }
69  
-
70  
-        protected Void doInBackground(Void... params) {
71  
-            Response r = activity.mGapi.object.tree(activity.mRepositoryOwner, activity.mRepositoryName, activity.mBranchSha);
  39
+        @Override
  40
+        protected Void doInBackground(final Void... params) {
  41
+            final Response r = activity.mGapi.object.tree(activity.mRepositoryOwner,
  42
+                    activity.mRepositoryName, activity.mBranchSha);
72 43
             if (r.statusCode == 200) {
73 44
                 try {
74 45
                     activity.mJson = (new JSONObject(r.resp)).getJSONArray("tree");
75 46
                     activity.mAdapter.loadData(activity.mJson);
76  
-                } catch (JSONException e) {
  47
+                } catch (final JSONException e) {
77 48
                     e.printStackTrace();
78 49
                 }
79 50
             }
80 51
             return null;
81 52
         }
82 53
 
83  
-        protected void onPostExecute(Void result) {
  54
+        @Override
  55
+        protected void onPostExecute(final Void result) {
84 56
             activity.mAdapter.pushData();
85 57
             activity.mAdapter.setIsLoadingData(false);
86 58
         }
  59
+
  60
+        @Override
  61
+        protected void onPreExecute() {
  62
+            activity.mAdapter.setIsLoadingData(true);
  63
+        }
87 64
     }
88 65
 
89  
-    private OnItemClickListener mOnListItemClick = new OnItemClickListener() {
90  
-        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
  66
+    private BranchTreeListAdapter mAdapter;
  67
+
  68
+    private String mBranchName;
  69
+
  70
+    private String mBranchSha;
  71
+
  72
+    private final GitHubAPI mGapi = new GitHubAPI();
  73
+
  74
+    public Intent mIntent;
  75
+
  76
+    public JSONArray mJson;
  77
+
  78
+    private ListView mListView;
  79
+
  80
+    private LoadTreeTask mLoadTreeTask;
  81
+
  82
+    private final OnItemClickListener mOnListItemClick = new OnItemClickListener() {
  83
+        public void onItemClick(final AdapterView<?> parent, final View v, final int position,
  84
+                final long id) {
91 85
             try {
92  
-                JSONObject treeItem = mJson.getJSONObject(position);
  86
+                final JSONObject treeItem = mJson.getJSONObject(position);
93 87
                 if (treeItem.getString("type").equals("tree")) {
94  
-                    Intent i = new Intent(BranchTree.this, BranchTree.class);
  88
+                    final Intent i = new Intent(BranchTree.this, BranchTree.class);
95 89
                     i.putExtra("repo_owner", mRepositoryOwner);
96 90
                     i.putExtra("repo_name", mRepositoryName);
97 91
                     i.putExtra("branch_name", mBranchName);
98 92
                     i.putExtra("branch_sha", treeItem.getString("sha"));
99 93
                     startActivity(i);
100 94
                 } else if (treeItem.getString("type").equals("blob")) {
101  
-                    Intent i = new Intent(BranchTree.this, FileViewer.class);
  95
+                    final Intent i = new Intent(BranchTree.this, FileViewer.class);
102 96
                     i.putExtra("repo_owner", mRepositoryOwner);
103 97
                     i.putExtra("repo_name", mRepositoryName);
104 98
                     i.putExtra("tree_sha", mBranchSha);
105 99
                     i.putExtra("blob_path", treeItem.getString("name"));
106 100
                     startActivity(i);
107 101
                 }
108  
-            } catch (JSONException e) {
  102
+            } catch (final JSONException e) {
109 103
                 e.printStackTrace();
110 104
             }
111 105
         }
112 106
     };
113 107
 
  108
+    private String mPassword;
  109
+
  110
+    private SharedPreferences mPrefs;
  111
+
  112
+    private String mRepositoryName;
  113
+
  114
+    private String mRepositoryOwner;
  115
+
  116
+    private String mUsername;
  117
+
114 118
     @Override
115 119
     public void onCreate(final Bundle icicle) {
116 120
         super.onCreate(icicle);
@@ -146,6 +150,7 @@ public void onClick(final View v) {
146 150
         }
147 151
     }
148 152
 
  153
+    @Override
149 154
     protected void onResume() {
150 155
         mListView.setAdapter(mAdapter);
151 156
 
@@ -154,13 +159,18 @@ protected void onResume() {
154 159
             mLoadTreeTask = new LoadTreeTask();
155 160
         }
156 161
         mLoadTreeTask.activity = BranchTree.this;
157  
-        if (mLoadTreeTask.getStatus() == AsyncTask.Status.PENDING && !mAdapter.hasItems()) {
  162
+        if ((mLoadTreeTask.getStatus() == AsyncTask.Status.PENDING) && !mAdapter.hasItems()) {
158 163
             mLoadTreeTask.execute();
159 164
         }
160 165
         super.onResume();
161 166
     }
162 167
 
163 168
     @Override
  169
+    public Object onRetainNonConfigurationInstance() {
  170
+        return mLoadTreeTask;
  171
+    }
  172
+
  173
+    @Override
164 174
     public void onStart() {
165 175
         super.onStart();
166 176
         FlurryAgent.onStartSession(this, "K8C93KDB2HH3ANRDQH1Z");
@@ -171,9 +181,4 @@ public void onStop() {
171 181
         super.onStop();
172 182
         FlurryAgent.onEndSession(this);
173 183
     }
174  
-
175  
-    @Override
176  
-    public Object onRetainNonConfigurationInstance() {
177  
-        return mLoadTreeTask;
178  
-    }
179 184
 }
101  src/net/idlesoft/android/apps/github/activities/BranchesList.java
... ...
@@ -1,14 +1,14 @@
1 1
 /**
2 2
  * Hubroid - A GitHub app for Android
3  
- * 
4  
- * Copyright (c) 2011 Idlesoft LLC.
5  
- * 
  3
+ *
  4
+ * Copyright (c) 2011 Eddie Ringle.
  5
+ *
6 6
  * Licensed under the New BSD License.
7 7
  */
8 8
 
9 9
 package net.idlesoft.android.apps.github.activities;
10 10
 
11  
-import java.io.File;
  11
+import com.flurry.android.FlurryAgent;
12 12
 
13 13
 import net.idlesoft.android.apps.github.R;
14 14
 import net.idlesoft.android.apps.github.adapters.BranchListAdapter;
@@ -28,24 +28,60 @@
28 28
 import android.view.View;
29 29
 import android.view.View.OnClickListener;
30 30
 import android.widget.AdapterView;
31  
-import android.widget.AdapterView.OnItemClickListener;
32 31
 import android.widget.ImageButton;
33 32
 import android.widget.ListView;
34 33
 import android.widget.TextView;
  34
+import android.widget.AdapterView.OnItemClickListener;
35 35
 
36  
-import com.flurry.android.FlurryAgent;
  36
+import java.io.File;
37 37
 
38 38
 public class BranchesList extends Activity {
39  
-    private GitHubAPI mGapi = new GitHubAPI();
  39
+    private static class GetBranchesTask extends AsyncTask<Void, Void, Void> {
  40
+        BranchesList activity;
40 41
 
41  
-    private SharedPreferences.Editor mEditor;
  42
+        @Override
  43
+        protected Void doInBackground(final Void... params) {
  44
+            try {
  45
+                activity.mJson = new JSONObject(activity.mGapi.repo.branches(activity.mRepoOwner,
  46
+                        activity.mRepoName).resp).getJSONObject("branches");
  47
+                activity.mBranchListAdapter = new BranchListAdapter(activity, activity.mJson);
  48
+            } catch (final JSONException e) {
  49
+                e.printStackTrace();
  50
+            }
  51
+            return null;
  52
+        }
  53
+
  54
+        @Override
  55
+        protected void onPostExecute(final Void result) {
  56
+            activity.mBranchList.removeHeaderView(activity.mLoadView);
  57
+            activity.mBranchList.setAdapter(activity.mBranchListAdapter);
  58
+            super.onPostExecute(result);
  59
+        }
  60
+
  61
+        @Override
  62
+        protected void onPreExecute() {
  63
+            activity.mBranchList.addHeaderView(activity.mLoadView);
  64
+            activity.mBranchList.setAdapter(null);
  65
+            super.onPreExecute();
  66
+        }
  67
+    }
  68
+
  69
+    public ListView mBranchList;
42 70
 
43 71
     public BranchListAdapter mBranchListAdapter;
44 72
 
  73
+    private SharedPreferences.Editor mEditor;
  74
+
  75
+    private final GitHubAPI mGapi = new GitHubAPI();
  76
+
  77
+    public GetBranchesTask mGetBranchesTask;
  78
+
45 79
     public Intent mIntent;
46 80
 
47 81
     public JSONObject mJson;
48 82
 
  83
+    public View mLoadView;
  84
+
49 85
     private final OnItemClickListener mOnBranchListItemClick = new OnItemClickListener() {
50 86
         public void onItemClick(final AdapterView<?> parent, final View v, final int position,
51 87
                 final long id) {
@@ -62,48 +98,16 @@ public void onItemClick(final AdapterView<?> parent, final View v, final int pos
62 98
         }
63 99
     };
64 100
 
  101
+    private String mPassword;
  102
+
65 103
     private SharedPreferences mPrefs;
66 104
 
67 105
     public String mRepoName;
68 106
 
69 107
     public String mRepoOwner;
70 108
 
71  
-    private String mPassword;
72  
-
73 109
     private String mUsername;
74 110
 
75  
-    public View mLoadView;
76  
-
77  
-    public ListView mBranchList;
78  
-
79  
-    public GetBranchesTask mGetBranchesTask;
80  
-
81  
-    private static class GetBranchesTask extends AsyncTask<Void, Void, Void> {
82  
-        BranchesList activity;
83  
-        @Override
84  
-        protected void onPreExecute() {
85  
-            activity.mBranchList.addHeaderView(activity.mLoadView);
86  
-            activity.mBranchList.setAdapter(null);
87  
-            super.onPreExecute();
88  
-        }
89  
-        @Override
90  
-        protected Void doInBackground(Void... params) {
91  
-            try {
92  
-                activity.mJson = new JSONObject(activity.mGapi.repo.branches(activity.mRepoOwner, activity.mRepoName).resp).getJSONObject("branches");
93  
-                activity.mBranchListAdapter = new BranchListAdapter(activity, activity.mJson);
94  
-            } catch (JSONException e) {
95  
-                e.printStackTrace();
96  
-            }
97  
-            return null;
98  
-        }
99  
-        @Override
100  
-        protected void onPostExecute(Void result) {
101  
-            activity.mBranchList.removeHeaderView(activity.mLoadView);
102  
-            activity.mBranchList.setAdapter(activity.mBranchListAdapter);
103  
-            super.onPostExecute(result);
104  
-        }
105  
-    }
106  
-
107 111
     @Override
108 112
     public void onCreate(final Bundle icicle) {
109 113
         super.onCreate(icicle);
@@ -143,7 +147,8 @@ public void onClick(final View v) {
143 147
 
144 148
             mGetBranchesTask.activity = this;
145 149
 
146  
-            if (mGetBranchesTask.getStatus() == AsyncTask.Status.PENDING && mBranchListAdapter == null) {
  150
+            if ((mGetBranchesTask.getStatus() == AsyncTask.Status.PENDING)
  151
+                    && (mBranchListAdapter == null)) {
147 152
                 mGetBranchesTask.execute();
148 153
             }
149 154
         }
@@ -177,11 +182,6 @@ public boolean onOptionsItemSelected(final MenuItem item) {
177 182
     }
178 183
 
179 184
     @Override
180  
-    public Object onRetainNonConfigurationInstance() {
181  
-        return mGetBranchesTask;
182  
-    }
183  
-
184  
-    @Override
185 185
     public boolean onPrepareOptionsMenu(final Menu menu) {
186 186
         if (!menu.hasVisibleItems()) {
187 187
             menu.add(0, 0, 0, "Back to Main").setIcon(android.R.drawable.ic_menu_revert);
@@ -192,6 +192,11 @@ public boolean onPrepareOptionsMenu(final Menu menu) {
192 192
     }
193 193
 
194 194
     @Override
  195
+    public Object onRetainNonConfigurationInstance() {
  196
+        return mGetBranchesTask;
  197
+    }
  198
+
  199
+    @Override
195 200
     public void onStart() {
196 201
         super.onStart();
197 202
         FlurryAgent.onStartSession(this, "K8C93KDB2HH3ANRDQH1Z");
327  src/net/idlesoft/android/apps/github/activities/Commit.java
... ...
@@ -1,8 +1,8 @@
1 1
 /**
2 2
  * Hubroid - A GitHub app for Android
3  
- * 
4  
- * Copyright (c) 2011 Idlesoft LLC.
5  
- * 
  3
+ *
  4
+ * Copyright (c) 2011 Eddie Ringle.
  5
+ *
6 6
  * Licensed under the New BSD License.
7 7
  */
8 8
 
@@ -40,92 +40,153 @@
40 40
 import java.util.Date;
41 41
 
42 42
 public class Commit extends Activity {
43  
-    private GitHubAPI mGapi = new GitHubAPI();
44  
-
45  
-    public Intent mIntent;
46  
-
47  
-    private JSONObject mJson;
48  
-
49  
-    private Bitmap mAuthorGravatar;
50  
-
51  
-    private Bitmap mCommitterGravatar;
52  
-
53  
-    private String mPassword;
54  
-
55  
-    private SharedPreferences mPrefs;
56  
-
57  
-    private String mRepositoryName;
58  
-
59  
-    private String mRepositoryOwner;
60  
-
61  
-    private String mUsername;
62  
-
63  
-    private String mCommitSha;
64  
-
65  
-    private String mAuthor;
66  
-
67  
-    private String mCommitter;
68  
-
69  
-    private String mAuthorName;
70  
-
71  
-    private String mCommitterName;
72  
-
73  
-    private GetCommitTask mGetCommitTask;
74  
-
75  
-    private ScrollView mCommitLayout;
76  
-
77  
-    private RelativeLayout mProgressLayout;
78  
-
79 43
     private static class GetCommitTask extends AsyncTask<Void, Void, Void> {
80 44
         public Commit activity;
81 45
 
82  
-        protected void onPreExecute() {
83  
-            activity.mCommitLayout.setVisibility(View.GONE);
84  
-            activity.mProgressLayout.setVisibility(View.VISIBLE);
85  
-            super.onPreExecute();
86  
-        }
87  
-
88  
-        protected Void doInBackground(Void... params) {
  46
+        @Override
  47
+        protected Void doInBackground(final Void... params) {
89 48
             try {
90  
-                final Response commitResponse = activity.mGapi.commits.commit(activity.mRepositoryOwner, activity.mRepositoryName, activity.mCommitSha);
  49
+                final Response commitResponse = activity.mGapi.commits.commit(
  50
+                        activity.mRepositoryOwner, activity.mRepositoryName, activity.mCommitSha);
91 51
                 if (commitResponse.statusCode != 200) {
92  
-                    /* Oh noez, something went wrong...
93  
-                     * TODO: Do some failure handling here
  52
+                    /*
  53
+                     * Oh noez, something went wrong... TODO: Do some failure
  54
+                     * handling here
94 55
                      */
95 56
                     return null;
96 57
                 }
97 58
                 activity.mJson = (new JSONObject(commitResponse.resp)).getJSONObject("commit");
98 59
 
99 60
                 // This Activity has two entry points:
100  
-                // * From CommitsList which provides an author and committer in the bundle.
  61
+                // * From CommitsList which provides an author and committer in
  62
+                // the bundle.
101 63
                 // * From SingleActivityItem which does not.
102  
-                // If the author or committer are null, populate them from the JSON data.
103  
-                if(activity.mAuthor == null) {
  64
+                // If the author or committer are null, populate them from the
  65
+                // JSON data.
  66
+                if (activity.mAuthor == null) {
104 67
                     activity.mAuthor = activity.mJson.getJSONObject("author").getString("login");
105 68
                 }
106 69
 
107  
-                if(activity.mCommitter == null) {
108  
-                    activity.mCommitter = activity.mJson.getJSONObject("committer").getString("login");
  70
+                if (activity.mCommitter == null) {
  71
+                    activity.mCommitter = activity.mJson.getJSONObject("committer").getString(
  72
+                            "login");
109 73
                 }
110 74
 
111 75
                 activity.mAuthorName = activity.mJson.getJSONObject("author").getString("name");
112  
-                activity.mCommitterName = activity.mJson.getJSONObject("committer").getString("name");
113  
-
114  
-                activity.mAuthorGravatar = Commit.loadGravatarByLoginName(activity, activity.mAuthor);
115  
-                activity.mCommitterGravatar = Commit.loadGravatarByLoginName(activity, activity.mCommitter);
116  
-            } catch (JSONException e) {
  76
+                activity.mCommitterName = activity.mJson.getJSONObject("committer").getString(
  77
+                        "name");
  78
+
  79
+                activity.mAuthorGravatar = Commit.loadGravatarByLoginName(activity,
  80
+                        activity.mAuthor);
  81
+                activity.mCommitterGravatar = Commit.loadGravatarByLoginName(activity,
  82
+                        activity.mCommitter);
  83
+            } catch (final JSONException e) {
117 84
                 e.printStackTrace();
118 85
             }
119 86
             return null;
120 87
         }
121 88
 
122  
-        protected void onPostExecute(Void result) {
  89
+        @Override
  90
+        protected void onPostExecute(final Void result) {
123 91
             activity.buildUi();
124 92
             activity.mProgressLayout.setVisibility(View.GONE);
125 93
             activity.mCommitLayout.setVisibility(View.VISIBLE);
126 94
         }
  95
+
  96
+        @Override
  97
+        protected void onPreExecute() {
  98
+            activity.mCommitLayout.setVisibility(View.GONE);
  99
+            activity.mProgressLayout.setVisibility(View.VISIBLE);
  100
+            super.onPreExecute();
  101
+        }
  102
+    }
  103
+
  104
+    public static String getHumanDate(final Date current_time, final Date commit_time) {
  105
+        String end;
  106
+        final long ms = current_time.getTime() - commit_time.getTime();
  107
+        final long sec = ms / 1000;
  108
+        final long min = sec / 60;
  109
+        final long hour = min / 60;
  110
+        final long day = hour / 24;
  111
+        if (day > 0) {
  112
+            if (day == 1) {
  113
+                end = " day ago";
  114
+            } else {
  115
+                end = " days ago";
  116
+            }
  117
+            return day + end;
  118
+        } else if (hour > 0) {
  119
+            if (hour == 1) {
  120
+                end = " hour ago";
  121
+            } else {
  122
+                end = " hours ago";
  123
+            }
  124
+            return hour + end;
  125
+        } else if (min > 0) {
  126
+            if (min == 1) {
  127
+                end = " minute ago";
  128
+            } else {
  129
+                end = " minutes ago";
  130
+            }
  131
+            return min + end;
  132
+        } else {
  133
+            if (sec == 1) {
  134
+                end = " second ago";
  135
+            } else {
  136
+                end = " seconds ago";
  137
+            }
  138
+            return sec + end;
  139
+        }
127 140
     }
128 141
 
  142
+    /**
  143
+     * Get the Gravatars of all users in the commit log
  144
+     */
  145
+    public static Bitmap loadGravatarByLoginName(final Activity pActivity, final String pLogin) {
  146
+        if (!pLogin.equals("")) {
  147
+            return GravatarCache.getDipGravatar(GravatarCache.getGravatarID(pLogin), 30.0f,
  148
+                    pActivity.getResources().getDisplayMetrics().density);
  149
+        } else {
  150
+            return null;
  151
+        }
  152
+    }
  153
+
  154
+    private String mAuthor;
  155
+
  156
+    private Bitmap mAuthorGravatar;
  157
+
  158
+    private String mAuthorName;
  159
+
  160
+    private ScrollView mCommitLayout;
  161
+
  162
+    private String mCommitSha;
  163
+
  164
+    private String mCommitter;
  165
+
  166
+    private Bitmap mCommitterGravatar;
  167
+
  168
+    private String mCommitterName;
  169
+
  170
+    private final GitHubAPI mGapi = new GitHubAPI();
  171
+
  172
+    private GetCommitTask mGetCommitTask;
  173
+
  174
+    public Intent mIntent;
  175
+
  176
+    private JSONObject mJson;
  177
+
  178
+    private String mPassword;
  179
+
  180
+    private SharedPreferences mPrefs;
  181
+
  182
+    private RelativeLayout mProgressLayout;
  183
+
  184
+    private String mRepositoryName;
  185
+
  186
+    private String mRepositoryOwner;
  187
+
  188
+    private String mUsername;
  189
+
129 190
     protected void buildUi() {
130 191
         // Get the commit data for that commit ID so that we can get the
131 192
         // tree ID and filename.
@@ -144,8 +205,7 @@ protected void buildUi() {
144 205
             }
145 206
 
146 207
             // Set the commit message
147  
-            ((TextView) findViewById(R.id.commit_view_message)).setText(mJson
148  
-                    .getString("message"));
  208
+            ((TextView) findViewById(R.id.commit_view_message)).setText(mJson.getString("message"));
149 209
 
150 210
             final SimpleDateFormat dateFormat = new SimpleDateFormat(Hubroid.GITHUB_TIME_FORMAT);
151 211
             Date commit_time;
@@ -155,8 +215,8 @@ protected void buildUi() {
155 215
             try {
156 216
                 commit_time = dateFormat.parse(mJson.getString("authored_date"));
157 217
                 current_time = dateFormat.parse(dateFormat.format(new Date()));
158  
-                ((TextView) findViewById(R.id.commit_view_author_time))
159  
-                        .setText(Commit.getHumanDate(current_time, commit_time));
  218
+                ((TextView) findViewById(R.id.commit_view_author_time)).setText(Commit
  219
+                        .getHumanDate(current_time, commit_time));
160 220
 
161 221
                 commit_time = dateFormat.parse(mJson.getString("committed_date"));
162 222
                 authorDate = Commit.getHumanDate(current_time, commit_time);
@@ -170,20 +230,19 @@ protected void buildUi() {
170 230
                 // fill in the details
171 231
                 ((LinearLayout) findViewById(R.id.commit_view_author_layout))
172 232
                         .setVisibility(View.VISIBLE);