fix API 8 usage

This commit is contained in:
Pavol Zibrita 2012-06-18 14:56:43 +02:00
parent e01598b47f
commit 52fe3bb571
2 changed files with 38 additions and 12 deletions

View file

@ -0,0 +1,34 @@
package net.osmand;
import android.content.Context;
import android.content.res.Configuration;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class AndroidUtils {
/**
* @param context
* @return true if Hardware keyboard is available
*/
public static boolean isHardwareKeyboardAvailable(Context context) {
return context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
}
/**
* @param context
*/
public static void softKeyboardDelayed(final View view) {
view.post(new Runnable() {
@Override
public void run() {
if (!isHardwareKeyboardAvailable(view.getContext())) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
}
}
});
}
}

View file

@ -9,6 +9,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
import net.osmand.FavouritePoint;
import net.osmand.GPXUtilities;
@ -125,20 +126,11 @@ public class MapActivityActions implements DialogProvider {
args.putSerializable(KEY_FAVORITE, point);
final EditText editText = (EditText) dialog.findViewById(R.id.Name);
editText.setText(point.getName());
editText.selectAll();
editText.requestFocus();
final AutoCompleteTextView cat = (AutoCompleteTextView) dialog.findViewById(R.id.Category);
cat.setText(point.getCategory());
editText.selectAll();
// PAVOL FIXME android API 8
// dialog.setOnShowListener(new OnShowListener() {
//
// @Override
// public void onShow(DialogInterface dialog) {
// InputMethodManager imm = (InputMethodManager) mapActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
// if (imm != null) {
// imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
// }
// }
// });
AndroidUtils.softKeyboardDelayed(editText);
}
protected Dialog createAddFavouriteDialog(final Bundle args) {