Commits

Juha Kuitunen committed 009e460

bugfix: access folders with whitespace character in the name

Comments (0)

Files changed (2)

src/com/saibotd/bitbeaker/SourceActivity.java

         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" + file);
-        else asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+slug+"/raw/tip" + file);
+        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);
     }
+    
+    private String replace_whitespace(String in) {
+    	//java.net.URLEncoder.encode(String, "UTF-8") did not gave right results
+    	return in.replaceAll(" ", "%20");
+    }
 	
 	public void AsyncLoaderDone(String result) {
 		super.AsyncLoaderDone(result);

src/com/saibotd/bitbeaker/SourceBrowserActivity.java

 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;
         setContentView(R.layout.repositories);
         ((TextView) findViewById(R.id.header_title)).setText(slug + subdir);
         AsyncLoader asyncLoader = new AsyncLoader();
-        if(scm.equals("git")) asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/" + owner + "/"+slug+"/src/master" + subdir);
-        else asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/" + owner + "/"+slug+"/src/tip" + subdir);
+        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);
     }
     
+    private String replace_whitespace(String in) {
+    	//java.net.URLEncoder.encode(String, "UTF-8") did not gave right results
+    	return in.replaceAll(" ", "%20");
+    }
+    
     protected void AsyncLoaderDone(String result) {
     	super.AsyncLoaderDone(result);
     	JSONArray jsonArray = new JSONArray();