Commit 78044345 by 石璀亮

feat(token match):get the token and estabish the message server

1 parent af0be4b0
Showing with 3167 additions and 0 deletions
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.14.1" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>Encapsulation issuesJava</id>
</State>
<State>
<id>Java</id>
</State>
</expanded-state>
<selected-state>
<State>
<id>Android</id>
</State>
</selected-state>
</profile-state>
</entry>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/XGDemo.iml" filepath="$PROJECT_DIR$/XGDemo.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.qq.xgdemo"
minSdkVersion 14
targetSdkVersion 20
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
//选择要添加的对应cpu类型的.so库。
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a','x86', 'x86_64', 'mips', 'mips64'
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
manifestPlaceholders = [
XG_ACCESS_ID:"2100262636",
XG_ACCESS_KEY:"A886KEG58MGY",
]
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.tencent.xinge:xinge:3.1.1-alpha'
compile 'com.tencent.mid:mid:3.721-alpha'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/admin/Library/Android/sdk/android-sdk-macosx/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# 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 *;
#}
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int); # 保持自定义控件类不被混淆
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class MyClass;
-keep public class * extends android.app.Service
-keep class com.tencent.android.tpush.** {* ;}
-keep class com.tencent.mid.** {* ;}
-keep public class * extends com.qq.taf.jce.JceStruct{*;}
package com.qq.xgdemo;
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.*;
/**
* Instrumentation 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("com.qq.xgdemo", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.qq.xgdemo"
android:versionCode="3"
android:versionName="3.0">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- 设置主界面的启动模式为singleTop,当应用在前他的时候不重新开启应用-->
<activity
android:name="com.qq.xgdemo.MainActivity"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.qq.xgdemo.activity.DeviceActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<activity
android:name="com.qq.xgdemo.activity.AboutActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<activity
android:name="com.qq.xgdemo.activity.HelpActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<activity
android:name="com.qq.xgdemo.activity.MsgInfoActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<activity
android:name="com.qq.xgdemo.activity.SettingActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<activity
android:name="com.qq.xgdemo.activity.DiagnosisActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: -->
<receiver android:name="com.qq.xgdemo.receiver.MessageReceiver"
android:exported="true" >
<intent-filter>
<!-- 接收消息透传 -->
<action android:name="com.tencent.android.tpush.action.PUSH_MESSAGE" />
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
<action android:name="com.tencent.android.tpush.action.FEEDBACK" />
</intent-filter>
</receiver>
<!-- 【必须】 请将YOUR_ACCESS_ID修改为APP的AccessId,“21”开头的10位数字,中间没空格 -->
<meta-data
android:name="XG_V2_ACCESS_ID"
android:value="2100262636" />
<!-- 【必须】 请将YOUR_ACCESS_KEY修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 -->
<meta-data
android:name="XG_V2_ACCESS_KEY"
android:value="A886KEG58MGY" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<!-- 【常用】 信鸽SDK所需权限 -->
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- 【可选】 信鸽SDK所需权限 -->
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
</manifest>
\ No newline at end of file
package com.qq.xgdemo.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import com.qq.xgdemo.R;
import com.tencent.android.tpush.XGPushManager;
public class AboutActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
findViewById(R.id.arrow).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
protected void onResume() {
super.onResume();
XGPushManager.onActivityStarted(this);
}
@Override
protected void onPause() {
super.onPause();
XGPushManager.onActivityStoped(this);
}
}
package com.qq.xgdemo.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.qq.xgdemo.R;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushManager;
public class DeviceActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device);
TextView textView = (TextView) this.findViewById(R.id.deviceToken);
textView.setText(XGPushConfig.getToken(this));
findViewById(R.id.arrow).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
protected void onResume() {
super.onResume();
XGPushManager.onActivityStarted(this);
}
@Override
protected void onPause() {
super.onPause();
XGPushManager.onActivityStoped(this);
}
}
package com.qq.xgdemo.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import com.qq.xgdemo.R;
import com.tencent.android.tpush.XGPushManager;
public class HelpActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
findViewById(R.id.arrow).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
protected void onResume() {
super.onResume();
XGPushManager.onActivityStarted(this);
}
@Override
protected void onPause() {
super.onPause();
XGPushManager.onActivityStoped(this);
}
}
package com.qq.xgdemo.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.qq.xgdemo.R;
import com.tencent.android.tpush.XGPushManager;
public class MsgInfoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_msginfo);
Bundle xgnotification = this.getIntent().getExtras();
TextView title_id = (TextView) this.findViewById(R.id.title_id);
title_id.setText("ID:" + xgnotification.getLong("msg_id"));
TextView textView = (TextView) this.findViewById(R.id.title);
textView.setText(xgnotification.getString("title"));
textView = (TextView) this.findViewById(R.id.content);
textView.setText(xgnotification.getString("content"));
textView = (TextView) this.findViewById(R.id.update_time);
textView.setText("到达时间:" + xgnotification.getString("update_time"));
textView = (TextView) this.findViewById(R.id.activityType);
TextView textViewContent = (TextView) this
.findViewById(R.id.activityContent);
if (xgnotification.getInt("notificationActionType", 0) == 1) {
textView.setText("特定页面:");
} else if (xgnotification.getInt("notificationActionType", 0) == 2) {
textView.setText(" URL:");
} else if (xgnotification.getInt("notificationActionType", 0) == 3) {
textView.setText("Intent:");
}
textViewContent.setText(xgnotification.getString("activity"));
findViewById(R.id.arrow).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
protected void onResume() {
super.onResume();
XGPushManager.onActivityStarted(this);
}
@Override
protected void onPause() {
super.onPause();
XGPushManager.onActivityStoped(this);
}
}
package com.qq.xgdemo;
import android.app.Application;
/**
* Created by admin on 2017/2/13.
*/
public class app extends Application {
@Override
public void onCreate() {
super.onCreate();
}
}
package com.qq.xgdemo.bean;
import android.text.TextUtils;
import org.json.JSONException;
import org.json.JSONObject;
public class ClickAction {
public static final int TYPE_ACTIVITY = 1;
public static final int TYPE_URL = 2;
public static final int TYPE_INTENT = 3;
public static final int TYPE_PACKAGE = 4;
public void setActionType(int actionType) {
this.m_actionType = actionType;
}
public void setActivity(String activity) {
this.m_activity = activity;
}
public void setUrl(String url) {
this.m_url = url;
}
public void setConfirmOnUrl(int confirmOnUrl) {
this.m_confirmOnUrl = confirmOnUrl;
}
public void setIntent(String intent) {
this.m_intent = intent;
}
public void setAtyAttrIntentFlag(int atyAttrIntentFlag) {
this.m_atyAttrIntentFlag = atyAttrIntentFlag;
}
public void setAtyAttrPendingIntentFlag(int atyAttrPendingIntentFlag) {
this.m_atyAttrPendingIntentFlag = atyAttrPendingIntentFlag;
}
public void setPackageDownloadUrl(String packageDownloadUrl) {
this.m_packageDownloadUrl = packageDownloadUrl;
}
public void setConfirmOnPackageDownloadUrl(int confirmOnPackageDownloadUrl) {
this.m_confirmOnPackageDownloadUrl = confirmOnPackageDownloadUrl;
}
public void setPackageName(String packageName) {
this.m_packageName = packageName;
}
public String toJson() throws JSONException {
JSONObject json = new JSONObject();
json.put("action_type", m_actionType);
JSONObject browser = new JSONObject();
browser.put("url", m_url);
browser.put("confirm", m_confirmOnUrl);
json.put("browser", browser);
json.put("activity", m_activity);
json.put("intent", m_intent);
JSONObject aty_attr = new JSONObject();
aty_attr.put("if", m_atyAttrIntentFlag);
aty_attr.put("pf", m_atyAttrPendingIntentFlag);
json.put("aty_attr", aty_attr);
JSONObject package_name = new JSONObject();
package_name.put("packageDownloadUrl", m_packageDownloadUrl);
package_name.put("confirm", m_confirmOnPackageDownloadUrl);
package_name.put("packageName", m_packageName);
json.put("package_name", package_name);
return json.toString();
}
public JSONObject toJsonObject() throws JSONException {
JSONObject json = new JSONObject();
json.put("action_type", m_actionType);
JSONObject browser = new JSONObject();
browser.put("url", m_url);
browser.put("confirm", m_confirmOnUrl);
json.put("browser", browser);
json.put("activity", m_activity);
json.put("intent", m_intent);
JSONObject aty_attr = new JSONObject();
aty_attr.put("if", m_atyAttrIntentFlag);
aty_attr.put("pf", m_atyAttrPendingIntentFlag);
json.put("aty_attr", aty_attr);
JSONObject package_name = new JSONObject();
package_name.put("packageDownloadUrl", m_packageDownloadUrl);
package_name.put("confirm", m_confirmOnPackageDownloadUrl);
package_name.put("packageName", m_packageName);
json.put("package_name", package_name);
return json;
}
public boolean isValid() {
if (m_actionType < TYPE_ACTIVITY || m_actionType > TYPE_PACKAGE)
return false;
if (m_actionType == TYPE_URL) {
if (TextUtils.isEmpty(m_url) || m_confirmOnUrl < 0 || m_confirmOnUrl > 1)
return false;
return true;
}
if (m_actionType == TYPE_INTENT) {
if (TextUtils.isEmpty(m_intent))
return false;
return true;
}
return true;
}
public ClickAction() {
m_url = "";
m_actionType = 1;
m_activity = "";
m_atyAttrIntentFlag = 0;
m_atyAttrPendingIntentFlag = 0;
m_packageDownloadUrl = "";
m_confirmOnPackageDownloadUrl = 1;
m_packageName = "";
}
private int m_actionType;
private String m_url;
private int m_confirmOnUrl;
private String m_activity;
private String m_intent;
private int m_atyAttrIntentFlag;
private int m_atyAttrPendingIntentFlag;
private String m_packageDownloadUrl;
private int m_confirmOnPackageDownloadUrl;
private String m_packageName;
}
\ No newline at end of file
package com.qq.xgdemo.bean;
import android.annotation.SuppressLint;
import android.text.TextUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.Vector;
/**
* Created by admin on 2017/2/13.
*/
public class Message {
public static final int TYPE_NOTIFICATION = 1;
public static final int TYPE_MESSAGE = 2;
public Message() {
this.m_title = "";
this.m_content = "";
this.m_sendTime = "2013-12-20 18:31:00";
this.m_acceptTimes = new Vector<TimeInterval>();
this.m_multiPkg = 0;
this.m_raw = "";
this.m_loopInterval = -1;
this.m_loopTimes = -1;
}
public void setTitle(String title) {
this.m_title = title;
}
public void setContent(String content) {
this.m_content = content;
}
public void setExpireTime(int expireTime) {
this.m_expireTime = expireTime;
}
public int getExpireTime() {
return this.m_expireTime;
}
public void setSendTime(String sendTime) {
this.m_sendTime = sendTime;
}
public String getSendTime() {
return this.m_sendTime;
}
public void addAcceptTime(TimeInterval acceptTime) {
this.m_acceptTimes.add(acceptTime);
}
public String acceptTimeToJson() throws JSONException {
JSONArray json_arr = new JSONArray();
for (TimeInterval ti : m_acceptTimes) {
JSONObject jtmp = ti.toJsonObject();
json_arr.put(jtmp);
}
return json_arr.toString();
}
public JSONArray acceptTimeToJsonArray() throws JSONException {
JSONArray json_arr = new JSONArray();
for (TimeInterval ti : m_acceptTimes) {
JSONObject jtmp = ti.toJsonObject();
json_arr.put(jtmp);
}
return json_arr;
}
public void setType(int type) {
this.m_type = type;
}
public int getType() {
return m_type;
}
public void setMultiPkg(int multiPkg) {
this.m_multiPkg = multiPkg;
}
public int getMultiPkg() {
return m_multiPkg;
}
public void setStyle(Style style) {
this.m_style = style;
}
public void setAction(ClickAction action) {
this.m_action = action;
}
public void setCustom(Map<String, Object> custom) {
this.m_custom = custom;
}
public void setRaw(String raw) {
this.m_raw = raw;
}
public int getLoopInterval() {
return m_loopInterval;
}
public void setLoopInterval(int loopInterval) {
m_loopInterval = loopInterval;
}
public int getLoopTimes() {
return m_loopTimes;
}
public void setLoopTimes(int loopTimes) {
m_loopTimes = loopTimes;
}
@SuppressLint("SimpleDateFormat")
public boolean isValid() {
if (!TextUtils.isEmpty(m_raw))
return true;
if (m_type < TYPE_NOTIFICATION || m_type > TYPE_MESSAGE)
return false;
if (m_multiPkg < 0 || m_multiPkg > 1)
return false;
if (m_type == TYPE_NOTIFICATION) {
if (!m_style.isValid())
return false;
if (!m_action.isValid())
return false;
}
if (m_expireTime < 0 || m_expireTime > 3 * 24 * 60 * 60)
return false;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
sdf.parse(m_sendTime);
} catch (Exception e) {
return false;
}
for (TimeInterval ti : m_acceptTimes) {
if (!ti.isValid())
return false;
}
if (m_loopInterval > 0 && m_loopTimes > 0
&& ((m_loopTimes - 1) * m_loopInterval + 1) > 15) {
return false;
}
return true;
}
public String toJson() throws JSONException {
if (!TextUtils.isEmpty(m_raw))
return m_raw;
JSONObject json = new JSONObject();
if (m_type == TYPE_NOTIFICATION) {
json.put("title", m_title);
json.put("content", m_content);
json.put("accept_time", acceptTimeToJsonArray());
json.put("builder_id", m_style.getBuilderId());
json.put("ring", m_style.getRing());
json.put("vibrate", m_style.getVibrate());
json.put("clearable", m_style.getClearable());
json.put("n_id", m_style.getNId());
json.put("ring_raw", m_style.getRingRaw());
json.put("lights", m_style.getLights());
json.put("icon_type", m_style.getIconType());
json.put("icon_res", m_style.getIconRes());
json.put("style_id", m_style.getStyleId());
json.put("small_icon", m_style.getSmallIcon());
json.put("action", m_action.toJsonObject());
} else if (m_type == TYPE_MESSAGE) {
json.put("title", m_title);
json.put("content", m_content);
json.put("accept_time", acceptTimeToJsonArray());
}
json.put("custom_content", m_custom);
return json.toString();
}
private String m_title;
private String m_content;
private int m_expireTime;
private String m_sendTime;
private Vector<TimeInterval> m_acceptTimes;
private int m_type;
private int m_multiPkg;
private Style m_style;
private ClickAction m_action;
private Map<String, Object> m_custom;
private String m_raw;
private int m_loopInterval;
private int m_loopTimes;
}
package com.qq.xgdemo.bean;
import android.annotation.SuppressLint;
import android.text.TextUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.Vector;
public class MessageIOS {
public MessageIOS() {
this.m_sendTime = "2014-03-13 16:13:00";
this.m_acceptTimes = new Vector<TimeInterval>();
this.m_raw = "";
this.m_alertStr = "";
this.m_alertJo = new JSONObject();
this.m_badge = 0;
this.m_sound = "";
this.m_category = "";
this.m_loopInterval = -1;
this.m_loopTimes = -1;
}
public void setExpireTime(int expireTime) {
this.m_expireTime = expireTime;
}
public int getExpireTime() {
return this.m_expireTime;
}
public void setSendTime(String sendTime) {
this.m_sendTime = sendTime;
}
public String getSendTime() {
return this.m_sendTime;
}
public void addAcceptTime(TimeInterval acceptTime) {
this.m_acceptTimes.add(acceptTime);
}
public String acceptTimeToJson() throws JSONException {
JSONArray json_arr = new JSONArray();
for (TimeInterval ti : m_acceptTimes) {
JSONObject jtmp = ti.toJsonObject();
json_arr.put(jtmp);
}
return json_arr.toString();
}
public JSONArray acceptTimeToJsonArray() throws JSONException {
JSONArray json_arr = new JSONArray();
for (TimeInterval ti : m_acceptTimes) {
JSONObject jtmp = ti.toJsonObject();
json_arr.put(jtmp);
}
return json_arr;
}
public int getType() {
return 0;
}
public void setCustom(Map<String, Object> custom) {
this.m_custom = custom;
}
public void setRaw(String raw) {
this.m_raw = raw;
}
public void setAlert(String alert) {
m_alertStr = alert;
}
public void setAlert(JSONObject alert) {
m_alertJo = alert;
}
public void setBadge(int badge) {
m_badge = badge;
}
public void setSound(String sound) {
m_sound = sound;
}
public void setCategory(String category) {
m_category = category;
}
public int getLoopInterval() {
return m_loopInterval;
}
public void setLoopInterval(int loopInterval) {
m_loopInterval = loopInterval;
}
public int getLoopTimes() {
return m_loopTimes;
}
public void setLoopTimes(int loopTimes) {
m_loopTimes = loopTimes;
}
@SuppressLint("SimpleDateFormat")
public boolean isValid() {
if (!TextUtils.isEmpty(m_raw))
return true;
if (m_expireTime < 0 || m_expireTime > 3 * 24 * 60 * 60)
return false;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
sdf.parse(m_sendTime);
} catch (ParseException e) {
return false;
}
for (TimeInterval ti : m_acceptTimes) {
if (!ti.isValid())
return false;
}
if (TextUtils.isEmpty(m_alertStr) && m_alertJo.length() == 0)
return false;
return true;
}
public String toJson() throws JSONException {
if (!TextUtils.isEmpty(m_raw))
return m_raw;
JSONObject json = new JSONObject(m_custom);
json.put("accept_time", acceptTimeToJsonArray());
JSONObject aps = new JSONObject();
if (m_alertJo.length() != 0)
aps.put("alert", m_alertJo);
else
aps.put("alert", m_alertStr);
if (m_badge != 0)
aps.put("badge", m_badge);
if (!TextUtils.isEmpty(m_sound))
aps.put("sound", m_sound);
if (!TextUtils.isEmpty(m_category))
aps.put("category", m_category);
json.put("aps", aps);
return json.toString();
}
private int m_expireTime;
private String m_sendTime;
private Vector<TimeInterval> m_acceptTimes;
private Map<String, Object> m_custom;
private String m_raw;
private String m_alertStr;
private JSONObject m_alertJo;
private int m_badge;
private String m_sound;
private String m_category;
private int m_loopInterval;
private int m_loopTimes;
}
package com.qq.xgdemo.bean;
public class Style {
public Style(int builderId) {
this(builderId, 0, 0, 1, 0, 1, 0, 1);
}
public Style(int builderId, int ring, int vibrate, int clearable, int nId) {
this.m_builderId = builderId;
this.m_ring = ring;
this.m_vibrate = vibrate;
this.m_clearable = clearable;
this.m_nId = nId;
}
public Style(int builderId, int ring, int vibrate, int clearable,
int nId, int lights, int iconType, int styleId) {
this.m_builderId = builderId;
this.m_ring = ring;
this.m_vibrate = vibrate;
this.m_clearable = clearable;
this.m_nId = nId;
this.m_lights = lights;
this.m_iconType = iconType;
this.m_styleId = styleId;
}
public int getBuilderId() {
return m_builderId;
}
public int getRing() {
return m_ring;
}
public int getVibrate() {
return m_vibrate;
}
public int getClearable() {
return m_clearable;
}
public int getNId() {
return m_nId;
}
public int getLights() {
return m_lights;
}
public int getIconType() {
return m_iconType;
}
public int getStyleId() {
return m_styleId;
}
public void setRingRaw(String ringRaw) {
this.m_ringRaw = ringRaw;
}
public String getRingRaw() {
return m_ringRaw;
}
public void setIconRes(String iconRes) {
this.m_iconRes = iconRes;
}
public String getIconRes() {
return m_iconRes;
}
public void setSmallIcon(String smallIcon) {
this.m_smallIcon = smallIcon;
}
public String getSmallIcon() {
return m_smallIcon;
}
public boolean isValid() {
if (m_ring < 0 || m_ring > 1) return false;
if (m_vibrate < 0 || m_vibrate > 1) return false;
if (m_clearable < 0 || m_clearable > 1) return false;
if (m_lights < 0 || m_lights > 1) return false;
if (m_iconType < 0 || m_iconType > 1) return false;
if (m_styleId < 0 || m_styleId > 1) return false;
return true;
}
private int m_builderId;
private int m_ring;
private int m_vibrate;
private int m_clearable;
private int m_nId;
private String m_ringRaw;
private int m_lights;
private int m_iconType;
private String m_iconRes;
private int m_styleId;
private String m_smallIcon;
}
package com.qq.xgdemo.bean;
public class TagTokenPair {
public TagTokenPair(String tag, String token) {
this.tag = tag;
this.token = token;
}
public String tag;
public String token;
}
\ No newline at end of file
package com.qq.xgdemo.bean;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Created by admin on 2017/2/13.
*/
public class TimeInterval {
public TimeInterval(int startHour, int startMin, int endHour, int endMin) {
this.m_startHour = startHour;
this.m_startMin = startMin;
this.m_endHour = endHour;
this.m_endMin = endMin;
}
public boolean isValid() {
if (this.m_startHour >= 0 && this.m_startHour <= 23 &&
this.m_startMin >= 0 && this.m_startMin <= 59 &&
this.m_endHour >= 0 && this.m_endHour <= 23 &&
this.m_endMin >= 0 && this.m_endMin <= 59)
return true;
else
return false;
}
public JSONObject toJsonObject() throws JSONException {
JSONObject json = new JSONObject();
JSONObject js = new JSONObject();
JSONObject je = new JSONObject();
js.put("hour", String.valueOf(m_startHour));
js.put("min", String.valueOf(m_startMin));
je.put("hour", String.valueOf(m_endHour));
je.put("min", String.valueOf(m_endMin));
json.put("start", js);
json.put("end", je);
return json;
}
private int m_startHour;
private int m_startMin;
private int m_endHour;
private int m_endMin;
}
package com.qq.xgdemo.bean;
/**
* Created by admin on 2017/2/13.
*/
public class XGNotification {
private Integer id;
private long msg_id;
private String title;
private String content;
private String activity;
private int notificationActionType;
private String update_time;
public void setId(Integer id) {
this.id = id;
}
public void setMsg_id(long msg_id) {
this.msg_id = msg_id;
}
public void setTitle(String title) {
this.title = title;
}
public void setContent(String content) {
this.content = content;
}
public void setActivity(String activity) {
this.activity = activity;
}
public void setNotificationActionType(int notificationActionType) {
this.notificationActionType = notificationActionType;
}
public void setUpdate_time(String update_time) {
this.update_time = update_time;
}
public Integer getId() {
return id;
}
public long getMsg_id() {
return msg_id;
}
public String getTitle() {
return title;
}
public String getContent() {
return content;
}
public String getActivity() {
return activity;
}
public int getNotificationActionType() {
return notificationActionType;
}
public String getUpdate_time() {
return update_time;
}
public XGNotification() {
}
public XGNotification(Integer id, Long msg_id, String title,
String content, String activity, int notificationActionType, String update_time) {
super();
this.id = id;
this.msg_id = msg_id;
this.title = title;
this.content = content;
this.activity = activity;
this.notificationActionType = notificationActionType;
this.update_time = update_time;
}
}
package com.qq.xgdemo.common;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
public class CommonWorkingThread {
private static HandlerThread thread = null;
private static Handler handler = null;
private CommonWorkingThread() {
}
public static class CommonWorkingThreadHolder {
public static CommonWorkingThread instance = new CommonWorkingThread();
}
public static CommonWorkingThread getInstance() {
initHandler();
return CommonWorkingThreadHolder.instance;
}
public boolean execute(Runnable r) {
if (handler != null) {
Log.i("CommonWorkingThread", ">>> working thread execute ");
return handler.post(r);
}
return false;
}
public boolean execute(Runnable r, long delayMillis) {
if (handler != null) {
Log.i("CommonWorkingThread",
">>> working thread execute delayMillis " + delayMillis);
return handler.postDelayed(r, delayMillis);
}
return false;
}
public Handler getHandler() {
return handler;
}
private static void initHandler() {
if (thread == null || !thread.isAlive() || thread.isInterrupted()
|| thread.getState() == Thread.State.TERMINATED) {
thread = new HandlerThread("tpush.working.thread");
thread.start();
handler = new Handler(thread.getLooper());
Log.i("CommonWorkingThread", ">>> Create new working thread."
+ thread.getId());
}
}
}
package com.qq.xgdemo.common;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DBOpenHelper extends SQLiteOpenHelper {
public DBOpenHelper(Context context) {
super(context, "XGExample.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE notification (id integer primary key autoincrement,msg_id varchar(64),title varchar(128),activity varchar(256),notificationActionType varchar(512),content text,update_time varchar(16))");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
package com.qq.xgdemo.common;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ListView;
import com.qq.xgdemo.R;
public class ExtendedListView extends ListView implements OnScrollListener {
public static interface OnPositionChangedListener {
public void onPositionChanged(ExtendedListView listView, int position, View scrollBarPanel);
}
private OnScrollListener mOnScrollListener = null;
private View mScrollBarPanel = null;
private int mScrollBarPanelPosition = 0;
private OnPositionChangedListener mPositionChangedListener;
private int mLastPosition = -1;
private Animation mInAnimation = null;
private Animation mOutAnimation = null;
private final Handler mHandler = new Handler();
private final Runnable mScrollBarPanelFadeRunnable = new Runnable() {
@Override
public void run() {
if (mOutAnimation != null) {
mScrollBarPanel.startAnimation(mOutAnimation);
}
}
};
/*
* keep track of Measure Spec
*/
private int mWidthMeasureSpec;
private int mHeightMeasureSpec;
public ExtendedListView(Context context) {
this(context, null);
}
public ExtendedListView(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.listViewStyle);
}
public ExtendedListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
super.setOnScrollListener(this);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ExtendedListView);
final int scrollBarPanelLayoutId = a.getResourceId(R.styleable.ExtendedListView_scrollBarPanel, -1);
final int scrollBarPanelInAnimation = a.getResourceId(R.styleable.ExtendedListView_scrollBarPanelInAnimation, R.anim.in_animation);
final int scrollBarPanelOutAnimation = a.getResourceId(R.styleable.ExtendedListView_scrollBarPanelOutAnimation, R.anim.out_animation);
a.recycle();
if (scrollBarPanelLayoutId != -1) {
setScrollBarPanel(scrollBarPanelLayoutId);
}
final int scrollBarPanelFadeDuration = ViewConfiguration.getScrollBarFadeDuration();
if (scrollBarPanelInAnimation > 0) {
mInAnimation = AnimationUtils.loadAnimation(getContext(), scrollBarPanelInAnimation);
}
if (scrollBarPanelOutAnimation > 0) {
mOutAnimation = AnimationUtils.loadAnimation(getContext(), scrollBarPanelOutAnimation);
mOutAnimation.setDuration(scrollBarPanelFadeDuration);
mOutAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (mScrollBarPanel != null) {
mScrollBarPanel.setVisibility(View.GONE);
}
}
});
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (mOnScrollListener != null) {
mOnScrollListener.onScrollStateChanged(view, scrollState);
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (null != mPositionChangedListener && null != mScrollBarPanel) {
// Don't do anything if there is no itemviews
if (totalItemCount > 0) {
/*
* from android source code (ScrollBarDrawable.java)
*/
final int thickness = getVerticalScrollbarWidth();
int height = Math.round((float) getMeasuredHeight() * computeVerticalScrollExtent() / computeVerticalScrollRange());
int thumbOffset = Math.round((float) (getMeasuredHeight() - height) * computeVerticalScrollOffset() / (computeVerticalScrollRange() - computeVerticalScrollExtent()));
final int minLength = thickness * 2;
if (height < minLength) {
height = minLength;
}
thumbOffset += height / 2;
/*
* find out which itemviews the center of thumb is on
*/
final int count = getChildCount();
for (int i = 0; i < count; ++i) {
final View childView = getChildAt(i);
if (childView != null) {
if (thumbOffset > childView.getTop() && thumbOffset < childView.getBottom()) {
/*
* we have our candidate
*/
if (mLastPosition != firstVisibleItem + i) {
mLastPosition = firstVisibleItem + i;
/*
* inform the position of the panel has changed
*/
mPositionChangedListener.onPositionChanged(this, mLastPosition, mScrollBarPanel);
/*
* measure panel right now since it has just changed
*
* INFO: quick hack to handle TextView has ScrollBarPanel (to wrap text in
* case TextView's content has changed)
*/
measureChild(mScrollBarPanel, mWidthMeasureSpec, mHeightMeasureSpec);
}
break;
}
}
}
/*
* update panel position
*/
mScrollBarPanelPosition = thumbOffset - mScrollBarPanel.getMeasuredHeight() / 2;
final int x = getMeasuredWidth() - mScrollBarPanel.getMeasuredWidth() - getVerticalScrollbarWidth();
mScrollBarPanel.layout(x, mScrollBarPanelPosition, x + mScrollBarPanel.getMeasuredWidth(),
mScrollBarPanelPosition + mScrollBarPanel.getMeasuredHeight());
}
}
if (mOnScrollListener != null) {
mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
}
}
public void setOnPositionChangedListener(OnPositionChangedListener onPositionChangedListener) {
mPositionChangedListener = onPositionChangedListener;
}
@Override
public void setOnScrollListener(OnScrollListener onScrollListener) {
mOnScrollListener = onScrollListener;
}
public void setScrollBarPanel(View scrollBarPanel) {
mScrollBarPanel = scrollBarPanel;
mScrollBarPanel.setVisibility(View.GONE);
requestLayout();
}
public void setScrollBarPanel(int resId) {
setScrollBarPanel(LayoutInflater.from(getContext()).inflate(resId, this, false));
}
public View getScrollBarPanel() {
return mScrollBarPanel;
}
@Override
protected boolean awakenScrollBars(int startDelay, boolean invalidate) {
final boolean isAnimationPlayed = super.awakenScrollBars(startDelay, invalidate);
if (isAnimationPlayed == true && mScrollBarPanel != null) {
if (mScrollBarPanel.getVisibility() == View.GONE) {
mScrollBarPanel.setVisibility(View.VISIBLE);
if (mInAnimation != null) {
mScrollBarPanel.startAnimation(mInAnimation);
}
}
mHandler.removeCallbacks(mScrollBarPanelFadeRunnable);
mHandler.postAtTime(mScrollBarPanelFadeRunnable, AnimationUtils.currentAnimationTimeMillis() + startDelay);
}
return isAnimationPlayed;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mScrollBarPanel != null && getAdapter() != null) {
mWidthMeasureSpec = widthMeasureSpec;
mHeightMeasureSpec = heightMeasureSpec;
measureChild(mScrollBarPanel, widthMeasureSpec, heightMeasureSpec);
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mScrollBarPanel != null) {
final int x = getMeasuredWidth() - mScrollBarPanel.getMeasuredWidth() - getVerticalScrollbarWidth();
mScrollBarPanel.layout(x, mScrollBarPanelPosition, x + mScrollBarPanel.getMeasuredWidth(),
mScrollBarPanelPosition + mScrollBarPanel.getMeasuredHeight());
}
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mScrollBarPanel != null && mScrollBarPanel.getVisibility() == View.VISIBLE) {
drawChild(canvas, mScrollBarPanel, getDrawingTime());
}
}
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
mHandler.removeCallbacks(mScrollBarPanelFadeRunnable);
}
}
package com.qq.xgdemo.common;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.qq.xgdemo.bean.XGNotification;
public class NotificationService {
private DBOpenHelper dbOpenHelper;
private static NotificationService instance = null;
public NotificationService(Context context) {
this.dbOpenHelper = new DBOpenHelper(context);
}
public synchronized static NotificationService getInstance(Context ctx) {
if (null == instance) {
instance = new NotificationService(ctx);
}
return instance;
}
public void save(XGNotification notification) {
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put("msg_id", notification.getMsg_id());
values.put("title", notification.getTitle());
values.put("content", notification.getContent());
values.put("activity", notification.getActivity());
values.put("notificationActionType", notification.getNotificationActionType());
values.put("update_time", notification.getUpdate_time());
db.insert("notification", null, values);
}
public void delete(Integer id) {
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
db.delete("notification", "id=?", new String[]{id.toString()});
}
public void deleteAll() {
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
db.delete("notification", "", null);
}
public void update(XGNotification notification) {
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put("msg_id", notification.getMsg_id());
values.put("title", notification.getTitle());
values.put("content", notification.getContent());
values.put("activity", notification.getActivity());
values.put("notificationActionType", notification.getNotificationActionType());
values.put("update_time", notification.getUpdate_time());
db.update("notification", values, "id=?", new String[]{notification
.getId().toString()});
}
public XGNotification find(Integer id) {
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor = db
.query("notification",
new String[]{"id,msg_id,title,content,activity,notificationActionType,update_time"},
"id=?", new String[]{id.toString()}, null, null,
null, "1");
try {
if (cursor.moveToFirst()) {
return new XGNotification(cursor.getInt(cursor
.getColumnIndex("id")), cursor.getLong(cursor
.getColumnIndex("msg_id")), cursor.getString(cursor
.getColumnIndex("title")), cursor.getString(cursor
.getColumnIndex("content")), cursor.getString(cursor
.getColumnIndex("activity")), cursor.getInt(cursor
.getColumnIndex("notificationActionType")), cursor.getString(cursor
.getColumnIndex("update_time")));
}
return null;
} finally {
cursor.close();
}
}
public List<XGNotification> getScrollData(int currentPage, int lineSize,
String msg_id) {
String firstResult = String.valueOf((currentPage - 1) * lineSize);
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor = null;
try {
if (msg_id == null || "".equals(msg_id)) {
cursor = db
.query("notification",
new String[]{"id,msg_id,title,content,activity,notificationActionType,update_time"},
null, null, null, null, "update_time DESC",
firstResult + "," + lineSize);
} else {
cursor = db
.query("notification",
new String[]{"id,msg_id,title,content,activity,notificationActionType,update_time"},
"msg_id like ?", new String[]{msg_id + "%"},
null, null, "update_time DESC", firstResult
+ "," + lineSize);
}
List<XGNotification> notifications = new ArrayList<XGNotification>();
while (cursor.moveToNext()) {
notifications.add(new XGNotification(cursor.getInt(cursor
.getColumnIndex("id")), cursor.getLong(cursor
.getColumnIndex("msg_id")), cursor.getString(cursor
.getColumnIndex("title")), cursor.getString(cursor
.getColumnIndex("content")), cursor.getString(cursor
.getColumnIndex("activity")), cursor.getInt(cursor
.getColumnIndex("notificationActionType")), cursor.getString(cursor
.getColumnIndex("update_time"))));
}
return notifications;
} finally {
cursor.close();
}
}
public int getCount() {
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select count(*) from notification", null);
try {
cursor.moveToFirst();
return cursor.getInt(0);
} finally {
cursor.close();
}
}
}
package com.qq.xgdemo.receiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
import com.qq.xgdemo.activity.SettingActivity;
import com.qq.xgdemo.bean.XGNotification;
import com.qq.xgdemo.common.NotificationService;
import com.tencent.android.tpush.XGPushBaseReceiver;
import com.tencent.android.tpush.XGPushClickedResult;
import com.tencent.android.tpush.XGPushRegisterResult;
import com.tencent.android.tpush.XGPushShowedResult;
import com.tencent.android.tpush.XGPushTextMessage;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class MessageReceiver extends XGPushBaseReceiver {
private Intent intent = new Intent("com.qq.xgdemo.activity.UPDATE_LISTVIEW");
public static final String LogTag = "TPushReceiver";
private void show(Context context, String text) {
Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}
// 通知展示
@Override
public void onNotifactionShowedResult(Context context,
XGPushShowedResult notifiShowedRlt) {
if (context == null || notifiShowedRlt == null) {
return;
}
XGNotification notific = new XGNotification();
notific.setMsg_id(notifiShowedRlt.getMsgId());
notific.setTitle(notifiShowedRlt.getTitle());
notific.setContent(notifiShowedRlt.getContent());
// notificationActionType==1为Activity,2为url,3为intent
notific.setNotificationActionType(notifiShowedRlt
.getNotificationActionType());
//Activity,url,intent都可以通过getActivity()获得
notific.setActivity(notifiShowedRlt.getActivity());
notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(Calendar.getInstance().getTime()));
NotificationService.getInstance(context).save(notific);
context.sendBroadcast(intent);
show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString());
Log.d("LC","+++++++++++++++++++++++++++++展示通知的回调");
}
//反注册的回调
@Override
public void onUnregisterResult(Context context, int errorCode) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "反注册成功";
} else {
text = "反注册失败" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
//设置tag的回调
@Override
public void onSetTagResult(Context context, int errorCode, String tagName) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "\"" + tagName + "\"设置成功";
} else {
text = "\"" + tagName + "\"设置失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
//删除tag的回调
@Override
public void onDeleteTagResult(Context context, int errorCode, String tagName) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "\"" + tagName + "\"删除成功";
} else {
text = "\"" + tagName + "\"删除失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
// 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击
@Override
public void onNotifactionClickedResult(Context context,
XGPushClickedResult message) {
if (context == null || message == null) {
return;
}
Log.e("LC","++++++++++++++++++");
Intent intent = new Intent(context, SettingActivity.class);
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
String text = "";
if (message.getActionType() == XGPushClickedResult.NOTIFACTION_CLICKED_TYPE) {
// 通知在通知栏被点击啦。。。。。
// APP自己处理点击的相关动作
// 这个动作可以在activity的onResume也能监听,请看第3点相关内容
text = "通知被打开 :" + message;
} else if (message.getActionType() == XGPushClickedResult.NOTIFACTION_DELETED_TYPE) {
// 通知被清除啦。。。。
// APP自己处理通知被清除后的相关动作
text = "通知被清除 :" + message;
}
Toast.makeText(context, "广播接收到通知被点击:" + message.toString(),
Toast.LENGTH_SHORT).show();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
try {
JSONObject obj = new JSONObject(customContent);
// key1为前台配置的key
if (!obj.isNull("key")) {
String value = obj.getString("key");
Log.d(LogTag, "get custom value:" + value);}
// ...
} catch (JSONException e) {
e.printStackTrace();}}
// APP自主处理的过程。。。
Log.d(LogTag, text);
show(context, text);
}
//注册的回调
@Override
public void onRegisterResult(Context context, int errorCode,
XGPushRegisterResult message) {
// TODO Auto-generated method stub
if (context == null || message == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = message + "注册成功";
// 在这里拿token
String token = message.getToken();
} else {
text = message + "注册失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
// 消息透传的回调
@Override
public void onTextMessage(Context context, XGPushTextMessage message) {
// TODO Auto-generated method stub
String text = "收到消息:" + message.toString();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
try {
JSONObject obj = new JSONObject(customContent);
// key1为前台配置的key
if (!obj.isNull("key")) {
String value = obj.getString("key");
Log.d(LogTag, "get custom value:" + value);
}
// ...
} catch (JSONException e) {
e.printStackTrace();
}
}
// APP自主处理消息的过程...
Log.d(LogTag, text);
show(context, text);
}
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<alpha
android:fromAlpha="0.2"
android:toAlpha="1.0"
android:fillAfter="true"
android:duration="@android:integer/config_shortAnimTime" />
<translate
android:fromXDelta="50%"
android:toXDelta="0%"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<alpha
android:fromAlpha="0.2"
android:toAlpha="1.0"
android:fillAfter="true"
android:duration="@android:integer/config_shortAnimTime" />
<translate
android:fromXDelta="-25%"
android:toXDelta="0%"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.2"
android:fillAfter="true"
android:duration="@android:integer/config_mediumAnimTime" />
<translate
android:fromXDelta="0%"
android:toXDelta="50%"
android:duration="@android:integer/config_longAnimTime" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.2"
android:fillAfter="true"
android:duration="@android:integer/config_mediumAnimTime" />
<translate
android:fromXDelta="0%"
android:toXDelta="-50%"
android:duration="@android:integer/config_longAnimTime" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#c8cacf" />
<solid android:color="#ffffff" />
<corners android:radius="5dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#c8cacf" />
<solid android:color="#ffffff" />
<corners android:radius="5dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#c8cacf" />
<solid android:color="#ffffff" />
<corners android:radius="5dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#c8cacf" />
<solid android:color="#ffffff" />
<corners android:radius="5dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/scrollbarpanel_background" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white">
<RelativeLayout
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="@dimen/qq_dimen_96px"
android:background="@android:color/black">
<ImageButton
android:id="@+id/arrow"
android:contentDescription="@string/action_back"
android:layout_width="@dimen/qq_dimen_70px"
android:layout_height="@dimen/qq_dimen_70px"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/qq_dimen_30px"
android:background="@drawable/fuxk_back" />
<View
android:id="@+id/img"
android:layout_width="@dimen/qq_dimen_80px"
android:layout_height="@dimen/qq_dimen_80px"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/qq_dimen_8px"
android:layout_toRightOf="@+id/img"
android:text="@string/action_about_us"
android:textColor="@android:color/white"
android:textSize="@dimen/qq_dimen_30px" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/logo"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:scaleType="centerCrop"
android:src="@drawable/about" />
<TextView
android:id="@+id/logotext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="@string/version"
android:textColor="@color/gray"
android:textSize="20sp" />
<TextView
android:id="@+id/copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/copyright1"
android:layout_centerHorizontal="true"
android:text="腾讯公司版权所有"
android:textColor="@color/gray"
android:textSize="16sp" />
<TextView
android:id="@+id/copyright1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/copyright2"
android:layout_centerHorizontal="true"
android:text="Copyright © 1998 - 2015 Tencent."
android:textColor="@color/gray"
android:textSize="16sp" />
<TextView
android:id="@+id/copyright2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="All Rights Reserved"
android:textColor="@color/gray"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white">
<RelativeLayout
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="@dimen/qq_dimen_96px"
android:background="@android:color/black">
<ImageButton
android:id="@+id/arrow"
android:contentDescription="@string/action_back"
android:layout_width="@dimen/qq_dimen_70px"
android:layout_height="@dimen/qq_dimen_70px"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/qq_dimen_30px"
android:background="@drawable/fuxk_back" />
<View
android:id="@+id/img"
android:layout_width="@dimen/qq_dimen_80px"
android:layout_height="@dimen/qq_dimen_80px"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/qq_dimen_8px"
android:layout_toRightOf="@+id/img"
android:text="@string/action_device_token"
android:textColor="@android:color/white"
android:textSize="@dimen/qq_dimen_30px" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/devicetitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:text="@string/device_title"
android:textColor="@color/gray"
android:textSize="24sp" />
<TextView
android:id="@+id/deviceToken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/devicetitle"
android:layout_marginTop="5dp"
android:textColor="@color/gray"
android:textSize="30sp" />
<View
android:id="@+id/deviceLine"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="@id/deviceToken"
android:layout_marginTop="40dp"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/deviceLine"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="@string/device_hint"
android:textColor="@color/gray"
android:textSize="16sp" />
<ImageView
android:id="@+id/right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/hint"
android:layout_alignTop="@id/hint"
android:layout_below="@id/deviceLine"
android:layout_centerHorizontal="true"
android:layout_marginRight="5dp"
android:layout_marginTop="4dp"
android:layout_toLeftOf="@id/hint"
android:scaleType="matrix"
android:src="@drawable/right" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white">
<RelativeLayout
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="@dimen/qq_dimen_96px"
android:background="@android:color/black">
<ImageButton
android:id="@+id/arrow"
android:contentDescription="@string/action_back"
android:layout_width="@dimen/qq_dimen_70px"
android:layout_height="@dimen/qq_dimen_70px"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/qq_dimen_30px"
android:background="@drawable/fuxk_back" />
<View
android:id="@+id/img"
android:layout_width="@dimen/qq_dimen_80px"
android:layout_height="@dimen/qq_dimen_80px"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/qq_dimen_8px"
android:layout_toRightOf="@+id/img"
android:text="@string/action_diagnosis"
android:textColor="@android:color/white"
android:textSize="@dimen/qq_dimen_30px" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<com.qq.xgdemo.common.ExtendedListView xmlns:dafruits="http://schemas.android.com/apk/res/com.qq.xgdemo"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:choiceMode="singleChoice"
dafruits:scrollBarPanel="@layout/scrollbarpanel"
dafruits:scrollBarPanelInAnimation="@anim/in"
dafruits:scrollBarPanelOutAnimation="@anim/out" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white">
<RelativeLayout
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="@dimen/qq_dimen_96px"
android:background="@android:color/black">
<ImageButton
android:id="@+id/arrow"
android:contentDescription="@string/action_back"
android:layout_width="@dimen/qq_dimen_70px"
android:layout_height="@dimen/qq_dimen_70px"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/qq_dimen_30px"
android:background="@drawable/fuxk_back" />
<View
android:id="@+id/img"
android:layout_width="@dimen/qq_dimen_80px"
android:layout_height="@dimen/qq_dimen_80px"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/qq_dimen_8px"
android:layout_toRightOf="@+id/img"
android:text="@string/action_help_center"
android:textColor="@android:color/white"
android:textSize="@dimen/qq_dimen_30px" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/help1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="1.示例app是什么?"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help1"
android:text="示例app是系统自动为您生成的,与QQ号相对应的体验应用,您可以通过在网页端发送消息,在示例app上体验推送效果。"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help2"
android:layout_marginTop="10dp"
android:autoLink="all"
android:text="2.常见问题"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help3"
android:layout_marginTop="10dp"
android:autoLink="all"
android:text="Q:Demo App安装了,推送出消息却无法收到?"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help4"
android:autoLink="all"
android:text="A:Demo安装后,请等待Demo首页显示您的设备token码,并且刷新电脑端网页;待应用列表内Demo app后的覆盖设备数由0变为1后,即表示设备已注册,可以正常接收消息。"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help5"
android:layout_marginTop="10dp"
android:autoLink="all"
android:text="Q:我给Demo App推送消息,别人会收到吗?"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help6"
android:autoLink="all"
android:text="A:每一个QQ号都有对应的Demo App,因此别人不会收到您推送出的消息,同样您也不会收到别人的消息。"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help7"
android:layout_marginTop="10dp"
android:autoLink="all"
android:text="Q:想利用Demo App测试一下单条消息的群发状态,可以吗?"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help8"
android:autoLink="all"
android:text="A:每一个QQ号都有对应的Demo App,如果您将Demo的安装包或二维码自愿提供给除您自己以外的人,您在网页端测试推送消息时,凡安装过该demo的设备都会收到该消息。"
android:textColor="@color/gray"
android:textSize="15sp" />
<TextView
android:id="@+id/help10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/help9"
android:layout_marginTop="10dp"
android:autoLink="all"
android:text="请参考 http://developer.xg.qq.com"
android:textColor="@color/gray"
android:textSize="15sp" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<RelativeLayout
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="@dimen/qq_dimen_96px"
android:background="@android:color/black">
<ImageView
android:id="@+id/img"
android:layout_width="@dimen/qq_dimen_80px"
android:layout_height="@dimen/qq_dimen_80px"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/qq_dimen_8px"
android:layout_toRightOf="@+id/img"
android:text="@string/app_name"
android:textColor="@android:color/white"
android:textSize="@dimen/qq_dimen_30px" />
<ImageView
android:id="@+id/img_right"
android:layout_width="@dimen/qq_dimen_70px"
android:layout_height="@dimen/qq_dimen_70px"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="@drawable/qq_right" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/nodata"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:scaleType="centerCrop"
android:src="@drawable/nodata" />
<TextView
android:id="@+id/deviceToken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:textColor="@color/gray"
android:textSize="24sp" />
<TextView
android:id="@+id/deviceTokenHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/deviceToken"
android:layout_marginTop="5dp"
android:text="您的设备Token为:"
android:textColor="@color/gray"
android:textSize="20sp" />
<View
android:id="@+id/deviceLine"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_above="@id/deviceTokenHint"
android:layout_marginBottom="10dp"
android:background="@color/gray" />
<ListView
android:id="@+id/push_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@null"
android:dividerHeight="5dp"
android:scrollbars="none" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white">
<RelativeLayout
android:id="@+id/rl_title"
android:layout_width="fill_parent"
android:layout_height="@dimen/qq_dimen_96px"
android:background="@android:color/black">
<View
android:id="@+id/arrow"
android:layout_width="@dimen/qq_dimen_27px"
android:layout_height="@dimen/qq_dimen_30px"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/qq_dimen_30px"
android:background="@drawable/fuxk_back" />
<View
android:id="@+id/img"
android:layout_width="@dimen/qq_dimen_80px"
android:layout_height="@dimen/qq_dimen_80px"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_toRightOf="@+id/arrow"
android:background="@drawable/ic_launcher" />
<TextView
android:id="@+id/title_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/qq_dimen_8px"
android:layout_toRightOf="@+id/img"
android:textColor="@android:color/white"
android:textSize="@dimen/qq_dimen_30px" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/rl_title"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textColor="@color/gray"
android:textSize="20sp" />
<View
android:id="@+id/msginfoLine1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@id/title"
android:layout_marginTop="15dp"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/update_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/msginfoLine1"
android:layout_marginTop="25dp"
android:textColor="@color/gray"
android:textSize="18sp" />
<TextView
android:id="@+id/activityType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/update_time"
android:textColor="@color/gray"
android:textSize="18sp" />
<TextView
android:id="@+id/activityContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/update_time"
android:layout_marginLeft="90dp"
android:layout_toRightOf="@id/activityType"
android:autoLink="all"
android:textColor="@color/gray"
android:textSize="18sp" />
<View
android:id="@+id/msginfoLine2"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@id/activityContent"
android:layout_marginTop="40dp"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/msginfoLine2"
android:layout_marginTop="30dp"
android:textColor="@color/gray"
android:textSize="18sp" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0"?>
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white">
<RelativeLayout
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="@dimen/qq_dimen_96px"
android:background="@android:color/black">
<ImageButton
android:id="@+id/arrow"
android:contentDescription="@string/action_back"
android:layout_width="@dimen/qq_dimen_70px"
android:layout_height="@dimen/qq_dimen_70px"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/qq_dimen_30px"
android:background="@drawable/fuxk_back" />
<View
android:id="@+id/img"
android:layout_width="@dimen/qq_dimen_80px"
android:layout_height="@dimen/qq_dimen_80px"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/qq_dimen_8px"
android:layout_toRightOf="@+id/img"
android:text="@string/action_setting"
android:textColor="@android:color/white"
android:textSize="@dimen/qq_dimen_30px" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<Button
android:id="@+id/Button_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="启动&amp;注册" />
<Button
android:id="@+id/Button_registerAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Button_register"
android:layout_below="@+id/Button_register"
android:text="启动&amp;注册(绑定账号)" />
<Button
android:id="@+id/Button_unregister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Button_register"
android:layout_below="@+id/Button_registerAccount"
android:text="反注册" />
<Button
android:id="@+id/Button_setTag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Button_register"
android:layout_below="@+id/Button_unregister"
android:text="设置标签" />
<Button
android:id="@+id/Button_delTag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Button_register"
android:layout_below="@+id/Button_setTag"
android:text="删除标签" />
<Button
android:id="@+id/Button_clearCache"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Button_register"
android:layout_below="@+id/Button_delTag"
android:text="清除本地缓存" />
<Button
android:id="@+id/Button_copyToken"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Button_clearCache"
android:layout_below="@+id/Button_clearCache"
android:text="复制Token" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/corner_round"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:id="@+id/push_msg_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textColor="@color/gray" />
<TextView
android:id="@+id/push_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/push_msg_id"
android:layout_marginTop="5dp"
android:textColor="@color/gray"
android:textSize="18sp" />
<TextView
android:id="@+id/push_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/push_title"
android:layout_alignParentRight="true"
android:layout_below="@id/push_msg_id"
android:layout_marginTop="8dp"
android:textColor="@color/gray" />
<TextView
android:id="@+id/push_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/push_title"
android:layout_marginTop="5dp"
android:textColor="@color/gray" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:gravity="left|center_vertical" />
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/qq_dimen_330px"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:layout_width="@dimen/qq_dimen_330px"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@android:color/black"
android:orientation="vertical">
<TextView
android:id="@+id/action_device_token"
android:layout_width="match_parent"
android:layout_height="@dimen/qq_dimen_80px"
android:gravity="center"
android:singleLine="true"
android:text="@string/action_device_token"
android:textColor="@android:color/white" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/fuxk_base_divide_line_color" />
<TextView
android:id="@+id/action_help_center"
android:layout_width="match_parent"
android:layout_height="@dimen/qq_dimen_80px"
android:gravity="center"
android:singleLine="true"
android:text="@string/action_help_center"
android:textColor="@android:color/white" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/fuxk_base_divide_line_color" />
<TextView
android:id="@+id/action_about_us"
android:layout_width="match_parent"
android:layout_height="@dimen/qq_dimen_80px"
android:gravity="center"
android:singleLine="true"
android:text="@string/action_about_us"
android:textColor="@android:color/white" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/fuxk_base_divide_line_color" />
<TextView
android:id="@+id/action_clear"
android:layout_width="match_parent"
android:layout_height="@dimen/qq_dimen_80px"
android:gravity="center"
android:singleLine="true"
android:text="@string/action_clear"
android:textColor="@android:color/white" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/fuxk_base_divide_line_color" />
<TextView
android:id="@+id/action_setting"
android:layout_width="match_parent"
android:layout_height="@dimen/qq_dimen_80px"
android:gravity="center"
android:singleLine="true"
android:text="@string/action_setting"
android:textColor="@android:color/white" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/fuxk_base_divide_line_color" />
<TextView
android:id="@+id/action_diagnosis"
android:layout_width="match_parent"
android:layout_height="@dimen/qq_dimen_80px"
android:gravity="center"
android:singleLine="true"
android:text="@string/action_diagnosis"
android:textColor="@android:color/white" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:orientation="horizontal"
android:padding="3dp">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp" />
<LinearLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/icon"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000" />
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000" />
</LinearLayout>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textColor="#000" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:singleLine="true"
android:ellipsize="none"
android:textColor="#ffffffff"
android:textSize="14sp"
android:textStyle="bold"
android:shadowColor="#ff000000"
android:shadowDx="0"
android:shadowDy="-1"
android:shadowRadius="0.1"
android:background="@drawable/background_scrollbarpanel" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="我的通知栏样式"/>
</LinearLayout>
\ No newline at end of file
No preview for this file type
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
<resources>
<declare-styleable name="ExtendedListView">
<attr name="scrollBarPanel" format="reference" />
<attr name="scrollBarPanelInAnimation" format="reference" />
<attr name="scrollBarPanelOutAnimation" format="reference" />
</declare-styleable>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="gray">#858585</color>
<color name="fuxk_base_color_white">#ffffff</color>
<color name="fuxk_base_divide_line_color">#dcdcdc</color>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="qq_dimen_80px">35.56dp</dimen>
<dimen name="qq_dimen_27px">12.00dp</dimen>
<dimen name="qq_dimen_96px">42.67dp</dimen>
<dimen name="qq_dimen_8px">3.56dp</dimen>
<dimen name="qq_dimen_30px">13.33dp</dimen>
<dimen name="qq_dimen_70px">31.11dp</dimen>
<dimen name="qq_dimen_330px">146.67dp</dimen>
</resources>
<resources>
<string name="app_name">XGDemo</string>
<string name="action_search">搜索</string>
<string name="action_device_token">设备Token</string>
<string name="action_help_center">帮助中心</string>
<string name="action_about_us">关于信鸽</string>
<string name="device_title">您的设备Token为:</string>
<string name="device_hint">已成功上传至网页端测试设备页面</string>
<string name="action_clear">清除已收到通知</string>
<string name="action_setting">功能设置</string>
<string name="action_diagnosis">一键诊断</string>
<string name="version">信鸽Demo 2.3.5</string>
<string name="register">启动&amp;注册</string>
<string name="unregister">反注册</string>
<string name="tag">设置标签</string>
<string name="registerAccount">启动&amp;注册(绑定账号)</string>
<string name="delTag">删除标签</string>
<string name="clearCache">清除本地缓存</string>
<string name="copyToken">复制Token</string>
<string name="device">您的设备Token为:</string>
<string name="action_back">返回上级</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
This diff is collapsed. Click to expand it.
No preview for this file type
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!