Forráskód Böngészése

Merge branch 'sheep2.0' of http://10.8.230.114:3000/kemllor/small_sheep_android into sheep2.0

zhanghai 8 éve
szülő
commit
7095811e3f

+ 16 - 0
app/src/main/java/com/sheep/gamegroup/di/components/ChangePhoneComponent.java

@@ -0,0 +1,16 @@
+package com.sheep.gamegroup.di.components;
+
+import com.sheep.gamegroup.di.modules.PhoneModule;
+import com.sheep.gamegroup.di.scopes.UserScope;
+import com.sheep.gamegroup.view.activity.ChangeTelAct;
+
+import dagger.Component;
+
+/**
+ * Created by ljy on 2018/3/29.
+ */
+@UserScope
+@Component(modules = PhoneModule.class, dependencies = NetComponent.class)
+public interface ChangePhoneComponent {
+    void inject (ChangeTelAct changeTelAct);
+}

+ 33 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/TaskDownloadState.java

@@ -0,0 +1,33 @@
+package com.sheep.gamegroup.model.entity;
+
+import java.io.Serializable;
+
+/**
+ * Created by ljy on 2018/3/27.
+ */
+
+public class TaskDownloadState implements Serializable {
+    private int state;
+    private long lastLength;
+
+    public TaskDownloadState(int state, long lastLength) {
+        this.state = state;
+        this.lastLength = lastLength;
+    }
+
+    public int getState() {
+        return state;
+    }
+
+    public void setState(int state) {
+        this.state = state;
+    }
+
+    public long getLastLength() {
+        return lastLength;
+    }
+
+    public void setLastLength(long lastLength) {
+        this.lastLength = lastLength;
+    }
+}

+ 6 - 0
app/src/main/java/com/sheep/gamegroup/presenter/PhoneContract.java

@@ -4,6 +4,7 @@ import com.sheep.gamegroup.exception.ApiException;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 
 import org.json.JSONException;
+import org.json.JSONObject;
 
 /**
  * Created by ljy on 2018/3/15.
@@ -15,6 +16,8 @@ public interface PhoneContract {
 
         void getCaptcha(String telphone) throws JSONException;
         void loginByCaptcha(String telphone, String code);
+
+        void switchPhone(JSONObject object);
     }
 
     interface View{
@@ -25,5 +28,8 @@ public interface PhoneContract {
         void returnLogindata(Object o);
 
         void loginFail(BaseMessage o);
+
+        void changeTelSuccess(BaseMessage o);
+        void changeTelFail(BaseMessage o);
     }
 }

+ 155 - 11
app/src/main/java/com/sheep/gamegroup/view/activity/ChangeTelAct.java

@@ -1,16 +1,31 @@
 package com.sheep.gamegroup.view.activity;
 
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
 import android.support.v7.widget.AppCompatEditText;
+import android.text.TextUtils;
 import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.di.components.DaggerPhoneComponent;
+import com.sheep.gamegroup.di.modules.PhoneModule;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.UserEntity;
+import com.sheep.gamegroup.presenter.PhoneContract;
+import com.sheep.gamegroup.presenter.PhonePresenter;
 import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.MyDbManager;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
+import org.xutils.ex.DbException;
+
+import javax.inject.Inject;
+
 import butterknife.BindView;
 import butterknife.ButterKnife;
 import butterknife.OnClick;
@@ -19,7 +34,7 @@ import butterknife.OnClick;
  * Created by ljy on 2018/3/27.
  */
 
-public class ChangeTelAct extends BaseActivity {
+public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
     @BindView(R.id.tel_tv)
     TextView telTv;
     @BindView(R.id.change_sure_tv)
@@ -32,13 +47,46 @@ public class ChangeTelAct extends BaseActivity {
     AppCompatEditText phoneEtAccount;
     @BindView(R.id.phone_et_code)
     AppCompatEditText phoneEtCode;
+    @BindView(R.id.phone_et_code_old)
+    AppCompatEditText phone_et_code_old;
     @BindView(R.id.phone_btn_code)
     TextView phoneBtnCode;
+    @BindView(R.id.phone_btn_code_old)
+    TextView phone_btn_code_old;
+    @BindView(R.id.phone_tip_tv)
+    TextView phone_tip_tv;
     @BindView(R.id.phone_sure_tv)
     TextView phoneSureTv;
     @BindView(R.id.change_phone_layout)
     LinearLayout changePhoneLayout;
 
+    @Inject
+    PhonePresenter presenter;
+
+    private final int CHANGGE_CLICK = 0;//切换手机按钮点击后
+    private final int OLD_PHONE_CLICK = 1;//旧手机获取验证码后
+
+    private int oldOrNew;   //1,绑定过   0,未绑定过
+
+    private String hitStr = "请输入手机号";
+    private String noticeStr = "绑定手机号";
+    UserEntity userEntity = null;
+
+    Handler handler = new Handler(){
+        @Override
+        public void handleMessage(Message msg) {
+            super.handleMessage(msg);
+            switch (msg.what){
+                case CHANGGE_CLICK://
+                    refreshData();
+                    break;
+                case OLD_PHONE_CLICK://
+
+                    break;
+            }
+        }
+    };
+
     @Override
     protected int getLayoutId() {
         return R.layout.changge_tel_layout;
@@ -47,10 +95,30 @@ public class ChangeTelAct extends BaseActivity {
     @Override
     public void initView() {
         ButterKnife.bind(this);
-        TitleBarUtils.getInstance()
-                .setTitle(this, "绑定手机号")
-                .setTitleFinish(this);
 
+//        DaggerPhoneComponent.builder()
+//                .netComponent(SheepApp.get(this).getNetComponent())
+//                .phoneModule(new PhoneModule(this))
+//                .build()
+//                .inject(this);
+        oldOrNew = 0;
+        try {
+            userEntity = MyDbManager.getInstance()
+                    .dbFindUser();
+        } catch (DbException e) {
+            e.printStackTrace();
+        }
+        if(userEntity != null && !TextUtils.isEmpty(userEntity.getMobile())){//提示
+
+            TitleBarUtils.getInstance()
+                    .setTitle(this, noticeStr)
+                    .setTitleFinish(this);
+            showChangeLayout.setVisibility(View.VISIBLE);
+            changePhoneLayout.setVisibility(View.GONE);
+            telTv.setText(userEntity.getMobile()+"");
+            return;
+        }
+        refreshData();
     }
 
     @Override
@@ -61,16 +129,31 @@ public class ChangeTelAct extends BaseActivity {
     @Override
     public void initData() {
 
+
     }
 
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        // TODO: add setContentView(...) invocation
-        ButterKnife.bind(this);
+    /**
+     * refresh
+     */
+    public void refreshData(){
+        showChangeLayout.setVisibility(View.GONE);
+        changePhoneLayout.setVisibility(View.VISIBLE);
+        if(oldOrNew == 1){
+            hitStr = "请输入原手机号码";
+            noticeStr = "验证原手机";
+            phoneEtAccount.setHint(hitStr+"");
+            phoneEtAccount.setText(userEntity.getMobile()+"");
+        }else{
+            hitStr = "请输入原手机号码";
+            noticeStr = "更换手机号";
+            phoneEtAccount.setHint(hitStr+"");
+        }
+        TitleBarUtils.getInstance()
+                .setTitle(this, noticeStr)
+                .setTitleFinish(this);
     }
 
-    @OnClick({R.id.change_sure_tv, R.id.phone_btn_code, R.id.phone_sure_tv, R.id.sure_change_tv})
+    @OnClick({R.id.change_sure_tv, R.id.phone_btn_code, R.id.phone_sure_tv, R.id.sure_change_tv, R.id.phone_btn_code_old})
     public void onViewClicked(View view) {
         switch (view.getId()) {
             case R.id.change_sure_tv:
@@ -80,8 +163,69 @@ public class ChangeTelAct extends BaseActivity {
             case R.id.phone_sure_tv:
                 break;
             case R.id.sure_change_tv:
-                Jump2View.getInstance().goPhoneLoginView(ChangeTelAct.this, 1);
+                oldOrNew = 1;
+                handler.sendEmptyMessage(CHANGGE_CLICK);
+                if(!checkCodeInput(phone_et_code_old.getText().toString() +"")){
+                    return;
+                }
+//                Jump2View.getInstance().goPhoneLoginView(ChangeTelAct.this, 1);
+                break;
+            case R.id.phone_btn_code_old://旧手机获取验证码
                 break;
         }
     }
+
+    @Override
+    public void returnGaptcha(Object o) {
+
+    }
+
+    @Override
+    public void gaptchaFail(BaseMessage o) {
+
+    }
+
+    @Override
+    public void returnLogindata(Object o) {
+
+    }
+
+    @Override
+    public void loginFail(BaseMessage o) {
+
+    }
+
+    @Override
+    public void changeTelSuccess(BaseMessage o) {
+
+    }
+
+    @Override
+    public void changeTelFail(BaseMessage o) {
+
+    }
+
+
+    private boolean checkPhoneInput(String etPhone) {
+        if (TextUtils.isEmpty(etPhone)) {
+            showToast(getString(R.string.input_your_phone));
+            return false;
+        }
+        if (etPhone.toString().length() != 11) {
+            showToast(getString(R.string.toast_warning_phone_number_size));
+            return false;
+        }
+        return true;
+    }
+    private boolean checkCodeInput(String etCode) {
+        if (TextUtils.isEmpty(etCode)) {
+            showToast(getString(R.string.input_your_captcha));
+            return false;
+        }
+        if (etCode.toString().length() != 6) {
+            showToast(getString(R.string.toast_warning_phone_captcha_image_code_size));
+            return false;
+        }
+        return true;
+    }
 }

+ 1 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/CommitWxAct.java

@@ -82,6 +82,7 @@ public class CommitWxAct extends BaseActivity implements CommitWxMakeMoneyContra
                 .commitWxMakeMoneyModule(new CommitWxMakeMoneyModule(this))
                 .build()
                 .inject(this);
+        et_wx_account.setHint("请输入微信号");
     }
 
     @Override

+ 22 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/DialogActivity.java

@@ -93,7 +93,7 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
 
     private DownloadManager downloadManager;
     DownloadInfo downloadInfo;
-    private int type;//0,开始任务 1,开始试玩 2,开始下载
+    private int type;//0,开始任务 1,开始试玩 2,开始下载 3,开始安装
     private boolean isStartPause = false;//false:开始,true:暂停
     private boolean isDownLoad = false;//是否下载
     private String buttonStr = "开始任务";//是否下载
@@ -244,6 +244,10 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
                     isStartPause = !isStartPause;
 
                     break;
+
+                case 3://开始安装
+                    PackageUtil.installApk(activity, downloadInfo.getFileSavePath()+"");
+                    break;
             }
         }catch (Exception e){
             e.printStackTrace();
@@ -269,6 +273,17 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
                 downloadInfo.setState(DownloadState.STARTED);
                 downloadInfo.setPkgName(task_entity.getPackage_names());
                 MyDbManager.getInstance().saveOrUpdateUser(downloadInfo);//保存到数据库
+            }else if (downloadInfo == null){
+                downloadInfo = new DownloadInfo();
+                downloadInfo.setUrl(task_entity.getDownload_link());
+                downloadInfo.setAutoRename(false);
+                downloadInfo.setAutoResume(true);
+                downloadInfo.setLabel(task_entity.getTask_name());
+                downloadInfo.setFileSavePath(mApkPath.getAbsolutePath());
+                downloadInfo.setIcon(task_entity.getIcon());
+                downloadInfo.setState(DownloadState.FINISHED);
+                downloadInfo.setPkgName(task_entity.getPackage_names());
+                MyDbManager.getInstance().saveOrUpdateUser(downloadInfo);//保存到数据库
             }
         }
         return downloadInfo;
@@ -292,7 +307,10 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
             if(isDownLoad){
                 buttonStr = "开始试玩";
                 type = 1;
-            }else {
+            }if(downloadInfo.getState() ==DownloadState.FINISHED ){
+                buttonStr = "开始安装";
+            }
+            else {
                 buttonStr = "开始下载";
                 type = 2;
             }
@@ -394,6 +412,8 @@ public class DialogActivity extends Activity implements TaskDialogContract.View
 
         @Override
         public void onFileDownloadStatusCompleted(DownloadFileInfo downloadFileInfo) {
+            if(downloadInfo != null)
+                downloadInfo.setState(DownloadState.FINISHED);
             handler.sendEmptyMessage(3);
         }
 

+ 10 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/PhoneAct.java

@@ -278,6 +278,16 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
 //        testData();
     }
 
+    @Override
+    public void changeTelSuccess(BaseMessage o) {
+
+    }
+
+    @Override
+    public void changeTelFail(BaseMessage o) {
+
+    }
+
     private void goMain() {
         // TODO: 2018/3/22  测试界面,过后删除s
         SpUtils.login(getApplicationContext(), "13626@395a75211751465f54789a7f459089bd");

+ 1 - 1
app/src/main/res/layout/bind_phone_number_act_layout.xml

@@ -78,7 +78,7 @@
                         android:layout_height="@dimen/edt_heigh_default"
                         android:layout_weight="2"
                         android:hint="请输入验证码"
-                        android:inputType="phone"
+                        android:inputType="number"
                         android:paddingLeft="@dimen/content_padding_big"
                         android:maxLength="6"
                         android:textSize="@dimen/text_size_3"/>

+ 43 - 5
app/src/main/res/layout/changge_tel_layout.xml

@@ -38,7 +38,7 @@
                     android:id="@+id/tel_tv"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:text="123456"
+                    android:text=""
                     style="@style/txt_style_12"
                     android:layout_marginTop="@dimen/content_padding_30"
                     android:layout_gravity="center"/>
@@ -50,6 +50,42 @@
                     android:layout_marginTop="@dimen/content_padding_10"
                     android:layout_marginBottom="@dimen/content_padding_10"
                     android:layout_gravity="center"/>
+
+
+                <LinearLayout
+                    android:id="@+id/send_code_old_layout"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="horizontal"
+                    android:layout_marginLeft="18dp"
+                    android:layout_marginRight="18dp"
+                    android:layout_marginTop="@dimen/content_padding_big"
+                    android:layout_marginBottom="@dimen/content_padding_small">
+
+                    <android.support.v7.widget.AppCompatEditText
+                        android:id="@+id/phone_et_code_old"
+                        style="@style/edt_style"
+                        android:layout_width="0dp"
+                        android:layout_height="@dimen/edt_heigh_default"
+                        android:layout_weight="2"
+                        android:hint="请输入验证码"
+                        android:inputType="number"
+                        android:paddingLeft="@dimen/content_padding_big"
+                        android:maxLength="6"
+                        android:textSize="@dimen/text_size_3"/>
+                    <TextView
+                        android:id="@+id/phone_btn_code_old"
+                        android:layout_width="0dp"
+                        android:layout_height="wrap_content"
+                        android:layout_gravity="center|center_vertical"
+                        android:layout_marginLeft="@dimen/content_padding"
+                        android:layout_weight="1"
+                        android:gravity="center"
+                        android:text="@string/get_captcha"
+                        android:textColor="@color/txt_bule"
+                        />
+
+                </LinearLayout>
                 <TextView
                     android:id="@+id/sure_change_tv"
                     android:layout_width="match_parent"
@@ -67,7 +103,8 @@
                 <LinearLayout
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:orientation="vertical">
+                    android:orientation="vertical"
+                    android:visibility="gone">
                     <ImageView
                         android:id="@+id/phone_iv"
                         android:layout_width="wrap_content"
@@ -89,7 +126,8 @@
                     android:text="为了避免机器刷单,请绑定手机号后领取任务奖励"
                     android:textColor="@color/black_444444"
                     android:textSize="11dp"
-                    android:layout_gravity="center_horizontal"/>
+                    android:layout_gravity="center_horizontal"
+                    android:visibility="gone"/>
 
                 <LinearLayout
                     android:layout_width="match_parent"
@@ -107,7 +145,7 @@
                         android:layout_height="@dimen/edt_heigh_default"
                         android:layout_centerVertical="true"
                         android:layout_margin="@dimen/content_padding_small"
-                        android:hint="请输入手机号"
+                        android:hint="请输入要绑定的手机号"
                         android:paddingLeft="@dimen/content_padding_big"
                         android:maxLength="11"/>
 
@@ -126,7 +164,7 @@
                             android:layout_height="@dimen/edt_heigh_default"
                             android:layout_weight="2"
                             android:hint="请输入验证码"
-                            android:inputType="phone"
+                            android:inputType="number"
                             android:paddingLeft="@dimen/content_padding_big"
                             android:maxLength="6"
                             android:textSize="@dimen/text_size_3"/>

+ 1 - 1
app/src/main/res/layout/x_ask_reward_dialog.xml

@@ -52,7 +52,7 @@
             android:text="复制链接"
             android:textColor="@color/black_444444"
             android:textSize="18dp"
-            android:background="@drawable/sp_bg_yellow"
+            android:background="@drawable/selector_button_full_main"
             android:gravity="center"
             android:layout_gravity="center"
             android:layout_marginTop="20dp"

BIN
app/src/main/res/mipmap-xhdpi/x_ic_phone.png


BIN
app/src/main/res/mipmap-xhdpi/x_ic_weixin.png


BIN
app/src/main/res/mipmap-xxhdpi/x_ic_phone.png


BIN
app/src/main/res/mipmap-xxhdpi/x_ic_weixin.png