提交 4b6c1a16 编写于 作者: A andrewleo

Added: refine ui of settingActivity,mailActivity and aboutActivityexit

上级 5d0a85c8
......@@ -28,6 +28,10 @@
android:name=".activity.SettingsActivity"
android:label="@string/app_name4" >
</activity>
<activity android:name=".activity.AboutActivity" />
<activity android:name=".activity.MailSettingsActivity" />
<service
android:name="com.netease.qa.emmagee.service.EmmageeService">
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checked_icon" android:state_checked="true"></item>
<item android:drawable="@drawable/checked_icon" android:state_selected="true"></item>
<item android:drawable="@drawable/checked_icon" android:state_pressed="true"></item>
<item android:drawable="@drawable/unchecked_icon"></item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/light_purple"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/navigation_bar" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/layout_vertical_margin_small"
android:gravity="center_vertical"
android:text="Emmagee"
android:textColor="@color/black"
android:textSize="@dimen/text_size_bigest" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="版本"
android:textSize="@dimen/text_size" />
<TextView
android:id="@+id/app_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/textview_horizontal_margin"
android:background="@color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Emmagee XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/light_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/light_purple"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<include
android:id="@+id/etNumCpuCores"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/navigation_bar" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/textview_horizontal_margin"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sender"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
<EditText
android:id="@+id/sender"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/light_gray" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:inputType="textPassword"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/light_gray" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/smtp"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
<EditText
android:id="@+id/smtp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:singleLine="true"
android:textSize="@dimen/text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/light_gray" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/receiver"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
<EditText
android:id="@+id/recipients"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:textSize="@dimen/text_size" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:background="@drawable/actionbar_bg"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal" >
<ImageView
android:id="@+id/go_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_back" />
<TextView
android:id="@+id/nb_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:singleLine="true"
android:text="@string/app_name4"
android:textColor="@color/white"
android:textSize="@dimen/text_size_big" />
<ImageView
android:id="@+id/btn_set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/layout_vertical_margin"
android:src="@drawable/btn_save" />
</LinearLayout>
\ No newline at end of file
......@@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/light_purple"
android:orientation="vertical" >
<LinearLayout
......@@ -9,133 +10,161 @@
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
<include
android:id="@+id/etNumCpuCores"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/collect" />
<!-- 允许输入数据为正整数 -->
<!-- android:numeric="integer" -->
<!-- 采集频率 -->
<EditText
android:id="@+id/time"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:inputType="number"
android:maxLength="5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/seconds" />
layout="@layout/navigation_bar" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sender" />
<EditText
android:id="@+id/sender"
android:layout_width="200dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/password" />
<EditText
android:id="@+id/password"
android:inputType="textPassword"
android:layout_width="200dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/smtp" />
<EditText
android:id="@+id/smtp"
android:layout_width="200dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="@dimen/textview_horizontal_margin"
android:background="@color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/collect"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<EditText
android:id="@+id/time"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="center_vertical|right"
android:hint="点击输入..."
android:inputType="number"
android:maxLength="5"
android:textSize="@dimen/text_size" >
<requestFocus />
</EditText>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/light_gray" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:id="@+id/floating_Window"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/window"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
<CheckBox
android:id="@+id/floating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/custom_checkbox"
android:button="@null"
android:checked="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/receiver" />
<EditText
android:id="@+id/recipients"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"/>
android:layout_marginTop="@dimen/textview_horizontal_margin"
android:background="@color/white"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/mail_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/mail_settings"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/right_arrow"
android:textSize="@dimen/text_size" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/light_gray" />
<LinearLayout
android:id="@+id/about"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/layout_vertical_margin_small" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/about"
android:textColor="@color/black"
android:textSize="@dimen/text_size" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/right_arrow"
android:textSize="@dimen/text_size" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/floating_Window"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/window" />
<CheckBox
android:id="@+id/floating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical" >
</ScrollView>
<Button
android:id="@+id/save"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="@string/ok" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="light_purple">#EFEFF4</color>
<color name="dark_gray">#818181</color>
<color name="light_gray">#D2D1D5</color>
<color name="gray">#A6A6A6</color>
<color name="dark_blue">#0079FF</color>
<color name="red">#FF0000</color>
<color name="light_green">#00C378</color>
<color name="green">#1D9C00</color>
<color name="mix_gray">#CECED2</color>
<color name="orangered">#FF4500</color>
</resources>
\ No newline at end of file
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="layout_horizontal_margin">15dp</dimen>
<dimen name="layout_horizontal_margin_large">30dp</dimen>
<dimen name="layout_vertical_margin">20dp</dimen>
<dimen name="layout_vertical_margin_small">10dp</dimen>
<dimen name="textview_horizontal_margin">10dp</dimen>
<dimen name="textview_vertical_margin">3dp</dimen>
<dimen name="textview_vertical_margin_large">3dp</dimen>
<dimen name="text_size">16sp</dimen>
<dimen name="text_size_middle">12sp</dimen>
<dimen name="text_size_small">12sp</dimen>
<dimen name="text_size_big">20sp</dimen>
<dimen name="text_size_bigest">30sp</dimen>
<dimen name="button_width">140dp</dimen>
<dimen name="button_height">40dp</dimen>
</resources>
......@@ -24,5 +24,7 @@
<string name="openwifi">开启wifi</string>
<string name="closewifi">关闭wifi</string>
<string name="stopTest">停止测试</string>
<string name="about">关于</string>
<string name="mail_settings">邮件发送配置</string>
</resources>
\ No newline at end of file
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* 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.
*
*/
package com.netease.qa.emmagee.activity;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.EncryptData;
/**
* Setting Page of Emmagee
*
* @author andrewleo
*/
public class AboutActivity extends Activity {
private static final String LOG_TAG = "Emmagee-"
+ AboutActivity.class.getSimpleName();
private TextView appVersion;
private ImageView goBack;
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(LOG_TAG, "onCreate");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.about);
appVersion = (TextView)findViewById(R.id.app_version);
appVersion.setText(getVersion());
goBack = (ImageView)findViewById(R.id.go_back);
TextView title = (TextView)findViewById(R.id.nb_title);
title.setText(R.string.about);
ImageView btnSave = (ImageView) findViewById(R.id.btn_set);
btnSave.setImageResource(R.drawable.actionbar_bg);
goBack.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent();
intent.setClass(AboutActivity.this, SettingsActivity.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
AboutActivity.this.finish();
}
});
}
/**
* 获取版本号
* @return 当前应用的版本号
*/
public String getVersion() {
try {
PackageManager manager = this.getPackageManager();
PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
String version = info.versionName;
return version;
} catch (Exception e) {
e.printStackTrace();
return "-";
}
}
@Override
public void finish() {
super.finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
/*
* Copyright (c) 2012-2013 NetEase, Inc. and other contributors
*
* 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.
*
*/
package com.netease.qa.emmagee.activity;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.netease.qa.emmagee.R;
import com.netease.qa.emmagee.utils.EncryptData;
/**
* Setting Page of Emmagee
*
* @author andrewleo
*/
public class MailSettingsActivity extends Activity {
private static final String LOG_TAG = "Emmagee-"
+ MailSettingsActivity.class.getSimpleName();
private EditText edtRecipients;
private EditText edtSender;
private EditText edtPassword;
private EditText edtSmtp;
private String sender;
private String prePassword, curPassword;
private String settingTempFile;
private String recipients, smtp;
private String[] receivers;
private TextView title;
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(LOG_TAG, "onCreate");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.mail_settings);
final EncryptData des = new EncryptData("emmagee");
Intent intent = this.getIntent();
settingTempFile = getBaseContext().getFilesDir().getPath()
+ "\\EmmageeSettings.properties";
;
edtSender = (EditText) findViewById(R.id.sender);
edtPassword = (EditText) findViewById(R.id.password);
edtRecipients = (EditText) findViewById(R.id.recipients);
edtSmtp = (EditText) findViewById(R.id.smtp);
title = (TextView)findViewById(R.id.nb_title);
ImageView btnSave = (ImageView) findViewById(R.id.btn_set);
ImageView goBack = (ImageView) findViewById(R.id.go_back);
boolean floatingTag = true;
title.setText(R.string.mail_settings);
try {
Properties properties = new Properties();
properties.load(new FileInputStream(settingTempFile));
sender = (null == properties.getProperty("sender")) ? ""
: properties.getProperty("sender").trim();
prePassword = (null == properties.getProperty("password")) ? ""
: properties.getProperty("password").trim();
recipients = (null == properties.getProperty("recipients")) ? ""
: properties.getProperty("recipients").trim();
smtp = (null == properties.getProperty("smtp")) ? "" : properties
.getProperty("smtp").trim();
} catch (FileNotFoundException e) {
Log.e(LOG_TAG, "FileNotFoundException: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Log.e(LOG_TAG, "IOException: " + e.getMessage());
e.printStackTrace();
}
edtRecipients.setText(recipients);
edtSender.setText(sender);
edtPassword.setText(prePassword);
edtSmtp.setText(smtp);
goBack.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
MailSettingsActivity.this.finish();
}
});
// edtTime.setInputType(InputType.TYPE_CLASS_NUMBER);
btnSave.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
sender = edtSender.getText().toString().trim();
if (!"".equals(sender) && !checkMailFormat(sender)) {
Toast.makeText(MailSettingsActivity.this, "发件人邮箱格式不正确",
Toast.LENGTH_LONG).show();
return;
}
recipients = edtRecipients.getText().toString().trim();
receivers = recipients.split("\\s+");
for (int i = 0; i < receivers.length; i++) {
if (!"".equals(receivers[i])
&& !checkMailFormat(receivers[i])) {
Toast.makeText(MailSettingsActivity.this,
"收件人邮箱" + receivers[i] + "格式不正确",
Toast.LENGTH_LONG).show();
return;
}
}
curPassword = edtPassword.getText().toString().trim();
smtp = edtSmtp.getText().toString().trim();
if (checkMailConfig(sender, recipients, smtp, curPassword) == -1) {
Toast.makeText(MailSettingsActivity.this,
"邮箱配置不完整,请完善所有信息", Toast.LENGTH_LONG).show();
return;
}
try {
Properties properties = new Properties();
properties.setProperty("sender", sender);
Log.d(LOG_TAG, "sender=" + sender);
try {
properties.setProperty(
"password",
curPassword.equals(prePassword) ? curPassword
: ("".equals(curPassword) ? "" : des
.encrypt(curPassword)));
} catch (Exception e) {
properties.setProperty("password", "");
}
properties.setProperty("recipients", recipients);
properties.setProperty("smtp", smtp);
FileOutputStream fos = new FileOutputStream(settingTempFile);
properties.store(fos, "Setting Data");
fos.close();
Toast.makeText(MailSettingsActivity.this, "保存成功",
Toast.LENGTH_LONG).show();
Intent intent = new Intent();
setResult(Activity.RESULT_FIRST_USER, intent);
MailSettingsActivity.this.finish();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
@Override
public void finish() {
super.finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
private int checkMailConfig(String sender, String recipients, String smtp,
String curPassword) {
if (!"".equals(curPassword) && !"".equals(sender)
&& !"".equals(recipients) && !"".equals(smtp)) {
return 1;
} else if ("".equals(curPassword) && "".equals(sender)
&& "".equals(recipients) && "".equals(smtp)) {
return 0;
} else
return -1;
}
/**
* 检查邮件格式正确性
*/
private boolean checkMailFormat(String mail) {
String strPattern = "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*"
+ "[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
Pattern p = Pattern.compile(strPattern);
Matcher m = p.matcher(mail);
return m.matches();
}
}
......@@ -39,6 +39,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
......@@ -80,6 +81,7 @@ public class MainPageActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
Log.i(LOG_TAG, "MainActivity::onCreate");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.mainpage);
createNewFile();
processInfo = new ProcessInfo();
......
......@@ -29,10 +29,13 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.netease.qa.emmagee.R;
......@@ -50,91 +53,101 @@ public class SettingsActivity extends Activity {
private CheckBox chkFloat;
private EditText edtTime;
private EditText edtRecipients;
private EditText edtSender;
private EditText edtPassword;
private EditText edtSmtp;
private String time, sender;
private String prePassword, curPassword;
private String time;
private String settingTempFile;
private String recipients, smtp;
private String[] receivers;
private LinearLayout about;
private LinearLayout mailSettings;
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(LOG_TAG, "onCreate");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.settings);
final EncryptData des = new EncryptData("emmagee");
Intent intent = this.getIntent();
settingTempFile = intent.getStringExtra("settingTempFile");
settingTempFile = getBaseContext().getFilesDir().getPath()
+ "\\EmmageeSettings.properties";
chkFloat = (CheckBox) findViewById(R.id.floating);
edtTime = (EditText) findViewById(R.id.time);
edtSender = (EditText) findViewById(R.id.sender);
edtPassword = (EditText) findViewById(R.id.password);
edtRecipients = (EditText) findViewById(R.id.recipients);
edtSmtp = (EditText) findViewById(R.id.smtp);
about = (LinearLayout) findViewById(R.id.about);
mailSettings = (LinearLayout) findViewById(R.id.mail_settings);
Button btnSave = (Button) findViewById(R.id.save);
ImageView btnSave = (ImageView) findViewById(R.id.btn_set);
ImageView goBack = (ImageView) findViewById(R.id.go_back);
boolean floatingTag = true;
btnSave.setImageResource(R.drawable.actionbar_bg);
try {
Properties properties = new Properties();
properties.load(new FileInputStream(settingTempFile));
String interval = properties.getProperty("interval").trim();
String isfloat = properties.getProperty("isfloat").trim();
sender = properties.getProperty("sender").trim();
prePassword = properties.getProperty("password").trim();
recipients = properties.getProperty("recipients").trim();
String interval = (null == properties.getProperty("interval"))?"":properties.getProperty("interval").trim();
String isfloat = (null == properties.getProperty("isfloat"))?"":properties.getProperty("isfloat").trim();
time = "".equals(interval) ? "5" : interval;
floatingTag = "false".equals(isfloat) ? false : true;
recipients = properties.getProperty("recipients");
smtp = properties.getProperty("smtp");
} catch (FileNotFoundException e) {
Log.e(LOG_TAG, "FileNotFoundException: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Log.e(LOG_TAG, "IOException: " + e.getMessage());
} catch (Exception e) {
Log.e(LOG_TAG, "Exception: " + e.getMessage());
e.printStackTrace();
}
edtTime.setText(time);
chkFloat.setChecked(floatingTag);
edtRecipients.setText(recipients);
edtSender.setText(sender);
edtPassword.setText(prePassword);
edtSmtp.setText(smtp);
goBack.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
SettingsActivity.this.finish();
Intent intent = new Intent();
intent.setClass(SettingsActivity.this,
MainPageActivity.class);
startActivity(intent);
}
});
mailSettings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent();
intent.setClass(SettingsActivity.this,
MailSettingsActivity.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
}
});
about.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent();
intent.setClass(SettingsActivity.this, AboutActivity.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
}
});
chkFloat.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
try {
Properties properties = new Properties();
properties.setProperty("isfloat",
chkFloat.isChecked() ? "true" : "false");
FileOutputStream fos = new FileOutputStream(settingTempFile);
properties.store(fos, "Setting Data");
fos.close();
} catch (Exception e) {
e.printStackTrace();
chkFloat.setChecked(chkFloat.isChecked() ? false : true);
}
}
});
// edtTime.setInputType(InputType.TYPE_CLASS_NUMBER);
btnSave.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
time = edtTime.getText().toString().trim();
sender = edtSender.getText().toString().trim();
if (!"".equals(sender) && !checkMailFormat(sender)) {
Toast.makeText(SettingsActivity.this, "发件人邮箱格式不正确",
Toast.LENGTH_LONG).show();
return;
}
recipients = edtRecipients.getText().toString().trim();
receivers = recipients.split("\\s+");
for (int i = 0; i < receivers.length; i++) {
if (!"".equals(receivers[i])
&& !checkMailFormat(receivers[i])) {
Toast.makeText(SettingsActivity.this,
"收件人邮箱" + receivers[i] + "格式不正确",
Toast.LENGTH_LONG).show();
return;
}
}
curPassword = edtPassword.getText().toString().trim();
smtp = edtSmtp.getText().toString().trim();
if (checkMailConfig(sender, recipients, smtp, curPassword) == -1) {
Toast.makeText(SettingsActivity.this, "邮箱配置不完整,请完善所有信息",
Toast.LENGTH_LONG).show();
return;
}
if (!isNumeric(time)) {
Toast.makeText(SettingsActivity.this, "输入数据无效,请重新输入",
Toast.LENGTH_LONG).show();
......@@ -152,23 +165,6 @@ public class SettingsActivity extends Activity {
properties.setProperty("interval", time);
properties.setProperty("isfloat",
chkFloat.isChecked() ? "true" : "false");
properties.setProperty("sender", sender);
Log.d(LOG_TAG, "sender=" + sender);
try {
// FIXME 注释
properties.setProperty(
"password",
curPassword.equals(prePassword) ? curPassword
: ("".equals(curPassword) ? ""
: des.encrypt(curPassword)));
Log.d(LOG_TAG, "curPassword=" + curPassword);
Log.d(LOG_TAG,
"encrtpt=" + des.encrypt(curPassword));
} catch (Exception e) {
properties.setProperty("password", "");
}
properties.setProperty("recipients", recipients);
properties.setProperty("smtp", smtp);
FileOutputStream fos = new FileOutputStream(
settingTempFile);
properties.store(fos, "Setting Data");
......@@ -198,29 +194,6 @@ public class SettingsActivity extends Activity {
super.onDestroy();
}
private int checkMailConfig(String sender, String recipients, String smtp,
String curPassword) {
if (!"".equals(curPassword) && !"".equals(sender)
&& !"".equals(recipients) && !"".equals(smtp)) {
return 1;
} else if ("".equals(curPassword) && "".equals(sender)
&& "".equals(recipients) && "".equals(smtp)) {
return 0;
} else
return -1;
}
/**
* 检查邮件格式正确性
*/
private boolean checkMailFormat(String mail) {
String strPattern = "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*"
+ "[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
Pattern p = Pattern.compile(strPattern);
Matcher m = p.matcher(mail);
return m.matches();
}
/**
* is input a number.
*
......
......@@ -270,7 +270,7 @@ public class CpuInfo {
}
// 多核cpu的值写入csv文件中
for(int i =0;i<getCpuNum()-totalCpuRatio.size()+1;i++){
totalCpuBuffer.append("N/A,");
totalCpuBuffer.append("0.00,");
}
long pidMemory = mi.getPidMemorySize(pid, context);
String pMemory = fomart.format((double) pidMemory / 1024);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册