Commits

Juha Kuitunen committed 2f7938a

hard coded strings, wiki uses repository name as a title instead of slug

  • Participants
  • Parent commits bdda843

Comments (0)

Files changed (3)

src/com/saibotd/bitbeaker/AsyncLoader.java

 public class AsyncLoader extends AbstractAsyncLoader<String, Integer, String> {
 	
 	private String http_method = "GET";
+	private static final String FAIL = "Fail";
 	
 	public AsyncLoader(MyActivity parentActivity, String user, String pass) {
 		super(parentActivity, user, pass);
 			in = new BufferedInputStream(urlConnection.getInputStream());
 		} catch (Exception e) {
 			e.printStackTrace();
-			return "Fail";
+			return FAIL;
 		}
 		String result = Helper.convertStreamToString(in);
 		if (http_method.equals("GET") && !Helper.isEmpty(result) && result.length() < 100000)
 			parent.setSupportProgressBarIndeterminateVisibility(false);
 		} catch(Exception e){  }
 		if (parent.getProgressDialog() != null) parent.getProgressDialog().dismiss();
-		if(result.equals("Fail")){
+		if(result.equals(FAIL)){
 			try {
 				AlertDialog alertDialog = new AlertDialog.Builder(parent).create();
 				alertDialog.setTitle(R.string.oops);

src/com/saibotd/bitbeaker/RepositoryActivity.java

 public class RepositoryActivity extends MyActivity {
     
 	private String slug;
+	private String repositoryName;
 	private String owner;
 	private String[] branches = new String[0];
 	private boolean firstCall;
 				return true;
 		    case R.id.menu_wiki:
 		    	Intent wikiIntent = new Intent(this, WikiActivity.class);
+		    	b.putString("repositoryName", repositoryName);
 		    	wikiIntent.putExtras(b);
 				startActivity(wikiIntent);
 				return true;
 				hasWiki = repository.has("has_wiki") && repository.getBoolean("has_wiki");
 				hasIssues = repository.has("has_issues") && repository.getBoolean("has_issues");
 				invalidateOptionsMenu();
-				setTitle(repository.getString("name"));
+				repositoryName = repository.getString("name");
+				setTitle(repositoryName);
 				StringBuilder desc = new StringBuilder();
 				if (Boolean.parseBoolean(repository.getString("is_fork"))) {
 					final JSONObject original = repository.getJSONObject("fork_of");

src/com/saibotd/bitbeaker/WikiActivity.java

 public class WikiActivity extends MyActivity {
 
 	private String slug;
+	private String repositoryName;
 	private String owner;
 	private String data; 
 	private WebView webView;
 
-    @SuppressLint("SetJavaScriptEnabled")
-    @Override
+	@SuppressLint("SetJavaScriptEnabled")
+	@Override
 	public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.wiki);
-        Bundle b = getIntent().getExtras();
-        slug = b.getString("slug");
-        owner = b.getString("owner");
-        setTitle(slug + " wiki");
-        executeAsyncLoader(API_BASE_URL + "/repositories/"+ owner +"/"+ slug +"/wiki/");
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.wiki);
+		Bundle b = getIntent().getExtras();
+		slug = b.getString("slug");
+		repositoryName = b.getString("repositoryName");
+		owner = b.getString("owner");
+		setTitle(repositoryName + " " + this.getString(R.string.wiki));
+		executeAsyncLoader(API_BASE_URL + "/repositories/"+ owner +"/"+ slug +"/wiki/");
 
 		webView = (WebView) findViewById(R.id.wiki_webview);
 		webView.getSettings().setBuiltInZoomControls(true);
 		webView.addJavascriptInterface(new JavaScriptInterface(), "bitbeaker");
 		webView.setWebChromeClient(new WebChromeClient());
 	}
-    
-    @Override
+
+	@Override
 	public boolean onCreateOptionsMenu(Menu menu) {
 		return false;
 	}
 
-    @Override
+	@Override
 	public void asyncLoaderDone(String result) {
 		super.asyncLoaderDone(result);
 		try {