[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectCategory and AddCategory activities refreshed #21

Merged
merged 13 commits into from
Jul 31, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove auto addition of special "Uncategorized" category
  • Loading branch information
maxme committed Jul 26, 2013
commit 5c7d5379b934ffb6bfb440251569c3777de7b589
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