Commit 78044345 by 石璀亮

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

1 parent af0be4b0
Showing with 5388 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;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Notification;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RemoteViews;
import android.widget.TextView;
import android.widget.Toast;
import com.qq.xgdemo.activity.AboutActivity;
import com.qq.xgdemo.activity.DeviceActivity;
import com.qq.xgdemo.activity.DiagnosisActivity;
import com.qq.xgdemo.activity.HelpActivity;
import com.qq.xgdemo.activity.MsgInfoActivity;
import com.qq.xgdemo.activity.SettingActivity;
import com.qq.xgdemo.bean.XGNotification;
import com.qq.xgdemo.common.NotificationService;
import com.tencent.android.tpush.XGCustomPushNotificationBuilder;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushClickedResult;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.android.tpush.common.Constants;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
public class MainActivity extends Activity implements AdapterView.OnItemClickListener, AbsListView.OnScrollListener {
private LinearLayout bloadLayout;// 加载提示的布局
private LinearLayout tloadLayout;// 加载提示的布局
private TextView bloadInfo;// 加载提示
private TextView tloadInfo;// 加载提示
private ListView pushListV;// 列表
private NotificationService notificationService;
// 获取通知数据服务
private pushAdapter adapter;// 列表适配器
private int currentPage = 1;// 默认第一页
private static final int lineSize = 10;// 每次显示数
private int allRecorders = 0;// 全部记录数
private int pageSize = 1;// 默认共1页
private boolean isLast = false;// 是否最后一条
private int firstItem;// 第一条显示出来的数据的游标
private int lastItem;// 最后显示出来数据的游标
private String id = "";// 查询条件
private boolean isUpdate = false;
private MsgReceiver updateListViewReceiver;
private Message m;
private Context context;
private String token;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context=this;
setContentView(R.layout.activity_main);
//代码内动态注册access ID
//XGPushConfig.setAccessId(this,2100250470);
//开启信鸽的日志输出,线上版本不建议调用
XGPushConfig.enableDebug(this,true);
//注册数据更新监听器
updateListViewReceiver = new MsgReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.qq.xgdemo.activity.UPDATE_LISTVIEW");
registerReceiver(updateListViewReceiver, intentFilter);
// 1.获取设备Token
Handler handler = new HandlerExtension(MainActivity.this);
m = handler.obtainMessage();
/*
注册信鸽服务的接口
如果仅仅需要发推送消息调用这段代码即可
*/
XGPushManager.registerPush(getApplicationContext(),
new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
Log.w(Constants.LogTag, "+++ register push sucess. token:" + data+"flag" +flag);
m.obj = "+++ register push sucess. token:" + data;
m.sendToTarget();
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.w(Constants.LogTag,
"+++ register push fail. token:" + data
+ ", errCode:" + errCode + ",msg:"
+ msg);
m.obj = "+++ register push fail. token:" + data
+ ", errCode:" + errCode + ",msg:" + msg;
m.sendToTarget();
}
});
//反注册代码,线上版本不能调用
// XGPushManager.unregisterPush(this);
intiView();
// initCustomPushNotificationBuilder(getApplicationContext());
}
private void intiView() {
//绑定列表展示
notificationService = NotificationService.getInstance(this);
pushListV = (ListView) this.findViewById(R.id.push_list);
//点击事件
pushListV.setOnItemClickListener(this);
//滑动事件
pushListV.setOnScrollListener(this);
//创建一个角标线性布局来显示正在加载
bloadLayout = new LinearLayout(this);
bloadLayout.setMinimumHeight(100);
bloadLayout.setGravity(Gravity.CENTER);
//定义一个文本显示"正在加载文本"
bloadInfo = new TextView(this);
bloadInfo.setTextSize(16);
bloadInfo.setTextColor(Color.parseColor("#858585"));
bloadInfo.setText("加载更多...");
bloadInfo.setGravity(Gravity.CENTER);
//绑定组件
bloadLayout.addView(bloadInfo, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
));
bloadLayout.getBottom();
//绑定提示到列表底部
pushListV.addFooterView(bloadLayout);
// 4. 创建一个角标线性布局来显示正在加载
tloadLayout = new LinearLayout(this);
tloadLayout.setGravity(Gravity.CENTER);
tloadLayout.setBackgroundResource(R.color.fuxk_base_color_white);
// 定义一个文本显示"正在加载文本"
tloadInfo = new TextView(this);
tloadInfo.setTextSize(14);
tloadInfo.setTextColor(Color.parseColor("#858585"));
// tloadInfo.setBackgroundResource(R.color.gray);
tloadInfo.setText("更多新消息...");
tloadInfo.setGravity(Gravity.CENTER);
tloadInfo.setHeight(0);
// 綁定組件
tloadLayout.addView(tloadInfo, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
// 绑定提示到列表底部
pushListV.addHeaderView(tloadLayout);
tloadLayout.setVisibility(View.GONE);
//右侧按钮
getOverflowMenu();
// 6.加载数据
getNotifications(id);
ImageView img_right = (ImageView) findViewById(R.id.img_right);
img_right.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showSpinner();
}
});
}
/**
* 设置通知自定义View,这样在下发通知时可以指定build_id。编号由开发者自己维护,build_id=0为默认设置
*
* @param context
*/
@SuppressWarnings("unused")
private void initCustomPushNotificationBuilder(Context context) {
XGCustomPushNotificationBuilder build = new XGCustomPushNotificationBuilder();
RemoteViews remoteViews =new RemoteViews("com.qq.xgdemo",R.layout.notification);
build.setbigContentView(remoteViews);
build.setSound(
RingtoneManager.getActualDefaultRingtoneUri(
getApplicationContext(), RingtoneManager.TYPE_ALARM))
.setSound(
Uri.parse("android.resource://" + getPackageName()
+ "/" + R.raw.tixin))
.setDefaults(Notification.DEFAULT_VIBRATE) // 振动
.setFlags(Notification.FLAG_NO_CLEAR); // 是否可清除
// 设置自定义通知layout,通知背景等可以在layout里设置
build.setLayoutId(R.layout.notification);
// 设置自定义通知内容id
build.setLayoutTextId(R.id.content);
// 设置自定义通知标题id
build.setLayoutTitleId(R.id.title);
// 设置自定义通知图片id
build.setLayoutIconId(R.id.icon);
// 设置自定义通知图片资源
build.setLayoutIconDrawableId(R.drawable.logo);
// 设置状态栏的通知小图标
//build.setbigContentView()
build.setIcon(R.drawable.right);
// 设置时间id
build.setLayoutTimeId(R.id.time);
// 若不设定以上自定义layout,又想简单指定通知栏图片资源
//build.setNotificationLargeIcon(R.drawable.ic_action_search);
// 客户端保存build_id
XGPushManager.setPushNotificationBuilder(this, 1, build);
XGPushManager.setDefaultNotificationBuilder(this,build);
}
@Override
protected void onNewIntent(Intent intent) {
// TODO Auto-generated method stub
super.onNewIntent(intent);
setIntent(intent);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
XGPushClickedResult click = XGPushManager.onActivityStarted(this);
Log.d("TPush", "onResumeXGPushClickedResult:" + click);
if (click != null) { // 判断是否来自信鸽的打开方式
Toast.makeText(this, "通知被点击:" + click.toString(),
Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onDestroy() {
unregisterReceiver(updateListViewReceiver);
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
XGPushManager.onActivityStoped(this);
}
private void showSpinner() {
View v = LayoutInflater.from(this).inflate(R.layout.menu_item, null);
final PopupWindow pw = new PopupWindow(v, LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
pw.setContentView(v);
pw.setOutsideTouchable(true);
pw.setFocusable(true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.showAsDropDown(findViewById(R.id.img_right));
TextView action_device_token = (TextView) v
.findViewById(R.id.action_device_token);
TextView action_help_center = (TextView) v
.findViewById(R.id.action_help_center);
TextView action_about_us = (TextView) v
.findViewById(R.id.action_about_us);
TextView action_clear = (TextView) v.findViewById(R.id.action_clear);
TextView action_setting = (TextView) v
.findViewById(R.id.action_setting);
TextView action_diagnosis = (TextView) v
.findViewById(R.id.action_diagnosis);
action_device_token.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pw.dismiss();
Intent deviceIntent = new Intent();
deviceIntent.setClass(context, DeviceActivity.class);
startActivity(deviceIntent);
}
});
action_help_center.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pw.dismiss();
Intent helpIntent = new Intent();
helpIntent.setClass(context, HelpActivity.class);
startActivity(helpIntent);
}
});
action_about_us.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pw.dismiss();
Intent aboutIntent = new Intent();
aboutIntent.setClass(context, AboutActivity.class);
startActivity(aboutIntent);
}
});
action_clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pw.dismiss();
adapter.setData(null);
adapter.notifyDataSetChanged();
findViewById(R.id.nodata).setVisibility(View.VISIBLE);
findViewById(R.id.deviceToken).setVisibility(View.VISIBLE);
findViewById(R.id.deviceTokenHint).setVisibility(View.VISIBLE);
findViewById(R.id.deviceLine).setVisibility(View.VISIBLE);
NotificationService.getInstance(context).deleteAll();
}
});
action_setting.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pw.dismiss();
Intent settingIntent = new Intent();
settingIntent.setClass(context, SettingActivity.class);
startActivity(settingIntent);
}
});
action_diagnosis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pw.dismiss();
Intent settingIntent = new Intent();
settingIntent.setClass(context, DiagnosisActivity.class);
startActivity(settingIntent);
}
});
}
private class pushAdapter extends BaseAdapter {
private Activity mActivity;
private LayoutInflater mInflater;
List<XGNotification> adapterData;
public pushAdapter(Activity aActivity) {
mActivity = aActivity;
mInflater = LayoutInflater.from(mActivity);
}
public List<XGNotification> getData() {
return adapterData;
}
public void setData(List<XGNotification> pushInfoList) {
adapterData = pushInfoList;
}
@Override
public int getCount() {
return (null == adapterData ? 0 : adapterData.size());
}
@Override
public Object getItem(int position) {
return (null == adapterData ? null : adapterData.get(position));
}
@Override
public long getItemId(int position) {
return position;
}
@SuppressLint("SimpleDateFormat")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
pushViewHolder aholder = null;
XGNotification item = adapterData.get(position);
if (convertView == null) {
aholder = new pushViewHolder();
convertView = mInflater.inflate(R.layout.item_push, null);
aholder.msg_idv = (TextView) convertView
.findViewById(R.id.push_msg_id);
aholder.contentv = (TextView) convertView
.findViewById(R.id.push_content);
aholder.timev = (TextView) convertView
.findViewById(R.id.push_time);
aholder.titlev = (TextView) convertView
.findViewById(R.id.push_title);
convertView.setTag(aholder);
} else {
aholder = (pushViewHolder) convertView.getTag();
}
aholder.msg_idv.setText("ID:" + item.getMsg_id());
aholder.titlev.setText(item.getTitle());
aholder.contentv.setText(item.getContent());
if (item.getUpdate_time() != null
&& item.getUpdate_time().length() > 18) {
String notificationdate = item.getUpdate_time()
.substring(0, 10);
String notificationtime = item.getUpdate_time().substring(11);
if (new SimpleDateFormat("yyyy-MM-dd").format(
Calendar.getInstance().getTime()).equals(
notificationdate)) {
aholder.timev.setText(notificationtime);
} else {
aholder.timev.setText(notificationdate);
}
} else {
aholder.timev.setText("未知");
}
return convertView;
}
}
;
private class pushViewHolder {
TextView msg_idv;
TextView titlev;
TextView timev;
TextView contentv;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int index, long id) {
Intent ait = new Intent(this, MsgInfoActivity.class);
if (index > 0 && index <= lastItem) {
XGNotification xgnotification = adapter.getData().get(index - 1);
ait.putExtra("msg_id", xgnotification.getMsg_id());
ait.putExtra("title", xgnotification.getTitle());
ait.putExtra("content", xgnotification.getContent());
ait.putExtra("activity", xgnotification.getActivity());
ait.putExtra("notificationActionType",
xgnotification.getNotificationActionType());
ait.putExtra("update_time", xgnotification.getUpdate_time());
this.startActivity(ait);
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
firstItem = firstVisibleItem;
lastItem = totalItemCount - 1;
if (firstVisibleItem + visibleItemCount == totalItemCount) {
isLast = true;
} else {
isLast = false;
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// 是否到最底部并且数据还没读完
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
if (isLast && currentPage < pageSize) {
currentPage++;
// 设置显示位置
pushListV.setSelection(lastItem);
// 增加数据
appendNotifications(id);
} else if (firstItem == 0) {
if (isUpdate && tloadInfo.getHeight() >= 50) {
isUpdate = false;
updateNotifications(id);
TranslateAnimation alp = new TranslateAnimation(0, 0, 80, 0);
alp.setDuration(1000);
alp.setRepeatCount(1);
tloadLayout.setAnimation(alp);
alp.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
tloadInfo.setText("正在更新...");
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
tloadInfo.setText("更多新消息...");
tloadLayout.setVisibility(View.GONE);
tloadInfo.setHeight(0);
tloadLayout.setMinimumHeight(0);
}
});
}
}
} else if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL
&& firstItem == 0) {
if (tloadInfo.getHeight() < 50) {
isUpdate = true;
tloadInfo.setHeight(50);
tloadLayout.setMinimumHeight(100);
tloadLayout.setVisibility(View.VISIBLE);
}
}
}
private void getOverflowMenu() {
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class
.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void getNotifications(String id) {
// 计算总数据条数
allRecorders = notificationService.getCount();
getNotificationswithouthint(id);
Toast.makeText(
this,
"共" + allRecorders + "条信息,加载了" + adapter.getData().size()
+ "条信息", Toast.LENGTH_SHORT).show();
}
private void updateNotifications(String id) {
// 计算总数据条数
int oldAllRecorders = allRecorders;
allRecorders = notificationService.getCount();
getNotificationswithouthint(id);
Toast.makeText(
this,
"共" + allRecorders + "条信息,更新了"
+ (allRecorders - oldAllRecorders) + "条新信息",
Toast.LENGTH_SHORT).show();
}
private void getNotificationswithouthint(String id) {
if (allRecorders != 0) {
this.findViewById(R.id.nodata).setVisibility(View.GONE);
this.findViewById(R.id.deviceToken).setVisibility(View.GONE);
this.findViewById(R.id.deviceTokenHint).setVisibility(View.GONE);
this.findViewById(R.id.deviceLine).setVisibility(View.GONE);
}
// 计算总页数
pageSize = (allRecorders + lineSize - 1) / lineSize;
// 创建适配器
adapter = new pushAdapter(this);
adapter.setData(NotificationService.getInstance(this).getScrollData(
currentPage = 1, lineSize, id));
if (allRecorders <= lineSize) {
bloadLayout.setVisibility(View.GONE);
bloadInfo.setHeight(0);
bloadLayout.setMinimumHeight(0);
} else {
if (pushListV.getFooterViewsCount() < 1) {
bloadLayout.setVisibility(View.VISIBLE);
bloadInfo.setHeight(50);
bloadLayout.setMinimumHeight(100);
}
}
pushListV.setAdapter(adapter);
}
private void appendNotifications(String id) {
// 计算总数据条数
allRecorders = notificationService.getCount();
// 计算总页数
pageSize = (allRecorders + lineSize - 1) / lineSize;
int oldsize = adapter.getData().size();
// 更新适配器
adapter.getData().addAll(
NotificationService.getInstance(this).getScrollData(
currentPage, lineSize, id));
// 如果到了最末尾则去掉"正在加载"
if (allRecorders == adapter.getCount()) {
bloadInfo.setHeight(0);
bloadLayout.setMinimumHeight(0);
bloadLayout.setVisibility(View.GONE);
} else {
bloadInfo.setHeight(50);
bloadLayout.setMinimumHeight(100);
bloadLayout.setVisibility(View.VISIBLE);
}
Toast.makeText(
this,
"共" + allRecorders + "条信息,加载了"
+ (adapter.getData().size() - oldsize) + "条信息",
Toast.LENGTH_SHORT).show();
// 通知改变
adapter.notifyDataSetChanged();
}
private static class HandlerExtension extends Handler {
WeakReference<MainActivity> mActivity;
HandlerExtension(MainActivity activity) {
mActivity = new WeakReference<MainActivity>(activity);
}
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
MainActivity theActivity = mActivity.get();
if (theActivity == null) {
theActivity = new MainActivity();
}
if (msg != null) {
Log.d("TPush", msg.obj.toString());
TextView textView = (TextView) theActivity
.findViewById(R.id.deviceToken);
textView.setText(XGPushConfig.getToken(theActivity));
}
// XGPushManager.registerCustomNotification(theActivity,
// "BACKSTREET", "BOYS", System.currentTimeMillis() + 5000, 0);
}
}
public class MsgReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
allRecorders = notificationService.getCount();
getNotificationswithouthint(id);
}
}
}
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.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.qq.xgdemo.R;
import com.qq.xgdemo.bean.ClickAction;
import com.qq.xgdemo.bean.Style;
import com.qq.xgdemo.bean.TimeInterval;
import com.qq.xgdemo.common.CommonWorkingThread;
import com.qq.xgdemo.common.ExtendedListView;
import com.qq.xgdemo.common.ExtendedListView.OnPositionChangedListener;
import com.qq.xgdemo.common.XingeApp;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGLocalMessage;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.android.tpush.common.Constants;
import com.tencent.android.tpush.service.XGPushServiceV3;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DiagnosisActivity extends Activity implements OnPositionChangedListener {
private DummyAdapter adapter;
Handler handler = null;
Message m = null;
private ExtendedListView mListView;
long currentTimeMillis = 0;
String token;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_diagnosis);
XGPushConfig.enableDebug(getApplicationContext(), true);
mListView = (ExtendedListView) findViewById(android.R.id.list);
adapter = new DummyAdapter();
adapter.setData(new ArrayList<String>());
mListView.setAdapter(adapter);
mListView.setCacheColorHint(Color.TRANSPARENT);
mListView.setOnPositionChangedListener(this);
handler = new HandlerExtension(DiagnosisActivity.this);
updateProgress("0ms 一键诊断程序开始执行......");
CommonWorkingThread.getInstance().execute(new Runnable() {
@Override
public void run() {
step0();
}
}, 100L);
findViewById(R.id.arrow).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
private class DummyAdapter extends BaseAdapter {
List<String> adapterData;
@Override
public int getCount() {
return (null == adapterData ? 0 : adapterData.size());
}
public List<String> getData() {
return adapterData;
}
public void setData(List<String> pushInfoList) {
adapterData = pushInfoList;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(DiagnosisActivity.this).inflate(R.layout.list_item, parent,
false);
}
TextView textView = (TextView) convertView;
textView.setText(position + " --> " + adapterData.get(position));
return convertView;
}
}
@Override
public void onPositionChanged(ExtendedListView listView, int firstVisiblePosition, View scrollBarPanel) {
((TextView) scrollBarPanel).setText("Position " + firstVisiblePosition);
}
private void step0() {
/*long timeMillis = System.currentTimeMillis();
try {
String path = "http://www.baidu.com";
*//*HttpGet httpGet = new HttpGet(path);
HttpClient httpClient = new DefaultHttpClient();
HttpResponse httpResp = httpClient.execute(httpGet);*//*
HttpURLConnection connection = (HttpURLConnection) new URL(path).openConnection();
connection.setRequestMethod("GET");
if (connection.getResponseCode() == 200) {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 网络状态良好!");
step1();
} else {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 网络状态异常,请检查是否联网!");
stepLast();
}
} catch (Throwable e) {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 网络状态异常,请检查是否联网!\r\n" + e.getMessage());
stepLast();
}*/
step1();
}
private void step1() {
long timeMillis = System.currentTimeMillis();
Process p;
try {
p = Runtime.getRuntime().exec("ping -c 3 -w 30 183.61.46.193");
int status = p.waitFor();
InputStream input = p.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(input));
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = in.readLine()) != null) {
buffer.append(line);
}
System.out.println("Return ============" + buffer.toString());
if (status == 0) {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽云端网络状态良好!");
step2();
} else {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽云端网络状态异常,请检查是否联网!");
stepLast();
}
} catch (Throwable e) {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽云端网络状态异常,请检查是否联网!\r\n" + e.getMessage());
stepLast();
}
}
private void step2() {
currentTimeMillis = System.currentTimeMillis();
XGPushManager.unregisterPush(getApplicationContext(),
new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
updateProgress((System.currentTimeMillis() - currentTimeMillis) + "ms 信鸽终端反注册成功!");
step3();
XGPushManager.registerPush(getApplicationContext(),
new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
token = data.toString();
updateProgress((System.currentTimeMillis() - currentTimeMillis) + "ms 信鸽终端注册成功!");
step4();
}
@Override
public void onFail(Object data, int errCode, String msg) {
StringBuffer sb = new StringBuffer((System.currentTimeMillis() - currentTimeMillis) + "ms 信鸽终端注册失败!\r\n").append(msg).append(errCode).append("!\r\n");
sb.append(errCodeHandle(errCode));
updateProgress("+++ register push failed. token:" + data);
}
});
}
@Override
public void onFail(Object data, int errCode, String msg) {
StringBuffer sb = new StringBuffer((System.currentTimeMillis() - currentTimeMillis) + "ms 信鸽终端反注册失败!\r\n").append(msg).append(errCode).append("!\r\n");
sb.append(errCodeHandle(errCode));
updateProgress(sb.toString());
}
});
}
private void step3() {
long timeMillis = System.currentTimeMillis();
ActivityManager am = (ActivityManager) this.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> runningServiceInfos = am.getRunningServices(Integer.MAX_VALUE);
if (runningServiceInfos == null || runningServiceInfos.size() < 1) {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端服务进程没有正常启动!");
return; }
String PushServiceName = XGPushServiceV3.class.getName();
for (RunningServiceInfo serviceInfo : runningServiceInfos) {
if (PushServiceName.equals(serviceInfo.service.getClassName())) {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端服务进程正常启动!");
return;
}
}
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端服务进程没有正常启动!");
}
private void step4() {
long timeMillis = System.currentTimeMillis();
XGLocalMessage local_msg = new XGLocalMessage();
local_msg.setType(1);
local_msg.setTitle("诊断程序-->本地通知测试");
local_msg.setContent("诊断程序-->本地通知测试");
local_msg.setDate("20170123");
local_msg.setHour("10");
local_msg.setMin("10");
XGPushManager.addLocalNotification(getApplicationContext(), local_msg);
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端添加本地通知成功!");
step5();
}
private void step5() {
long timeMillis = System.currentTimeMillis();
XGPushManager.clearLocalNotifications(getApplicationContext());
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端清理本地通知缓存成功!");
step6();
}
private void step6() {
long timeMillis = System.currentTimeMillis();
XGPushManager.setTag(getApplicationContext(), "DiagnosisTag");
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端添加标签成功!");
XGPushManager.deleteTag(getApplicationContext(), "DiagnosisTag");
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端删除标签成功!");
step7();
}
private void step7() {
long timeMillis = System.currentTimeMillis();
int ret_code = 0;
try {
com.qq.xgdemo.bean.Message message = new com.qq.xgdemo.bean.Message();
message.setType(com.qq.xgdemo.bean.Message.TYPE_NOTIFICATION);
Style style = new Style(1);
style = new Style(3, 1, 0, 1, 0);
ClickAction action = new ClickAction();
action.setActionType(ClickAction.TYPE_URL);
action.setUrl("http://xg.qq.com");
Map<String, Object> custom = new HashMap<String, Object>();
custom.put("key1", "value1");
custom.put("key2", 2);
message.setTitle("诊断程序-->网络通知测试");
message.setContent("诊断程序-->网络通知测试");
message.setStyle(style);
message.setAction(action);
message.setCustom(custom);
TimeInterval acceptTime1 = new TimeInterval(0, 0, 23, 59);
message.addAcceptTime(acceptTime1);
String secretKey = (String) getMetaData(getApplicationContext(), "XG_V2_SECRET_KEY", "");
long accID = (Integer) getMetaData(getApplicationContext(), "XG_V2_ACCESS_ID", "0");
XingeApp xinge = new XingeApp(accID, secretKey);
JSONObject ret = xinge.pushSingleDevice(token, message);
ret_code = ret.getInt("ret_code");
} catch (Throwable e) {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端向云端请求发送通知失败!\r\n" + e.getMessage());
}
if (ret_code == 0) {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端向云端请求发送通知成功!");
} else {
updateProgress((System.currentTimeMillis() - timeMillis) + "ms 信鸽终端向云端请求发送通知失败!\r\n" + errCodeHandle(ret_code));
}
stepLast();
}
private void stepLast() {
updateProgress("一键诊断程序执行完毕!\r\n");
updateProgress("请将/sdcard0/tencent/Tpush/Logs目录打包发送给管理员!\r\n");
updateProgress("如果以上看不懂,请截图并联系您的开发人员!");
}
private static class HandlerExtension extends Handler {
WeakReference<DiagnosisActivity> mActivity;
HandlerExtension(DiagnosisActivity activity) {
mActivity = new WeakReference<DiagnosisActivity>(activity);
}
@Override
public void handleMessage(android.os.Message msg) {
super.handleMessage(msg);
DiagnosisActivity theActivity = mActivity.get();
if (theActivity == null) {
theActivity = new DiagnosisActivity();
}
if (msg != null) {
Log.w(Constants.LogTag, msg.obj.toString());
ExtendedListView mListView = (ExtendedListView) theActivity.findViewById(android.R.id.list);
DummyAdapter adapter = (DummyAdapter) mListView.getAdapter();
adapter.getData().add(msg.obj.toString());
adapter.notifyDataSetChanged();
}
}
}
private static String errCodeHandle(int errCode) {
switch (errCode) {
case -1:
return "参数错误,请检查各字段是否合法!";
case -2:
return "请求时间戳不在有效期内!";
case -3:
return "sign校验无效,检查access id和secret key(注意不是access key)!";
case 7:
return "别名/账号绑定的终端数满了(10个)!";
case 14:
return "收到非法token,例如ios终端没能拿到正确的token!";
case 15:
return "信鸽逻辑服务器繁忙!";
case 19:
return "操作时序错误\r\n例如:进行tag操作前未获取到deviceToken 没有获取到deviceToken的原因: 1.没有注册信鸽或者苹果推送。 2.provisioning profile制作不正确。!";
case 20:
return "鉴权错误,可能是由于Access ID和Access Key不匹配,请检查1.AndroidMenifest.xml是否配置正确;2.云端环境是否是正式环境!";
case 40:
return "推送的token没有在信鸽中注册,请重新执行注册流程,或增加注册失败重试逻辑!并检查反注册逻辑是否使用不当?";
case 48:
return "推送的账号没有在信鸽中注册,请重新执行注册流程,或增加注册失败重试逻辑!";
case 63:
return "标签系统忙,请重新执行设置标签流程,或增加设置标签失败重试逻辑!";
case 71:
return "APNS服务器繁忙!";
case 73:
return "消息字符数超限,通知不超过75个字符,消息不超过4096字节!";
case 76:
return "请求过于频繁,请稍后再试!";
case 100:
return "APNS证书错误。请重新提交正确的证书!";
case 2:
return "参数错误,例如绑定了单字符的别名,或是ios的token长度不对,应为64个字符!";
case 10000:
return "起始错误!";
case 10001:
return "操作类型错误码,例如参数错误时将会发生该错误!";
case 10002:
return "正在执行注册操作时,又有一个注册操作到来,则回调此错误码!";
case 10003:
return "权限出错,请检查AndroidMenifest.xml权限是否配置齐全,详见http://developer.xg.qq.com/index.php/Android_SDK%E5%BF%AB%E9%80%9F%E6%8C%87%E5%8D%97!";
case 10004:
return "so出错,请检查工程是否导入libtpnsSecurity.so和libtpnsWatchdog.so,然后重新安装!";
case 10100:
return "当前网络不可用,请检查wifi或移动网络是否打开!";
case 10101:
return "创建链路失败,请重启应用!";
case 10102:
return "请求处理过程中, 链路被主动关闭!";
case 10103:
return "请求处理过程中,服务器关闭链接!";
case 10104:
return "请求处理过程中,客户端产生异常!";
case 10105:
return "请求处理过程中,发送或接收报文超时!";
case 10106:
return "请求处理过程中, 等待发送请求超时!";
case 10107:
return "请求处理过程中, 等待接收请求超时!";
case 10108:
return "服务器返回异常报文!";
case 10109:
return "未知异常,请在QQ群中直接联系管理员,或前往论坛发帖留言!";
case 10110:
return "创建链路的handler为null!";
default:
return "";
}
}
private static Object getMetaData(Context paramContext, String name, Object defaultValue) throws NameNotFoundException {
PackageManager packageManager = paramContext.getPackageManager();
ApplicationInfo applicationInfo = packageManager
.getApplicationInfo(paramContext.getPackageName(),
PackageManager.GET_META_DATA);
if (applicationInfo != null) {
Object obj = applicationInfo.metaData.get(name);
if (obj != null) {
return obj;
}
}
return defaultValue;
}
private void updateProgress(String mobj) {
m = handler.obtainMessage();
m.obj = mobj;
m.sendToTarget();
}
}
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.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Notification;
import android.content.Context;
import android.content.DialogInterface;
import android.media.RingtoneManager;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.qq.xgdemo.R;
import com.tencent.android.tpush.XGBasicPushNotificationBuilder;
import com.tencent.android.tpush.XGCustomPushNotificationBuilder;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGLocalMessage;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.android.tpush.horse.Tools;
public class SettingActivity extends Activity {
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
context = this;
initComponent();
// 通知自定义初始化(如果需要自定义通知view)
//initCustomPushNotificationBuilder(context);
}
/**
* 设置自定义样式,这样在下发通知时可以指定build_id。编号由开发者自己维护,build_id=0为默认设置
*
* @param context
*/
@SuppressWarnings("unused")
public void initNotificationBuilder(Context context) {
// 新建自定义样式
XGBasicPushNotificationBuilder build = new XGBasicPushNotificationBuilder();
// 设置自定义样式属性,该属性对对应的编号生效,指定后不能修改。
build.setIcon(R.drawable.notification_icon)
.setSound(
RingtoneManager.getActualDefaultRingtoneUri(
getApplicationContext(),
RingtoneManager.TYPE_ALARM)) // 设置声音
.setDefaults(Notification.DEFAULT_VIBRATE) // 振动
.setFlags(Notification.FLAG_NO_CLEAR); // 是否可清除
// 设置通知样式,样式编号为2,即build_id为2,可通过后台脚本指定
XGPushManager.setPushNotificationBuilder(getApplicationContext(),
2, build);
// 下同
// XGBasicPushNotificationBuilder build11 = new
// XGBasicPushNotificationBuilder();
// build11.setIcon(R.drawable.ic_launcher)
// .setSound(
// RingtoneManager
// .getDefaultUri(RingtoneManager.TYPE_ALARM))
// .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
// .setFlags(Notification.FLAG_NO_CLEAR);
// XGPushManager.setPushNotificationBuilder(getApplicationContext(), 5,
// build11);
}
/**
* 设置通知自定义View,这样在下发通知时可以指定build_id。编号由开发者自己维护,build_id=0为默认设置
*
* @param context
*/
@SuppressWarnings("unused")
private void initCustomPushNotificationBuilder(Context context) {
XGCustomPushNotificationBuilder build = new XGCustomPushNotificationBuilder();
build.setSound(
RingtoneManager.getActualDefaultRingtoneUri(
getApplicationContext(), RingtoneManager.TYPE_ALARM)) // 设置声音
// setSound(
// Uri.parse("android.resource://" + getPackageName()
// + "/" + R.raw.wind)) 设定Raw下指定声音文件
.setDefaults(Notification.DEFAULT_VIBRATE) // 振动
.setFlags(Notification.FLAG_NO_CLEAR); // 是否可清除
// 设置自定义通知layout,通知背景等可以在layout里设置
build.setLayoutId(R.layout.notification);
// 设置自定义通知内容id
build.setLayoutTextId(R.id.content);
// 设置自定义通知标题id
build.setLayoutTitleId(R.id.title);
// 设置自定义通知图片id
build.setLayoutIconId(R.id.icon);
// 设置自定义通知图片资源
build.setLayoutIconDrawableId(R.drawable.logo);
// 设置状态栏的通知小图标
build.setIcon(R.drawable.right);
// 设置时间id
build.setLayoutTimeId(R.id.time);
// 若不设定以上自定义layout,又想简单指定通知栏图片资源(注:自定义layout和setNotificationLargeIcon两种方式指定图片资源只能选其一,不能同时使用)
// build.setNotificationLargeIcon(R.drawable.logo);
// 客户端保存build_id
// XGPushManager.setPushNotificationBuilder(this, build_id, build);
}
// 设置本地消息
@SuppressWarnings("unused")
private void initLocalMessage() {
XGLocalMessage local_msg = new XGLocalMessage();
// 设置本地消息类型,1:通知,2:消息
local_msg.setType(1);
// 设置消息标题
local_msg.setTitle("qq");
// 设置消息内容
local_msg.setContent("ww");
// 设置消息日期,格式为:20140502
local_msg.setDate("20140930");
// 设置消息触发的小时(24小时制),例如:22代表晚上10点
local_msg.setHour("19");
// 获取消息触发的分钟,例如:05代表05分
local_msg.setMin("31");
// 设置消息样式,默认为0或不设置
// local_msg.setBuilderId(6);
// 设置拉起应用页面
// local_msg.setActivity("com.qq.xgdemo.SettingActivity");
// 设置动作类型:1打开activity或app本身,2打开浏览器,3打开Intent ,4通过包名打开应用
// local_msg.setAction_type(1);
// 设置URL
// local_msg.setUrl("http://www.baidu.com");
// 设置Intent
// local_msg.setIntent("intent:10086#Intent;scheme=tel;action=android.intent.action.DIAL;S.key=value;end");
// 自定义本地通知样式
// local_msg.setIcon_type(0);
// local_msg.setIcon_res("right");
// 是否覆盖原先build_id的保存设置。1覆盖,0不覆盖
// local_msg.setStyle_id(1);
// 设置音频资源
// local_msg.setRing_raw("mm");
// 设置key,value
// HashMap<String, Object> map = new HashMap<String, Object>();
// map.put("key", "v1");
// map.put("key2", "v2");
// local_msg.setCustomContent(map);
// 设置下载应用URL
// local_msg.setPackageDownloadUrl("http://softfile.3g.qq.com:8080/msoft/179/1105/10753/MobileQQ1.0(Android)_Build0198.apk");
// 设置要打开的应用包名
// local_msg.setPackageName("com.example.com.qq.feedback");
XGPushManager.addLocalNotification(context, local_msg);
}
private void initComponent() {
// initCustomPushNotificationBuilder(getApplicationContext());
// initNotificationBuilder(getApplicationContext());
findViewById(R.id.Button_register).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
// 注册应用(必须调用本接口,否则APP将无法接收到通知和消息)
// registerPush有2个版本的接口:带账号绑定和不带
// registerPush可以在APP启动时或用户登陆后调用
XGPushManager.registerPush(getApplicationContext());
}
});
findViewById(R.id.Button_registerAccount).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Context ctx = context;
if (ctx != null) {
LinearLayout layout = new LinearLayout(ctx);
layout.setOrientation(LinearLayout.VERTICAL);
final EditText textviewGid = new EditText(ctx);
textviewGid.setHint("请输入需要绑定的账号");
layout.addView(textviewGid);
AlertDialog.Builder builder = new AlertDialog.Builder(
ctx);
builder.setView(layout);
builder.setPositiveButton("账号注册",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
String text = textviewGid.getText()
.toString();
if (text != null
&& text.length() != 0) {
// 注册应用(必须调用本接口,否则APP将无法接收到通知和消息)
// 使用绑定账号的注册接口(可针对账号下发通知和消息)
// 可以重复注册,以最后一次注册为准
XGPushManager
.registerPush(
getApplicationContext(),
text);
}
}
});
builder.show();
}
}
});
findViewById(R.id.Button_unregister).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
// 反注册,调用本接口后,APP将停止接收通知和消息
XGPushManager.unregisterPush(getApplicationContext());
}
});
findViewById(R.id.Button_setTag).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Context ctx = context;
if (ctx != null) {
LinearLayout layout = new LinearLayout(ctx);
layout.setOrientation(LinearLayout.VERTICAL);
final EditText textviewGid = new EditText(ctx);
textviewGid.setHint("请输入标签名称");
layout.addView(textviewGid);
AlertDialog.Builder builder = new AlertDialog.Builder(
ctx);
builder.setView(layout);
builder.setPositiveButton("设置标签",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
String text = textviewGid.getText()
.toString();
if (text != null
&& text.length() != 0) {
XGPushManager
.setTag(getApplicationContext(),
text);
}
}
});
builder.show();
}
}
});
findViewById(R.id.Button_delTag).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Context ctx = context;
if (ctx != null) {
LinearLayout layout = new LinearLayout(ctx);
layout.setOrientation(LinearLayout.VERTICAL);
final EditText textviewGid = new EditText(ctx);
textviewGid.setHint("请输入标签名称");
layout.addView(textviewGid);
AlertDialog.Builder builder = new AlertDialog.Builder(
ctx);
builder.setView(layout);
builder.setPositiveButton("删除标签",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
String text = textviewGid.getText()
.toString();
if (text != null
&& text.length() != 0) {
XGPushManager.deleteTag(
SettingActivity.this,
text);
}
}
});
builder.show();
}
}
});
findViewById(R.id.Button_clearCache).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Tools.clearCacheServerItems(getApplicationContext());
Tools.clearOptStrategyItem(getApplicationContext());
}
});
findViewById(R.id.Button_copyToken).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
String token = XGPushConfig
.getToken(getApplicationContext());
if (token != null && !"".equals(token)) {
ClipboardManager copy = (ClipboardManager) SettingActivity.this
.getSystemService(Context.CLIPBOARD_SERVICE);
copy.setText(token);
} else {
Toast.makeText(SettingActivity.this,
"请先注册,获取token!", Toast.LENGTH_SHORT).show();
}
}
});
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);
}
@Override
protected void onDestroy() {
super.onDestroy();
XGPushManager.registerPush(this, "*", new XGIOperateCallback() {
@Override
public void onSuccess(Object o, int i) {
Log.d("TPush","接触绑定成功");
}
@Override
public void onFail(Object o, int i, String s) {
Log.d("TPush","接触绑定失败"+s);
}
});
}
}
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.common;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.text.TextUtils;
import com.qq.xgdemo.bean.Message;
import com.qq.xgdemo.bean.MessageIOS;
import com.qq.xgdemo.bean.TagTokenPair;
public class XingeApp {
public static final String RESTAPI_PUSHSINGLEDEVICE = "http://openapi.xg.qq.com/v2/push/single_device";
public static final String RESTAPI_PUSHSINGLEACCOUNT = "http://openapi.xg.qq.com/v2/push/single_account";
public static final String RESTAPI_PUSHACCOUNTLIST = "http://openapi.xg.qq.com/v2/push/account_list";
public static final String RESTAPI_PUSHALLDEVICE = "http://openapi.xg.qq.com/v2/push/all_device";
public static final String RESTAPI_PUSHTAGS = "http://openapi.xg.qq.com/v2/push/tags_device";
public static final String RESTAPI_QUERYPUSHSTATUS = "http://openapi.xg.qq.com/v2/push/get_msg_status";
public static final String RESTAPI_QUERYDEVICECOUNT = "http://openapi.xg.qq.com/v2/application/get_app_device_num";
public static final String RESTAPI_QUERYTAGS = "http://openapi.xg.qq.com/v2/tags/query_app_tags";
public static final String RESTAPI_CANCELTIMINGPUSH = "http://openapi.xg.qq.com/v2/push/cancel_timing_task";
public static final String RESTAPI_BATCHSETTAG = "http://openapi.xg.qq.com/v2/tags/batch_set";
public static final String RESTAPI_BATCHDELTAG = "http://openapi.xg.qq.com/v2/tags/batch_del";
public static final String RESTAPI_QUERYTOKENTAGS = "http://openapi.xg.qq.com/v2/tags/query_token_tags";
public static final String RESTAPI_QUERYTAGTOKENNUM = "http://openapi.xg.qq.com/v2/tags/query_tag_token_num";
public static final String HTTP_POST = "POST";
public static final String HTTP_GET = "GET";
public static final int DEVICE_ALL = 0;
public static final int DEVICE_BROWSER = 1;
public static final int DEVICE_PC = 2;
public static final int DEVICE_ANDROID = 3;
public static final int DEVICE_IOS = 4;
public static final int DEVICE_WINPHONE = 5;
public static final int IOSENV_PROD = 1;
public static final int IOSENV_DEV = 2;
public static void main(String[] args) {
System.out.println("Hello xg!");
}
public JSONObject pushSingleDevice(String deviceToken, Message message) throws JSONException {
if (!message.isValid()) {
return new JSONObject("{'ret_code':-1,'err_msg':'message invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("send_time", message.getSendTime());
params.put("multi_pkg", message.getMultiPkg());
params.put("device_token", deviceToken);
params.put("message_type", message.getType());
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
return callRestful(XingeApp.RESTAPI_PUSHSINGLEDEVICE, params);
}
public JSONObject pushSingleDevice(String deviceToken, MessageIOS message, int environment) throws JSONException {
if (!message.isValid()) {
return new JSONObject("{'ret_code':-1,'err_msg':'message invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("send_time", message.getSendTime());
params.put("device_token", deviceToken);
params.put("message_type", message.getType());
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
params.put("environment", environment);
if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0) {
params.put("loop_interval", message.getLoopInterval());
params.put("loop_times", message.getLoopTimes());
}
return callRestful(XingeApp.RESTAPI_PUSHSINGLEDEVICE, params);
}
public JSONObject pushSingleAccount(int deviceType, String account, Message message) throws JSONException {
if (!message.isValid()) {
return new JSONObject("{'ret_code':-1,'err_msg':'message invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("send_time", message.getSendTime());
params.put("multi_pkg", message.getMultiPkg());
params.put("device_type", deviceType);
params.put("account", account);
params.put("message_type", message.getType());
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
return callRestful(XingeApp.RESTAPI_PUSHSINGLEACCOUNT, params);
}
public JSONObject pushAccountList(int deviceType, List<String> accountList, Message message) throws JSONException {
if (!message.isValid()) {
return new JSONObject("{'ret_code':-1,'err_msg':'message invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("multi_pkg", message.getMultiPkg());
params.put("device_type", deviceType);
params.put("account_list", new JSONArray(accountList).toString());
params.put("message_type", message.getType());
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
return callRestful(XingeApp.RESTAPI_PUSHACCOUNTLIST, params);
}
public JSONObject pushSingleAccount(int deviceType, String account, MessageIOS message, int environment) throws JSONException {
if (!message.isValid()) {
return new JSONObject("{'ret_code':-1,'err_msg':'message invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("send_time", message.getSendTime());
params.put("device_type", deviceType);
params.put("account", account);
params.put("message_type", message.getType());
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
params.put("environment", environment);
return callRestful(XingeApp.RESTAPI_PUSHSINGLEACCOUNT, params);
}
public JSONObject pushAccountList(int deviceType, List<String> accountList, MessageIOS message, int environment) throws JSONException {
if (!message.isValid()) {
return new JSONObject("{'ret_code':-1,'err_msg':'message invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("device_type", deviceType);
params.put("account_list", new JSONArray(accountList).toString());
params.put("message_type", message.getType());
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
params.put("environment", environment);
return callRestful(XingeApp.RESTAPI_PUSHACCOUNTLIST, params);
}
public JSONObject pushAllDevice(int deviceType, Message message) throws JSONException {
if (!message.isValid()) {
return new JSONObject("{'ret_code':-1,'err_msg':'message invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("send_time", message.getSendTime());
params.put("multi_pkg", message.getMultiPkg());
params.put("device_type", deviceType);
params.put("message_type", message.getType());
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0) {
params.put("loop_interval", message.getLoopInterval());
params.put("loop_times", message.getLoopTimes());
}
return callRestful(XingeApp.RESTAPI_PUSHALLDEVICE, params);
}
public JSONObject pushAllDevice(int deviceType, MessageIOS message, int environment) throws JSONException {
if (!message.isValid()) {
return new JSONObject("{'ret_code':-1,'err_msg':'message invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("send_time", message.getSendTime());
params.put("device_type", deviceType);
params.put("message_type", message.getType());
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
params.put("environment", environment);
if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0) {
params.put("loop_interval", message.getLoopInterval());
params.put("loop_times", message.getLoopTimes());
}
return callRestful(XingeApp.RESTAPI_PUSHALLDEVICE, params);
}
public JSONObject pushTags(int deviceType, List<String> tagList, String tagOp, Message message) throws JSONException {
if (!message.isValid() || tagList.size() == 0 || (!tagOp.equals("AND") && !tagOp.equals("OR"))) {
return new JSONObject("{'ret_code':-1,'err_msg':'param invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("send_time", message.getSendTime());
params.put("multi_pkg", message.getMultiPkg());
params.put("device_type", deviceType);
params.put("message_type", message.getType());
params.put("tags_list", new JSONArray(tagList).toString());
params.put("tags_op", tagOp);
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0) {
params.put("loop_interval", message.getLoopInterval());
params.put("loop_times", message.getLoopTimes());
}
return callRestful(XingeApp.RESTAPI_PUSHTAGS, params);
}
public JSONObject pushTags(int deviceType, List<String> tagList, String tagOp, MessageIOS message, int environment) throws JSONException {
if (!message.isValid() || tagList.size() == 0 || (!tagOp.equals("AND") && !tagOp.equals("OR"))) {
return new JSONObject("{'ret_code':-1,'err_msg':'param invalid!'}");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("expire_time", message.getExpireTime());
params.put("send_time", message.getSendTime());
params.put("device_type", deviceType);
params.put("message_type", message.getType());
params.put("tags_list", new JSONArray(tagList).toString());
params.put("tags_op", tagOp);
params.put("message", message.toJson());
params.put("timestamp", System.currentTimeMillis() / 1000);
params.put("environment", environment);
if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0) {
params.put("loop_interval", message.getLoopInterval());
params.put("loop_times", message.getLoopTimes());
}
return callRestful(XingeApp.RESTAPI_PUSHTAGS, params);
}
public JSONObject queryPushStatus(List<String> pushIdList) throws JSONException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("timestamp", System.currentTimeMillis() / 1000);
JSONArray jArray = new JSONArray();
for (String pushId : pushIdList) {
JSONObject js = new JSONObject();
js.put("push_id", pushId);
jArray.put(js);
}
params.put("push_ids", jArray.toString());
return callRestful(XingeApp.RESTAPI_QUERYPUSHSTATUS, params);
}
public JSONObject queryDeviceCount() throws JSONException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("timestamp", System.currentTimeMillis() / 1000);
return callRestful(XingeApp.RESTAPI_QUERYDEVICECOUNT, params);
}
public JSONObject queryTags(int start, int limit) throws JSONException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("start", start);
params.put("limt", limit);
params.put("timestamp", System.currentTimeMillis() / 1000);
return callRestful(XingeApp.RESTAPI_QUERYTAGS, params);
}
public JSONObject queryTags() throws JSONException {
return queryTags(0, 100);
}
public JSONObject queryTagTokenNum(String tag) throws JSONException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("tag", tag);
params.put("timestamp", System.currentTimeMillis() / 1000);
return callRestful(XingeApp.RESTAPI_QUERYTAGTOKENNUM, params);
}
public JSONObject queryTokenTags(String deviceToken) throws JSONException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("device_token", deviceToken);
params.put("timestamp", System.currentTimeMillis() / 1000);
return callRestful(XingeApp.RESTAPI_QUERYTOKENTAGS, params);
}
public JSONObject cancelTimingPush(String pushId) throws JSONException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("push_id", pushId);
params.put("timestamp", System.currentTimeMillis() / 1000);
return callRestful(XingeApp.RESTAPI_CANCELTIMINGPUSH, params);
}
public XingeApp(long accessId, String secretKey) {
this.m_accessId = accessId;
this.m_secretKey = secretKey;
}
protected String generateSign(String method, String url, Map<String, Object> params) {
List<Map.Entry<String, Object>> paramList = new ArrayList<Map.Entry<String, Object>>(params.entrySet());
Collections.sort(paramList, new Comparator<Map.Entry<String, Object>>() {
public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
return (o1.getKey()).toString().compareTo(o2.getKey());
}
});
String paramStr = "";
String md5Str = "";
for (Map.Entry<String, Object> entry : paramList) {
paramStr += entry.getKey() + "=" + entry.getValue().toString();
}
try {
URL u = new URL(url);
MessageDigest md5 = MessageDigest.getInstance("MD5");
String s = method + u.getHost() + u.getPath() + paramStr + this.m_secretKey;
byte[] bArr = s.getBytes("UTF-8");
byte[] md5Value = md5.digest(bArr);
BigInteger bigInt = new BigInteger(1, md5Value);
md5Str = bigInt.toString(16);
while (md5Str.length() < 32) {
md5Str = "0" + md5Str;
}
// System.out.println(s);
} catch (Exception e) {
// e.printStackTrace();
return "";
}
return md5Str;
}
protected JSONObject callRestful(String url, Map<String, Object> params) throws JSONException {
String temp;
String ret = "";
JSONObject jsonRet = null;
String sign = generateSign("POST", url, params);
if (TextUtils.isEmpty(sign))
return new JSONObject("{\"ret_code\":-1,\"err_msg\":\"generateSign error\"}");
params.put("sign", sign);
try {
URL u = new URL(url);
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
conn.setRequestMethod("POST");
conn.setConnectTimeout(10000);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
StringBuffer param = new StringBuffer();
for (String key : params.keySet()) {
param.append(key).append("=").append(URLEncoder.encode(params.get(key).toString(), "UTF-8")).append("&");
}
conn.getOutputStream().write(param.toString().getBytes("UTF-8"));
// System.out.println(param);
conn.getOutputStream().flush();
conn.getOutputStream().close();
InputStreamReader isr = new InputStreamReader(conn.getInputStream());
BufferedReader br = new BufferedReader(isr);
while ((temp = br.readLine()) != null) {
ret += temp;
}
br.close();
isr.close();
conn.disconnect();
// System.out.println(ret);
jsonRet = new JSONObject(ret);
} catch (java.net.SocketTimeoutException e) {
// e.printStackTrace();
jsonRet = new JSONObject("{\"ret_code\":-1,\"err_msg\":\"call restful timeout\"}");
} catch (Exception e) {
// e.printStackTrace();
jsonRet = new JSONObject("{\"ret_code\":-1,\"err_msg\":\"call restful error\"}");
}
return jsonRet;
}
protected boolean ValidateToken(String token) {
if (this.m_accessId >= 2200000000L) {
return token.length() == 64;
} else {
return (token.length() == 40 || token.length() == 64);
}
}
protected Map<String, Object> InitParams() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("access_id", this.m_accessId);
params.put("timestamp", System.currentTimeMillis() / 1000);
return params;
}
public JSONObject BatchSetTag(List<TagTokenPair> tagTokenPairs) throws JSONException {
for (TagTokenPair pair : tagTokenPairs) {
if (!this.ValidateToken(pair.token)) {
String returnMsgJsonStr = String.format("{\"ret_code\":-1,\"err_msg\":\"invalid token %s\"}", pair.token);
return new JSONObject(returnMsgJsonStr);
}
}
Map<String, Object> params = this.InitParams();
List<List> tag_token_list = new ArrayList<List>();
for (TagTokenPair pair : tagTokenPairs) {
List<String> singleTagToken = new ArrayList<String>();
singleTagToken.add(pair.tag);
singleTagToken.add(pair.token);
tag_token_list.add(singleTagToken);
}
params.put("tag_token_list", new JSONArray(tag_token_list).toString());
return callRestful(XingeApp.RESTAPI_BATCHSETTAG, params);
}
public JSONObject BatchDelTag(List<TagTokenPair> tagTokenPairs) throws JSONException {
for (TagTokenPair pair : tagTokenPairs) {
if (!this.ValidateToken(pair.token)) {
String returnMsgJsonStr = String.format("{\"ret_code\":-1,\"err_msg\":\"invalid token %s\"}", pair.token);
return new JSONObject(returnMsgJsonStr);
}
}
Map<String, Object> params = this.InitParams();
List<List> tag_token_list = new ArrayList<List>();
for (TagTokenPair pair : tagTokenPairs) {
List<String> singleTagToken = new ArrayList<String>();
singleTagToken.add(pair.tag);
singleTagToken.add(pair.token);
tag_token_list.add(singleTagToken);
}
params.put("tag_token_list", new JSONArray(tag_token_list).toString());
return callRestful(XingeApp.RESTAPI_BATCHDELTAG, params);
}
private long m_accessId;
private String m_secretKey;
}
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>
package com.qq.xgdemo;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
No preview for this file type
#Tue May 16 15:40:00 CST 2017
0......=
...................................................................................................................................................................................................................................................................................................+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\#Fri=Apr 21 13\:30\:32 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
include ':app'
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!