Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #29 from awong1900/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
awong1900 committed Apr 26, 2016
2 parents 1bdb2bd + 7b3fee0 commit 351ce77
Show file tree
Hide file tree
Showing 35 changed files with 396 additions and 706 deletions.
Binary file modified android/app/app-release.apk
Binary file not shown.
16 changes: 9 additions & 7 deletions android/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,23 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
Expand All @@ -99,6 +100,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
Expand Down
8 changes: 4 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "cc.seeed.iot.ap"
minSdkVersion 16
minSdkVersion 17
targetSdkVersion 23
versionCode 15
versionName "2.2.0"
versionCode 16
versionName "2.2.2"
}
buildTypes {
release {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<meta-data
android:name="AA_DB_NAME"
android:value="WioLink.db" />
android:value="Wio.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="1" />
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/java/cc/seeed/iot/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.content.Context;
import android.content.SharedPreferences;

import cc.seeed.iot.datastruct.User;
import cc.seeed.iot.util.User;
import cc.seeed.iot.util.Common;
import cc.seeed.iot.webapi.IotApi;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import cc.seeed.iot.MyApplication;
import cc.seeed.iot.R;
import cc.seeed.iot.datastruct.User;
import cc.seeed.iot.util.User;
import cc.seeed.iot.udp.ConfigUdpSocket;
import cc.seeed.iot.ui_main.MainScreenActivity;
import cc.seeed.iot.webapi.IotApi;
Expand Down Expand Up @@ -55,6 +55,7 @@ public class ApConnectActivity extends AppCompatActivity implements OnClickListe
private String node_sn;
private String node_key;
private ConfigUdpSocket udpClient;
private ProgressDialog mProgressDialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -74,6 +75,10 @@ protected void onCreate(Bundle savedInstanceState) {
mConnectBtnView.setOnClickListener(this);

udpClient = new ConfigUdpSocket();

mProgressDialog = new ProgressDialog(ApConnectActivity.this);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.setCancelable(false);
}

@Override
Expand All @@ -87,6 +92,12 @@ protected void onResume() {
mSsidView.setText(ssid);
}

@Override
protected void onDestroy() {
dismissProgressDialog();
super.onDestroy();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
Expand All @@ -112,19 +123,9 @@ public void onClick(View v) {
mNodeNameView.setError("Node name is empty");
return;
}
//APCFG: ssid\tpassword\tkey\tsn\t
// String cmd_connect = "APCFG: " + ssid + "\t" + password + "\t" +
// node_key + "\t" + node_sn + "\t";
String ota_server_ip = ((MyApplication) getApplication()).getOtaServerIP();
String exchange_server_ip = ota_server_ip;

// if (ota_server.equals(Common.OTA_CHINA_URL)) {
// ota_server = Common.OTA_CHINA_IP;
// exchange_server = Common.EXCHANGE_CHINA_IP;
// } else if (ota_server.equals(Common.OTA_INTERNATIONAL_URL)) {
// ota_server = Common.OTA_INTERNATIONAL_IP;
// exchange_server = Common.EXCHANGE_INTERNATIONAL_IP;
// }
String cmd_connect = "APCFG: " + ssid + "\t" + password + "\t" +
node_key + "\t" + node_sn + "\t" + exchange_server_ip + "\t"
+ ota_server_ip + "\t";
Expand All @@ -140,10 +141,7 @@ private class SetNodeSn extends AsyncTask<String, Void, Boolean> {

@Override
protected void onPreExecute() {
mProgressDialog = new ProgressDialog(ApConnectActivity.this);
mProgressDialog.setMessage("Sending wifi password to Wio...");
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
showProgressDialog("Sending wifi password to Wio...");
}

@Override
Expand All @@ -162,7 +160,7 @@ protected Boolean doInBackground(String... params) {
} catch (SocketTimeoutException e) {
udpClient.setSoTimeout(3000);
udpClient.sendData(cmd, ipAddr);
continue;

} catch (IOException e) {
Log.e(TAG, "Error[SetNodeSn]:" + e);
return false;
Expand All @@ -174,8 +172,6 @@ protected Boolean doInBackground(String... params) {

@Override
protected void onPostExecute(Boolean b) {
mProgressDialog.dismiss();

//remove Wio wifi config
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
List<WifiConfiguration> wifiConfigurations = wifiManager.getConfiguredNetworks();
Expand All @@ -185,21 +181,16 @@ protected void onPostExecute(Boolean b) {
wifiManager.saveConfiguration();
}
}

new checkNodeIsOnline().execute();
}
}

private class checkNodeIsOnline extends AsyncTask<Void, Void, Boolean> {
private ProgressDialog mProgressDialog;
private class checkNodeIsOnline extends AsyncTask<Void, Integer, Boolean> {
private Boolean state_online = false;

@Override
protected void onPreExecute() {
mProgressDialog = new ProgressDialog(ApConnectActivity.this);
mProgressDialog.setMessage("Waiting Wio get ip address...");
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
showProgressDialog("Waiting Wio get ip address...");
}

@Override
Expand Down Expand Up @@ -233,13 +224,23 @@ public void failure(RetrofitError error) {
} catch (InterruptedException e) {
e.printStackTrace();
}
publishProgress(30-i);
}
return state_online;
}

@Override
protected void onProgressUpdate(Integer... values) {
int i = values[0];
showProgressDialog("Waiting Wio get ip address...[" + i + "]");
}

@Override
protected void onPostExecute(Boolean state_online) {
mProgressDialog.dismiss();
if (ApConnectActivity.this.isFinishing()) { // or call isFinishing() if min sdk version < 17
return;
}
dismissProgressDialog();

if (state_online) {
attemptRename(node_name);
Expand Down Expand Up @@ -289,4 +290,18 @@ public void failure(RetrofitError error) {
});
}
}

private void showProgressDialog(String message) {
mProgressDialog.setMessage(message);
// mProgressDialog.setIndeterminate(false);
if (!mProgressDialog.isShowing()) {
mProgressDialog.show();
}
}

private void dismissProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import cc.seeed.iot.MyApplication;
import cc.seeed.iot.R;
import cc.seeed.iot.datastruct.Constant;
import cc.seeed.iot.datastruct.User;
import cc.seeed.iot.util.Constant;
import cc.seeed.iot.util.User;
import cc.seeed.iot.webapi.IotApi;
import cc.seeed.iot.webapi.IotService;
import cc.seeed.iot.webapi.model.NodeResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import butterknife.InjectView;
import cc.seeed.iot.MyApplication;
import cc.seeed.iot.R;
import cc.seeed.iot.datastruct.User;
import cc.seeed.iot.util.User;
import cc.seeed.iot.ui_main.MainScreenActivity;
import cc.seeed.iot.util.Common;
import cc.seeed.iot.webapi.IotApi;
Expand Down Expand Up @@ -97,13 +97,13 @@ protected void onResume() {
}

private void refresh_layout() {
String ota_server_ip = ((MyApplication) getApplication()).getOtaServerIP();
if (ota_server_ip.equals(Common.OTA_INTERNATIONAL_IP)) {
String ota_server_url = ((MyApplication) getApplication()).getOtaServerUrl();
if (ota_server_url.equals(Common.OTA_INTERNATIONAL_URL)) {
_serverLink.setText(getString(R.string.serverOn) + " International" + getString(R.string.change));
} else if (ota_server_ip.equals(Common.OTA_CHINA_IP)) {
} else if (ota_server_url.equals(Common.OTA_CHINA_URL)) {
_serverLink.setText(getString(R.string.serverOn) + " China" + getString(R.string.change));
} else {
_serverLink.setText(getString(R.string.serverOn) + " " + ota_server_ip + getString(R.string.change));
_serverLink.setText(getString(R.string.serverOn) + " " + ota_server_url + getString(R.string.change));
}
}

Expand All @@ -124,7 +124,7 @@ public void login() {
progressDialog.show();

//Implement your own authentication logic here.
attemptLogin(progressDialog);
attemptLogin(progressDialog);

}

Expand Down
Loading

0 comments on commit 351ce77

Please sign in to comment.