Skip to content

Commit

Permalink
✅ 2.2.51版本,达成成就:联动?快了!
Browse files Browse the repository at this point in the history
  • Loading branch information
Hny0305Lin committed May 12, 2022
1 parent 45a60e9 commit 44e06a7
Show file tree
Hide file tree
Showing 8 changed files with 603 additions and 1 deletion.
2 changes: 1 addition & 1 deletion HaohanyhHAMOSProjectX Software/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdk 21
targetSdk 26
versionCode 1
versionName "2.1.30.2022.0508.Haohanyh.Release"
versionName "2.2.51.2022.0512.Haohanyh.Release"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<activity android:name=".ImportActivity.FifthActivity" android:exported="true" />
<activity android:name=".hhyhlogin.Lv2LoginActivity" android:exported="true" />
<activity android:name=".hhyhlogin.Lv2RegisterActivity" android:exported="true" />
<activity android:name=".LianDong.ExceedActivity" android:exported="true" />
<activity android:name=".LianDong.ExceedRunActivity" android:exported="true" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
package com.haohanyh.hamos.projectx.LianDong;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.haohanyh.hamos.projectx.R.*;


public class ExceedActivity extends Activity {

int autotimer = 0;

CheckBox cbKey;

Button btnTemp,btnHumi,btnLight,btnInfraned;
Button btndayu,btndengyu,btnxiaoyu;
EditText txtnum,txtIO;

Button btnLamp,btnLED,btnFan;
Button btnoff,btnon;

boolean btnsensorI,btnsensorII,btnsensorIII,btnsensorIV,btnbijiaoI,btnbijiaoII,btnbijiaoIII;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(layout.activity_liandong_all);

//复选框,勾选为开启线程,非勾选为关闭线程
cbKey = findViewById(id.checkBoxKey);

btnTemp = findViewById(id.rb1);
btnHumi = findViewById(id.rb2);
btnLight = findViewById(id.rb3);
btnInfraned = findViewById(id.rb4);
btnxiaoyu = findViewById(id.rrb1);
btndengyu = findViewById(id.rrb2);
btndayu = findViewById(id.rrb3);

btnLamp = findViewById(id.rb5);
btnLED = findViewById(id.rb6);
btnFan = findViewById(id.rb7);
btnoff = findViewById(id.rrb4);
btnon = findViewById(id.rrb5);

txtnum = findViewById(id.editText1);
txtIO = findViewById(id.editText2);

cbKey.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
autotimer++;
if(autotimer % 2 != 0) {
Toast.makeText(ExceedActivity.this,"开启自定义联动功能",Toast.LENGTH_SHORT).show();
if(ExceedCheck() && ExceedCheck2())
{
Toast.makeText(ExceedActivity.this, "正在加载中...!", Toast.LENGTH_SHORT).show();
Log.w("浩瀚银河灰度测试,函数为:", String.valueOf(ExceedGetInformation()));
if(ExceedGetInformation() == 502)
{
Toast.makeText(ExceedActivity.this, "灰度测试:您有一项没设置,但没有关系!", Toast.LENGTH_SHORT).show();
Intent i = new Intent(ExceedActivity.this,ExceedRunActivity.class);
startActivity(i);
}
if(ExceedGetInformation() == 200)
{
Toast.makeText(ExceedActivity.this, "灰度测试:您有零项没设置,非常好!", Toast.LENGTH_SHORT).show();
Intent i = new Intent(ExceedActivity.this,ExceedRunActivity.class);
startActivity(i);
}
if(ExceedGetInformation() != 404)
{
Intent i = new Intent(ExceedActivity.this,ExceedRunActivity.class);
startActivity(i);
}
} else {
Toast.makeText(ExceedActivity.this, "您还没设置完毕!", Toast.LENGTH_SHORT).show();
cbKey.setChecked(false);
autotimer--;//还没设置完毕就想跑联动?做梦!
}
} else {
Context context = ExceedActivity.this;
int bottom = 24;
int top = 12;
TextView textView = new TextView(context);
textView.setText("您已关闭自定义联动功能,是否离开当前页面?\n\n\n");
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
textView.setPadding(0, top, 0, bottom);
textView.setGravity(Gravity.CENTER);
textView.setTextColor(ContextCompat.getColor(context, color.Pink_is_fancy));
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setCustomTitle(textView)
.setPositiveButton("我要保留", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(ExceedActivity.this,"好的目前您还在此页面!",Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("我要离开", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
onBackPressed();
}
});
builder.show();
}
}
});

btnTemp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean btnsensorI = true;
boolean btnsensorII = false;
boolean btnsensorIII = false;
boolean bensensorIV = false;
}
});

btnHumi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean btnsensorI = false;
boolean btnsensorII = true;
boolean btnsensorIII = false;
boolean bensensorIV = false;
}
});

btnLight.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean btnsensorI = false;
boolean btnsensorII = false;
boolean btnsensorIII = true;
boolean bensensorIV = false;
}
});

btnInfraned.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean btnsensorI = false;
boolean btnsensorII = false;
boolean btnsensorIII = false;
boolean bensensorIV = true;
}
});

btnxiaoyu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean btnbijiaoI = true;
boolean btnbijiaoII = false;
boolean btnbijiaoIII = false;
}
});

btndengyu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean btnbijiaoI = false;
boolean btnbijiaoII = true;
boolean btnbijiaoIII = false;
}
});

btndayu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean btnbijiaoI = false;
boolean btnbijiaoII = false;
boolean btnbijiaoIII = true;
}
});
}

private boolean ExceedCheck() {

String num = txtnum.getText().toString();
String IorO = txtIO.getText().toString();

if(btnTemp.isClickable() || btnHumi.isClickable() || btnLight.isClickable() || btnInfraned.isClickable()) {
//第一层 按钮肯定按了嘛,所以接下来是剩下的第一行的控件
if(btnxiaoyu.isClickable() || btndengyu.isClickable() || btndayu.isClickable()) {
//第二层 大于小于等于肯定按了一个嘛,所以接下来是剩下的
if(num.equals("") && IorO.equals(""))
{
Toast.makeText(ExceedActivity.this,"目前您还没设置数值,如果是人体感应联动,您还没设置0和1的触发条件!",Toast.LENGTH_SHORT).show();
return false;
}
Toast.makeText(ExceedActivity.this,"正在检查....",Toast.LENGTH_SHORT).show();
cbKey.setChecked(false);
return true;
}
Toast.makeText(ExceedActivity.this,"您还未选择大于、小于、等于的其中一个!",Toast.LENGTH_SHORT).show();
return false;
}
Toast.makeText(ExceedActivity.this,"您还未选择传感器的其中一个!",Toast.LENGTH_SHORT).show();
return false;
}

private boolean ExceedCheck2() {
if(btnLamp.isClickable() || btnLED.isClickable() || btnFan.isClickable())
{
//第一层 按钮肯定按了嘛,所以接下来是剩下的第二行的控件
if(btnoff.isClickable() || btnon.isClickable())
{
Toast.makeText(ExceedActivity.this,"检查完成,您的设置毫无问题!",Toast.LENGTH_SHORT).show();
cbKey.setChecked(true);
return true;
}
Toast.makeText(ExceedActivity.this,"您还未选择On和Off的其中一个!",Toast.LENGTH_SHORT).show();
return false;
}
Toast.makeText(ExceedActivity.this,"您还未选择传感器的其中一个!",Toast.LENGTH_SHORT).show();
return false;
}

private int ExceedGetInformation() {

String numstr = txtnum.getText().toString();
String IorOstr = txtIO.getText().toString();

int num = Integer.parseInt(numstr.equals("") ? "502":numstr);
Log.w("浩瀚银河灰度测试,num为:", String.valueOf(num));
int IorO = Integer.parseInt(IorOstr.equals("") ? "502":IorOstr);
Log.w("浩瀚银河灰度测试,IorO为:", String.valueOf(IorO));

if(btnsensorI || btnsensorII || btnsensorIII)
{
if(num < 60 && num > -20)
{
return num;
}
}

if(btnsensorIV)
{
if(IorO < 2 && IorO > -1)
{
return IorO;
}
}

return ((numstr.equals("") && (IorOstr.equals("")) ? 404:200));
//404 Not Found,233333~~~
//404 为找不到设置是否正常
//502 为没有填写的正常返回值
}

public boolean onKeyDown(int keyCode, KeyEvent event)
{
if(keyCode == KeyEvent.KEYCODE_BACK)
{
onBackPressed();
return true;
} else {
return onKeyDown(keyCode,event);
}
}

public void onBackPressed() {
Toast.makeText(ExceedActivity.this,"正在完全退出进程...",Toast.LENGTH_SHORT).show();
super.onBackPressed();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.haohanyh.hamos.projectx.LianDong;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.haohanyh.hamos.projectx.R.*;
import com.haohanyh.hamos.projectx.LianDong.ExceedActivity;

public class ExceedRunActivity extends Activity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(layout.activity_liandong_start);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ protected void onCreate(Bundle savedInstanceState) {
Button btnnew7 = findViewById(id.kaiqi7);
Button btnnew8 = findViewById(id.kaiqinew);

Button btnliandong = findViewById(id.kaiqi5liandong);

btnnew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -139,6 +141,13 @@ public void onClick(View view) {
Click8(view);
}
});

btnliandong.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Click9(view, "自定义联动");
}
});
}

void Click1(View v)
Expand Down Expand Up @@ -251,4 +260,11 @@ void Click8(View v)
Intent intent = new Intent(MainActivity.this, NewFirstActivity.class);
startActivity(intent);
}

void Click9(View v,String a)
{
Toast.makeText(MainActivity.this,"即将前往"+a,Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, ExceedActivity.class);
startActivity(intent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/main_background"
android:gravity="bottom|top"
android:orientation="vertical"
tools:context=".LianDong.ExceedActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/Pink_is_fancy"
android:gravity="bottom|center"
android:text="@string/haohanyh_hamos_lights_project"
android:textColor="@color/white"
android:textSize="24sp"
android:textStyle="italic" />

<include
layout="@layout/activity_liandong_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />

</LinearLayout>

</LinearLayout>
Loading

0 comments on commit 44e06a7

Please sign in to comment.