-                if(orderMsgSwitch==null||systemMsgSwitch==null){
174
+                if (orderMsgSwitch == null || systemMsgSwitch == null) {
153 175
                     return;
154 176
                 }
155 177
                 orderMsgSwitch.setText(TextUtils.isEmpty(orderMsg) ? getString(R.string.no_order_msg) : orderMsg);
156
-                systemMsgSwitch.setText(TextUtils.isEmpty(sysMsg) ? getString(R.string.no_system_msg): sysMsg);
178
+                systemMsgSwitch.setText(TextUtils.isEmpty(sysMsg) ? getString(R.string.no_system_msg) : sysMsg);
157 179
             }
158 180
         });
159 181
 

+ 7 - 1
app/src/main/java/ai/pai/lensman/db/Preferences.java

@@ -81,6 +81,13 @@ public class Preferences {
81 81
         return mPrefs.getInt("delay",10);
82 82
     }
83 83
 
84
+    public boolean isEnergySaveMode(){
85
+        return mPrefs.getBoolean("isEnergySaveMode",false);
86
+    }
87
+
88
+    public void setEnergySaveMode(boolean isEnergySaveMode){
89
+        mPrefs.edit().putBoolean("isEnergySaveMode",isEnergySaveMode).commit();
90
+    }
84 91
     public boolean isUploadInMobile(){
85 92
         return mPrefs.getBoolean("uploadInMobile",true);
86 93
     }
@@ -89,7 +96,6 @@ public class Preferences {
89 96
         mPrefs.edit().putBoolean("uploadInMobile",uploadInMobile).commit();
90 97
     }
91 98
 
92
-
93 99
     public void setCameraQueryInterval(int interval){
94 100
         mPrefs.edit().putInt("interval",interval).commit();
95 101
     }

+ 54 - 43
app/src/main/java/ai/pai/lensman/session/SessionActivity.java

@@ -9,6 +9,7 @@ import android.support.v7.widget.LinearLayoutManager;
9 9
 import android.support.v7.widget.RecyclerView;
10 10
 import android.support.v7.widget.helper.ItemTouchHelper;
11 11
 import android.view.View;
12
+import android.view.WindowManager;
12 13
 import android.widget.ImageView;
13 14
 import android.widget.TextView;
14 15
 import android.widget.Toast;
@@ -25,6 +26,7 @@ import ai.pai.lensman.activities.SessionQRCodeActivity;
25 26
 import ai.pai.lensman.base.BaseActivity;
26 27
 import ai.pai.lensman.bean.PhotoBean;
27 28
 import ai.pai.lensman.bean.SessionBean;
29
+import ai.pai.lensman.db.Preferences;
28 30
 import ai.pai.lensman.qrcode.QRCaptureActivity;
29 31
 import ai.pai.lensman.utils.UmengEvent;
30 32
 import ai.pai.lensman.views.ExitSessionConfirmPopup;
@@ -32,22 +34,27 @@ import butterknife.BindView;
32 34
 import butterknife.ButterKnife;
33 35
 import butterknife.OnClick;
34 36
 
35
-public class SessionActivity extends BaseActivity implements SessionContract.View ,View.OnClickListener{
37
+public class SessionActivity extends BaseActivity implements SessionContract.View, View.OnClickListener {
36 38
 
37
-    @BindView(R.id.icon_no_data)         View noPhotoLayout;
38
-    @BindView(R.id.title_bar_middle_txt) TextView titleTextView;
39
-    @BindView(R.id.recycler_view_photos) RecyclerView photosRecyclerView;
40
-    @BindView(R.id.iv_scan)              ImageView qrcodeScanBtn;
41
-    @BindView(R.id.tv_camera_status)     TextView cameraStatusTextView;
39
+    @BindView(R.id.icon_no_data)
40
+    View noPhotoLayout;
41
+    @BindView(R.id.title_bar_middle_txt)
42
+    TextView titleTextView;
43
+    @BindView(R.id.recycler_view_photos)
44
+    RecyclerView photosRecyclerView;
45
+    @BindView(R.id.iv_scan)
46
+    ImageView qrcodeScanBtn;
47
+    @BindView(R.id.tv_camera_status)
48
+    TextView cameraStatusTextView;
42 49
 
43 50
     private PhotoRecyclerAdapter adapter;
44
-    private  SessionBean sessionBean;
51
+    private SessionBean sessionBean;
45 52
     private SessionContract.Presenter presenter;
46 53
     private static final int JOIN_REQUEST_CODE = 3002;
47 54
 
48 55
     private boolean isBackground;
49 56
 
50
-    private ItemTouchHelper.Callback mCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.RIGHT|ItemTouchHelper.LEFT) {
57
+    private ItemTouchHelper.Callback mCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.RIGHT | ItemTouchHelper.LEFT) {
51 58
 
52 59
         @Override
53 60
         public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
@@ -63,13 +70,13 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
63 70
         public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
64 71
             int position = viewHolder.getAdapterPosition();
65 72
             PhotoBean photoBean = adapter.getPhotoAt(position);
66
-            if(photoBean==null){
73
+            if (photoBean == null) {
67 74
                 return;
68 75
             }
69
-            if(photoBean.canDelete){
76
+            if (photoBean.canDelete) {
70 77
                 presenter.swipeToDeletePhoto(position);
71 78
                 adapter.removePhotoAtIndex(position);
72
-            }else{
79
+            } else {
73 80
                 showToast(getString(R.string.can_not_delete));
74 81
             }
75 82
         }
@@ -80,15 +87,15 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
80 87
         super.onCreate(savedInstanceState);
81 88
         setContentView(R.layout.activity_session);
82 89
         unbinder = ButterKnife.bind(this);
83
-        sessionBean =(SessionBean)getIntent().getSerializableExtra("session");
84
-        if(BuildConfig.isTestMode){
85
-            sessionBean.sessionId="test";
90
+        sessionBean = (SessionBean) getIntent().getSerializableExtra("session");
91
+        if (BuildConfig.isTestMode) {
92
+            sessionBean.sessionId = "test";
86 93
         }
87
-        if(BuildConfig.DEBUG){
94
+        if (BuildConfig.DEBUG) {
88 95
             cameraStatusTextView.setVisibility(View.VISIBLE);
89 96
         }
90
-        presenter = new SessionPresenter(sessionBean,this);
91
-        titleTextView.setText(getString(R.string.scene,sessionBean.sessionSeq));
97
+        presenter = new SessionPresenter(sessionBean, this);
98
+        titleTextView.setText(getString(R.string.scene, sessionBean.sessionSeq));
92 99
         adapter = new PhotoRecyclerAdapter(this);
93 100
 
94 101
         RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
@@ -101,9 +108,9 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
101 108
         presenter.start();
102 109
         String LOG_PATH = Environment.getExternalStorageDirectory()
103 110
                 .getAbsolutePath() + "/lensman/logs/";
104
-        if(!new File(LOG_PATH).exists()&&!new File(LOG_PATH).mkdirs()){
105
-            LogHelper.d("czy","sdcard write file error");
106
-            Toast.makeText(this,R.string.sdcard_fail,Toast.LENGTH_SHORT).show();
111
+        if (!new File(LOG_PATH).exists() && !new File(LOG_PATH).mkdirs()) {
112
+            LogHelper.d("czy", "sdcard write file error");
113
+            Toast.makeText(this, R.string.sdcard_fail, Toast.LENGTH_SHORT).show();
107 114
         }
108 115
     }
109 116
 
@@ -111,12 +118,16 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
111 118
     protected void onResume() {
112 119
         super.onResume();
113 120
         isBackground = false;
121
+        if(!Preferences.getInstance().isEnergySaveMode()){
122
+            getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
123
+        }
114 124
     }
115 125
 
116 126
     @Override
117 127
     protected void onPause() {
118 128
         super.onPause();
119 129
         isBackground = true;
130
+        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
120 131
     }
121 132
 
122 133
     @Override
@@ -126,7 +137,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
126 137
     }
127 138
 
128 139
     @OnClick(R.id.iv_scan)
129
-    void scanToFetchSessionQR(){
140
+    void scanToFetchSessionQR() {
130 141
         MobclickAgent.onEvent(this, UmengEvent.session_scan_qr_btn_click);
131 142
         Intent intent = new Intent(SessionActivity.this, QRCaptureActivity.class);
132 143
         startActivityForResult(intent, JOIN_REQUEST_CODE);
@@ -134,22 +145,22 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
134 145
     }
135 146
 
136 147
     @OnClick(R.id.iv_qrcode)
137
-    void showQRCodeForSession(){
148
+    void showQRCodeForSession() {
138 149
         MobclickAgent.onEvent(this, UmengEvent.session_view_qr_btn_click);
139
-        Intent intent = new Intent(this,SessionQRCodeActivity.class);
140
-        intent.putExtra("qrcode",sessionBean.sessionId);
150
+        Intent intent = new Intent(this, SessionQRCodeActivity.class);
151
+        intent.putExtra("qrcode", sessionBean.sessionId);
141 152
         startActivity(intent);
142 153
     }
143 154
 
144 155
     @OnClick(R.id.title_bar_back_layout)
145
-    void backToMain(){
146
-       new ExitSessionConfirmPopup(this,this).showPopupWindow();
156
+    void backToMain() {
157
+        new ExitSessionConfirmPopup(this, this).showPopupWindow();
147 158
     }
148 159
 
149 160
     @OnClick(R.id.btn_session_complete)
150
-    void onSessionComplete(){
161
+    void onSessionComplete() {
151 162
         MobclickAgent.onEvent(this, UmengEvent.session_finish_btn_click);
152
-        new ExitSessionConfirmPopup(this,this).showPopupWindow();
163
+        new ExitSessionConfirmPopup(this, this).showPopupWindow();
153 164
     }
154 165
 
155 166
     @Override
@@ -157,7 +168,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
157 168
         photosRecyclerView.post(new Runnable() {
158 169
             @Override
159 170
             public void run() {
160
-                LogHelper.d(TAG,"addNewPhoto to UI "+bean);
171
+                LogHelper.d(TAG, "addNewPhoto to UI " + bean);
161 172
                 adapter.addPhotoBean(bean);
162 173
                 photosRecyclerView.smoothScrollToPosition(0);
163 174
             }
@@ -193,14 +204,14 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
193 204
 
194 205
     @Override
195 206
     public void showToast(final String toast) {
196
-        if(isBackground){
207
+        if (isBackground) {
197 208
             return;
198 209
         }
199
-        if(photosRecyclerView!=null){
210
+        if (photosRecyclerView != null) {
200 211
             photosRecyclerView.post(new Runnable() {
201 212
                 @Override
202 213
                 public void run() {
203
-                    Toast.makeText(SessionActivity.this,toast,Toast.LENGTH_SHORT).show();
214
+                    Toast.makeText(SessionActivity.this, toast, Toast.LENGTH_SHORT).show();
204 215
                 }
205 216
             });
206 217
         }
@@ -210,7 +221,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
210 221
 
211 222
     @Override
212 223
     public void refreshRecyclerView() {
213
-        if(adapter!=null && photosRecyclerView!=null && photosRecyclerView.getVisibility()==View.VISIBLE){
224
+        if (adapter != null && photosRecyclerView != null && photosRecyclerView.getVisibility() == View.VISIBLE) {
214 225
             photosRecyclerView.post(new Runnable() {
215 226
                 @Override
216 227
                 public void run() {
@@ -222,25 +233,25 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
222 233
 
223 234
     @Override
224 235
     public void addPhotos(final ArrayList<PhotoBean> photoList) {
225
-        if(photoList==null||photoList.size()<1) {
236
+        if (photoList == null || photoList.size() < 1) {
226 237
             return;
227 238
         }
228 239
         photosRecyclerView.post(new Runnable() {
229 240
             @Override
230 241
             public void run() {
231 242
                 adapter.addPreviousPhotos(photoList);
232
-                photosRecyclerView.smoothScrollToPosition(photoList.size()-1);
243
+                photosRecyclerView.smoothScrollToPosition(photoList.size() - 1);
233 244
             }
234 245
         });
235 246
     }
236 247
 
237 248
     @Override
238 249
     public void refreshCameraStatus(final String status) {
239
-        if(cameraStatusTextView!=null){
250
+        if (cameraStatusTextView != null) {
240 251
             cameraStatusTextView.post(new Runnable() {
241 252
                 @Override
242 253
                 public void run() {
243
-                    if(cameraStatusTextView!=null){
254
+                    if (cameraStatusTextView != null) {
244 255
                         cameraStatusTextView.setText(status);
245 256
                     }
246 257
                 }
@@ -250,16 +261,16 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
250 261
 
251 262
     @Override
252 263
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
253
-        super.onActivityResult(requestCode,resultCode,data);
264
+        super.onActivityResult(requestCode, resultCode, data);
254 265
         if (resultCode == Activity.RESULT_OK) {
255 266
             if (data == null || data.getStringExtra("info") == null) {
256 267
                 return;
257 268
             }
258 269
             String qrInfo = data.getStringExtra("info");
259
-            if(qrInfo.contains("pai.ai/g/")||qrInfo.contains("xfoto.com.cn/g/")){
260
-                String groupId = qrInfo.substring(qrInfo.lastIndexOf("/")+1);
270
+            if (qrInfo.contains("pai.ai/g/") || qrInfo.contains("xfoto.com.cn/g/")) {
271
+                String groupId = qrInfo.substring(qrInfo.lastIndexOf("/") + 1);
261 272
                 presenter.addSessionPhotos2Group(groupId);
262
-            }else{
273
+            } else {
263 274
                 presenter.change2QRCodeSessionId(data.getStringExtra("info"));
264 275
             }
265 276
         }
@@ -267,7 +278,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
267 278
 
268 279
     @Override
269 280
     public void onClick(View view) {
270
-       if(view.getId()==R.id.btn_exit_session_confirm){
281
+        if (view.getId() == R.id.btn_exit_session_confirm) {
271 282
             presenter.stop();
272 283
             finish();
273 284
         }
@@ -275,7 +286,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
275 286
 
276 287
     @Override
277 288
     public void onBackPressed() {
278
-        new ExitSessionConfirmPopup(this,this).showPopupWindow();
289
+        new ExitSessionConfirmPopup(this, this).showPopupWindow();
279 290
     }
280 291
 
281 292
 

+ 35 - 0
app/src/main/res/layout/activity_briefs.xml

@@ -394,6 +394,41 @@
394 394
                         android:textOn="@null" />
395 395
 
396 396
                 </LinearLayout>
397
+                <View
398
+                    android:layout_width="match_parent"
399
+                    android:layout_height="1px"
400
+                    android:background="@color/text_hint_grey_color" />
401
+
402
+                <LinearLayout
403
+                    android:layout_width="match_parent"
404
+                    android:layout_height="32dp"
405
+                    android:orientation="horizontal">
406
+
407
+                    <TextView
408
+                        android:id="@+id/tv_energy_save"
409
+                        android:layout_width="0dp"
410
+                        android:layout_weight="1"
411
+                        android:layout_height="wrap_content"
412
+                        android:layout_gravity="center_vertical|left"
413
+                        android:paddingLeft="10dp"
414
+                        android:text="@string/energy_mode_off"
415
+                        android:textColor="@color/_7B8088"
416
+                        android:textSize="14sp" />
417
+
418
+                    <ToggleButton
419
+                        android:id="@+id/toggle_energy_save"
420
+                        android:layout_width="56dp"
421
+                        android:layout_height="20dp"
422
+                        android:layout_marginRight="12dp"
423
+                        android:layout_gravity="center_vertical"
424
+                        android:background="@drawable/toggle_button_selector"
425
+                        android:checked="false"
426
+                        android:gravity="center"
427
+                        android:textColor="@color/white"
428
+                        android:textOff="@null"
429
+                        android:textOn="@null" />
430
+
431
+                </LinearLayout>
397 432
 
398 433
 
399 434
             </LinearLayout>

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -142,6 +142,8 @@
142 142
     <string name="logout_user">退出登录</string>
143 143
 
144 144
     <string name="upload_in_mobile_network">运营商网络下自动上传</string>
145
+    <string name="energy_mode_on">节能模式已开启</string>
146
+    <string name="energy_mode_off">节能模式已关闭</string>
145 147
 
146 148
     <string name="can_not_delete">该照片已在上传队列,无法删除</string>
147 149
     <string name="auto_upload_after_seconds">距加入上传队列还有%d秒</string>

Kodo/kodo - Gogs: Go Git Service

1 コミット (7f9088cde4c366f35a777435a7dc6f5531428d1c)

作者 SHA1 メッセージ 日付
  Brightcells 9bb56c50cc Makemigrations 7 年 前