call log
This commit is contained in:
Binary file not shown.
@@ -73,6 +73,8 @@
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.coolape.tianrun;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class CallLogInfo {
|
||||
public String number;
|
||||
public String date;
|
||||
public int type;
|
||||
public CallLogInfo(String number, String date, int type) {
|
||||
super();
|
||||
this.number = number;
|
||||
this.date = date;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public JSONObject toJson(){
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("number", number);
|
||||
jsonObject.put("date", date);
|
||||
/* Call log type for incoming calls.
|
||||
public static final int INCOMING_TYPE = 1;
|
||||
Call log type for outgoing calls.
|
||||
public static final int OUTGOING_TYPE = 2;
|
||||
Call log type for missed calls.
|
||||
public static final int MISSED_TYPE = 3;
|
||||
*/
|
||||
jsonObject.put("type", type);
|
||||
return jsonObject;
|
||||
} catch (JSONException e) {
|
||||
Log.i("", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1801de6425b084a7da4903cf17039d82
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.coolape.tianrun;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.CallLog;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CallLogUtl {
|
||||
public static List<CallLogInfo> getCallLog(Context context) {
|
||||
List<CallLogInfo> infos = new ArrayList<CallLogInfo>();
|
||||
ContentResolver cr = context.getContentResolver();
|
||||
Uri uri = CallLog.Calls.CONTENT_URI;
|
||||
String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.DATE,
|
||||
CallLog.Calls.TYPE };
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat(
|
||||
"yyyy-MM-dd hh:mm:ss");
|
||||
Cursor cursor = cr.query(uri, projection, null, null, null);
|
||||
while (cursor.moveToNext()) {
|
||||
String number = cursor.getString(0);
|
||||
long date = cursor.getLong(1);
|
||||
int type = cursor.getInt(2);
|
||||
infos.add(new CallLogInfo(number, format.format(date), type));
|
||||
}
|
||||
cursor.close();
|
||||
return infos;
|
||||
}
|
||||
|
||||
public static String getCallLogJson(Context context) {
|
||||
List<CallLogInfo> infos = getCallLog(context);
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
for(int i=0; i < infos.size(); i++){
|
||||
array.put(infos.get(i).toJson());
|
||||
}
|
||||
return array.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3146148febae9416bb04160071c8876c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -216,6 +216,11 @@ public class U3dPlugin {
|
||||
return mediaPlayer.getProgress();
|
||||
}
|
||||
|
||||
//取得记录记录
|
||||
public String getCallLog() {
|
||||
return CallLogUtl.getCallLogJson(UnityPlayer.currentActivity);
|
||||
}
|
||||
|
||||
public static void UnitySendMessage(String CallbackFunc, String retCode,
|
||||
String orgs) {
|
||||
if (u3dListener.isEmpty()) {
|
||||
|
||||
32
Assets/trCRM/Scripts/call/CallLogUtl.cs
Normal file
32
Assets/trCRM/Scripts/call/CallLogUtl.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class CallLogUtl
|
||||
{
|
||||
const string className = "com.coolape.tianrun.U3dPlugin";
|
||||
#if UNITY_ANDROID
|
||||
static AndroidJavaObject _plugin;
|
||||
public static AndroidJavaObject plugin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_plugin == null)
|
||||
{
|
||||
_plugin = new AndroidJavaObject(className);
|
||||
}
|
||||
return _plugin;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public static string getCallLog()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
return plugin.CallStatic<string>("getCallLog");
|
||||
#elif UNITY_IOS
|
||||
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/trCRM/Scripts/call/CallLogUtl.cs.meta
Normal file
11
Assets/trCRM/Scripts/call/CallLogUtl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06baaefd3505747e19fe243a0b84bc56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -210,6 +210,7 @@ public static class XluaGenCodeConfig
|
||||
typeof(TextureFormat),
|
||||
typeof(FileInfo),
|
||||
typeof(CallListner),
|
||||
typeof(CallLogUtl),
|
||||
};
|
||||
|
||||
//C#静态调用Lua的配置(包括事件的原型),仅可以配delegate,interface
|
||||
|
||||
@@ -284,6 +284,8 @@ ImageConversion = CS.UnityEngine.ImageConversion
|
||||
FileInfo = CS.System.IO.FileInfo
|
||||
---@type CallListner
|
||||
CallListner = CS.CallListner
|
||||
---@type CallLogUtl
|
||||
CallLogUtl = CS.CallLogUtl
|
||||
-------------------------------------------------------
|
||||
|
||||
-------------------------------------------------------
|
||||
|
||||
1
tianrunPlugins/.idea/gradle.xml
generated
1
tianrunPlugins/.idea/gradle.xml
generated
@@ -14,6 +14,7 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.coolape.tianrun;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class CallLogInfo {
|
||||
public String number;
|
||||
public String date;
|
||||
public int type;
|
||||
public CallLogInfo(String number, String date, int type) {
|
||||
super();
|
||||
this.number = number;
|
||||
this.date = date;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public JSONObject toJson(){
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("number", number);
|
||||
jsonObject.put("date", date);
|
||||
/* Call log type for incoming calls.
|
||||
public static final int INCOMING_TYPE = 1;
|
||||
Call log type for outgoing calls.
|
||||
public static final int OUTGOING_TYPE = 2;
|
||||
Call log type for missed calls.
|
||||
public static final int MISSED_TYPE = 3;
|
||||
*/
|
||||
jsonObject.put("type", type);
|
||||
return jsonObject;
|
||||
} catch (JSONException e) {
|
||||
Log.i("", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.coolape.tianrun;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.CallLog;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CallLogUtl {
|
||||
public static List<CallLogInfo> getCallLog(Context context) {
|
||||
List<CallLogInfo> infos = new ArrayList<CallLogInfo>();
|
||||
ContentResolver cr = context.getContentResolver();
|
||||
Uri uri = CallLog.Calls.CONTENT_URI;
|
||||
String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.DATE,
|
||||
CallLog.Calls.TYPE };
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat(
|
||||
"yyyy-MM-dd hh:mm:ss");
|
||||
Cursor cursor = cr.query(uri, projection, null, null, null);
|
||||
while (cursor.moveToNext()) {
|
||||
String number = cursor.getString(0);
|
||||
long date = cursor.getLong(1);
|
||||
int type = cursor.getInt(2);
|
||||
infos.add(new CallLogInfo(number, format.format(date), type));
|
||||
}
|
||||
cursor.close();
|
||||
return infos;
|
||||
}
|
||||
|
||||
public static String getCallLogJson(Context context) {
|
||||
List<CallLogInfo> infos = getCallLog(context);
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
for(int i=0; i < infos.size(); i++){
|
||||
array.put(infos.get(i).toJson());
|
||||
}
|
||||
return array.toString();
|
||||
}
|
||||
}
|
||||
@@ -216,6 +216,11 @@ public class U3dPlugin {
|
||||
return mediaPlayer.getProgress();
|
||||
}
|
||||
|
||||
//取得记录记录
|
||||
public String getCallLog() {
|
||||
return CallLogUtl.getCallLogJson(UnityPlayer.currentActivity);
|
||||
}
|
||||
|
||||
public static void UnitySendMessage(String CallbackFunc, String retCode,
|
||||
String orgs) {
|
||||
if (u3dListener.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user