Commit 383e85498497b7379255204f2c537d0c24500d71

Authored by chudinhbka@gmail.com
1 parent 0c1f9bf911
Exists in master and in 1 other branch development

update handle UI

Showing 6 changed files with 66 additions and 19 deletions Side-by-side Diff

... ... @@ -3,8 +3,6 @@
3 3 <component name="ProjectModuleManager">
4 4 <modules>
5 5 <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
6   - <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
7   - <module fileurl="file://$PROJECT_DIR$/lifelog_android.iml" filepath="$PROJECT_DIR$/lifelog_android.iml" />
8 6 <module fileurl="file://$PROJECT_DIR$/lifelog_android.iml" filepath="$PROJECT_DIR$/lifelog_android.iml" />
9 7 <module fileurl="file://$PROJECT_DIR$/lifelogpedometer.iml" filepath="$PROJECT_DIR$/lifelogpedometer.iml" />
10 8 </modules>
app/src/main/java/com/dinhcv/lifelogpedometer/activity/PedometerActivity.java
... ... @@ -10,6 +10,7 @@
10 10 import android.support.v4.app.FragmentPagerAdapter;
11 11 import android.support.v4.content.PermissionChecker;
12 12 import android.support.v4.view.ViewPager;
  13 +import android.support.v7.widget.PopupMenu;
13 14 import android.support.v7.widget.Toolbar;
14 15 import android.view.Gravity;
15 16 import android.view.MenuItem;
16 17  
... ... @@ -19,8 +20,10 @@
19 20 import android.widget.ImageView;
20 21 import android.widget.PopupWindow;
21 22 import android.widget.TextView;
  23 +import android.widget.Toast;
22 24  
23 25 import com.dinhcv.lifelogpedometer.R;
  26 +import com.dinhcv.lifelogpedometer.model.Shareprefer.Setting;
24 27 import com.dinhcv.lifelogpedometer.utils.Debug;
25 28 import com.dinhcv.lifelogpedometer.utils.Utils;
26 29  
... ... @@ -114,6 +117,48 @@
114 117 }
115 118 }
116 119 });
  120 +
  121 + imvMenu.setOnClickListener(new View.OnClickListener() {
  122 + @Override
  123 + public void onClick(View v) {
  124 + //Creating the instance of PopupMenu
  125 + PopupMenu popup = new PopupMenu(PedometerActivity.this, imvMenu);
  126 + //Inflating the Popup using xml file
  127 + popup.getMenuInflater().inflate(R.menu.main, popup.getMenu());
  128 +
  129 + //registering popup with OnMenuItemClickListener
  130 + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
  131 + public boolean onMenuItemClick(MenuItem item) {
  132 + switch (item.getItemId()){
  133 + case R.id.action_setting:
  134 + Toast.makeText(
  135 + PedometerActivity.this,
  136 + "Have not spec : " + item.getTitle(),
  137 + Toast.LENGTH_SHORT
  138 + ).show();
  139 + break;
  140 + case R.id.action_profile:
  141 + Toast.makeText(
  142 + PedometerActivity.this,
  143 + "Have not spec : " + item.getTitle(),
  144 + Toast.LENGTH_SHORT
  145 + ).show();
  146 + break;
  147 + case R.id.action_logout:
  148 + logout();
  149 + break;
  150 + default:
  151 + Debug.warn("Not run here");
  152 + break;
  153 + }
  154 +
  155 + return true;
  156 + }
  157 + });
  158 +
  159 + popup.show(); //showing popup menu
  160 + }
  161 + }); //closing the setOnClickListener method
117 162 }
118 163  
119 164 private void setupTabIcons() {
... ... @@ -145,7 +190,7 @@
145 190 Window window = this.getWindow();
146 191 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
147 192 window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
148   - window.setStatusBarColor(Utils.getColorWrapper(this, R.color.white));
  193 + // window.setStatusBarColor(Utils.getColorWrapper(this, R.color.white));
149 194 }
150 195 }
151 196  
... ... @@ -294,16 +339,14 @@
294 339 }
295 340 }
296 341  
297   - private void showMenu(){
298   -// show
299   -// int[] location = new int[2];
300   -// imvMenu.getLocationOnScreen(location);
301   -// final View mView = inflater.inflate(R.layout.xxxx, null, false);
302   -// final PopupWindow popUp = new PopupWindow(mView, Width, Height, false);
303   -// popUp.setTouchable(true);
304   -// popUp.setFocusable(true);
305   -// popUp.setOutsideTouchable(true);
306   -// popUp.showAtLocation(view, Gravity.NO_GRAVITY, location[0], location[1]);
  342 + private void logout(){
  343 + // clear data
  344 + Setting.clearUserIdSharepre(PedometerActivity.this);
  345 + // go to login
  346 + Intent intent = new Intent(PedometerActivity.this, LoginActivity.class);
  347 + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  348 + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  349 + startActivity(intent);
307 350 }
308 351  
309 352 }
app/src/main/java/com/dinhcv/lifelogpedometer/activity/TopDateFragment.java
... ... @@ -295,7 +295,7 @@
295 295 private void loadUI(){
296 296 tvStep.setText(String.valueOf(mTagetInfo.getSteps()));
297 297 tvRemain.setText(String.valueOf(mTagetInfo.getStepRemain()));
298   - tvRateDone.setText(getResources().getString(R.string.percent_unit, mTagetInfo.getCompletePercent()));
  298 + tvRateDone.setText(mContext.getResources().getString(R.string.percent_unit, mTagetInfo.getCompletePercent()));
299 299  
300 300 List<NoticeInfo> infoLists = mTagetInfo.getNoticeList();
301 301 if (infoLists != null && infoLists.size() >0){
app/src/main/java/com/dinhcv/lifelogpedometer/model/Shareprefer/Setting.java
... ... @@ -93,7 +93,7 @@
93 93 return value;
94 94 }
95 95  
96   - private static void clearUserIdSharepre(Context context){
  96 + public static void clearUserIdSharepre(Context context){
97 97 SharedPreferences.Editor preferences = context.getSharedPreferences(USER_ID_SHAREPRE, Context.MODE_PRIVATE).edit();
98 98 preferences.clear();
99 99 preferences.apply();
app/src/main/res/menu/main.xml
1 1 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
2 2  
3 3 <item
4   - android:id="@+id/action_pause"
  4 + android:id="@+id/action_setting"
5 5 android:orderInCategory="100"
6   - android:title="@string/pause"/>
  6 + android:title="@string/setting"/>
7 7 <item
8   - android:id="@+id/action_settings"
  8 + android:id="@+id/action_profile"
9 9 android:orderInCategory="100"
10   - android:title="@string/settings"/>
  10 + android:title="@string/profile_change"/>
  11 +
  12 + <item
  13 + android:id="@+id/action_logout"
  14 + android:orderInCategory="100"
  15 + android:title="@string/logout"/>
11 16  
12 17 </menu>
app/src/main/res/values/strings.xml
... ... @@ -10,6 +10,7 @@
10 10 <string name="average">Average</string>
11 11 <string name="close">close</string>
12 12 <string name="pause">Pause</string>
  13 + <string name="logout">ログアウト</string>
13 14 <string name="setting">設定</string>
14 15 <string name="profile_change">プロフェイール変更</string>
15 16 <string name="step">step</string>