>();
@@ -127,7 +127,7 @@ public final class LocalBroadcastManager {
ArrayList entries = (ArrayList) this.mActions.get(intent.getAction());
if (entries != null) {
if (debug) {
- Logger.v("LocalBroadcastManager", "Action list: " + entries);
+ Logger.v("LocalBroadcastManager", "Action list: " + entries);
}
ArrayList receivers = null;
@@ -141,7 +141,7 @@ public final class LocalBroadcastManager {
if (receiver.broadcasting) {
if (debug) {
- Logger.v("LocalBroadcastManager", " Filter\'s target already added");
+ Logger.v("LocalBroadcastManager", " Filter\'s target already added");
}
} else {
int match = receiver.filter.match(action, type, scheme, data, categories, "LocalBroadcastManager");
@@ -175,7 +175,7 @@ public final class LocalBroadcastManager {
reason = "unknown reason";
}
- Logger.v("LocalBroadcastManager", " Filter did not match: " + reason);
+ Logger.v("LocalBroadcastManager", " Filter did not match: " + reason);
}
}
}
diff --git a/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/MyReceiver.java b/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/MyReceiver.java
index bd52cd52c34eb0975b43655191af15588b5a700c..8e3dbd1971342565d9e3d6c3c51cb9f6a2ec8945 100644
--- a/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/MyReceiver.java
+++ b/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/MyReceiver.java
@@ -15,109 +15,109 @@ import cn.jpush.android.api.JPushInterface;
/**
* 自定义接收器
- *
+ *
* 如果不定义这个 Receiver,则:
* 1) 默认用户会打开主界面
* 2) 接收不到自定义消息
*/
public class MyReceiver extends BroadcastReceiver {
- private static final String TAG = "JIGUANG-Example";
-
- @Override
- public void onReceive(Context context, Intent intent) {
- try {
- Bundle bundle = intent.getExtras();
- Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
-
- if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
- String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
- Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
- //send the Registration Id to your server...
-
- } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
- Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
- processCustomMessage(context, bundle);
-
- } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
- Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
- int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
- Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
-
- } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
- Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
-
- //打开自定义的Activity
- Intent i = new Intent(context, TestActivity.class);
- i.putExtras(bundle);
- //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
- context.startActivity(i);
-
- } else if(JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
- boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
- Logger.w(TAG, "[MyReceiver]" + intent.getAction() +" connected state change to "+connected);
- } else {
- Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
- }
- } catch (Exception e){
-
- }
-
- }
-
- // 打印所有的 intent extra 数据
- private static String printBundle(Bundle bundle) {
- StringBuilder sb = new StringBuilder();
- for (String key : bundle.keySet()) {
- if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
- sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
- }else if(key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)){
- sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
- } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
- if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
- Logger.i(TAG, "This message has no Extra data");
- continue;
- }
-
- try {
- JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
- Iterator it = json.keys();
-
- while (it.hasNext()) {
- String myKey = it.next();
- sb.append("\nkey:" + key + ", value: [" +
- myKey + " - " +json.optString(myKey) + "]");
- }
- } catch (JSONException e) {
- Logger.e(TAG, "Get message extra JSON error!");
- }
-
- } else {
- sb.append("\nkey:" + key + ", value:" + bundle.get(key));
- }
- }
- return sb.toString();
- }
-
- //send msg to MainActivity
- private void processCustomMessage(Context context, Bundle bundle) {
- if (JiGuangPushMainActivity.isForeground) {
- String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
- String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
- Intent msgIntent = new Intent(JiGuangPushMainActivity.MESSAGE_RECEIVED_ACTION);
- msgIntent.putExtra(JiGuangPushMainActivity.KEY_MESSAGE, message);
- if (!ExampleUtil.isEmpty(extras)) {
- try {
- JSONObject extraJson = new JSONObject(extras);
- if (extraJson.length() > 0) {
- msgIntent.putExtra(JiGuangPushMainActivity.KEY_EXTRAS, extras);
- }
- } catch (JSONException e) {
-
- }
-
- }
- LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
- }
- }
+ private static final String TAG = JiGuangApplication.TAG;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ try {
+ Bundle bundle = intent.getExtras();
+ Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
+
+ if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
+ String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
+ Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
+ //send the Registration Id to your server...
+
+ } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
+ Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
+ processCustomMessage(context, bundle);
+
+ } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
+ Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
+ int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
+ Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
+
+ } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
+ Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
+
+ //打开自定义的Activity
+ Intent i = new Intent(context, TestActivity.class);
+ i.putExtras(bundle);
+ //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ context.startActivity(i);
+
+ } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
+ boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
+ Logger.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
+ } else {
+ Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
+ }
+ } catch (Exception e) {
+
+ }
+
+ }
+
+ // 打印所有的 intent extra 数据
+ private static String printBundle(Bundle bundle) {
+ StringBuilder sb = new StringBuilder();
+ for (String key : bundle.keySet()) {
+ if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
+ sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
+ } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
+ sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
+ } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
+ if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
+ Logger.i(TAG, "This message has no Extra data");
+ continue;
+ }
+
+ try {
+ JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
+ Iterator it = json.keys();
+
+ while (it.hasNext()) {
+ String myKey = it.next();
+ sb.append("\nkey:" + key + ", value: [" +
+ myKey + " - " + json.optString(myKey) + "]");
+ }
+ } catch (JSONException e) {
+ Logger.e(TAG, "Get message extra JSON error!");
+ }
+
+ } else {
+ sb.append("\nkey:" + key + ", value:" + bundle.get(key));
+ }
+ }
+ return sb.toString();
+ }
+
+ //send msg to MainActivity
+ private void processCustomMessage(Context context, Bundle bundle) {
+ if (JiGuangPushMainActivity.isForeground) {
+ String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
+ String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
+ Intent msgIntent = new Intent(JiGuangPushMainActivity.MESSAGE_RECEIVED_ACTION);
+ msgIntent.putExtra(JiGuangPushMainActivity.KEY_MESSAGE, message);
+ if (!ExampleUtil.isEmpty(extras)) {
+ try {
+ JSONObject extraJson = new JSONObject(extras);
+ if (extraJson.length() > 0) {
+ msgIntent.putExtra(JiGuangPushMainActivity.KEY_EXTRAS, extras);
+ }
+ } catch (JSONException e) {
+
+ }
+
+ }
+ LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
+ }
+ }
}
diff --git a/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/PushSetActivity.java b/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/PushSetActivity.java
index b809dd8b049ebcf1a8ba6c226a2d7d007be208c2..82bcc4095384efb58327ceba6e97c5c56d33d52c 100644
--- a/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/PushSetActivity.java
+++ b/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/PushSetActivity.java
@@ -12,8 +12,6 @@ import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;
-import com.wzq.jiguangpush.R;
-
import java.util.LinkedHashSet;
import java.util.Set;
@@ -25,12 +23,12 @@ import cn.jpush.android.api.TagAliasCallback;
public class PushSetActivity extends Activity implements OnClickListener {
- private static final String TAG = "JIGUANG-Example";
+ private static final String TAG = JiGuangApplication.TAG;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- setContentView(R.layout.push_set_dialog);
+ setContentView(R.layout.jiguang_push_set_dialog);
initListener();
}
@@ -86,7 +84,7 @@ public class PushSetActivity extends Activity implements OnClickListener {
TagAliasCallback tagAlias = new TagAliasCallback() {
@Override
public void gotResult(int responseCode, String alias, Set tags) {
- Log.e(TAG,"responseCode:"+responseCode+",alias:"+alias+",tags:"+tags);
+ Log.e(TAG, "responseCode:" + responseCode + ",alias:" + alias + ",tags:" + tags);
}
};
@@ -108,7 +106,7 @@ public class PushSetActivity extends Activity implements OnClickListener {
* 设置通知栏样式 - 定义通知栏Layout
*/
private void setStyleCustom() {
- CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(PushSetActivity.this, R.layout.customer_notitfication_layout, R.id.icon, R.id.title, R.id.text);
+ CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(PushSetActivity.this, R.layout.jiguang_customer_notitfication_layout, R.id.icon, R.id.title, R.id.text);
builder.layoutIconDrawable = R.drawable.ic_launcher;
builder.developerArg0 = "developerArg2";
JPushInterface.setPushNotificationBuilder(2, builder);
@@ -140,7 +138,7 @@ public class PushSetActivity extends Activity implements OnClickListener {
/**
* 处理tag/alias相关操作的点击
- * */
+ */
public void onTagAliasAction(View view) {
Set tags = null;
String alias = null;
@@ -205,16 +203,16 @@ public class PushSetActivity extends Activity implements OnClickListener {
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
tagAliasBean.action = action;
TagAliasOperatorHelper.sequence++;
- if(isAliasAction){
+ if (isAliasAction) {
tagAliasBean.alias = alias;
- }else{
+ } else {
tagAliasBean.tags = tags;
}
tagAliasBean.isAliasAction = isAliasAction;
- TagAliasOperatorHelper.getInstance().handleAction(getApplicationContext(), TagAliasOperatorHelper.sequence,tagAliasBean);
+ TagAliasOperatorHelper.getInstance().handleAction(getApplicationContext(), TagAliasOperatorHelper.sequence, tagAliasBean);
}
- private void handleSetMobileNumber(){
+ private void handleSetMobileNumber() {
EditText mobileEdit = (EditText) findViewById(R.id.et_mobilenumber);
String mobileNumber = mobileEdit.getText().toString().trim();
if (TextUtils.isEmpty(mobileNumber)) {
@@ -225,12 +223,13 @@ public class PushSetActivity extends Activity implements OnClickListener {
return;
}
TagAliasOperatorHelper.sequence++;
- TagAliasOperatorHelper.getInstance().handleAction(getApplicationContext(), TagAliasOperatorHelper.sequence,mobileNumber);
+ TagAliasOperatorHelper.getInstance().handleAction(getApplicationContext(), TagAliasOperatorHelper.sequence, mobileNumber);
}
+
/**
* 获取输入的alias
- * */
- private String getInPutAlias(){
+ */
+ private String getInPutAlias() {
EditText aliasEdit = (EditText) findViewById(R.id.et_alias);
String alias = aliasEdit.getText().toString().trim();
if (TextUtils.isEmpty(alias)) {
@@ -243,10 +242,11 @@ public class PushSetActivity extends Activity implements OnClickListener {
}
return alias;
}
+
/**
* 获取输入的tags
- * */
- private Set getInPutTags(){
+ */
+ private Set getInPutTags() {
EditText tagEdit = (EditText) findViewById(R.id.et_tag);
String tag = tagEdit.getText().toString().trim();
// 检查 tag 的有效性
@@ -265,7 +265,7 @@ public class PushSetActivity extends Activity implements OnClickListener {
}
tagSet.add(sTagItme);
}
- if(tagSet.isEmpty()){
+ if (tagSet.isEmpty()) {
Toast.makeText(getApplicationContext(), R.string.error_tag_empty, Toast.LENGTH_SHORT).show();
return null;
}
diff --git a/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/SettingActivity.java b/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/SettingActivity.java
index b953fc552179bf417a5c8a40083d2c83622fe2b8..6fa7179fa011e56238b8ba222aa450262187478a 100644
--- a/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/SettingActivity.java
+++ b/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/SettingActivity.java
@@ -14,183 +14,180 @@ import android.widget.CheckBox;
import android.widget.TimePicker;
import android.widget.Toast;
-import com.wzq.jiguangpush.R;
-
import java.util.HashSet;
import java.util.Set;
import cn.jpush.android.api.JPushInterface;
public class SettingActivity extends Activity implements OnClickListener {
- TimePicker startTime;
- TimePicker endTime;
- CheckBox mMonday ;
- CheckBox mTuesday ;
- CheckBox mWednesday;
- CheckBox mThursday;
- CheckBox mFriday ;
- CheckBox mSaturday;
- CheckBox mSunday ;
- Button mSetTime;
- SharedPreferences mSettings;
- Editor mEditor;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.set_push_time);
- init();
- initListener();
- }
-
- @Override
+ TimePicker startTime;
+ TimePicker endTime;
+ CheckBox mMonday;
+ CheckBox mTuesday;
+ CheckBox mWednesday;
+ CheckBox mThursday;
+ CheckBox mFriday;
+ CheckBox mSaturday;
+ CheckBox mSunday;
+ Button mSetTime;
+ SharedPreferences mSettings;
+ Editor mEditor;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ setContentView(R.layout.jiguang_set_push_time);
+ init();
+ initListener();
+ }
+
+ @Override
public void onStart() {
- super.onStart();
- initData();
- }
-
- private void init(){
- startTime = (TimePicker) findViewById(R.id.start_time);
- endTime = (TimePicker) findViewById(R.id.end_time);
- startTime.setIs24HourView(DateFormat.is24HourFormat(this));
- endTime.setIs24HourView(DateFormat.is24HourFormat(this));
- mSetTime = (Button)findViewById(R.id.bu_setTime);
- mMonday = (CheckBox)findViewById(R.id.cb_monday);
- mTuesday = (CheckBox)findViewById(R.id.cb_tuesday);
- mWednesday = (CheckBox)findViewById(R.id.cb_wednesday);
- mThursday = (CheckBox)findViewById(R.id.cb_thursday);
- mFriday = (CheckBox)findViewById(R.id.cb_friday);
- mSaturday = (CheckBox)findViewById(R.id.cb_saturday);
- mSunday = (CheckBox)findViewById(R.id.cb_sunday);
- }
-
- private void initListener(){
- mSetTime.setOnClickListener(this);
+ super.onStart();
+ initData();
+ }
+
+ private void init() {
+ startTime = (TimePicker) findViewById(R.id.start_time);
+ endTime = (TimePicker) findViewById(R.id.end_time);
+ startTime.setIs24HourView(DateFormat.is24HourFormat(this));
+ endTime.setIs24HourView(DateFormat.is24HourFormat(this));
+ mSetTime = (Button) findViewById(R.id.bu_setTime);
+ mMonday = (CheckBox) findViewById(R.id.cb_monday);
+ mTuesday = (CheckBox) findViewById(R.id.cb_tuesday);
+ mWednesday = (CheckBox) findViewById(R.id.cb_wednesday);
+ mThursday = (CheckBox) findViewById(R.id.cb_thursday);
+ mFriday = (CheckBox) findViewById(R.id.cb_friday);
+ mSaturday = (CheckBox) findViewById(R.id.cb_saturday);
+ mSunday = (CheckBox) findViewById(R.id.cb_sunday);
+ }
+
+ private void initListener() {
+ mSetTime.setOnClickListener(this);
+ }
+
+ private void initData() {
+ mSettings = getSharedPreferences(ExampleUtil.PREFS_NAME, MODE_PRIVATE);
+ String days = mSettings.getString(ExampleUtil.PREFS_DAYS, "");
+ if (!TextUtils.isEmpty(days)) {
+ initAllWeek(false);
+ String[] sArray = days.split(",");
+ for (String day : sArray) {
+ setWeek(day);
+ }
+ } else {
+ initAllWeek(true);
+ }
+
+ int startTimeStr = mSettings.getInt(ExampleUtil.PREFS_START_TIME, 0);
+ startTime.setCurrentHour(startTimeStr);
+ int endTimeStr = mSettings.getInt(ExampleUtil.PREFS_END_TIME, 23);
+ endTime.setCurrentHour(endTimeStr);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.bu_setTime) {
+ v.requestFocus();
+ v.requestFocusFromTouch();
+ setPushTime();
+ }
+ }
+
+ /**
+ * 设置允许接收通知时间
+ */
+ private void setPushTime() {
+ int startime = startTime.getCurrentHour();
+ int endtime = endTime.getCurrentHour();
+ if (startime > endtime) {
+ Toast.makeText(SettingActivity.this, "开始时间不能大于结束时间", Toast.LENGTH_SHORT).show();
+ return;
+ }
+ StringBuffer daysSB = new StringBuffer();
+ Set days = new HashSet();
+ if (mSunday.isChecked()) {
+ days.add(0);
+ daysSB.append("0,");
+ }
+ if (mMonday.isChecked()) {
+ days.add(1);
+ daysSB.append("1,");
+ }
+ if (mTuesday.isChecked()) {
+ days.add(2);
+ daysSB.append("2,");
+ }
+ if (mWednesday.isChecked()) {
+ days.add(3);
+ daysSB.append("3,");
+ }
+ if (mThursday.isChecked()) {
+ days.add(4);
+ daysSB.append("4,");
+ }
+ if (mFriday.isChecked()) {
+ days.add(5);
+ daysSB.append("5,");
+ }
+ if (mSaturday.isChecked()) {
+ days.add(6);
+ daysSB.append("6,");
+ }
+
+ //调用JPush api设置Push时间
+ JPushInterface.setPushTime(getApplicationContext(), days, startime, endtime);
+
+ mEditor = mSettings.edit();
+ mEditor.putString(ExampleUtil.PREFS_DAYS, daysSB.toString());
+ mEditor.putInt(ExampleUtil.PREFS_START_TIME, startime);
+ mEditor.putInt(ExampleUtil.PREFS_END_TIME, endtime);
+ mEditor.commit();
+ Toast.makeText(SettingActivity.this, R.string.setting_su, Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ finish();
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+ private void setWeek(String day) {
+ int dayId = Integer.valueOf(day);
+ switch (dayId) {
+ case 0:
+ mSunday.setChecked(true);
+ break;
+ case 1:
+ mMonday.setChecked(true);
+ break;
+ case 2:
+ mTuesday.setChecked(true);
+ break;
+ case 3:
+ mWednesday.setChecked(true);
+ break;
+ case 4:
+ mThursday.setChecked(true);
+ break;
+ case 5:
+ mFriday.setChecked(true);
+ break;
+ case 6:
+ mSaturday.setChecked(true);
+ break;
+ }
+ }
+
+ private void initAllWeek(boolean isChecked) {
+ mSunday.setChecked(isChecked);
+ mMonday.setChecked(isChecked);
+ mTuesday.setChecked(isChecked);
+ mWednesday.setChecked(isChecked);
+ mThursday.setChecked(isChecked);
+ mFriday.setChecked(isChecked);
+ mSaturday.setChecked(isChecked);
}
-
- private void initData(){
- mSettings = getSharedPreferences(ExampleUtil.PREFS_NAME, MODE_PRIVATE);
- String days = mSettings.getString(ExampleUtil.PREFS_DAYS, "");
- if (!TextUtils.isEmpty(days)) {
- initAllWeek(false);
- String[] sArray = days.split(",");
- for (String day : sArray) {
- setWeek(day);
- }
- } else {
- initAllWeek(true);
- }
-
- int startTimeStr = mSettings.getInt(ExampleUtil.PREFS_START_TIME, 0);
- startTime.setCurrentHour(startTimeStr);
- int endTimeStr = mSettings.getInt(ExampleUtil.PREFS_END_TIME, 23);
- endTime.setCurrentHour(endTimeStr);
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.bu_setTime) {
- v.requestFocus();
- v.requestFocusFromTouch();
- setPushTime();
- }
- }
-
- /**
- *设置允许接收通知时间
- */
- private void setPushTime(){
- int startime = startTime.getCurrentHour();
- int endtime = endTime.getCurrentHour();
- if (startime > endtime) {
- Toast.makeText(SettingActivity.this, "开始时间不能大于结束时间", Toast.LENGTH_SHORT).show();
- return;
- }
- StringBuffer daysSB = new StringBuffer();
- Set days = new HashSet();
- if (mSunday.isChecked()) {
- days.add(0);
- daysSB.append("0,");
- }
- if (mMonday.isChecked()) {
- days.add(1);
- daysSB.append("1,");
- }
- if (mTuesday.isChecked()) {
- days.add(2);
- daysSB.append("2,");
- }
- if (mWednesday.isChecked()) {
- days.add(3);
- daysSB.append("3,");
- }
- if (mThursday.isChecked()) {
- days.add(4);
- daysSB.append("4,");
- }
- if (mFriday.isChecked()) {
- days.add(5);
- daysSB.append("5,");
- }
- if (mSaturday.isChecked()) {
- days.add(6);
- daysSB.append("6,");
- }
-
-
- //调用JPush api设置Push时间
- JPushInterface.setPushTime(getApplicationContext(), days, startime, endtime);
-
- mEditor = mSettings.edit();
- mEditor.putString(ExampleUtil.PREFS_DAYS, daysSB.toString());
- mEditor.putInt(ExampleUtil.PREFS_START_TIME, startime);
- mEditor.putInt(ExampleUtil.PREFS_END_TIME, endtime);
- mEditor.commit();
- Toast.makeText(SettingActivity.this, R.string.setting_su, Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK){
- finish();
- }
- return super.onKeyDown(keyCode, event);
- }
-
- private void setWeek(String day){
- int dayId = Integer.valueOf(day);
- switch (dayId) {
- case 0:
- mSunday.setChecked(true);
- break;
- case 1:
- mMonday.setChecked(true);
- break;
- case 2:
- mTuesday.setChecked(true);
- break;
- case 3:
- mWednesday.setChecked(true);
- break;
- case 4:
- mThursday.setChecked(true);
- break;
- case 5:
- mFriday.setChecked(true);
- break;
- case 6:
- mSaturday.setChecked(true);
- break;
- }
- }
-
- private void initAllWeek(boolean isChecked) {
- mSunday.setChecked(isChecked);
- mMonday.setChecked(isChecked);
- mTuesday.setChecked(isChecked);
- mWednesday.setChecked(isChecked);
- mThursday.setChecked(isChecked);
- mFriday.setChecked(isChecked);
- mSaturday.setChecked(isChecked);
- }
}
\ No newline at end of file
diff --git a/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/TagAliasOperatorHelper.java b/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/TagAliasOperatorHelper.java
index 436b6bc99a0832a5665af56ee0e0a7f800bbb01e..417fd5c5b0cc3678a8b544be124cb2375ebce96d 100644
--- a/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/TagAliasOperatorHelper.java
+++ b/pushbase/jiguangpush/src/main/java/com/wzq/jiguangpush/TagAliasOperatorHelper.java
@@ -15,7 +15,7 @@ import cn.jpush.android.api.JPushMessage;
* 处理tagalias相关的逻辑
*/
public class TagAliasOperatorHelper {
- private static final String TAG = "JIGUANG-TagAliasHelper";
+ private static final String TAG = JiGuangApplication.TAG;
public static int sequence = 1;
/**
* 增加
@@ -142,10 +142,10 @@ public class TagAliasOperatorHelper {
JPushInterface.getAlias(context, sequence);
break;
case ACTION_DELETE:
- JPushInterface.deleteAlias(context, sequence);
+ JPushInterface.deleteAlias(context, 1);
break;
case ACTION_SET:
- JPushInterface.setAlias(context, sequence, tagAliasBean.alias);
+ JPushInterface.setAlias(context, 1, tagAliasBean.alias);
break;
default:
Logger.w(TAG, "unsupport alias action type");
diff --git a/pushbase/jiguangpush/src/main/res/layout/customer_notitfication_layout.xml b/pushbase/jiguangpush/src/main/res/layout/jiguang_customer_notitfication_layout.xml
similarity index 100%
rename from pushbase/jiguangpush/src/main/res/layout/customer_notitfication_layout.xml
rename to pushbase/jiguangpush/src/main/res/layout/jiguang_customer_notitfication_layout.xml
diff --git a/pushbase/jiguangpush/src/main/res/layout/customer_notitfication_layout_one.xml b/pushbase/jiguangpush/src/main/res/layout/jiguang_customer_notitfication_layout_one.xml
similarity index 100%
rename from pushbase/jiguangpush/src/main/res/layout/customer_notitfication_layout_one.xml
rename to pushbase/jiguangpush/src/main/res/layout/jiguang_customer_notitfication_layout_one.xml
diff --git a/pushbase/jiguangpush/src/main/res/layout/jpush_inapp_banner.xml b/pushbase/jiguangpush/src/main/res/layout/jiguang_inapp_banner.xml
similarity index 100%
rename from pushbase/jiguangpush/src/main/res/layout/jpush_inapp_banner.xml
rename to pushbase/jiguangpush/src/main/res/layout/jiguang_inapp_banner.xml
diff --git a/pushbase/jiguangpush/src/main/res/layout/main.xml b/pushbase/jiguangpush/src/main/res/layout/jiguang_main.xml
similarity index 80%
rename from pushbase/jiguangpush/src/main/res/layout/main.xml
rename to pushbase/jiguangpush/src/main/res/layout/jiguang_main.xml
index fff61b4f97bf751ea3ebead470beb66d912d3a63..4537f54837a81419e9ea59906a8f753372b3c1ce 100644
--- a/pushbase/jiguangpush/src/main/res/layout/main.xml
+++ b/pushbase/jiguangpush/src/main/res/layout/jiguang_main.xml
@@ -3,6 +3,7 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tiledstripes">
+
+ android:layout_marginTop="8dip"
+ android:textColor="@color/colorAccent"
+ android:textIsSelectable="true"
+ android:textSize="22dp" />
+ android:layout_marginTop="8dip"
+ android:textIsSelectable="true" />
+ android:layout_marginTop="8dip"
+ android:textIsSelectable="true" />
+ android:layout_marginTop="8dip"
+ android:gravity="center"
+ android:text="IMME Code"
+ android:textColor="@color/colorAccent"
+ android:textIsSelectable="true"
+ android:textSize="22dp" />
+ android:layout_marginTop="8dip"
+ android:textIsSelectable="true" />
+ android:layout_marginTop="8dip"
+ android:textIsSelectable="true" />
-