Compare commits
44
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
816ad0831d | ||
|
|
487f7c4ee1 | ||
|
|
7df1704147 | ||
|
|
ad3611e586 | ||
|
|
d1390fd38d | ||
|
|
3c2e573ea6 | ||
|
|
1ad2672fd5 | ||
|
|
45e0c2ecb1 | ||
|
|
fbd6d7fb70 | ||
|
|
ec35beb407 | ||
|
|
5126bb1ec8 | ||
|
|
6378f323a3 | ||
|
|
0c90c61598 | ||
|
|
69d4d65f24 | ||
|
|
54efd036e4 | ||
|
|
bc2b17e963 | ||
|
|
f1f144ec32 | ||
|
|
1ed84b8b79 | ||
|
|
f62606bd96 | ||
|
|
9ef9c1e10b | ||
|
|
14bd2910aa | ||
|
|
ac765ef03d | ||
|
|
2bd29aaf73 | ||
|
|
02fea51b9e | ||
|
|
b6f1aeaeb6 | ||
|
|
6788ff18d1 | ||
|
|
e7479a8d7e | ||
|
|
c3fcea2b0a | ||
|
|
cdd48de227 | ||
|
|
8b227aa7f7 | ||
|
|
ea8623ada8 | ||
|
|
870cc3ae5b | ||
|
|
196d95f792 | ||
|
|
bc5fafab52 | ||
|
|
ba54b1ff84 | ||
|
|
9cf570410b | ||
|
|
963c6d135d | ||
|
|
a041e630ec | ||
|
|
ab6f02b4e1 | ||
|
|
fd7278e599 | ||
|
|
3bf35ff5be | ||
|
|
304268fd8e | ||
|
|
5bf3588b57 | ||
|
|
45ae954324 |
@@ -25,6 +25,6 @@ android {
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testImplementation 'junit:junit:4.12'
|
||||
api 'androidx.appcompat:appcompat:1.0.0'
|
||||
api 'androidx.appcompat:appcompat:1.3.0'
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -12,7 +12,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
// classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
|
||||
classpath 'com.android.tools.build:gradle:4.2.2'
|
||||
classpath 'com.android.tools.build:gradle:7.4.2'
|
||||
}
|
||||
}
|
||||
allprojects {
|
||||
@@ -24,10 +24,10 @@ allprojects {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven {url 'https://dl.google.com/dl/android/maven2/'}
|
||||
maven { url 'http://developer.huawei.com/repo/' }
|
||||
maven { url 'https://developer.huawei.com/repo/' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/repositories/releases/'
|
||||
url 'https://maven.aliyun.com/nexus/content/repositories/releases/'
|
||||
}
|
||||
google()
|
||||
}
|
||||
@@ -35,6 +35,6 @@ allprojects {
|
||||
ext {
|
||||
compileSdkVersion = 33
|
||||
buildToolsVersion = "33.0.0"
|
||||
minSdkVersion = 24
|
||||
minSdkVersion = 21
|
||||
targetSdkVersion = 33
|
||||
}
|
||||
+2
-2
@@ -26,5 +26,5 @@ android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
android.useDeprecatedNdk=true
|
||||
|
||||
versionCode=40
|
||||
versionName=4.11.0
|
||||
versionCode=43
|
||||
versionName=4.11.3
|
||||
Vendored
BIN
Binary file not shown.
+2
-3
@@ -1,6 +1,5 @@
|
||||
#Thu Sep 21 11:53:04 CST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,74 +1,129 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# https://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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn ( ) {
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die ( ) {
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -77,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -85,76 +140,95 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
Vendored
+89
-90
@@ -1,90 +1,89 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
||||
+13
-2
@@ -83,6 +83,7 @@ dependencies {
|
||||
|
||||
implementation 'de.greenrobot:eventbus:2.4.0'
|
||||
implementation 'com.squareup.picasso:picasso:2.5.2'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.9.0'
|
||||
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
||||
implementation 'com.google.zxing:core:3.3.0'
|
||||
//云信聊天
|
||||
@@ -97,7 +98,10 @@ dependencies {
|
||||
implementation 'jp.wasabeef:picasso-transformations:2.1.0'
|
||||
//Picasso 显示圆形图片
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||
// implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
|
||||
//Glide
|
||||
implementation 'cn.bingoogolapple:bga-refreshlayout:1.1.7@aar'
|
||||
//下拉刷新
|
||||
@@ -149,10 +153,17 @@ dependencies {
|
||||
implementation 'com.umeng.umsdk:share-core:7.3.3'//分享核心库,必选
|
||||
//在线依赖目前支持QQ、微信、新浪微博、支付宝、钉钉、抖音;若需支持其他平台,请选择手动下载SDK
|
||||
implementation 'com.umeng.umsdk:share-wx:7.3.3' //微信完整版
|
||||
implementation 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.24' //微信官方依赖库
|
||||
implementation 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.24'//微信官方依赖库
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
|
||||
//友盟分享
|
||||
// implementation files('libs/umeng_social_sdk.jar')
|
||||
|
||||
implementation 'com.tencent:mmkv:1.3.3'
|
||||
|
||||
implementation("com.github.bumptech.glide:okhttp3-integration:4.11.0" )
|
||||
//
|
||||
// annotationProcessor 'com.github.bumptech.glide:compiler:3.7.0'
|
||||
|
||||
}
|
||||
+299
-359
File diff suppressed because it is too large
Load Diff
@@ -94,6 +94,9 @@ public class BindCameraActivity extends BaseActivity {
|
||||
init();
|
||||
regFilter();
|
||||
// testBindCamera();
|
||||
|
||||
//判断是否是从新页面跳转来的,声波sdk还没初始化成功,不能直接开始调用checkNewBindType连网
|
||||
// checkNewBindType();
|
||||
}
|
||||
|
||||
private void testBindCamera() {
|
||||
@@ -407,4 +410,16 @@ public class BindCameraActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果是从新的界面来的,则直接使用密码开始连接
|
||||
*/
|
||||
public void checkNewBindType(){
|
||||
String pwd = getIntent().getStringExtra("wifiPassword");
|
||||
if (!TextUtils.isEmpty(pwd)){
|
||||
et_wifipsw.setText(pwd);
|
||||
connection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BindDeviceChoiceActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
setContentView(R.layout.activity_device_choice);
|
||||
initTitle("选择设备");
|
||||
initTitle("连接设备");
|
||||
initView();//初始化控件
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,9 @@ public class BindTankActivity extends BaseActivity {
|
||||
initListener();
|
||||
init();
|
||||
// testBindDevice();
|
||||
|
||||
//判断是否是从新页面跳转来的
|
||||
checkNewBindType();
|
||||
}
|
||||
|
||||
private class EsptouchAsyncTask2 extends AsyncTask<String, Void, IEsptouchResult> {
|
||||
@@ -539,7 +542,7 @@ public class BindTankActivity extends BaseActivity {
|
||||
startActivity(i);
|
||||
AnimationUtil.startAnimation(BindTankActivity.this);
|
||||
break;
|
||||
case R.id.tv_thiswifi:
|
||||
case R.id.tv_thiswifi://跳转热点连接
|
||||
Intent intentwifi = new Intent(BindTankActivity.this, HotSpotConnentActivity.class);
|
||||
startActivity(intentwifi);
|
||||
AnimationUtil.startAnimation(BindTankActivity.this);
|
||||
@@ -822,4 +825,16 @@ public class BindTankActivity extends BaseActivity {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 如果是从新的界面来的,则直接使用密码开始连接
|
||||
*/
|
||||
public void checkNewBindType(){
|
||||
String pwd = getIntent().getStringExtra("wifiPassword");
|
||||
if (!TextUtils.isEmpty(pwd)){
|
||||
et_wifipsw.setText(pwd);
|
||||
connection();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,9 @@ public class BindTankPetActivity extends BaseActivity {
|
||||
initListener();
|
||||
init();
|
||||
// testBindDevice();
|
||||
|
||||
//判断是否是从新页面跳转来的
|
||||
checkNewBindType();
|
||||
}
|
||||
|
||||
private class EsptouchAsyncTask2 extends AsyncTask<String, Void, IEsptouchResult> {
|
||||
@@ -850,4 +853,17 @@ public class BindTankPetActivity extends BaseActivity {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 如果是从新的界面来的,则直接使用密码开始连接
|
||||
*/
|
||||
public void checkNewBindType(){
|
||||
String pwd = getIntent().getStringExtra("wifiPassword");
|
||||
if (!TextUtils.isEmpty(pwd)){
|
||||
et_wifipsw.setText(pwd);
|
||||
connection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ifish.activity.newbind.NewBindDeviceActivity;
|
||||
import com.ifish.baseclass.BaseActivity;
|
||||
import com.ifish.utils.AnimationUtil;
|
||||
import com.ifish.utils.Commons;
|
||||
@@ -100,7 +101,7 @@ public class BindTwoDeviceActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
}
|
||||
intent.setClass(BindTwoDeviceActivity.this, BindDeviceChoiceActivity.class);
|
||||
intent.setClass(BindTwoDeviceActivity.this, NewBindDeviceActivity.class);
|
||||
intent.putExtra("devicetype", "camera");
|
||||
intent.putExtra("title", "连接摄像头");
|
||||
startActivity(intent);
|
||||
@@ -130,7 +131,7 @@ public class BindTwoDeviceActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
}
|
||||
intent.setClass(BindTwoDeviceActivity.this, BindDeviceChoiceActivity.class);
|
||||
intent.setClass(BindTwoDeviceActivity.this, NewBindDeviceActivity.class);
|
||||
intent.putExtra("title", "连接水族箱");
|
||||
startActivity(intent);
|
||||
AnimationUtil.startAnimation(BindTwoDeviceActivity.this);
|
||||
@@ -159,7 +160,7 @@ public class BindTwoDeviceActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
}
|
||||
intent.setClass(BindTwoDeviceActivity.this, BindDeviceChoiceActivity.class);
|
||||
intent.setClass(BindTwoDeviceActivity.this, NewBindDeviceActivity.class);
|
||||
intent.putExtra("title", "连接热流器");
|
||||
startActivity(intent);
|
||||
AnimationUtil.startAnimation(BindTwoDeviceActivity.this);
|
||||
@@ -184,7 +185,8 @@ public class BindTwoDeviceActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
}
|
||||
intent.setClass(BindTwoDeviceActivity.this, BindDeviceChoiceActivity.class);
|
||||
// intent.setClass(BindTwoDeviceActivity.this, BindDeviceChoiceActivity.class);
|
||||
intent.setClass(BindTwoDeviceActivity.this, NewBindDeviceActivity.class);
|
||||
intent.putExtra("devicetype", "pet");
|
||||
intent.putExtra("title", "连接宠物系统");
|
||||
startActivity(intent);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package com.ifish.activity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -19,6 +20,7 @@ import android.net.wifi.ScanResult;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -43,6 +45,7 @@ import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.SPUtil;
|
||||
import com.ifish.utils.ToastUtil;
|
||||
import com.ifish.utils.WifiAdmin;
|
||||
import com.ifish.utils.WifiUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -37,6 +37,9 @@ import java.util.List;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* 热点连接
|
||||
*/
|
||||
public class HotSpotConnentActivity extends BaseActivity {
|
||||
private EditText et_wifiname, et_wifipwd;
|
||||
ImageView iv_wifiset;
|
||||
@@ -102,7 +105,14 @@ public class HotSpotConnentActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
if(!is24G && is5G){ //之所以这样处理,是因为现在有的路由器支持2.4+5G双频同时存在
|
||||
// if(!is24G && is5G){ //之所以这样处理,是因为现在有的路由器支持2.4+5G双频同时存在
|
||||
// WifiDialog wd = new WifiDialog(HotSpotConnentActivity.this);
|
||||
// wd.show("仅支持2.4G Wi-Fi网络,请重新选择", "去更改", et_wifiname);
|
||||
// dismissProgressDialog();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(is5G){ //之所以这样处理,是因为现在有的路由器支持2.4+5G双频同时存在,但是它们却是同一个ssid
|
||||
WifiDialog wd = new WifiDialog(HotSpotConnentActivity.this);
|
||||
wd.show("仅支持2.4G Wi-Fi网络,请重新选择", "去更改", et_wifiname);
|
||||
dismissProgressDialog();
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.ifish.utils.Commons;
|
||||
import com.ifish.utils.Commons.LoginSPKey;
|
||||
import com.ifish.utils.Commons.NetWork;
|
||||
import com.ifish.utils.Commons.Text;
|
||||
import com.ifish.utils.GlideApp;
|
||||
import com.ifish.utils.HttpListener;
|
||||
import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.L;
|
||||
@@ -59,7 +60,7 @@ public class HotSpotConnentDeviceActivity extends BaseActivity {
|
||||
connectDevice = new ConnectDevice(20000, 1000);
|
||||
initTitle("尝试与设备建立连接");
|
||||
ImageView iv_wifiset = findMyViewById(R.id.iv_wifiset);
|
||||
Glide.with(this).load(R.drawable.hotconnectgif).asGif().into(iv_wifiset);
|
||||
GlideApp.with(this).load(R.drawable.hotconnectgif).into(iv_wifiset);
|
||||
sp = SPUtil.getInstance(HotSpotConnentDeviceActivity.this);
|
||||
// device_mac="5ccf7f99e929";
|
||||
// doPostBindDevice();
|
||||
@@ -678,6 +679,7 @@ public class HotSpotConnentDeviceActivity extends BaseActivity {
|
||||
break;
|
||||
case NetWork.Fail:
|
||||
ToastUtil.show(HotSpotConnentDeviceActivity.this, "绑定设备失败 请重试");
|
||||
EventBus.getDefault().post(new ConnectMessageEvent(-1, "fail"));
|
||||
finish();
|
||||
break;
|
||||
case NetWork.DEVICETYPEERROR:
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.ifish.utils.Commons;
|
||||
import com.ifish.utils.Commons.LoginSPKey;
|
||||
import com.ifish.utils.Commons.NetWork;
|
||||
import com.ifish.utils.Commons.Text;
|
||||
import com.ifish.utils.GlideApp;
|
||||
import com.ifish.utils.HttpListener;
|
||||
import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.SPUtil;
|
||||
@@ -61,7 +62,7 @@ public class HotSpotConnentDeviceCameraActivity extends BaseActivity {
|
||||
connectDevice = new ConnectDevice(20000, 1000);
|
||||
initTitle("尝试与设备建立连接");
|
||||
ImageView iv_wifiset = findMyViewById(R.id.iv_wifiset);
|
||||
Glide.with(this).load(R.drawable.hotconnectgif).asGif().into(iv_wifiset);
|
||||
GlideApp.with(this).load(R.drawable.hotconnectgif).into(iv_wifiset);
|
||||
sp = SPUtil.getInstance(HotSpotConnentDeviceCameraActivity.this);
|
||||
// device_mac="5ccf7f99e929";
|
||||
// doPostBindDevice();
|
||||
@@ -159,7 +160,10 @@ public class HotSpotConnentDeviceCameraActivity extends BaseActivity {
|
||||
private boolean isContinue = true;
|
||||
private Camera userCamera;
|
||||
|
||||
public class ConnectDevice extends CountDownTimer {
|
||||
public class ConnectDevice extends
|
||||
|
||||
|
||||
CountDownTimer {
|
||||
|
||||
public ConnectDevice(long millisInFuture, long countDownInterval) {
|
||||
super(millisInFuture, countDownInterval);
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.ifish.utils.Commons;
|
||||
import com.ifish.utils.Commons.LoginSPKey;
|
||||
import com.ifish.utils.Commons.NetWork;
|
||||
import com.ifish.utils.Commons.Text;
|
||||
import com.ifish.utils.GlideApp;
|
||||
import com.ifish.utils.HttpListener;
|
||||
import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.L;
|
||||
@@ -61,7 +62,7 @@ public class HotSpotConnentPetDeviceActivity extends BaseActivity {
|
||||
connectDevice = new ConnectDevice(20000, 1000);
|
||||
initTitle("尝试与设备建立连接");
|
||||
ImageView iv_wifiset = findMyViewById(R.id.iv_wifiset);
|
||||
Glide.with(this).load(R.drawable.hotconnectgif).asGif().into(iv_wifiset);
|
||||
GlideApp.with(this).load(R.drawable.hotconnectgif).into(iv_wifiset);
|
||||
sp = SPUtil.getInstance(HotSpotConnentPetDeviceActivity.this);
|
||||
// device_mac="5ccf7f99e929";
|
||||
// doPostBindDevice();
|
||||
|
||||
@@ -40,7 +40,6 @@ public class HotSpotConnentSetWIFIActivity extends BaseActivity {
|
||||
// doPostBindDevice();
|
||||
isjump = true;
|
||||
Intent i = new Intent();
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i = new Intent(Settings.ACTION_WIFI_SETTINGS);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ifish.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -95,10 +96,12 @@ public class MainSixControlActivity extends BaseGradeActivity implements SwipeRe
|
||||
init();
|
||||
initView();
|
||||
initListener();
|
||||
L.i( "---3-------------onCreate"+HttpManager.Store_URL+Commons.DEVICE.get(sp.getInt(Commons.LoginSPKey.Position, 0)).getVenderList().getLogo());
|
||||
try {
|
||||
initTitle(Commons.DEVICE.get(Commons.DevicePosition).getShowName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
ReviewBrand();
|
||||
LoginDevice();
|
||||
@@ -326,8 +329,15 @@ public class MainSixControlActivity extends BaseGradeActivity implements SwipeRe
|
||||
private void ReviewBrand() {
|
||||
try {//展示厂家
|
||||
if (Commons.DEVICE.get(sp.getInt(Commons.LoginSPKey.Position, 0)).getVenderList()!=null) {//厂家为空则展示默认的鱼影
|
||||
Picasso.with(MainSixControlActivity.this).load(HttpManager.Store_URL+Commons.DEVICE.get(sp.getInt(Commons.LoginSPKey.Position, 0)).getVenderList().getLogo()).error(R.drawable.ifish_logo_default).into(iv_left);
|
||||
tv_left.setText(Commons.DEVICE.get(sp.getInt(Commons.LoginSPKey.Position, 0)).getVenderList().getBrandName());
|
||||
Picasso.with(MainSixControlActivity.this)
|
||||
.load(HttpManager.Store_URL+Commons.DEVICE.get(sp.getInt(Commons.LoginSPKey.Position, 0))
|
||||
.getVenderList().getLogo()).error(R.drawable.ifish_logo_default)
|
||||
.placeholder(getDrawable(R.drawable.ifish_logo_default))
|
||||
.into(iv_left);
|
||||
String brandName = Commons.DEVICE.get(sp.getInt(Commons.LoginSPKey.Position, 0)).getVenderList().getBrandName();
|
||||
if (!TextUtils.isEmpty(brandName)){
|
||||
tv_left.setText(brandName);
|
||||
}
|
||||
L.i("厂家Logo="+HttpManager.Store_URL+Commons.DEVICE.get(sp.getInt(Commons.LoginSPKey.Position, 0)).getVenderList().getLogo());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -18,6 +18,8 @@ import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.ifish.basebean.BaseBean;
|
||||
import com.ifish.basebean.FinishMainActivity;
|
||||
import com.ifish.basebean.Version;
|
||||
@@ -41,7 +43,7 @@ import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
import com.ifish.activity.BuildConfig;
|
||||
/**
|
||||
* ---------------------------
|
||||
* 丨你存在 我某一行代码里丨
|
||||
@@ -49,7 +51,7 @@ import de.greenrobot.event.EventBus;
|
||||
* ---------------------------
|
||||
*
|
||||
* @author Jacky dada
|
||||
* @Description: TODO
|
||||
* @Description: 设置页面
|
||||
* @date 2017/4/18 21:46
|
||||
*/
|
||||
public class MySettingActivity extends BaseActivity {
|
||||
@@ -62,6 +64,10 @@ public class MySettingActivity extends BaseActivity {
|
||||
NotificationManager mNotificationManager;
|
||||
private SPUtil sp;
|
||||
|
||||
private TextView tvDebug;
|
||||
private int clickCount = 0;
|
||||
private static final int MAX_CLICKS = 10;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -70,6 +76,39 @@ public class MySettingActivity extends BaseActivity {
|
||||
sp = SPUtil.getInstance(getApplicationContext());
|
||||
initListener();
|
||||
init();
|
||||
initDebug();
|
||||
}
|
||||
|
||||
private void initDebug() {
|
||||
if (BuildConfig.DEBUG){
|
||||
tvDebug = findMyViewById(R.id.tv_debug);
|
||||
tvDebug.setVisibility(View.VISIBLE);
|
||||
tvDebug.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(MySettingActivity.this,PhoneInfoActivity.class));
|
||||
// ToastUtil.show(MySettingActivity.this,"跳转到debug页面");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
TextView title_text = (TextView) findViewById(R.id.title_text);
|
||||
title_text.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
clickCount++;
|
||||
if (clickCount == MAX_CLICKS) {
|
||||
startNewActivity();
|
||||
clickCount = 0; // 重置计数器
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void startNewActivity() {
|
||||
Intent intent = new Intent(this, PhoneInfoActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
@@ -61,7 +61,7 @@ import rx.schedulers.Schedulers;
|
||||
* @description:新的绑定摄像头&鱼缸设备界面
|
||||
*/
|
||||
public class NewBindDeviceChoiceActivity extends BaseActivity implements View.OnClickListener {
|
||||
private int TYPE_ONE_BUTTON_CONNECT = 1;
|
||||
private int TYPE_ONE_BUTTON_CONNECT = 1;//airkiss
|
||||
private int TYPE_QUICK_CONNECT = 2;
|
||||
private int TYPE_APP_CONNECT = 3;
|
||||
private TextView tv_connect_type;
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.ifish.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
|
||||
public class PhoneInfoActivity extends AppCompatActivity {
|
||||
|
||||
private TextView textViewModel;
|
||||
private TextView textViewNetworkInfo;
|
||||
private TextView tvWifiInfo;
|
||||
private static final int REQUEST_WIFI_PERMISSION = 1;
|
||||
private static final int REQUEST_PHONE_PERMISSION = 2;
|
||||
|
||||
private WifiManager wifiManager;
|
||||
private TelephonyManager telephonyManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_phone_info);
|
||||
textViewModel = findViewById(R.id.tvModel);
|
||||
textViewNetworkInfo = findViewById(R.id.tvNetworkInfo);
|
||||
tvWifiInfo = findViewById(R.id.tvWifiInfo);
|
||||
|
||||
wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
// Permission is not granted
|
||||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
REQUEST_WIFI_PERMISSION);
|
||||
} else {
|
||||
// Permission has already been granted
|
||||
getPhoneInfo();
|
||||
}
|
||||
|
||||
findViewById(R.id.test_airkiss).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String appId = "wxb3b27d653ec3e3cb"; // 厂商填移动应用(App)的 AppId
|
||||
IWXAPI api = WXAPIFactory.createWXAPI(PhoneInfoActivity.this, appId);
|
||||
WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
|
||||
req.userName = "gh_471f5f7b25a9";// 注意这是微信硬件的username,不需要改动
|
||||
req.path = "pages/discover-new/discover-new?ticket=234234";
|
||||
//以绑定为例,路径示例:"pages/discover-new/discover-new?ticket=234234",内部字符串不需要引号
|
||||
|
||||
req.miniprogramType = WXLaunchMiniProgram.Req.MINIPROGRAM_TYPE_PREVIEW;//注意这里可选不同版本TEST(测试版)/PREVIEW(体验版)/RELEASE(线上版),正常测试时使用体验版,正式上线时需切换至线上正式版
|
||||
api.sendReq(req);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getPhoneInfo() {
|
||||
// 获取设备型号
|
||||
String model = Build.MODEL;
|
||||
textViewModel.setText("设备型号: " + model + "\n");
|
||||
// 获取移动网络信息(可选)
|
||||
if (telephonyManager != null) {
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
|
||||
// Permission is not granted
|
||||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{android.Manifest.permission.READ_PHONE_STATE},
|
||||
REQUEST_PHONE_PERMISSION);
|
||||
return;
|
||||
}
|
||||
int networkType = telephonyManager.getNetworkType();
|
||||
String networkTypeName = getNetworkTypeName(networkType);
|
||||
textViewModel.append(networkTypeName + "\n");
|
||||
}
|
||||
|
||||
// 检查网络连接状态
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
boolean isConnected = activeNetwork != null && activeNetwork.isConnected();
|
||||
// 显示网络情况
|
||||
String networkInfo = isConnected ? "已连接到网络" : "未连接到网络";
|
||||
textViewNetworkInfo.setText("网络信息:\n" + "网络情况: " + networkInfo);
|
||||
// 如果需要,你还可以检查具体的网络类型(如Wi-Fi、移动数据等)
|
||||
if (isConnected) {
|
||||
NetworkInfo.State state = activeNetwork.getState();
|
||||
if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
|
||||
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
|
||||
networkInfo = "连接到Wi-Fi网络";
|
||||
} else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
|
||||
networkInfo = "连接到移动网络";
|
||||
}
|
||||
}
|
||||
}
|
||||
textViewNetworkInfo.setText("网络情况: " + networkInfo);
|
||||
|
||||
// 获取WiFi信息
|
||||
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo info = wifiManager.getConnectionInfo();
|
||||
String ssid = info.getSSID();
|
||||
int frequency = info.getFrequency();
|
||||
|
||||
tvWifiInfo.append("SSID: " + ssid + "\n");
|
||||
|
||||
// 判断WiFi频段(2.4G或5G)
|
||||
if (frequency >= 2400 && frequency <= 2500) {
|
||||
tvWifiInfo.append("WiFi Band: 2.4GHz\n");
|
||||
} else if (frequency >= 4800 && frequency <= 6000) {
|
||||
tvWifiInfo.append("WiFi Band: 5GHz\n");
|
||||
} else {
|
||||
tvWifiInfo.append("WiFi Band: Unknown\n");
|
||||
}
|
||||
}
|
||||
|
||||
public String getNetworkTypeName(int networkType) {
|
||||
String typeName;
|
||||
String description;
|
||||
|
||||
switch (networkType) {
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
typeName = "GPRS";
|
||||
description = "GPRS 是一种基于 GSM 的无线分组交换技术,提供了比传统 GSM 电路交换数据服务更快的数据传输速度。它是 2G 和 2.5G 移动通信技术的一部分。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
typeName = "EDGE";
|
||||
description = "EDGE 是 GPRS 的一个增强版本,提供了更高的数据传输速率,被认为是 2.75G 技术。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
typeName = "UMTS";
|
||||
description = "UMTS 是一种 3G 移动通信技术,包括多种标准,如 WCDMA,提供了更高的数据传输速率和更先进的多媒体服务。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
||||
typeName = "HSDPA";
|
||||
description = "HSDPA 是 UMTS 家族中的一个增强技术,专注于提供更高的下行链路数据传输速率。它是 3.5G 技术的一部分。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
||||
typeName = "HSUPA";
|
||||
description = "HSUPA 类似于 HSDPA,但专注于提供更高的上行链路数据传输速率。它也是 3.5G 技术的一部分。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_HSPA:
|
||||
typeName = "HSPA";
|
||||
description = "HSPA 通常是指结合了 HSDPA 和 HSUPA 的技术,提供了同时增强的上行和下行数据传输速率。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_LTE:
|
||||
typeName = "LTE";
|
||||
description = "LTE 是一种 4G 无线通信标准,旨在提供比 3G 技术更快的数据传输速率、更低的延迟和更高的系统容量。";
|
||||
break;
|
||||
|
||||
// 添加其他网络类型的 case 语句...
|
||||
|
||||
default:
|
||||
typeName = "未知";
|
||||
description = "无法识别的网络类型。";
|
||||
break;
|
||||
}
|
||||
|
||||
return "手机网络类型:" + typeName + " || " + description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_WIFI_PERMISSION) {
|
||||
if (grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// Permission has been granted, update the UI
|
||||
getPhoneInfo();
|
||||
} else {
|
||||
// Permission denied, Disable the functionality that depends on this permission.
|
||||
Toast.makeText(this, "Permission Denied", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.ifish.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.ifish.baseclass.BaseActivity;
|
||||
@@ -36,128 +40,129 @@ public class ShowDeviceImageActivity extends BaseActivity {
|
||||
if(device_type != 0){
|
||||
switch (device_type){
|
||||
case R.id.iv_no_connect:
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.no_connect_image).listener(new RequestListener<Integer, GlideDrawable>() {
|
||||
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.no_connect_image).listener(new RequestListener< Drawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
ToastUtil.show(getApplicationContext(),"加载失败,请稍后再试");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
}).into(iv_show);
|
||||
break;
|
||||
case R.id.iv_camera:
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.camera_image).listener(new RequestListener<Integer, GlideDrawable>() {
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.camera_image).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
ToastUtil.show(getApplicationContext(),"加载失败,请稍后再试");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
}).into(iv_show);
|
||||
break;
|
||||
case R.id.iv_move_camera:
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.move_camera_image).listener(new RequestListener<Integer, GlideDrawable>() {
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.move_camera_image).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
ToastUtil.show(getApplicationContext(),"加载失败,请稍后再试");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
}).into(iv_show);
|
||||
break;
|
||||
case R.id.iv_sw7:
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.sw7_image).listener(new RequestListener<Integer, GlideDrawable>() {
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.sw7_image).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
ToastUtil.show(getApplicationContext(),"加载失败,请稍后再试");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
}).into(iv_show);
|
||||
break;
|
||||
case R.id.iv_sw10:
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.sw10_image).listener(new RequestListener<Integer, GlideDrawable>() {
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.sw10_image).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
ToastUtil.show(getApplicationContext(),"加载失败,请稍后再试");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
}).into(iv_show);
|
||||
break;
|
||||
case R.id.iv_cw2:
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.cw2_image).listener(new RequestListener<Integer, GlideDrawable>() {
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.cw2_image).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
ToastUtil.show(getApplicationContext(),"加载失败,请稍后再试");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
}).into(iv_show);
|
||||
break;
|
||||
case R.id.iv_sw1sw6:
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.sw1_image).listener(new RequestListener<Integer, GlideDrawable>() {
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.sw1_image).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
ToastUtil.show(getApplicationContext(),"加载失败,请稍后再试");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
}).into(iv_show);
|
||||
break;
|
||||
case R.id.iv_wy01:
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.wy01_image).listener(new RequestListener<Integer, GlideDrawable>() {
|
||||
Glide.with(ShowDeviceImageActivity.this).load(R.drawable.wy01_image).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Drawable> target, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
ToastUtil.show(getApplicationContext(),"加载失败,请稍后再试");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||
public boolean onResourceReady(Drawable drawable, Object o, Target<Drawable> target, DataSource dataSource, boolean b) {
|
||||
progressDialog.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,861 @@
|
||||
package com.ifish.activity.newbind;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.ifish.activity.BindTankPetActivity;
|
||||
import com.ifish.activity.BlackListActivity;
|
||||
import com.ifish.activity.LoadingActivity;
|
||||
import com.ifish.activity.MainEightControlActivity;
|
||||
import com.ifish.activity.MainFiveBDControlActivity;
|
||||
import com.ifish.activity.MainFiveControlActivity;
|
||||
import com.ifish.activity.MainFourControlActivity;
|
||||
import com.ifish.activity.MainFour_2B_ControlActivity;
|
||||
import com.ifish.activity.MainFour_3F_ControlActivity;
|
||||
import com.ifish.activity.MainHot_3A_ControlActivity;
|
||||
import com.ifish.activity.MainSeven_2F_ControlActivity;
|
||||
import com.ifish.activity.MainSixControlActivity;
|
||||
import com.ifish.activity.MainSix_2A_ControlActivity;
|
||||
import com.ifish.activity.MainSix_4F_ControlActivity;
|
||||
import com.ifish.activity.MainThree1CControlActivity;
|
||||
import com.ifish.activity.MainThreeControlActivity;
|
||||
import com.ifish.activity.MainTwoControlActivity;
|
||||
import com.ifish.activity.MainZeroControlActivity;
|
||||
import com.ifish.airkiss.AirKissEncoder;
|
||||
import com.ifish.airkiss.UDPReceiver;
|
||||
import com.ifish.basebean.BaseBean;
|
||||
import com.ifish.basebean.Device;
|
||||
import com.ifish.baseclass.BaseGradeActivity;
|
||||
import com.ifish.esptouch.ByteUtil;
|
||||
import com.ifish.esptouch.EsptouchTask;
|
||||
import com.ifish.esptouch.IEsptouchResult;
|
||||
import com.ifish.esptouch.IEsptouchTask;
|
||||
import com.ifish.utils.AnimationUtil;
|
||||
import com.ifish.utils.Commons;
|
||||
import com.ifish.utils.HttpListener;
|
||||
import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.L;
|
||||
import com.ifish.utils.SPUtil;
|
||||
import com.ifish.utils.ToastUtil;
|
||||
import com.ifish.utils.WifiUtil;
|
||||
import com.ifish.view.PetPopupChoice;
|
||||
import com.lidroid.xutils.util.LogUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import rx.Observable;
|
||||
import rx.Observer;
|
||||
import rx.Subscriber;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @ClassName: AirKissUtil
|
||||
* @Description: 作用描述
|
||||
* @Author: LiHongda
|
||||
* @CreateDate: 2024/2/23 4:36
|
||||
*/
|
||||
public class AirKissUtil {
|
||||
|
||||
private Subscription sendSubscribe;
|
||||
private Subscription receiveSubscribe;
|
||||
private String device_mac;
|
||||
private WifiUtil wifiUtil;
|
||||
private Device deviceObj;
|
||||
private HttpManager hm = HttpManager.getInstance();
|
||||
private boolean deviceIsNull = false;///当服务器返回的设备控制器数和定时器数为null的时候 改变标记的值 不跳转进入主界面
|
||||
private int deviceIsNullNum = 0;//循环请求次数
|
||||
private CountDownTimer deviceIsNullTimer;
|
||||
private SPUtil sp;
|
||||
private AppCompatActivity curActivity;
|
||||
private String bssid = "";
|
||||
private String isSsidHiddenStr = "YES";
|
||||
|
||||
//当前需要连接的是什么设备
|
||||
private String devicetype;
|
||||
|
||||
private UDPReceiver udpReceiver = null;
|
||||
private DatagramSocket sendSocket = null;
|
||||
ProgressDialog mDialog = null;
|
||||
|
||||
private static final int REPLY_BYTE_CONFIRM_TIMES = 3;
|
||||
|
||||
public void init(AppCompatActivity activity, String devicetype) {
|
||||
wifiUtil = new WifiUtil(activity);
|
||||
sp = SPUtil.getInstance(activity);
|
||||
curActivity = activity;
|
||||
mDialog = new ProgressDialog(activity);
|
||||
this.devicetype = devicetype;
|
||||
if (sendSocket != null) {
|
||||
sendSocket.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void connectDeviceByAirKiss(AppCompatActivity activity, String ssid, String bssid, String password) {
|
||||
if (sendSubscribe != null && sendSubscribe.isUnsubscribed()) {
|
||||
sendSubscribe.unsubscribe();
|
||||
}
|
||||
if (receiveSubscribe != null && receiveSubscribe.isUnsubscribed()) {
|
||||
receiveSubscribe.unsubscribe();
|
||||
}
|
||||
AirKissEncoder airKissEncoder = new AirKissEncoder(ssid, password);
|
||||
// smartLinkExportObject.connectWithSSID(ssid, password, handler);
|
||||
|
||||
//注册udp接收器
|
||||
// udpReceiver = new UDPReceiver(wifiUtil, new UdpCallback() {
|
||||
// @Override
|
||||
// public void onReceive(String data) {
|
||||
// Log.e("LHD test9999999990", "收到的udp包 数据:" + data);
|
||||
// curActivity.runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (mDialog != null) {
|
||||
// mDialog.dismiss();
|
||||
// }
|
||||
// ToastUtil.show(curActivity, "接收到设备包:" + data);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(String error) {
|
||||
// if (mDialog != null) {
|
||||
// mDialog.dismiss();
|
||||
// }
|
||||
// LogUtils.d("LHD 设备绑定失败:" + error);
|
||||
// ToastUtil.showLong(curActivity, "设备绑定失败:" + error);
|
||||
// }
|
||||
// });
|
||||
// udpReceiver.start();
|
||||
|
||||
// 发送AirKiss
|
||||
sendSubscribe = Observable.create(new Observable.OnSubscribe<String>() {
|
||||
@Override
|
||||
public void call(Subscriber<? super String> subscriber) {
|
||||
subscriber.onNext("start");
|
||||
byte[] DUMMY_DATA = new byte[1500];
|
||||
DatagramSocket sendSocket = null;
|
||||
try {
|
||||
sendSocket = new DatagramSocket();
|
||||
sendSocket.setBroadcast(true);
|
||||
int[] encoded_data = airKissEncoder.getEncodedData();
|
||||
for (int encoded_datum : encoded_data) {
|
||||
DatagramPacket pkg = new DatagramPacket(DUMMY_DATA,
|
||||
encoded_datum,
|
||||
InetAddress.getByName("255.255.255.255"),
|
||||
10000);
|
||||
sendSocket.send(pkg);
|
||||
Thread.sleep(4);
|
||||
}
|
||||
|
||||
subscriber.onCompleted();
|
||||
} catch (Exception e) {
|
||||
subscriber.onError(e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
sendSocket.close();
|
||||
sendSocket.disconnect();
|
||||
}
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<String>() {
|
||||
@Override
|
||||
public void onCompleted() {
|
||||
// ToastUtil.show(activity, "连接信号发送完成");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
LogUtils.d("LHD onError e "+e.getLocalizedMessage());
|
||||
ToastUtil.show(activity, "连接失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
LogUtils.d("LHD send onNext =" + string);
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
mDialog.setTitle("配网中");
|
||||
mDialog.setMessage("发送配网信息...");
|
||||
mDialog.setCancelable(false);
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//发送配网ssid pwd,因为字节发送需要时间比较久,此处只是设置比较短的提示,但实际上后台线程还在发送中。
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
mDialog.setTitle("连接设备");
|
||||
mDialog.setMessage("正在接受设备信息,请耐心等待...");
|
||||
mDialog.setCancelable(false);
|
||||
mDialog.show();
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//接收udp包
|
||||
receiveSubscribe = Observable.create(new Observable.OnSubscribe<String>() {
|
||||
@Override
|
||||
public void call(Subscriber<? super String> subscriber) {
|
||||
receivePackage(airKissEncoder, subscriber);
|
||||
}
|
||||
}).subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Subscriber<String>() {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
mDialog.setMessage("正在连接...");
|
||||
mDialog.setCancelable(false);
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted() {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Toast.makeText(curActivity, "连接失败: " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
mDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if ("success".equals(s)) {
|
||||
// Toast.makeText(curActivity, "配网成功:", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void receivePackage(AirKissEncoder airKissEncoder, Subscriber subscriber) {
|
||||
byte[] buffer = new byte[7];
|
||||
DatagramSocket udpServerSocket = null;
|
||||
char mRandomChar = airKissEncoder.getRandomChar();//获取UDP数据包中的随机字符
|
||||
|
||||
// 将char类型的变量拆分为两个字节,并输出它们的值
|
||||
byte highByte = (byte) (mRandomChar >> 8); // 获取高字节
|
||||
byte lowByte = (byte) mRandomChar; // 获取低字节
|
||||
|
||||
LogUtils.d("LHD 发送的随机数 = "+mRandomChar+"高字节:" + highByte+ "低字节:" + lowByte);
|
||||
|
||||
try {
|
||||
int replyByteCounter = 0;
|
||||
udpServerSocket = new DatagramSocket(10000);
|
||||
udpServerSocket.setSoTimeout(1000 * 60);//设置超时时间
|
||||
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
|
||||
while (true) {
|
||||
udpServerSocket.receive(packet);
|
||||
|
||||
if (!packet.getAddress().getHostAddress().equals(WifiUtil.intToIp(wifiUtil.getConnectIpAddress()))) {
|
||||
byte[] receivedData = packet.getData();
|
||||
Log.d("LHD","收到消息:"+ Arrays.toString(receivedData));
|
||||
for (byte b : receivedData) {
|
||||
LogUtils.d("LHD dfaf = "+(char) b); // 将低字节转换为char类型);
|
||||
if (b == mRandomChar){
|
||||
replyByteCounter++;
|
||||
}
|
||||
LogUtils.d("LHD 比较 replyByteCounter = "+replyByteCounter);
|
||||
}
|
||||
Log.d("LHD","收到消息:"+ Arrays.toString(receivedData));
|
||||
if (replyByteCounter > REPLY_BYTE_CONFIRM_TIMES) {
|
||||
subscriber.onNext("success");
|
||||
String mac = ByteUtil.parseBssid(
|
||||
receivedData,
|
||||
1,
|
||||
6);
|
||||
device_mac = mac;
|
||||
LogUtils.d("LHD 获取到的mac地址 = " + mac+" 当前设备类型 devicetype = "+devicetype);
|
||||
if (!TextUtils.isEmpty(device_mac)) {
|
||||
stopAirKiss();
|
||||
//todo 区分是否是宠物笼和摄像头
|
||||
if (TextUtils.isEmpty(devicetype)){
|
||||
doPostBindDevice();
|
||||
} else if ("pet".equals(devicetype)){
|
||||
doPostBindPetDevice();
|
||||
}else {
|
||||
doPostBindDevice();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
subscriber.onCompleted();
|
||||
} catch (SocketException e) {
|
||||
subscriber.onError(e);
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
subscriber.onError(e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
udpServerSocket.close();
|
||||
udpServerSocket.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param
|
||||
* @Description: 给设备发送入网指令
|
||||
* @author Jacky dada
|
||||
* @date 2015-9-21 下午3:05:01
|
||||
*/
|
||||
private void doPostBindDevice() {
|
||||
try {
|
||||
hm.bindDevice(new HttpListener<BaseBean<Device>>() {
|
||||
private int result;
|
||||
|
||||
@Override
|
||||
public void success(BaseBean<Device> baseBean) {
|
||||
result = baseBean.result;
|
||||
stopAirKiss();
|
||||
if (result == Commons.NetWork.Success) {
|
||||
deviceObj = baseBean.data;
|
||||
deviceObj.setMacAddress(device_mac);
|
||||
/**
|
||||
//当服务器返回的设备控制器数和定时器数为null的时候 不跳转进入主界面
|
||||
*/
|
||||
if (deviceObj.getControlAmount() == null || deviceObj.getTimerAmount() == null) {
|
||||
L.i("第一次获取空");
|
||||
deviceIsNull = true;
|
||||
deviceIsNullNum = 0;
|
||||
startDeviceIsNullTimer();//启动倒计时
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
doPostBindDeviceHandler.sendEmptyMessage(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Exception e, String msg) {
|
||||
result = Commons.NetWork.ERROR;
|
||||
}
|
||||
}, Commons.USER.getUserId(), device_mac);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void doPostBindPetDevice(){
|
||||
hm.queryStoreName(new HttpListener<BaseBean<List<String>>>() {
|
||||
@Override
|
||||
public void success(final BaseBean<List<String>> baseBean) {
|
||||
curActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new PetPopupChoice(curActivity, new PetPopupChoice.OnChoiceListener() {
|
||||
@Override
|
||||
public void onChoice(String s) {
|
||||
doPostBindPetDevice(s);
|
||||
}
|
||||
}, baseBean.data).showDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Exception e, String msg) {
|
||||
ToastUtil.show(curActivity, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
|
||||
}
|
||||
}, Commons.USER.getUserId());
|
||||
}
|
||||
/**
|
||||
* @param
|
||||
* @Description: 给宠物设备发送入网指令
|
||||
* @author Jacky dada
|
||||
* @date 2015-9-21 下午3:05:01
|
||||
*/
|
||||
private void doPostBindPetDevice(String storeName) {
|
||||
try {
|
||||
hm.bindPetDevice(new HttpListener<BaseBean<Device>>() {
|
||||
private int result;
|
||||
|
||||
@Override
|
||||
public void success(BaseBean<Device> baseBean) {
|
||||
result = baseBean.result;
|
||||
if (result == Commons.NetWork.Success) {
|
||||
deviceObj = baseBean.data;
|
||||
deviceObj.setMacAddress(device_mac);
|
||||
/**
|
||||
//当服务器返回的设备控制器数和定时器数为null的时候 不跳转进入主界面
|
||||
*/
|
||||
if (deviceObj.getControlAmount() == null || deviceObj.getTimerAmount() == null) {
|
||||
deviceIsNull = true;
|
||||
deviceIsNullNum = 0;
|
||||
startDeviceIsNullTimer();//启动倒计时
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
doPostBindDeviceHandler.sendEmptyMessage(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Exception e, String msg) {
|
||||
result = Commons.NetWork.ERROR;
|
||||
}
|
||||
}, Commons.USER.getUserId(), device_mac, storeName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAirKiss() {
|
||||
if (sendSocket != null) {
|
||||
sendSocket.close();
|
||||
sendSocket.disconnect();
|
||||
}
|
||||
if (udpReceiver != null) {
|
||||
udpReceiver.stopRunning();
|
||||
}
|
||||
}
|
||||
|
||||
public void unSubscribe() {
|
||||
stopAirKiss();
|
||||
if (sendSubscribe != null && sendSubscribe.isUnsubscribed()) {
|
||||
sendSubscribe.unsubscribe();
|
||||
}
|
||||
if (receiveSubscribe != null && receiveSubscribe.isUnsubscribed()) {
|
||||
receiveSubscribe.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void startDeviceIsNullTimer() {
|
||||
if (deviceIsNullTimer == null) {
|
||||
deviceIsNullTimer = new CountDownTimer(2000, 1000) {
|
||||
@Override
|
||||
public void onTick(long arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
L.i("重新请求");
|
||||
//拿到设备id 去服务器查询 看看是否为空
|
||||
try {
|
||||
hm.getSingleDeviceInf(new HttpListener<BaseBean<Device>>() {
|
||||
private int result;
|
||||
|
||||
@Override
|
||||
public void success(BaseBean<Device> baseBean) {
|
||||
result = baseBean.result;
|
||||
deviceObj = baseBean.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
deviceIsNullHandler.sendEmptyMessage(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Exception e, String msg) {
|
||||
result = Commons.NetWork.ERROR;
|
||||
}
|
||||
}, deviceObj.getDeviceId(), Commons.USER.getUserId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
deviceIsNullTimer.start();
|
||||
}
|
||||
|
||||
Handler deviceIsNullHandler = new Handler() {
|
||||
|
||||
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
L.i("请求结束");
|
||||
switch (msg.what) {
|
||||
case Commons.NetWork.Success:
|
||||
if (deviceObj.getControlAmount() == null || deviceObj.getTimerAmount() == null) {
|
||||
deviceIsNullNum = deviceIsNullNum + 1;
|
||||
if (deviceIsNullNum < 3) {
|
||||
startDeviceIsNullTimer();
|
||||
} else {
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity, "绑定设备失败 请重试");
|
||||
}
|
||||
return;
|
||||
}
|
||||
boolean isSameName = false;
|
||||
try {
|
||||
if (Commons.DEVICE != null) {
|
||||
if (Commons.DEVICE.size() != 0) {
|
||||
for (int i = 0; i < Commons.DEVICE.size(); i++) {
|
||||
if (device_mac.equals(Commons.DEVICE.get(i).getMacAddress())) {
|
||||
sp.putInt(Commons.LoginSPKey.Position, i);
|
||||
Commons.DevicePosition = i;
|
||||
isSameName = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (!isSameName) {
|
||||
Commons.DEVICE.add(deviceObj);
|
||||
try {
|
||||
sp.putInt(Commons.LoginSPKey.Position, Commons.DEVICE.size() - 1);
|
||||
Commons.DevicePosition = Commons.DEVICE.size() - 1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
Commons.IS_EventBus = true;
|
||||
Commons.HAVE_DEVICE = true;//改变判断是否绑定的变量
|
||||
Commons.IS_CAMERA = false;
|
||||
sp.putBoolean(Commons.LoginSPKey.IS_CAMERA, Commons.IS_CAMERA);
|
||||
Intent i = new Intent();
|
||||
try {
|
||||
Integer controlAmount = Commons.DEVICE.get(Commons.DevicePosition).getControlAmount();
|
||||
Integer timerAmount = Commons.DEVICE.get(Commons.DevicePosition).getTimerAmount();
|
||||
String type = Commons.DEVICE.get(Commons.DevicePosition).type;
|
||||
if (Commons.FishKey.On.equals(Commons.DEVICE.get(Commons.DevicePosition).isBlacklist)) {//黑名单
|
||||
i.setClass(curActivity, BlackListActivity.class);
|
||||
} else {
|
||||
if (Device.TYPE_1C.equals(type)) {
|
||||
i.setClass(curActivity, MainThree1CControlActivity.class);
|
||||
} else if (Device.TYPE_AA.equals(type)) {
|
||||
i.setClass(curActivity, MainFiveControlActivity.class);
|
||||
} else if (Device.TYPE_BD.equals(type)) {
|
||||
i.setClass(curActivity, MainFiveBDControlActivity.class);
|
||||
} else if (Device.TYPE_2A.equals(type)) {
|
||||
i.setClass(curActivity, MainSix_2A_ControlActivity.class);
|
||||
} else if (Device.TYPE_2B.equals(type)) {
|
||||
i.setClass(curActivity, MainFour_2B_ControlActivity.class);
|
||||
} else if (Device.TYPE_3A.equals(type)) {
|
||||
i.setClass(curActivity, MainHot_3A_ControlActivity.class);
|
||||
} else if (Device.TYPE_2F.equals(type)) {
|
||||
i.setClass(curActivity, MainSeven_2F_ControlActivity.class);
|
||||
} else if (Device.TYPE_3F.equals(type)) {
|
||||
i.setClass(curActivity, MainFour_3F_ControlActivity.class);
|
||||
} else if (Device.TYPE_4F.equals(type) || Device.TYPE_5F.equals(type)) {
|
||||
i.setClass(curActivity, MainSix_4F_ControlActivity.class);
|
||||
} else {
|
||||
if (controlAmount == null) {//如果控制器返回空 则默认给三控的页面
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
} else {
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
switch (controlAmount) {
|
||||
case 0: {
|
||||
i.setClass(curActivity, MainZeroControlActivity.class);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
i.setClass(curActivity, MainTwoControlActivity.class);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if (timerAmount == 6) { // 可丽爱
|
||||
i.setClass(curActivity, MainFiveControlActivity.class);
|
||||
} else {//4控
|
||||
i.setClass(curActivity, MainFourControlActivity.class);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (6 == timerAmount) {//5控六定时器 询多页面
|
||||
i.setClass(curActivity, MainSixControlActivity.class);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
i.setClass(curActivity, MainEightControlActivity.class);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
}
|
||||
i.putExtra(BaseGradeActivity.BINDDEVICE, true);//绑定成功增加经验
|
||||
ToastUtil.show(curActivity, "绑定设备成功");
|
||||
curActivity.startActivity(i);
|
||||
AnimationUtil.startAnimation(curActivity);
|
||||
curActivity.finish();
|
||||
L.i("===================绑定设备成功=" + device_mac);
|
||||
break;
|
||||
case Commons.NetWork.ERROR:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity, Commons.Text.ERROR);
|
||||
break;
|
||||
case Commons.NetWork.Fail:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity, Commons.Text.Repat);
|
||||
break;
|
||||
default:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity, Commons.Text.ServerException);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void resetWifiContentView() {
|
||||
ToastUtil.show(curActivity, "重置联网view");
|
||||
}
|
||||
|
||||
Handler doPostBindDeviceHandler = new Handler() {
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
|
||||
switch (msg.what) {
|
||||
/**
|
||||
* 1:绑定成功
|
||||
0:绑定失败
|
||||
-4:请求验证失败,请重新登陆
|
||||
-5:请求被舍弃,未执行
|
||||
*/
|
||||
case Commons.NetWork.Success:
|
||||
if (deviceIsNull) {//当服务器返回的设备控制器数和定时器数为null的时候 不跳转进入主界面
|
||||
return;
|
||||
}
|
||||
boolean isSameName = false;
|
||||
try {
|
||||
if (Commons.DEVICE != null) {
|
||||
if (Commons.DEVICE.size() != 0) {
|
||||
for (int i = 0; i < Commons.DEVICE.size(); i++) {
|
||||
if (device_mac.equals(Commons.DEVICE.get(i).getMacAddress())) {
|
||||
sp.putInt(Commons.LoginSPKey.Position, i);
|
||||
Commons.DevicePosition = i;
|
||||
isSameName = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (!isSameName) {
|
||||
Commons.DEVICE.add(deviceObj);
|
||||
try {
|
||||
sp.putInt(Commons.LoginSPKey.Position, Commons.DEVICE.size() - 1);
|
||||
Commons.DevicePosition = Commons.DEVICE.size() - 1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
Commons.IS_EventBus = true;
|
||||
Commons.HAVE_DEVICE = true;//改变判断是否绑定的变量
|
||||
Commons.IS_CAMERA = false;
|
||||
sp.putBoolean(Commons.LoginSPKey.IS_CAMERA, Commons.IS_CAMERA);
|
||||
Intent i = new Intent();
|
||||
try {
|
||||
Integer controlAmount = Commons.DEVICE.get(Commons.DevicePosition).getControlAmount();
|
||||
Integer timerAmount = Commons.DEVICE.get(Commons.DevicePosition).getTimerAmount();
|
||||
String type = Commons.DEVICE.get(Commons.DevicePosition).type;
|
||||
if (Commons.FishKey.On.equals(Commons.DEVICE.get(Commons.DevicePosition).isBlacklist)) {//黑名单
|
||||
i.setClass(curActivity, BlackListActivity.class);
|
||||
} else {
|
||||
if (Device.TYPE_1C.equals(type)) {
|
||||
i.setClass(curActivity, MainThree1CControlActivity.class);
|
||||
} else if (Device.TYPE_AA.equals(type)) {
|
||||
i.setClass(curActivity, MainFiveControlActivity.class);
|
||||
} else if (Device.TYPE_BD.equals(type)) {
|
||||
i.setClass(curActivity, MainFiveBDControlActivity.class);
|
||||
} else if (Device.TYPE_2A.equals(type)) {
|
||||
i.setClass(curActivity, MainSix_2A_ControlActivity.class);
|
||||
} else if (Device.TYPE_2B.equals(type)) {
|
||||
i.setClass(curActivity, MainFour_2B_ControlActivity.class);
|
||||
} else if (Device.TYPE_3A.equals(type)) {
|
||||
i.setClass(curActivity, MainHot_3A_ControlActivity.class);
|
||||
} else if (Device.TYPE_2F.equals(type)) {
|
||||
i.setClass(curActivity, MainSeven_2F_ControlActivity.class);
|
||||
} else if (Device.TYPE_3F.equals(type)) {
|
||||
i.setClass(curActivity, MainFour_3F_ControlActivity.class);
|
||||
} else if (Device.TYPE_4F.equals(type) || Device.TYPE_5F.equals(type)) {
|
||||
i.setClass(curActivity, MainSix_4F_ControlActivity.class);
|
||||
} else {
|
||||
if (controlAmount == null) {//如果控制器返回空 则默认给三控的页面
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
} else {
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
switch (controlAmount) {
|
||||
case 0: {
|
||||
i.setClass(curActivity, MainZeroControlActivity.class);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
i.setClass(curActivity, MainTwoControlActivity.class);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if (timerAmount == 6) { // 可丽爱
|
||||
i.setClass(curActivity, MainFiveControlActivity.class);
|
||||
} else {//4控
|
||||
i.setClass(curActivity, MainFourControlActivity.class);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (6 == timerAmount) {//5控六定时器 询多页面
|
||||
i.setClass(curActivity, MainSixControlActivity.class);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
i.setClass(curActivity, MainEightControlActivity.class);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
i.setClass(curActivity, MainThreeControlActivity.class);
|
||||
}
|
||||
i.putExtra(BaseGradeActivity.BINDDEVICE, true);//绑定成功增加经验
|
||||
ToastUtil.show(curActivity, "绑定设备成功");
|
||||
curActivity.startActivity(i);
|
||||
AnimationUtil.startAnimation(curActivity);
|
||||
curActivity.finish();
|
||||
L.i("===================绑定设备成功=" + device_mac);
|
||||
break;
|
||||
case Commons.NetWork.Fail:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity, "绑定设备失败 请重试");
|
||||
// ToastUtil.show(BindTankPetActivity.this, HttpManager.petdevice);
|
||||
break;
|
||||
case Commons.NetWork.DEVICETYPEERROR:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity, "设备类型不匹配,请重新选择入口绑定");
|
||||
break;
|
||||
case Commons.NetWork.ReLogin:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity.getApplicationContext(), "请求验证失败 请重新登陆");
|
||||
Commons.clean();
|
||||
curActivity.startActivity(new Intent(curActivity, LoadingActivity.class));
|
||||
curActivity.finish();
|
||||
break;
|
||||
case Commons.NetWork.ERROR:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity.getApplicationContext(), Commons.Text.ERROR);
|
||||
break;
|
||||
case Commons.NetWork.NotImplemented:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity.getApplicationContext(), Commons.Text.Unknown);
|
||||
break;
|
||||
default:
|
||||
resetWifiContentView();
|
||||
ToastUtil.show(curActivity.getApplicationContext(), Commons.Text.ServerException);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private IEsptouchTask mEsptouchTask;
|
||||
private CountDownTimer wifiTimer;
|
||||
private boolean isTimeout = true;
|
||||
|
||||
public void stopTimer() {
|
||||
if (wifiTimer != null) {
|
||||
wifiTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private class EsptouchAsyncTask2 extends AsyncTask<String, Void, IEsptouchResult> {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IEsptouchResult doInBackground(String... params) {
|
||||
String apSsid = params[0];
|
||||
String apBssid = params[1];
|
||||
String apPassword = params[2];
|
||||
String isSsidHiddenStr = params[3];
|
||||
|
||||
L.i(apSsid + apBssid + apPassword + isSsidHiddenStr);
|
||||
mEsptouchTask = new EsptouchTask(apSsid, apBssid, apPassword, curActivity);
|
||||
IEsptouchResult result = mEsptouchTask.executeForResult();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(IEsptouchResult result) {
|
||||
stopTimer();
|
||||
if (isTimeout) {
|
||||
try {
|
||||
if (!result.isCancelled()) {
|
||||
if (result.isSuc()) {
|
||||
device_mac = "";
|
||||
device_mac = result.getBssid();
|
||||
|
||||
L.i("LHD 绑定的Mac地址" + device_mac);
|
||||
// doPostBindDevice();
|
||||
} else {
|
||||
ToastUtil.show(curActivity, "绑定设备失败 请重试");
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(curActivity, "绑定设备失败 请重试");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(curActivity, "绑定设备失败 请重试");
|
||||
}
|
||||
} else {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.ifish.activity.newbind;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.ifish.activity.R;
|
||||
|
||||
/**
|
||||
* @ClassName: BottomChoiceDialog
|
||||
* @Description: 连接类型底部弹窗
|
||||
* @Author: LiHongda
|
||||
* @CreateDate: 2024/2/22 20:53
|
||||
*/
|
||||
public class BottomChoiceDialog extends DialogFragment implements View.OnClickListener {
|
||||
|
||||
private static BottomChoiceDialog bottomChoiceDialog;
|
||||
|
||||
public static BottomChoiceDialog newInstance(String title, String message) {
|
||||
BottomChoiceDialog dialog = new BottomChoiceDialog();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("title", title);
|
||||
bundle.putString("message", message);
|
||||
dialog.setArguments(bundle);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static ConnectType curType;
|
||||
|
||||
public static BottomChoiceDialog newInstance() {
|
||||
if (bottomChoiceDialog == null) {
|
||||
bottomChoiceDialog = new BottomChoiceDialog();
|
||||
}
|
||||
return bottomChoiceDialog;
|
||||
}
|
||||
|
||||
private TextView tvSmartConfig;
|
||||
private TextView tvAP;
|
||||
private TextView tvAirKiss;
|
||||
private TextView tvCancel;
|
||||
private LinearLayout lineAirKiss;
|
||||
private LinearLayout lineSmartConfig;
|
||||
private LinearLayout lineAP;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
View view = inflater.inflate(R.layout.dialog_choose_connect_wifi_type, container, false);
|
||||
tvSmartConfig = (TextView) view.findViewById(R.id.tv_smartConfig);
|
||||
tvAP = (TextView) view.findViewById(R.id.tv_AP);
|
||||
tvAirKiss = (TextView) view.findViewById(R.id.tv_airkiss);
|
||||
tvCancel = (TextView) view.findViewById(R.id.tv_cancel);
|
||||
lineAirKiss = (LinearLayout) view.findViewById(R.id.line_airKiss);
|
||||
lineSmartConfig = (LinearLayout) view.findViewById(R.id.line_smartConfig);
|
||||
lineAP = (LinearLayout) view.findViewById(R.id.line_AP);
|
||||
|
||||
tvSmartConfig.setOnClickListener(this);
|
||||
tvAP.setOnClickListener(this);
|
||||
tvAirKiss.setOnClickListener(this);
|
||||
tvCancel.setOnClickListener(this);
|
||||
|
||||
switchChooseUI(curType);
|
||||
return view;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setCancelable(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
setStyle(STYLE_NORMAL, R.style.BottomDialogAnimation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
||||
// 不带style的构建的dialog宽度无法铺满屏幕
|
||||
// Dialog dialog = new Dialog(getActivity());
|
||||
Dialog dialog = new Dialog(getActivity(), R.style.CustomDatePickerDialog);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.dialog_choose_connect_wifi_type);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
|
||||
// 设置弹出框布局参数,宽度铺满全屏,底部。
|
||||
Window window = dialog.getWindow();
|
||||
WindowManager.LayoutParams wlp = window.getAttributes();
|
||||
wlp.gravity = Gravity.BOTTOM;
|
||||
wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
window.setAttributes(wlp);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
private OnChooseClickListener chooseClickListener;
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
switch (id) {
|
||||
case R.id.tv_smartConfig:
|
||||
chooseClickListener.smartConfigConnect();
|
||||
dismissAllowingStateLoss();
|
||||
break;
|
||||
case R.id.tv_AP:
|
||||
chooseClickListener.APConnect();
|
||||
dismissAllowingStateLoss();
|
||||
break;
|
||||
case R.id.tv_airkiss:
|
||||
chooseClickListener.AirKissConnect();
|
||||
dismissAllowingStateLoss();
|
||||
break;
|
||||
case R.id.tv_cancel:
|
||||
dismissAllowingStateLoss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void switchChooseUI(ConnectType curConnectType) {
|
||||
lineAirKiss.setVisibility(View.VISIBLE);
|
||||
lineAP.setVisibility(View.VISIBLE);
|
||||
lineSmartConfig.setVisibility(View.VISIBLE);
|
||||
switch (curConnectType) {
|
||||
case SmartConfig:
|
||||
// 处理SmartConfig逻辑
|
||||
lineSmartConfig.setVisibility(View.GONE);
|
||||
break;
|
||||
case APConnect:
|
||||
// 处理APConnect逻辑
|
||||
lineAP.setVisibility(View.GONE);
|
||||
break;
|
||||
case AirKiss:
|
||||
lineAirKiss.setVisibility(View.GONE);
|
||||
// 处理AirKiss逻辑
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface OnChooseClickListener {
|
||||
void smartConfigConnect();//智能连接
|
||||
|
||||
void APConnect();//热点连接
|
||||
|
||||
void AirKissConnect();//airkiss连接
|
||||
}
|
||||
|
||||
public void setOnChooseClickListener(OnChooseClickListener shareClickListener) {
|
||||
this.chooseClickListener = shareClickListener;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package com.ifish.activity.newbind;
|
||||
|
||||
import static android.content.Context.WIFI_SERVICE;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.ifish.activity.HotSpotConnentDeviceActivity;
|
||||
import com.ifish.activity.HotSpotConnentDeviceCameraActivity;
|
||||
import com.ifish.activity.HotSpotConnentPetDeviceActivity;
|
||||
import com.ifish.activity.R;
|
||||
import com.ifish.utils.AnimationUtil;
|
||||
import com.ifish.utils.KVUtil;
|
||||
import com.ifish.utils.SPUtil;
|
||||
import com.ifish.utils.ToastUtil;
|
||||
import com.ifish.utils.WifiUtil;
|
||||
import com.ifish.wheelview.adapter.ArrayWheelAdapter;
|
||||
import com.ifish.wheelview.view.WheelView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: CheckWifiUtil
|
||||
* @Description: 检查当前wifi密码
|
||||
* @Author: LiHongda
|
||||
* @CreateDate: 2024/2/22 23:33
|
||||
*/
|
||||
public class CheckWifiUtil {
|
||||
|
||||
public boolean checkWifiCanUse(AppCompatActivity activity) {
|
||||
WifiManager wifiManager = (WifiManager) activity.getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (!wifiManager.isWifiEnabled()) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "请检查WiFi是否开启");
|
||||
return false;
|
||||
}
|
||||
String wifissid = wifiInfo.getSSID();
|
||||
wifissid = wifissid.replaceAll("\"", "");
|
||||
if (TextUtils.isEmpty(wifissid)) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "您没有连接WiFi");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前的wifi是否可以用来配网
|
||||
*
|
||||
* @param activity
|
||||
* @param wifiname
|
||||
* @param wifipwd
|
||||
* @return
|
||||
*/
|
||||
public boolean checkWifiCanUse(AppCompatActivity activity, String wifiname, String wifipwd) {
|
||||
if (!checkWifiCanUse(activity)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(wifiname)) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "请输入路由器名称");
|
||||
return false;
|
||||
}
|
||||
WifiManager wifiManager = (WifiManager) activity.getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "缺少联网权限");
|
||||
return false;
|
||||
}
|
||||
List<ScanResult> scanResults = wifiManager.getScanResults();
|
||||
// 是否是 2.4G
|
||||
boolean is24G = false;
|
||||
// 是否是 5G
|
||||
boolean is5G = false;
|
||||
for (ScanResult scanResult : scanResults) {
|
||||
if (wifiname.equals(scanResult.SSID)) {
|
||||
int frequency = scanResult.frequency;
|
||||
WifiUtil wifiUtil = new WifiUtil(activity);
|
||||
if (wifiUtil.is24GHzWifi(frequency)) {
|
||||
is24G = true;
|
||||
}
|
||||
if (wifiUtil.is5GHzWifi(frequency)) {
|
||||
is5G = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if(!is24G && is5G){ //之所以这样处理,是因为现在有的路由器支持2.4+5G双频同时存在
|
||||
// WifiDialog wd = new WifiDialog(activity);
|
||||
// wd.show("仅支持2.4G Wi-Fi网络,请重新选择", "去更改", et_wifiname);
|
||||
// dismissProgressDialog();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (is5G) {
|
||||
//既是2.4G也是5G
|
||||
ToastUtil.show(activity.getApplicationContext(), "仅支持2.4G Wi-Fi网络,不支持2.4G和5G双频共存的网络,请重新选择");
|
||||
return false;
|
||||
}
|
||||
|
||||
wifipwd = wifipwd.trim();
|
||||
if (TextUtils.isEmpty(wifipwd)) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "请输入路由器密码");
|
||||
return false;
|
||||
}
|
||||
//保存wifiname和wifipwd
|
||||
// KVUtil.setString(wifiname, wifipwd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//切换wifi弹框
|
||||
private Dialog wifiDialog;
|
||||
|
||||
public List<ScanResult> getWifiList(AppCompatActivity activity) {
|
||||
WifiManager wifiManager = (WifiManager) activity.getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
List<ScanResult> scanWifiList = wifiManager.getScanResults();
|
||||
List<ScanResult> wifiList = new ArrayList<>();
|
||||
if (scanWifiList != null && scanWifiList.size() > 0) {
|
||||
HashMap<String, Integer> signalStrength = new HashMap<String, Integer>();
|
||||
for (int i = 0; i < scanWifiList.size(); i++) {
|
||||
ScanResult scanResult = scanWifiList.get(i);
|
||||
if (!scanResult.SSID.isEmpty()) {
|
||||
String key = scanResult.SSID + " " + scanResult.capabilities;
|
||||
if (!signalStrength.containsKey(key)) {
|
||||
signalStrength.put(key, i);
|
||||
wifiList.add(scanResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return wifiList;
|
||||
}
|
||||
|
||||
private void showHeatWenduDialog(AppCompatActivity activity, TextView tvWifiName) {
|
||||
List<ScanResult> wifiList = getWifiList(activity);
|
||||
if (wifiList == null || wifiList.size() == 0) {
|
||||
ToastUtil.show(activity, "未查找到周边WIFI");
|
||||
return;
|
||||
}
|
||||
final String[] wifis = new String[wifiList.size()];
|
||||
for (int i = 0; i < wifis.length; i++) {
|
||||
wifis[i] = wifiList.get(i).SSID;
|
||||
}
|
||||
final WheelView wv_water;
|
||||
Button bt_submit;
|
||||
wifiDialog = new Dialog(activity, R.style.HOLOMyDialogs);
|
||||
wifiDialog.setCancelable(true);
|
||||
Window window = wifiDialog.getWindow();
|
||||
window.setContentView(R.layout.setwifi_dialog);
|
||||
wv_water = (WheelView) window.findViewById(R.id.wv_water);
|
||||
bt_submit = (Button) window.findViewById(R.id.bt_submit);
|
||||
wv_water.setViewAdapter(new ArrayWheelAdapter<String>(activity, wifis));
|
||||
wifiDialog.show();
|
||||
wv_water.setCurrentItem(0);
|
||||
bt_submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
wifiDialog.dismiss();
|
||||
tvWifiName.setText(wifis[wv_water.getCurrentItem()]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getCurWifiSsid(AppCompatActivity activity) {
|
||||
WifiManager wifiManager = (WifiManager) activity.getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (!wifiManager.isWifiEnabled()) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "请检查WiFi是否开启");
|
||||
return wifiInfo.getSSID();
|
||||
}
|
||||
String wifissid = wifiInfo.getSSID();
|
||||
wifissid = wifissid.replaceAll("\"", "");
|
||||
if (TextUtils.isEmpty(wifissid)) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "您没有连接WiFi");
|
||||
return wifiInfo.getSSID();
|
||||
}
|
||||
|
||||
return wifissid;
|
||||
}
|
||||
|
||||
public void checkCurAP(AppCompatActivity activity, String wifiName, String wifiPwd, String devicetype) {
|
||||
String wifissid = getCurWifiSsid(activity);
|
||||
if (TextUtils.isEmpty(wifissid)) {
|
||||
wifissid = "";
|
||||
}
|
||||
|
||||
Intent intent = new Intent();
|
||||
|
||||
if ("camera".equals(devicetype)) {
|
||||
if (!wifissid.startsWith("GW_AP_")) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "请先连接摄像头ifish-xxxx的网络");
|
||||
return;
|
||||
}
|
||||
//todo 摄像头
|
||||
intent.setClass(activity, HotSpotConnentDeviceCameraActivity.class);
|
||||
} else if ("pet".equals(devicetype)) {
|
||||
if (!wifissid.startsWith("ifish-")) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "请先连接宠物笼ifish-xxxx的网络");
|
||||
return;
|
||||
}
|
||||
//todo 宠物
|
||||
intent.setClass(activity, HotSpotConnentPetDeviceActivity.class);
|
||||
} else {
|
||||
if (!wifissid.startsWith("ifish-")) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "请先连接ifish-xxxx的网络");
|
||||
return;
|
||||
}
|
||||
//todo 设备
|
||||
intent.setClass(activity, HotSpotConnentDeviceActivity.class);
|
||||
}
|
||||
|
||||
if (wifissid.equals(wifiName)) {
|
||||
ToastUtil.show(activity.getApplicationContext(), "WiFi名称不能和热点名称一致");
|
||||
return;
|
||||
}
|
||||
|
||||
intent.putExtra("wifiname", (!TextUtils.isEmpty(wifiName) ? wifiName : ""));
|
||||
intent.putExtra("wifipwd", (!TextUtils.isEmpty(wifiPwd) ? wifiPwd : ""));
|
||||
intent.putExtra("wifihotid", wifissid);
|
||||
activity.startActivity(intent);
|
||||
AnimationUtil.startAnimation(activity);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ifish.activity.newbind;
|
||||
|
||||
/**
|
||||
* @ClassName: ConnectType
|
||||
* @Description: 作用描述
|
||||
* @Author: LiHongda
|
||||
* @CreateDate: 2024/2/22 21:22
|
||||
*/
|
||||
public enum ConnectType {
|
||||
APConnect,
|
||||
SmartConfig,
|
||||
AirKiss
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.ifish.activity.newbind;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
public class DeviceUtils {
|
||||
|
||||
/**
|
||||
* 隐藏软键盘
|
||||
* <p>
|
||||
* {@link InputMethodManager#hideSoftInputFromWindow}第一个参数如果使用getCurrentFocus.getWindowToken,在使用模拟器调试时,
|
||||
* 存在获取不到焦点的情况,故会出现空指针异常。
|
||||
*
|
||||
* @param view 任意一个当前layout的view
|
||||
*/
|
||||
public static void hideKeyboard(View view) {
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) view.getContext()
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (inputMethodManager != null) {
|
||||
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断网络连接是否是WiFi,否则返回false
|
||||
*/
|
||||
public static boolean isWifi(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (cm != null) {
|
||||
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
||||
if (netInfo != null && netInfo.isConnected()) {
|
||||
return netInfo.getType() == ConnectivityManager.TYPE_WIFI;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static String getSSID(Context context) {
|
||||
String ssid = "unknown id";
|
||||
//android 8.1
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O_MR1){
|
||||
ConnectivityManager connManager = (ConnectivityManager) context.getApplicationContext().
|
||||
getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
assert connManager != null;
|
||||
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
|
||||
if (networkInfo.isConnected()){
|
||||
Log.e("DeviceUtils", "getSSID111: "+ networkInfo.getExtraInfo() );
|
||||
if (networkInfo.getExtraInfo() != null){
|
||||
return networkInfo.getExtraInfo().replace("\"","");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (isWifi(context)){
|
||||
final WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo connectionInfo = null;
|
||||
if (wifiManager != null) {
|
||||
connectionInfo = wifiManager.getConnectionInfo();
|
||||
}
|
||||
if (connectionInfo != null) {
|
||||
ssid = connectionInfo.getSSID();
|
||||
Log.e("DeviceUtils", "getSSID: "+ssid );
|
||||
if (ssid.startsWith("\"") && ssid.endsWith("\"")) {
|
||||
ssid = ssid.replaceAll("^\"|\"$", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ssid;
|
||||
}
|
||||
|
||||
public static boolean isApkDebuggable(Context context){
|
||||
try {
|
||||
ApplicationInfo info = context.getApplicationInfo();
|
||||
return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE)!=0;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
package com.ifish.activity.newbind;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.ifish.activity.BindCameraActivity;
|
||||
import com.ifish.activity.BindDeviceChoiceActivity;
|
||||
import com.ifish.activity.BindTankActivity;
|
||||
import com.ifish.activity.BindTankPetActivity;
|
||||
import com.ifish.activity.R;
|
||||
import com.ifish.activity.TimeSettingFour;
|
||||
import com.ifish.activity.WebViewActivity;
|
||||
import com.ifish.basebean.ConnectMessageEvent;
|
||||
import com.ifish.utils.AnimationUtil;
|
||||
import com.ifish.utils.ClickUtil;
|
||||
import com.ifish.utils.Commons;
|
||||
import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.KVUtil;
|
||||
import com.ifish.utils.SPUtil;
|
||||
import com.ifish.utils.ToastUtil;
|
||||
import com.ifish.utils.WifiAdmin;
|
||||
import com.lidroid.xutils.util.LogUtils;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* @ClassName: NewBindDeviceActivity
|
||||
* @Description: 新版连接界面
|
||||
* @Author: LiHongda
|
||||
* @CreateDate: 2024/2/22 20:45
|
||||
*/
|
||||
public class NewBindDeviceActivity extends AppCompatActivity {
|
||||
|
||||
//----------------控件区--------------------//
|
||||
private TextView tvConnectType;
|
||||
private LinearLayout llWifi;
|
||||
private TextView tvWifiName;
|
||||
private EditText tvWifiPwd;
|
||||
private TextView tvTips;
|
||||
private TextView tvTips2;
|
||||
private TextView tvTips3;
|
||||
private TextView tvOtherConnect;
|
||||
private TextView tvClickButton;
|
||||
private TextView tvConnectVideo;
|
||||
|
||||
|
||||
//----------------变量区--------------------//
|
||||
private ConnectType curConnectType;//当前选择的连接类型 APConnect,SmartConfig,AirKiss
|
||||
private boolean first = true;//首次进入
|
||||
//当前需要连接的是什么设备
|
||||
private String devicetype;
|
||||
|
||||
//---------------工具类--------------------//
|
||||
private CheckWifiUtil checkWifiUtil;
|
||||
private AirKissUtil airKissUtil;
|
||||
private String bssid = "";
|
||||
private SPUtil sp;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_new_bind_device_choice);
|
||||
sp=SPUtil.getInstance(this);
|
||||
initTitle();
|
||||
initView();
|
||||
initListener();
|
||||
initWifiName();
|
||||
checkWifiUtil = new CheckWifiUtil();
|
||||
airKissUtil = new AirKissUtil();
|
||||
devicetype = getIntent().getStringExtra("devicetype");
|
||||
airKissUtil.init(this,devicetype);
|
||||
//默认AP联网
|
||||
curConnectType = ConnectType.AirKiss;
|
||||
switchUIConnectType(curConnectType);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
private void initWifiName() {
|
||||
WifiAdmin wifiAdmin = new WifiAdmin(this);
|
||||
String wifissid = wifiAdmin.getSSID();
|
||||
LogUtils.d("LHD 获取当前连接的wifi:" + wifissid);
|
||||
wifissid = wifiAdmin.updateSsid(wifissid);
|
||||
String wifiname = wifissid;
|
||||
if (TextUtils.isEmpty(wifissid)) {
|
||||
wifiname = "";
|
||||
} else {
|
||||
if ("0x".equals(wifissid)) {//上次连接过wifi,但是中途断开,则会出现0x
|
||||
wifiname = "";
|
||||
}
|
||||
}
|
||||
tvWifiName.setText(wifiname);
|
||||
bssid = wifiAdmin.getBSSID();
|
||||
if (!TextUtils.isEmpty(wifiname)) {
|
||||
// String pwd = KVUtil.getString(wifiname, "");
|
||||
String pwd = sp.getString(wifiname, "");
|
||||
tvWifiPwd.setText(pwd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initTitle() {
|
||||
TextView title_text = (TextView) findViewById(R.id.title_text);
|
||||
title_text.setText("连接设备");
|
||||
findViewById(R.id.title_img).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
tvConnectType = (TextView) findViewById(R.id.tv_connect_type);
|
||||
tvConnectVideo = (TextView) findViewById(R.id.tv_connect_video);
|
||||
llWifi = (LinearLayout) findViewById(R.id.ll_wifi);
|
||||
tvWifiName = (TextView) findViewById(R.id.tv_wifi_name);
|
||||
tvWifiPwd = (EditText) findViewById(R.id.tv_wifi_pwd);
|
||||
tvTips = (TextView) findViewById(R.id.tv_tips);
|
||||
tvTips2 = (TextView) findViewById(R.id.tv_tips2);
|
||||
tvTips3 = (TextView) findViewById(R.id.tv_tips3);
|
||||
tvOtherConnect = (TextView) findViewById(R.id.tv_other_connect);
|
||||
tvClickButton = (TextView) findViewById(R.id.tv_click_button);
|
||||
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
tvOtherConnect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (ClickUtil.isFastDoubleClick()) {
|
||||
LogUtils.d("LHD 防止快速点击");
|
||||
return;
|
||||
}
|
||||
//选择连接类型的底部弹窗
|
||||
BottomChoiceDialog.curType = curConnectType;
|
||||
BottomChoiceDialog bottomChoiceDialog = BottomChoiceDialog.newInstance();
|
||||
bottomChoiceDialog.show(getSupportFragmentManager(), "选择连接类型");
|
||||
bottomChoiceDialog.setOnChooseClickListener(new BottomChoiceDialog.OnChooseClickListener() {
|
||||
@Override
|
||||
public void smartConfigConnect() {
|
||||
//智能连接逻辑
|
||||
curConnectType = ConnectType.SmartConfig;
|
||||
switchUIConnectType(curConnectType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void APConnect() {
|
||||
//AP连接逻辑
|
||||
curConnectType = ConnectType.APConnect;
|
||||
switchUIConnectType(curConnectType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AirKissConnect() {
|
||||
//airKiss逻辑
|
||||
curConnectType = ConnectType.AirKiss;
|
||||
switchUIConnectType(curConnectType);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
tvClickButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
connectDevice();
|
||||
}
|
||||
});
|
||||
tvConnectVideo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent();
|
||||
i.setClass(NewBindDeviceActivity.this, WebViewActivity.class);
|
||||
if (curConnectType == ConnectType.AirKiss){
|
||||
i.putExtra(WebViewActivity.URL, HttpManager.AirKissConnectVideoUrl);
|
||||
i.putExtra(WebViewActivity.WEBVIEWTITLE, HttpManager.AirKissConnectVideoTitle);
|
||||
}else {
|
||||
i.putExtra(WebViewActivity.URL, HttpManager.APConnectVideoUrl);
|
||||
i.putExtra(WebViewActivity.WEBVIEWTITLE, HttpManager.APConnectVideoTitle);
|
||||
}
|
||||
startActivity(i);
|
||||
AnimationUtil.startAnimation(NewBindDeviceActivity.this);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void resetLayout() {
|
||||
//确定&下一步按钮
|
||||
tvClickButton.setVisibility(View.VISIBLE);
|
||||
tvConnectVideo.setVisibility(View.VISIBLE);
|
||||
airKissUtil.stopAirKiss();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据连接类型切换UI
|
||||
* todo 这里的提示应该根据连接类型有不同的提示
|
||||
*
|
||||
* @param connectType
|
||||
*/
|
||||
public void switchUIConnectType(ConnectType connectType) {
|
||||
resetLayout();
|
||||
showToast(connectType);
|
||||
switch (connectType) {
|
||||
case SmartConfig:
|
||||
// 处理SmartConfig逻辑
|
||||
tvConnectType.setText("快捷联网");
|
||||
tvClickButton.setText("确定");
|
||||
tvConnectVideo.setVisibility(View.INVISIBLE);
|
||||
tvTips.setText("1、插座仅支持2.4G的WiFi网络,不支持5G及双频合一的网络(需在路由器设置中分开)");
|
||||
tvTips2.setText("2、先长按插座复位键3秒,松手后红灯绿灯同时闪烁以后,再点确定按钮。");
|
||||
tvTips3.setText("3、如多次尝试一键联网都不成功,可切换其他联网方式,每次重新连接时插座需断一次电然后重新复位连接。");
|
||||
break;
|
||||
case APConnect:
|
||||
// 处理APConnect逻辑
|
||||
tvConnectType.setText("AP联网");
|
||||
tvClickButton.setText("下一步");
|
||||
tvTips.setText("1、插座仅支持2.4G的WiFi网络,不支持5G及双频合一的网络(需在路由器设置中分开)");
|
||||
tvTips2.setText("2、先长按插座复位键13秒左右,松手后红灯绿灯同时熄灭,只有绿灯偶尔闪烁,再点下一步。");
|
||||
tvTips3.setText("3、APP跳转到WLAN后,选择ifish-xxxx的网络,点击连接,密码是12345678,连好以后点击左上角返回箭头,耐心等待连接。");
|
||||
break;
|
||||
case AirKiss:
|
||||
tvConnectType.setText("一键联网");
|
||||
tvClickButton.setText("确定");
|
||||
tvTips.setText("1、插座仅支持2.4G的WiFi网络,不支持5G及双频合一的网络(需在路由器设置中分开)");
|
||||
tvTips2.setText("2、先长按插座复位键3秒,松手后红灯绿灯同时闪烁以后,再点确定按钮。");
|
||||
tvTips3.setText("3、如多次尝试一键联网都不成功,可切换其他联网方式,每次重新连接时插座需断一次电然后重新复位连接。");
|
||||
// 处理AirKiss逻辑
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showToast(ConnectType connectType){
|
||||
if (first){
|
||||
first = false;
|
||||
LogUtils.d("LHD 首次进入的时候不显示toast");
|
||||
return;
|
||||
}
|
||||
switch (connectType) {
|
||||
case SmartConfig:
|
||||
ToastUtil.show(this, "切换到快捷联网");
|
||||
break;
|
||||
case APConnect:
|
||||
ToastUtil.show(this, "切换到AP联网");
|
||||
break;
|
||||
case AirKiss:
|
||||
ToastUtil.show(this, "切换到一键联网");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据连接类型去连接设备
|
||||
*/
|
||||
public void connectDevice() {
|
||||
airKissUtil.stopAirKiss();
|
||||
//根据选择的联网类型跳转不同的逻辑
|
||||
String ssid = tvWifiName.getText().toString();
|
||||
String pwd = tvWifiPwd.getText().toString();
|
||||
//一系列判断逻辑
|
||||
boolean canConnect = checkWifiUtil.checkWifiCanUse(this, ssid, pwd);
|
||||
sp.putString(ssid,pwd);
|
||||
if (!canConnect) {
|
||||
return;
|
||||
}
|
||||
switch (curConnectType) {
|
||||
case SmartConfig:
|
||||
// 处理SmartConfig逻辑
|
||||
Intent intent = new Intent();
|
||||
String devicetype = getIntent().getStringExtra("devicetype");
|
||||
LogUtils.d("LHD 快捷联网 smartConfig devicetype = "+devicetype);
|
||||
if ("camera".equals(devicetype)) {
|
||||
intent.setClass(NewBindDeviceActivity.this, BindCameraActivity.class);
|
||||
} else if ("pet".equals(devicetype)) {
|
||||
intent.setClass(NewBindDeviceActivity.this, BindTankPetActivity.class);
|
||||
} else {
|
||||
intent.setClass(NewBindDeviceActivity.this, BindTankActivity.class);
|
||||
}
|
||||
String title = getIntent().getStringExtra("title");
|
||||
if ("连接热流器".equals(title)) {
|
||||
intent.putExtra("title", "连接热流器");
|
||||
}
|
||||
//新页面跳转
|
||||
intent.putExtra("wifiPassword", pwd);
|
||||
ToastUtil.show(NewBindDeviceActivity.this, "开始快捷联网...");
|
||||
startActivity(intent);
|
||||
AnimationUtil.startAnimation(NewBindDeviceActivity.this);
|
||||
finish();
|
||||
break;
|
||||
case APConnect:
|
||||
//开始AP连接
|
||||
connectAP();
|
||||
break;
|
||||
case AirKiss:
|
||||
// 处理AirKiss逻辑
|
||||
ToastUtil.show(NewBindDeviceActivity.this, "开始AirKiss联网...");
|
||||
airKissUtil.connectDeviceByAirKiss(this, ssid, bssid, pwd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isJump = false;
|
||||
|
||||
/**
|
||||
* 1.跳转设置页面连接ifish-xxx的wifi,连接成功后返回
|
||||
*/
|
||||
private void connectAP() {
|
||||
isJump = true;
|
||||
Intent i = new Intent();
|
||||
i = new Intent(Settings.ACTION_WIFI_SETTINGS);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (isJump) {
|
||||
String wifiName = tvWifiName.getText().toString();
|
||||
String wifiPwd = tvWifiPwd.getText().toString();
|
||||
checkWifiUtil.checkCurAP(this, wifiName, wifiPwd, devicetype);
|
||||
isJump = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
airKissUtil.unSubscribe();
|
||||
}
|
||||
|
||||
public void onEventMainThread(ConnectMessageEvent event) {
|
||||
if (event.getId() == -1){
|
||||
//绑定失败
|
||||
if (curConnectType == ConnectType.APConnect){
|
||||
ToastUtil.showLongToast(NewBindDeviceActivity.this,"点击右上角联网视频查看联网失败的原因");
|
||||
return;
|
||||
}
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
//检查位置权限
|
||||
public boolean checkPermission(Activity context) {
|
||||
//9.0以前版本获取wifi ssid不用申请此权限
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
return true;
|
||||
}
|
||||
int result = context.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
if (result == PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
}
|
||||
String[] permission = {Manifest.permission.ACCESS_COARSE_LOCATION};
|
||||
context.requestPermissions(permission, 1001);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == 1001) {
|
||||
if (grantResults.length > 0 && PackageManager.PERMISSION_GRANTED == grantResults[0]) {
|
||||
if (DeviceUtils.isWifi(this)) {
|
||||
// ssidET.setText(DeviceUtils.getSSID(this));
|
||||
}
|
||||
} else {
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
|
||||
alertDialog.setTitle("权限拒绝");
|
||||
alertDialog.setMessage("请在设置中打开此应用的位置权限后重试");
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,8 +8,11 @@ import android.util.Log;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.ifish.basebean.WxLoginMessageEvent;
|
||||
import com.lidroid.xutils.util.LogUtils;
|
||||
import com.tencent.mm.opensdk.constants.ConstantsAPI;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
||||
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
@@ -60,5 +63,12 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
|
||||
EventBus.getDefault().post(new WxLoginMessageEvent(false, "失败"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (baseResp.getType() == ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM) {
|
||||
WXLaunchMiniProgram.Resp launchMiniProResp = (WXLaunchMiniProgram.Resp) baseResp;
|
||||
String extraData = launchMiniProResp.extMsg; //对应组件 &amp;lt;button open-type="launchApp"&amp;gt; 中的 app-parameter 属性
|
||||
LogUtils.d("LHD airkiss "+extraData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.ifish.activity.EditVideoActivity;
|
||||
import com.ifish.activity.R;
|
||||
import com.ifish.basebean.IfishVideo;
|
||||
@@ -69,7 +70,11 @@ public class VideoListAdapter extends BaseAdapter {
|
||||
}
|
||||
final IfishVideo bean = list.get(position);
|
||||
if (bean!=null) {
|
||||
Glide.with(context).load(HttpManager.VIDEO_IMG_URL+bean.userId+"/"+ bean.commodityImg).placeholder(R.drawable.error_lookfishlist).error(R.drawable.error_lookfishlist).into(holder.iv_commodityImg);
|
||||
|
||||
Glide.with(context).load(HttpManager.VIDEO_IMG_URL+bean.userId+"/"+ bean.commodityImg)
|
||||
.apply( new RequestOptions().placeholder(R.drawable.error_lookfishlist)
|
||||
.error(R.drawable.error_lookfishlist))
|
||||
.into(holder.iv_commodityImg);
|
||||
holder.tv_commodityName.setText(bean.commodityName);
|
||||
holder.tv_click.setText("浏览次数:"+bean.click+"次");
|
||||
try {
|
||||
|
||||
@@ -1,35 +1,44 @@
|
||||
package com.ifish.airkiss;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
//测试时需要先启动设备端程序,然后在手机上发送配网信息,根据周围环境条件,配网速度可能或快或慢
|
||||
public class AirKissEncoder {
|
||||
private int mEncodedData[] = new int[2 << 14];
|
||||
private int[] mEncodedData = new int[2 << 14];
|
||||
private int mLength = 0;
|
||||
|
||||
// Random char should be in range [0, 127).
|
||||
private char mRandomChar = (char)(new Random().nextInt(0x7F));
|
||||
// private char mRandomChar = 'A';//固定随机数
|
||||
|
||||
public AirKissEncoder(String ssid, String password) {
|
||||
Log.d("LHD","随机数 = "+mRandomChar);
|
||||
int times = 5;
|
||||
while (times-- > 0) {
|
||||
leadingPart();
|
||||
magicCode(ssid, password);
|
||||
|
||||
for (int i = 0; i < 15; ++i) {
|
||||
prefixCode(password);
|
||||
String data = password + mRandomChar + ssid;
|
||||
try {
|
||||
data = new String(data.getBytes(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int index;
|
||||
byte content[] = new byte[4];
|
||||
for (index = 0; index < data.length() / 4; ++index) {
|
||||
for (index = 0; index < data.getBytes().length / 4; ++index) {
|
||||
System.arraycopy(data.getBytes(), index * 4, content, 0, content.length);
|
||||
sequence(index, content);
|
||||
}
|
||||
|
||||
if (data.length() % 4 != 0) {
|
||||
content = new byte[data.length() % 4];
|
||||
if (data.getBytes().length % 4 != 0) {
|
||||
content = new byte[data.getBytes().length % 4];
|
||||
System.arraycopy(data.getBytes(), index * 4, content, 0, content.length);
|
||||
sequence(index, content);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,9 +59,9 @@ public class AirKissEncoder {
|
||||
private int CRC8(byte data[]) {
|
||||
int len = data.length;
|
||||
int i = 0;
|
||||
byte crc = 0x00;
|
||||
int crc = 0x00;
|
||||
while (len-- > 0) {
|
||||
byte extract = data[i++];
|
||||
int extract = data[i++];
|
||||
for (byte tempI = 8; tempI != 0; tempI--) {
|
||||
byte sum = (byte) ((crc & 0xFF) ^ (extract & 0xFF));
|
||||
sum = (byte) ((sum & 0xFF) & 0x01);
|
||||
@@ -78,13 +87,20 @@ public class AirKissEncoder {
|
||||
}
|
||||
|
||||
private void magicCode(String ssid, String password) {
|
||||
int length = ssid.length() + password.length() + 1;
|
||||
byte[] bSsid = ssid.getBytes();
|
||||
String u8Ssid = null;
|
||||
try {
|
||||
u8Ssid = new String(bSsid, "UTF-8" );
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int length = u8Ssid.getBytes().length+ password.length()+1;
|
||||
int magicCode[] = new int[4];
|
||||
magicCode[0] = 0x00 | (length >>> 4 & 0xF);
|
||||
if (magicCode[0] == 0)
|
||||
magicCode[0] = 0x08;
|
||||
magicCode[1] = 0x10 | (length & 0xF);
|
||||
int crc8 = CRC8(ssid);
|
||||
int crc8 = CRC8(u8Ssid);
|
||||
magicCode[2] = 0x20 | (crc8 >>> 4 & 0xF);
|
||||
magicCode[3] = 0x30 | (crc8 & 0xF);
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
@@ -112,7 +128,9 @@ public class AirKissEncoder {
|
||||
int crc8 = CRC8(content);
|
||||
appendEncodedData(0x80 | crc8);
|
||||
appendEncodedData(0x80 | index);
|
||||
for (byte aData : data)
|
||||
appendEncodedData(aData | 0x100);
|
||||
for (byte aData : data) {
|
||||
int bData = (aData & 0xff);
|
||||
appendEncodedData(bData | 0x100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.ifish.airkiss;
|
||||
import android.util.Log;
|
||||
|
||||
import com.ifish.utils.WifiUtil;
|
||||
import com.lidroid.xutils.util.LogUtils;
|
||||
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -16,7 +18,7 @@ import java.nio.charset.StandardCharsets;
|
||||
*/
|
||||
// 创建一个接收器类
|
||||
public class UDPReceiver extends Thread {
|
||||
private static final int MAX_UDP_DATAGRAM_LEN = 1500;
|
||||
private static final int MAX_UDP_DATAGRAM_LEN = 15000;
|
||||
private DatagramSocket mSocket;
|
||||
private boolean mRunning;
|
||||
private UdpCallback resultBack;
|
||||
@@ -32,7 +34,9 @@ public class UDPReceiver extends Thread {
|
||||
mSocket = null;
|
||||
}
|
||||
// 创建一个UDP套接字
|
||||
mSocket = new DatagramSocket(10000);
|
||||
mSocket = new DatagramSocket(null);
|
||||
mSocket.bind(new InetSocketAddress(10000));
|
||||
mSocket.setSoTimeout(1000 * 60);
|
||||
} catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -46,15 +50,22 @@ public class UDPReceiver extends Thread {
|
||||
|
||||
while (mRunning) {
|
||||
try {
|
||||
LogUtils.d("LHD 开始接受");
|
||||
// 接收UDP数据包
|
||||
mSocket.receive(packet);
|
||||
// String hexString = Str_Hex.byte2hex(packet.getData());
|
||||
String data = new String(packet.getData(), 0, packet.getLength(), StandardCharsets.UTF_8);
|
||||
Log.e("test9999999990","收到的udp包 ip=" + packet.getAddress().getHostAddress());
|
||||
String ip3 = WifiUtil.intToIp(wifiUtil.getConnectIpAddress());
|
||||
LogUtils.d("LHD 开始接受 = "+" ip3 = "+ip3);
|
||||
// Log.e("LHD test9999999990","收到的udp包 ip=" + packet.getAddress().getHostAddress()+" ip3 = "+ip3);
|
||||
// 处理接收到的数据
|
||||
if(!packet.getAddress().getHostAddress().equals(WifiUtil.intToIp(wifiUtil.getConnectIpAddress()))){
|
||||
handleData(data);
|
||||
String data = new String(packet.getData(), 0, packet.getLength(), StandardCharsets.UTF_8);
|
||||
String hexString = Str_Hex.byte2hex(packet.getData());
|
||||
handleData(hexString);
|
||||
}
|
||||
}catch (SocketException e) {
|
||||
LogUtils.d("LHD SocketException : " + e.getLocalizedMessage());
|
||||
handleErrorData(e.toString());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
handleErrorData(e.toString());
|
||||
@@ -79,6 +90,7 @@ public class UDPReceiver extends Thread {
|
||||
}
|
||||
|
||||
private void handleErrorData(String data) {
|
||||
stopRunning();
|
||||
// 处理接收到的数据
|
||||
if(resultBack != null){
|
||||
resultBack.onError(data);
|
||||
|
||||
@@ -52,4 +52,5 @@ public class LiveRoomInfo implements Serializable {
|
||||
public LiveRoomInfo(String roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package com.ifish.basebean;
|
||||
|
||||
import com.ifish.utils.Commons;
|
||||
import com.lidroid.xutils.util.LogUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -50,25 +46,6 @@ public class User implements Serializable{
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public byte[] getUserIdBytes(){
|
||||
String originalUserId = Commons.USER.getUserId();
|
||||
|
||||
// 创建一个长度为10的字节数组,用于存储补零后的用户ID
|
||||
byte[] userIdBytes = new byte[10];
|
||||
|
||||
// 将原始用户ID的字节数组复制到新的字节数组中
|
||||
byte[] originalBytes = originalUserId.getBytes();
|
||||
System.arraycopy(originalBytes, 0, userIdBytes, 0, Math.min(originalBytes.length, userIdBytes.length));
|
||||
|
||||
// 如果原始用户ID的长度小于10,用零填充剩余的空间
|
||||
for (int i = originalBytes.length; i < userIdBytes.length; i++) {
|
||||
userIdBytes[i] = 0;
|
||||
}
|
||||
LogUtils.d("LHD 传递userId = "+ Arrays.toString(userIdBytes));
|
||||
return userIdBytes;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@ import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
|
||||
@@ -24,13 +29,30 @@ import com.alibaba.sdk.android.push.PushControlService;
|
||||
import com.alibaba.sdk.android.push.huawei.HuaWeiRegister;
|
||||
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
|
||||
import com.alibaba.sdk.android.push.register.MiPushRegister;
|
||||
import com.ifish.activity.BuildConfig;
|
||||
import com.ifish.utils.ImageDownLoader;
|
||||
import com.ifish.utils.KVUtil;
|
||||
import com.ifish.utils.SystemUtil;
|
||||
import com.ifish.utils.TrustAllCerts;
|
||||
import com.p2p.core.P2PSpecial.P2PSpecial;
|
||||
//import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.tendcloud.tenddata.TCAgent;
|
||||
import com.umeng.commonsdk.UMConfigure;
|
||||
import com.umeng.socialize.PlatformConfig;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
/**
|
||||
* @author Jacky dada
|
||||
* @ClassName: BaseApplication
|
||||
@@ -52,8 +74,8 @@ public class BaseApplication extends MultiDexApplication {
|
||||
/**
|
||||
* 正式环境
|
||||
*/
|
||||
// public static String BASE = "https://app.ifish7.cn/";//正式环境 接口访问地址
|
||||
public static String BASE = "http://139.196.24.156:7080/";//测试环境 接口访问地址
|
||||
public static String BASE = "https://app.ifish7.cn/";//正式环境 接口访问地址
|
||||
// public static String BASE = "http://139.196.24.156:7080/";//测试环境 接口访问地址
|
||||
public static String BASE_URL = BASE + "api/";// 接口URL
|
||||
|
||||
@Override
|
||||
@@ -69,13 +91,20 @@ public class BaseApplication extends MultiDexApplication {
|
||||
initalipushSDK();
|
||||
P2PSpecial.getInstance().init(app, APPID, APPToken, APPVersion);
|
||||
initLog();
|
||||
//初始化MMKV
|
||||
// KVUtil.init(this);
|
||||
initPicasso();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示当前Acitivity名字
|
||||
*/
|
||||
private void initLog() {
|
||||
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle bundle) {
|
||||
Log.i("ifish7", "LHD" + "---" + activity.getLocalClassName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +114,27 @@ public class BaseApplication extends MultiDexApplication {
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
if (BuildConfig.DEBUG){
|
||||
Log.i("ifish7", "LHD" + " debug模式显示当前页面:"+activity.getLocalClassName());
|
||||
// 创建一个新的TextView
|
||||
TextView textView = new TextView(activity);
|
||||
textView.setText(activity.getLocalClassName());
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
textView.setTextColor(Color.YELLOW);
|
||||
// 设置TextView的布局参数,确保它有一个合适的大小
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.TOP | Gravity.START);
|
||||
// 可以设置具体的边距和位置
|
||||
layoutParams.setMargins(10, 10, 10, 10);
|
||||
textView.setLayoutParams(layoutParams);
|
||||
// 获取根布局容器
|
||||
ViewGroup rootLayout = (ViewGroup) activity.getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
|
||||
// 在布局容器的顶部添加TextView
|
||||
rootLayout.addView(textView); // 0 表示将视图添加到容器的顶部
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,4 +255,65 @@ public class BaseApplication extends MultiDexApplication {
|
||||
String processName = SystemUtil.getProcessName(this);
|
||||
return packageName.equals(processName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化picasso使用okhttp作为网络请求框架
|
||||
*/
|
||||
private void initPicasso() {
|
||||
|
||||
Picasso
|
||||
.setSingletonInstance(new Picasso.Builder(this).
|
||||
downloader(new ImageDownLoader(getSOkHttpClient())).loggingEnabled(true)
|
||||
.build());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建全局OkHttpClient对象
|
||||
* <p>
|
||||
* OkHttpClient 用于管理所有的请求,内部支持并发,
|
||||
* 所以我们不必每次请求都创建一个 OkHttpClient 对象,这是非常耗费资源的。接下来就是创建一个 Request 对象了
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static OkHttpClient getSOkHttpClient() {
|
||||
//创建okhttp的请求对象 参考地址 http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0106/2275.html
|
||||
|
||||
// if (sOkHttpClient == null) {
|
||||
// sOkHttpClient =
|
||||
return new OkHttpClient.Builder()
|
||||
.readTimeout(20000, TimeUnit.SECONDS)//设置读取超时时间
|
||||
.writeTimeout(20000, TimeUnit.SECONDS)//设置写的超时时间
|
||||
.connectTimeout(20000, TimeUnit.SECONDS)//设置连接超时时间
|
||||
.sslSocketFactory(createSSLSocketFactory()) //添加信任所有证书
|
||||
.hostnameVerifier(new HostnameVerifier() { //信任规则全部信任
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
.build();
|
||||
// }
|
||||
// return sOkHttpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试环境https添加全部信任
|
||||
* okhttp的配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static SSLSocketFactory createSSLSocketFactory() {
|
||||
SSLSocketFactory ssfFactory = null;
|
||||
|
||||
try {
|
||||
SSLContext sc = SSLContext.getInstance("TLS");
|
||||
sc.init(null, new TrustManager[]{new TrustAllCerts()}, new SecureRandom());
|
||||
|
||||
ssfFactory = sc.getSocketFactory();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
return ssfFactory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
@@ -102,6 +103,7 @@ import com.ifish.geewe.SettingListener;
|
||||
import com.ifish.permission.PermissionHelper;
|
||||
import com.ifish.utils.ActivityManager;
|
||||
import com.ifish.utils.AnimationUtil;
|
||||
import com.ifish.utils.AppUtil;
|
||||
import com.ifish.utils.Commons;
|
||||
import com.ifish.utils.Commons.LoginSPKey;
|
||||
import com.ifish.utils.Commons.NetWork;
|
||||
@@ -280,24 +282,18 @@ public class DeviceFragment extends BaseV4Fragment implements ObservableScrollVi
|
||||
|
||||
@Override
|
||||
public void onPermissionDeniedBySystem() {
|
||||
// AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
|
||||
// dialog.setCancelable(false);
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
|
||||
dialog.setCancelable(false);
|
||||
// dialog.setMessage("请到应用管理-爱鱼奇-应用权限页面开启权限后重新打开app");
|
||||
// dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(
|
||||
// DialogInterface dialog,
|
||||
// int which) {
|
||||
dialog.setMessage("请到应用信息页面-权限管理-打开位置和相机权限");
|
||||
dialog.setPositiveButton("去开启", (dialog1, which) -> {
|
||||
// Intent mItent = new Intent(Settings.ACTION_SETTINGS);
|
||||
// startActivity(mItent);
|
||||
// }
|
||||
// });
|
||||
// dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// }
|
||||
// });
|
||||
// dialog.show();
|
||||
AppUtil.toAuthority(requireActivity());
|
||||
});
|
||||
dialog.setNegativeButton("取消", (dialog12, which) -> {
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -188,6 +188,8 @@ public class LookFishLeftFragment extends BaseV4Fragment implements BGARefreshLa
|
||||
*/
|
||||
position=position-2;//自定义GridView 添加头部后position改变
|
||||
Intent i =new Intent(getActivity(),LookFishMonitorActivity.class);
|
||||
|
||||
L.i(this.getClass().getName() + "----------------onCreate"+liveRoomList.get(position).toString());
|
||||
i.putExtra("LiveRoomInfo",liveRoomList.get(position));
|
||||
startActivity(i);
|
||||
AnimationUtil.startAnimation(getActivity());
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.ifish.tcp;
|
||||
|
||||
import static com.ifish.utils.Commons.Device;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.ifish.basebean.Device;
|
||||
import com.ifish.utils.ByteUtil;
|
||||
import com.ifish.utils.Commons;
|
||||
|
||||
@@ -14,6 +13,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.ifish.utils.Commons.Device;
|
||||
import static com.ifish.utils.Commons.num;
|
||||
|
||||
public class ModelCodec {
|
||||
/**
|
||||
* 把对象转成字节数
|
||||
@@ -268,8 +270,6 @@ public class ModelCodec {
|
||||
buffer.put(model.getWifiSSID());
|
||||
//wifi密码
|
||||
buffer.put(model.getWifiPWD());
|
||||
//用户id
|
||||
buffer.put(Commons.USER.getUserIdBytes());
|
||||
//crc16校验码
|
||||
buffer.put(model.getCrc16_code());
|
||||
//tcp连接域名
|
||||
@@ -288,8 +288,6 @@ public class ModelCodec {
|
||||
buffer.put(model.getSsid_name());
|
||||
//wifi密码
|
||||
buffer.put(model.getSsid_password());
|
||||
//用户id
|
||||
buffer.put(Commons.USER.getUserIdBytes());
|
||||
//crc16校验码
|
||||
buffer.put(model.getCrc16_code());
|
||||
//tcp连接域名
|
||||
@@ -441,7 +439,7 @@ public class ModelCodec {
|
||||
} else if (Check_code == 25) {
|
||||
return decodexuanduo_get(buf);
|
||||
}
|
||||
//todo switch语句
|
||||
//switch语句
|
||||
switch (length) {
|
||||
//长度为20,绑定wifi的反馈
|
||||
case 20: {
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.ifish.utils;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.activity.ComponentActivity;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class AppUtil {
|
||||
|
||||
|
||||
|
||||
|
||||
public static boolean isBrandXiaoMi() {
|
||||
return "xiaomi".equals(
|
||||
Build.BRAND
|
||||
) || "xiaomi".equals(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
public static boolean isBrandHuawei() {
|
||||
return "huawei".equals(
|
||||
Build.BRAND
|
||||
) || "huawei".equals(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
public static boolean isBrandMeizu() {
|
||||
return "meizu".equals(
|
||||
Build.BRAND
|
||||
) || "meizu".equals(Build.MANUFACTURER) || "22c4185e".equals(
|
||||
Build.BRAND
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean isBrandOppo() {
|
||||
return "oppo".equalsIgnoreCase(Build.BRAND) || "oppo".equals(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
public static boolean isBrandOnePlus() {
|
||||
return "oneplus".equals(
|
||||
Build.BRAND
|
||||
) || "oneplus".equals(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
public static boolean isBrandVivo() {
|
||||
return "vivo".equals(
|
||||
Build.BRAND
|
||||
) || "vivo".equals(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isBrandHonor() {
|
||||
return "honor".equals(
|
||||
Build.BRAND
|
||||
) || "honor".equals(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
private static void toPermission(ComponentActivity context) {
|
||||
Intent intent =new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS") ;
|
||||
intent.setData(Uri.fromParts("package", context.getPackageName(), null));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private static void gotoOppoPermission(ComponentActivity context) {
|
||||
try {
|
||||
|
||||
Intent intent =new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("packageName", context.getPackageName());
|
||||
ComponentName comp =new ComponentName(
|
||||
"com.color.safecenter",
|
||||
"com.color.safecenter.permission.PermissionManagerActivity"
|
||||
);
|
||||
intent.setComponent(comp);
|
||||
context.startActivity(intent);
|
||||
} catch ( Exception e) {
|
||||
toPermission(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static void gotoMiuiPermission(ComponentActivity context) {
|
||||
Intent i = new Intent("miui.intent.action.APP_PERM_EDITOR");
|
||||
ComponentName componentName =new ComponentName(
|
||||
"com.miui.securitycenter",
|
||||
"com.miui.permcenter.permissions.PermissionsEditorActivity"
|
||||
);
|
||||
i.setComponent(componentName);
|
||||
i.putExtra("extra_pkgname", context.getPackageName());
|
||||
try {
|
||||
context.startActivity(i);
|
||||
} catch ( Exception e) {
|
||||
e.printStackTrace();
|
||||
toPermission(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static void gotoMeizuPermission(ComponentActivity context) {
|
||||
Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
|
||||
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
intent.putExtra("packageName", context.getPackageName());
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (java.lang.Exception e) {
|
||||
e.printStackTrace();
|
||||
toPermission(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static void gotoHuaweiPermission(ComponentActivity context) {
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ComponentName comp =new ComponentName(
|
||||
"com.huawei.systemmanager",
|
||||
"com.huawei.permissionmanager.ui.MainActivity"
|
||||
) ;//华为权限管理
|
||||
intent.setComponent(comp) ;
|
||||
context.startActivity(intent);
|
||||
} catch ( java.lang.Exception e) {
|
||||
e.printStackTrace();
|
||||
toPermission(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static void toAuthority(ComponentActivity context) {
|
||||
|
||||
if (isBrandXiaoMi()){
|
||||
gotoMiuiPermission(context);
|
||||
}else if (isBrandMeizu()){
|
||||
gotoMeizuPermission(context);
|
||||
}else if (isBrandHuawei()){
|
||||
gotoHuaweiPermission(context);
|
||||
}else if(isBrandOnePlus()){
|
||||
gotoOppoPermission(context);
|
||||
}else if (isBrandOppo()){
|
||||
gotoOppoPermission(context);
|
||||
}else {
|
||||
toPermission(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ifish.utils;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public class ClickUtil {
|
||||
|
||||
private static long lastClickTime;
|
||||
|
||||
public static boolean isFastDoubleClick() {
|
||||
return isFastDoubleClick(300);
|
||||
}
|
||||
|
||||
public static boolean isFastDoubleClick(long interval) {
|
||||
long time = System.currentTimeMillis();
|
||||
long timeD = time - lastClickTime;
|
||||
if (0 < timeD && timeD < interval) {
|
||||
lastClickTime = time;
|
||||
return true;
|
||||
}
|
||||
lastClickTime = time;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -121,6 +121,11 @@ public class HttpManager {
|
||||
public static String Company_PhoneNum = "18667812003";// 公司电话
|
||||
public static String BuyCameraTaobao_URL = "http://h5.m.taobao.com/awp/core/detail.htm?id=535991514644";// 购买摄像头淘宝网址
|
||||
|
||||
public static final String AirKissConnectVideoTitle = "一键联网";
|
||||
public static String AirKissConnectVideoUrl = "https://www.ifish7.com/download/s1.mp4"; //安卓版本的一键联网的视频
|
||||
public static final String APConnectVideoTitle = "AP联网";
|
||||
public static String APConnectVideoUrl = "https://www.ifish7.com/download/s2.mp4"; //安卓版本的 AP联网视频
|
||||
|
||||
private String user_URL = "user/";
|
||||
private String users_URL = "users/";
|
||||
public static String Room_URL = "room/";
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.ifish.utils;
|
||||
|
||||
import android.net.Uri;
|
||||
import com.squareup.picasso.Downloader;
|
||||
import com.squareup.picasso.NetworkPolicy;
|
||||
import java.io.IOException;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.CacheControl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.Request;
|
||||
|
||||
|
||||
public class ImageDownLoader implements Downloader {
|
||||
/* OkHttpClient client = new OkHttpClient.Builder()
|
||||
.protocols(Collections.singletonList(Protocol.HTTP_1_1))
|
||||
.build();*/
|
||||
private OkHttpClient client= null;
|
||||
|
||||
public ImageDownLoader(OkHttpClient okHttpClient) {
|
||||
this.client = okHttpClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response load(Uri uri, int networkPolicy) throws IOException {
|
||||
CacheControl cacheControl = null;
|
||||
if (networkPolicy != 0) {
|
||||
if (NetworkPolicy.isOfflineOnly(networkPolicy)) {
|
||||
cacheControl = CacheControl.FORCE_CACHE;
|
||||
} else {
|
||||
CacheControl.Builder builder = new CacheControl.Builder();
|
||||
if (!NetworkPolicy.shouldReadFromDiskCache(networkPolicy)) {
|
||||
builder.noCache();
|
||||
}
|
||||
if (!NetworkPolicy.shouldWriteToDiskCache(networkPolicy)) {
|
||||
builder.noStore();
|
||||
}
|
||||
cacheControl = builder.build();
|
||||
}
|
||||
}
|
||||
|
||||
Request.Builder builder = new Request.Builder().url(uri.toString());
|
||||
if (cacheControl != null) {
|
||||
builder.cacheControl(cacheControl);
|
||||
}
|
||||
|
||||
okhttp3.Response response = client.newCall(builder.build()).execute();
|
||||
int responseCode = response.code();
|
||||
if (responseCode >= 300) {
|
||||
response.body().close();
|
||||
throw new ResponseException(responseCode + " " + response.message(), networkPolicy,
|
||||
responseCode);
|
||||
}
|
||||
|
||||
boolean fromCache = response.cacheResponse() != null;
|
||||
|
||||
ResponseBody responseBody = response.body();
|
||||
return new Response(responseBody.byteStream(), fromCache, responseBody.contentLength());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
||||
Cache cache = client.cache();
|
||||
if (cache != null) {
|
||||
try {
|
||||
cache.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.ifish.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
/**
|
||||
* key-value 工具类,包装微信MMKV
|
||||
*
|
||||
* @Company SINA
|
||||
* Created by chenyuebo on 2019/5/16.
|
||||
*/
|
||||
public class KVUtil {
|
||||
|
||||
public static void init(Context context) {
|
||||
// 初始化微信key-value 组件,默认设定 MMKV 的根目录(files/mmkv/)
|
||||
MMKV.initialize(context.getApplicationContext());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static MMKV getMmkv() {
|
||||
return MMKV.defaultMMKV(MMKV.MULTI_PROCESS_MODE, null);
|
||||
}
|
||||
|
||||
public static String getString(String key, String defValue) {
|
||||
return getMmkv().getString(key, defValue);
|
||||
}
|
||||
|
||||
public static String getString(String key) {
|
||||
return getString(key, null);
|
||||
}
|
||||
|
||||
|
||||
public static void setString(String key, String value) {
|
||||
getMmkv().encode(key, value);
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key, boolean defValue) {
|
||||
return getMmkv().decodeBool(key, defValue);
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key) {
|
||||
return getMmkv().decodeBool(key);
|
||||
}
|
||||
|
||||
public static void setBoolean(String key, boolean value) {
|
||||
getMmkv().encode(key, value);
|
||||
}
|
||||
|
||||
public static long getLong(String key, long defValue) {
|
||||
return getMmkv().decodeLong(key, defValue);
|
||||
}
|
||||
|
||||
public static void setLong(String key, long value) {
|
||||
getMmkv().encode(key, value);
|
||||
}
|
||||
|
||||
public static float getFloat(String key, float defValue) {
|
||||
return getMmkv().decodeFloat(key, defValue);
|
||||
}
|
||||
|
||||
public static void setFloat(String key, float value) {
|
||||
getMmkv().encode(key, value);
|
||||
}
|
||||
|
||||
public static int getInt(String key, int defValue) {
|
||||
return getMmkv().decodeInt(key, defValue);
|
||||
}
|
||||
|
||||
public static int getInt(String key) {
|
||||
return getMmkv().decodeInt(key);
|
||||
}
|
||||
|
||||
public static void setInt(String key, int value) {
|
||||
getMmkv().encode(key, value);
|
||||
}
|
||||
|
||||
public static void removeValueForKey(String key) {
|
||||
getMmkv().removeValueForKey(key);
|
||||
}
|
||||
|
||||
public static void removeValuesForKeys(String[] keys) {
|
||||
getMmkv().removeValuesForKeys(keys);
|
||||
}
|
||||
|
||||
public static boolean containsKey(String key) {
|
||||
return getMmkv().containsKey(key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ifish.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.GlideBuilder;
|
||||
import com.bumptech.glide.Registry;
|
||||
import com.bumptech.glide.annotation.GlideModule;
|
||||
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
import com.bumptech.glide.module.AppGlideModule;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@GlideModule
|
||||
public class OkHttpAppGlideModule extends AppGlideModule {
|
||||
|
||||
@Override
|
||||
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
|
||||
super.applyOptions(context, builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
|
||||
super.registerComponents(context, glide, registry);
|
||||
//设置请求方式为okhttp 并设置okhttpClient的证书及超时时间
|
||||
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(UnsafeOkHttpClient.getUnsafeOkHttpClient());
|
||||
registry.replace(GlideUrl.class, InputStream.class,factory);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,11 @@ public class ToastUtil {
|
||||
public static void show( Context context,CharSequence text) {
|
||||
showToast(context.getApplicationContext(),text, false);
|
||||
}
|
||||
|
||||
public static void showLong( Context context,CharSequence text) {
|
||||
showLongToast(context.getApplicationContext(),text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 特殊情况显示的toast
|
||||
*/
|
||||
@@ -92,6 +97,16 @@ public class ToastUtil {
|
||||
tipToast.show();
|
||||
}
|
||||
|
||||
public static void showLongToast(Context context, CharSequence message) {
|
||||
if (tipToast == null) {
|
||||
tipToast = TipsToast.makeText(context, message, Toast.LENGTH_LONG);
|
||||
} else {
|
||||
tipToast.setText(message);
|
||||
}
|
||||
// tipToast.setIsShowIco(isShowIco);
|
||||
tipToast.show();
|
||||
}
|
||||
|
||||
// public static void showToast(int message) {
|
||||
// showToast(BaseApplication.getInstance().getString(message), false);
|
||||
// }
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ifish.utils;
|
||||
|
||||
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
|
||||
|
||||
|
||||
public class TrustAllCerts implements X509TrustManager {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {return new X509Certificate[0];}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ifish.utils;
|
||||
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class UnsafeOkHttpClient {
|
||||
public static OkHttpClient getUnsafeOkHttpClient() {
|
||||
try {
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return new java.security.cert.X509Certificate[]{};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Install the all-trusting trust manager
|
||||
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
|
||||
// Create an ssl socket factory with our all-trusting manager
|
||||
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]);
|
||||
builder.hostnameVerifier(new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
builder.connectTimeout(20, TimeUnit.SECONDS);
|
||||
builder.readTimeout(20,TimeUnit.SECONDS);
|
||||
|
||||
OkHttpClient okHttpClient = builder.build();
|
||||
return okHttpClient;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate
|
||||
android:duration="300"
|
||||
android:fromYDelta="100%"
|
||||
android:toYDelta="0" />
|
||||
<!-- <alpha-->
|
||||
<!-- android:duration="300"-->
|
||||
<!-- android:fromAlpha="0.0"-->
|
||||
<!-- android:toAlpha="1.0" />-->
|
||||
</set>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate
|
||||
android:duration="300"
|
||||
android:fromYDelta="0"
|
||||
android:toYDelta="100%"/>
|
||||
<!-- <alpha-->
|
||||
<!-- android:duration="300"-->
|
||||
<!-- android:fromAlpha="1.0"-->
|
||||
<!-- android:toAlpha="0.0"/>-->
|
||||
</set>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="false" android:drawable="@drawable/connect_device_normal" />
|
||||
<item android:state_pressed="true" android:drawable="@drawable/connect_device_pressed" />
|
||||
</selector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#65C2C2" />
|
||||
<corners android:radius="6dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#5ab3b3" />
|
||||
<corners android:radius="6dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/white"/>
|
||||
<corners android:radius="10dp"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,214 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
android:id="@+id/in_daohang"
|
||||
layout="@layout/title_layout" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
android:paddingBottom="50dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_connect_video"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="联网视频"
|
||||
android:textColor="#E60012"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_connect_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="18dp"
|
||||
android:text="一键联网"
|
||||
android:textColor="@color/shoplist_text_item"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!--选择路由器-->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:text="选择路由器WIFI"
|
||||
android:textColor="#3E3A39" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.1dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="#efedee" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_wifi"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="WIFI"
|
||||
android:textColor="#3E3A39" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_wifi_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_weight="1"
|
||||
android:text="请输入WiFi名称"
|
||||
android:textColor="#999999"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.1dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="#efedee" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="密码"
|
||||
android:textColor="#3E3A39" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tv_wifi_pwd"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:hint="请输入WiFi密码"
|
||||
android:textColor="#999999"
|
||||
android:textColorHint="#999999"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.1dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="#efedee" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tips"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:lineSpacingExtra="5dp"
|
||||
android:text="1、插座仅支持2.4G的WiFi网络,不支持5G及双频合一的网络(需在路由器设置中分开)"
|
||||
android:textColor="#999999" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tips2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:lineSpacingExtra="5dp"
|
||||
android:text="2、先长按插座复位键3秒,松手后红灯绿灯同时闪烁以后,再点确定按钮。"
|
||||
android:textColor="#E60012" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tips3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:lineSpacingExtra="5dp"
|
||||
android:text="3、如多次尝试一键联网都不成功,可切换其他联网方式,每次重新联接时插座需断一次电然后重新复位联接。"
|
||||
android:textColor="#999999" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_other_connect"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="25dp"
|
||||
android:padding="6dp"
|
||||
android:text="其他联网方式"
|
||||
android:textColor="@color/shoplist_text_item"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_click_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="40dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginRight="40dp"
|
||||
android:background="@drawable/login_button_select"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="确定"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp"
|
||||
tools:context=".PhoneInfoActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="设备信息"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvModel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="设备型号:" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="网络信息"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvNetworkInfo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="网络情况:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWifiInfo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="WiFi信息:" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/test_airkiss"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="test_airkiss" />
|
||||
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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="wrap_content"
|
||||
android:background="@drawable/white_radius10"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/line_airKiss"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_airkiss"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:text="一键联网"
|
||||
android:textColor="#3E3A39"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="#efedee" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/line_smartConfig"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_smartConfig"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:text="快捷联网"
|
||||
android:textColor="#3E3A39"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="#efedee" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/line_AP"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_AP"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:text="AP联网"
|
||||
android:textColor="#3E3A39"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="#efedee" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:gravity="center"
|
||||
android:text="取消"
|
||||
android:textColor="#3E3A39"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -7,7 +7,7 @@
|
||||
android:id="@+id/in_daohang"
|
||||
layout="@layout/title_layout" />
|
||||
<com.ifish.view.SwipeRefreshLayout
|
||||
android:id="@+id/sw_SwipeRefreshLayout "
|
||||
android:id="@+id/sw_SwipeRefreshLayout"
|
||||
android:layout_below="@id/in_daohang"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
android:id="@+id/in_daohang"
|
||||
layout="@layout/title_layout" />
|
||||
<com.ifish.view.SwipeRefreshLayout
|
||||
android:id="@+id/sw_SwipeRefreshLayout "
|
||||
android:id="@+id/sw_SwipeRefreshLayout"
|
||||
android:layout_below="@id/in_daohang"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -282,5 +282,16 @@
|
||||
android:src="@drawable/ic_back_right_black" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_debug"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/mine_fragment_item"
|
||||
android:layout_marginTop="@dimen/mine_fragment_gray_size"
|
||||
android:text="手机环境"
|
||||
android:visibility="gone"
|
||||
android:textSize="17sp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/minefragment_bg_select"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -72,4 +72,8 @@
|
||||
<string name="day">日</string>
|
||||
<string name="hour">时</string>
|
||||
<string name="minute">分</string>
|
||||
|
||||
<string name="ap_connect_tip1">1、点击连接设备按钮以后,请耐心等待连接,如提示设备连接失败,请将插座断一次电,然后重新长按复位键13秒左右,再点连接设备</string>
|
||||
<string name="ap_connect_tip2">2、设备连接成功后会进入插座控制界面,过几秒当温度出现时,表示插座联网成功。</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -258,4 +258,15 @@
|
||||
<item name="android:windowExitAnimation">@anim/actionsheet_dialog_out</item>
|
||||
</style>
|
||||
|
||||
<style name="CustomDatePickerDialog" parent="@style/MyAppTheme">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
</style>
|
||||
|
||||
<style name="BottomDialogAnimation">
|
||||
<item name="android:windowEnterAnimation">@anim/bottom_dialog_in</item>
|
||||
<item name="android:windowExitAnimation">@anim/bottom_dialog_out</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -15,4 +15,5 @@
|
||||
10.友盟分享初始化逻辑变更,初始化分为预先初始化和正式初始化
|
||||
11.下载功能适配android12+,解决高版本安卓手机无法更新APK的问题
|
||||
|
||||
12.增加阿里云镜像,版本控制移除local.pro
|
||||
12.增加阿里云镜像,版本控制移除local.pro
|
||||
13.增加airkiss,注意在发送前AirKissEncoder只能实例化一次,确保发送的随机数和接受的时候用来比较的随机数要保持一致
|
||||
+6
-1
@@ -8,4 +8,9 @@
|
||||
2.在gitlab上添加自己的ssh
|
||||
注意,android studio - settings -Version Control - git -- 一定要勾选上use credential helper !!! 不然是无法push代码到gitlab的
|
||||
|
||||
3.android studio 版本不要太新,使用 2021.2.1 patch 2即可
|
||||
3.android studio 版本不要太新,使用 2021.2.1 patch 2即可
|
||||
|
||||
4.!!! Android Studio Dolphin | 2021.3.1 Patch 1 //使用这个版本可以解决升级到33,XML布局文件无法自动提示的问题
|
||||
5.如果要使用MMKV注意要引入so库,不然会在低版本安卓手机上运行崩溃
|
||||
|
||||
6.开发分支是dev_1.0.0,master分支上有userid需求的代码,所以不要使用master分支
|
||||
Reference in New Issue
Block a user