diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 6fcfd81..9cb3ea6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,6 +26,7 @@
+
diff --git a/app/src/main/java/com/qhclh/ytzh/home/MainActivity.java b/app/src/main/java/com/qhclh/ytzh/home/MainActivity.java
index 4294f44..fdfdede 100644
--- a/app/src/main/java/com/qhclh/ytzh/home/MainActivity.java
+++ b/app/src/main/java/com/qhclh/ytzh/home/MainActivity.java
@@ -106,20 +106,20 @@ public class MainActivity extends BaseActivity {
clearAllTabState();
switch (tabPosition) {
case TAB_POSITION_INDEX: {
-// iv_index.setImageResource(R.drawable.ghs12x);
+ iv_index.setImageResource(R.drawable.shouye_3x);
tv_index.setTextColor(getResources().getColor(R.color.green029737));
mTvToolbarTitle.setText(R.string.index);
break;
}
case TAB_POSITION_WORK: {
-// iv_work.setImageResource(R.drawable.gwc12x);
+ iv_work.setImageResource(R.drawable.gongzuo_3x);
tv_work.setTextColor(getResources().getColor(R.color.green029737));
mTvToolbarTitle.setText(R.string.work);
break;
}
case TAB_POSITION_ME: {
-// iv_me.setImageResource(R.drawable.dd12x);
+ iv_me.setImageResource(R.drawable.wode_3x);
tv_me.setTextColor(getResources().getColor(R.color.green029737));
mTvToolbarTitle.setText(R.string.me);
break;
@@ -130,14 +130,14 @@ public class MainActivity extends BaseActivity {
private void clearAllTabState() {
///< 首页
-// iv_index.setImageResource(R.drawable.ghs2x);
+ iv_index.setImageResource(R.drawable.shouye1_3x);
tv_index.setTextColor(getResources().getColor(R.color.grey888888));
///< 工作
-// iv_work.setImageResource(R.drawable.gwc2x);
+ iv_work.setImageResource(R.drawable.gongzuo1_3x);
tv_work.setTextColor(getResources().getColor(R.color.grey888888));
///< 我的
-// iv_me.setImageResource(R.drawable.dd2x);
+ iv_me.setImageResource(R.drawable.wode1_3x);
tv_me.setTextColor(getResources().getColor(R.color.grey888888));
}
diff --git a/app/src/main/java/com/qhclh/ytzh/login/LoginActivity.java b/app/src/main/java/com/qhclh/ytzh/login/LoginActivity.java
new file mode 100644
index 0000000..1040a6f
--- /dev/null
+++ b/app/src/main/java/com/qhclh/ytzh/login/LoginActivity.java
@@ -0,0 +1,123 @@
+package com.qhclh.ytzh.login;
+
+import android.content.Intent;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import com.qhclh.ytzh.R;
+import com.qhclh.ytzh.base.BaseActivity;
+import com.qhclh.ytzh.configs.ConfigUtil;
+import com.qhclh.ytzh.configs.LoginUserConfig;
+import com.qhclh.ytzh.configs.ServerConfig;
+import com.qhclh.ytzh.home.MainActivity;
+import com.qhclh.ytzh.home.MyApplication;
+import com.qhclh.ytzh.tasks.ViewOnClickTask;
+import com.qhclh.ytzh.utils.ActivityUtil;
+import com.qhclh.ytzh.utils.DialogUtil;
+import com.qhclh.ytzh.utils.HdHttpUtil;
+
+import org.forks.jsonrpc.RpcFacade;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+/**
+ * Created by 青花瓷 on 2017/11/28.
+ */
+
+public class LoginActivity extends BaseActivity {
+ @BindView(R.id.login_username)
+ EditText login_username;
+ @BindView(R.id.login_psw)
+ EditText login_psw;
+ @BindView(R.id.login_sure)
+ Button login_sure;
+
+ private LoginUserConfig config = new LoginUserConfig(this);
+ private ServerConfig sconfig = new ServerConfig(this);
+ @Override
+ protected int setLayoutId() {
+ return R.layout.act_login;
+ }
+
+ @Override
+ protected void initView() {
+ loginOut.execute();
+ MyApplication.ClearLogin();
+ ConfigUtil.Fill(sconfig);
+ ConfigUtil.Fill(config);
+ login_username.setText(config.Username);
+ login_psw.setText(config.Password);
+
+ }
+
+ @Override
+ protected void initData() {
+
+ }
+
+ @Override
+ protected void initOper() {
+
+ }
+
+ @OnClick({R.id.login_sure})
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.login_sure:
+ if (HdHttpUtil.isNetworkAvailable(LoginActivity.this)) {
+ loginTask.execute();
+ } else {
+ DialogUtil.AutoHiddenAlert(LoginActivity.this, "网络不可用");
+ }
+ break;
+ }
+ }
+
+
+ ViewOnClickTask loginOut = new ViewOnClickTask(this, "") {
+
+ @Override
+ public Object call() throws Exception {
+ RpcFacade.logout();
+ return null;
+ }
+
+ @Override
+ protected void successUI() {
+
+ }
+ };
+ ViewOnClickTask loginTask = new ViewOnClickTask(this, "登录中...") {
+ public Object call() throws Exception {
+ String username = login_username.getText().toString();
+ String password = login_psw.getText().toString();
+ config.Username = username;
+ config.Password = password;
+ RpcFacade.logout();
+ RpcFacade.login(username, password);
+ config.DisplayName = username;
+ ConfigUtil.Save(config);
+ return null;
+ }
+
+ @Override
+ protected void successUI() {
+ ConfigUtil.Fill(sconfig);
+ ActivityUtil.Go(LoginActivity.this, MainActivity.class);
+ }
+ };
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ //按返回键,程序进入后台运行,不关闭程序
+ MyApplication.getInstance().exit();
+ finish();
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+}
diff --git a/app/src/main/java/com/qhclh/ytzh/splash/SplashActivity.java b/app/src/main/java/com/qhclh/ytzh/splash/SplashActivity.java
index 6850548..3b7e89a 100644
--- a/app/src/main/java/com/qhclh/ytzh/splash/SplashActivity.java
+++ b/app/src/main/java/com/qhclh/ytzh/splash/SplashActivity.java
@@ -8,6 +8,7 @@ import android.widget.LinearLayout;
import com.qhclh.ytzh.R;
import com.qhclh.ytzh.base.BaseActivity;
import com.qhclh.ytzh.home.MainActivity;
+import com.qhclh.ytzh.login.LoginActivity;
import butterknife.BindView;
@@ -60,7 +61,7 @@ public class SplashActivity extends BaseActivity {
}
private void redirectTo() {
- startActivity(new Intent(this, MainActivity.class));
+ startActivity(new Intent(this, LoginActivity.class));
finish();
}
}
diff --git a/app/src/main/java/com/qhclh/ytzh/utils/ActivityUtil.java b/app/src/main/java/com/qhclh/ytzh/utils/ActivityUtil.java
new file mode 100644
index 0000000..dd50da8
--- /dev/null
+++ b/app/src/main/java/com/qhclh/ytzh/utils/ActivityUtil.java
@@ -0,0 +1,44 @@
+package com.qhclh.ytzh.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class ActivityUtil {
+ public String GetText(Activity activity, int id) {
+ View view = activity.findViewById(id);
+ if (view instanceof EditText) {
+ return ((EditText) view).getText().toString();
+ }
+
+ return String.format("未支持得到类型%s的文本", view.getClass());
+ }
+
+ public static Button FindButton(Activity activity, int id) {
+ return (Button) activity.findViewById(id);
+ }
+
+ public static void Go(Context context, Class> class1) {
+ Intent intent = new Intent();
+ intent.setClass(context, class1);
+ context.startActivity(intent);
+ }
+
+ public static void Go(View arg0, Class> class1) {
+ Go(arg0.getContext(), class1);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static T Find(Activity activity, int id) {
+ return (T) activity.findViewById(id);
+ }
+
+ public static void Finish(Activity activity, Intent data) {
+ activity.setResult(Activity.RESULT_OK, data);
+ activity.finish();
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/qhclh/ytzh/utils/HdHttpUtil.java b/app/src/main/java/com/qhclh/ytzh/utils/HdHttpUtil.java
new file mode 100644
index 0000000..bad8909
--- /dev/null
+++ b/app/src/main/java/com/qhclh/ytzh/utils/HdHttpUtil.java
@@ -0,0 +1,321 @@
+package com.qhclh.ytzh.utils;
+
+import android.content.Context;
+import android.location.LocationManager;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.telephony.TelephonyManager;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * Created by luanhui on 2016/7/8.
+ */
+public class HdHttpUtil {
+ public static final int NETWORK_OPERATOR_UNKOWN = 0;
+ public static final int NETWORK_OPERATOR_MOBILE = 1;
+ public static final int NETWORK_OPERATOR_UNICOM = 2;
+ public static final int NETWORK_OPERATOR_TELECOM = 3;
+
+ private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
+
+ /**
+ * String is null。
+ *
+ * @param src
+ * @return boolean
+ */
+ public static boolean isEmptyString(String src) {
+ return src == null || src.trim().length() == 0;
+ }
+
+ /**
+ * Return if the device is connected to wifi.
+ *
+ * @return boolean
+ */
+ public static boolean isWifi(Context context) {
+ try {
+ ConnectivityManager connectivityManager = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
+ if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
+ return true;
+ }
+ } catch (Exception e) {
+ }
+ return false;
+ }
+
+ /**
+ * 判断WiFi是否打开
+ *
+ * @param context
+ * @return
+ */
+ public static boolean isWifiEnabled(Context context) {
+ ConnectivityManager mgrConn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ TelephonyManager mgrTel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ return ((mgrConn.getActiveNetworkInfo() != null
+ && mgrConn.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED)
+ || mgrTel.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
+ }
+
+ /**
+ * Return if the device is connected to the 3G net.
+ *
+ * @param context
+ * @return boolean
+ */
+ public static boolean is3G(Context context) {
+ TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ int networkType = telephony.getNetworkType();
+
+ return networkType == TelephonyManager.NETWORK_TYPE_UMTS || networkType == TelephonyManager.NETWORK_TYPE_HSDPA
+ || networkType == TelephonyManager.NETWORK_TYPE_EVDO_0
+ || networkType == TelephonyManager.NETWORK_TYPE_EVDO_A
+ || networkType == TelephonyManager.NETWORK_TYPE_LTE
+ || networkType == TelephonyManager.NETWORK_TYPE_EVDO_B
+ || networkType == TelephonyManager.NETWORK_TYPE_EHRPD
+ || networkType == TelephonyManager.NETWORK_TYPE_HSUPA;
+
+ }
+
+ /**
+ * 判断当前网络是WiFi还是3G
+ *
+ * @param context
+ * @return
+ */
+ public static boolean isWifiOr3G(Context context) {
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo networkINfo = cm.getActiveNetworkInfo();
+ if (networkINfo != null && networkINfo.getType() == ConnectivityManager.TYPE_WIFI) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return if the device is connected to the 2G net.
+ *
+ * @param context
+ * @return boolean
+ */
+ public static boolean is2G(Context context) {
+ TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ int networkType = telephony.getNetworkType();
+
+ return networkType == TelephonyManager.NETWORK_TYPE_1xRTT || networkType == TelephonyManager.NETWORK_TYPE_CDMA
+ || networkType == TelephonyManager.NETWORK_TYPE_EDGE
+ || networkType == TelephonyManager.NETWORK_TYPE_IDEN
+ || networkType == TelephonyManager.NETWORK_TYPE_GPRS;
+
+ }
+
+ /**
+ * 判断Gsp是否可用
+ *
+ * @param context
+ * @return
+ */
+ public static boolean isGpsEnabled(Context context) {
+ LocationManager lm = ((LocationManager) context.getSystemService(Context.LOCATION_SERVICE));
+ List accessibleProviders = lm.getProviders(true);
+ return accessibleProviders != null && accessibleProviders.size() > 0;
+ }
+
+ /**
+ * Return if the network is available for the device
+ *
+ * @return boolean
+ */
+ public static boolean isNetAvailable(Context context) {
+ ConnectivityManager connectivityManager = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
+ if (networkInfo != null) {
+ return networkInfo.isAvailable();
+ }
+
+ return false;
+ }
+
+ /**
+ * 判断网络连接是否可用
+ *
+ * @param context
+ * @return
+ */
+ public static boolean isNetworkAvailable(Context context) {
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (cm == null) {
+ } else {
+ // 如果仅仅是用来判断网络连接
+ // 则可以使用 cm.getActiveNetworkInfo().isAvailable();
+ NetworkInfo[] info = cm.getAllNetworkInfo();
+ if (info != null) {
+ for (int i = 0; i < info.length; i++) {
+ if (info[i].getState() == NetworkInfo.State.CONNECTED) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Return if the device is connected to mobile network.
+ *
+ * @return boolean
+ */
+ public static boolean isMobile(Context context) {
+ try {
+ ConnectivityManager connectivityManager = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
+ if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
+ return true;
+ }
+ } catch (Exception e) {
+ }
+ return false;
+ }
+
+ /**
+ * Return if the device is connected to wap network.
+ *
+ * @return boolean
+ */
+ public static boolean isWap(String proxyhost) {
+ Pattern pattern = Pattern.compile("^[0]{0,1}10\\.[0]{1,3}\\.[0]{1,3}\\.172$", Pattern.MULTILINE);
+ boolean ret = false;
+ Matcher m = pattern.matcher(proxyhost);
+ if (m.find()) {
+ ret = true;
+ } else {
+ ret = false;
+ }
+ return ret;
+ }
+
+ /**
+ * return if proxy is used for connect to the network
+ *
+ * @return
+ */
+ public static boolean isPorxyUsed(Context context) {
+ if (isWifi(context)) {
+ return false;
+ }
+
+ // 不管cmnet和cmwap都选择直连方式
+ if (readNetworkOperatorType(context) == NETWORK_OPERATOR_MOBILE) {
+ return false;
+ }
+
+ String proxyHost = android.net.Proxy.getDefaultHost();
+ if (isEmptyString(proxyHost)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * read the network operator type
+ */
+ public static int readNetworkOperatorType(Context context) {
+ TelephonyManager telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ String operator = telManager.getNetworkOperator();
+
+ // 飞行模式下 获取不到operator
+ if (isEmptyString(operator)) {
+ return NETWORK_OPERATOR_UNKOWN;
+ }
+
+ // 非中国运营商
+ String mcc = operator.substring(0, 3);
+ if (mcc == null || !mcc.equals("460")) {
+ return NETWORK_OPERATOR_UNKOWN;
+ }
+
+ // operator 由mcc + mnc组成 中国的mcc为460
+ // 这里取得mnc来判断是国内的哪个运营商
+ String mnc = operator.substring(3);
+ int mncIntVar = 0;
+ try {
+ mncIntVar = Integer.parseInt(mnc);
+ } catch (NumberFormatException e) {
+ }
+
+ switch (mncIntVar) {
+ case 0:
+ case 2:
+ case 7:
+ return NETWORK_OPERATOR_MOBILE;
+ case 1:
+ case 6:
+ return NETWORK_OPERATOR_UNICOM;
+ case 3:
+ case 5:
+ return NETWORK_OPERATOR_TELECOM;
+ default:
+ break;
+ }
+
+ return NETWORK_OPERATOR_UNKOWN;
+ }
+
+ /**
+ * gzip decompress
+ *
+ * @param is
+ * @param os
+ * @throws Exception
+ */
+ public static void decompress(InputStream is, OutputStream os) throws Exception {
+ GZIPInputStream gin = new GZIPInputStream(is);
+ int count;
+ byte data[] = new byte[1024];
+ while ((count = gin.read(data, 0, 1024)) != -1) {
+ os.write(data, 0, count);
+ }
+ gin.close();
+ }
+
+ /**
+ * gzip compress
+ *
+ * @param is
+ * @param os
+ * @throws Exception
+ */
+ public static void compress(InputStream is, OutputStream os) throws Exception {
+ GZIPOutputStream gos = new GZIPOutputStream(os);
+ int count;
+ byte data[] = new byte[1024];
+ while ((count = is.read(data, 0, 1024)) != -1) {
+ gos.write(data, 0, count);
+ }
+ gos.flush();
+ gos.finish();
+ gos.close();
+ }
+
+ public static byte[] compress(byte[] is) throws Exception {
+ ByteArrayInputStream tmpInput = new ByteArrayInputStream(is);
+ ByteArrayOutputStream tmpOutput = new ByteArrayOutputStream(1024);
+ HdHttpUtil.compress(tmpInput, tmpOutput);
+ return tmpOutput.toByteArray();
+ }
+}
diff --git a/app/src/main/res/drawable-xhdpi/gongzuo1_3x.png b/app/src/main/res/drawable-xhdpi/gongzuo1_3x.png
new file mode 100644
index 0000000..1793af4
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/gongzuo1_3x.png differ
diff --git a/app/src/main/res/drawable-xhdpi/gongzuo_3x.png b/app/src/main/res/drawable-xhdpi/gongzuo_3x.png
new file mode 100644
index 0000000..b6b2be0
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/gongzuo_3x.png differ
diff --git a/app/src/main/res/drawable-xhdpi/shouye1_3x.png b/app/src/main/res/drawable-xhdpi/shouye1_3x.png
new file mode 100644
index 0000000..f9ee872
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/shouye1_3x.png differ
diff --git a/app/src/main/res/drawable-xhdpi/shouye_3x.png b/app/src/main/res/drawable-xhdpi/shouye_3x.png
new file mode 100644
index 0000000..86c0f46
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/shouye_3x.png differ
diff --git a/app/src/main/res/drawable-xhdpi/wode1_3x.png b/app/src/main/res/drawable-xhdpi/wode1_3x.png
new file mode 100644
index 0000000..f0ef407
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/wode1_3x.png differ
diff --git a/app/src/main/res/drawable-xhdpi/wode_3x.png b/app/src/main/res/drawable-xhdpi/wode_3x.png
new file mode 100644
index 0000000..79d68c1
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/wode_3x.png differ
diff --git a/app/src/main/res/layout/act_login.xml b/app/src/main/res/layout/act_login.xml
new file mode 100644
index 0000000..332e845
--- /dev/null
+++ b/app/src/main/res/layout/act_login.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 7f21df9..cc018a1 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -23,6 +23,7 @@
#888888
#f4f4f4
#dbdbdb
+ #cacaca
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 9caafe2..40ea8ad 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -131,9 +131,9 @@
8px
20px
- @dimen/text_size_16
- 30dp
- 30dp
+ @dimen/text_size_12
+ 28dp
+ 28dp
8dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 412173c..5e5c09b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -4,4 +4,7 @@
工作
我的
再按一次返回键退出应用
+ 请输入用户名
+ 请输入密码
+ 登录
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 8b8bd9b..553594a 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -32,7 +32,8 @@