添加加解密图片功能

chengzhenyu лет %!s(int64=6): %!d(string=назад)
Родитель
Сommit
457d3442fb

+ 6 - 1
app/src/main/java/ai/pai/lensman/activities/EncryptActivity.java

@@ -2,6 +2,7 @@ package ai.pai.lensman.activities;
2 2
 
3 3
 import android.os.Bundle;
4 4
 import android.view.View;
5
+import android.widget.Button;
5 6
 import android.widget.ImageView;
6 7
 import android.widget.TextView;
7 8
 import android.widget.Toast;
@@ -25,6 +26,7 @@ public class EncryptActivity extends BaseActivity implements View.OnClickListene
25 26
     private DisplayImageOptions options;
26 27
 
27 28
     private String currentPath = "";
29
+    private Button encryptBtn;
28 30
 
29 31
     @Override
30 32
     protected void onCreate(Bundle savedInstanceState) {
@@ -37,7 +39,8 @@ public class EncryptActivity extends BaseActivity implements View.OnClickListene
37 39
         ((TextView) findViewById(R.id.title_bar_middle_txt)).setText("加密");
38 40
         findViewById(R.id.title_bar_back_layout).setOnClickListener(this);
39 41
         findViewById(R.id.title_bar_option_layout).setVisibility(View.INVISIBLE);
40
-        findViewById(R.id.btn_encrypt).setOnClickListener(this);
42
+        encryptBtn = (Button) findViewById(R.id.btn_encrypt);
43
+        encryptBtn.setOnClickListener(this);
41 44
         findViewById(R.id.title_bar_back_layout).setOnClickListener(this);
42 45
         image = (ImageView) findViewById(R.id.image_encrypt);
43 46
         currentPath = originImgFilePath;
@@ -59,12 +62,14 @@ public class EncryptActivity extends BaseActivity implements View.OnClickListene
59 62
                         LogHelper.d("czy", "加密成功");
60 63
                         currentPath = encryptImgFilePath;
61 64
                         ImageLoaderUtils.displayLocalImage(currentPath, image, options);
65
+                        encryptBtn.setText("解密");
62 66
                     } else {
63 67
                         LogHelper.d("czy", "开始解密");
64 68
                         EncryptUtils.xorFile(encryptImgFilePath, decryptImgFilePath, "chengzhenyu".getBytes());
65 69
                         LogHelper.d("czy", "解密成功");
66 70
                         currentPath = decryptImgFilePath;
67 71
                         ImageLoaderUtils.displayLocalImage(currentPath, image, options);
72
+                        encryptBtn.setText("加密");
68 73
                     }
69 74
                 } catch (Exception e) {
70 75
                     e.printStackTrace();

+ 8 - 4
app/src/main/res/layout/activity_encrypt.xml

@@ -9,6 +9,7 @@
9 9
         android:layout_width="match_parent"
10 10
         android:layout_height="wrap_content"
11 11
         android:background="@color/colorPrimaryDark">
12
+
12 13
         <include layout="@layout/title_bar_with_back_and_option" />
13 14
     </RelativeLayout>
14 15
 
@@ -16,17 +17,20 @@
16 17
         android:id="@+id/image_encrypt"
17 18
         android:layout_width="match_parent"
18 19
         android:layout_height="300dp"
19
-        android:scaleType="centerInside"
20
-        android:layout_below="@id/title_layout"/>
20
+        android:layout_below="@id/title_layout"
21
+        android:scaleType="centerCrop" />
21 22
 
22 23
     <Button
23 24
         android:id="@+id/btn_encrypt"
24 25
         android:layout_width="100dp"
25 26
         android:layout_height="48dp"
26 27
         android:layout_alignParentBottom="true"
27
-        android:layout_marginBottom="60dp"
28 28
         android:layout_centerHorizontal="true"
29
-        android:gravity="center"/>
29
+        android:layout_marginBottom="60dp"
30
+        android:background="@color/colorPrimary"
31
+        android:gravity="center"
32
+        android:text="加密"
33
+        android:textColor="@color/white" />
30 34
 
31 35
 
32 36
 </RelativeLayout>