Commits

Tobias Duehr committed dfc9da1

- Got rid of the "Loading ..." Alert Boxes
- Started with "Add comment to issue"
- Removed unneeded imports

  • Participants
  • Parent commits a325ba6

Comments (0)

Files changed (14)

File res/layout/issue.xml

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
-  xmlns:android="http://schemas.android.com/apk/res/android"
-  android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
+  android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">
     <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">
+
+        <LinearLayout
+            android:id="@+id/issue_layout"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:focusableInTouchMode="true"
+            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>
             <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_status" android:text="@string/nothing" android:paddingTop="4dip"></TextView>
         </LinearLayout>
     </ScrollView>
-    <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_comments_list" android:layout_margin="4dip"></ListView>
+
+    <ListView
+        android:id="@+id/issue_comments_list"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_margin="4dip"
+
+ >
+
+</ListView>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical" >
+
+        <EditText
+            android:id="@+id/issue_new_comment"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:ems="10"
+            android:hint="@string/new_comment_hint"
+            android:inputType="textMultiLine" >
+
+        </EditText>
+
+    </LinearLayout>
+
 </LinearLayout>

File res/menu/menu_add.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/add" android:showAsAction="always|withText" android:icon="@drawable/plus_alt_32x32"></item>
+    
+
+</menu>

File res/values/strings.xml

         <item>wontfix</item>
     </string-array>
         <string name="menu_source">Source</string>
+        <string name="submit_comment">Submit</string>
+        <string name="new_comment_hint">Leave a comment</string>
+        <string name="add">Add</string>
 
 </resources>

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

 import android.widget.TextView;
 
 import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockActivity;
 import com.actionbarsherlock.view.Menu;
 
 public class ChangesetActivity extends MyActivity {
 		ActionBar actionBar = getSupportActionBar();
 		setTitle(slug);
         actionBar.setSubtitle("Changeset: " + changeset_id);
+        setSupportProgressBarIndeterminateVisibility(false);
     }
     
     @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;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.webkit.WebChromeClient;
 import android.webkit.WebView;
-import android.widget.TextView;
+
+import com.actionbarsherlock.view.Menu;
 
 public class DiffActivity extends MyActivity {
 
 		changeset_id = b.getString("changeset");
 		file = b.getString("file");
 
-		progressDialog = ProgressDialog.show(this, "", "Loading diff...", true);
 		AsyncLoader asyncLoader = new AsyncLoader();
 		/*
 		 * TODO: authenticate to get diff for own private repositories

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;
 import android.content.Context;
+import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.EditText;
 import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.TextView;
 
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.view.ActionMode;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+
 public class IssueActivity extends MyActivity {
 
 	private String slug;
 	private String title;
 	private int id;
 	private ListView listView;//issue's content and comments
+	ActionMode mMode;
 
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
 		id = b.getInt("id");
 		listView = (ListView) findViewById(R.id.issue_comments_list);
 
-		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);
+        
+        ((EditText)findViewById(R.id.issue_new_comment)).setOnFocusChangeListener(new View.OnFocusChangeListener() {
+
+			@Override
+			public void onFocusChange(View v, boolean hasFocus) {
+				Log.d("EDIT", v.toString());
+        		if(hasFocus){
+        			mMode = startActionMode(new NewCommentActionMode());
+        		} else {
+        			if (mMode != null) mMode.finish();
+        		}
+        	}
+		});
 	}
 	
-	 @Override
-		public boolean onCreateOptionsMenu(Menu menu) {
-			return false;
-		}
+	public boolean onCreateOptionsMenu(Menu menu) {
+        MenuInflater inflater = getSupportMenuInflater();
+        inflater.inflate(R.menu.menu_issues, menu);
+        return true;
+    }
+    
+    @Override
+   	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);
+   	    }
+   	}
+    
+    private final class NewCommentActionMode implements ActionMode.Callback {
+        @Override
+        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+            return true;
+        }
+
+        @Override
+        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+            return false;
+        }
+
+        @Override
+        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+            Log.d("ITEM", item.toString());
+            mode.finish();
+            return true;
+        }
+
+        @Override
+        public void onDestroyActionMode(ActionMode mode) {
+        }
+    }
 
 	public void AsyncLoaderDone(String result) {
 		super.AsyncLoaderDone(result);
 			e.printStackTrace();
 		}
 
-		progressDialog = ProgressDialog.show(IssueActivity.this, "", "Loading comments...", true);
 		AsyncCommentsLoader asyncCommentsLoader = new AsyncCommentsLoader();
+		setSupportProgressBarIndeterminateVisibility(true);
 		asyncCommentsLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/" + id + "/comments/");
 	}
 
 		@Override
 		protected void onPostExecute(String result) {
 			AsyncCommentsLoaderDone(result);
+			setSupportProgressBarIndeterminateVisibility(false);
 		}
 	}
 

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

 import org.json.JSONException;
 import org.json.JSONObject;
 
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 		super.onResume();
 		AsyncLoader asyncLoader = new AsyncLoader();
 		asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/" + filter);
-		progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
 	}
 
 	private OnNavigationListener mNavigationCallback = new OnNavigationListener() {

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

 import android.os.Bundle;
 import android.util.Base64;
 import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
 
 import com.actionbarsherlock.app.SherlockActivity;
 import com.actionbarsherlock.view.Menu;
 import com.actionbarsherlock.view.MenuInflater;
 import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.view.Window;
 
 public class MyActivity extends SherlockActivity {
 
 
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
+		requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
 		postParams = null;
 		ignoreError = false;
 		bitbeaker = (Bitbeaker) getApplication();
 
 	protected void AsyncLoaderDone(String result) {
 		Log.d("RESULT", result);
+		setSupportProgressBarIndeterminateVisibility(false);
 		if (progressDialog != null)
 			progressDialog.dismiss();
 		if (ignoreError == false && (result == null || result.length() == 0)) {
 				postParams = params[1];
 			return getAuthHTTPS(params[0]);
 		}
+		
+		@Override
+		protected void onPreExecute() {
+			setSupportProgressBarIndeterminateVisibility(true);
+		}
 
 		@Override
 		protected void onPostExecute(String result) {

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;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.Spinner;
-import android.widget.TextView;
 import android.widget.Toast;
 
+import com.actionbarsherlock.view.Menu;
+
 public class NewIssueActivity extends MyActivity {
 	
 	private String slug;

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;
 import android.os.Bundle;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
-import android.widget.ImageButton;
 import android.widget.ListView;
 import android.widget.TextView;
 
+import com.actionbarsherlock.app.ActionBar;
+
 public class RepositoriesActivity extends MyActivity {
 	
     @Override
         
         AsyncLoader asyncLoader = new AsyncLoader();
         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");

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

 import org.json.JSONException;
 import org.json.JSONObject;
 
-import android.app.ProgressDialog;
 import android.content.Intent;
 import android.os.Bundle;
 import android.text.Html;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
-import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
         setTitle(slug);
         AsyncLoader asyncLoader = new AsyncLoader();
         asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/");
-        progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
     }
     
     public boolean onCreateOptionsMenu(Menu menu) {

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

 package com.saibotd.bitbeaker;
 
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.view.Menu;
-
-import android.app.ProgressDialog;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.util.Log;
 import android.webkit.JsResult;
 import android.webkit.WebChromeClient;
 import android.webkit.WebView;
-import android.widget.TextView;
+
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.view.Menu;
 
 public class SourceActivity extends MyActivity {
     
         scm = b.getString("scm");
         owner = b.getString("owner");
         file = b.getString("file");
-        progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
         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));

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

 import org.json.JSONException;
 import org.json.JSONObject;
 
-import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
         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

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;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;
-import android.widget.TextView;
+
+import com.actionbarsherlock.view.Menu;
 
 public class WikiActivity extends MyActivity {
 
         Bundle b = getIntent().getExtras();
         slug = b.getString("slug");
         owner = b.getString("owner");
-        progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
         setTitle(slug + " wiki");
         AsyncLoader asyncLoader = new AsyncLoader();
         asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/wiki/");