This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from awong1900/dev_setup_prove
Dev setup prove
- Loading branch information
Showing
109 changed files
with
2,074 additions
and
863 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
package cc.seeed.iot; | ||
|
||
import android.app.Application; | ||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import java.util.ArrayList; | ||
|
||
import cc.seeed.iot.datastruct.User; | ||
import cc.seeed.iot.webapi.ExchangeApi; | ||
import cc.seeed.iot.webapi.IotApi; | ||
import cc.seeed.iot.webapi.model.Node; | ||
|
||
/** | ||
* Created by tenwong on 15/7/9. | ||
*/ | ||
public class MyApplication extends Application { | ||
public class MyApplication extends com.activeandroid.app.Application { | ||
private SharedPreferences sp; | ||
|
||
private ArrayList<Node> nodes = new ArrayList<Node>(); | ||
|
||
private User user = new User(); | ||
|
||
private String server_url; | ||
private String ota_server_url; | ||
private String exchange_server_url; | ||
|
||
/** | ||
* into smartconfig state | ||
|
@@ -32,6 +26,30 @@ public class MyApplication extends Application { | |
*/ | ||
private Boolean loginState; | ||
|
||
private Boolean firstUseState; | ||
|
||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
sp = this.getSharedPreferences("IOT", Context.MODE_PRIVATE); | ||
user.email = sp.getString("userName", "[email protected]"); | ||
user.user_key = sp.getString("userToken", "sBoKhjQNdtT8oTjukEeg98Ui3fuF3416zh-1Qm5Nkm0"); | ||
ota_server_url = sp.getString("ota_server_url", "https://iot.seeed.cc/v1"); //https://iot.seeed.cc/v1 //https://120.25.216.117/v1 | ||
exchange_server_url = sp.getString("exchange_server_url", "https://120.25.216.117/v1"); | ||
configState = sp.getBoolean("configState", false); | ||
loginState = sp.getBoolean("loginState", false); | ||
firstUseState = sp.getBoolean("firstUseState", true); | ||
|
||
init(); | ||
|
||
} | ||
|
||
private void init() { | ||
IotApi.SetServerUrl(ota_server_url); | ||
ExchangeApi.SetServerUrl(exchange_server_url); | ||
} | ||
|
||
public Boolean getLoginState() { | ||
return loginState; | ||
} | ||
|
@@ -43,6 +61,17 @@ public void setLoginState(Boolean loginState) { | |
editor.apply(); | ||
} | ||
|
||
public Boolean getFirstUseState() { | ||
return firstUseState; | ||
} | ||
|
||
public void setFirstUseState(Boolean firstUseState) { | ||
this.firstUseState = firstUseState; | ||
SharedPreferences.Editor editor = sp.edit(); | ||
editor.putBoolean("firstUseState", firstUseState); | ||
editor.apply(); | ||
} | ||
|
||
public User getUser() { | ||
return user; | ||
} | ||
|
@@ -55,22 +84,26 @@ public void setUser(User user) { | |
editor.apply(); | ||
} | ||
|
||
public ArrayList<Node> getNodes() { | ||
return nodes; | ||
public String getServerUrl() { | ||
return ota_server_url; | ||
} | ||
|
||
public void setNodes(ArrayList<Node> nodes) { | ||
this.nodes = nodes; | ||
public void setServerUrl(String server_url) { | ||
this.ota_server_url = server_url; | ||
IotApi.SetServerUrl(server_url); | ||
SharedPreferences.Editor editor = sp.edit(); | ||
editor.putString("ota_server_url", server_url); | ||
editor.apply(); | ||
} | ||
|
||
public String getServer_url() { | ||
return server_url; | ||
public String getExchangeServerUrl() { | ||
return exchange_server_url; | ||
} | ||
|
||
public void setServer_url(String server_url) { | ||
this.server_url = server_url; | ||
public void setExchangeServerUrl(String server_url) { | ||
this.exchange_server_url = server_url; | ||
SharedPreferences.Editor editor = sp.edit(); | ||
editor.putString("server_url", server_url); | ||
editor.putString("exchange_server_url", server_url); | ||
editor.apply(); | ||
} | ||
|
||
|
@@ -85,24 +118,4 @@ public void setConfigState(Boolean configState) { | |
editor.apply(); | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
sp = this.getSharedPreferences("IOT", Context.MODE_PRIVATE); | ||
sp.getString("serverAddress", "http://192.168.21.83:8080/v1"); | ||
user.email = sp.getString("userName", "[email protected]"); | ||
user.user_key = sp.getString("userToken", "sBoKhjQNdtT8oTjukEeg98Ui3fuF3416zh-1Qm5Nkm0"); | ||
|
||
server_url = sp.getString("server_url", "https://iot.seeed.cc/v1"); | ||
|
||
configState = sp.getBoolean("configState", false); | ||
|
||
configState = sp.getBoolean("loginState", false); | ||
|
||
init(); | ||
} | ||
|
||
private void init() { | ||
IotApi.SetServerUrl(server_url); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.