Commits

Tobias Duehr  committed 638f02f

- Issues and Wiki is no only visible if available in the repo
- Still no diffs for private repos :(
- Some graphical stuff
- Minor tweaks for ICS/ABS style

  • Participants
  • Parent commits d7da52f

Comments (0)

Files changed (22)

File AndroidManifest.xml

                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <activity android:name="RepositoryActivity" android:uiOptions="splitActionBarWhenNarrow">
+        <activity android:name="RepositoryActivity">
         	<meta-data android:name="android.app.default_searchable" android:value=".SearchableActivity" />
         </activity>
         <activity android:name="EventsActivity"></activity>

File project.properties

 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
 
 # Project target.
-target=android-15
+target=android-16
 android.library.reference.1=../../Apps/JakeWharton-ActionBarSherlock-2eabf25/library

File res/drawable-mdpi/book_alt2_32x28.png

Added
New image

File res/drawable-mdpi/chat_alt_fill_32x32.png

Old
Old image
New
New image

File res/drawable-mdpi/cog_32x32.png

Added
New image

File res/drawable-mdpi/document_alt_stroke_24x32.png

Old
Old image
New
New image

File res/drawable-mdpi/eye_32x24.png

Old
Old image
New
New image

File res/drawable-mdpi/magnifying_glass_32x32.png

Old
Old image
New
New image

File res/drawable-mdpi/plus_alt_32x32.png

Added
New image

File res/layout/issues.xml

     <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1">
         <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issues_list"></ListView>
     </LinearLayout>
-    <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/ad_space">
-        <Button android:id="@+id/bt_new_issue" android:layout_height="wrap_content" android:text="@string/new_issue" android:layout_width="match_parent"></Button>
-    </LinearLayout>
 </LinearLayout>

File res/menu/mainmenu.xml

 <?xml version="1.0" encoding="utf-8"?>
 <menu
   xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:id="@+id/menu_search" android:showAsAction="always" android:icon="@drawable/magnifying_glass_32x32"></item><item android:icon="@drawable/ic_menu_refresh" android:id="@+id/menu_refresh" android:title="@string/clear_cache"></item>
+  <item android:id="@+id/menu_search" android:showAsAction="always" android:icon="@drawable/ic_menu_search_holo_dark"></item><item android:icon="@drawable/ic_menu_refresh" android:id="@+id/menu_refresh" android:title="@string/clear_cache"></item>
     <item android:title="@string/log_out" android:id="@+id/menu_logout" android:icon="@drawable/ic_menu_stop"></item>
     
 </menu>

File res/menu/menu_issues.xml

+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:id="@+id/menu_add" android:title="@string/new_issue" android:showAsAction="always|withText" android:icon="@drawable/plus_alt_32x32"></item>
+    
+
+</menu>

File res/menu/menu_repository.xml

 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
-    <item android:id="@+id/menu_source" android:title="@string/source" android:showAsAction="ifRoom|withText" android:icon="@drawable/eye_32x24"></item>
-    <item android:id="@+id/menu_issues" android:title="@string/issues" android:showAsAction="ifRoom|withText" android:icon="@drawable/chat_alt_fill_32x32"></item>
-    <item android:id="@+id/menu_wiki" android:title="@string/wiki" android:showAsAction="ifRoom|withText" android:icon="@drawable/document_alt_stroke_24x32"></item>
+    <item android:id="@+id/menu_source" android:title="@string/source" android:showAsAction="always|withText" android:icon="@drawable/eye_32x24"></item>
+    <item android:id="@+id/menu_issues" android:title="@string/issues" android:showAsAction="always|withText" android:icon="@drawable/chat_alt_fill_32x32"></item>
+    <item android:id="@+id/menu_wiki" android:title="@string/wiki" android:showAsAction="always|withText" android:icon="@drawable/book_alt2_32x28"></item>
     
 
 </menu>

File src/com/saibotd/bitbeaker/ChangesetActivity.java

 import android.widget.ListView;
 import android.widget.TextView;
 
+import com.actionbarsherlock.app.ActionBar;
 import com.actionbarsherlock.app.SherlockActivity;
 import com.actionbarsherlock.view.Menu;
 
         Bundle b = getIntent().getExtras();
         owner = b.getString("owner");
         slug = b.getString("slug");
-        setTitle(slug + " changeset");
         try {
 			mData = new JSONObject(b.getString("data"));
 		} catch (JSONException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
+		ActionBar actionBar = getSupportActionBar();
+		setTitle(slug);
+        actionBar.setSubtitle("Changeset: " + changeset_id);
     }
     
     @Override

File src/com/saibotd/bitbeaker/DiffActivity.java

 package com.saibotd.bitbeaker;
 
+import com.actionbarsherlock.app.ActionBar;
 import com.actionbarsherlock.view.Menu;
 
 import android.app.ProgressDialog;
 
 		progressDialog = ProgressDialog.show(this, "", "Loading diff...", true);
 		AsyncLoader asyncLoader = new AsyncLoader();
-		asyncLoader.execute("https://bitbucket.org/"+ owner +"/"+slug+"/changeset/"+changeset_id+"/raw/");//TODO: authenticate to get diff for own private repositories 
-		setTitle("Diff: "+changeset_id);
+		/*
+		 * TODO: authenticate to get diff for own private repositories
+		 * NOTE: Bitbucket doesn't provide an API call for fetching the diffs. This kinda sucks as we need to implement
+		 * oAuth at some point in the future ... */
+		asyncLoader.execute("https://bitbucket.org/"+ owner +"/"+slug+"/changeset/"+changeset_id+"/raw/");
+        setTitle(slug + ": " + changeset_id);
+        getSupportActionBar().setSubtitle(file);
 	}
 	
 	 @Override

File src/com/saibotd/bitbeaker/IssueActivity.java

 import org.json.JSONException;
 import org.json.JSONObject;
 
+import com.actionbarsherlock.app.ActionBar;
 import com.actionbarsherlock.view.Menu;
 
 import android.app.ProgressDialog;
 		title = b.getString("title");
 		id = b.getInt("id");
 		listView = (ListView) findViewById(R.id.issue_comments_list);
-		((TextView) findViewById(R.id.issue_title)).setText(title);
 
 		progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
 		AsyncLoader asyncLoader = new AsyncLoader();
 		asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/" + id);
+		ActionBar actionBar = getSupportActionBar();
+		setTitle(slug);
+        actionBar.setSubtitle("Issue: " + title);
 	}
 	
 	 @Override

File src/com/saibotd/bitbeaker/IssuesActivity.java

 import com.actionbarsherlock.app.ActionBar;
 import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
 import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
 
 public class IssuesActivity extends MyActivity {
 
         //setListAdapter(new IssuesAdapter(this, slug, owner));
 
         setContentView(R.layout.issues);
-        setTitle(slug);
+        setTitle(slug + " issues");
 
         mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.status_of_issue, R.layout.spinner_item);
         
         //progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
     }
     
+    public boolean onCreateOptionsMenu(Menu menu) {
+        MenuInflater inflater = getSupportMenuInflater();
+        inflater.inflate(R.menu.menu_issues, menu);
+        return true;
+    }
+    
     @Override
-   	public boolean onCreateOptionsMenu(Menu menu) {
-   		return false;
+   	public boolean onOptionsItemSelected(MenuItem item) {
+       	Bundle b = new Bundle();
+   		b.putString("slug", slug);
+   		b.putString("owner", owner);
+   	    switch (item.getItemId()) {
+   		    case R.id.menu_add:
+   		    	Intent intent = new Intent(this, NewIssueActivity.class);
+   				intent.putExtras(b);
+   				startActivity(intent);
+   		        return true;
+   		    default:
+   		        return super.onOptionsItemSelected(item);
+   	    }
    	}
 
 	public void onResume(){
 		
 	};
 
-	private OnClickListener newIssueClickListener = new OnClickListener() {
-		public void onClick(View v) {
-			Intent intent = new Intent(v.getContext(), NewIssueActivity.class);
-			Bundle b = new Bundle();
-			b.putString("slug", slug);
-			b.putString("owner", owner);
-			intent.putExtras(b);
-			v.getContext().startActivity(intent);
-		}
-	};
-
 	protected void AsyncLoaderDone(String result) {
 		super.AsyncLoaderDone(result);
 		ListView listView = (ListView) findViewById(R.id.issues_list);
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-		Button newIssue = (Button) findViewById(R.id.bt_new_issue);
-		newIssue.setOnClickListener(newIssueClickListener);
 	}
 
     protected class IssuesAdapter extends MyAdapter {

File src/com/saibotd/bitbeaker/LoginActivity.java

 		setContentView(R.layout.login);
 		findViewById(R.id.login_button).setOnClickListener(clickListener);
 		getSupportActionBar().setDisplayHomeAsUpEnabled(false);
+		getSupportActionBar().hide();
 	}
 
 	private void logOut(Boolean isError) {

File src/com/saibotd/bitbeaker/MyActivity.java

 	}
 
 	protected String getAuthHTTPS(String webadress) {
+		Log.d("FETCH", webadress);
 		String cache = bitbeaker.getKV(webadress);
 		if (cache != null)
 			return cache;
 						"Basic "
 								+ Base64.encodeToString(loginString.getBytes(),
 										Base64.DEFAULT).trim());
+				Log.d("AUTH", "True");
 			}
 			if (postParams != null) {
 				urlConnection.setDoOutput(true);

File src/com/saibotd/bitbeaker/NewIssueActivity.java

         bitbeaker.delKV("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/");
         setContentView(R.layout.new_issue);
         setTitle(slug);
+        getSupportActionBar().setSubtitle("Report new issue");
         Button newIssue = (Button) findViewById(R.id.bt_save_new_issue);
 		newIssue.setOnClickListener(saveNewIssueClickListener);
     }

File src/com/saibotd/bitbeaker/RepositoriesActivity.java

 import org.json.JSONException;
 import org.json.JSONObject;
 
+import com.actionbarsherlock.app.ActionBar;
+
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
         asyncLoader.execute("https://api.bitbucket.org/1.0/user/repositories/");
         progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
         getSupportActionBar().setDisplayHomeAsUpEnabled(false);
+        ActionBar actionBar = getSupportActionBar();
+        actionBar.setSubtitle("Your repositories");
     }
     
     protected void AsyncLoaderDone(String result){

File src/com/saibotd/bitbeaker/RepositoryActivity.java

 	private String owner;
 	private String scm;
 	private Boolean firstCall;
+	private Boolean hasIssues = false;
+	private Boolean hasWiki = false;
 	
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
     }
     
     @Override
+    public boolean onPrepareOptionsMenu (Menu menu) {
+        if (hasIssues) menu.getItem(1).setVisible(true);
+        else menu.getItem(1).setVisible(false);
+        if (hasWiki) menu.getItem(2).setVisible(true);
+        else menu.getItem(2).setVisible(false);
+        return true;
+    }
+    
+    @Override
 	public boolean onOptionsItemSelected(MenuItem item) {
 	    // Handle item selection
     	Bundle b = new Bundle();
 			
 			try {
 				JSONObject jsonObject = new JSONObject(result);
-				/*
-				if(jsonObject.has("has_wiki") && jsonObject.getBoolean("has_wiki")) wiki.setEnabled(true);
-				else wiki.setEnabled(false);
-				if(jsonObject.has("has_issues") && jsonObject.getBoolean("has_issues")) issues.setEnabled(true);
-				else issues.setEnabled(false);
-				*/
-				//name.setText(jsonObject.getString("name"));
+				if(jsonObject.has("has_wiki") && jsonObject.getBoolean("has_wiki")) hasWiki = true;
+				if(jsonObject.has("has_issues") && jsonObject.getBoolean("has_issues")) hasIssues = true;
+				invalidateOptionsMenu();
+				setTitle(jsonObject.getString("name"));
 				String desc = "<b>" + jsonObject.getString("owner") + " / " + jsonObject.getString("slug") + "</b>";
 				if(!jsonObject.getString("description").trim().equals("")) desc += "<br>" + jsonObject.getString("description");
 				if(!jsonObject.getString("website").trim().equals("") && !jsonObject.getString("website").trim().equals("null")) desc += "<br><a href='"+ jsonObject.getString("website") +"'>" + jsonObject.getString("website") + "</a>";