[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
Next Next commit
Replace category list in EditPost by category buttons
- click on category remove it from the post
- introduce a new layout: FlowLayout
- some refactoring (don't use JSONArray to manipulate data)
  • Loading branch information
maxme committed Jul 25, 2013
commit 37b22400e5c2082a9e7d1d38fef0313b796433e9
4 changes: 2 additions & 2 deletions res/layout/add_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:src="@drawable/wpcom" />

<RelativeLayout
android:id="@+id/section1"
android:id="@+id/sectionContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/wpcomLogo"
Expand Down Expand Up @@ -93,7 +93,7 @@
android:id="@+id/l_wordpressdotcom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/section1"
android:layout_below="@id/sectionContent"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:shadowColor="#FFFFFF"
Expand Down
2 changes: 1 addition & 1 deletion res/layout/add_account_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:paddingRight="10dip" >

<RelativeLayout
android:id="@+id/section1"
android:id="@+id/sectionContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dip"
Expand Down
14 changes: 7 additions & 7 deletions res/layout/blog_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:paddingRight="@dimen/settings_padding" >

<RelativeLayout
android:id="@+id/section1"
android:id="@+id/sectionContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

Expand Down Expand Up @@ -69,10 +69,10 @@
</RelativeLayout>

<RelativeLayout
android:id="@+id/section2"
android:id="@+id/sectionTags"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/section1"
android:layout_below="@id/sectionContent"
android:layout_marginTop="8dp" >

<TextView
Expand Down Expand Up @@ -131,10 +131,10 @@
</RelativeLayout>

<RelativeLayout
android:id="@+id/section3"
android:id="@+id/sectionLocation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/section2"
android:layout_below="@id/sectionTags"
android:layout_marginTop="8dp" >

<TextView
Expand All @@ -153,10 +153,10 @@
</RelativeLayout>

<RelativeLayout
android:id="@+id/section4"
android:id="@+id/sectionSettings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/section3"
android:layout_below="@id/sectionLocation"
android:layout_marginTop="8dp" >

<TextView
Expand Down
1 change: 0 additions & 1 deletion res/layout/categories_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:checkMark="?android:attr/listChoiceIndicatorMultiple" />

8 changes: 8 additions & 0 deletions res/layout/category_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/categoryButton"
android:drawableRight="@android:drawable/ic_delete"/>
9 changes: 9 additions & 0 deletions res/layout/category_select_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/selectCategories"
android:drawableRight="@android:drawable/ic_input_add"
android:tag="select-category"/>
33 changes: 13 additions & 20 deletions res/layout/edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
android:padding="8dp" >

<LinearLayout
android:id="@+id/section1"
android:id="@+id/sectionContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
Expand All @@ -45,11 +45,11 @@
</LinearLayout>

<LinearLayout
android:id="@+id/section2"
android:id="@+id/sectionTags"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="vertical" >
android:orientation="vertical">

<EditText
android:id="@+id/tags"
Expand All @@ -59,25 +59,18 @@
android:hint="@string/tags_separate_with_commas"
android:inputType="textAutoCorrect" />

<Button
android:id="@+id/selectCategories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/select_categories" />

<TextView
android:id="@+id/selectedCategories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:text="@string/selected_categories"
android:textColor="#444444"
android:visibility="gone" />
</LinearLayout>

<org.wordpress.android.util.FlowLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/sectionCategories" android:paddingLeft="8dp">
<TextView android:id="@+id/textView"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:text="@string/selected_categories"
android:paddingTop="10dp" />
</org.wordpress.android.util.FlowLayout>
<RelativeLayout
android:id="@+id/section3"
android:id="@+id/sectionLocation"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="10dp"
Expand Down Expand Up @@ -127,7 +120,7 @@
</RelativeLayout>

<LinearLayout
android:id="@+id/section4"
android:id="@+id/sectionSettings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
Expand Down
2 changes: 1 addition & 1 deletion res/layout/edit_comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:paddingTop="8dp" >

<RelativeLayout
android:id="@+id/section1"
android:id="@+id/sectionContent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
Expand Down
11 changes: 11 additions & 0 deletions res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="FlowLayout">
<attr name="horizontalSpacing" format="dimension"/>
<attr name="verticalSpacing" format="dimension"/>
</declare-styleable>
<declare-styleable name="FlowLayout_LayoutParams">
<attr name="layout_horizontalSpacing" format="dimension"/>
<attr name="layout_verticalSpacing" format="dimension"/>
</declare-styleable>
</resources>
4 changes: 2 additions & 2 deletions src/org/wordpress/android/WordPressDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -1269,10 +1269,10 @@ public int updatePost(Post post, int blogID) {
values.put("mt_text_more", post.getMt_text_more());
values.put("uploaded", post.isUploaded());

if (post.getCategories() != null) {
if (post.getJSONCategories() != null) {
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray(post.getCategories().toString());
jsonArray = new JSONArray(post.getJSONCategories().toString());
values.put("categories", jsonArray.toString());
} catch (JSONException e) {
e.printStackTrace();
Expand Down
4 changes: 2 additions & 2 deletions src/org/wordpress/android/models/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void setLocalDraft(boolean localDraft) {
this.localDraft = localDraft;
}

public JSONArray getCategories() {
public JSONArray getJSONCategories() {
JSONArray jArray = null;
if (categories == null)
categories = "";
Expand All @@ -169,7 +169,7 @@ public JSONArray getCategories() {
return jArray;
}

public void setCategories(JSONArray categories) {
public void setJSONCategories(JSONArray categories) {
this.categories = categories.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public void run() {
Thread shake = new Thread() {
public void run() {
Animation shake = AnimationUtils.loadAnimation(AccountSetupActivity.this, R.anim.shake);
findViewById(R.id.section1).startAnimation(shake);
findViewById(R.id.sectionContent).startAnimation(shake);
Toast.makeText(AccountSetupActivity.this, getString(R.string.invalid_login), Toast.LENGTH_SHORT).show();
}
};
Expand Down
Loading