Commits

Tobias Duehr  committed b2db2c0

- Unified the UI with ActionBarSherlock4 (Work in progress)
- Fixed the search activity for non logged in users
- Added icons (not final)

  • Participants
  • Parent commits 74afb52

Comments (0)

Files changed (38)

 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="src" path="gen"/>
 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
 	<classpathentry kind="output" path="bin/classes"/>
 </classpath>

File AndroidManifest.xml

     <uses-permission android:name="android.permission.INTERNET"></uses-permission>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 
-    <application android:label="@string/app_name" android:theme="@style/bbTheme" android:icon="@drawable/icon" android:name="Bitbeaker">
+    <application android:label="@string/app_name" android:theme="@style/Theme.Sherlock.Light.DarkActionBar" android:icon="@drawable/icon" android:name="Bitbeaker">
         <activity android:label="@string/app_name" android:name="LoginActivity" android:noHistory="true">
         	<meta-data android:name="android.app.default_searchable" android:value=".SearchableActivity" />
             <intent-filter>
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <activity android:name="RepositoryActivity">
+        <activity android:name="RepositoryActivity" android:uiOptions="splitActionBarWhenNarrow">
         	<meta-data android:name="android.app.default_searchable" android:value=".SearchableActivity" />
         </activity>
         <activity android:name="EventsActivity"></activity>

File default.properties

-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
 # Project target.
-target=android-8
-
+target=android-15

File project.properties

+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-15
+android.library.reference.1=../../Apps/JakeWharton-ActionBarSherlock-2eabf25/library

File res/drawable-mdpi/chat_alt_fill_32x32.png

Added
New image

File res/drawable-mdpi/document_alt_stroke_24x32.png

Added
New image

File res/drawable-mdpi/eye_32x24.png

Added
New image

File res/drawable-mdpi/lightbulb_20x32.png

Added
New image

File res/drawable-mdpi/magnifying_glass_32x32.png

Added
New image

File res/layout/changeset.xml

 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
-  <include layout="@layout/header"  android:layout_width="match_parent" android:layout_height="wrap_content"/>
     <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="4dip">
         <TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:id="@+id/changeset_message" android:text="@string/description"></TextView>
     </LinearLayout>

File res/layout/diff.xml

   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent" android:orientation="vertical">
-    <include layout="@layout/header" android:layout_height="wrap_content" android:layout_width="match_parent"></include>
     <WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/diff_webview"></WebView>
 </LinearLayout>

File res/layout/header.xml

-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout
-  xmlns:android="http://schemas.android.com/apk/res/android"
-  android:background="@drawable/top_bg" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/title">
-    <ImageView android:id="@+id/imageView1" android:src="@drawable/header" android:minHeight="0dip" android:layout_height="54dip" android:paddingLeft="10dip" android:layout_width="130dip"></ImageView>
-    <TextView android:layout_width="wrap_content" android:layout_height="54dip" android:layout_gravity="center|center_vertical|right" android:layout_marginRight="5dip" android:id="@+id/header_title" android:paddingLeft="150dip" android:gravity="center_vertical|right" android:text="@string/nothing"></TextView>
-    <ImageButton android:background="@drawable/top_search" android:layout_gravity="right" android:id="@+id/bt_search" android:src="@drawable/ic_menu_search_holo_dark" android:layout_height="54dip" android:layout_width="54dip" android:visibility="gone" android:focusable="true" android:focusableInTouchMode="true"></ImageButton>
-</FrameLayout>

File res/layout/issue.xml

 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
-  <include layout="@layout/header"  android:layout_width="match_parent" android:layout_height="wrap_content"/>
     <ScrollView android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_margin="4dip">
         <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_layout" android:orientation="vertical">
             <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_title" android:textSize="18dip" android:text="@string/nothing"></TextView>

File res/layout/issues.xml

     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     >
-    <include layout="@layout/header" android:layout_width="match_parent" android:layout_height="wrap_content"/>
     <Spinner
         android:id="@+id/issueSpinner"
         android:layout_width="match_parent"

File res/layout/login.xml

 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
-  android:orientation="vertical" android:layout_height="match_parent" android:background="@drawable/bg">
-  <include layout="@layout/header" android:layout_width="match_parent" android:layout_height="wrap_content"/>
-    <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_weight="1" android:orientation="vertical">
-        <ImageView android:layout_height="wrap_content" android:layout_width="match_parent" android:src="@drawable/logo_big" android:layout_margin="10dip"></ImageView>
+  android:orientation="vertical" android:layout_height="match_parent">
+    <LinearLayout android:layout_height="0dip" android:layout_width="match_parent" android:layout_weight="1" android:orientation="vertical" android:background="@drawable/bg">
+        <ImageView android:layout_height="wrap_content" android:layout_width="match_parent" android:src="@drawable/logo_big" android:layout_margin="10dip" android:padding="16dip"></ImageView>
     </LinearLayout>
     <ScrollView android:id="@+id/scrollView1" android:layout_height="wrap_content" android:layout_width="match_parent">
         <LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="match_parent">

File res/layout/new_issue.xml

 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
-  <include layout="@layout/header" android:layout_width="match_parent" android:layout_height="wrap_content"/>
   <ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="wrap_content">
       <LinearLayout android:layout_width="match_parent" android:orientation="vertical" android:layout_height="wrap_content">
           <TextView android:text="@string/title" android:autoLink="all" android:layout_margin="5dip" android:layout_height="wrap_content" android:id="@+id/repository_description" android:layout_width="match_parent" android:linksClickable="true"></TextView>

File res/layout/repositories.xml

     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     >
-    <include layout="@layout/header" android:layout_width="match_parent" android:layout_height="wrap_content"/>
     <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/repositories_list"></ListView>
     </LinearLayout>
-    <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/ad_space"></LinearLayout>
 </LinearLayout>

File res/layout/repository.xml

 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
-  <include layout="@layout/header" android:layout_width="match_parent" android:layout_height="wrap_content"/>
     <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
         <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="4dip">
             <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/repository_description" android:text="@string/nothing" android:layout_marginRight="42dip" android:autoLink="all" android:linksClickable="true"></TextView>
         <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/repository_changesets"></ListView>
         <ProgressBar android:id="@+id/changeset_loading" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center|center_vertical" android:layout_marginTop="30dip"></ProgressBar>
     </LinearLayout>
-    <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="horizontal" >
-        <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
-            <Button android:layout_width="wrap_content" android:layout_weight="1" android:layout_height="wrap_content" android:text="@string/source" android:id="@+id/bt_source_browser"></Button>
-            <Button android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:enabled="false" android:text="@string/issues" android:id="@+id/bt_issues"></Button>
-            <Button android:layout_width="wrap_content" android:layout_weight="1" android:layout_height="wrap_content" android:text="@string/wiki" android:id="@+id/bt_wiki" android:enabled="false"></Button>
-        </LinearLayout>
-    </LinearLayout>
   
 </LinearLayout>

File res/layout/source.xml

   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent" android:orientation="vertical">
-    <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
-        <include layout="@layout/header" android:layout_height="wrap_content" android:layout_width="match_parent"></include>
-    </LinearLayout>
     <WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/source_webview"></WebView>
 </LinearLayout>

File res/layout/wiki.xml

   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent" android:orientation="vertical">
-    <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
-        <include layout="@layout/header" android:layout_height="wrap_content" android:layout_width="match_parent"></include>
-    </LinearLayout>
     <WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/wiki_webview"></WebView>
 </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: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|collapseActionView" android:icon="@drawable/magnifying_glass_32x32" android:actionViewClass="android.widget.SearchView"></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_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>
+    
+
+</menu>

File res/values-v11/themes.xml

-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-    <style parent="@android:style/Theme.DeviceDefault.Light.NoActionBar" name="bbTheme"></style>
-    
-</resources>

File res/values/strings.xml

         <item>duplicate</item>
         <item>wontfix</item>
     </string-array>
+        <string name="menu_source">Source</string>
 
 </resources>

File res/values/themes.xml

-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-    <style parent="@android:style/Theme.Light.NoTitleBar" name="bbTheme"></style>
-    
-</resources>

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

 import org.json.JSONException;
 import org.json.JSONObject;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.widget.ListView;
 import android.widget.TextView;
 
-public class ChangesetActivity extends Activity {
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+
+public class ChangesetActivity extends MyActivity {
 
 	private JSONObject mData;
 	private String changeset_id;
         super.onCreate(savedInstanceState);
         setContentView(R.layout.changeset);
         
-        ((TextView) findViewById(R.id.header_title)).setText("Changeset");
-        
         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) {
 		}
     }
     
+    @Override
+   	public boolean onCreateOptionsMenu(Menu menu) {
+   		return false;
+   	}
+    
     protected class ChangesetAdapter extends MyAdapter {
 
     	public ChangesetAdapter(Context context, JSONArray jsonArray) {

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

 package com.saibotd.bitbeaker;
 
+import com.actionbarsherlock.view.Menu;
+
 import android.app.ProgressDialog;
 import android.os.Bundle;
 import android.text.TextUtils;
 		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 
-		((TextView) findViewById(R.id.header_title)).setText("Diff: "+changeset_id);
+		setTitle("Diff: "+changeset_id);
+	}
+	
+	 @Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		return false;
 	}
 
 	public void AsyncLoaderDone(String result) {

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

 import org.json.JSONException;
 import org.json.JSONObject;
 
+import com.actionbarsherlock.view.Menu;
+
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.os.Bundle;
 		AsyncLoader asyncLoader = new AsyncLoader();
 		asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/" + id);
 	}
+	
+	 @Override
+		public boolean onCreateOptionsMenu(Menu menu) {
+			return false;
+		}
 
 	public void AsyncLoaderDone(String result) {
 		super.AsyncLoaderDone(result);

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

 import org.json.JSONException;
 import org.json.JSONObject;
 
+import com.actionbarsherlock.view.Menu;
+
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
         //setListAdapter(new IssuesAdapter(this, slug, owner));
 
         setContentView(R.layout.issues);
-        ((TextView) findViewById(R.id.header_title)).setText(slug);
+        setTitle(slug);
 
         filterSpinner = (Spinner) findViewById(R.id.issueSpinner);
         filterSpinner.setSelection(1);// default open & new instead of show all
         //asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/");
         //progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
     }
+    
+    @Override
+   	public boolean onCreateOptionsMenu(Menu menu) {
+   		return false;
+   	}
 
 	public void onResume(){
 		super.onResume();

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

 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.util.Base64;
-import android.view.Menu;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.EditText;
-import android.widget.ImageButton;
 
 public class LoginActivity extends MyActivity {
-	
 
-	
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        
-        try{
-	        Bundle b = getIntent().getExtras();
-	        if(b.containsKey("logout")) logOut(false);
-        } catch(Exception e) {}
-        if(bitbeaker.getSettings().contains("username")){
-        	progressDialog = ProgressDialog.show(this, bitbeaker.getUsername(), "Logging in ...", true);
-        	new CheckLogin().execute();
-        }
-        setContentView(R.layout.login);
-    	findViewById(R.id.login_button).setOnClickListener(clickListener);
-    	ImageButton search = (ImageButton) findViewById(R.id.bt_search);
-        search.setVisibility(ImageButton.VISIBLE);
-        search.setOnClickListener(searchClickListener);
-        search.requestFocus();
-    }
-    
-    public boolean onCreateOptionsMenu(Menu menu) {
-	    return false;
+	public void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+
+		try {
+			Bundle b = getIntent().getExtras();
+			if (b.containsKey("logout"))
+				logOut(false);
+		} catch (Exception e) {
+		}
+		if (bitbeaker.getSettings().contains("username")) {
+			progressDialog = ProgressDialog.show(this, bitbeaker.getUsername(),
+					"Logging in ...", true);
+			new CheckLogin().execute();
+		}
+		setContentView(R.layout.login);
+		findViewById(R.id.login_button).setOnClickListener(clickListener);
+		getSupportActionBar().setDisplayHomeAsUpEnabled(false);
 	}
-    
-    private void logOut(Boolean isError){
-    	if(progressDialog != null) progressDialog.dismiss();
-    	bitbeaker.logOut();
-    	if(isError){
-    		AlertDialog alertDialog = new AlertDialog.Builder(this).create();
+
+	private void logOut(Boolean isError) {
+		if (progressDialog != null)
+			progressDialog.dismiss();
+		bitbeaker.logOut();
+		if (isError) {
+			AlertDialog alertDialog = new AlertDialog.Builder(this).create();
 			alertDialog.setTitle("Login failed");
 			alertDialog.setMessage("Please check your username and password.");
 			alertDialog.show();
-    	}
-    	bitbeaker.clearKV();
-    }
-    
-    private void logInOK(){
-    	if(progressDialog != null) progressDialog.dismiss();
-    	Intent intent = new Intent(this, RepositoriesActivity.class);
-    	startActivity(intent);
-    	finish();
-    }
-    
-    private OnClickListener clickListener = new OnClickListener() {
+		}
+		bitbeaker.clearKV();
+	}
+
+	private void logInOK() {
+		if (progressDialog != null) {
+			try {
+				progressDialog.dismiss();
+			} catch (Exception e) {
+			}
+		}
+		Intent intent = new Intent(this, RepositoriesActivity.class);
+		startActivity(intent);
+		finish();
+	}
+
+	private OnClickListener clickListener = new OnClickListener() {
 		public void onClick(View v) {
-			progressDialog = ProgressDialog.show(v.getContext(), "", "Logging in ...", true);
-			String username = ((EditText) findViewById(R.id.login_username)).getText().toString();
-			String password = ((EditText) findViewById(R.id.login_password)).getText().toString();
+			progressDialog = ProgressDialog.show(v.getContext(), "",
+					"Logging in ...", true);
+			String username = ((EditText) findViewById(R.id.login_username))
+					.getText().toString();
+			String password = ((EditText) findViewById(R.id.login_password))
+					.getText().toString();
 			bitbeaker.setUsername(username);
 			bitbeaker.setPassword(password);
 			new CheckLogin().execute();
 		}
 	};
-	
+
 	private class CheckLogin extends AsyncTask<String, Integer, Boolean> {
 		protected Boolean doInBackground(String... params) {
-	    	Boolean all_fine = true;
+			Boolean all_fine = true;
 			try {
-				
+
 				/* This is an awful way to check the login! */
-				
-				URL url = new URL("https://api.bitbucket.org/1.0/user/repositories/");
+
+				URL url = new URL(
+						"https://api.bitbucket.org/1.0/user/repositories/");
 				HttpsURLConnection urlConnection;
 				urlConnection = (HttpsURLConnection) url.openConnection();
-				String loginString = bitbeaker.getUsername() + ":" + bitbeaker.getPassword();
-				urlConnection.setRequestProperty("Authorization", "Basic " + Base64.encodeToString(loginString.getBytes(), Base64.DEFAULT).trim()); 			
+				String loginString = bitbeaker.getUsername() + ":"
+						+ bitbeaker.getPassword();
+				urlConnection.setRequestProperty(
+						"Authorization",
+						"Basic "
+								+ Base64.encodeToString(loginString.getBytes(),
+										Base64.DEFAULT).trim());
 				@SuppressWarnings("unused")
-				InputStream in = new BufferedInputStream(urlConnection.getInputStream());
+				InputStream in = new BufferedInputStream(
+						urlConnection.getInputStream());
 			} catch (Exception e) {
 				all_fine = false;
 			}
 			return all_fine;
-	    }
+		}
 
-	    protected void onPostExecute(Boolean result) {
-	    	if(result) logInOK();
-	    	else logOut(true);
-	    }
+		protected void onPostExecute(Boolean result) {
+			if (result)
+				logInOK();
+			else
+				logOut(true);
+		}
 	};
 }

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

 
 import javax.net.ssl.HttpsURLConnection;
 
-import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.ProgressDialog;
 import android.content.DialogInterface;
 import android.os.Bundle;
 import android.util.Base64;
 import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
 
-public class MyActivity extends Activity {
-	
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
+public class MyActivity extends SherlockActivity {
+
 	protected Bitbeaker bitbeaker;
 	protected ProgressDialog progressDialog;
 	protected AlertDialog alertDialog;
 	protected String postParams;
 	protected Boolean ignoreError;
-	
+
 	public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        postParams = null;
-        ignoreError = false;
-        bitbeaker = (Bitbeaker) getApplication();
-        System.setProperty("http.keepAlive", "false");
+		super.onCreate(savedInstanceState);
+		postParams = null;
+		ignoreError = false;
+		bitbeaker = (Bitbeaker) getApplication();
+		System.setProperty("http.keepAlive", "false");
+		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 	}
-	
-	public void onDestroy(){
+
+	public void onDestroy() {
 		Log.d("Activity", "Destroy");
 		super.onDestroy();
 	}
-	
-	protected OnClickListener searchClickListener = new OnClickListener() {
-		public void onClick(View v) {
-			onSearchRequested();
-		}
-	};
-	
+
+	@Override
 	public boolean onCreateOptionsMenu(Menu menu) {
-	    MenuInflater inflater = getMenuInflater();
-	    inflater.inflate(R.menu.mainmenu, menu);
-	    return true;
+		MenuInflater inflater = getSupportMenuInflater();
+		inflater.inflate(R.menu.mainmenu, menu);
+		return true;
 	}
-	
+
 	@Override
 	public boolean onOptionsItemSelected(MenuItem item) {
-	    // Handle item selection
-	    switch (item.getItemId()) {
-	    case R.id.menu_refresh:
-	        bitbeaker.clearKV();
-	        return true;
-	    case R.id.menu_logout:
-	    	Intent intent = new Intent(this, LoginActivity.class);
+		// Handle item selection
+		switch (item.getItemId()) {
+		case R.id.menu_refresh:
+			bitbeaker.clearKV();
+			return true;
+		case R.id.menu_logout:
+			Intent intent = new Intent(this, LoginActivity.class);
 			Bundle b = new Bundle();
 			b.putBoolean("logout", true);
 			intent.putExtras(b);
 			startActivity(intent);
 			finish();
 			return true;
-	    default:
-	        return super.onOptionsItemSelected(item);
-	    }
+		case R.id.menu_search:
+			onSearchRequested();
+			return true;
+		case android.R.id.home:
+			finish();
+			return true;
+		default:
+			return super.onOptionsItemSelected(item);
+		}
 	}
-	
+
 	protected void AsyncLoaderDone(String result) {
 		Log.d("RESULT", result);
-		if(progressDialog != null) progressDialog.dismiss();
-		if(ignoreError == false && (result == null || result.length() == 0)){
-			alertDialog = new AlertDialog.Builder(this).create();
-		    alertDialog.setTitle("Oops.");
-		    alertDialog.setMessage("There was a problem retrieving and/or processing data from Bitbucket.org. Checking your data connectivity and trying again might help.");
-		    alertDialog.show();
+		if (progressDialog != null)
+			progressDialog.dismiss();
+		if (ignoreError == false && (result == null || result.length() == 0)) {
+			try {
+				alertDialog = new AlertDialog.Builder(this).create();
+				alertDialog.setTitle("Oops.");
+				alertDialog
+						.setMessage("There was a problem retrieving and/or processing data from Bitbucket.org. Checking your data connectivity and trying again might help.");
+				alertDialog.show();
+			} catch (Exception e) {
+			}
 		}
 		ignoreError = false;
 	}
-	
-	protected class AsyncLoader extends AsyncTask<String, Integer, String> implements OnCancelListener {
+
+	protected class AsyncLoader extends AsyncTask<String, Integer, String>
+			implements OnCancelListener {
 
 		@Override
 		protected String doInBackground(String... params) {
-			if(params.length == 2) postParams = params[1];
+			if (params.length == 2)
+				postParams = params[1];
 			return getAuthHTTPS(params[0]);
 		}
 
 		}
 
 	}
-	
+
 	protected String getAuthHTTPS(String webadress) {
 		String cache = bitbeaker.getKV(webadress);
-        if(cache != null) return cache;
+		if (cache != null)
+			return cache;
 		URL url;
 		InputStream in = null;
 		try {
 			url = new URL(webadress);
-			HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
+			HttpsURLConnection urlConnection = (HttpsURLConnection) url
+					.openConnection();
 			urlConnection.setUseCaches(true);
-			if(!bitbeaker.getUsername().equals("")){
-				String loginString = bitbeaker.getUsername() + ":" + bitbeaker.getPassword();
-				urlConnection.setRequestProperty("Authorization", "Basic " + Base64.encodeToString(loginString.getBytes(), Base64.DEFAULT).trim());
+			if (!bitbeaker.getUsername().equals("")) {
+				String loginString = bitbeaker.getUsername() + ":"
+						+ bitbeaker.getPassword();
+				urlConnection.setRequestProperty(
+						"Authorization",
+						"Basic "
+								+ Base64.encodeToString(loginString.getBytes(),
+										Base64.DEFAULT).trim());
 			}
-			if(postParams != null){
+			if (postParams != null) {
 				urlConnection.setDoOutput(true);
-				OutputStreamWriter out = new OutputStreamWriter(urlConnection.getOutputStream());
+				OutputStreamWriter out = new OutputStreamWriter(
+						urlConnection.getOutputStream());
 				out.write(postParams);
 				Log.d("POST", postParams);
 				out.close();
 			e.printStackTrace();
 		}
 		String result = convertStreamToString(in);
-		if(!result.trim().equals("") && result.length() < 100000) bitbeaker.setKV(webadress, result);
+		if (!result.trim().equals("") && result.length() < 100000)
+			bitbeaker.setKV(webadress, result);
 		return result;
 	}
-	
+
 	private static String convertStreamToString(InputStream is) {
 
 		String line = null;
 		try {
-			BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+			BufferedReader reader = new BufferedReader(
+					new InputStreamReader(is));
 			StringBuilder sb = new StringBuilder();
 			while ((line = reader.readLine()) != null) {
 				sb.append(line + "\n");
 		}
 		return "";
 	}
-	
+
 }

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

 
 import java.net.URLEncoder;
 
+import com.actionbarsherlock.view.Menu;
+
 import android.app.ProgressDialog;
 import android.os.Bundle;
 import android.view.View;
         owner = b.getString("owner");
         bitbeaker.delKV("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/");
         setContentView(R.layout.new_issue);
-        ((TextView) findViewById(R.id.header_title)).setText(slug);
+        //((TextView) findViewById(R.id.header_title)).setText(slug);
         Button newIssue = (Button) findViewById(R.id.bt_save_new_issue);
 		newIssue.setOnClickListener(saveNewIssueClickListener);
     }
     
+    @Override
+   	public boolean onCreateOptionsMenu(Menu menu) {
+   		return false;
+   	}
+    
     private void showLoading(){
     	progressDialog = ProgressDialog.show(this, "", "Submitting ...", true);
     }

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

         super.onCreate(savedInstanceState);
         
         setContentView(R.layout.repositories);
-        ImageButton search = (ImageButton) findViewById(R.id.bt_search);
-        search.setVisibility(ImageButton.VISIBLE);
-        search.setOnClickListener(searchClickListener);
+        //ImageButton search = (ImageButton) findViewById(R.id.bt_search);
+        //search.setVisibility(ImageButton.VISIBLE);
+        //search.setOnClickListener(searchClickListener);
         
         AsyncLoader asyncLoader = new AsyncLoader();
         asyncLoader.execute("https://api.bitbucket.org/1.0/user/repositories/");
         progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
+        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
     }
     
     protected void AsyncLoaderDone(String result){

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

 import android.widget.ListView;
 import android.widget.TextView;
 
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
 public class RepositoryActivity extends MyActivity {
     
 	private String slug;
         Log.d("SLUG", slug);
         Log.d("SCM", scm);
         Log.d("OWNER", owner);
+        setTitle(slug);
         AsyncLoader asyncLoader = new AsyncLoader();
         asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/");
         progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
     }
     
-	private OnClickListener sourceBrowserClickListener = new OnClickListener() {
-		public void onClick(View v) {
-	    	Intent intent = new Intent(v.getContext(), SourceBrowserActivity.class);
-			Bundle b = new Bundle();
-			b.putString("slug", slug);
-			b.putString("owner", owner);
-			b.putString("scm", scm);
-			b.putString("subdir", "/");
-			intent.putExtras(b);
-			v.getContext().startActivity(intent);
-		}
-	};
-	
-	private OnClickListener wikiBrowserClickListener = new OnClickListener() {
-		public void onClick(View v) {
-	    	Intent intent = new Intent(v.getContext(), WikiActivity.class);
-			Bundle b = new Bundle();
-			b.putString("slug", slug);
-			b.putString("owner", owner);
-			intent.putExtras(b);
-			v.getContext().startActivity(intent);
-		}
-	};
-	
-	private OnClickListener issuesBrowserClickListener = new OnClickListener() {
-		public void onClick(View v) {
-	    	Intent intent = new Intent(v.getContext(), IssuesActivity.class);
-			Bundle b = new Bundle();
-			b.putString("slug", slug);
-			b.putString("owner", owner);
-			intent.putExtras(b);
-			v.getContext().startActivity(intent);
-		}
-	};
+    public boolean onCreateOptionsMenu(Menu menu) {
+        MenuInflater inflater = getSupportMenuInflater();
+        inflater.inflate(R.menu.menu_repository, menu);
+        return true;
+    }
+    
+    @Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+	    // Handle item selection
+    	Bundle b = new Bundle();
+		b.putString("slug", slug);
+		b.putString("owner", owner);
+		b.putString("scm", scm);
+		b.putString("subdir", "/");
+	    switch (item.getItemId()) {
+		    case R.id.menu_source:
+		    	Intent sourceIntent = new Intent(this, SourceBrowserActivity.class);
+				sourceIntent.putExtras(b);
+				startActivity(sourceIntent);
+		        return true;
+		    case R.id.menu_issues:
+		    	Intent intent = new Intent(this, IssuesActivity.class);
+				intent.putExtras(b);
+				startActivity(intent);
+				return true;
+		    case R.id.menu_wiki:
+		    	Intent wikiIntent = new Intent(this, WikiActivity.class);
+		    	wikiIntent.putExtras(b);
+				startActivity(wikiIntent);
+				return true;
+		    case android.R.id.home:
+		    	finish();
+		    	return true;
+		    default:
+		        return super.onOptionsItemSelected(item);
+	    }
+	}
 	
 	private JSONArray reverse(JSONArray a) throws JSONException{
 		JSONArray _a = new JSONArray();
 		super.AsyncLoaderDone(result);
 		if(firstCall){
 			firstCall = false;
-			Button sourceBrowser = (Button) findViewById(R.id.bt_source_browser);
-			sourceBrowser.setOnClickListener(sourceBrowserClickListener);
 			
-			Button wiki = (Button) findViewById(R.id.bt_wiki);
-			wiki.setOnClickListener(wikiBrowserClickListener);
-			
-			Button issues = (Button) findViewById(R.id.bt_issues);
-			issues.setOnClickListener(issuesBrowserClickListener);
-			
-			TextView name = (TextView) findViewById(R.id.header_title);
+			//TextView name = (TextView) findViewById(R.id.header_title);
 			TextView description = (TextView) findViewById(R.id.repository_description);
 			
 			ImageView icon = (ImageView) findViewById(R.id.icon);
 			
 			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"));
+				*/
+				//name.setText(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>";

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

 	          AsyncLoader asyncLoader = new AsyncLoader();
 	          asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/?name=" + query);
 	          progressDialog = ProgressDialog.show(this, "", "Searching ...", true);
-	          ((TextView) findViewById(R.id.header_title)).setText("Results for \"" + query + "\"");
+	          setTitle("Results for \"" + query + "\"");
           } else {
         	  Toast.makeText(this, "Please enter at least 3 letters.", Toast.LENGTH_LONG).show();
           }
     				Bundle b = new Bundle();
     				b.putString("slug", rec.getString("slug"));
     				b.putString("owner", rec.getString("owner"));
+    				b.putString("scm", rec.getString("scm"));
     				intent.putExtras(b);
     				v.getContext().startActivity(intent);
     			} catch (JSONException e) {

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

 package com.saibotd.bitbeaker;
 
+import com.actionbarsherlock.view.Menu;
+
 import android.app.ProgressDialog;
 import android.os.Bundle;
 import android.text.TextUtils;
         AsyncLoader asyncLoader = new AsyncLoader();
         if(scm.equals("git")) asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+slug+"/raw/master" + replace_whitespace(file));
         else asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+slug+"/raw/tip" + replace_whitespace(file));
-        ((TextView) findViewById(R.id.header_title)).setText(slug + file);
+        setTitle(slug + file);
     }
     
+    @Override
+   	public boolean onCreateOptionsMenu(Menu menu) {
+   		return false;
+   	}
+    
     private String replace_whitespace(String in) {
     	//java.net.URLEncoder.encode(String, "UTF-8") did not gave right results
     	return in.replaceAll(" ", "%20");

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

 import org.json.JSONException;
 import org.json.JSONObject;
 
+import com.actionbarsherlock.view.Menu;
+
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
         subdir = b.getString("subdir");
         //setListAdapter(new SourceBrowserAdapter(this, slug, owner, subdir));
         setContentView(R.layout.repositories);
-        ((TextView) findViewById(R.id.header_title)).setText(slug + subdir);
+        setTitle(slug + subdir);
         AsyncLoader asyncLoader = new AsyncLoader();
         if(scm.equals("git")) asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/" + owner + "/"+slug+"/src/master" + replace_whitespace(subdir));
         else asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/" + owner + "/"+slug+"/src/tip" + replace_whitespace(subdir));
         progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
     }
     
+    @Override
+   	public boolean onCreateOptionsMenu(Menu menu) {
+   		return false;
+   	}
+    
     private String replace_whitespace(String in) {
     	//java.net.URLEncoder.encode(String, "UTF-8") did not gave right results
     	return in.replaceAll(" ", "%20");

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

 import org.json.JSONException;
 import org.json.JSONObject;
 
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+
 import android.app.ProgressDialog;
 import android.os.Bundle;
 import android.webkit.WebChromeClient;
         slug = b.getString("slug");
         owner = b.getString("owner");
         progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
-        ((TextView) findViewById(R.id.header_title)).setText(slug + "/wiki");
+        setTitle(slug + " wiki");
         AsyncLoader asyncLoader = new AsyncLoader();
         asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/wiki/");
 
 		webView.addJavascriptInterface(new JavaScriptInterface(), "bitbeaker");
 		webView.setWebChromeClient(new WebChromeClient());
 	}
+    
+    @Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		return false;
+	}
 
 	public void AsyncLoaderDone(String result) {
 		super.AsyncLoaderDone(result);