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

Bugfixes #56

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions res/layout/categories_row_parent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/category_row_height"
android:orientation="horizontal"
android:id="@+id/categoryRow" android:clickable="false">
<ImageView android:layout_width="@dimen/category_row_height"
android:layout_height="@dimen/category_row_height"
android:src="@drawable/ic_level_indicator"
android:id="@+id/categoryRowLevelIndicator" android:scaleType="fitEnd"/>
<TextView
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:textColor="#464646"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:id="@+id/categoryRowText"/>
</LinearLayout>
30 changes: 7 additions & 23 deletions src/org/wordpress/android/ui/posts/AddCategoryActivity.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package org.wordpress.android.ui.posts;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

import org.wordpress.android.R;
import org.wordpress.android.WordPress;
import org.wordpress.android.models.CategoryNode;

import java.util.ArrayList;

public class AddCategoryActivity extends Activity {
private int id;
@Override
Expand Down Expand Up @@ -51,7 +47,7 @@ public void onClick(View v) {
Spinner sCategories = (Spinner) findViewById(R.id.parent_category);
String parent_category = "";
if (sCategories.getSelectedItem() != null)
parent_category = sCategories.getSelectedItem().toString().trim();
parent_category = ((CategoryNode)sCategories.getSelectedItem()).getName().trim();
int parent_id = 0;
if (sCategories.getSelectedItemPosition() != 0){
parent_id = WordPress.wpDB.getCategoryId(id, parent_category);
Expand Down Expand Up @@ -105,25 +101,14 @@ public void onClick(View v) {
}

private void loadCategories() {
ArrayList<CharSequence> loadTextArray = new ArrayList<CharSequence>();
CategoryNode rootCategory = CategoryNode.createCategoryTreeFromDB(id);
ArrayList<CategoryNode> categoryLevels = CategoryNode.getSortedListOfCategoriesFromRoot(rootCategory);
categoryLevels.add(0, new CategoryNode(0, 0, getString(R.string.none)));
if (categoryLevels.size() > 0) {
loadTextArray.add(getResources().getText(R.string.none));
for (int i = 0; i < categoryLevels.size(); i++) {
CategoryNode currentCategory = categoryLevels.get(i);
String name = "";
for (int j = 1; j < currentCategory.getLevel(); j++) {
name += " ";
}
name += Html.fromHtml(currentCategory.getName());
loadTextArray.add(name);
}
ArrayAdapter<CharSequence> categories = new ArrayAdapter<CharSequence>(this,
android.R.layout.simple_dropdown_item_1line, loadTextArray);
categories.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ParentCategorySpinnerAdapter categoryAdapter = new ParentCategorySpinnerAdapter(this,
R.layout.categories_row_parent, categoryLevels);
Spinner sCategories = (Spinner) findViewById(R.id.parent_category);
sCategories.setAdapter(categories);
sCategories.setAdapter(categoryAdapter);
}
}

Expand All @@ -132,5 +117,4 @@ public void onConfigurationChanged(Configuration newConfig) {
//ignore orientation change
super.onConfigurationChanged(newConfig);
}

}
4 changes: 3 additions & 1 deletion src/org/wordpress/android/ui/posts/CategoryArrayAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
import java.util.List;

public class CategoryArrayAdapter extends ArrayAdapter<CategoryNode> {
int mResourceId;

public CategoryArrayAdapter(Context context, int resource, List<CategoryNode> objects) {
super(context, resource, objects);
mResourceId = resource;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.categories_row, parent, false);
View rowView = inflater.inflate(mResourceId, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.categoryRowText);
ImageView levelIndicatorView = (ImageView) rowView.findViewById(R.id.categoryRowLevelIndicator);
textView.setText(Html.fromHtml(getItem(position).getName()));
Expand Down
73 changes: 45 additions & 28 deletions src/org/wordpress/android/ui/posts/EditPostActivity.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
package org.wordpress.android.ui.posts;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Vector;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
Expand Down Expand Up @@ -74,14 +56,21 @@
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
<<<<<<< HEAD
=======
import android.widget.ScrollView;
>>>>>>> c30d056... fix #32: removed a call to showFormatBar() on OnTouch events triggered when ContentText is touched
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;
<<<<<<< HEAD

=======
>>>>>>> c30d056... fix #32: removed a call to showFormatBar() on OnTouch events triggered when ContentText is touched
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuInflater;
Expand All @@ -90,14 +79,10 @@
import com.android.volley.toolbox.ImageLoader.ImageListener;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONArray;
import org.xmlrpc.android.ApiHelper;

import org.wordpress.android.Constants;
import org.wordpress.android.R;
import org.wordpress.android.WordPress;
import org.wordpress.passcodelock.AppLockManager;
import org.wordpress.android.models.Blog;
import org.wordpress.android.models.MediaFile;
import org.wordpress.android.models.MediaGallery;
Expand All @@ -119,6 +104,26 @@
import org.wordpress.android.util.WPHtml;
import org.wordpress.android.util.WPImageSpan;
import org.wordpress.android.util.WPUnderlineSpan;
import org.wordpress.passcodelock.AppLockManager;
import org.xmlrpc.android.ApiHelper;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Vector;

public class EditPostActivity extends SherlockFragmentActivity implements OnClickListener, OnTouchListener, TextWatcher,
WPEditText.OnSelectionChangedListener, OnFocusChangeListener, WPEditText.EditTextImeBackListener {
Expand Down Expand Up @@ -476,6 +481,21 @@ else if (mQuickMediaType == Constants.QUICK_POST_VIDEO_LIBRARY)
}
}

<<<<<<< HEAD
=======
final ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView);
scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
scrollView.setFocusable(true);
scrollView.setFocusableInTouchMode(true);
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.requestFocusFromTouch();
return false;
}
});

>>>>>>> c30d056... fix #32: removed a call to showFormatBar() on OnTouch events triggered when ContentText is touched
populateSelectedCategories();

registerForContextMenu(mAddPictureButton);
Expand Down Expand Up @@ -623,10 +643,11 @@ else if (mQuickMediaType == Constants.QUICK_POST_VIDEO_CAMERA || mQuickMediaType

@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus && mFormatBar.getVisibility() != View.VISIBLE)
if (hasFocus && mFormatBar.getVisibility() != View.VISIBLE) {
showFormatBar();
else if (!hasFocus && mFormatBar.getVisibility() == View.VISIBLE)
} else if (!hasFocus && mFormatBar.getVisibility() == View.VISIBLE) {
hideFormatBar();
}
}

@Override
Expand Down Expand Up @@ -744,10 +765,6 @@ else if (mQuickMediaType == Constants.QUICK_POST_VIDEO_CAMERA || mQuickMediaType

@Override
public boolean onTouch(View v, MotionEvent event) {

if (mFormatBar.getVisibility() != View.VISIBLE)
showFormatBar();

float pos = event.getY();

if (event.getAction() == 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.wordpress.android.ui.posts;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import org.wordpress.android.R;
import org.wordpress.android.models.CategoryNode;

import java.util.List;


public class ParentCategorySpinnerAdapter extends BaseAdapter implements SpinnerAdapter {
int mResourceId;
List<CategoryNode> mObjects;
Context mContext;

public int getCount() {
return mObjects.size();
}

public CategoryNode getItem(int position) {
return mObjects.get(position);
}

public long getItemId(int position) {
return position;
}

public ParentCategorySpinnerAdapter(Context context, int resource, List<CategoryNode> objects) {
super();
mContext = context;
mObjects = objects;
mResourceId = resource;
}

@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(mResourceId, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.categoryRowText);
ImageView levelIndicatorView = (ImageView) rowView.findViewById(R.id.categoryRowLevelIndicator);
textView.setText(Html.fromHtml(getItem(position).getName()));
int level = getItem(position).getLevel();
if (level == 1) { // hide ImageView
levelIndicatorView.setVisibility(View.GONE);
} else {
ViewGroup.LayoutParams params = levelIndicatorView.getLayoutParams();
params.width = (params.width / 2) * level;
levelIndicatorView.setLayoutParams(params);
}
return rowView;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(mResourceId, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.categoryRowText);
ImageView levelIndicatorView = (ImageView) rowView.findViewById(R.id.categoryRowLevelIndicator);
textView.setText(Html.fromHtml(getItem(position).getName()));
levelIndicatorView.setVisibility(View.GONE);
return rowView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3)
}
}
});

mSelectedCategories = new HashSet<String>();

Bundle extras = getIntent().getExtras();
Expand All @@ -89,6 +89,9 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3)
if (extras.containsKey("categories"))
mSelectedCategories = (HashSet<String>) extras.getSerializable("categories");
}
if (mSelectedCategories == null) {
mSelectedCategories = new HashSet<String>();
}

populateOrFetchCategories();
}
Expand Down