package be.yakupkalin.fakesms;
import android.app.Activity;
import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
public class Main extends Activity {
private Button btnSave, btnStatus;
private Spinner spFrom;
private TextView txtBody;
private String from
= "Ghost";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnSave
= (Button)findViewById
(R.
id.
btnSave);
btnStatus
= (Button)findViewById
(R.
id.
btnStatus);
spFrom = (Spinner)findViewById(R.id.spFrom);
txtBody = (TextView)findViewById(R.id.etBody);
String[] arFrom
= getResources
().
getStringArray(R.
array.
fromStrings);
java.
util.
Arrays.
sort(arFrom
);
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_item, arFrom);
spFrom.setAdapter(adapter);
btnStatus.setOnClickListener(new OnClickListener() {
@Override
public void onClick
(View v
) {
btnStatus.
setVisibility(View.
INVISIBLE);
}
});
btnSave.setOnClickListener(new OnClickListener() {
@Override
public void onClick
(View v
) {
saveSMS(spFrom.getSelectedItem().toString(), txtBody.getText().toString());
}
});
}
ContentValues values = new ContentValues();
values.put("address", from);
values.put("body", body);
getContentResolver().insert(Uri.parse("content://sms/inbox"), values);
btnStatus.setText("Message Sent! (close)");
btnStatus.
setVisibility(View.
VISIBLE);
}
}