Skip to content

Commit

Permalink
初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
RayZhao1998 committed Nov 17, 2018
0 parents commit d008d9b
Show file tree
Hide file tree
Showing 57 changed files with 1,475 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
.idea/gradle.xml
.idea/misc.xml
.idea/modules.xml
.idea/runConfigurations.xml
*.apk
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
43 changes: 43 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apply plugin: 'com.android.application'

android {
signingConfigs {
}
compileSdkVersion 26
defaultConfig {
applicationId "top.rayzhao98.fzzzmask"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
}





dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/okhttp-3.2.0.jar')
implementation files('libs/AMap2DMap_5.2.0_AMapSearch_6.5.0_20180930.jar')
implementation files('libs/BaiduLBS_Android.jar')
implementation files('libs/okio-1.7.0.jar')
implementation 'com.jjoe64:graphview:4.2.2'
}
Binary file not shown.
Binary file added app/libs/BaiduLBS_Android.jar
Binary file not shown.
Binary file added app/libs/okhttp-3.2.0.jar
Binary file not shown.
Binary file added app/libs/okio-1.7.0.jar
Binary file not shown.
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# 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
1 change: 1 addition & 0 deletions app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"top.rayzhao98.fzzzmask","split":"","minSdkVersion":"15"}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package top.rayzhao98.fzzzmask;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("top.rayzhao98.fzzzmask", appContext.getPackageName());
}
}
38 changes: 38 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="top.rayzhao98.fzzzmask">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="com.amap.api.v2.apikey"
android:value="66c4642d4ccc22fe22842f16ca803a25" />

<activity android:name=".RegisterActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".GraphActivity"></activity>
</application>

</manifest>
10 changes: 10 additions & 0 deletions app/src/main/java/top/rayzhao98/fzzzmask/ApiConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package top.rayzhao98.fzzzmask;

/**
* Created by Ray on 2018/11/17.
*/

public class ApiConfig {
public static final String API_ROOT = "http://192.168.1.103:8000/api/v1";

}
26 changes: 26 additions & 0 deletions app/src/main/java/top/rayzhao98/fzzzmask/BTConnectThread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package top.rayzhao98.fzzzmask;

import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;

/**
* Created by Ray on 2018/11/17.
*/

public class BTConnectThread extends Thread {
@Override
public void run() {
super.run();
}
}
27 changes: 27 additions & 0 deletions app/src/main/java/top/rayzhao98/fzzzmask/GraphActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package top.rayzhao98.fzzzmask;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;

public class GraphActivity extends MyBluetooth {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_graph);

GraphView graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[] {
new DataPoint(0, 1),
new DataPoint(1, 5),
new DataPoint(2, 3),
new DataPoint(3, 2),
new DataPoint(4, 6)
});
graph.addSeries(series);
}
}
65 changes: 65 additions & 0 deletions app/src/main/java/top/rayzhao98/fzzzmask/LoginActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package top.rayzhao98.fzzzmask;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class LoginActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

final EditText loginUsernameEditText = findViewById(R.id.loginUsernameEditText);
final EditText loginPasswordEditText = findViewById(R.id.loginPasswordEditText);
Button loginButton = findViewById(R.id.loginButton);

loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String loginUsername = loginUsernameEditText.getText().toString();
String loginPassword = loginPasswordEditText.getText().toString();

OkHttpClient client = new OkHttpClient();
FormBody formBody = new FormBody.Builder()
.add("username", loginUsername)
.add("email", "")
.add("password", loginPassword)
.build();
Request request = new Request.Builder()
.url(ApiConfig.API_ROOT + "/auth/login")
.addHeader("Content-Type", "application/json")
.post(formBody).build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.d("error", "onFailure: " + "fail");
}

@Override
public void onResponse(Call call, Response response) throws IOException {
final String res = response.body().string();
Log.d("res", "onResponse: " + res);
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
});
}
}
88 changes: 88 additions & 0 deletions app/src/main/java/top/rayzhao98/fzzzmask/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package top.rayzhao98.fzzzmask;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.amap.api.services.weather.LocalWeatherForecastResult;
import com.amap.api.services.weather.LocalWeatherLive;
import com.amap.api.services.weather.LocalWeatherLiveResult;
import com.amap.api.services.weather.WeatherSearch;
import com.amap.api.services.weather.WeatherSearchQuery;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import okhttp3.OkHttpClient;
import okhttp3.Request;

public class MainActivity extends MyBluetooth {

TextView mainPM25TextView;
TextView mainWeatherTextView;
TextView mainTemperatureTextView;
TextView mainHumidityTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainPM25TextView = findViewById(R.id.mainPM25TextView);
mainTemperatureTextView = findViewById(R.id.mainTemperatureTextView);
mainHumidityTextView = findViewById(R.id.mainHumidityTextView);
mainWeatherTextView = findViewById(R.id.mainWeatherTextView);

super.mainPM25TextView = mainPM25TextView;
super.mainTemperatureTextView = mainTemperatureTextView;
super.mainHumidityTextView = mainHumidityTextView;
super.mainWeatherTextView = mainWeatherTextView;

mainPM25TextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, GraphActivity.class);
startActivity(intent);
}
});
getWeather();
bluetoothfunction();
}

public void getWeather() {
WeatherSearchQuery mquery = new WeatherSearchQuery("南京", WeatherSearchQuery.WEATHER_TYPE_LIVE);
WeatherSearch mweathersearch = new WeatherSearch(this);
mweathersearch.setOnWeatherSearchListener(new WeatherSearch.OnWeatherSearchListener() {

@Override
public void onWeatherLiveSearched(LocalWeatherLiveResult localWeatherLiveResult, int i) {
LocalWeatherLive weatherlive = localWeatherLiveResult.getLiveResult();
mainWeatherTextView.setText(weatherlive.getWeather());
}

@Override
public void onWeatherForecastSearched(LocalWeatherForecastResult localWeatherForecastResult, int i) {

}
});
mweathersearch.setQuery(mquery);
mweathersearch.searchWeatherAsyn();
}
}

Loading

0 comments on commit d008d9b

Please sign in to comment.