completed compatibility changes for new server

This commit is contained in:
2017-05-14 16:09:37 +08:00
parent 81d63de77a
commit 79205bd92f
19 changed files with 84 additions and 3958 deletions

3
Android/.gitignore vendored
View File

@@ -1,8 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.idea/
.DS_Store
/build
/captures

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@@ -1,3 +0,0 @@
<component name="CopyrightManager">
<settings default="" />
</component>

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/decodesdk" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Android.iml" filepath="$PROJECT_DIR$/Android.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/decodesdk/decodesdk.iml" filepath="$PROJECT_DIR$/decodesdk/decodesdk.iml" />
</modules>
</component>
</project>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

View File

@@ -30,19 +30,16 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
incremental true
}
productFlavors {
}
}
dependencies {
compile files('libs/irext-web-api.jar')
compile project(path: ':decodesdk')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile project(':decodesdk')
}

Binary file not shown.

View File

@@ -21,7 +21,7 @@ public class IRApplication extends com.activeandroid.app.Application {
private static final String TAG = IRApplication.class.getSimpleName();
private static final String ADDRESS = "http://192.168.1.100:8080";
private static final String ADDRESS = "http://192.168.137.128:8080";
private static final String APP_NAME = "/irext";
public WebAPIs mWeAPIs = WebAPIs.getInstance(ADDRESS, APP_NAME);

View File

@@ -22,13 +22,13 @@ import java.util.List;
public class RemoteControl extends Model {
@Column(name = "CategoryID")
private int categoryID;
private int categoryId;
@Column(name = "CategoryName")
private String categoryName;
@Column(name = "BrandID")
private int brandID;
private int brandId;
@Column(name = "BrandName")
private String brandName;
@@ -40,7 +40,7 @@ public class RemoteControl extends Model {
private String cityName;
@Column(name = "OperatorID")
private String operatorID;
private String operatorId;
@Column(name = "OperatorName")
private String operatorName;
@@ -57,12 +57,12 @@ public class RemoteControl extends Model {
@Column(name = "SubCategory")
private int subCategory;
public int getCategoryID() {
return categoryID;
public int getCategoryId() {
return categoryId;
}
public void setCategoryID(int categoryID) {
this.categoryID = categoryID;
public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
@@ -73,12 +73,12 @@ public class RemoteControl extends Model {
this.categoryName = categoryName;
}
public int getBrandID() {
return brandID;
public int getBrandId() {
return brandId;
}
public void setBrandID(int brandID) {
this.brandID = brandID;
public void setBrandId(int brandId) {
this.brandId = brandId;
}
public String getBrandName() {
@@ -105,12 +105,12 @@ public class RemoteControl extends Model {
this.cityName = cityName;
}
public String getOperatorID() {
return operatorID;
public String getOperatorId() {
return operatorId;
}
public void setOperatorID(String operatorID) {
this.operatorID = operatorID;
public void setOperatorId(String operatorId) {
this.operatorId = operatorId;
}
public String getOperatorName() {
@@ -157,16 +157,16 @@ public class RemoteControl extends Model {
return super.getId();
}
public RemoteControl(int categoryID, String categoryName, int brandID, String brandName,
String cityCode, String cityName, String operatorID, String operatorName,
public RemoteControl(int categoryId, String categoryName, int brandId, String brandName,
String cityCode, String cityName, String operatorId, String operatorName,
String remote, String protocol, String remoteMap, int subCategory) {
this.categoryID = categoryID;
this.categoryId = categoryId;
this.categoryName = categoryName;
this.brandID = brandID;
this.brandId = brandId;
this.brandName = brandName;
this.cityCode = cityCode;
this.cityName = cityName;
this.operatorID = operatorID;
this.operatorId = operatorId;
this.operatorName = operatorName;
this.remote = remote;
this.protocol = protocol;

View File

@@ -1,18 +1,12 @@
package net.irext.ircontrol.ui.activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MenuItem;
import net.irext.ircontrol.R;
import net.irext.ircontrol.ui.fragment.ControlFragment;
import net.irext.ircontrol.utils.MessageUtil;
import java.lang.ref.WeakReference;
/**
* Filename: ControlActivity.java
@@ -26,12 +20,11 @@ import java.lang.ref.WeakReference;
*/
public class ControlActivity extends AppCompatActivity {
@SuppressWarnings("unused")
private static final String TAG = ControlActivity.class.getSimpleName();
public static final String KEY_REMOTE_ID = "KEY_REMOTE_ID";
private MsgHandler mMsgHandler;
private ControlFragment mFragment;
@Override
@@ -39,8 +32,6 @@ public class ControlActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_control);
mMsgHandler = new MsgHandler(this);
FragmentManager fragmentManager = getSupportFragmentManager();
mFragment = new ControlFragment();
@@ -68,26 +59,4 @@ public class ControlActivity extends AppCompatActivity {
}
super.onStop();
}
private static class MsgHandler extends Handler {
WeakReference<ControlActivity> mControlActivity;
MsgHandler(ControlActivity activity) {
mControlActivity = new WeakReference<>(activity);
}
@Override
public void handleMessage(Message msg) {
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
Log.d(TAG, "handle message " + Integer.toString(cmd));
ControlActivity controlActivity = mControlActivity.get();
switch (cmd) {
default:
break;
}
}
}
}

View File

@@ -65,7 +65,7 @@ public class OperatorAdapter extends BaseAdapter {
} else {
holder = (ViewHolder)convertView.getTag();
}
holder.textView.setText(mOperators.get(position).getOperator_name());
holder.textView.setText(mOperators.get(position).getOperatorName());
return convertView;
}

View File

@@ -68,7 +68,7 @@ public class RemoteControlAdapter extends BaseAdapter {
}
RemoteControl remoteControl = mRemoteControls.get(position);
String remoteName;
if (Constants.CategoryID.STB.getValue() != remoteControl.getCategoryID()) {
if (Constants.CategoryID.STB.getValue() != remoteControl.getCategoryId()) {
remoteName = remoteControl.getCategoryName() + "-" + remoteControl.getBrandName();
} else {
remoteName = remoteControl.getCityName() + "-" + remoteControl.getOperatorName();

View File

@@ -16,7 +16,6 @@ import net.irext.ircontrol.ui.activity.CreateActivity;
import net.irext.ircontrol.ui.adapter.CityAdapter;
import net.irext.ircontrol.ui.adapter.OperatorAdapter;
import net.irext.ircontrol.utils.MessageUtil;
import net.irext.webapi.WebAPIs;
import net.irext.webapi.model.City;
import net.irext.webapi.model.StbOperator;

View File

@@ -23,7 +23,6 @@ import net.irext.ircontrol.ui.activity.ControlActivity;
import net.irext.ircontrol.utils.FileUtils;
import net.irext.ircontrol.utils.MessageUtil;
import java.io.File;
import java.lang.ref.WeakReference;
/**
@@ -130,42 +129,26 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
private void showRemote() {
mCurrentRemoteControl = RemoteControl.getRemoteControl(mRemoteID);
if (null != mCurrentRemoteControl) {
Log.d(TAG, "current remote control = " + mCurrentRemoteControl.getRemoteMap());
int category = mCurrentRemoteControl.getCategoryID();
int ret = 0;
int category = mCurrentRemoteControl.getCategoryId();
String binFileName = FileUtils.BIN_PATH + FileUtils.FILE_NAME_PREFIX +
mCurrentRemoteControl.getRemoteMap() + FileUtils.FILE_NAME_EXT;
if (Constants.CategoryID.AIR_CONDITIONER.getValue() == category) {
/* decode SDK - load AC binary file */
ret = mIRDecode.openACBinary(binFileName);
} else {
/* decode SDK - load TV binary file */
ret = mIRDecode.openTVBinary(binFileName, mCurrentRemoteControl.getSubCategory());
}
Log.d(TAG, "open binary result = " + ret);
/* decode SDK - load binary file */
// int ret = mIRDecode.openBinary(category, mCurrentRemoteControl.getSubCategory(), binFileName);
// Log.d(TAG, "open binary result = " + ret);
}
}
public void closeIRBinary() {
int category = mCurrentRemoteControl.getCategoryID();
if (Constants.CategoryID.AIR_CONDITIONER.getValue() == category) {
mIRDecode.closeACBinary();
} else {
mIRDecode.closeTVBinary();
}
// mIRDecode.closeBinary();
}
@Nullable
private int[] irControl(int keyCode) {
int inputKeyCode;
ACStatus acStatus = new ACStatus();
/* decode SDK - decode according to key code */
if (Constants.CategoryID.AIR_CONDITIONER.getValue() == mCurrentRemoteControl.getCategoryID()) {
int acFunction;
ACStatus acStatus = new ACStatus();
if (Constants.CategoryID.AIR_CONDITIONER.getValue() == mCurrentRemoteControl.getCategoryId()) {
acStatus.setAcPower(Constants.ACPower.POWER_OFF.getValue());
acStatus.setAcMode(Constants.ACMode.MODE_COOL.getValue());
acStatus.setAcTemp(Constants.ACTemperature.TEMP_24.getValue());
@@ -178,40 +161,46 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
switch(keyCode) {
case KEY_POWER:
// power key --> change power
acFunction = Constants.ACFunction.FUNCTION_SWITCH_POWER.getValue();
inputKeyCode = Constants.ACFunction.FUNCTION_SWITCH_POWER.getValue();
break;
case KEY_UP:
// up key --> change wind speed
acFunction = Constants.ACFunction.FUNCTION_SWITCH_WIND_SPEED.getValue();
inputKeyCode = Constants.ACFunction.FUNCTION_SWITCH_WIND_SPEED.getValue();
break;
case KEY_DOWN:
// down key --> change wind dir
acFunction = Constants.ACFunction.FUNCTION_SWITCH_WIND_DIR.getValue();
inputKeyCode = Constants.ACFunction.FUNCTION_SWITCH_WIND_DIR.getValue();
break;
case KEY_RIGHT:
// right key --> change mode
acFunction = Constants.ACFunction.FUNCTION_CHANGE_MODE.getValue();
inputKeyCode = Constants.ACFunction.FUNCTION_CHANGE_MODE.getValue();
break;
case KEY_OK:
// center key --> fix wind dir
acFunction = Constants.ACFunction.FUNCTION_SWITCH_SWING.getValue();
inputKeyCode = Constants.ACFunction.FUNCTION_SWITCH_SWING.getValue();
break;
case KEY_PLUS:
// plus key --> temp up
acFunction = Constants.ACFunction.FUNCTION_TEMPERATURE_UP.getValue();
inputKeyCode = Constants.ACFunction.FUNCTION_TEMPERATURE_UP.getValue();
break;
case KEY_MINUS:
// minus key --> temp down
acFunction = Constants.ACFunction.FUNCTION_TEMPERATURE_DOWN.getValue();
inputKeyCode = Constants.ACFunction.FUNCTION_TEMPERATURE_DOWN.getValue();
break;
default:
return null;
}
return IRDecode.getInstance().decodeACBinary(acStatus, acFunction);
} else {
return IRDecode.getInstance().decodeTVBinary(keyCode);
inputKeyCode = keyCode;
}
/* decode SDK - decode from binary */
/* translate key code for AC according to the mapping above */
/* ac status is useless for decoding devices other than AC, it's an optional parameter */
/* change wind dir is an optional parameter, set to 0 as default */
// return mIRDecode.decodeBinary(inputKeyCode, acStatus, 0);
return null;
}
// control
@@ -265,7 +254,8 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
break;
}
// send decoded integer array to IR emitter
ConsumerIrManager irEmitter = (ConsumerIrManager) mParent.getSystemService(Context.CONSUMER_IR_SERVICE);
ConsumerIrManager irEmitter =
(ConsumerIrManager) mParent.getSystemService(Context.CONSUMER_IR_SERVICE);
if (irEmitter.hasIrEmitter()) {
irEmitter.transmit(38000, decoded);
}
@@ -282,7 +272,6 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
@Override
public void handleMessage(Message msg) {
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
Log.d(TAG, "handle message " + Integer.toString(cmd));
ControlFragment controlFragment = mMainFragment.get();
switch (cmd) {

View File

@@ -67,12 +67,12 @@ public class IndexFragment extends BaseCreateFragment {
City city = mParent.getCurrentCity();
StbOperator operator = mParent.getCurrentOperator();
int brandID = 0;
int brandId = 0;
String cityCode = null;
String operatorID = null;
String operatorId = null;
if (null != brand) {
brandID = brand.getId();
brandId = brand.getId();
}
if (null != city) {
@@ -80,11 +80,11 @@ public class IndexFragment extends BaseCreateFragment {
}
if (null != operator) {
operatorID = operator.getOperator_id();
operatorId = operator.getOperatorId();
}
mIndexes = mApp.mWeAPIs.listRemoteIndexes(mParent.getCurrentCategory().getId(), brandID,
cityCode, operatorID);
mIndexes = mApp.mWeAPIs.listRemoteIndexes(mParent.getCurrentCategory().getId(), brandId,
cityCode, operatorId);
if (null == mIndexes) {
mIndexes = new ArrayList<>();
}
@@ -97,22 +97,26 @@ public class IndexFragment extends BaseCreateFragment {
new Thread() {
@Override
public void run() {
String remoteMap = mCurrentIndex.getRemoteMap();
int indexID = mCurrentIndex.getId();
InputStream in = mApp.mWeAPIs.downloadBin(remoteMap, indexID);
if (createDirectory()) {
File binFile = new File(FileUtils.BIN_PATH +
FileUtils.FILE_NAME_PREFIX + mCurrentIndex.getRemoteMap() +
FileUtils.FILE_NAME_EXT);
FileUtils.write(binFile, in);
} else {
Log.w(TAG, "no directory to contain bin file");
}
try {
String remoteMap = mCurrentIndex.getRemoteMap();
int indexId = mCurrentIndex.getId();
InputStream in = mApp.mWeAPIs.downloadBin(remoteMap, indexId);
if (createDirectory()) {
File binFile = new File(FileUtils.BIN_PATH +
FileUtils.FILE_NAME_PREFIX + mCurrentIndex.getRemoteMap() +
FileUtils.FILE_NAME_EXT);
FileUtils.write(binFile, in);
} else {
Log.w(TAG, "no directory to contain bin file");
}
if (null != in) {
MessageUtil.postMessage(mMsgHandler, CMD_SAVE_REMOTE_CONTROL);
} else {
Log.e(TAG, "bin file download failed");
if (null != in) {
MessageUtil.postMessage(mMsgHandler, CMD_SAVE_REMOTE_CONTROL);
} else {
Log.e(TAG, "bin file download failed");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
@@ -120,18 +124,21 @@ public class IndexFragment extends BaseCreateFragment {
private boolean createDirectory() {
File file = new File(FileUtils.BIN_PATH);
if (file.exists()) {
return true;
}
return file.mkdirs();
}
private void saveRemoteControl() {
RemoteControl remoteControl = new RemoteControl();
remoteControl.setCategoryID(mCurrentIndex.getCategoryId());
remoteControl.setCategoryId(mCurrentIndex.getCategoryId());
remoteControl.setCategoryName(mCurrentIndex.getCategoryName());
remoteControl.setBrandID(mCurrentIndex.getBrandId());
remoteControl.setBrandId(mCurrentIndex.getBrandId());
remoteControl.setBrandName(mCurrentIndex.getBrandName());
remoteControl.setCityCode(mCurrentIndex.getCityCode());
remoteControl.setCityName(mCurrentIndex.getCityName());
remoteControl.setOperatorID(mCurrentIndex.getOperatorId());
remoteControl.setOperatorId(mCurrentIndex.getOperatorId());
remoteControl.setOperatorName(mCurrentIndex.getOperatorName());
remoteControl.setProtocol(mCurrentIndex.getProtocol());
remoteControl.setRemote(mCurrentIndex.getRemote());
@@ -139,7 +146,6 @@ public class IndexFragment extends BaseCreateFragment {
remoteControl.setSubCategory(mCurrentIndex.getSubCate());
long id = RemoteControl.createRemoteControl(remoteControl);
Log.d(TAG, "remote control has been saved: " + id);
mParent.finish();
}
@@ -197,7 +203,6 @@ public class IndexFragment extends BaseCreateFragment {
@Override
public void handleMessage(Message msg) {
int cmd = msg.getData().getInt(MessageUtil.KEY_CMD);
Log.d(TAG, "handle message " + Integer.toString(cmd));
IndexFragment indexFragment = mIndexFragment.get();
switch (cmd) {

View File

@@ -284,10 +284,10 @@ public class PullToRefreshListView extends ListView{
else {
previousY = -1;
}
// Remember where have we started
mScrollStartY = event.getY();
break;
case MotionEvent.ACTION_UP:
@@ -296,7 +296,6 @@ public class PullToRefreshListView extends ListView{
case RELEASE_TO_REFRESH:
setState(State.REFRESHING);
bounceBackHeader();
break;
case PULL_TO_REFRESH:

File diff suppressed because it is too large Load Diff