安卓客户端新增登录窗体,测试完成登录效果,v1.7.6
This commit is contained in:
@@ -28,4 +28,5 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.UserSoftwareAndroidTemplate">
|
||||
|
||||
<!--网络权限的申请-->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!--机器码权限申请-->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
@@ -12,8 +16,7 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
</activity>
|
||||
<activity android:name=".MainActivity" />
|
||||
<activity
|
||||
android:name=".LoginSupport.SplashActivity"
|
||||
android:configChanges="keyboardHidden"
|
||||
@@ -23,9 +26,12 @@
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".LoginSupport.LoginActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -126,31 +126,58 @@ public class SystemVersion {
|
||||
}
|
||||
|
||||
|
||||
public boolean IsSameVersion(SystemVersion sv)
|
||||
{
|
||||
if(this.m_MainVersion!=sv.m_MainVersion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.m_SecondaryVersion!=sv.m_SecondaryVersion)
|
||||
{
|
||||
public boolean IsSameVersion(SystemVersion sv) {
|
||||
if (this.m_MainVersion != sv.m_MainVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.m_EditVersion!=sv.m_EditVersion)
|
||||
{
|
||||
if (this.m_SecondaryVersion != sv.m_SecondaryVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.m_InnerVersion!=sv.m_InnerVersion)
|
||||
{
|
||||
if (this.m_EditVersion != sv.m_EditVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.m_InnerVersion != sv.m_InnerVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean IsSmallerThan(SystemVersion sv) {
|
||||
if (this.m_MainVersion < sv.m_MainVersion) {
|
||||
return true;
|
||||
}
|
||||
else if(this.m_MainVersion > sv.m_MainVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.m_SecondaryVersion < sv.m_SecondaryVersion) {
|
||||
return true;
|
||||
}
|
||||
else if (this.m_SecondaryVersion > sv.m_SecondaryVersion) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (this.m_EditVersion < sv.m_EditVersion) {
|
||||
return true;
|
||||
}
|
||||
else if (this.m_EditVersion > sv.m_EditVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.m_InnerVersion < sv.m_InnerVersion) {
|
||||
return true;
|
||||
}
|
||||
else if (this.m_InnerVersion > sv.m_InnerVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.example.HslCommunication.Core.Utilities;
|
||||
|
||||
import com.example.HslCommunication.Log.LogUtil;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -125,15 +127,16 @@ public class Utilities {
|
||||
byteArray = str.getBytes("unicode");
|
||||
} catch (Exception ex) {
|
||||
byteArray = str.getBytes();
|
||||
LogUtil.LogE("string2Byte","unicode编码转换错误",ex);
|
||||
}
|
||||
|
||||
for(int i=0;i<byteArray.length;i++)
|
||||
{
|
||||
byte temp=byteArray[i];
|
||||
byteArray[i]=byteArray[i+1];
|
||||
byteArray[i+1] =temp;
|
||||
i++;
|
||||
}
|
||||
//
|
||||
// for(int i=0;i<byteArray.length;i++)
|
||||
// {
|
||||
// byte temp=byteArray[i];
|
||||
// byteArray[i]=byteArray[i+1];
|
||||
// byteArray[i+1] =temp;
|
||||
// i++;
|
||||
// }
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.UserSoftwareAndroidTemplate.CommonHeadCode;
|
||||
package com.example.UserSoftwareAndroidTemplate.CommonLibrary;
|
||||
|
||||
import com.example.HslCommunication.Core.Types.NetHandle;
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.example.UserSoftwareAndroidTemplate.CommonLibrary;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by hsl20 on 2017/11/5.
|
||||
*/
|
||||
|
||||
public class UserAccount {
|
||||
|
||||
/// <summary>
|
||||
/// 用户名称,该名称唯一
|
||||
/// </summary>
|
||||
public String UserName = "";
|
||||
/// <summary>
|
||||
/// 用户名称的别名,也不可以不使用
|
||||
/// </summary>
|
||||
public String NameAlias = "";
|
||||
/// <summary>
|
||||
/// 用户登录的密码
|
||||
/// </summary>
|
||||
public String Password = "";
|
||||
/// <summary>
|
||||
/// 账户所属的工厂名称或类别名称
|
||||
/// </summary>
|
||||
public String Factory = "";
|
||||
/// <summary>
|
||||
/// 用户的权限等级,目前配置了4个等级
|
||||
/// </summary>
|
||||
public int Grade = 0;
|
||||
/// <summary>
|
||||
/// 用户的手机号
|
||||
/// </summary>
|
||||
public String Phone = "";
|
||||
/// <summary>
|
||||
/// 用户的电子邮件
|
||||
/// </summary>
|
||||
public String EMail ="";
|
||||
/// <summary>
|
||||
/// 该用户的注册日期,一旦注册,应该固定
|
||||
/// </summary>
|
||||
public Date RegisterTime = new Date();
|
||||
/// <summary>
|
||||
/// 该用户是否允许登录
|
||||
/// </summary>
|
||||
public boolean LoginEnable = false;
|
||||
/// <summary>
|
||||
/// 该用户不允许被登录的原因
|
||||
/// </summary>
|
||||
public String ForbidMessage = "该账户被管理员禁止登录!";
|
||||
/// <summary>
|
||||
/// 该用户自注册以来登录的次数
|
||||
/// </summary>
|
||||
public int LoginFrequency = 0;
|
||||
/// <summary>
|
||||
/// 该用户上次登录的时间
|
||||
/// </summary>
|
||||
public Date LastLoginTime = new Date();
|
||||
/// <summary>
|
||||
/// 该用户上次登录的IP地址
|
||||
/// </summary>
|
||||
public String LastLoginIpAddress = "";
|
||||
/// <summary>
|
||||
/// 该用户连续登录失败的计数,可以用来连续五次失败禁止账户登录
|
||||
/// </summary>
|
||||
public int LoginFailedCount = 0;
|
||||
/// <summary>
|
||||
/// 上次登录系统的方式,有winform版,wpf版,web版,Android版
|
||||
/// </summary>
|
||||
public String LastLoginWay = "";
|
||||
/// <summary>
|
||||
/// 小尺寸头像的MD5码
|
||||
/// </summary>
|
||||
public String SmallPortraitMD5 = "";
|
||||
/// <summary>
|
||||
/// 大尺寸头像的MD5码
|
||||
/// </summary>
|
||||
public String LargePortraitMD5 = "";
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用于存储和传送的名称
|
||||
/// </summary>
|
||||
public static String UserNameText = "UserName";
|
||||
/// <summary>
|
||||
/// 用于存储和传送的名称
|
||||
/// </summary>
|
||||
public static String PasswordText = "Password";
|
||||
/// <summary>
|
||||
/// 用于存储和传送的名称
|
||||
/// </summary>
|
||||
public static String LoginWayText = "LoginWay";
|
||||
/// <summary>
|
||||
/// 登录系统的唯一设备ID
|
||||
/// </summary>
|
||||
public static String DeviceUniqueID = "DeviceUniqueID";
|
||||
/// <summary>
|
||||
/// 小尺寸头像的MD5传送名称
|
||||
/// </summary>
|
||||
public static String SmallPortraitText = "SmallPortrait";
|
||||
/// <summary>
|
||||
/// 大尺寸头像的MD5传送名称
|
||||
/// </summary>
|
||||
public static String LargePortraitText = "LargePortrait";
|
||||
/// <summary>
|
||||
/// 系统的框架版本,框架版本不一致,由服务器决定是否允许客户端登录
|
||||
/// </summary>
|
||||
public static String FrameworkVersion = "FrameworkVersion";
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取本账号的JSON字符串,用于在网络中数据传输
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public String ToJsonString()
|
||||
{
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取账号的用户名
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public String toString()
|
||||
{
|
||||
return UserName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example.UserSoftwareAndroidTemplate.LoginSupport;
|
||||
|
||||
import android.view.animation.LinearInterpolator;
|
||||
|
||||
/**
|
||||
* Created by hsl20 on 2017/11/5.
|
||||
*/
|
||||
|
||||
public class JellyInterpolator extends LinearInterpolator {
|
||||
private float factor;
|
||||
|
||||
public JellyInterpolator() {
|
||||
this.factor = 0.15f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
return (float) (Math.pow(2, -10 * input)
|
||||
* Math.sin((input - factor / 4) * (2 * Math.PI) / factor) + 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.UserSoftwareAndroidTemplate.LoginSupport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by hsl20 on 2017/11/5.
|
||||
*/
|
||||
|
||||
public class JsonBeanPara {
|
||||
|
||||
public String Announcement="";
|
||||
|
||||
public List<String> SystemFactories = null;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
package com.example.UserSoftwareAndroidTemplate.LoginSupport;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.HslCommunication.BasicFramework.SystemVersion;
|
||||
import com.example.HslCommunication.Core.Types.NetHandle;
|
||||
import com.example.HslCommunication.Core.Types.OperateResultString;
|
||||
import com.example.HslCommunication.Log.LogUtil;
|
||||
import com.example.UserSoftwareAndroidTemplate.CommonLibrary.SimplifyHeadCode;
|
||||
import com.example.UserSoftwareAndroidTemplate.CommonLibrary.UserAccount;
|
||||
import com.example.UserSoftwareAndroidTemplate.MainActivity;
|
||||
import com.example.UserSoftwareAndroidTemplate.R;
|
||||
import com.example.UserSoftwareAndroidTemplate.UserClient;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.example.UserSoftwareAndroidTemplate.CommonLibrary.UserAccount.FrameworkVersion;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.activity_login);
|
||||
initView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private TextView mBtnLogin;
|
||||
private View progress;
|
||||
private View mInputLayout;
|
||||
private float mWidth, mHeight;
|
||||
private LinearLayout mName, mPsw;
|
||||
/*
|
||||
系统的登录状态,0,未登录,1,登入中
|
||||
*/
|
||||
private int logStatus = 0;
|
||||
|
||||
private void initView() {
|
||||
mBtnLogin = (TextView) findViewById(R.id.main_btn_login);
|
||||
progress = findViewById(R.id.layout_progress);
|
||||
mInputLayout = findViewById(R.id.input_layout);
|
||||
mName = (LinearLayout) findViewById(R.id.input_layout_name);
|
||||
mPsw = (LinearLayout) findViewById(R.id.input_layout_psw);
|
||||
|
||||
mBtnLogin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(logStatus==0) {
|
||||
|
||||
// 应该在这里启动账户验证
|
||||
EditText editText1 = (EditText) findViewById(R.id.login_intput_username);
|
||||
UserName = editText1.getText().toString();
|
||||
if("".equals(UserName))
|
||||
{
|
||||
Toast.makeText(LoginActivity.this, "请输入用户名", Toast.LENGTH_SHORT).show();
|
||||
editText1.setFocusable(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
EditText editText2 = (EditText) findViewById(R.id.login_intput_password);
|
||||
UserPassword = editText2.getText().toString();
|
||||
if("".equals(UserPassword))
|
||||
{
|
||||
Toast.makeText(LoginActivity.this, "请输入密码", Toast.LENGTH_SHORT).show();
|
||||
editText2.setFocusable(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 开启程序验证
|
||||
logStatus = 1;
|
||||
|
||||
// 计算出控件的高与宽
|
||||
mWidth = mBtnLogin.getMeasuredWidth(); // 209
|
||||
|
||||
LogUtil.LogD("onClick",""+mWidth);
|
||||
|
||||
mHeight = mBtnLogin.getMeasuredHeight();
|
||||
|
||||
// 隐藏输入框
|
||||
mName.setVisibility(View.INVISIBLE);
|
||||
mPsw.setVisibility(View.INVISIBLE);
|
||||
|
||||
inputAnimator(mInputLayout, mWidth, mHeight);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void InterfaceRestore()
|
||||
{
|
||||
logStatus = 0;
|
||||
// 重新显示界面
|
||||
progress.setVisibility(View.INVISIBLE);
|
||||
|
||||
|
||||
//mInputLayout.SCALE_X=1f;
|
||||
mInputLayout.setScaleX(1);
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams)mInputLayout.getLayoutParams();
|
||||
params.leftMargin=0;
|
||||
params.rightMargin=0;
|
||||
mInputLayout.setLayoutParams(params);
|
||||
mInputLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
mName.setVisibility(View.VISIBLE);
|
||||
mPsw.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
private Handler handler=new Handler(){
|
||||
/**重写handleMessage方法*/
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.arg1 == 1) {
|
||||
// 登录失败并且显示信息
|
||||
Toast.makeText(LoginActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
|
||||
InterfaceRestore();
|
||||
}
|
||||
else if(msg.arg1 == 2)
|
||||
{
|
||||
// 登录成功
|
||||
InterfaceRestore();
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
//两个参数分别表示进入的动画,退出的动画
|
||||
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void MessageShow(String message)
|
||||
{
|
||||
Message msg = new Message();
|
||||
msg.arg1=1;
|
||||
msg.obj = message;
|
||||
handler.sendMessage(msg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String UserName = "";
|
||||
private String UserPassword = "";
|
||||
|
||||
/**
|
||||
* 网络操作相关的子线程
|
||||
*/
|
||||
Runnable loginSystem = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
LogUtil.LogD("loginSystem","开始请求维护检查");
|
||||
// 第一步请求维护状态
|
||||
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(SimplifyHeadCode.维护检查, "", null, null);
|
||||
if (!result.IsSuccess) {
|
||||
MessageShow(result.ToMessageShowString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result.Content.equals("1")) {
|
||||
MessageShow(result.Content.substring(1));
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtil.LogD("loginSystem","开始请求账户检查");
|
||||
// 第二步检查账户
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty(UserAccount.UserNameText, UserName);
|
||||
jsonObject.addProperty(UserAccount.PasswordText, UserPassword);
|
||||
jsonObject.addProperty(UserAccount.LoginWayText, "Andriod");
|
||||
jsonObject.addProperty(UserAccount.DeviceUniqueID, "Missing");
|
||||
jsonObject.addProperty(FrameworkVersion, UserClient.FrameworkVersion.toString());
|
||||
|
||||
LogUtil.LogD("loginSystem",jsonObject.toString());
|
||||
result = UserClient.Net_simplify_client.ReadFromServer(SimplifyHeadCode.账户检查, jsonObject.toString(), null, null);
|
||||
if (!result.IsSuccess) {
|
||||
MessageShow(result.ToMessageShowString());
|
||||
return;
|
||||
}
|
||||
|
||||
UserAccount account = new Gson().fromJson(result.Content, UserAccount.class);
|
||||
if (!account.LoginEnable) {
|
||||
// 不允许登录
|
||||
MessageShow(account.ForbidMessage);
|
||||
return;
|
||||
}
|
||||
UserClient.UserAccount = account;
|
||||
// 保存用户名和密码
|
||||
|
||||
|
||||
LogUtil.LogD("loginSystem","开始请求版本检查");
|
||||
// 第三步检查版本
|
||||
result = UserClient.Net_simplify_client.ReadFromServer(SimplifyHeadCode.更新检查, "", null, null);
|
||||
if (!result.IsSuccess) {
|
||||
MessageShow(result.ToMessageShowString());
|
||||
return;
|
||||
}
|
||||
|
||||
SystemVersion sv = new SystemVersion(result.Content);
|
||||
|
||||
if (account.UserName != "admin") {
|
||||
if (!UserClient.CurrentVersion.IsSameVersion(sv)) {
|
||||
MessageShow("版本号校验失败!服务器版本为:" + sv.toString());
|
||||
|
||||
// 此处应该启动下载更新,这部分的服务以后再完成
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(UserClient.CurrentVersion.IsSmallerThan(sv))
|
||||
{
|
||||
// 管理员也不允许以低版本登录
|
||||
MessageShow("版本号校验失败!服务器版本为:" + sv.toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LogUtil.LogD("loginSystem","开始请求数据下载");
|
||||
// 下载服务器数据
|
||||
result = UserClient.Net_simplify_client.ReadFromServer(SimplifyHeadCode.参数下载,"",null,null);
|
||||
if (result.IsSuccess) {
|
||||
// 服务器返回初始化的数据,此处进行数据的提取,有可能包含了多个数据
|
||||
JsonBeanPara para = new Gson().fromJson(result.Content, JsonBeanPara.class);
|
||||
// 例如公告数据和分厂数据
|
||||
UserClient.Announcement = para.Announcement;
|
||||
UserClient.SystemFactories = para.SystemFactories;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 访问失败
|
||||
MessageShow(result.ToMessageShowString());
|
||||
return;
|
||||
}
|
||||
|
||||
long loadingTime = System.currentTimeMillis() - startTime;
|
||||
// 如果时间很短,做个延时处理
|
||||
if (loadingTime < 2000) {
|
||||
try {
|
||||
Thread.sleep(2000 - loadingTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
LogUtil.LogD("loginSystem","登录成功");
|
||||
// 登录成功
|
||||
Message msg = new Message();
|
||||
msg.arg1 = 2;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 输入框的动画效果
|
||||
*
|
||||
* @param view
|
||||
* 控件
|
||||
* @param w
|
||||
* 宽
|
||||
* @param h
|
||||
* 高
|
||||
*/
|
||||
private void inputAnimator(final View view, float w, float h) {
|
||||
|
||||
AnimatorSet set = new AnimatorSet();
|
||||
|
||||
ValueAnimator animator = ValueAnimator.ofFloat(0, w);
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
float value = (Float) animation.getAnimatedValue();
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view
|
||||
.getLayoutParams();
|
||||
params.leftMargin = (int) value;
|
||||
params.rightMargin = (int) value;
|
||||
|
||||
view.setLayoutParams(params);
|
||||
}
|
||||
});
|
||||
|
||||
ObjectAnimator animator2 = ObjectAnimator.ofFloat(mInputLayout,
|
||||
"scaleX", 1f, 0.5f);
|
||||
set.setDuration(300);
|
||||
set.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
set.playTogether(animator, animator2);
|
||||
set.start();
|
||||
set.addListener(new Animator.AnimatorListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
/**
|
||||
* 动画结束后,先显示加载的动画,然后再隐藏输入框
|
||||
*/
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
progressAnimator(progress);
|
||||
mInputLayout.setVisibility(View.INVISIBLE);
|
||||
|
||||
|
||||
/*
|
||||
启动后台验证程序
|
||||
*/
|
||||
new Thread(loginSystem).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 出现进度动画
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
private void progressAnimator(final View view) {
|
||||
PropertyValuesHolder animator = PropertyValuesHolder.ofFloat("scaleX",
|
||||
0.5f, 1f);
|
||||
PropertyValuesHolder animator2 = PropertyValuesHolder.ofFloat("scaleY",
|
||||
0.5f, 1f);
|
||||
ObjectAnimator animator3 = ObjectAnimator.ofPropertyValuesHolder(view,
|
||||
animator, animator2);
|
||||
animator3.setDuration(1000);
|
||||
animator3.setInterpolator(new JellyInterpolator());
|
||||
animator3.start();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,13 @@ import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.HslCommunication.BasicFramework.SystemVersion;
|
||||
import com.example.HslCommunication.Core.Types.NetHandle;
|
||||
import com.example.HslCommunication.Core.Types.OperateResultString;
|
||||
import com.example.UserSoftwareAndroidTemplate.CommonHeadCode.SimplifyHeadCode;
|
||||
import com.example.UserSoftwareAndroidTemplate.CommonLibrary.SimplifyHeadCode;
|
||||
import com.example.UserSoftwareAndroidTemplate.MainActivity;
|
||||
import com.example.UserSoftwareAndroidTemplate.R;
|
||||
import com.example.UserSoftwareAndroidTemplate.UserClient;
|
||||
@@ -54,7 +49,7 @@ public class SplashActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onPostExecute(Integer result) {
|
||||
if (result > 0) {
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
|
||||
//intent.setClassName(SplashActivity.this, getString(R.string.));
|
||||
startActivity(intent);
|
||||
finish();
|
||||
@@ -97,7 +92,7 @@ public class SplashActivity extends AppCompatActivity {
|
||||
private int loadingCache() {
|
||||
|
||||
// 第一步请求维护状态
|
||||
OperateResultString result=UserClient.Client.ReadFromServer(SimplifyHeadCode.维护检查,"",null,null);
|
||||
OperateResultString result=UserClient.Net_simplify_client.ReadFromServer(SimplifyHeadCode.维护检查,"",null,null);
|
||||
if(!result.IsSuccess){
|
||||
MessageShow(result.ToMessageShowString());
|
||||
return FAILURE;
|
||||
@@ -117,14 +112,17 @@ public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
// 第三步检查版本
|
||||
result=UserClient.Client.ReadFromServer(SimplifyHeadCode.维护检查,"",null,null);
|
||||
result=UserClient.Net_simplify_client.ReadFromServer(SimplifyHeadCode.更新检查,"",null,null);
|
||||
if(!result.IsSuccess){
|
||||
MessageShow(result.ToMessageShowString());
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
SystemVersion sv=new SystemVersion(result.Content);
|
||||
if(!UserClient.CurrentVersion.IsSameVersion(sv)) return FAILURE;
|
||||
if(!UserClient.CurrentVersion.IsSameVersion(sv)) {
|
||||
MessageShow("版本号校验失败!服务器版本为:" + sv.toString());
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// 下载服务器数据
|
||||
|
||||
@@ -14,6 +14,8 @@ import android.widget.Toast;
|
||||
import com.example.HslCommunication.Core.Types.NetHandle;
|
||||
import com.example.HslCommunication.Core.Types.OperateResultString;
|
||||
import com.example.HslCommunication.Enthernet.NetSimplifyClient;
|
||||
import com.example.UserSoftwareAndroidTemplate.CommonLibrary.UserAccount;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -56,7 +58,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
public void run() {
|
||||
// 在这里进行网络请求相关操作
|
||||
Message msg = new Message();
|
||||
OperateResultString result = UserClient.Client.ReadFromServer(new NetHandle(1,2, 15),"",null,null);
|
||||
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(new NetHandle(1,2, 15),"",null,null);
|
||||
msg.arg1=1;
|
||||
msg.obj = result;
|
||||
handler.sendMessage(msg);
|
||||
@@ -77,6 +79,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
new Thread(networkTask).start();
|
||||
}});
|
||||
|
||||
Button button2 = (Button) findViewById(R.id.button2);
|
||||
button2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
UserAccount account = new UserAccount();
|
||||
TextView textView = (TextView) findViewById(R.id.textViewMain);
|
||||
textView.setText(new Gson().toJson(account));
|
||||
}
|
||||
});
|
||||
|
||||
TextView textView = (TextView) findViewById(R.id.textViewMain);
|
||||
textView.setMovementMethod(new ScrollingMovementMethod());
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.example.UserSoftwareAndroidTemplate;
|
||||
|
||||
import com.example.HslCommunication.BasicFramework.SystemVersion;
|
||||
import com.example.HslCommunication.Enthernet.NetSimplifyClient;
|
||||
import com.example.UserSoftwareAndroidTemplate.CommonLibrary.UserAccount;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -11,7 +13,7 @@ import java.util.UUID;
|
||||
|
||||
public class UserClient {
|
||||
|
||||
|
||||
public static SystemVersion FrameworkVersion = new SystemVersion("1.7.5");
|
||||
public static SystemVersion CurrentVersion= new SystemVersion("1.0.0.171026");
|
||||
|
||||
|
||||
@@ -26,8 +28,8 @@ public class UserClient {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static NetSimplifyClient Client=new NetSimplifyClient(ServerIp,PortSecondary,Token);
|
||||
|
||||
public static List<String> SystemFactories = null; // 分厂
|
||||
public static String Announcement=""; // 公告
|
||||
public static NetSimplifyClient Net_simplify_client=new NetSimplifyClient(ServerIp,PortSecondary,Token);
|
||||
public static UserAccount UserAccount = null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<corners android:radius="5dip"/>
|
||||
<solid android:color="#ffffff"/>
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval" >
|
||||
|
||||
<corners android:radius="60dip" />
|
||||
|
||||
<solid android:color="#ffffff" />
|
||||
|
||||
</shape>
|
||||
11
AndroidTemplate/app/src/main/res/drawable/text_bg.xml
Normal file
11
AndroidTemplate/app/src/main/res/drawable/text_bg.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
|
||||
<corners android:radius="50dip"/>
|
||||
|
||||
<stroke
|
||||
android:width="1dip"
|
||||
android:color="#ffffff" />
|
||||
|
||||
</shape>
|
||||
80
AndroidTemplate/app/src/main/res/layout/activity_login.xml
Normal file
80
AndroidTemplate/app/src/main/res/layout/activity_login.xml
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/holo_blue_dark"
|
||||
tools:context="com.example.UserSoftwareAndroidTemplate.LoginSupport.LoginActivity">
|
||||
|
||||
<include
|
||||
android:id="@+id/main_title"
|
||||
layout="@layout/title_layout" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/main_title"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="130dip"
|
||||
android:layout_height="130dip"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dip"
|
||||
android:gravity="center"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="系统登录"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<include
|
||||
android:id="@+id/input_layout"
|
||||
layout="@layout/input_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="130dip" />
|
||||
|
||||
<include
|
||||
android:id="@+id/layout_progress"
|
||||
layout="@layout/layout_progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="130dip"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/main_btn_login"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/input_layout"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginTop="15dip"
|
||||
android:background="@drawable/text_bg"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="2dip"
|
||||
android:paddingLeft="15dip"
|
||||
android:paddingRight="15dip"
|
||||
android:paddingTop="2dip"
|
||||
android:text="Login"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="20sp" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
@@ -6,21 +6,35 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.example.UserSoftwareAndroidTemplate.MainActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewMain"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:scrollbars="vertical"/>
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewMain"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:scrollbars="vertical"/>
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@@ -29,7 +28,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal">
|
||||
<ImageView android:id="@+id/jay_studio_icon"
|
||||
android:layout_width="110dip"
|
||||
android:layout_width="130dip"
|
||||
android:layout_height="130dip"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
/>
|
||||
|
||||
62
AndroidTemplate/app/src/main/res/layout/input_layout.xml
Normal file
62
AndroidTemplate/app/src/main/res/layout/input_layout.xml
Normal file
@@ -0,0 +1,62 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dip"
|
||||
android:background="@drawable/radius_drawable_bg"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dip" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/input_layout_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/login_intput_username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dip"
|
||||
android:background="#00000000"
|
||||
android:hint="请输入用户名"
|
||||
android:padding="5dip"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_marginBottom="5dip"
|
||||
android:layout_marginTop="5dip"
|
||||
android:background="#eeeeee" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/input_layout_psw"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/login_intput_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dip"
|
||||
android:background="#00000000"
|
||||
android:hint="密码"
|
||||
android:inputType="textPassword"
|
||||
android:padding="5dip"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
27
AndroidTemplate/app/src/main/res/layout/layout_progress.xml
Normal file
27
AndroidTemplate/app/src/main/res/layout/layout_progress.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="20dip"
|
||||
android:background="@drawable/rotate_layout_bg"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dip" >
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_margin="10dip"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
17
AndroidTemplate/app/src/main/res/layout/title_layout.xml
Normal file
17
AndroidTemplate/app/src/main/res/layout/title_layout.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dip"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="10dip" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#ffffff"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textSize="20sp"
|
||||
android:text=" "
|
||||
/>
|
||||
</RelativeLayout>
|
||||
@@ -44,7 +44,7 @@ namespace CommonLibrary
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
SoftBasic.FrameworkVersion = new SystemVersion("1.7.5");
|
||||
SoftBasic.FrameworkVersion = new SystemVersion("1.7.6");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -492,7 +492,8 @@ namespace 软件系统服务端模版
|
||||
else if (handle == CommonHeadCode.SimplifyHeadCode.账户检查)
|
||||
{
|
||||
//此处使用的是组件自带的验证的方式,如果使用SQL数据库,另行验证
|
||||
JObject json = JObject.Parse(data);
|
||||
JObject json = JObject.Parse(data.Trim());
|
||||
|
||||
//提取账户,密码
|
||||
string name = SoftBasic.GetValueFromJsonObject(json, UserAccount.UserNameText, "");
|
||||
string password = SoftBasic.GetValueFromJsonObject(json, UserAccount.PasswordText, "");
|
||||
|
||||
Reference in New Issue
Block a user