Commits

Tobias Duehr committed 960a92d

New Issues: almost done

Comments (0)

Files changed (7)

gen/com/saibotd/bitbeaker/R.java

-/* AUTO-GENERATED FILE.  DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found.  It
- * should not be modified by hand.
- */
-
-package com.saibotd.bitbeaker;
-
-public final class R {
-    public static final class array {
-        public static final int type_of_issue=0x7f060000;
-    }
-    public static final class attr {
-    }
-    public static final class drawable {
-        public static final int add=0x7f020000;
-        public static final int bg=0x7f020001;
-        public static final int bug=0x7f020002;
-        public static final int del=0x7f020003;
-        public static final int edit=0x7f020004;
-        public static final int enhancement=0x7f020005;
-        public static final int file=0x7f020006;
-        public static final int folder=0x7f020007;
-        public static final int header=0x7f020008;
-        public static final int ic_menu_refresh=0x7f020009;
-        public static final int ic_menu_search_holo_dark=0x7f02000a;
-        public static final int ic_menu_share=0x7f02000b;
-        public static final int ic_menu_stop=0x7f02000c;
-        public static final int icon=0x7f02000d;
-        public static final int lock=0x7f02000e;
-        public static final int logo_big=0x7f02000f;
-        public static final int proposal=0x7f020010;
-        public static final int top_bg=0x7f020011;
-        public static final int top_search=0x7f020012;
-    }
-    public static final class id {
-        public static final int TextView01=0x7f08001c;
-        public static final int TextView02=0x7f08001a;
-        public static final int ad_space=0x7f080008;
-        public static final int bt_issues=0x7f080024;
-        public static final int bt_new_issue=0x7f080009;
-        public static final int bt_save_new_issue=0x7f08001e;
-        public static final int bt_search=0x7f080006;
-        public static final int bt_source_browser=0x7f080023;
-        public static final int bt_wiki=0x7f080025;
-        public static final int changeset_files=0x7f080002;
-        public static final int changeset_loading=0x7f080022;
-        public static final int changeset_message=0x7f080000;
-        public static final int changeset_what=0x7f08000c;
-        public static final int editText1=0x7f080019;
-        public static final int editText2=0x7f08001b;
-        public static final int frameLayout1=0x7f08000b;
-        public static final int header_title=0x7f080005;
-        public static final int icon=0x7f080020;
-        public static final int imageView1=0x7f080004;
-        public static final int is_locked=0x7f080011;
-        public static final int issues_list=0x7f080007;
-        public static final int issues_subtitle=0x7f08000f;
-        public static final int issues_title=0x7f08000d;
-        public static final int issues_what=0x7f08000e;
-        public static final int login_button=0x7f080017;
-        public static final int login_password=0x7f080016;
-        public static final int login_username=0x7f080015;
-        public static final int menu_logout=0x7f080029;
-        public static final int menu_refresh=0x7f080028;
-        public static final int owner_listitem_repositories=0x7f080012;
-        public static final int repositories_list=0x7f08001f;
-        public static final int repository_changesets=0x7f080021;
-        public static final int repository_description=0x7f080018;
-        public static final int source_title=0x7f080013;
-        public static final int source_webview=0x7f080026;
-        public static final int source_what=0x7f080014;
-        public static final int spinner1=0x7f08001d;
-        public static final int subtitle=0x7f08000a;
-        public static final int textView1=0x7f080001;
-        public static final int title=0x7f080003;
-        public static final int title_listitem_repositories=0x7f080010;
-        public static final int wiki_webview=0x7f080027;
-    }
-    public static final class layout {
-        public static final int changeset=0x7f030000;
-        public static final int header=0x7f030001;
-        public static final int issues=0x7f030002;
-        public static final int listitem=0x7f030003;
-        public static final int listitem_changeset=0x7f030004;
-        public static final int listitem_issues=0x7f030005;
-        public static final int listitem_repositories=0x7f030006;
-        public static final int listitem_source=0x7f030007;
-        public static final int login=0x7f030008;
-        public static final int new_issue=0x7f030009;
-        public static final int repositories=0x7f03000a;
-        public static final int repository=0x7f03000b;
-        public static final int source=0x7f03000c;
-        public static final int wiki=0x7f03000d;
-    }
-    public static final class menu {
-        public static final int mainmenu=0x7f070000;
-    }
-    public static final class string {
-        public static final int app_name=0x7f050001;
-        public static final int browse_source=0x7f05000c;
-        public static final int changes=0x7f05000b;
-        public static final int changesets=0x7f050005;
-        public static final int clear_cache=0x7f050013;
-        public static final int content=0x7f050016;
-        public static final int description=0x7f050006;
-        public static final int files=0x7f05000a;
-        public static final int hello=0x7f050000;
-        public static final int issue_tracker=0x7f050003;
-        public static final int issues=0x7f05000f;
-        public static final int log_out=0x7f050010;
-        public static final int login=0x7f050008;
-        public static final int new_issue=0x7f050014;
-        public static final int nothing=0x7f050007;
-        public static final int pleaseenterbitbucket=0x7f050009;
-        public static final int refresh=0x7f050012;
-        public static final int search_repo=0x7f050011;
-        public static final int source=0x7f05000e;
-        public static final int source_browser=0x7f05000d;
-        public static final int title=0x7f050015;
-        public static final int type=0x7f050017;
-        public static final int website=0x7f050004;
-        public static final int wiki=0x7f050002;
-    }
-    public static final class xml {
-        public static final int searchable=0x7f040000;
-    }
-}
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package com.saibotd.bitbeaker;
+
+public final class R {
+    public static final class array {
+        public static final int type_of_issue=0x7f060000;
+    }
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int add=0x7f020000;
+        public static final int bg=0x7f020001;
+        public static final int bug=0x7f020002;
+        public static final int del=0x7f020003;
+        public static final int edit=0x7f020004;
+        public static final int enhancement=0x7f020005;
+        public static final int file=0x7f020006;
+        public static final int folder=0x7f020007;
+        public static final int header=0x7f020008;
+        public static final int ic_menu_refresh=0x7f020009;
+        public static final int ic_menu_search_holo_dark=0x7f02000a;
+        public static final int ic_menu_share=0x7f02000b;
+        public static final int ic_menu_stop=0x7f02000c;
+        public static final int icon=0x7f02000d;
+        public static final int lock=0x7f02000e;
+        public static final int logo_big=0x7f02000f;
+        public static final int proposal=0x7f020010;
+        public static final int top_bg=0x7f020011;
+        public static final int top_search=0x7f020012;
+    }
+    public static final class id {
+        public static final int TextView01=0x7f08001c;
+        public static final int TextView02=0x7f08001a;
+        public static final int ad_space=0x7f080008;
+        public static final int bt_issues=0x7f080024;
+        public static final int bt_new_issue=0x7f080009;
+        public static final int bt_save_new_issue=0x7f08001e;
+        public static final int bt_search=0x7f080006;
+        public static final int bt_source_browser=0x7f080023;
+        public static final int bt_wiki=0x7f080025;
+        public static final int changeset_files=0x7f080002;
+        public static final int changeset_loading=0x7f080022;
+        public static final int changeset_message=0x7f080000;
+        public static final int changeset_what=0x7f08000c;
+        public static final int frameLayout1=0x7f08000b;
+        public static final int header_title=0x7f080005;
+        public static final int icon=0x7f080020;
+        public static final int imageView1=0x7f080004;
+        public static final int is_locked=0x7f080011;
+        public static final int issues_list=0x7f080007;
+        public static final int issues_subtitle=0x7f08000f;
+        public static final int issues_title=0x7f08000d;
+        public static final int issues_what=0x7f08000e;
+        public static final int login_button=0x7f080017;
+        public static final int login_password=0x7f080016;
+        public static final int login_username=0x7f080015;
+        public static final int menu_logout=0x7f080029;
+        public static final int menu_refresh=0x7f080028;
+        public static final int new_issue_content=0x7f08001b;
+        public static final int new_issue_title=0x7f080019;
+        public static final int new_issue_type=0x7f08001d;
+        public static final int owner_listitem_repositories=0x7f080012;
+        public static final int repositories_list=0x7f08001f;
+        public static final int repository_changesets=0x7f080021;
+        public static final int repository_description=0x7f080018;
+        public static final int source_title=0x7f080013;
+        public static final int source_webview=0x7f080026;
+        public static final int source_what=0x7f080014;
+        public static final int subtitle=0x7f08000a;
+        public static final int textView1=0x7f080001;
+        public static final int title=0x7f080003;
+        public static final int title_listitem_repositories=0x7f080010;
+        public static final int wiki_webview=0x7f080027;
+    }
+    public static final class layout {
+        public static final int changeset=0x7f030000;
+        public static final int header=0x7f030001;
+        public static final int issues=0x7f030002;
+        public static final int listitem=0x7f030003;
+        public static final int listitem_changeset=0x7f030004;
+        public static final int listitem_issues=0x7f030005;
+        public static final int listitem_repositories=0x7f030006;
+        public static final int listitem_source=0x7f030007;
+        public static final int login=0x7f030008;
+        public static final int new_issue=0x7f030009;
+        public static final int repositories=0x7f03000a;
+        public static final int repository=0x7f03000b;
+        public static final int source=0x7f03000c;
+        public static final int wiki=0x7f03000d;
+    }
+    public static final class menu {
+        public static final int mainmenu=0x7f070000;
+    }
+    public static final class string {
+        public static final int app_name=0x7f050001;
+        public static final int browse_source=0x7f05000c;
+        public static final int changes=0x7f05000b;
+        public static final int changesets=0x7f050005;
+        public static final int clear_cache=0x7f050013;
+        public static final int content=0x7f050016;
+        public static final int description=0x7f050006;
+        public static final int files=0x7f05000a;
+        public static final int hello=0x7f050000;
+        public static final int issue_tracker=0x7f050003;
+        public static final int issues=0x7f05000f;
+        public static final int log_out=0x7f050010;
+        public static final int login=0x7f050008;
+        public static final int new_issue=0x7f050014;
+        public static final int nothing=0x7f050007;
+        public static final int pleaseenterbitbucket=0x7f050009;
+        public static final int refresh=0x7f050012;
+        public static final int search_repo=0x7f050011;
+        public static final int source=0x7f05000e;
+        public static final int source_browser=0x7f05000d;
+        public static final int submit_new_issue=0x7f050018;
+        public static final int title=0x7f050015;
+        public static final int type=0x7f050017;
+        public static final int website=0x7f050004;
+        public static final int wiki=0x7f050002;
+    }
+    public static final class xml {
+        public static final int searchable=0x7f040000;
+    }
+}

res/layout/new_issue.xml

   <include layout="@layout/header" android:layout_width="match_parent" android:layout_height="wrap_content"/>
     <LinearLayout android:layout_weight="1" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content">
         <TextView android:layout_height="wrap_content" android:autoLink="all" android:linksClickable="true" android:layout_marginRight="42dip" android:layout_width="match_parent" android:id="@+id/repository_description" android:text="@string/title"></TextView>
-        <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content">
+        <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/new_issue_title">
             <requestFocus></requestFocus>
         </EditText>
         <TextView android:text="@string/content" android:autoLink="all" android:linksClickable="true" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="42dip" android:id="@+id/TextView02"></TextView>
-        <EditText android:id="@+id/editText2" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textMultiLine" android:layout_weight="1"></EditText>
+        <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textMultiLine" android:layout_weight="1" android:id="@+id/new_issue_content"></EditText>
         <TextView android:autoLink="all" android:linksClickable="true" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="42dip" android:id="@+id/TextView01" android:text="@string/type"></TextView>
-        <Spinner android:id="@+id/spinner1" android:layout_width="match_parent" android:layout_height="wrap_content" android:entries="@array/type_of_issue"></Spinner>
+        <Spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:entries="@array/type_of_issue" android:id="@+id/new_issue_type"></Spinner>
     </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:id="@+id/bt_save_new_issue" android:text="@string/new_issue"></Button>
+            <Button android:layout_width="wrap_content" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/bt_save_new_issue" android:text="@string/submit_new_issue"></Button>
         </LinearLayout>
     </LinearLayout>
   

res/values/strings.xml

         <item>enhancement</item>
         <item>proposal</item>
     </string-array>
+        <string name="submit_new_issue">Submit new issue</string>
 </resources>

src/com/saibotd/bitbeaker/Bitbeaker.java

 		return null;
 	}
 	
+	public void delKV(String key){
+		for(int i = 0; i < kv.size(); i++){
+			if(kv.get(i).key.equals(key)){
+				kv.remove(i);
+			}
+		}
+	}
+	
 	public void clearKV() {
 		kv.clear();
 	}

src/com/saibotd/bitbeaker/IssuesActivity.java

         //setListAdapter(new IssuesAdapter(this, slug, owner));
         setContentView(R.layout.issues);
         ((TextView) findViewById(R.id.header_title)).setText(slug);
-        AsyncLoader asyncLoader = new AsyncLoader();
+        //AsyncLoader asyncLoader = new AsyncLoader();
+        //asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/");
+        //progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
+    }
+    
+    public void onResume(){
+    	super.onResume();
+    	AsyncLoader asyncLoader = new AsyncLoader();
         asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/");
         progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
     }

src/com/saibotd/bitbeaker/MyActivity.java

 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
 import java.net.URL;
 
 import javax.net.ssl.HttpsURLConnection;
 	protected Bitbeaker bitbeaker;
 	protected ProgressDialog progressDialog;
 	protected AlertDialog alertDialog;
+	protected String postParams;
 	
 	public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        postParams = null;
         bitbeaker = (Bitbeaker) getApplication();
 	}
 	
 
 		@Override
 		protected String doInBackground(String... params) {
+			if(params.length ==2) postParams = params[1];
 			return getAuthHTTPS(params[0]);
 		}
 
 				String loginString = bitbeaker.getUsername() + ":" + bitbeaker.getPassword();
 				urlConnection.setRequestProperty("Authorization", "Basic " + Base64.encodeToString(loginString.getBytes(), Base64.DEFAULT).trim());
 			}
+			if(postParams != null){
+				urlConnection.setDoOutput(true);
+				OutputStreamWriter out = new OutputStreamWriter(urlConnection.getOutputStream());
+				out.write(postParams);
+				out.close();
+			}
 			in = new BufferedInputStream(urlConnection.getInputStream());
 		} catch (Exception e) {
 			e.printStackTrace();

src/com/saibotd/bitbeaker/NewIssueActivity.java

 package com.saibotd.bitbeaker;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import java.net.URLEncoder;
 
 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;
+import android.widget.AdapterView;
 import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.ListView;
+import android.widget.EditText;
+import android.widget.Spinner;
 import android.widget.TextView;
+import android.widget.Toast;
 
 public class NewIssueActivity extends MyActivity {
 	
 	private String slug;
 	private String owner;
+	private String type;
 	
     @Override
     public void onCreate(Bundle savedInstanceState) {
         Bundle b = getIntent().getExtras();
         slug = b.getString("slug");
         owner = b.getString("owner");
+        type = "bug";
         //setListAdapter(new IssuesAdapter(this, slug, owner));
         setContentView(R.layout.new_issue);
         ((TextView) findViewById(R.id.header_title)).setText(slug);
-        //AsyncLoader asyncLoader = new AsyncLoader();
-        //asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/");
-        //progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
+        Button newIssue = (Button) findViewById(R.id.bt_save_new_issue);
+		newIssue.setOnClickListener(saveNewIssueClickListener);
+		Spinner spinner =  ((Spinner) findViewById(R.id.new_issue_type));
+		spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+		    public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
+		    	type = parent.getItemAtPosition(pos).toString();
+		    	Log.d("SPINNER", type);
+		    }
+		    public void onNothingSelected(AdapterView<?> parent) {
+		    	type = "bug";
+		    }
+		});
     }
     
+    private void showLoading(){
+    	progressDialog = ProgressDialog.show(this, "", "Submitting ...", true);
+    }
+    
+    private void done(){
+    	Toast.makeText(this, "New issue submitted!", 1000);
+    	bitbeaker.delKV("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/");
+    	finish();
+    }
+    
+    
+    
     private OnClickListener saveNewIssueClickListener = 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);
+			*/
+			showLoading();
+			String title = ((EditText) findViewById(R.id.new_issue_title)).getText().toString();
+			String content = ((EditText) findViewById(R.id.new_issue_content)).getText().toString();
+	        AsyncLoader asyncLoader = new AsyncLoader();
+	        asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/", "title=" + URLEncoder.encode(title) + "&content=" + URLEncoder.encode(content) + "&kind=" + URLEncoder.encode(type));
+	        //progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
 		}
 	};
-    
+	
     protected void AsyncLoaderDone(String result) {
     	super.AsyncLoaderDone(result);
-    	ListView listView = (ListView) findViewById(R.id.issues_list);
-		try {
-			listView.setAdapter(new IssuesAdapter(this, new JSONObject(result).getJSONArray("issues")));
-		} catch (JSONException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		Button newIssue = (Button) findViewById(R.id.bt_save_new_issue);
-		newIssue.setOnClickListener(saveNewIssueClickListener);
+    	Log.d("BLA", result);
+    	done();
 	}
-    
-    protected class IssuesAdapter extends MyAdapter {
-
-
-    	
-    	public IssuesAdapter(Context context, JSONArray jsonArray) {
-    		super(context, jsonArray);
-    	}
-    	
-    	private OnClickListener clickListener = new OnClickListener() {
-    		public void onClick(View v) {
-    			try {
-    				int id = getItem(v.getId()).getInt("local_id");
-    				Bundle b = new Bundle();
-    				b.putString("slug", slug);
-    				b.putString("owner", owner);
-    				b.putInt("id", id);
-    				/*
-    				Intent intent = new Intent(v.getContext(), IssueActivity.class);
-    				intent.putExtras(b);
-    				v.getContext().startActivity(intent);
-    				*/
-    			} catch (JSONException e) {
-    				// TODO Auto-generated catch block
-    				e.printStackTrace();
-    			}
-    		}
-    	};
-    	
-    	public View getView(int position, View convertView, ViewGroup parent) {
-    		View view;
-    		if (convertView == null) {
-    			view = mFactory.inflate(R.layout.listitem_issues, null);
-    		} else {
-    			view = (View) convertView;
-    		}
-    		view.setId(position);
-    		TextView title = (TextView) view.findViewById(R.id.issues_title);
-    		TextView subtitle = (TextView) view.findViewById(R.id.issues_subtitle);
-    		ImageView icon = (ImageView) view.findViewById(R.id.issues_what);
-    		try {
-    			String type = this.getItem(position).getJSONObject("metadata").getString("kind");
-    			title.setText(this.getItem(position).getString("title"));
-    			subtitle.setText(this.getItem(position).getString("created_on") + " - " + this.getItem(position).getString("comment_count") + " comment(s)");
-    			if(type.equals("bug")) icon.setImageResource(R.drawable.bug);
-    			if(type.equals("enhancement")) icon.setImageResource(R.drawable.enhancement);
-    			if(type.equals("proposal")) icon.setImageResource(R.drawable.proposal);
-    		} catch (JSONException e) {
-    			// TODO Auto-generated catch block
-    			e.printStackTrace();
-    		}
-    		view.setOnClickListener(clickListener);
-    		return view;
-    	}
-
-    }
-
-    
+	
     
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.