/*
   * (non-Javadoc)
   *
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    int orentation = ThemeManager.getInstance().screenOrentation;
    if (orentation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
        || orentation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
      setRequestedOrientation(orentation);
    } else {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }

    super.onCreate(savedInstanceState);
    v = this.getLayoutInflater().inflate(R.layout.messagereply, null);
    v.setBackgroundColor(getResources().getColor(ThemeManager.getInstance().getBackgroundColor()));
    this.setContentView(v);

    if (PhoneConfiguration.getInstance().uploadLocation
        && PhoneConfiguration.getInstance().location == null) {
      ActivityUtil.reflushLocation(this);
    }

    Intent intent = this.getIntent();
    prefix = intent.getStringExtra("prefix");
    // if(prefix!=null){
    // prefix=prefix.replaceAll("\\n\\n", "\n");
    // }
    tousername = intent.getStringExtra("to");
    action = intent.getStringExtra("action");
    mid = intent.getIntExtra("mid", 0);
    String title = intent.getStringExtra("title");

    titleText = (EditText) findViewById(R.id.reply_titile_edittext);
    toText = (EditText) findViewById(R.id.reply_titile_edittext_to);
    bodyText = (EditText) findViewById(R.id.reply_body_edittext);

    if (action.equals("new")) {
      getSupportActionBar().setTitle(R.string.new_message);
    } else if (action.equals("reply")) {
      getSupportActionBar().setTitle(R.string.reply_message);
    }
    titleText.setSelected(true);

    act = new MessagePostAction(mid, "", "");
    act.setAction_(action);
    this.act.set__ngaClientChecksum(FunctionUtil.getngaClientChecksum(this));
    loading = false;

    if (!StringUtil.isEmpty(tousername)) {
      toText.setText(tousername);
      if (!StringUtil.isEmpty(title)) {
        titleText.setText(title);
      }
    } else {
      if (!StringUtil.isEmpty(title)) {
        titleText.setText(title);
      }
    }
    if (prefix != null) {
      if (prefix.startsWith("[quote][pid=") && prefix.endsWith("[/quote]\n")) {
        SpannableString spanString = new SpannableString(prefix);
        spanString.setSpan(
            new BackgroundColorSpan(-1513240),
            0,
            prefix.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        spanString.setSpan(
            new StyleSpan(android.graphics.Typeface.BOLD),
            prefix.indexOf("[b]Post by"),
            prefix.indexOf("):[/b]") + 5,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        bodyText.append(spanString);
      } else {
        bodyText.append(prefix);
      }
      bodyText.setSelection(prefix.length());
    }
    ThemeManager tm = ThemeManager.getInstance();
    if (tm.getMode() == ThemeManager.MODE_NIGHT) {
      bodyText.setBackgroundResource(tm.getBackgroundColor());
      toText.setBackgroundResource(tm.getBackgroundColor());
      titleText.setBackgroundResource(tm.getBackgroundColor());
      int textColor = this.getResources().getColor(tm.getForegroundColor());
      bodyText.setTextColor(textColor);
      titleText.setTextColor(textColor);
      toText.setTextColor(textColor);
    }
  }