1. German Larrain
  2. bitbeaker

Commits

Juha Kuitunen  committed e4dfba1

same thing as in a5e88d294f3d to prioritySpinner and StatusSpinner

  • Participants
  • Parent commits a5e88d2
  • Branches default

Comments (0)

Files changed (4)

File res/layout/new_issue.xml

View file
  • Ignore whitespace
             <Spinner
                 android:id="@+id/new_issue_status"
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:entries="@array/issue_status_options" />
+                android:layout_height="wrap_content" />
 
             <!-- Issue type -->
 
             <Spinner
                 android:id="@+id/new_issue_priority"
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:entries="@array/priority_of_issue" >
+                android:layout_height="wrap_content" >
             </Spinner>
         </LinearLayout>
     </ScrollView>

File res/values/strings.xml

View file
  • Ignore whitespace
         <item>duplicate</item>
         <item>wontfix</item>
     </string-array>
-    <string-array name="issue_status_options">
-        <item>new</item>
-        <item>open</item>
-        <item>resolved</item>
-        <item>on hold</item>
-        <item>invalid</item>
-        <item>duplicate</item>
-        <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="proceed">Proceed</string>
     <string name="submit">Submit</string>
     <string name="priority">Priority</string>
-    <string-array name="priority_of_issue">
-        <item>trivial</item>
-        <item>minor</item>
-        <item>major</item>
-        <item>critical</item>
-        <item>blocker</item>
-    </string-array>
     
     <!-- MyActivity.java -->
     <string name="AsyncErrorMSG">There was a problem retrieving and/or processing data from Bitbucket.org. Checking your data connectivity and trying again might help.</string>
     <string name="changeset_not_found">Changeset not found!</string>
     <string name="link_not_supported">Unsupported link type!</string>
     
-    <!-- These Strings are translated versions of various Strings used in API queries if we need to show them to user. -->
+    <!-- These Strings are translated versions of various Strings used in API queries if we need to show them to user.
+         Mappings to real API Strings are made in Helper class -->
     <string name="api_status_new">New</string>
     <string name="api_status_open">Open</string>
     <string name="api_status_resolved">Resolved</string>

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

View file
  • Ignore whitespace
 
 	public String slug;
 	public String owner;
-	private Spinner typeSpinner;
+	private Spinner typeSpinner, prioritySpinner, statusSpinner;
 
 	@Override
 	public void onCreate(Bundle savedInstanceState) {
 
 		typeSpinner = (Spinner) findViewById(R.id.new_issue_type);
 		String[] typeOptions = {
-				Helper.translatedApiStrings.getByKey("bug"),
-				Helper.translatedApiStrings.getByKey("enhancement"),
-				Helper.translatedApiStrings.getByKey("proposal"),
-				Helper.translatedApiStrings.getByKey("task")
+			Helper.translatedApiStrings.getByKey("bug"),
+			Helper.translatedApiStrings.getByKey("enhancement"),
+			Helper.translatedApiStrings.getByKey("proposal"),
+			Helper.translatedApiStrings.getByKey("task")
 		};
 		ArrayAdapter<String> typeSpinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, typeOptions);
 		typeSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 		typeSpinner.setAdapter(typeSpinnerArrayAdapter);
+
+		prioritySpinner = (Spinner) findViewById(R.id.new_issue_priority);
+		String[] priorityOptions = {
+			Helper.translatedApiStrings.getByKey("trivial"),
+			Helper.translatedApiStrings.getByKey("minor"),
+			Helper.translatedApiStrings.getByKey("major"),
+			Helper.translatedApiStrings.getByKey("critical"),
+			Helper.translatedApiStrings.getByKey("blocker")
+		};
+		ArrayAdapter<String> prioritySpinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, priorityOptions);
+		prioritySpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+		prioritySpinner.setAdapter(prioritySpinnerArrayAdapter);
+
+		statusSpinner = (Spinner) findViewById(R.id.new_issue_status);
+		String[] statusOptions = {
+			Helper.translatedApiStrings.getByKey("new"),
+			Helper.translatedApiStrings.getByKey("open"),
+			Helper.translatedApiStrings.getByKey("resolved"),
+			Helper.translatedApiStrings.getByKey("on hold"),
+			Helper.translatedApiStrings.getByKey("invalid"),
+			Helper.translatedApiStrings.getByKey("duplicate"),
+			Helper.translatedApiStrings.getByKey("wontfix")
+		};
+		ArrayAdapter<String> statusSpinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, statusOptions);
+		statusSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+		statusSpinner.setAdapter(statusSpinnerArrayAdapter);
 	}
 
 	@Override
 			String content = ((EditText) findViewById(R.id.new_issue_content)).getText().toString();
 
 			String type = Helper.translatedApiStrings.getByValue(typeSpinner.getSelectedItem().toString());
-
-			String priority;
-			switch (((Spinner) findViewById(R.id.new_issue_priority)).getSelectedItemPosition()) {
-				case 0:
-					priority = "trivial";
-					break;
-				case 1:
-					priority = "minor";
-					break;
-				case 2:
-					priority = "major";
-					break;
-				case 3:
-					priority = "critical";
-					break;
-				case 4:
-					priority = "blocker";
-					break;
-				default:
-					priority = "major";
-			}
-			String status;
-			switch (((Spinner) findViewById(R.id.new_issue_status)).getSelectedItemPosition()) {
-				case 0:
-					status = "new";
-					break;
-				case 1:
-					status = "open";
-					break;
-				case 2:
-					status = "resolved";
-					break;
-				case 3:
-					status = "on%20hold";
-					break;
-				case 4:
-					status = "invalid";
-					break;
-				case 5:
-					status = "duplicate";
-					break;
-				case 6:
-					status = "wontfix";
-					break;
-				default:
-					status = "new";
-			}
+			String priority = Helper.translatedApiStrings.getByValue(prioritySpinner.getSelectedItem().toString());
+			String status = Helper.translatedApiStrings.getByValue(statusSpinner.getSelectedItem().toString());
 
 			executeAsyncLoader(API_BASE_URL + "/repositories/" 
 					+ owner + "/" + slug

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

View file
  • Ignore whitespace
 			initialType = issueJson.getJSONObject("metadata").getString("kind");
 			typeSpinner = (Spinner) findViewById(R.id.new_issue_type);
 			String[] typeOptions = {
-					Helper.translatedApiStrings.getByKey("bug"),
-					Helper.translatedApiStrings.getByKey("enhancement"),
-					Helper.translatedApiStrings.getByKey("proposal"),
-					Helper.translatedApiStrings.getByKey("task")
+				Helper.translatedApiStrings.getByKey("bug"),
+				Helper.translatedApiStrings.getByKey("enhancement"),
+				Helper.translatedApiStrings.getByKey("proposal"),
+				Helper.translatedApiStrings.getByKey("task")
 			};
 			ArrayAdapter<String> typeSpinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, typeOptions);
 			typeSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 			// Issue priority.
 			initialPriority = issueJson.getString("priority");
 			prioritySpinner = (Spinner) findViewById(R.id.new_issue_priority);
-			String[] priorityOptions = getResources().getStringArray(R.array.priority_of_issue);
+			String[] priorityOptions = {
+				Helper.translatedApiStrings.getByKey("trivial"),
+				Helper.translatedApiStrings.getByKey("minor"),
+				Helper.translatedApiStrings.getByKey("major"),
+				Helper.translatedApiStrings.getByKey("critical"),
+				Helper.translatedApiStrings.getByKey("blocker")
+			};
+			ArrayAdapter<String> prioritySpinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, priorityOptions);
+			prioritySpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+			prioritySpinner.setAdapter(prioritySpinnerArrayAdapter);
 			int priority_index = 0;
 			for (String priority : priorityOptions) {
 				if (priority.equalsIgnoreCase(initialPriority)) {
 				++priority_index;
 			}
 			prioritySpinner.setSelection(priority_index);
-			
+
 			// Issue status.
 			initialStatus = issueJson.getString("status");
 			statusSpinner = (Spinner) findViewById(R.id.new_issue_status);
-			String[] statusOptions = getResources().getStringArray(R.array.issue_status_options);
+			String[] statusOptions = {
+				Helper.translatedApiStrings.getByKey("new"),
+				Helper.translatedApiStrings.getByKey("open"),
+				Helper.translatedApiStrings.getByKey("resolved"),
+				Helper.translatedApiStrings.getByKey("on hold"),
+				Helper.translatedApiStrings.getByKey("invalid"),
+				Helper.translatedApiStrings.getByKey("duplicate"),
+				Helper.translatedApiStrings.getByKey("wontfix")
+			};
+			ArrayAdapter<String> statusSpinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, statusOptions);
+			statusSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+			statusSpinner.setAdapter(statusSpinnerArrayAdapter);
 			int status_index = 0;
 			for (String status : statusOptions) {
 				if (status.equalsIgnoreCase(initialStatus)) {
 
 			}
 			
-			if (!initialPriority.equalsIgnoreCase(prioritySpinner.getSelectedItem().toString())) {
+			if (!initialPriority.equalsIgnoreCase(Helper.translatedApiStrings.getByValue(prioritySpinner.getSelectedItem().toString()))) {
 
 				if (0 < postParams.length()) {
 					postParams += "&priority=";
 				} else {
 					postParams = "priority=";
 				}
-				postParams += prioritySpinner.getSelectedItem().toString();
+				postParams += Helper.translatedApiStrings.getByValue(prioritySpinner.getSelectedItem().toString());
 
 			}
 			
-			if (!initialStatus.equalsIgnoreCase(statusSpinner.getSelectedItem().toString())) {
+			if (!initialStatus.equalsIgnoreCase(Helper.translatedApiStrings.getByValue(statusSpinner.getSelectedItem().toString()))) {
 
 				if (0 < postParams.length()) {
 					postParams += "&status=";
 				} else {
 					postParams = "status=";
 				}
-				postParams += statusSpinner.getSelectedItem().toString();
+				postParams += Helper.translatedApiStrings.getByValue(statusSpinner.getSelectedItem().toString());
 
 			}