[go: nahoru, domu]

Skip to content

Commit

Permalink
Remove auto addition of special "Uncategorized" category
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Jul 26, 2013
1 parent d4bf822 commit 5c7d537
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
<string name="media">Media</string>

<!-- category management -->
<string name="category">Category</string>
<string name="add_new_category">Add New Category</string>
<string name="category_name">Category Name</string>
<string name="category_slug">Category Slug (optional)</string>
Expand Down
29 changes: 6 additions & 23 deletions src/org/wordpress/android/ui/posts/EditPostActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.view.*;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
Expand Down Expand Up @@ -92,7 +91,6 @@ public class EditPostActivity extends SherlockActivity implements OnClickListene
private static final int ID_DIALOG_LOADING = 2;

private static final String CATEGORY_PREFIX_TAG = "category-";
private static final String UNCATEGORIZED_LABEL = "Uncategorized";

private Blog mBlog;
private Post mPost;
Expand Down Expand Up @@ -416,7 +414,6 @@ else if (mQuickMediaType == Constants.QUICK_POST_VIDEO_LIBRARY)
}
}

// if mCategories is empty or if mIsNew, we want to add an "Uncategorized" category
populateSelectedCategories();

registerForContextMenu(mAddPictureButton);
Expand Down Expand Up @@ -1336,17 +1333,6 @@ private void onCategoryButtonClick(View v) {

private void populateSelectedCategories() {
ViewGroup sectionCategories = ((ViewGroup) findViewById(R.id.sectionCategories));
boolean uncategorizedAlone = false;

// We want an "Uncategorized" if no category selected
if (mCategories.size() == 0) {
mCategories.add(UNCATEGORIZED_LABEL);
uncategorizedAlone = true;
} else { // Check for an alone "Uncategorized"
if (mCategories.size() == 1 && mCategories.get(0).equals(UNCATEGORIZED_LABEL)) {
uncategorizedAlone = true;
}
}

// Remove previous category buttons if any + select category button
List<View> viewsToRemove = new ArrayList<View>();
Expand All @@ -1365,25 +1351,22 @@ private void populateSelectedCategories() {

// New category buttons
LayoutInflater layoutInflater = getLayoutInflater();
List<View> categoryButtons = new ArrayList<View>();
for (int i = 0; i < mCategories.size(); i++) {
String categoryName = mCategories.get(i);
Button buttonCategory = (Button) layoutInflater.inflate(R.layout.category_button, null);
buttonCategory.setText(categoryName);
buttonCategory.setTag(CATEGORY_PREFIX_TAG + categoryName);
buttonCategory.setOnClickListener(this);
// Special case for Uncategorized, remove drawable left and disable
if (uncategorizedAlone) {
buttonCategory.setCompoundDrawables(null, null, null, null);
buttonCategory.setEnabled(false);
buttonCategory.setPadding(buttonCategory.getPaddingLeft(), buttonCategory.getPaddingTop(),
buttonCategory.getPaddingLeft(), buttonCategory.getPaddingBottom());
}
sectionCategories.addView(buttonCategory);
}

// Add select category button
View selectCategory = layoutInflater.inflate(R.layout.category_select_button, null);
Button selectCategory = (Button) layoutInflater.inflate(R.layout.category_select_button, null);
if (mCategories.size() == 0) {
selectCategory.setText(getResources().getText(R.string.category));
} else {
selectCategory.setText("");
}
selectCategory.setOnClickListener(this);
sectionCategories.addView(selectCategory);
}
Expand Down

0 comments on commit 5c7d537

Please sign in to comment.