diff --git a/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java b/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java index 2401afa..70421a6 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java @@ -4,8 +4,10 @@ import android.util.Log; import com.activeandroid.ActiveAndroid; +import net.irext.webapi.WebAPICallbacks; import net.irext.webapi.WebAPIs; import net.irext.webapi.model.UserApp; +import net.irext.webapi.WebAPICallbacks.SignInCallback; /** * Filename: IRApplication.java @@ -29,6 +31,23 @@ public class IRApplication extends com.activeandroid.app.Application { private UserApp mUserApp; + private SignInCallback mSignInCallback = new SignInCallback() { + @Override + public void onSignInSuccess(UserApp admin) { + mUserApp = admin; + } + + @Override + public void onSignInFailed() { + Log.w(TAG, "sign in failed"); + } + + @Override + public void onSignInError() { + Log.e(TAG, "sign in error"); + } + }; + public UserApp getAdmin() { return mUserApp; } @@ -44,7 +63,7 @@ public class IRApplication extends com.activeandroid.app.Application { new Thread() { @Override public void run() { - mUserApp = mWeAPIs.signIn(IRApplication.this); + mWeAPIs.signIn(IRApplication.this, mSignInCallback); if (null != mUserApp) { Log.d(TAG, "signIn response : " + mUserApp.getId() + ", " + mUserApp.getToken()); } diff --git a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/BrandFragment.java b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/BrandFragment.java index 82f6df4..d8295fa 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/BrandFragment.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/BrandFragment.java @@ -15,6 +15,7 @@ import net.irext.ircontrol.ui.activity.CreateActivity; import net.irext.ircontrol.ui.adapter.BrandAdapter; import net.irext.ircontrol.ui.widget.PullToRefreshListView; import net.irext.ircontrol.utils.MessageUtil; +import net.irext.webapi.WebAPICallbacks.ListBrandsCallback; import net.irext.webapi.model.Brand; import java.lang.ref.WeakReference; @@ -46,6 +47,27 @@ public class BrandFragment extends BaseCreateFragment { private MsgHandler mMsgHandler; private IRApplication mApp; + private ListBrandsCallback mListBrandsCallback = new ListBrandsCallback() { + @Override + public void onListBrandsSuccess(List brands) { + mBrands = brands; + if (null == mBrands) { + mBrands = new ArrayList<>(); + } + MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_BRAND_LIST); + } + + @Override + public void onListBrandsFailed() { + Log.w(TAG, "list brands failed"); + } + + @Override + public void onListBrandsError() { + Log.e(TAG, "list brands error"); + } + }; + public BrandFragment() { } @@ -53,12 +75,9 @@ public class BrandFragment extends BaseCreateFragment { new Thread() { @Override public void run() { - mBrands = mApp.mWeAPIs - .listBrands(mParent.getCurrentCategory().getId(), 0, 20); - if (null == mBrands) { - mBrands = new ArrayList<>(); - } - MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_BRAND_LIST); + mApp.mWeAPIs + .listBrands(mParent.getCurrentCategory().getId(), 0, 20, + mListBrandsCallback); } }.start(); } diff --git a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/CategoryFragment.java b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/CategoryFragment.java index 5621942..a8d0ff7 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/CategoryFragment.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/CategoryFragment.java @@ -17,6 +17,7 @@ import net.irext.ircontrol.ui.widget.PullToRefreshListView; import net.irext.ircontrol.utils.MessageUtil; import net.irext.decodesdk.utils.Constants; import net.irext.webapi.model.Category; +import net.irext.webapi.WebAPICallbacks.ListCategoriesCallback; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -46,6 +47,27 @@ public class CategoryFragment extends BaseCreateFragment { private MsgHandler mMsgHandler; private IRApplication mApp; + private ListCategoriesCallback mListCategoriesCallback = new ListCategoriesCallback() { + @Override + public void onListCategoriesSuccess(List categories) { + mCategories = categories; + if (null == mCategories) { + mCategories = new ArrayList<>(); + } + MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_CATEGORY_LIST); + } + + @Override + public void onListCategoriesFailed() { + Log.w(TAG, "list categories failed"); + } + + @Override + public void onListCategoriesError() { + Log.e(TAG, "list categories error"); + } + }; + public CategoryFragment() { } @@ -53,11 +75,7 @@ public class CategoryFragment extends BaseCreateFragment { new Thread() { @Override public void run() { - mCategories = mApp.mWeAPIs.listCategories(0, 20); - if (null == mCategories) { - mCategories = new ArrayList<>(); - } - MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_CATEGORY_LIST); + mApp.mWeAPIs.listCategories(0, 20, mListCategoriesCallback); } }.start(); } diff --git a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/CityFragment.java b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/CityFragment.java index 69489a4..0c8156a 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/CityFragment.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/CityFragment.java @@ -16,6 +16,11 @@ 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.WebAPICallbacks.ListProvincesCallback; +import net.irext.webapi.WebAPICallbacks.ListCitiesCallback; +import net.irext.webapi.WebAPICallbacks.ListOperatersCallback; + import net.irext.webapi.model.City; import net.irext.webapi.model.StbOperator; @@ -57,6 +62,70 @@ public class CityFragment extends BaseCreateFragment { private MsgHandler mMsgHandler; private IRApplication mApp; + private ListProvincesCallback mListProvincesCallback = new ListProvincesCallback() { + @Override + public void onListProvincesSuccess(List provinces) { + mProvinces = provinces; + if (null == mProvinces) { + mProvinces = new ArrayList<>(); + } + MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_PROVINCE_LIST); + } + + @Override + public void onListProvincesFailed() { + Log.w(TAG, "list provinces failed"); + } + + @Override + public void onListProvincesError() { + Log.e(TAG, "list provinces error"); + } + }; + + private ListCitiesCallback mListCitiesCallback = new ListCitiesCallback() { + @Override + public void onListCitiesSuccess(List cities) { + mCities = cities; + if (null == mCities) { + mCities = new ArrayList<>(); + } + MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_CITY_LIST); + } + + @Override + public void onListCitiesFailed() { + Log.w(TAG, "list cities failed"); + } + + @Override + public void onListCitiesError() { + Log.w(TAG, "list cities error"); + } + }; + + private ListOperatersCallback mListOperatorCallback = new ListOperatersCallback() { + + @Override + public void onListOperatorsSuccess(List operators) { + mOperators = operators; + if (null == mOperators) { + mOperators = new ArrayList<>(); + } + MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_OPERATOR_LIST); + } + + @Override + public void onListOperatorsFailed() { + Log.w(TAG, "list operators failed"); + } + + @Override + public void onListOperatorsError() { + Log.e(TAG, "list operators error"); + } + }; + private City mCurrentProvince; private int mListLevel = LEVEL_PROVINCE; @@ -70,13 +139,8 @@ public class CityFragment extends BaseCreateFragment { new Thread() { @Override public void run() { - mProvinces = mApp.mWeAPIs - .listProvinces(); - - if (null == mProvinces) { - mProvinces = new ArrayList<>(); - } - MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_PROVINCE_LIST); + mApp.mWeAPIs + .listProvinces(mListProvincesCallback); } }.start(); } else { @@ -89,13 +153,8 @@ public class CityFragment extends BaseCreateFragment { new Thread() { @Override public void run() { - mCities = mApp.mWeAPIs - .listCities(prefix); - - if (null == mCities) { - mCities = new ArrayList<>(); - } - MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_CITY_LIST); + mApp.mWeAPIs + .listCities(prefix, mListCitiesCallback); } }.start(); } @@ -105,13 +164,8 @@ public class CityFragment extends BaseCreateFragment { new Thread() { @Override public void run() { - mOperators = mApp.mWeAPIs - .listOperators(cityCode); - - if (null == mOperators) { - mOperators = new ArrayList<>(); - } - MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_OPERATOR_LIST); + mApp.mWeAPIs + .listOperators(cityCode, mListOperatorCallback); } }.start(); } diff --git a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/IndexFragment.java b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/IndexFragment.java index 5a47316..721b251 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/IndexFragment.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/IndexFragment.java @@ -17,6 +17,8 @@ import net.irext.ircontrol.R; import net.irext.ircontrol.ui.adapter.IndexAdapter; import net.irext.ircontrol.utils.FileUtils; import net.irext.ircontrol.utils.MessageUtil; +import net.irext.webapi.WebAPICallbacks.ListIndexesCallback; +import net.irext.webapi.WebAPICallbacks.DownloadBinCallback; import net.irext.webapi.model.Brand; import net.irext.webapi.model.Category; import net.irext.webapi.model.City; @@ -45,7 +47,8 @@ public class IndexFragment extends BaseCreateFragment { private static final int CMD_REFRESH_INDEX_LIST = 0; private static final int CMD_DOWNLOAD_BIN_FILE = 1; - private static final int CMD_SAVE_REMOTE_CONTROL = 2; + private static final int CMD_BIN_FILE_DOWNLOADED = 2; + private static final int CMD_SAVE_REMOTE_CONTROL = 3; private PullToRefreshListView mIndexList; @@ -61,11 +64,54 @@ public class IndexFragment extends BaseCreateFragment { private String mBrandName = ""; private String mOperatorName = ""; + private InputStream mBinStream; + private IndexAdapter mIndexAdapter; private MsgHandler mMsgHandler; private IRApplication mApp; + private ListIndexesCallback mListIndexesCallback = new ListIndexesCallback() { + + @Override + public void onListIndexesSuccess(List indexes) { + mIndexes = indexes; + if (null == mIndexes) { + mIndexes = new ArrayList<>(); + } + MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_INDEX_LIST); + } + + @Override + public void onListIndexesFailed() { + Log.w(TAG, "list indexes failed"); + } + + @Override + public void onListIndexesError() { + Log.e(TAG, "list indexes error"); + } + }; + + private DownloadBinCallback mDownloadBinCallback = new DownloadBinCallback() { + @Override + public void onDownloadBinSuccess(InputStream inputStream) { + Log.d(TAG, "binary file download successfully"); + mBinStream = inputStream; + MessageUtil.postMessage(mMsgHandler, CMD_BIN_FILE_DOWNLOADED); + } + + @Override + public void onDownloadBinFailed() { + Log.w(TAG, "download bin file failed"); + } + + @Override + public void onDownloadBinError() { + Log.w(TAG, "download bin file error"); + } + }; + public IndexFragment() { } @@ -74,12 +120,8 @@ public class IndexFragment extends BaseCreateFragment { new Thread() { @Override public void run() { - mIndexes = mApp.mWeAPIs.listRemoteIndexes(mParent.getCurrentCategory().getId(), - mBrandId, mCityCode, mOperatorId); - if (null == mIndexes) { - mIndexes = new ArrayList<>(); - } - MessageUtil.postMessage(mMsgHandler, CMD_REFRESH_INDEX_LIST); + mApp.mWeAPIs.listRemoteIndexes(mParent.getCurrentCategory().getId(), + mBrandId, mCityCode, mOperatorId, mListIndexesCallback); } }.start(); } @@ -91,21 +133,7 @@ public class IndexFragment extends BaseCreateFragment { 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"); - } + mApp.mWeAPIs.downloadBin(remoteMap, indexId, mDownloadBinCallback); } catch (Exception e) { e.printStackTrace(); } @@ -121,6 +149,29 @@ public class IndexFragment extends BaseCreateFragment { return file.mkdirs(); } + private void saveBinFile() { + new Thread() { + @Override + public void run() { + if (createDirectory()) { + File binFile = new File(FileUtils.BIN_PATH + + FileUtils.FILE_NAME_PREFIX + mCurrentIndex.getRemoteMap() + + FileUtils.FILE_NAME_EXT); + boolean ret = FileUtils.write(binFile, mBinStream); + Log.d(TAG, "write bin file succeeded : " + ret); + } else { + Log.w(TAG, "no directory to contain bin file"); + } + + if (null != mBinStream) { + MessageUtil.postMessage(mMsgHandler, CMD_SAVE_REMOTE_CONTROL); + } else { + Log.e(TAG, "bin file download failed"); + } + } + }.start(); + } + private void saveRemoteControl() { // TODO: update brand and operator name i18n RemoteControl remoteControl = new RemoteControl(); @@ -138,6 +189,8 @@ public class IndexFragment extends BaseCreateFragment { remoteControl.setSubCategory(mCurrentIndex.getSubCate()); long id = RemoteControl.createRemoteControl(remoteControl); + + Log.d(TAG, "save remote control : " + id); mParent.finish(); } @@ -226,6 +279,10 @@ public class IndexFragment extends BaseCreateFragment { indexFragment.downloadBinFile(); break; + case CMD_BIN_FILE_DOWNLOADED: + indexFragment.saveBinFile(); + break; + case CMD_SAVE_REMOTE_CONTROL: indexFragment.saveRemoteControl(); diff --git a/android-example/web-api/.gitignore b/android-example/web-api/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/android-example/web-api/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android-example/web-api/README.md b/android-example/web-api/README.md new file mode 100644 index 0000000..25568bd --- /dev/null +++ b/android-example/web-api/README.md @@ -0,0 +1,65 @@ +## Usage + +### 1. Register your APP +Register your APP on irext SDK console [irext SDK console](http://irext.net), (You need to register an irext account first) + +You need to fetch the package name and SHA1 signature of your APP and fill these information as SDK registration information + +While your APP is registered, you can see the APP key and APP secret in your APP list + +### 2. Import the SDK +You can either import this project or download the web-api .aar file from [Android SDK](http://irext-lib-releaese.oss-cn-hangzhou.aliyuncs.com/decode/0.1.2/web-api-android-0.1.2.aar) and import to your Android APP project + +Add 2 meta-data tags to your AndroidManifest.xml providing APP key and secret get from step 1. +```xml + + + +``` + +### 3. Use the SDK + +Import classes: +```java +import net.irext.webapi.model.*; +import net.irext.webapi.WebAPIs; +``` +Get web API instance: +```java +WebAPIs webApis = WebAPIs.getInstance(); +``` +Sign in for access id and token: +```java +UserApp userApp = webApis.signIn(context); +int id = userApp.getId(); +int token = userApp.getToken(); +``` +Fetch household appliances categories: +```java +List categories = webApis.listCategories(); +``` +Fetch brands of a certain category other than STB: +```java +List brands = webApis.listBrands(category.getId()); +``` +Fetch cities (in China) for STB: +```java +List provinces = webApis.listProvinces(); +List cities = webApis.listCities(provincePrefix); +``` +Fetch STB operators of a certain city: +```java +List; operators = webApis.listOperators(cityCode); +``` +Fetch remote indexes of a certain brand or STB operator: +```java +List remoteIndexes = webApis.listRemoteIndexes(category.getId(), brand.getId(), city.getCode(), operator.getOperator_id()); +``` +Download IR binary for certain remote index: +```java +InputStream is = webApis.downloadBin(remoteIndex.getRemote_map(), remoteIndex.getId()); +``` diff --git a/android-example/web-api/build.gradle b/android-example/web-api/build.gradle index 46e9cb1..05bdee6 100644 --- a/android-example/web-api/build.gradle +++ b/android-example/web-api/build.gradle @@ -1,2 +1,29 @@ -configurations.maybeCreate("default") -artifacts.add("default", file('web-api.aar')) \ No newline at end of file +apply plugin: 'com.android.library' + +android { + signingConfigs { + } + compileSdkVersion 25 + buildToolsVersion "25.0.2" + defaultConfig { + minSdkVersion 19 + targetSdkVersion 25 + versionCode 1 + versionName "0.1.2" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + versionNameSuffix '0.1.2' + } + } + productFlavors { + } +} + +dependencies { + compile files('libs/gson-2.8.0.jar') + compile files('libs/okhttp-3.7.0.jar') + compile files('libs/okio-1.12.0.jar') +} diff --git a/android-example/web-api/libs/gson-2.8.0.jar b/android-example/web-api/libs/gson-2.8.0.jar new file mode 100644 index 0000000..1235f63 Binary files /dev/null and b/android-example/web-api/libs/gson-2.8.0.jar differ diff --git a/android-example/web-api/libs/okhttp-3.7.0.jar b/android-example/web-api/libs/okhttp-3.7.0.jar new file mode 100644 index 0000000..853c553 Binary files /dev/null and b/android-example/web-api/libs/okhttp-3.7.0.jar differ diff --git a/android-example/web-api/libs/okio-1.12.0.jar b/android-example/web-api/libs/okio-1.12.0.jar new file mode 100644 index 0000000..0ac0d70 Binary files /dev/null and b/android-example/web-api/libs/okio-1.12.0.jar differ diff --git a/android-example/web-api/proguard-rules.pro b/android-example/web-api/proguard-rules.pro new file mode 100644 index 0000000..e4fe55e --- /dev/null +++ b/android-example/web-api/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Android\android-sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# 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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android-example/web-api/src/main/AndroidManifest.xml b/android-example/web-api/src/main/AndroidManifest.xml new file mode 100644 index 0000000..179f9a3 --- /dev/null +++ b/android-example/web-api/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/android-example/web-api/src/main/java/net/irext/webapi/WebAPICallbacks.java b/android-example/web-api/src/main/java/net/irext/webapi/WebAPICallbacks.java new file mode 100644 index 0000000..bdac629 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/WebAPICallbacks.java @@ -0,0 +1,90 @@ +package net.irext.webapi; + +import net.irext.webapi.model.Brand; +import net.irext.webapi.model.Category; +import net.irext.webapi.model.City; +import net.irext.webapi.model.RemoteIndex; +import net.irext.webapi.model.StbOperator; +import net.irext.webapi.model.UserApp; + +import java.io.InputStream; +import java.util.List; + +/** + * Filename: WebAPICallbacks.java + * Revised: Date: 2017-07-01 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Response Callbacks + *

+ * Revision log: + * 2017-07-01: created by strawmanbobi + */ +public class WebAPICallbacks { + + public interface SignInCallback { + void onSignInSuccess(UserApp admin); + void onSignInFailed(); + void onSignInError(); + } + + public interface ListCategoriesCallback { + void onListCategoriesSuccess(List categories); + void onListCategoriesFailed(); + void onListCategoriesError(); + } + + public interface ListBrandsCallback { + void onListBrandsSuccess(List brands); + void onListBrandsFailed(); + void onListBrandsError(); + } + + public interface ListPopularBrandsCallback { + void onListPopularBrandsSuccess(List brands); + void onListPopularBrandsFailed(); + void onListPopularBrandsError(); + } + + public interface ListPopularCitiesCallback { + void onListPopularCitiesSuccess(List cities); + void onListPopularCitiesFailed(); + void onListPopularCitiesError(); + } + + public interface ListProvincesCallback { + void onListProvincesSuccess(List provinces); + void onListProvincesFailed(); + void onListProvincesError(); + } + + public interface ListCitiesCallback { + void onListCitiesSuccess(List cities); + void onListCitiesFailed(); + void onListCitiesError(); + } + + public interface ListAreasCallback { + void onListAreasSuccess(List cities); + void onListAreasFailed(); + void onListAreasError(); + } + + public interface ListOperatersCallback { + void onListOperatorsSuccess(List operators); + void onListOperatorsFailed(); + void onListOperatorsError(); + } + + public interface ListIndexesCallback { + void onListIndexesSuccess(List indexes); + void onListIndexesFailed(); + void onListIndexesError(); + } + + public interface DownloadBinCallback { + void onDownloadBinSuccess(InputStream inputStream); + void onDownloadBinFailed(); + void onDownloadBinError(); + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java b/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java new file mode 100644 index 0000000..7f4c92a --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java @@ -0,0 +1,357 @@ +package net.irext.webapi; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; + +import com.google.gson.Gson; +import net.irext.webapi.model.*; +import net.irext.webapi.utils.Constants; +import net.irext.webapi.request.*; +import net.irext.webapi.response.*; +import net.irext.webapi.utils.PackageUtils; +import net.irext.webapi.WebAPICallbacks.*; + +import okhttp3.*; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Filename: WebAPIs.java + * Revised: Date: 2017-03-30 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Request initializer + *

+ * Revision log: + * 2017-03-30: created by strawmanbobi + */ +public class WebAPIs { + + @SuppressWarnings("all") + private static final String TAG = WebAPIs.class.getSimpleName(); + + private static WebAPIs mInstance = null; + + private static final String DEFAULT_ADDRESS = "http://irext.net"; + private static final String DEFAULT_APP = "/irext-server"; + private static String URL_PREFIX = DEFAULT_ADDRESS + DEFAULT_APP; + + private static final String SERVICE_SIGN_IN = "/app/app_login"; + private static final String SERVICE_LIST_CATEGORIES = "/indexing/list_categories"; + private static final String SERVICE_LIST_BRANDS = "/indexing/list_brands"; + private static final String SERVICE_LIST_PROVINCES = "/indexing/list_provinces"; + private static final String SERVICE_LIST_CITIES = "/indexing/list_cities"; + private static final String SERVICE_LIST_OPERATORS = "/indexing/list_operators"; + private static final String SERVICE_LIST_INDEXES = "/indexing/list_indexes"; + private static final String SERVICE_DOWNLOAD_BIN = "/operation/download_bin"; + private static final String SERVICE_ONLINE_DECODE = "/operation/decode"; + + private int adminId; + private String token; + + private OkHttpClient mHttpClient; + + private WebAPIs(String address, String appName) { + if (null != address && null != appName) { + URL_PREFIX = address + appName; + } + mHttpClient = new OkHttpClient(); + } + + private static void initializeInstance(String address, String appName) { + mInstance = new WebAPIs(address, appName); + } + + @SuppressWarnings("unused") + public static WebAPIs getInstance(String address, String appName) { + if (null == mInstance) { + initializeInstance(address, appName); + } + return mInstance; + } + + private String postToServer(String url, String json) throws IOException { + MediaType JSON + = MediaType.parse("application/json; charset=utf-8"); + + RequestBody body = RequestBody.create(JSON, json); + Request request = new Request.Builder() + .url(url) + .post(body) + .build(); + Response response = mHttpClient.newCall(request).execute(); + return response.body().string(); + } + + private InputStream postToServerForOctets(String url, String json) throws IOException { + MediaType JSON + = MediaType.parse("application/json; charset=utf-8"); + RequestBody body = RequestBody.create(JSON, json); + + Request request = new Request.Builder() + .url(url) + .post(body) + .build(); + + Response response = mHttpClient.newCall(request).execute(); + return response.body().byteStream(); + } + + @SuppressWarnings("unused") + public void signIn(Context context, SignInCallback signInCallback) { + try { + String signInURL = URL_PREFIX + SERVICE_SIGN_IN; + AppSignInRequest appSignInRequest = new AppSignInRequest(); + + ApplicationInfo appInfo = context.getPackageManager() + .getApplicationInfo(context.getPackageName(), + PackageManager.GET_META_DATA); + String appKey = appInfo.metaData.getString("irext_app_key"); + String appSecret = appInfo.metaData.getString("irext_app_secret"); + + appSignInRequest.setAppKey(appKey); + appSignInRequest.setAppSecret(appSecret); + appSignInRequest.setAppType(0); + + String packageName = context.getApplicationContext().getPackageName(); + appSignInRequest.setAndroidPackageName(packageName); + + String signature = PackageUtils.getCertificateSHA1Fingerprint(context); + + appSignInRequest.setAndroidSignature(signature); + String bodyJson = appSignInRequest.toJson(); + + String response = postToServer(signInURL, bodyJson); + LoginResponse loginResponse = new Gson().fromJson(response, LoginResponse.class); + if (loginResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + UserApp admin = loginResponse.getEntity(); + if (0 != admin.getId() && null != admin.getToken()) { + adminId = admin.getId(); + token = admin.getToken(); + signInCallback.onSignInSuccess(admin); + } else { + signInCallback.onSignInFailed(); + } + } + } catch (Exception e) { + e.printStackTrace(); + signInCallback.onSignInError(); + } + } + + @SuppressWarnings("unused") + public void listCategories(int from, int count, ListCategoriesCallback listCategoriesCallback) { + String listCategoriesURL = URL_PREFIX + SERVICE_LIST_CATEGORIES; + ListCategoriesRequest listCategoriesRequest = new ListCategoriesRequest(); + listCategoriesRequest.setAdminId(adminId); + listCategoriesRequest.setToken(token); + listCategoriesRequest.setFrom(from); + listCategoriesRequest.setCount(count); + String bodyJson = listCategoriesRequest.toJson(); + + try { + String response = postToServer(listCategoriesURL, bodyJson); + CategoriesResponse categoriesResponse = new Gson().fromJson(response, CategoriesResponse.class); + + if(categoriesResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + listCategoriesCallback.onListCategoriesSuccess(categoriesResponse.getEntity()); + } else { + listCategoriesCallback.onListCategoriesFailed(); + } + } catch (Exception e) { + e.printStackTrace(); + listCategoriesCallback.onListCategoriesError(); + } + } + + @SuppressWarnings("unused") + public void listBrands(int categoryId, int from, int count, + ListBrandsCallback listBrandsCallback) { + String listBrandsURL = URL_PREFIX + SERVICE_LIST_BRANDS; + ListBrandsRequest listBrandsRequest = new ListBrandsRequest(); + listBrandsRequest.setAdminId(adminId); + listBrandsRequest.setToken(token); + listBrandsRequest.setCategoryId(categoryId); + listBrandsRequest.setFrom(from); + listBrandsRequest.setCount(count); + String bodyJson = listBrandsRequest.toJson(); + + try { + String response = postToServer(listBrandsURL, bodyJson); + BrandsResponse brandsResponse = new Gson().fromJson(response, BrandsResponse.class); + + if (brandsResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + listBrandsCallback.onListBrandsSuccess(brandsResponse.getEntity()); + } else { + listBrandsCallback.onListBrandsFailed(); + } + } catch (Exception e) { + e.printStackTrace(); + listBrandsCallback.onListBrandsError(); + } + } + + @SuppressWarnings("unused") + public void listProvinces(ListProvincesCallback listProvincesCallback) { + String listProvincesURL = URL_PREFIX + SERVICE_LIST_PROVINCES; + ListCitiesRequest listCitiesRequest = new ListCitiesRequest(); + listCitiesRequest.setAdminId(adminId); + listCitiesRequest.setToken(token); + String bodyJson = listCitiesRequest.toJson(); + + try { + String response = postToServer(listProvincesURL, bodyJson); + CitiesResponse citiesResponse = new Gson().fromJson(response, CitiesResponse.class); + + if (citiesResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + listProvincesCallback.onListProvincesSuccess(citiesResponse.getEntity()); + } else { + listProvincesCallback.onListProvincesFailed(); + } + } catch (Exception e) { + e.printStackTrace(); + listProvincesCallback.onListProvincesError(); + } + } + + @SuppressWarnings("unused") + public void listCities(String prefix, ListCitiesCallback listCitiesCallback) { + String listCitiesURL = URL_PREFIX + SERVICE_LIST_CITIES; + ListCitiesRequest listCitiesRequest = new ListCitiesRequest(); + listCitiesRequest.setAdminId(adminId); + listCitiesRequest.setToken(token); + listCitiesRequest.setProvincePrefix(prefix); + String bodyJson = listCitiesRequest.toJson(); + + try { + String response = postToServer(listCitiesURL, bodyJson); + CitiesResponse citiesResponse = new Gson().fromJson(response, CitiesResponse.class); + + if (citiesResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + listCitiesCallback.onListCitiesSuccess(citiesResponse.getEntity()); + } else { + listCitiesCallback.onListCitiesFailed(); + } + } catch (Exception e) { + e.printStackTrace(); + listCitiesCallback.onListCitiesError(); + } + } + + @SuppressWarnings("unused") + public void listOperators(String cityCode, + ListOperatersCallback listOperatersCallback) { + String listOperatorsURL = URL_PREFIX + SERVICE_LIST_OPERATORS; + ListOperatorsRequest listOperatorsRequest = new ListOperatorsRequest(); + listOperatorsRequest.setAdminId(adminId); + listOperatorsRequest.setToken(token); + listOperatorsRequest.setCityCode(cityCode); + listOperatorsRequest.setFrom(0); + listOperatorsRequest.setCount(20); + String bodyJson = listOperatorsRequest.toJson(); + + try { + String response = postToServer(listOperatorsURL, bodyJson); + OperatorsResponse operatorsResponse = new Gson().fromJson(response, OperatorsResponse.class); + + if (operatorsResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + listOperatersCallback.onListOperatorsSuccess(operatorsResponse.getEntity()); + } else { + listOperatersCallback.onListOperatorsFailed(); + } + } catch (Exception e) { + e.printStackTrace(); + listOperatersCallback.onListOperatorsError(); + } + } + + @SuppressWarnings("unused") + public void listRemoteIndexes(int categoryId, + int brandId, + String cityCode, + String operatorId, + ListIndexesCallback onListIndexCallback) { + String listIndexesURL = URL_PREFIX + SERVICE_LIST_INDEXES; + ListIndexesRequest listIndexesRequest = new ListIndexesRequest(); + listIndexesRequest.setAdminId(adminId); + listIndexesRequest.setToken(token); + listIndexesRequest.setCategoryId(categoryId); + listIndexesRequest.setBrandId(brandId); + listIndexesRequest.setCityCode(cityCode); + listIndexesRequest.setOperatorId(operatorId); + listIndexesRequest.setFrom(0); + listIndexesRequest.setCount(20); + String bodyJson = listIndexesRequest.toJson(); + + try { + String response = postToServer(listIndexesURL, bodyJson); + + IndexesResponse indexesResponse = new Gson().fromJson(response, IndexesResponse.class); + + if (indexesResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + onListIndexCallback.onListIndexesSuccess(indexesResponse.getEntity()); + } else { + onListIndexCallback.onListIndexesFailed(); + } + } catch (Exception e) { + e.printStackTrace(); + onListIndexCallback.onListIndexesError(); + } + } + + @SuppressWarnings("unused") + public void downloadBin(String remoteMap, int indexId, + DownloadBinCallback downloadBinCallback) { + String downloadURL = URL_PREFIX + SERVICE_DOWNLOAD_BIN; + DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest(); + downloadBinaryRequest.setAdminId(adminId); + downloadBinaryRequest.setToken(token); + downloadBinaryRequest.setIndexId(indexId); + + String bodyJson = downloadBinaryRequest.toJson(); + + if (null != bodyJson) { + try { + InputStream binStream = postToServerForOctets(downloadURL, bodyJson); + + if (null != binStream) { + downloadBinCallback.onDownloadBinSuccess(binStream); + } else { + downloadBinCallback.onDownloadBinFailed(); + } + } catch (IOException e) { + e.printStackTrace(); + downloadBinCallback.onDownloadBinError(); + } + } + } + + @SuppressWarnings("unused") + @Deprecated + public int[] decodeIR(int indexId) { + String decodeURL = URL_PREFIX + SERVICE_ONLINE_DECODE; + DecodeRequest decodeRequest = new DecodeRequest(); + decodeRequest.setAdminId(adminId); + decodeRequest.setToken(token); + decodeRequest.setIndexId(indexId); + + String bodyJson = decodeRequest.toJson(); + + if (null != bodyJson) { + try { + String response = postToServer(decodeURL, bodyJson); + + DecodeResponse decodeResponse = new Gson().fromJson(response, DecodeResponse.class); + + if (decodeResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + return decodeResponse.getEntity(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/bean/ACStatus.java b/android-example/web-api/src/main/java/net/irext/webapi/bean/ACStatus.java new file mode 100644 index 0000000..ca4c51d --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/bean/ACStatus.java @@ -0,0 +1,104 @@ +package net.irext.webapi.bean; + +/** + * Filename: ACStatus.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: Status descriptor for air-conditioner + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class ACStatus { + + private static final String TAG = ACStatus.class.getSimpleName(); + + private int acPower; + private int acTemp; + private int acMode; + private int acWindDir; + private int acWindSpeed; + private int acDisplay; + private int acSleep; + private int acTimer; + + public ACStatus() { + } + + public ACStatus(int acPower, int acMode, int acTemp, int acWindSpeed, int acWindDir, + int acDisplay, int acSleep, int acTimer) { + this.acPower = acPower; + this.acTemp = acTemp; + this.acMode = acMode; + this.acWindDir = acWindDir; + this.acWindSpeed = acWindSpeed; + this.acDisplay = acDisplay; + this.acSleep = acSleep; + this.acTimer = acTimer; + } + + public int getAcPower() { + return acPower; + } + + public void setAcPower(int acPower) { + this.acPower = acPower; + } + + public int getAcTemp() { + return acTemp; + } + + public void setAcTemp(int acTemp) { + this.acTemp = acTemp; + } + + public int getAcMode() { + return acMode; + } + + public void setAcMode(int acMode) { + this.acMode = acMode; + } + + public int getAcWindDir() { + return acWindDir; + } + + public void setAcWindDir(int acWindDir) { + this.acWindDir = acWindDir; + } + + public int getAcWindSpeed() { + return acWindSpeed; + } + + public void setAcWindSpeed(int acWindSpeed) { + this.acWindSpeed = acWindSpeed; + } + + public int getAcDisplay() { + return acDisplay; + } + + public void setAcDisplay(int acDisplay) { + this.acDisplay = acDisplay; + } + + public int getAcSleep() { + return acSleep; + } + + public void setAcSleep(int acSleep) { + this.acSleep = acSleep; + } + + public int getAcTimer() { + return acTimer; + } + + public void setAcTimer(int acTimer) { + this.acTimer = acTimer; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/bean/TemperatureRange.java b/android-example/web-api/src/main/java/net/irext/webapi/bean/TemperatureRange.java new file mode 100644 index 0000000..5e5106d --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/bean/TemperatureRange.java @@ -0,0 +1,43 @@ +package net.irext.webapi.bean; + +/** + * Filename: TemperatureRange.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: Temperature range for air-conditioner + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class TemperatureRange { + + private static final String TAG = TemperatureRange.class.getSimpleName(); + + private int tempMin; + private int tempMax; + + public TemperatureRange() { + } + + public TemperatureRange(int tempMin, int tempMax) { + this.tempMin = tempMin; + this.tempMax = tempMax; + } + + public int getTempMin() { + return tempMin; + } + + public void setTempMin(int tempMin) { + this.tempMin = tempMin; + } + + public int getTempMax() { + return tempMax; + } + + public void setTempMax(int tempMax) { + this.tempMax = tempMax; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/model/Brand.java b/android-example/web-api/src/main/java/net/irext/webapi/model/Brand.java new file mode 100644 index 0000000..d7fa2be --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/model/Brand.java @@ -0,0 +1,124 @@ +package net.irext.webapi.model; + +/** + * Filename: Brand.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: Brand bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class Brand { + + private int id; + private String name; + private int categoryId; + private String categoryName; + private int status; + private String updateTime; + private int priority; + private String nameEn; + private String nameTw; + private String contributor; + + public Brand(int id, String name, int categoryId, String categoryName, int status, + String updateTime, int priority, + String nameEn, String nameTw, String contributor) { + this.id = id; + this.name = name; + this.categoryId = categoryId; + this.categoryName = categoryName; + this.status = status; + this.updateTime = updateTime; + this.priority = priority; + this.nameEn = nameEn; + this.nameTw = nameTw; + this.contributor = contributor; + } + + public Brand() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public int getPriority() { + return priority; + } + + public void setPriority(int priority) { + this.priority = priority; + } + + public String getNameEn() { + return nameEn; + } + + public void setNameEn(String nameEn) { + this.nameEn = nameEn; + } + + public String getNameTw() { + return nameTw; + } + + public void setNameTw(String nameTw) { + this.nameTw = nameTw; + } + + public String getContributor() { + return contributor; + } + + public void setContributor(String contributor) { + this.contributor = contributor; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/model/Category.java b/android-example/web-api/src/main/java/net/irext/webapi/model/Category.java new file mode 100644 index 0000000..9e36e8a --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/model/Category.java @@ -0,0 +1,93 @@ +package net.irext.webapi.model; + +/** + * Filename: Category.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: Category bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class Category { + + private int id; + private String name; + private int status; + private String updateTime; + private String nameEn; + private String nameTw; + private String contributor; + + public Category(int id, String name, int status, String updateTime, + String nameEn, String nameTw, String contributor) { + this.id = id; + this.name = name; + this.status = status; + this.updateTime = updateTime; + this.nameEn = nameEn; + this.nameTw = nameTw; + this.contributor = contributor; + } + + public Category() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getNameEn() { + return nameEn; + } + + public void setNameEn(String nameEn) { + this.nameEn = nameEn; + } + + public String getNameTw() { + return nameTw; + } + + public void setNameTw(String nameTw) { + this.nameTw = nameTw; + } + + public String getContributor() { + return contributor; + } + + public void setContributor(String contributor) { + this.contributor = contributor; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/model/City.java b/android-example/web-api/src/main/java/net/irext/webapi/model/City.java new file mode 100644 index 0000000..6105c34 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/model/City.java @@ -0,0 +1,93 @@ +package net.irext.webapi.model; + +/** + * Filename: City.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: City bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class City { + + private int id; + private String code; + private String name; + private double longitude; + private double latitude; + private int status; + private String nameTw; + + public City(int id, String code, String name, double longitude, double latitude, + int status, String nameTw) { + this.id = id; + this.code = code; + this.name = name; + this.longitude = longitude; + this.latitude = latitude; + this.status = status; + this.nameTw = nameTw; + } + + public City() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getNameTw() { + return nameTw; + } + + public void setNameTw(String nameTw) { + this.nameTw = nameTw; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/model/RemoteIndex.java b/android-example/web-api/src/main/java/net/irext/webapi/model/RemoteIndex.java new file mode 100644 index 0000000..57e7314 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/model/RemoteIndex.java @@ -0,0 +1,259 @@ +package net.irext.webapi.model; + +/** + * Filename: RemoteIndex.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: RemoteIndex bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class RemoteIndex { + + private int id; + private int categoryId; + private String categoryName; + private int brandId; + private String brandName; + private String cityCode; + private String cityName; + private String operatorId; + private String operatorName; + private String protocol; + private String remote; + private String remoteMap; + private int status; + private int subCate; + private int priority; + private String remoteNumber; + private String categoryNameTw; + private String brandNameTw; + private String cityNameTw; + private String operatorNameTw; + private String binaryMd5; + private String contributor; + private String updateTime; + + public RemoteIndex(int id, + int categoryId, String categoryName, int brandId, String brandName, + String cityCode, String cityName, String operatorId, String operatorName, + String protocol, String remote, String remoteMap, int status, int subCate, + int priority, String remoteNumber, + String categoryNameTw, String brandNameTw, + String cityNameTw, String operatorNameTw, + String binaryMd5, String contributor, String updateTime) { + this.id = id; + this.categoryId = categoryId; + this.categoryName = categoryName; + this.brandId = brandId; + this.brandName = brandName; + this.cityCode = cityCode; + this.cityName = cityName; + this.operatorId = operatorId; + this.operatorName = operatorName; + this.protocol = protocol; + this.remote = remote; + this.remoteMap = remoteMap; + this.status = status; + this.subCate = subCate; + this.priority = priority; + this.remoteNumber = remoteNumber; + this.categoryNameTw = categoryNameTw; + this.brandNameTw = brandNameTw; + this.cityNameTw = cityNameTw; + this.operatorNameTw = operatorNameTw; + this.binaryMd5 = binaryMd5; + this.contributor = contributor; + this.updateTime = updateTime; + } + + public RemoteIndex() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public int getBrandId() { + return brandId; + } + + public void setBrandId(int brandId) { + this.brandId = brandId; + } + + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName = brandName; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getRemote() { + return remote; + } + + public void setRemote(String remote) { + this.remote = remote; + } + + public String getRemoteMap() { + return remoteMap; + } + + public void setRemoteMap(String remoteMap) { + this.remoteMap = remoteMap; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public int getSubCate() { + return subCate; + } + + public void setSubCate(int subCate) { + this.subCate = subCate; + } + + public int getPriority() { + return priority; + } + + public void setPriority(int priority) { + this.priority = priority; + } + + public String getRemoteNumber() { + return remoteNumber; + } + + public void setRemoteNumber(String remoteNumber) { + this.remoteNumber = remoteNumber; + } + + public String getCategoryNameTw() { + return categoryNameTw; + } + + public void setCategoryNameTw(String categoryNameTw) { + this.categoryNameTw = categoryNameTw; + } + + public String getBrandNameTw() { + return brandNameTw; + } + + public void setBrandNameTw(String brandNameTw) { + this.brandNameTw = brandNameTw; + } + + public String getCityNameTw() { + return cityNameTw; + } + + public void setCityNameTw(String cityNameTw) { + this.cityNameTw = cityNameTw; + } + + public String getOperatorNameTw() { + return operatorNameTw; + } + + public void setOperatorNameTw(String operatorNameTw) { + this.operatorNameTw = operatorNameTw; + } + + public String getBinaryMd5() { + return binaryMd5; + } + + public void setBinaryMd5(String binaryMd5) { + this.binaryMd5 = binaryMd5; + } + + public String getContributor() { + return contributor; + } + + public void setContributor(String contributor) { + this.contributor = contributor; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/model/StbOperator.java b/android-example/web-api/src/main/java/net/irext/webapi/model/StbOperator.java new file mode 100644 index 0000000..167d938 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/model/StbOperator.java @@ -0,0 +1,93 @@ +package net.irext.webapi.model; + +/** + * Filename: StbOperator.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: StbOperator bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class StbOperator { + + private int id; + private String operatorId; + private String operatorName; + private String cityCode; + private String cityName; + private int status; + private String operatorNameTw; + + public StbOperator(int id, String operatorId, String operatorName, + String cityCode, String cityName, int status, String operatorNameTw) { + this.id = id; + this.operatorId = operatorId; + this.operatorName = operatorName; + this.cityCode = cityCode; + this.cityName = cityName; + this.status = status; + this.operatorNameTw = operatorNameTw; + } + + public StbOperator() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getOperatorNameTw() { + return operatorNameTw; + } + + public void setOperatorNameTw(String operatorNameTw) { + this.operatorNameTw = operatorNameTw; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/model/UserApp.java b/android-example/web-api/src/main/java/net/irext/webapi/model/UserApp.java new file mode 100644 index 0000000..e16c502 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/model/UserApp.java @@ -0,0 +1,397 @@ +package net.irext.webapi.model; + +public class UserApp { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private Integer id; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.app_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String appName; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.admin_id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private Integer adminId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.admin_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String adminName; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.app_type + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private Byte appType; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.android_package_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String androidPackageName; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.android_signature + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String androidSignature; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.ios_identity + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String iosIdentity; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.is_debug + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private Byte isDebug; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.app_key + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String appKey; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.app_secret + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String appSecret; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.update_time + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String updateTime; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.id + * + * @return the value of user_app.id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.id + * + * @param id the value for user_app.id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.app_name + * + * @return the value of user_app.app_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAppName() { + return appName; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.app_name + * + * @param appName the value for user_app.app_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAppName(String appName) { + this.appName = appName; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.admin_id + * + * @return the value of user_app.admin_id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public Integer getAdminId() { + return adminId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.admin_id + * + * @param adminId the value for user_app.admin_id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAdminId(Integer adminId) { + this.adminId = adminId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.admin_name + * + * @return the value of user_app.admin_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAdminName() { + return adminName; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.admin_name + * + * @param adminName the value for user_app.admin_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAdminName(String adminName) { + this.adminName = adminName; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.app_type + * + * @return the value of user_app.app_type + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public Byte getAppType() { + return appType; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.app_type + * + * @param appType the value for user_app.app_type + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAppType(Byte appType) { + this.appType = appType; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.android_package_name + * + * @return the value of user_app.android_package_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAndroidPackageName() { + return androidPackageName; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.android_package_name + * + * @param androidPackageName the value for user_app.android_package_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAndroidPackageName(String androidPackageName) { + this.androidPackageName = androidPackageName; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.android_signature + * + * @return the value of user_app.android_signature + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAndroidSignature() { + return androidSignature; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.android_signature + * + * @param androidSignature the value for user_app.android_signature + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAndroidSignature(String androidSignature) { + this.androidSignature = androidSignature; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.ios_identity + * + * @return the value of user_app.ios_identity + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getIosIdentity() { + return iosIdentity; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.ios_identity + * + * @param iosIdentity the value for user_app.ios_identity + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setIosIdentity(String iosIdentity) { + this.iosIdentity = iosIdentity; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.is_debug + * + * @return the value of user_app.is_debug + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public Byte getIsDebug() { + return isDebug; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.is_debug + * + * @param isDebug the value for user_app.is_debug + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setIsDebug(Byte isDebug) { + this.isDebug = isDebug; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.app_key + * + * @return the value of user_app.app_key + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAppKey() { + return appKey; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.app_key + * + * @param appKey the value for user_app.app_key + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAppKey(String appKey) { + this.appKey = appKey; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.app_secret + * + * @return the value of user_app.app_secret + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAppSecret() { + return appSecret; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.app_secret + * + * @param appSecret the value for user_app.app_secret + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAppSecret(String appSecret) { + this.appSecret = appSecret; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.update_time + * + * @return the value of user_app.update_time + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getUpdateTime() { + return updateTime; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.update_time + * + * @param updateTime the value for user_app.update_time + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + private String token; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } +} \ No newline at end of file diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/AppSignInRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/AppSignInRequest.java new file mode 100644 index 0000000..7cb3bc8 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/AppSignInRequest.java @@ -0,0 +1,83 @@ +package net.irext.webapi.request; + +/** + * Filename: AppSignInRequest.java + * Revised: Date: 2017-05-27 + * Revision: Revision: 1.0 + *

+ * Description: HTTP admin login request + *

+ * Revision log: + * 2017-05-27: created by strawmanbobi + */ +public class AppSignInRequest extends BaseRequest { + + private String appKey; + private String appSecret; + private int appType; + private String iOSID; + private String androidPackageName; + private String androidSignature; + + public AppSignInRequest(String appKey, String appSecret, int appType, + String iOSID, String androidPackageName, String androidSignature) { + this.appKey = appKey; + this.appSecret = appSecret; + this.appType = appType; + this.iOSID = iOSID; + this.androidPackageName = androidPackageName; + this.androidSignature = androidSignature; + } + + public AppSignInRequest() { + + } + + public String getAppKey() { + return appKey; + } + + public void setAppKey(String appKey) { + this.appKey = appKey; + } + + public String getAppSecret() { + return appSecret; + } + + public void setAppSecret(String appSecret) { + this.appSecret = appSecret; + } + + public int getAppType() { + return appType; + } + + public void setAppType(int appType) { + this.appType = appType; + } + + public String getiOSID() { + return iOSID; + } + + public void setiOSID(String iOSID) { + this.iOSID = iOSID; + } + + public String getAndroidPackageName() { + return androidPackageName; + } + + public void setAndroidPackageName(String androidPackageName) { + this.androidPackageName = androidPackageName; + } + + public String getAndroidSignature() { + return androidSignature; + } + + public void setAndroidSignature(String androidSignature) { + this.androidSignature = androidSignature; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/BaseRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/BaseRequest.java new file mode 100644 index 0000000..93777aa --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/BaseRequest.java @@ -0,0 +1,48 @@ +package net.irext.webapi.request; + +import com.google.gson.Gson; + +/** + * Filename: BaseRequest.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: authentication factors included + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class BaseRequest { + + private int adminId; + private String token; + + public BaseRequest(int adminId, String token) { + this.adminId = adminId; + this.token = token; + } + + BaseRequest() { + + } + + public int getAdminId() { + return adminId; + } + + public void setAdminId(int adminId) { + this.adminId = adminId; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String toJson() { + return new Gson().toJson(this, this.getClass()); + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/DecodeRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/DecodeRequest.java new file mode 100644 index 0000000..93b977e --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/DecodeRequest.java @@ -0,0 +1,64 @@ +package net.irext.webapi.request; + +import net.irext.webapi.bean.ACStatus; + +/** + * Filename: DecodeRequest.java + * Revised: Date: 2017-05-16 + * Revision: Revision: 1.0 + *

+ * Description: HTTP decode online + *

+ * Revision log: + * 2017-05-16: created by strawmanbobi + */ +public class DecodeRequest extends BaseRequest { + + private int indexId; + private ACStatus acStatus; + private int keyCode; + private int changeWindDir; + + public DecodeRequest(int indexId, ACStatus acStatus, int keyCode, int changeWindDir) { + this.indexId = indexId; + this.acStatus = acStatus; + this.keyCode = keyCode; + this.changeWindDir = changeWindDir; + } + + public DecodeRequest() { + + } + + public int getIndexId() { + return indexId; + } + + public void setIndexId(int indexId) { + this.indexId = indexId; + } + + public ACStatus getAcStatus() { + return acStatus; + } + + public void setAcStatus(ACStatus acStatus) { + this.acStatus = acStatus; + } + + public int getKeyCode() { + return keyCode; + } + + public void setKeyCode(int keyCode) { + this.keyCode = keyCode; + } + + public int getChangeWindDir() { + return changeWindDir; + } + + public void setChangeWindDir(int changeWindDir) { + this.changeWindDir = changeWindDir; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/DownloadBinaryRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/DownloadBinaryRequest.java new file mode 100644 index 0000000..ee995b4 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/DownloadBinaryRequest.java @@ -0,0 +1,32 @@ +package net.irext.webapi.request; + +/** + * Filename: DownloadBinaryRequest.java + * Revised: Date: 2017-04-14 + * Revision: Revision: 1.0 + *

+ * Description: HTTP download IR binary + *

+ * Revision log: + * 2017-04-14: created by strawmanbobi + */ +public class DownloadBinaryRequest extends BaseRequest { + + private int indexId; + + public DownloadBinaryRequest(int indexId) { + this.indexId = indexId; + } + + public DownloadBinaryRequest() { + + } + + public int getIndexId() { + return indexId; + } + + public void setIndexId(int indexId) { + this.indexId = indexId; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/ListBrandsRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/ListBrandsRequest.java new file mode 100644 index 0000000..6dcd236 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/ListBrandsRequest.java @@ -0,0 +1,52 @@ +package net.irext.webapi.request; + +/** + * Filename: ListBrandsRequest.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list brands request + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class ListBrandsRequest extends BaseRequest { + + private int categoryId; + private int from; + private int count; + + public ListBrandsRequest(int categoryId, int from, int count) { + this.categoryId = categoryId; + this.from = from; + this.count = count; + } + + public ListBrandsRequest() { + + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public int getFrom() { + return from; + } + + public void setFrom(int from) { + this.from = from; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/ListCategoriesRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/ListCategoriesRequest.java new file mode 100644 index 0000000..48760f3 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/ListCategoriesRequest.java @@ -0,0 +1,42 @@ +package net.irext.webapi.request; + +/** + * Filename: ListCategoriesRequest.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list categories request + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class ListCategoriesRequest extends BaseRequest { + + private int from; + private int count; + + public ListCategoriesRequest(int from, int count) { + this.from = from; + this.count = count; + } + + public ListCategoriesRequest() { + + } + + public int getFrom() { + return from; + } + + public void setFrom(int from) { + this.from = from; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/ListCitiesRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/ListCitiesRequest.java new file mode 100644 index 0000000..6bd0cd9 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/ListCitiesRequest.java @@ -0,0 +1,32 @@ +package net.irext.webapi.request; + +/** + * Filename: ListCitiesRequest.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list cities request + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class ListCitiesRequest extends BaseRequest { + + private String provincePrefix; + + public ListCitiesRequest(String provincePrefix) { + this.provincePrefix = provincePrefix; + } + + public ListCitiesRequest() { + + } + + public String getProvincePrefix() { + return provincePrefix; + } + + public void setProvincePrefix(String provincePrefix) { + this.provincePrefix = provincePrefix; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/ListIndexesRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/ListIndexesRequest.java new file mode 100644 index 0000000..8ece383 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/ListIndexesRequest.java @@ -0,0 +1,83 @@ +package net.irext.webapi.request; + +/** + * Filename: ListIndexesRequest.java + * Revised: Date: 2017-04-12 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list remote indexes request + *

+ * Revision log: + * 2017-04-12: created by strawmanbobi + */ +public class ListIndexesRequest extends BaseRequest { + + private int from; + private int count; + private int categoryId; + private int brandId; + private String cityCode; + private String operatorId; + + public ListIndexesRequest(int from, int count, int categoryId, int brandId, + String cityCode, String operatorId) { + this.from = from; + this.count = count; + this.categoryId = categoryId; + this.brandId = brandId; + this.cityCode = cityCode; + this.operatorId = operatorId; + } + + public ListIndexesRequest() { + + } + + public int getFrom() { + return from; + } + + public void setFrom(int from) { + this.from = from; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public int getBrandId() { + return brandId; + } + + public void setBrandId(int brandId) { + this.brandId = brandId; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/request/ListOperatorsRequest.java b/android-example/web-api/src/main/java/net/irext/webapi/request/ListOperatorsRequest.java new file mode 100644 index 0000000..264be93 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/request/ListOperatorsRequest.java @@ -0,0 +1,52 @@ +package net.irext.webapi.request; + +/** + * Filename: ListOperatorsRequest.java + * Revised: Date: 2017-04-10 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list STB operators request + *

+ * Revision log: + * 2017-04-10: created by strawmanbobi + */ +public class ListOperatorsRequest extends BaseRequest { + + private int from; + private int count; + private String cityCode; + + public ListOperatorsRequest(int from, int count, String cityCode) { + this.from = from; + this.count = count; + this.cityCode = cityCode; + } + + public ListOperatorsRequest() { + + } + + public int getFrom() { + return from; + } + + public void setFrom(int from) { + this.from = from; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/BrandsResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/BrandsResponse.java new file mode 100644 index 0000000..327227f --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/BrandsResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.Brand; + +import java.util.List; + +/** + * Filename: BrandsResponse.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: List brands response + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class BrandsResponse extends ServiceResponse { + + private List entity; + + public BrandsResponse(Status status, List brands) { + super(status); + this.entity = brands; + } + + public BrandsResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/CategoriesResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/CategoriesResponse.java new file mode 100644 index 0000000..409f582 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/CategoriesResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.Category; + +import java.util.List; + +/** + * Filename: CategoriesResponse.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: List categories response + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class CategoriesResponse extends ServiceResponse { + + private List entity; + + public CategoriesResponse(Status status, List categories) { + super(status); + this.entity = categories; + } + + public CategoriesResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/CitiesResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/CitiesResponse.java new file mode 100644 index 0000000..a97a868 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/CitiesResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.City; + +import java.util.List; + +/** + * Filename: CitiesResponse.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: List cities response + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class CitiesResponse extends ServiceResponse { + + private List entity; + + public CitiesResponse(Status status, List cities) { + super(status); + this.entity = cities; + } + + public CitiesResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/DecodeResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/DecodeResponse.java new file mode 100644 index 0000000..c221f4e --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/DecodeResponse.java @@ -0,0 +1,33 @@ +package net.irext.webapi.response; + +/** + * Filename: DecodeResponse.java + * Revised: Date: 2017-05-16 + * Revision: Revision: 1.0 + *

+ * Description: Online decode response + *

+ * Revision log: + * 2017-05-16: created by strawmanbobi + */ +public class DecodeResponse extends ServiceResponse { + + private int[] entity; + + public DecodeResponse(Status status, int[] entity) { + super(status); + this.entity = entity; + } + + public DecodeResponse() { + + } + + public int[] getEntity() { + return entity; + } + + public void setEntity(int[] entity) { + this.entity = entity; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/IndexesResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/IndexesResponse.java new file mode 100644 index 0000000..7b666a5 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/IndexesResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.RemoteIndex; + +import java.util.List; + +/** + * Filename: IndexesResponse.java + * Revised: Date: 2017-04-12 + * Revision: Revision: 1.0 + *

+ * Description: List remote indexes response + *

+ * Revision log: + * 2017-04-12: created by strawmanbobi + */ +public class IndexesResponse extends ServiceResponse { + + private List entity; + + public IndexesResponse(Status status, List indexes) { + super(status); + this.entity = indexes; + } + + public IndexesResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/LoginResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/LoginResponse.java new file mode 100644 index 0000000..9f06381 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/LoginResponse.java @@ -0,0 +1,35 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.UserApp; + +/** + * Filename: LoginResponse.java + * Revised: Date: 2017-03-31 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Admin login response + *

+ * Revision log: + * 2017-03-31: created by strawmanbobi + */ +public class LoginResponse extends ServiceResponse { + + private UserApp entity; + + public LoginResponse(Status status, UserApp userApp) { + super(status); + this.entity = userApp; + } + + public LoginResponse() { + + } + + public UserApp getEntity() { + return entity; + } + + public void setEntity(UserApp entity) { + this.entity = entity; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/OperatorsResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/OperatorsResponse.java new file mode 100644 index 0000000..4856989 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/OperatorsResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.StbOperator; + +import java.util.List; + +/** + * Filename: OperatorsResponse.java + * Revised: Date: 2017-04-10 + * Revision: Revision: 1.0 + *

+ * Description: List STB operators response + *

+ * Revision log: + * 2017-04-10: created by strawmanbobi + */ +public class OperatorsResponse extends ServiceResponse { + + private List entity; + + public OperatorsResponse(Status status, List cities) { + super(status); + this.entity = cities; + } + + public OperatorsResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/ServiceResponse.java b/android-example/web-api/src/main/java/net/irext/webapi/response/ServiceResponse.java new file mode 100644 index 0000000..8f8852f --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/ServiceResponse.java @@ -0,0 +1,32 @@ +package net.irext.webapi.response; + +/** + * Filename: ServiceResponse.java + * Revised: Date: 2017-03-31 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Response base class + *

+ * Revision log: + * 2017-03-31: created by strawmanbobi + */ +public class ServiceResponse { + + private Status status; + + public ServiceResponse(Status status) { + this.status = status; + } + + public ServiceResponse() { + + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/response/Status.java b/android-example/web-api/src/main/java/net/irext/webapi/response/Status.java new file mode 100644 index 0000000..7c354d4 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/response/Status.java @@ -0,0 +1,42 @@ +package net.irext.webapi.response; + +/** + * Filename: Status.java + * Revised: Date: 2017-03-31 + * Revision: Revision: 1.0 + *

+ * Description: HTTP response status + *

+ * Revision log: + * 2017-03-31: created by strawmanbobi + */ +public class Status { + + private int code; + private String cause; + + public Status(int code, String cause) { + this.code = code; + this.cause = cause; + } + + public Status() { + + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getCause() { + return cause; + } + + public void setCause(String cause) { + this.cause = cause; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/utils/Constants.java b/android-example/web-api/src/main/java/net/irext/webapi/utils/Constants.java new file mode 100644 index 0000000..fa00765 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/utils/Constants.java @@ -0,0 +1,175 @@ +package net.irext.webapi.utils; + +/** + * Filename: Constants.java + * Revised: Date: 2017-04-03 + * Revision: Revision: 1.0 + *

+ * Description: SDK Constants + *

+ * Revision log: + * 2017-04-03: created by strawmanbobi + */ +public class Constants { + + public static final int ERROR_CODE_SUCCESS = 0; + public static final int ERROR_CODE_NETWORK_ERROR = -1; + public static final int ERROR_CODE_AUTH_FAILURE = 1; + public static final int ERROR_CODE_INVALID_CATEGORY = 2; + public static final int ERROR_CODE_INVALID_BRAND = 3; + public static final int ERROR_CODE_INVALID_PARAMETER = 4; + + public enum CategoryID { + AIR_CONDITIONER(1), + TV(2), + STB(3), + NET_BOX(4), + IPTV(5), + DVD(6), + FAN(7), + PROJECTOR(8), + STEREO(9), + LIGHT(10), + BSTB(11), + CLEANING_ROBOT(12), + AIR_CLEANER(13); + + private final int id; + + CategoryID(int id) { + this.id = id; + } + + public int getValue() { + return id; + } + } + + public enum BinaryType { + TYPE_BINARY(0), + TYPE_HEXDECIMAL(1); + + private final int type; + + BinaryType(int type) { + this.type = type; + } + + public int getValue() { + return type; + } + } + + public enum ACPower { + POWER_ON(0), + POWER_OFF(1); + + private final int power; + + ACPower(int power) { + this.power = power; + } + + public int getValue() { + return power; + } + } + + public enum ACMode { + MODE_COOL(0), + MODE_HEAT(1), + MODE_AUTO(2), + MODE_FAN(3), + MODE_DEHUMIDITY(4); + + private final int mode; + + ACMode(int mode) { + this.mode = mode; + } + + public int getValue() { + return mode; + } + } + + public enum ACTemperature { + TEMP_16(0), + TEMP_17(1), + TEMP_18(2), + TEMP_19(3), + TEMP_20(4), + TEMP_21(5), + TEMP_22(6), + TEMP_23(7), + TEMP_24(8), + TEMP_25(9), + TEMP_26(10), + TEMP_27(11), + TEMP_28(12), + TEMP_29(13), + TEMP_30(14); + + private final int temp; + + ACTemperature(int temp) { + this.temp = temp; + } + + public int getValue() { + return temp; + } + } + + public enum ACWindSpeed { + SPEED_AUTO(0), + SPEED_LOW(1), + SPEED_MEDIUM(2), + SPEED_HIGH(3); + + private final int speed; + + ACWindSpeed(int speed) { + this.speed = speed; + } + + public int getValue() { + return speed; + } + } + + public enum ACSwing { + SWING_ON(0), + SWING_OFF(1); + + private final int swing; + + ACSwing(int swing) { + this.swing = swing; + } + + public int getValue() { + return swing; + } + } + + public enum ACFunction { + FUNCTION_SWITCH_POWER(1), + FUNCTION_CHANGE_MODE(2), + FUNCTION_TEMPERATURE_UP(3), + FUNCTION_TEMPERATURE_DOWN(4), + FUNCTION_SWITCH_WIND_SPEED(5), + FUNCTION_SWITCH_WIND_DIR(6), + FUNCTION_SWITCH_SWING(7); + + private final int function; + + ACFunction(int function) { + this.function = function; + } + + public int getValue() { + return function; + } + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/utils/MD5Digest.java b/android-example/web-api/src/main/java/net/irext/webapi/utils/MD5Digest.java new file mode 100644 index 0000000..1c48710 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/utils/MD5Digest.java @@ -0,0 +1,40 @@ +package net.irext.webapi.utils; + +import java.security.MessageDigest; + +/** + * Filename: MD5Digest.java + * Revised: Date: 2017-04-03 + * Revision: Revision: 1.0 + *

+ * Description: MD5 digest algorithm + *

+ * Revision log: + * 2017-04-03: created by strawmanbobi + */ +public class MD5Digest { + + public static String MD5(String content) { + String result = null; + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(content.getBytes()); + byte b[] = md.digest(); + + int i; + + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) i += 256; + if (i < 16) buf.append("0"); + buf.append(Integer.toHexString(i)); + } + result = buf.toString(); + } catch (Exception e) { + e.printStackTrace(); + return content; + } + return result; + } +} diff --git a/android-example/web-api/src/main/java/net/irext/webapi/utils/PackageUtils.java b/android-example/web-api/src/main/java/net/irext/webapi/utils/PackageUtils.java new file mode 100644 index 0000000..f7bac70 --- /dev/null +++ b/android-example/web-api/src/main/java/net/irext/webapi/utils/PackageUtils.java @@ -0,0 +1,79 @@ +package net.irext.webapi.utils; + +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.Signature; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateEncodingException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; + +/** + * Filename: PackageUtils.java + * Revised: Date: 2017-05-27 + * Revision: Revision: 1.0 + *

+ * Description: String utils + *

+ * Revision log: + * 2017-05-27: created by strawmanbobi + */ +public class PackageUtils { + + public static String byte2HexFormatted(byte[] arr) { + StringBuilder str = new StringBuilder(arr.length * 2); + for (int i = 0; i < arr.length; i++) { + String h = Integer.toHexString(arr[i]); + int l = h.length(); + if (l == 1) h = "0" + h; + if (l > 2) h = h.substring(l - 2, l); + str.append(h.toUpperCase()); + if (i < (arr.length - 1)) str.append(':'); + } + return str.toString(); + } + + public static String getCertificateSHA1Fingerprint(Context context) { + PackageManager pm = context.getPackageManager(); + String packageName = context.getPackageName(); + int flags = PackageManager.GET_SIGNATURES; + PackageInfo packageInfo = null; + try { + packageInfo = pm.getPackageInfo(packageName, flags); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + Signature[] signatures = packageInfo.signatures; + byte[] cert = signatures[0].toByteArray(); + InputStream input = new ByteArrayInputStream(cert); + CertificateFactory cf = null; + try { + cf = CertificateFactory.getInstance("X509"); + } catch (CertificateException e) { + e.printStackTrace(); + } + X509Certificate c = null; + try { + c = (X509Certificate) cf.generateCertificate(input); + } catch (CertificateException e) { + e.printStackTrace(); + } + String hexString = null; + try { + MessageDigest md = MessageDigest.getInstance("SHA1"); + byte[] publicKey = md.digest(c.getEncoded()); + hexString = byte2HexFormatted(publicKey); + } catch (NoSuchAlgorithmException e1) { + e1.printStackTrace(); + } catch (CertificateEncodingException e) { + e.printStackTrace(); + } + return hexString; + } +} diff --git a/android-example/web-api/web-api.aar b/android-example/web-api/web-api.aar deleted file mode 100644 index e5a8341..0000000 Binary files a/android-example/web-api/web-api.aar and /dev/null differ