@@ -43,7 +43,7 @@ import ai.pai.client.utils.Constants; |
||
43 | 43 |
import ai.pai.client.utils.PhotoLoader; |
44 | 44 |
import ai.pai.client.utils.UrlContainer; |
45 | 45 |
import ai.pai.client.views.GroupSelectPopup; |
46 |
-import ai.pai.client.views.SignOutConfirmPopup; |
|
46 |
+import ai.pai.client.views.PersonInfoPopup; |
|
47 | 47 |
|
48 | 48 |
public class MainActivity extends AppCompatActivity |
49 | 49 |
implements NavigationView.OnNavigationItemSelectedListener, View.OnClickListener, GroupService.GroupServiceListener,IndicatorViewPager.OnIndicatorPageChangeListener { |
@@ -54,7 +54,8 @@ public class MainActivity extends AppCompatActivity |
||
54 | 54 |
private GroupServiceConnection serviceConnection; |
55 | 55 |
private static final int JOIN_REQUEST_CODE = 3002; |
56 | 56 |
private long exitTime; |
57 |
- |
|
57 |
+ private String guideId; |
|
58 |
+ private PersonInfoPopup personInfoPopup; |
|
58 | 59 |
@Override |
59 | 60 |
protected void onCreate(Bundle savedInstanceState) { |
60 | 61 |
super.onCreate(savedInstanceState); |
@@ -189,9 +190,40 @@ public class MainActivity extends AppCompatActivity |
||
189 | 190 |
finish(); |
190 | 191 |
} |
191 | 192 |
break; |
193 |
+ case R.id.btn_info_confirm: |
|
194 |
+ joinTourGuideGroup(guideId,personInfoPopup.getInputName(),personInfoPopup.getInputPhone()); |
|
195 |
+ personInfoPopup.dismiss(); |
|
196 |
+ break; |
|
192 | 197 |
} |
193 | 198 |
} |
194 | 199 |
|
200 |
+ private void joinTourGuideGroup(String guideId,String realName,String phone){ |
|
201 |
+ if(phone==null||phone.length()!=11){ |
|
202 |
+ return; |
|
203 |
+ } |
|
204 |
+ Preferences.getInstance(this).setUserPhone(phone); |
|
205 |
+ if(TextUtils.isEmpty(realName)){ |
|
206 |
+ realName = Preferences.getInstance(this).getNickName(); |
|
207 |
+ }else{ |
|
208 |
+ Preferences.getInstance(this).setUserName(realName); |
|
209 |
+ } |
|
210 |
+ Intent intent = new Intent(this, GroupService.class); |
|
211 |
+ if (!isBound) { |
|
212 |
+ serviceConnection = new GroupServiceConnection(this); |
|
213 |
+ bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); |
|
214 |
+ isBound = true; |
|
215 |
+ } |
|
216 |
+ Bundle bundle = new Bundle(); |
|
217 |
+ bundle.putInt("command", GroupService.GroupCommand.COMMAND_JOIN_GUIDE_GROUP); |
|
218 |
+ bundle.putString("admin_id", guideId); |
|
219 |
+ bundle.putString("name", realName); |
|
220 |
+ bundle.putString("phone",phone); |
|
221 |
+ intent.putExtras(bundle); |
|
222 |
+ startService(intent); |
|
223 |
+ Toast.makeText(this, R.string.group_join_tip, Toast.LENGTH_SHORT).show(); |
|
224 |
+ } |
|
225 |
+ |
|
226 |
+ |
|
195 | 227 |
private IndicatorViewPager.IndicatorPagerAdapter adapter = new IndicatorViewPager |
196 | 228 |
.IndicatorFragmentPagerAdapter(getSupportFragmentManager()) { |
197 | 229 |
|
@@ -247,8 +279,16 @@ public class MainActivity extends AppCompatActivity |
||
247 | 279 |
} |
248 | 280 |
LogHelper.d("czy","qr scan result = "+urlInfo); |
249 | 281 |
boolean isFromGuideApp = urlInfo.startsWith(UrlContainer.QR_GUIDE_APP_GROUP_URL); |
250 |
- //TODO 导游群处理 |
|
251 |
- |
|
282 |
+ if(isFromGuideApp){ |
|
283 |
+ guideId = urlInfo.substring(urlInfo.lastIndexOf("/") + 1); |
|
284 |
+ if(!TextUtils.isEmpty(Preferences.getInstance(this).getUserPhone())){ |
|
285 |
+ joinTourGuideGroup(guideId,Preferences.getInstance(this).getUserName(),Preferences.getInstance(this).getUserPhone()); |
|
286 |
+ }else{ |
|
287 |
+ personInfoPopup = new PersonInfoPopup(this,this); |
|
288 |
+ personInfoPopup.showPopupWindow(); |
|
289 |
+ } |
|
290 |
+ return; |
|
291 |
+ } |
|
252 | 292 |
boolean isFromAPP = urlInfo.startsWith(UrlContainer.QR_APP_GROUP_URL); |
253 | 293 |
String groupId = urlInfo.substring(urlInfo.lastIndexOf("/") + 1); |
254 | 294 |
if (requestCode == JOIN_REQUEST_CODE) { |
@@ -43,6 +43,14 @@ public class Preferences { |
||
43 | 43 |
return mPrefs.getString("userName",NullStr); |
44 | 44 |
} |
45 | 45 |
|
46 |
+ public void setUserPhone(String phone){ |
|
47 |
+ mPrefs.edit().putString("phone",phone).commit(); |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+ public String getUserPhone(){ |
|
51 |
+ return mPrefs.getString("phone",NullStr); |
|
52 |
+ } |
|
53 |
+ |
|
46 | 54 |
public void setNickName(String nickName){ |
47 | 55 |
mPrefs.edit().putString("nickName",nickName).commit(); |
48 | 56 |
} |
@@ -40,6 +40,7 @@ public class GroupService extends Service implements UploadTask.OnPhotoUploadLis |
||
40 | 40 |
int COMMAND_DELETE_GROUP_MEMBER = 8; |
41 | 41 |
int COMMAND_QUIT_GROUP = 9; |
42 | 42 |
int COMMAND_REFRESH_PHOTOS = 10; |
43 |
+ int COMMAND_JOIN_GUIDE_GROUP = 11; |
|
43 | 44 |
} |
44 | 45 |
|
45 | 46 |
private Context context; |
@@ -15,13 +15,15 @@ public class UrlContainer { |
||
15 | 15 |
|
16 | 16 |
public static final String QR_APP_GROUP_URL = "https://pai.ai/g/"; |
17 | 17 |
|
18 |
- //TODO |
|
19 |
- public static final String QR_GUIDE_APP_GROUP_URL= "https://pai.ai/guide/"; |
|
18 |
+ public static final String QR_GUIDE_APP_GROUP_URL= "https://pai.ai/tgu/"; |
|
19 |
+ |
|
20 | 20 |
|
21 | 21 |
public static final String APP_GROUP_JOIN_URL = HOST_URL+"g/join"; |
22 | 22 |
|
23 | 23 |
public static final String SESSION_GROUP_JOIN_URL = HOST_URL+"s/join"; |
24 | 24 |
|
25 |
+ public static final String GUIDE_GROUP_JOIN_URL = HOST_URL+"tgu/join"; |
|
26 |
+ |
|
25 | 27 |
public static final String GROUP_CREATE_URL = HOST_URL+"g/create"; |
26 | 28 |
|
27 | 29 |
public static final String GROUP_DETAIL_URL = HOST_URL+"g/detail"; |
@@ -0,0 +1,108 @@ |
||
1 |
+package ai.pai.client.views; |
|
2 |
+ |
|
3 |
+import android.animation.Animator; |
|
4 |
+import android.animation.AnimatorSet; |
|
5 |
+import android.animation.ObjectAnimator; |
|
6 |
+import android.app.Activity; |
|
7 |
+import android.text.Editable; |
|
8 |
+import android.text.TextWatcher; |
|
9 |
+import android.view.LayoutInflater; |
|
10 |
+import android.view.View; |
|
11 |
+import android.view.animation.Animation; |
|
12 |
+import android.widget.Button; |
|
13 |
+import android.widget.EditText; |
|
14 |
+ |
|
15 |
+import com.android.views.popup.BasePopupWindow; |
|
16 |
+ |
|
17 |
+import ai.pai.client.R; |
|
18 |
+ |
|
19 |
+public class PersonInfoPopup extends BasePopupWindow { |
|
20 |
+ |
|
21 |
+ private Button mJoinBtn; |
|
22 |
+ private EditText mNameEdit; |
|
23 |
+ private EditText mPhoneEdit; |
|
24 |
+ |
|
25 |
+ public PersonInfoPopup(Activity context, View.OnClickListener listener) { |
|
26 |
+ super(context); |
|
27 |
+ mJoinBtn = (Button) mPopupView.findViewById(R.id.btn_info_confirm); |
|
28 |
+ mNameEdit = (EditText) mPopupView.findViewById(R.id.et_user_name); |
|
29 |
+ mPhoneEdit = (EditText)mPopupView.findViewById(R.id.et_user_phone); |
|
30 |
+ |
|
31 |
+ mPhoneEdit.addTextChangedListener(new TextWatcher() { |
|
32 |
+ @Override |
|
33 |
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
|
34 |
+ |
|
35 |
+ } |
|
36 |
+ |
|
37 |
+ @Override |
|
38 |
+ public void onTextChanged(CharSequence s, int start, int before, int count) { |
|
39 |
+ |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ @Override |
|
43 |
+ public void afterTextChanged(Editable s) { |
|
44 |
+ mJoinBtn.setEnabled(s.toString().length()==11); |
|
45 |
+ } |
|
46 |
+ }); |
|
47 |
+ setAutoShowInputMethod(true); |
|
48 |
+ mJoinBtn.setOnClickListener(listener); |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ public String getInputName(){ |
|
52 |
+ if(mNameEdit.getText()!=null){ |
|
53 |
+ return mNameEdit.getText().toString(); |
|
54 |
+ } |
|
55 |
+ return null; |
|
56 |
+ } |
|
57 |
+ |
|
58 |
+ public String getInputPhone(){ |
|
59 |
+ if(mPhoneEdit.getText()!=null){ |
|
60 |
+ return mPhoneEdit.getText().toString(); |
|
61 |
+ } |
|
62 |
+ return null; |
|
63 |
+ } |
|
64 |
+ |
|
65 |
+ @Override |
|
66 |
+ protected Animation getShowAnimation() { |
|
67 |
+ return getDefaultScaleAnimation(); |
|
68 |
+ } |
|
69 |
+ |
|
70 |
+ @Override |
|
71 |
+ public Animator getShowAnimator() { |
|
72 |
+ return getDefaultSlideFromBottomAnimationSet(); |
|
73 |
+ } |
|
74 |
+ |
|
75 |
+ @Override |
|
76 |
+ public View getInputView() { |
|
77 |
+ return mNameEdit; |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ @Override |
|
81 |
+ protected View getClickToDismissView() { |
|
82 |
+ return mPopupView; |
|
83 |
+ } |
|
84 |
+ |
|
85 |
+ @Override |
|
86 |
+ public View getPopupView() { |
|
87 |
+ return LayoutInflater.from(mContext).inflate(R.layout.popup_comment_input,null); |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ @Override |
|
91 |
+ public View getAnimaView() { |
|
92 |
+ return mPopupView.findViewById(R.id.popup_anima); |
|
93 |
+ } |
|
94 |
+ |
|
95 |
+ @Override |
|
96 |
+ public Animator getExitAnimator() { |
|
97 |
+ AnimatorSet set = null; |
|
98 |
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { |
|
99 |
+ set = new AnimatorSet(); |
|
100 |
+ if (getAnimaView() != null) { |
|
101 |
+ set.playTogether( |
|
102 |
+ ObjectAnimator.ofFloat(getAnimaView(), "translationY", 0, 250).setDuration(400), |
|
103 |
+ ObjectAnimator.ofFloat(getAnimaView(), "alpha", 1, 0.4f).setDuration(250 * 3 / 2)); |
|
104 |
+ } |
|
105 |
+ } |
|
106 |
+ return set; |
|
107 |
+ } |
|
108 |
+} |
@@ -0,0 +1,58 @@ |
||
1 |
+<?xml version="1.0" encoding="utf-8"?> |
|
2 |
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
+ android:layout_width="match_parent" |
|
4 |
+ android:layout_height="match_parent" |
|
5 |
+ android:background="@color/popup_bg"> |
|
6 |
+ |
|
7 |
+ <LinearLayout |
|
8 |
+ android:id="@+id/popup_anima" |
|
9 |
+ android:layout_width="match_parent" |
|
10 |
+ android:layout_height="wrap_content" |
|
11 |
+ android:layout_margin="20dp" |
|
12 |
+ android:layout_centerInParent="true" |
|
13 |
+ android:orientation="vertical" |
|
14 |
+ android:background="@color/white" |
|
15 |
+ android:padding="6dp"> |
|
16 |
+ |
|
17 |
+ |
|
18 |
+ <EditText |
|
19 |
+ android:id="@+id/et_user_name" |
|
20 |
+ android:layout_width="match_parent" |
|
21 |
+ android:textSize="16sp" |
|
22 |
+ android:textColorHint="@color/grey" |
|
23 |
+ android:background="@drawable/round_edittext" |
|
24 |
+ android:textColor="@color/dark_grey" |
|
25 |
+ android:hint="@string/guide_app_input_name" |
|
26 |
+ android:paddingLeft="12dp" |
|
27 |
+ android:gravity="center_vertical" |
|
28 |
+ android:layout_height="40dp" /> |
|
29 |
+ |
|
30 |
+ <EditText |
|
31 |
+ android:id="@+id/et_user_phone" |
|
32 |
+ android:layout_width="match_parent" |
|
33 |
+ android:textSize="16sp" |
|
34 |
+ android:textColorHint="@color/grey" |
|
35 |
+ android:layout_marginTop="12dp" |
|
36 |
+ android:background="@drawable/round_edittext" |
|
37 |
+ android:textColor="@color/dark_grey" |
|
38 |
+ android:hint="@string/guide_app_input_phone" |
|
39 |
+ android:paddingLeft="12dp" |
|
40 |
+ android:gravity="center_vertical" |
|
41 |
+ android:layout_height="40dp" /> |
|
42 |
+ |
|
43 |
+ <Button |
|
44 |
+ android:id="@+id/btn_info_confirm" |
|
45 |
+ android:layout_width="match_parent" |
|
46 |
+ android:layout_height="40dp" |
|
47 |
+ android:textColor="@color/white" |
|
48 |
+ android:layout_margin="12dp" |
|
49 |
+ android:paddingRight="10dp" |
|
50 |
+ android:paddingLeft="10dp" |
|
51 |
+ android:textSize="16sp" |
|
52 |
+ android:enabled="false" |
|
53 |
+ android:background="@drawable/send_btn_bg_selector" |
|
54 |
+ android:text="@string/guide_app_join_tour"/> |
|
55 |
+ |
|
56 |
+ </LinearLayout> |
|
57 |
+ |
|
58 |
+</RelativeLayout> |
@@ -238,4 +238,10 @@ |
||
238 | 238 |
<string name="no_orders_found_tip">暂无您的订单信息</string> |
239 | 239 |
|
240 | 240 |
<string name="no_more_content">暂时没有更多啦</string> |
241 |
+ |
|
242 |
+ <string name="guide_app_input_name">请输入姓名以便导游更好地服务</string> |
|
243 |
+ |
|
244 |
+ <string name="guide_app_input_phone">请输入电话以便导游途中联系</string> |
|
245 |
+ |
|
246 |
+ <string name="guide_app_join_tour">加入旅行团</string> |
|
241 | 247 |
</resources> |