Back to project page AndroidWifiServer.
The source code is released under:
Apache License
If you think the Android project AndroidWifiServer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package jp.maju.wifiserver.server; /*w w w.j a v a 2s . co m*/ import jp.maju.wifiserver.R; import jp.maju.wifiserver.twitter.TwitterOAuthActivity; import jp.maju.wifiserver.util.PreferenceUtil; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.text.InputFilter; import android.text.Spanned; import android.text.TextUtils; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; /* * Copyright {2014} {Matsuda Jumpei} * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ public class InitServerActivity extends ActionBarActivity implements OnClickListener { private static final String TAG = InitServerActivity.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_init_server); findViewById(R.id.init_server_btn_init).setOnClickListener(this); init(); } private void init() { InputFilter inputFilter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { if (source.toString().matches("^[0-9a-zA-Z@._-]+$")) { return source; } else { return ""; } } }; InputFilter[] filters = new InputFilter[] { inputFilter }; EditText titleEdit = (EditText) findViewById(R.id.init_server_edit_title); titleEdit.setFilters(filters); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.init_server_btn_init: if (verifyInputContent()) { doSave(); } break; } } private boolean verifyInputContent() { int[] ids = { R.id.init_server_edit_title, R.id.init_server_edit_client_in_tweet_content, R.id.init_server_edit_client_out_tweet_content, R.id.init_server_edit_server_tweet_content, }; for (int i = 0; verifyOneOfInputContent(ids[i]); i++) { if (i == ids.length - 1) { return true; } } return false; } private boolean verifyOneOfInputContent(int id) { EditText editText = (EditText) findViewById(id); if (editText == null) { return false; } String str = editText.getText().toString(); if (TextUtils.isEmpty(str)) { editText.setBackgroundColor(Color.argb(100, 100, 0, 0)); return false; } editText.setBackgroundColor(Color.WHITE); return true; } private void doSave() { EditText titleEdit = (EditText) findViewById(R.id.init_server_edit_title); String title = titleEdit.getText().toString(); EditText clientTweetInEdit = (EditText) findViewById(R.id.init_server_edit_client_in_tweet_content); String clientInTweet = clientTweetInEdit.getText().toString(); EditText clientTweetOutEdit = (EditText) findViewById(R.id.init_server_edit_client_out_tweet_content); String clientOutTweet = clientTweetOutEdit.getText().toString(); EditText serverTweetEdit = (EditText) findViewById(R.id.init_server_edit_server_tweet_content); String serverTweet = serverTweetEdit.getText().toString(); PreferenceUtil.setAnchor(getApplication(), title); PreferenceUtil.setHttpRefererLogin(getApplication(), clientInTweet); PreferenceUtil.setHttpRefererLogout(getApplication(), clientOutTweet); PreferenceUtil.setServerMessage(getApplication(), serverTweet); // PreferenceUtil.setClientMessage(getApplication(), clientInTweet); startActivity(new Intent(this, TwitterOAuthActivity.class).putExtra( TwitterOAuthActivity.KEY_IS_SERVER, true)); finish(); } }