This commit is contained in:
cyw
2026-02-13 14:34:15 +08:00
parent 6ed1953e24
commit f36e3f9df2
5206 changed files with 573757 additions and 16 deletions

9
proj.android/.classpath Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.andmore.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="org.eclipse.andmore.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="org.eclipse.andmore.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

263
proj.android/.cproject Normal file
View File

@@ -0,0 +1,263 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.1230402123">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1230402123" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1230402123" name="Release" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.1230402123." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1911072326" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1911072326.2087917918" name=""/>
<builder arguments="-j6 NDK_DEBUG=1" buildPath="${ProjDirPath}" command="${NDKROOT}/ndk-build.cmd" id="org.eclipse.cdt.build.core.settings.default.builder.1038735572" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder">
<outputEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name=""/>
</outputEntries>
</builder>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.547532631" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.1481118451" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.990682174" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.387417389" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.992559344" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.429561268" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1008860290" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
<listOptionValue builtIn="false" value="${NDK_ROOT}/platforms/android-18/arch-arm/usr/include"/>
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.8/include"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/2d"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/physics"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/base"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/math/kazmath"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/ui"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/network"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/audio/include"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/editor-support"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/extensions"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/external"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/external/chipmunk/include/chipmunk"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.1728671637" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.788524757" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.795443271" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.315092538" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.706119994" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1846971482" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="cocos2d|Classes" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Classes"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="cocos2d"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="0.1377291156">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1230402123.1377291156" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1230402123.1377291156" name="Debug" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.1230402123.1377291156." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.201833538" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.201833538.235980614" name=""/>
<builder arguments="${ProjDirPath}/build_native.py -b debug" buildPath="${ProjDirPath}" command="python" id="org.eclipse.cdt.build.core.settings.default.builder.1949248716" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder">
<outputEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name=""/>
</outputEntries>
</builder>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.813839891" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.766422923" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.658464030" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.402466199" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.930232989" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.55647957" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.814113654" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
<listOptionValue builtIn="false" value="${NDK_ROOT}/platforms/android-18/arch-arm/usr/include"/>
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.8/include"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/2d"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/physics"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/base"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/math/kazmath"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/ui"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/network"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/audio/include"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/editor-support"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/extensions"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/external"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/external/chipmunk/include/chipmunk"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.923561092" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.383151501" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.2139448747" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.715095106" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.157274928" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.108662290" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="Classes|cocos2d" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Classes"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="cocos2d"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="0.1230402123.1377291156">
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1230402123.1377291156" name="Debug" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.1230402123.1377291156." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.201833538" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.201833538.235980614" name=""/>
<builder arguments="${ProjDirPath}/build_native.py -b debug" buildPath="${ProjDirPath}" command="python" id="org.eclipse.cdt.build.core.settings.default.builder.1949248716" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder">
<outputEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name=""/>
</outputEntries>
</builder>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.813839891" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.766422923" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.658464030" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.402466199" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.930232989" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.55647957" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.814113654" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
<listOptionValue builtIn="false" value="${NDK_ROOT}/platforms/android-18/arch-arm/usr/include"/>
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.8/include"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/2d"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/physics"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/base"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/math/kazmath"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/ui"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/network"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/audio/include"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/cocos/editor-support"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/extensions"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/external"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../cocos2d/external/chipmunk/include/chipmunk"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.923561092" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.383151501" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.2139448747" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.715095106" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="${NDK_ROOT}/sources/android/native_app_glue"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.157274928" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CC_TARGET_PLATFORM=CC_PLATFORM_ANDROID"/>
<listOptionValue builtIn="false" value="CC_DLL"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.108662290" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="cocos2d|Classes" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Classes"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="cocos2d"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1230402123.1377291156" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.1230402123">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="GameBase.null.31159645" name="GameBase"/>
</storageModule>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/GameBase"/>
</configuration>
<configuration configurationName="Release"/>
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/GameBase"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

127
proj.android/.project Normal file
View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GameClient</name>
<comment></comment>
<projects>
<project>libcocos2dx</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?children?</key>
<value>?children?=?name?=entry\\\\\\\|\\\|\|?name?=outputEntries\||</value>
</dictionary>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value>-j6 NDK_DEBUG=1</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>${NDKROOT}/ndk-build.cmd</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${ProjDirPath}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>false</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.andmore.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.andmore.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.andmore.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.andmore.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>Classes</name>
<type>2</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/Classes</locationURI>
</link>
<link>
<name>cocos2d</name>
<type>2</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/cocos2d</locationURI>
</link>
<link>
<name>libcocos2d</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/cocos2d/cocos/platform/android/java/src</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jxkh.queyi"
android:versionCode="16"
android:versionName="1.0.16"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="14"/>
<uses-feature android:glEsVersion="0x00020000" />
<application android:label="@string/app_name"
android:icon="@drawable/icon">
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="cocos2dcpp" />
<activity android:name=".AppActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="com.jxkh.queyi" android:scheme="ysrunapp"/>
</intent-filter>
</activity>
<activity
android:name=".wxapi.WXEntryActivity"
android:label="@string/app_name"
android:exported="true"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Translucent"
/>
<activity android:name=".sgapi.SGShareActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:screenOrientation="portrait">
</activity>
<activity android:name=".sgapi.SGEntryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:screenOrientation="portrait">
<!--用于接收从闲聊邀请跳转进应用的roomId roomToken-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<!--scheme = "paraches" 固定不能改变host = "xianliao"+ 你申请的appId-->
<data android:scheme="paraches"
android:host="xianliaorrqu5DQlY7lMO5mx"/>
</intent-filter>
</activity>
<meta-data android:name="TencentMapSDK" android:value="43CBZ-XFWW5-IDEIY-QV4ZR-PBOZK-5SBDL" />
<service android:name="com.pg.core.sdk.lib.YayaService"/>
</application>
<supports-screens android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- 通过GPS得到精确位置 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 通过网络得到粗略位置 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- 修改WiFi状态. 发起WiFi扫描, 需要WiFi信息用于网络定位 -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<!-- 访问网络的变化, 需要某些信息用于网络定位 -->
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
</manifest>

Binary file not shown.

View File

@@ -0,0 +1,21 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.
key.alias.password=sqys2016
key.store.password=sqys2016
key.store=android.keystore
key.alias=android.keystore

View File

@@ -0,0 +1,13 @@
{
"ndk_module_path" :[
"../../../cocos2d",
"../../../cocos2d/cocos",
"../../../cocos2d/external"
],
"copy_resources": [
{
"from": "../Resources",
"to": ""
}
]
}

83
proj.android/build.xml Normal file
View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="GameClient" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@@ -0,0 +1,43 @@
#!/usr/bin/python
# build_native.py
# Build native codes
#
# Please use cocos console instead
import sys
import os, os.path
import shutil
from optparse import OptionParser
def build(build_mode):
current_dir = os.path.dirname(os.path.realpath(__file__))
cocos_root = os.path.join(current_dir, "../cocos2d")
app_android_root = os.path.join(current_dir, "../")
if build_mode is None:
build_mode = 'debug'
elif build_mode != 'release':
build_mode = 'debug'
command = 'cocos compile -p android -s %s -m %s' % (app_android_root, build_mode)
if os.system(command) != 0:
raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
# -------------- main --------------
if __name__ == '__main__':
parser = OptionParser()
parser.add_option("-n", "--ndk", dest="ndk_build_param", help='it is not used', action="append")
parser.add_option("-p", "--platform", dest="android_platform",
help='it is not used')
parser.add_option("-b", "--build", dest="build_mode",
help='the build mode for java project,debug[default] or release.Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html')
(opts, args) = parser.parse_args()
print "Please use cocos console instead.\n"
build(opts.build_mode)

View File

@@ -0,0 +1,94 @@
LOCAL_PATH := $(call my-dir)
######################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := libtencentloc
LOCAL_SRC_FILES := ../../libs/TencentLocation/$(TARGET_ARCH_ABI)/libtencentloc.so
include $(PREBUILT_SHARED_LIBRARY)
#######################################################################
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../..)
$(call import-add-path,$(LOCAL_PATH)/../../../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_SHARED_LIBRARIES += libYvImSdk
LOCAL_MODULE_FILENAME := libcocos2dcpp
FILE_LIST := hellocpp/main.cpp
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/GameFrame/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/JniCross/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Network/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Global/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Define/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Mission/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Utils/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Utils/crypt/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Utils/crypt/base/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Scenes/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Games/SparrowBase/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Games/WNMJ/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Games/DDZ/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Games/NiuNiu/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Games/DaZha/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Games/13S/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Games/ZJH/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Games/PDK/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Voice/YunVaSDK/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/Voice/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
$(LOCAL_PATH)/../../Classes/GameFrame \
$(LOCAL_PATH)/../../Classes/JniCross \
$(LOCAL_PATH)/../../Classes/Network \
$(LOCAL_PATH)/../../Classes/Global \
$(LOCAL_PATH)/../../Classes/Define \
$(LOCAL_PATH)/../../Classes/Mission \
$(LOCAL_PATH)/../../Classes/Interface \
$(LOCAL_PATH)/../../Classes/Utils \
$(LOCAL_PATH)/../../Classes/Utils/crypt \
$(LOCAL_PATH)/../../Classes/Utils/crypt/base \
$(LOCAL_PATH)/../../Classes/Scenes \
$(LOCAL_PATH)/../../Classes/Games/WNMJ \
$(LOCAL_PATH)/../../Classes/Games/DDZ \
$(LOCAL_PATH)/../../Classes/Games/DaZha \
$(LOCAL_PATH)/../../Classes/Games/NiuNiu \
$(LOCAL_PATH)/../../Classes/Games/13S \
$(LOCAL_PATH)/../../Classes/Games/ZJH \
$(LOCAL_PATH)/../../Classes/Games/PDK \
$(LOCAL_PATH)/../../Classes/Games/SparrowBase \
$(LOCAL_PATH)/../../Classes/Voice \
$(LOCAL_PATH)/../../Classes/Voice/YunVaSDK \
$(LOCAL_PATH)/../../IM_SDK/include
# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END
LOCAL_LDFLAGS := -Wl,--allow-multiple-definition
LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_STATIC_LIBRARIES += android_support
LOCAL_STATIC_LIBRARIES += libtencentloc
# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
$(call import-module,IM_SDK)
$(call import-module,android/support)
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

View File

@@ -0,0 +1,18 @@
APP_STL := gnustl_static
#TARGET_CPU_API := armeabi-v7a
#APP_ABI := armeabi-v7a
#APP_PLATFORM := android-14
APP_CFLAGS += -Wno-error=format-security
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
APP_LDFLAGS := -latomic
ifeq ($(NDK_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif

View File

@@ -0,0 +1,15 @@
#include "AppDelegate.h"
#include "cocos2d.h"
#include "platform/android/jni/JniHelper.h"
#include <jni.h>
#include <android/log.h>
#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,10 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=G:\\cocos\\Android\\android-sdk

View File

@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-14
android.library=false
android.library.reference.1=../../../cocos2d/cocos/platform/android/java

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">雀奕</string>
</resources>

View File

@@ -0,0 +1,200 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package com.jxkh.queyi;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import android.content.Intent;
import android.net.Uri;
import android.os.*;
import android.util.Log;
import com.jxkh.queyi.common.MainActivityHolder;
import com.tencent.map.geolocation.TencentLocation;
import com.tencent.map.geolocation.TencentLocationListener;
import com.tencent.map.geolocation.TencentLocationManager;
import com.tencent.map.geolocation.TencentLocationRequest;
public class AppActivity extends Cocos2dxActivity implements TencentLocationListener {
private Handler mHandler;
private HandlerThread mThread;
private TencentLocationManager mLocationManager;
static
{
System.loadLibrary("YvImSdk");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MainActivityHolder.setMainActivity(this);
// ysrunapp://com.jxkh.queyi
// scheme host
Uri uri = getIntent().getData();
if ( uri!=null )
{
String scheme = uri.getScheme();
String host = uri.getHost();
if (scheme.equals("ysrunapp")&&host.equals("com.jxkh.queyi"))
{
//Uri mUri = Uri.parse(scheme+uri.getSchemeSpecificPart());
String strParam = uri.getQueryParameter("param");
Native.strAppRunParam = strParam;
}
}
com.yunva.im.sdk.lib.YvLoginInit.initApplicationOnCreate(this.getApplication(), "1003394");
mThread = new HandlerThread("Thread_demo_" + (int) (Math.random() * 10));
mThread.start();
mHandler = new Handler(mThread.getLooper());
mLocationManager = TencentLocationManager.getInstance(this);
// 设置坐标系为 gcj-02, 缺省坐标为 gcj-02, 所以通常不必进行如下调用
mLocationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02);
}
@Override
protected void onDestroy() {
super.onDestroy();
/**
* 注意, 本示例中 requestLocationUpdates 和 removeUpdates 都可能被多次重复调用.
* <p>
* 重复调用 requestLocationUpdates, 将忽略之前的 reqest 并自动取消之前的 listener, 并使用最新的
* request 和 listener 继续定位
* <p>
* 重复调用 removeUpdates, 将定位停止
*/
//com.yunva.im.sdk.lib.YvLoginInit.release();
// 退出 activity 前一定要停止定位!
stopLocation();
// 清空
mHandler.removeCallbacksAndMessages(null);
// 停止线程
mThread.getLooper().quit();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
// 响应点击"停止"
public void stopLocation() {
mLocationManager.removeUpdates(this);
updateLocationStatus("停止定位");
}
// 响应点击"开始"
public void startLocation() {
// 创建定位请求
final TencentLocationRequest request = TencentLocationRequest.create();
// 修改定位请求参数, 定位周期 3000 ms
request.setInterval(60000);
// 在 mThread 线程发起定位
mHandler.post(new Runnable() {
@Override
public void run() {
mLocationManager.requestLocationUpdates(request, AppActivity.this);
}
});
updateLocationStatus("开始定位: " + request);
}
public void clearStatus() {
}
// ====== view listener
// ====== location callback
@Override
public void onLocationChanged(TencentLocation location, int error,
String reason) {
if (error == TencentLocation.ERROR_OK) {
// 定位成功
StringBuilder sb = new StringBuilder();
//sb.append("(纬度=").append(location.getLatitude()).append(",经度=")
// .append(location.getLongitude()).append(",精度=")
// .append(location.getAccuracy()).append("), 来源=")
// .append(location.getProvider()).append(", 地址=")
// .append(location.getAddress());
//sb.append(", 当前线程=" + threadName);
sb.append("{\"ret\":true, \"latitude\":").append(location.getLatitude()).append(",\"longitude\":")
.append(location.getLongitude()).append(",\"accuracy\":")
.append(location.getAccuracy()).append(", \"provider\":\"")
.append(location.getProvider()).append("\", \"address\":\"")
.append(location.getAddress()).append("\"}");
Native.strLocation = sb.toString();
} else {
// 定位失败
Native.strLocation = "{ret:false, reason: \"" + reason + " \" }";
}
// 注意! 如果 onLocationChanged 不是在主线程中回调, 一定不要直接修改 UI
Log.d("Location:", Native.strLocation);
Cocos2dxGLSurfaceView.getInstance().queueEvent(new Runnable() {
public void run() {
Native.onLocationChanged(Native.strLocation);
}
});
}
@Override
public void onStatusUpdate(String name, int status, String desc) {
// ignore
}
// ====== location callback
private void updateLocationStatus(String message) {
}
}

View File

@@ -0,0 +1,219 @@
package com.jxkh.queyi;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxHelper;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;
import com.jxkh.queyi.wxapi.*;
import com.jxkh.queyi.common.*;
import com.jxkh.queyi.sgapi.SGShareActivity;
import com.tencent.map.geolocation.TencentLocationUtils;
public class Native extends Cocos2dxHelper
{
public static native void WxLoginGetAccessToken(String kUrl);
public static native void WxLoginGetFailToken(String Error);
public static native void onLocationChanged(String strJson);
public static String strAppRunParam;
public static String strLocation;
public static void LoginWX(String APP_ID,String AppSecret)
{
Intent intent = new Intent(Cocos2dxActivity.getContext(), WXEntryActivity.class);
intent.putExtra(WXEntryActivity.ReqWxLogin,"wxlogin");
Cocos2dxActivity.getContext().startActivity(intent);
}
public static void ShareImageWX(String ImgPath,int nType)
{
Intent intent = new Intent(Cocos2dxActivity.getContext(), WXEntryActivity.class);
intent.putExtra(WXEntryActivity.ReqWxShareImg,"ReqWxShareImg");
intent.putExtra("ImgPath",ImgPath);
intent.putExtra("ShareType",nType);
Cocos2dxActivity.getContext().startActivity(intent);
}
public static void ShareTextWX(String text,int nType)
{
Intent intent = new Intent(Cocos2dxActivity.getContext(), WXEntryActivity.class);
intent.putExtra(WXEntryActivity.ReqWxShareTxt,"ReqWxShareTxt");
intent.putExtra("ShareText",text);
intent.putExtra("ShareType",nType);
Cocos2dxActivity.getContext().startActivity(intent);
}
public static void ShareUrlWX(String url,String title,String desc,int nType)
{
Intent intent = new Intent(Cocos2dxActivity.getContext(), WXEntryActivity.class);
intent.putExtra(WXEntryActivity.ReqWxShareUrl,"ReqWxShareUrl");
intent.putExtra("ShareUrl",url);
intent.putExtra("ShareTitle",title);
intent.putExtra("ShareDesc",desc);
intent.putExtra("ShareType",nType);
Cocos2dxActivity.getContext().startActivity(intent);
}
// 闲聊分享
public static void ShareImageXL(String ImgPath, int nType) {
Intent intent = new Intent(Cocos2dxActivity.getContext(), SGShareActivity.class);
intent.putExtra(SGShareActivity.ReqXLShareImg, "ReqXLShareImg");
intent.putExtra("ImgPath", ImgPath);
intent.putExtra("ShareType", nType);
Cocos2dxActivity.getContext().startActivity(intent);
}
public static void ShareTextXL(String text, int nType) {
Intent intent = new Intent(Cocos2dxActivity.getContext(), SGShareActivity.class);
intent.putExtra(SGShareActivity.ReqXLShareTxt, "ReqXLShareTxt");
intent.putExtra("ShareText", text);
intent.putExtra("ShareType", nType);
Cocos2dxActivity.getContext().startActivity(intent);
}
public static void ShareUrlXL(String url, String title, String desc, int nType) {
Intent intent = new Intent(Cocos2dxActivity.getContext(), SGShareActivity.class);
intent.putExtra(SGShareActivity.ReqXLShareUrl, "ReqXLShareUrl");
intent.putExtra("ShareUrl", url);
intent.putExtra("ShareTitle", title);
intent.putExtra("ShareDesc", desc);
intent.putExtra("ShareType", nType);
Cocos2dxActivity.getContext().startActivity(intent);
}
public static void showWebView(final String kUrl)
{
Log.d("showWebView",kUrl);
MainActivityHolder.getMainActivity().runOnUiThread(new Runnable() {
public void run()
{
Uri uri = Uri.parse(kUrl);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
Cocos2dxActivity.getContext().startActivity(it);
}
});
}
public static void versionUpdate(final String url, final String info,final int size, final int isUpdate)
{
downloadNewApk(info, url);
}
public static void startSoundRecord()
{
String SoundFilePath= Environment.getExternalStorageDirectory().getAbsolutePath();
String SoundFileName = "soundRecord.wav";
Log.d("startSoundRecord",SoundFilePath);
ExtAudioRecorder recorder = ExtAudioRecorder.getInstanse(false);
recorder.recordChat(SoundFilePath+"/",SoundFileName);
}
public static String stopSoundRecord()
{
return ExtAudioRecorder.stopRecord();
}
//获取启动参数
public static String getRunParam()
{
String strTemp = strAppRunParam;
strAppRunParam = "";
return strTemp;
}
//获取版本名
public static String getVersionName() {
try {
PackageManager manager = MainActivityHolder.getMainActivity().getPackageManager();
PackageInfo info = manager.getPackageInfo(MainActivityHolder.getMainActivity().getPackageName(), 0);
return info.versionName;
} catch (Exception e) {
e.printStackTrace();
}
return "1.0";
}
//获取版本号
public static int getVersionCode() {
try {
PackageManager manager = MainActivityHolder.getMainActivity().getPackageManager();
PackageInfo info = manager.getPackageInfo(MainActivityHolder.getMainActivity().getPackageName(), 0);
return info.versionCode;
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
//app名称
public static String getAppName() {
return "雀奕";
}
/**
* 检测下载新版本
* @param apkUrl
*/
public static void downloadNewApk(final String updateDesc, final String apkUrl ){
MainActivityHolder.getMainActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivityHolder.getMainActivity());
String desc = updateDesc.replaceAll("$", "\n");
builder.setMessage(desc);
builder.setCancelable(false);
builder.setNegativeButton("立即升级",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
dialog.dismiss();
AsyncDownloadApkTask downApkTask = new AsyncDownloadApkTask();
downApkTask.execute(apkUrl);
}
});
builder.setPositiveButton("稍后再说",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
dialog.dismiss();
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainActivityHolder.getMainActivity().startActivity(startMain);
System.exit(0);
}
});
builder.show();
}
});
}
public static void startLocation(){
AppActivity app = (AppActivity)MainActivityHolder.getMainActivity();
app.startLocation();
}
public static void stopLocation() {
AppActivity app = (AppActivity)MainActivityHolder.getMainActivity();
app.stopLocation();
}
public static double distanceBetween(double aLatitude, double aLongitude, double bLatitude, double bLongitude) {
return TencentLocationUtils.distanceBetween(aLatitude, aLongitude, bLatitude, bLongitude);
}
}

View File

@@ -0,0 +1,90 @@
package com.jxkh.queyi.common;
import java.io.File;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
public class AsyncDownloadApkTask extends AsyncTask<String, Integer, Void> {
private ProgressDialog dialog = null;
private String destFilePath = "";
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
dialog.dismiss();
MainActivityHolder.getMainActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(destFilePath)), "application/vnd.android.package-archive");
MainActivityHolder.getMainActivity().startActivity(intent);
}
});
}
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(MainActivityHolder.getMainActivity());
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setTitle("下载新版本");
dialog.setMessage("玩儿命下载中...");
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
dialog.setButton("退出", new ExitDialogListener());
dialog.setProgress(0);
dialog.setMax(100);
dialog.show();
}
@Override
protected void onProgressUpdate(Integer... values) {
// TODO Auto-generated method stub
super.onProgressUpdate(values);
dialog.setProgress(values[0]);
}
@Override
protected Void doInBackground(String... params) {
// sd卡根目录
String rootPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/yskj_game/";
String apkUrl = params[0];
String fileName = apkUrl.substring(apkUrl.lastIndexOf("/")+1);
final String destFile = rootPath + "/apks/" + fileName;
destFilePath = destFile;
YSHttpClient.download(apkUrl, destFile,
new YSHttpClient.IProgressListener() {
@Override
public void update(long now, long total) {
publishProgress((int) (now * 100 / total));
}
});
return null;
}
// Button的监听器类
class ExitDialogListener implements DialogInterface.OnClickListener {
@Override
public void onClick(DialogInterface dialog, int which) {
// 点击“退出”按钮取消对话框
dialog.cancel();
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainActivityHolder.getMainActivity().startActivity(startMain);
System.exit(0);
}
}
}

View File

@@ -0,0 +1,535 @@
package com.jxkh.queyi.common;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.media.MediaRecorder.AudioSource;
import android.util.Log;
public class ExtAudioRecorder {
private final static int[] sampleRates = { 44100, 22050, 11025, 8000 };
private static ExtAudioRecorder result = null;
public static ExtAudioRecorder getInstanse(Boolean recordingCompressed) {
if (recordingCompressed) {
result = new ExtAudioRecorder(false, AudioSource.MIC,
sampleRates[3], AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT);
} else {
int i = 3;
do {
result = new ExtAudioRecorder(true, AudioSource.MIC,
sampleRates[i], AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT);
} while ((++i < sampleRates.length)
& !(result.getState() == ExtAudioRecorder.State.INITIALIZING));
}
return result;
}
/**
* INITIALIZING : recorder is initializing; READY : recorder has been
* initialized, recorder not yet started RECORDING : recording ERROR :
* reconstruction needed STOPPED: reset needed
*/
public enum State {
INITIALIZING, READY, RECORDING, ERROR, STOPPED
};
public static final boolean RECORDING_UNCOMPRESSED = true;
public static final boolean RECORDING_COMPRESSED = false;
// The interval in which the recorded samples are output to the file
// Used only in uncompressed mode
private static final int TIMER_INTERVAL = 120;
// Toggles uncompressed recording on/off; RECORDING_UNCOMPRESSED /
// RECORDING_COMPRESSED
private boolean rUncompressed;
// Recorder used for uncompressed recording
private AudioRecord audioRecorder = null;
// Recorder used for compressed recording
private MediaRecorder mediaRecorder = null;
// Stores current amplitude (only in uncompressed mode)
private int cAmplitude = 0;
// Output file path
private String filePath = null;
// Recorder state; see State
private State state;
// File writer (only in uncompressed mode)
private RandomAccessFile randomAccessWriter;
// Number of channels, sample rate, sample size(size in bits), buffer size,
// audio source, sample size(see AudioFormat)
private short nChannels;
private int sRate;
private short bSamples;
private int bufferSize;
private int aSource;
private int aFormat;
// Number of frames written to file on each output(only in uncompressed
// mode)
private int framePeriod;
// Buffer for output(only in uncompressed mode)
private byte[] buffer;
// Number of bytes written to file after header(only in uncompressed mode)
// after stop() is called, this size is written to the header/data chunk in
// the wave file
private int payloadSize;
/**
*
* Returns the state of the recorder in a RehearsalAudioRecord.State typed
* object. Useful, as no exceptions are thrown.
*
* @return recorder state
*/
public State getState() {
return state;
}
/*
*
* Method used for recording.
*/
private AudioRecord.OnRecordPositionUpdateListener updateListener = new AudioRecord.OnRecordPositionUpdateListener() {
public void onPeriodicNotification(AudioRecord recorder) {
audioRecorder.read(buffer, 0, buffer.length); // Fill buffer
try {
randomAccessWriter.write(buffer); // Write buffer to file
payloadSize += buffer.length;
if (bSamples == 16) {
for (int i = 0; i < buffer.length / 2; i++) { // 16bit
// sample
// size
short curSample = getShort(buffer[i * 2],
buffer[i * 2 + 1]);
if (curSample > cAmplitude) { // Check amplitude
cAmplitude = curSample;
}
}
} else { // 8bit sample size
for (int i = 0; i < buffer.length; i++) {
if (buffer[i] > cAmplitude) { // Check amplitude
cAmplitude = buffer[i];
}
}
}
} catch (IOException e) {
Log.e(ExtAudioRecorder.class.getName(),
"Error occured in updateListener, recording is aborted");
// stop();
}
}
public void onMarkerReached(AudioRecord recorder) {
// NOT USED
}
};
/**
*
*
* Default constructor
*
* Instantiates a new recorder, in case of compressed recording the
* parameters can be left as 0. In case of errors, no exception is thrown,
* but the state is set to ERROR
*
*/
public ExtAudioRecorder(boolean uncompressed, int audioSource,
int sampleRate, int channelConfig, int audioFormat) {
try {
rUncompressed = uncompressed;
if (rUncompressed) { // RECORDING_UNCOMPRESSED
if (audioFormat == AudioFormat.ENCODING_PCM_16BIT) {
bSamples = 16;
} else {
bSamples = 8;
}
if (channelConfig == AudioFormat.CHANNEL_CONFIGURATION_MONO) {
nChannels = 1;
} else {
nChannels = 2;
}
aSource = audioSource;
sRate = sampleRate;
aFormat = audioFormat;
framePeriod = sampleRate * TIMER_INTERVAL / 1000;
bufferSize = framePeriod * 2 * bSamples * nChannels / 8;
if (bufferSize < AudioRecord.getMinBufferSize(sampleRate,
channelConfig, audioFormat)) { // Check to make sure
// buffer size is not
// smaller than the
// smallest allowed one
bufferSize = AudioRecord.getMinBufferSize(sampleRate,
channelConfig, audioFormat);
// Set frame period and timer interval accordingly
framePeriod = bufferSize / (2 * bSamples * nChannels / 8);
Log.w(ExtAudioRecorder.class.getName(),
"Increasing buffer size to "
+ Integer.toString(bufferSize));
}
audioRecorder = new AudioRecord(audioSource, sampleRate,
channelConfig, audioFormat, bufferSize);
if (audioRecorder.getState() != AudioRecord.STATE_INITIALIZED)
throw new Exception("AudioRecord initialization failed");
audioRecorder.setRecordPositionUpdateListener(updateListener);
audioRecorder.setPositionNotificationPeriod(framePeriod);
} else { // RECORDING_COMPRESSED
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder
.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder
.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
}
cAmplitude = 0;
filePath = null;
state = State.INITIALIZING;
} catch (Exception e) {
if (e.getMessage() != null) {
Log.e(ExtAudioRecorder.class.getName(), e.getMessage());
} else {
Log.e(ExtAudioRecorder.class.getName(),
"Unknown error occured while initializing recording");
}
state = State.ERROR;
}
}
/**
* Sets output file path, call directly after construction/reset.
*
* @param output
* file path
*
*/
public void setOutputFile(String argPath) {
try {
if (state == State.INITIALIZING) {
filePath = argPath;
if (!rUncompressed) {
mediaRecorder.setOutputFile(filePath);
}
}
} catch (Exception e) {
if (e.getMessage() != null) {
Log.e(ExtAudioRecorder.class.getName(), e.getMessage());
} else {
Log.e(ExtAudioRecorder.class.getName(),
"Unknown error occured while setting output path");
}
state = State.ERROR;
}
}
/**
*
* Returns the largest amplitude sampled since the last call to this method.
*
* @return returns the largest amplitude since the last call, or 0 when not
* in recording state.
*
*/
public int getMaxAmplitude() {
if (state == State.RECORDING) {
if (rUncompressed) {
int result = cAmplitude;
cAmplitude = 0;
return result;
} else {
try {
return mediaRecorder.getMaxAmplitude();
} catch (IllegalStateException e) {
return 0;
}
}
} else {
return 0;
}
}
/**
*
* Prepares the recorder for recording, in case the recorder is not in the
* INITIALIZING state and the file path was not set the recorder is set to
* the ERROR state, which makes a reconstruction necessary. In case
* uncompressed recording is toggled, the header of the wave file is
* written. In case of an exception, the state is changed to ERROR
*
*/
public void prepare() {
try {
if (state == State.INITIALIZING) {
if (rUncompressed) {
if ((audioRecorder.getState() == AudioRecord.STATE_INITIALIZED)
& (filePath != null)) {
// write file header
randomAccessWriter = new RandomAccessFile(filePath,
"rw");
randomAccessWriter.setLength(0); // Set file length to
// 0, to prevent
// unexpected
// behavior in case
// the file already
// existed
randomAccessWriter.writeBytes("RIFF");
randomAccessWriter.writeInt(0); // Final file size not
// known yet, write 0
randomAccessWriter.writeBytes("WAVE");
randomAccessWriter.writeBytes("fmt ");
randomAccessWriter.writeInt(Integer.reverseBytes(16)); // Sub-chunk
// size,
// 16
// for
// PCM
randomAccessWriter.writeShort(Short
.reverseBytes((short) 1)); // AudioFormat, 1 for
// PCM
randomAccessWriter.writeShort(Short
.reverseBytes(nChannels));// Number of channels,
// 1 for mono, 2 for
// stereo
randomAccessWriter
.writeInt(Integer.reverseBytes(sRate)); // Sample
// rate
randomAccessWriter.writeInt(Integer.reverseBytes(sRate
* bSamples * nChannels / 8)); // Byte rate,
// SampleRate*NumberOfChannels*BitsPerSample/8
randomAccessWriter
.writeShort(Short
.reverseBytes((short) (nChannels
* bSamples / 8))); // Block
// align,
// NumberOfChannels*BitsPerSample/8
randomAccessWriter.writeShort(Short
.reverseBytes(bSamples)); // Bits per sample
randomAccessWriter.writeBytes("data");
randomAccessWriter.writeInt(0); // Data chunk size not
// known yet, write 0
buffer = new byte[framePeriod * bSamples / 8
* nChannels];
state = State.READY;
} else {
Log.e(ExtAudioRecorder.class.getName(),
"prepare() method called on uninitialized recorder");
state = State.ERROR;
}
} else {
mediaRecorder.prepare();
state = State.READY;
}
} else {
Log.e(ExtAudioRecorder.class.getName(),
"prepare() method called on illegal state");
release();
state = State.ERROR;
}
} catch (Exception e) {
if (e.getMessage() != null) {
Log.e(ExtAudioRecorder.class.getName(), e.getMessage());
} else {
Log.e(ExtAudioRecorder.class.getName(),
"Unknown error occured in prepare()");
}
state = State.ERROR;
}
}
/**
*
*
* Releases the resources associated with this class, and removes the
* unnecessary files, when necessary
*
*/
public void release() {
if (state == State.RECORDING) {
stop();
} else {
if ((state == State.READY) & (rUncompressed)) {
try {
randomAccessWriter.close(); // Remove prepared file
} catch (IOException e) {
Log.e(ExtAudioRecorder.class.getName(),
"I/O exception occured while closing output file");
}
(new File(filePath)).delete();
}
}
if (rUncompressed) {
if (audioRecorder != null) {
audioRecorder.release();
}
} else {
if (mediaRecorder != null) {
mediaRecorder.release();
}
}
}
/**
*
*
* Resets the recorder to the INITIALIZING state, as if it was just created.
* In case the class was in RECORDING state, the recording is stopped. In
* case of exceptions the class is set to the ERROR state.
*
*/
public void reset() {
try {
if (state != State.ERROR) {
release();
filePath = null; // Reset file path
cAmplitude = 0; // Reset amplitude
if (rUncompressed) {
audioRecorder = new AudioRecord(aSource, sRate,
nChannels + 1, aFormat, bufferSize);
} else {
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder
.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder
.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
}
state = State.INITIALIZING;
}
} catch (Exception e) {
Log.e(ExtAudioRecorder.class.getName(), e.getMessage());
state = State.ERROR;
}
}
/**
*
*
* Starts the recording, and sets the state to RECORDING. Call after
* prepare().
*
*/
public void start() {
if (state == State.READY) {
if (rUncompressed) {
payloadSize = 0;
audioRecorder.startRecording();
audioRecorder.read(buffer, 0, buffer.length);
} else {
mediaRecorder.start();
}
state = State.RECORDING;
} else {
Log.e(ExtAudioRecorder.class.getName(),
"start() called on illegal state");
state = State.ERROR;
}
}
/**
*
*
* Stops the recording, and sets the state to STOPPED. In case of further
* usage, a reset is needed. Also finalizes the wave file in case of
* uncompressed recording.
*
*/
public void stop() {
if (state == State.RECORDING) {
if (rUncompressed) {
audioRecorder.stop();
try {
randomAccessWriter.seek(4); // Write size to RIFF header
randomAccessWriter.writeInt(Integer
.reverseBytes(36 + payloadSize));
randomAccessWriter.seek(40); // Write size to Subchunk2Size
// field
randomAccessWriter.writeInt(Integer
.reverseBytes(payloadSize));
randomAccessWriter.close();
} catch (IOException e) {
Log.e(ExtAudioRecorder.class.getName(),
"I/O exception occured while closing output file");
state = State.ERROR;
}
} else {
mediaRecorder.stop();
}
state = State.STOPPED;
} else {
Log.e(ExtAudioRecorder.class.getName(),
"stop() called on illegal state");
state = State.ERROR;
}
}
/*
*
* Converts a byte[2] to a short, in LITTLE_ENDIAN format
*/
private short getShort(byte argB1, byte argB2) {
return (short) (argB1 | (argB2 << 8));
}
/**
* 褰曞埗wav鏍煎紡鏂囦欢
*
* @param path
* : 鏂囦欢璺緞
*/
public static File recordChat(String savePath, String fileName) {
File dir = new File(savePath);
// 濡傛灉璇ョ洰褰曟病鏈夊瓨鍦紝鍒欐柊寤虹洰褰<E6B4B0>
if (dir.list() == null) {
dir.mkdirs();
}
// 鑾峰彇褰曢煶鏂囦欢
File file = new File(savePath + fileName);
// 璁剧疆杈撳嚭鏂囦欢
result.setOutputFile(savePath + fileName);
result.prepare();
// 寮<>濮嬪綍闊<E7B68D>
result.start();
return file;
}
/**
* 鍋滄褰曢煶
*
* @param mediaRecorder
* 寰呭仠姝㈢殑褰曢煶鏈<E785B6>
* @return 杩斿洖
*/
public static String stopRecord() {
result.stop();
result.release();
Log.d("stopRecord",result.filePath);
return result.filePath;
}
}

View File

@@ -0,0 +1,202 @@
package com.jxkh.queyi.common;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.security.cert.CertificateException;
import javax.security.cert.X509Certificate;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.params.ConnPerRouteBean;
import org.apache.http.conn.params.ConnRouteParams;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import android.content.Context;
import android.net.Proxy;
import android.text.TextUtils;
public class HttpClientManager {
private static final int DEFAULT_MAX_CONNECTIONS = 30;
private static final int DEFAULT_SOCKET_TIMEOUT = 60 * 1000;
private static final int DEFAULT_SOCKET_BUFFER_SIZE = 81920;
private static DefaultHttpClient sHttpClient;
static {
final HttpParams httpParams = new BasicHttpParams();
ConnManagerParams.setTimeout(httpParams, 10000);
ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(10));
ConnManagerParams.setMaxTotalConnections(httpParams, DEFAULT_MAX_CONNECTIONS);
HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(httpParams, "UTF-8");
HttpConnectionParams.setStaleCheckingEnabled(httpParams, false);
HttpClientParams.setRedirecting(httpParams, false);
HttpProtocolParams.setUserAgent(httpParams, "Android client");
HttpConnectionParams.setSoTimeout(httpParams, DEFAULT_SOCKET_TIMEOUT);
HttpConnectionParams.setConnectionTimeout(httpParams, DEFAULT_SOCKET_TIMEOUT);
HttpConnectionParams.setTcpNoDelay(httpParams, true);
HttpConnectionParams.setSocketBufferSize(httpParams, DEFAULT_SOCKET_BUFFER_SIZE);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
try {
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
schemeRegistry.register(new Scheme("https", sf, 443));
} catch (Exception ex) {
// do nothing, just keep not crash
}
ClientConnectionManager manager = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
sHttpClient = new DefaultHttpClient(manager, httpParams);
}
private HttpClientManager() {
}
public static HttpResponse execute(HttpHead head) throws IOException {
return sHttpClient.execute(head);
}
public static HttpResponse execute(HttpHost host, HttpGet get) throws IOException {
return sHttpClient.execute(host, get);
}
public static HttpResponse execute(Context context, HttpGet get) throws IOException {
if (!Util.isWiFiActive(context) && isWapNetwork()) {
setWapProxy();
return sHttpClient.execute(get);
}
final HttpHost host = (HttpHost) sHttpClient.getParams().getParameter(ConnRouteParams.DEFAULT_PROXY);
if (host != null) {
sHttpClient.getParams().removeParameter(ConnRouteParams.DEFAULT_PROXY);
}
return sHttpClient.execute(get);
}
private static void setSinaWapProxy() {
final HttpHost para = (HttpHost) sHttpClient.getParams().getParameter(ConnRouteParams.DEFAULT_PROXY);
if (para != null) {
sHttpClient.getParams().removeParameter(ConnRouteParams.DEFAULT_PROXY);
}
String host = Proxy.getDefaultHost();
int port = Proxy.getDefaultPort();
HttpHost httpHost = new HttpHost(host, port);
HttpParams httpParams = new BasicHttpParams();
httpParams.setParameter(ConnRouteParams.DEFAULT_PROXY, httpHost);
}
public static HttpResponse execute(Context context, HttpUriRequest post) throws IOException {
if (!Util.isWiFiActive(context) && isWapNetwork()) {
setSinaWapProxy();
}
return sHttpClient.execute(post);
}
public static HttpResponse execute(Context context, HttpPost post) throws IOException {
if (!Util.isWiFiActive(context) && isWapNetwork()) {
setWapProxy();
return sHttpClient.execute(post);
}
final HttpHost host = (HttpHost) sHttpClient.getParams().getParameter(ConnRouteParams.DEFAULT_PROXY);
if (host != null) {
sHttpClient.getParams().removeParameter(ConnRouteParams.DEFAULT_PROXY);
}
return sHttpClient.execute(post);
}
private static boolean isWapNetwork() {
final String proxyHost = android.net.Proxy.getDefaultHost();
return !TextUtils.isEmpty(proxyHost);
}
private static void setWapProxy() {
final HttpHost host = (HttpHost) sHttpClient.getParams().getParameter(ConnRouteParams.DEFAULT_PROXY);
if (host == null) {
final String host1 = Proxy.getDefaultHost();
int port = Proxy.getDefaultPort();
HttpHost httpHost = new HttpHost(host1, port);
sHttpClient.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, httpHost);
}
}
private static class MySSLSocketFactory extends SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
public MySSLSocketFactory(KeyStore truststore)
throws NoSuchAlgorithmException, KeyManagementException,
KeyStoreException, UnrecoverableKeyException {
super(truststore);
TrustManager tm = new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] arg0, String arg1)
throws java.security.cert.CertificateException {
// TODO Auto-generated method stub
}
@Override
public void checkServerTrusted(
java.security.cert.X509Certificate[] arg0, String arg1)
throws java.security.cert.CertificateException {
// TODO Auto-generated method stub
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
// TODO Auto-generated method stub
return null;
}
};
sslContext.init(null, new TrustManager[] { tm }, null);
}
@Override
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
}
@Override
public Socket createSocket() throws IOException {
return sslContext.getSocketFactory().createSocket();
}
}
}

View File

@@ -0,0 +1,16 @@
package com.jxkh.queyi.common;
import android.app.Activity;
public class MainActivityHolder {
private static Activity activity = null;
public static void setMainActivity( Activity activity ){
MainActivityHolder.activity = activity;
}
public static Activity getMainActivity(){
return MainActivityHolder.activity;
}
}

View File

@@ -0,0 +1,225 @@
package com.jxkh.queyi.common;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import junit.framework.Assert;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.graphics.Bitmap.CompressFormat;
import android.util.Log;
public class Util {
private static final String TAG = "SDK_Sample.Util";
public static byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
bmp.compress(CompressFormat.PNG, 100, output);
if (needRecycle) {
bmp.recycle();
}
byte[] result = output.toByteArray();
try {
output.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static byte[] getHtmlByteArray(final String url) {
URL htmlUrl = null;
InputStream inStream = null;
try {
htmlUrl = new URL(url);
URLConnection connection = htmlUrl.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection)connection;
int responseCode = httpConnection.getResponseCode();
if(responseCode == HttpURLConnection.HTTP_OK){
inStream = httpConnection.getInputStream();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
byte[] data = inputStreamToByte(inStream);
return data;
}
public static byte[] inputStreamToByte(InputStream is) {
try{
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
int ch;
while ((ch = is.read()) != -1) {
bytestream.write(ch);
}
byte imgdata[] = bytestream.toByteArray();
bytestream.close();
return imgdata;
}catch(Exception e){
e.printStackTrace();
}
return null;
}
public static byte[] readFromFile(String fileName, int offset, int len) {
if (fileName == null) {
return null;
}
File file = new File(fileName);
if (!file.exists()) {
Log.i(TAG, "readFromFile: file not found");
return null;
}
if (len == -1) {
len = (int) file.length();
}
Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));
if(offset <0){
Log.e(TAG, "readFromFile invalid offset:" + offset);
return null;
}
if(len <=0 ){
Log.e(TAG, "readFromFile invalid len:" + len);
return null;
}
if(offset + len > (int) file.length()){
Log.e(TAG, "readFromFile invalid file len:" + file.length());
return null;
}
byte[] b = null;
try {
RandomAccessFile in = new RandomAccessFile(fileName, "r");
b = new byte[len];
in.seek(offset);
in.readFully(b);
in.close();
} catch (Exception e) {
Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
e.printStackTrace();
}
return b;
}
private static final int MAX_DECODE_PICTURE_SIZE = 1920 * 1440;
public static Bitmap extractThumbNail(final String path, final int height, final int width, final boolean crop) {
Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0);
BitmapFactory.Options options = new BitmapFactory.Options();
try {
options.inJustDecodeBounds = true;
Bitmap tmp = BitmapFactory.decodeFile(path, options);
if (tmp != null) {
tmp.recycle();
tmp = null;
}
Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
final double beY = options.outHeight * 1.0 / height;
final double beX = options.outWidth * 1.0 / width;
Log.d(TAG, "extractThumbNail: extract beX = " + beX + ", beY = " + beY);
options.inSampleSize = (int) (crop ? (beY > beX ? beX : beY) : (beY < beX ? beX : beY));
if (options.inSampleSize <= 1) {
options.inSampleSize = 1;
}
// NOTE: out of memory error
while (options.outHeight * options.outWidth / options.inSampleSize > MAX_DECODE_PICTURE_SIZE) {
options.inSampleSize++;
}
int newHeight = height;
int newWidth = width;
if (crop) {
if (beY > beX) {
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
} else {
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
}
} else {
if (beY < beX) {
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
} else {
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
}
}
options.inJustDecodeBounds = false;
Log.i(TAG, "bitmap required size=" + newWidth + "x" + newHeight + ", orig=" + options.outWidth + "x" + options.outHeight + ", sample=" + options.inSampleSize);
Bitmap bm = BitmapFactory.decodeFile(path, options);
if (bm == null) {
Log.e(TAG, "bitmap decode failed");
return null;
}
Log.i(TAG, "bitmap decoded size=" + bm.getWidth() + "x" + bm.getHeight());
final Bitmap scale = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true);
if (scale != null) {
bm.recycle();
bm = scale;
}
if (crop) {
final Bitmap cropped = Bitmap.createBitmap(bm, (bm.getWidth() - width) >> 1, (bm.getHeight() - height) >> 1, width, height);
if (cropped == null) {
return bm;
}
bm.recycle();
bm = cropped;
Log.i(TAG, "bitmap croped size=" + bm.getWidth() + "x" + bm.getHeight());
}
return bm;
} catch (final OutOfMemoryError e) {
Log.e(TAG, "decode bitmap failed: " + e.getMessage());
options = null;
}
return null;
}
/**
* Wifi是否可用
* @param context
* @return
*/
public static boolean isWiFiActive( Context context ) {
ConnectivityManager connectivity = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] infos = connectivity.getAllNetworkInfo();
if (infos != null) {
for(NetworkInfo ni : infos){
if(ni.getTypeName().equals("WIFI") && ni.isConnected()){
return true;
}
}
}
}
return false;
}
}

View File

@@ -0,0 +1,121 @@
package com.jxkh.queyi.common;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import android.content.Context;
public class YSHttpClient {
public interface IProgressListener {
void update(long now, long total);
}
/**
* 下载指定文件 到 指定位置
* @param sourceUrl
* @param destFile
* @param listener
*/
public static void download(final String sourceUrl, final String destFile, final IProgressListener listener){
// new Thread(){
// public void run() {
System.out.println("download:" + sourceUrl);
System.out.println("download:" + destFile);
File dest = new File(destFile);
if(dest.exists()){
//if(null != listener) {
// listener.update(100, 100);
//}
//return ;
dest.delete();
}//else{
String path = destFile.substring(0,destFile.lastIndexOf("/"));
System.out.println("downloadPath:" + path);
File folder = new File(path);
if(!folder.exists()) {
folder.mkdirs();
}
//}
Context context = MainActivityHolder.getMainActivity();
HttpGet get = new HttpGet(sourceUrl);
get.addHeader("Accept-Encoding", "gzip");
HttpResponse response = null;
try {
response = HttpClientManager.execute(context, get);
int code = response.getStatusLine().getStatusCode();
if (code >= 200 && code < 300) {
FileOutputStream fout = new FileOutputStream(dest);
HttpEntity entity = response.getEntity();
InputStream instream = entity.getContent();
byte[] buf = new byte[4096];
int bufsize = -1;
long progress = 0;
while ((bufsize = instream.read(buf)) != -1) {
fout.write(buf, 0, bufsize);
progress += bufsize;
if (listener != null) {
listener.update(progress, entity.getContentLength());
}
}
fout.flush();
instream.close();
fout.close();
} else {
throw new IOException("response code is " + code);
}
} catch (IOException e) {
e.printStackTrace();
}
// };
// }.start();
}
/**
* 获取 json结果
* @param url 请求地址
* @return
*/
public static JSONObject getJson(String url){
Context context = MainActivityHolder.getMainActivity();
HttpGet get = new HttpGet(url);
get.setHeader("Connection", "Keep-Alive");
// get.addHeader("Accept-Encoding", "gzip");
JSONObject result = null;
try {
HttpResponse response = HttpClientManager.execute(context, get);
int code = response.getStatusLine().getStatusCode();
if (code >= 200 && code < 300) {
String resultStr = EntityUtils.toString(response.getEntity(), "UTF-8");
System.out.println("-----------"+resultStr);
if( null != resultStr && code != 204 && resultStr.length()>0){
result = new JSONObject(resultStr);
}
} else {
throw new IOException("response code is " + code);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}

View File

@@ -0,0 +1,109 @@
package com.jxkh.queyi.sgapi;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.xianliao.im.sdk.api.ISGAPI;
import org.xianliao.im.sdk.api.ISGAPIEventHandler;
import org.xianliao.im.sdk.api.SGAPIFactory;
import org.xianliao.im.sdk.constants.SGConstants;
import org.xianliao.im.sdk.modelbase.BaseReq;
import org.xianliao.im.sdk.modelbase.BaseResp;
import org.xianliao.im.sdk.modelmsg.InvitationResp;
import org.xianliao.im.sdk.modelmsg.SendAuth;
import com.jxkh.queyi.*;
import com.jxkh.queyi.common.*;
public class SGEntryActivity extends Activity implements ISGAPIEventHandler {
ISGAPI api;
private static String mAppID = "rrqu5DQlY7lMO5mx";
private static String mAppSecret = "ZhppLPb3SzAGSX4v";
public static String Tag = "SGEntryActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
api = SGAPIFactory.createSGAPI(this, mAppID);
api.handleIntent(getIntent(),this);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
}
@Override
public void onReq(BaseReq req) {
}
@Override
public void onResp(BaseResp resp) {
switch (resp.getType()){
case SGConstants.COMMAND_AUTH: //授权登陆
SendAuth.Resp respAuth = (SendAuth.Resp) resp;
if(resp.errCode == SGConstants.ERR_OK){
Toast.makeText(this, "授权登录成功!"+resp.errCode + "\ncode: "+respAuth.code, Toast.LENGTH_SHORT).show();
}else if(resp.errCode == SGConstants.ERR_CANCEL){
Toast.makeText(this, "授权登录取消!"+resp.errCode, Toast.LENGTH_SHORT).show();
}else if(resp.errCode == SGConstants.ERR_FAIL){
Toast.makeText(this, "授权登录失败!"+resp.errCode, Toast.LENGTH_SHORT).show();
}
break;
case SGConstants.COMMAND_SHARE: //分享文本,图片,邀请
if(resp.errCode == SGConstants.ERR_OK){
Toast.makeText(this, "分享成功!"+resp.errCode, Toast.LENGTH_SHORT).show();
}else if(resp.errCode == SGConstants.ERR_CANCEL){
Toast.makeText(this, "分享取消!"+resp.errCode, Toast.LENGTH_SHORT).show();
}else if(resp.errCode == SGConstants.ERR_FAIL){
Toast.makeText(this, "分享失败!"+resp.errCode, Toast.LENGTH_SHORT).show();
}
break;
case SGConstants.COMMAND_INVITE: //从闲聊点击邀请进入应用,
/**
* 需要Manifest里面配置特殊 intent-filter 才有用,详情参见AndroidManifest
*/
InvitationResp invitationResp = (InvitationResp) resp;
//Toast.makeText(this, "邀请进入: roomId: " + invitationResp.roomId +" roomToken: "
// + invitationResp.roomToken, Toast.LENGTH_LONG).show();
if (MainActivityHolder.getMainActivity() == null)
{
Log.d(Tag, "MainActivityHolder.getMainActivity() is NULL");
Native.strAppRunParam = invitationResp.roomId;
//传递roomId roomToken到其他页面
Intent intent = new Intent(this,AppActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("roomId", invitationResp.roomId);
intent.putExtra("roomToken", invitationResp.roomToken);
intent.putExtra("openId", invitationResp.openId);
startActivity(intent);
}
else
{
Log.d(Tag, "MainActivityHolder.getMainActivity() is Not NULL" + invitationResp.roomId);
Native.strAppRunParam = invitationResp.roomId;
}
break;
}
finish();
}
@Override
protected void onResume() {
super.onResume();
}
}

View File

@@ -0,0 +1,175 @@
package com.jxkh.queyi.sgapi;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import java.io.File;
import org.xianliao.im.sdk.api.ISGAPI;
import org.xianliao.im.sdk.api.SGAPIFactory;
import org.xianliao.im.sdk.constants.SGConstants;
import org.xianliao.im.sdk.modelmsg.SGTextObject;
import org.xianliao.im.sdk.modelmsg.SGGameObject;
import org.xianliao.im.sdk.modelmsg.SGImageObject;
import org.xianliao.im.sdk.modelmsg.SGMediaMessage;
import org.xianliao.im.sdk.modelmsg.SendMessageToSG;
import com.jxkh.queyi.*;
/**
* Created by nickyang on 2017/1/18.
*
* 此类用于接收从闲聊返回到应用的返回值
*
* 注意: "sgapi" 目录名和 "SGEntryActivity" 类名都不能改动
*
*/
public class SGShareActivity extends Activity {
ISGAPI api;
private static String mAppID = "rrqu5DQlY7lMO5mx";
private static String mAppSecret = "ZhppLPb3SzAGSX4v";
public static String Tag = "SendToSGActivity";
public static String ReqXLShareImg = "ReqXLShareImg";
public static String ReqXLShareTxt = "ReqXLShareTxt";
public static String ReqXLShareUrl = "ReqXLShareUrl";
public static int nXLTodoType = 0;
public static String strXLTodo = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
api = SGAPIFactory.createSGAPI(this, mAppID);
//可以检测闲聊是否已经安装
if(!api.isSGAppInstalled()){
Toast.makeText(this,"闲聊应用未安装,请先安装闲聊应用",Toast.LENGTH_SHORT).show();
finish();
return;
}
Intent intent = getIntent();
if (intent.hasExtra(ReqXLShareImg)) {
strXLTodo = ReqXLShareImg;
String ImgPath = intent.getStringExtra("ImgPath");
nXLTodoType = intent.getIntExtra("ShareType", 0);
reqShareImg(ImgPath, nXLTodoType);
} else if (intent.hasExtra(ReqXLShareTxt)) {
strXLTodo = ReqXLShareTxt;
String ShareText = intent.getStringExtra("ShareText");
nXLTodoType = intent.getIntExtra("ShareType", 0);
reqShareTxt(ShareText, nXLTodoType);
} else if (intent.hasExtra(ReqXLShareUrl)) {
strXLTodo = ReqXLShareUrl;
String ShareUrl = intent.getStringExtra("ShareUrl");
String ShareTitle = intent.getStringExtra("ShareTitle");
String ShareDesc = intent.getStringExtra("ShareDesc");
nXLTodoType = intent.getIntExtra("ShareType", 0);
reqShareUrl(ShareUrl, ShareTitle, ShareDesc, nXLTodoType);
}
finish();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
@Override
protected void onResume() {
super.onResume();
}
// 文本信息分享
private void reqShareTxt(String text, int nType) {
//初始化一个SGTextObject对象填写分享的文本内容
SGTextObject textObject = new SGTextObject();
textObject.text = text;
//用SGTextObject对象初始化一个SGMediaMessage对象
SGMediaMessage msg = new SGMediaMessage();
msg.mediaObject = textObject;
//msg.title = "titleXXX";
//构造一个Req
SendMessageToSG.Req req = new SendMessageToSG.Req();
req.transaction = SGConstants.T_TEXT;
req.mediaMessage = msg;
req.scene = SendMessageToSG.Req.SGSceneSession; //代表分享到会话列表
//调用api接口发送数据到闲聊
api.sendReq(req);
}
// 网页分享
private void reqShareUrl(String url, String title, String desc, int nType) {
String tmpUrl = url.toLowerCase();
if(!tmpUrl.startsWith("http://"))
{
url = "http://" + url;
Log.d(Tag, url);
}
//注意ic_launcher 图片的大小放在res里不同图片资源文件目录下系统会根据手机屏幕自动缩放
// 建议放在xxhdpi目录下大小不要超过 200 x 200
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
//初始化一个SGGameObject对象设置所分享的应用图片内容
SGGameObject gameObject = new SGGameObject(bitmap);
gameObject.roomId = url.substring(url.length()-6,url.length());
gameObject.roomToken = url.substring(url.length()-6,url.length());
//可以自定义邀请应用的下载链接也可以不填不填会默认使用应用申请appid时填写的链接
gameObject.androidDownloadUrl = url;
gameObject.iOSDownloadUrl = url;
//用SGGameObject对象初始化一个SGMediaMessage对象
SGMediaMessage msg = new SGMediaMessage();
msg.mediaObject = gameObject;
msg.title = title;
msg.description = desc;
//构造一个Req
SendMessageToSG.Req req = new SendMessageToSG.Req();
req.transaction = SGConstants.T_GAME;
req.mediaMessage = msg;
req.scene = SendMessageToSG.Req.SGSceneSession; //代表分享到会话列表
//调用api接口发送数据到闲聊
api.sendReq(req);
}
// 图片分享
private void reqShareImg(String ImgPath, int nType) {
Log.d(Tag, "reqShare file :" + ImgPath);
File file = new File(ImgPath);
if (!file.exists()) {
Log.d(Tag, "reqShare file not exists:" + ImgPath);
return;
}
Bitmap bitmap = BitmapFactory.decodeFile(ImgPath);
//初始化一个SGImageObject对象设置所分享的图片内容
SGImageObject imageObject = new SGImageObject(bitmap);
//用SGImageObject对象初始化一个SGMediaMessage对象
SGMediaMessage msg = new SGMediaMessage();
msg.mediaObject = imageObject;
//构造一个Req
SendMessageToSG.Req req = new SendMessageToSG.Req();
req.transaction = SGConstants.T_IMAGE;
req.mediaMessage = msg;
req.scene = SendMessageToSG.Req.SGSceneSession; //代表分享到会话列表
//调用api接口发送数据到闲聊
api.sendReq(req);
}
}

View File

@@ -0,0 +1,318 @@
package com.jxkh.queyi.wxapi;
import java.io.File;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.jxkh.queyi.Native;
import com.jxkh.queyi.common.Util;
import com.jxkh.queyi.R;
import com.tencent.mm.sdk.constants.ConstantsAPI;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.modelmsg.SendAuth;
import com.tencent.mm.sdk.modelmsg.SendMessageToWX;
import com.tencent.mm.sdk.modelmsg.ShowMessageFromWX;
import com.tencent.mm.sdk.modelmsg.WXAppExtendObject;
import com.tencent.mm.sdk.modelmsg.WXImageObject;
import com.tencent.mm.sdk.modelmsg.WXMediaMessage;
import com.tencent.mm.sdk.modelmsg.WXTextObject;
import com.tencent.mm.sdk.modelmsg.WXWebpageObject;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
public class WXEntryActivity extends Activity implements IWXAPIEventHandler{
public static String Tag = "WXEntryActivity";
private static final int TIMELINE_SUPPORTED_VERSION = 0x21020001;
private static WXEntryActivity sContext = null;
public static boolean bLogonWX = false;
private static final int THUMB_SIZE = 150;
public static final String APP_ID = "wxa7cc95beceb229c3";
public static final String AppSecret = "1c772bbb5509297392cbde5a02ae603e";
//public static final String APP_ID = "wx4b3e665b045adc34";
//public static final String AppSecret = "85dda78b3fdf3cb6619526fabf089863";
// IWXAPI 鏄涓夋柟app鍜屽井淇¢<E6B787>氫俊鐨刼penapi鎺ュ彛
private static IWXAPI api;
private static final int SceneSession = 0;
private static final int SceneTimeline = 1;
public static String ReqWxLogin = "ReqWxLogin";
public static String ReqWxShareImg = "ReqWxShareImg";
public static String ReqWxShareTxt = "ReqWxShareTxt";
public static String ReqWxShareUrl = "ReqWxShareUrl";
public static String ReqWXPay = "ReqWXPay";
public static String strWXTodo = "";
public static int nWXTodoType = 0;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
sContext = this;
Log.d(Tag,"onCreate");
Intent intent = getIntent();
// 閫氳繃WXAPIFactory宸ュ巶锛岃幏鍙朓WXAPI鐨勫疄渚<E79684>
api = WXAPIFactory.createWXAPI(this,APP_ID, true);
// 灏嗚app娉ㄥ唽鍒板井淇<E4BA95>
api.registerApp(APP_ID);
api.handleIntent(intent, this);
if (intent.hasExtra(ReqWxLogin))
{
strWXTodo = ReqWxLogin;
reqLogin();
}
else if(intent.hasExtra(ReqWxShareImg))
{
strWXTodo = ReqWxShareImg;
String ImgPath = intent.getStringExtra("ImgPath");
int nType = intent.getIntExtra("ShareType",0);
nWXTodoType = nType;
reqShareImg(ImgPath,nType);
}
else if(intent.hasExtra(ReqWxShareTxt))
{
strWXTodo = ReqWxShareTxt;
String ShareText = intent.getStringExtra("ShareText");
int nType = intent.getIntExtra("ShareType",0);
nWXTodoType = nType;
reqShareTxt(ShareText,nType);
}
else if(intent.hasExtra(ReqWxShareUrl))
{
strWXTodo = ReqWxShareUrl;
String ShareUrl = intent.getStringExtra("ShareUrl");
String ShareTitle = intent.getStringExtra("ShareTitle");
String ShareDesc = intent.getStringExtra("ShareDesc");
int nType = intent.getIntExtra("ShareType",0);
nWXTodoType = nType;
reqShareUrl(ShareUrl,ShareTitle,ShareDesc,nType);
}
finish();
}
@Override
protected void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
setIntent(intent);
WXEntryActivity.api.handleIntent(intent, this);
}
public void reqLogin()
{
SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "carjob_wx_login";
WXEntryActivity.api.sendReq(req);
Log.d(Tag,"reqLogin!!!!");
}
public void reqShareImg(String ImgPath,int nType)
{
File file = new File(ImgPath);
if (!file.exists())
{
Log.d(Tag,"reqShare file not exists:"+ImgPath);
return;
}
Bitmap bmp = BitmapFactory.decodeFile(ImgPath);
// 璁$畻缂╂斁姣斾緥
int scaleWidth = (int)(bmp.getWidth() * 0.5);
int scaleHeight = (int)(bmp.getHeight() * 0.5);
Bitmap newBmp = Bitmap.createScaledBitmap(bmp, scaleWidth, scaleHeight, true);
WXImageObject imgObj = new WXImageObject(newBmp);
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = imgObj;
Bitmap thumbBmp = Bitmap.createScaledBitmap(newBmp, 128, 72, true);
bmp.recycle();
msg.thumbData = Util.bmpToByteArray(thumbBmp, true);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("img");
req.message = msg;
if(nType==SceneTimeline )
{
req.scene = SendMessageToWX.Req.WXSceneTimeline;
}
else if(nType==SceneSession )
{
req.scene = SendMessageToWX.Req.WXSceneSession;
}
WXEntryActivity.api.sendReq(req);
Log.d(Tag,"reqShare Ok:"+ImgPath);
}
public void reqShareTxt(String text,int nType)
{
WXTextObject textObj = new WXTextObject();
textObj.text = text;
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = textObj;
// msg.title = "Will be ignored";
msg.description = text;
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("text");
req.message = msg;
if(nType==SceneTimeline )
{
req.scene = SendMessageToWX.Req.WXSceneTimeline;
}
else if(nType==SceneSession )
{
req.scene = SendMessageToWX.Req.WXSceneSession;
}
WXEntryActivity.api.sendReq(req);
Log.d(Tag,"reqShareTxt Ok:"+text);
}
public void reqShareUrl(String url, String title,String desc,int nType)
{
WXWebpageObject textObj = new WXWebpageObject();
textObj.webpageUrl = url;
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = textObj;
msg.title = title;
msg.description = desc;
Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
msg.setThumbImage(thumb);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("webpage"); // transaction
req.message = msg;
if(nType==SceneTimeline )
{
req.scene = SendMessageToWX.Req.WXSceneTimeline;
}
else if(nType==SceneSession )
{
req.scene = SendMessageToWX.Req.WXSceneSession;
}
WXEntryActivity.api.sendReq(req);
Log.d(Tag,"reqShareUrl Ok:"+url);
}
public void reqShareTxtCB(String text,int nType)
{
// send appdata with no attachment
WXAppExtendObject appdata = new WXAppExtendObject("lallalallallal", "filePath");
boolean bValue = appdata.checkArgs();
if (!bValue)
{
Log.d(Tag,"reqShareTxtCB Error:"+text);
}
WXMediaMessage msg = new WXMediaMessage();
msg.title ="11";
msg.description = "22";
msg.mediaObject = appdata;
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("appdata");
req.message = msg;
if(nType==SceneTimeline )
{
req.scene = SendMessageToWX.Req.WXSceneTimeline;
}
else if(nType==SceneSession )
{
req.scene = SendMessageToWX.Req.WXSceneSession;
}
WXEntryActivity.api.sendReq(req);
Log.d(Tag,"reqShareTxtCB Ok:"+text);
}
// 寰俊鍙戦<E98D99>佽姹傚埌绗笁鏂瑰簲鐢ㄦ椂锛屼細鍥炶皟鍒拌鏂规硶
@Override
public void onReq(BaseReq req)
{
Log.d(Tag,"public void onReq(BaseReq req) !!!!!!!");
switch (req.getType())
{
case ConstantsAPI.COMMAND_GETMESSAGE_FROM_WX:
Log.d(Tag,"onReq:COMMAND_GETMESSAGE_FROM_WX");
break;
case ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX:
Log.d(Tag,"onReq:COMMAND_SHOWMESSAGE_FROM_WX");
break;
default:
break;
}
Log.d(Tag,"onReq:"+req.getType());
}
// 绗笁鏂瑰簲鐢ㄥ彂閫佸埌寰俊鐨勮姹傚鐞嗗悗鐨勫搷搴旂粨鏋滐紝浼氬洖璋冨埌璇ユ柟娉<E69F9F>
@Override
public void onResp(BaseResp resp) {
Log.d(Tag,"public void onResp(BaseResp resp)");
int result = 0;
Log.d(Tag,"errCode:"+resp.errCode);
switch (resp.errCode) {
case BaseResp.ErrCode.ERR_OK:
if (strWXTodo.equals(ReqWxLogin))
{
String code = ((SendAuth.Resp) resp).code;
String Url =APP_ID+":"+AppSecret+":"+code+":authorization_code";
Log.d(Tag,Url);
Native.WxLoginGetAccessToken(Url);
}
else if (nWXTodoType == 1)
{
Native.WxLoginGetAccessToken("ShareFriendsSuccess");
}
strWXTodo = "";
break;
case BaseResp.ErrCode.ERR_USER_CANCEL:
Native.WxLoginGetAccessToken("ERR_USER_CANCEL");
break;
case BaseResp.ErrCode.ERR_AUTH_DENIED:
Native.WxLoginGetAccessToken("ERR_AUTH_DENIED");
break;
default:
Native.WxLoginGetAccessToken("REE_Unknow");
break;
}
}
private String buildTransaction(final String type) {
return (type == null) ? String.valueOf(System.currentTimeMillis()) : type + System.currentTimeMillis();
}
}