Commit febbd8db71107f97dd99c40918f958b2751b9836

Authored by 杨帅
2 parents 74c3a670 b7c677cc
config.gradle
... ... @@ -21,7 +21,7 @@ ext {
21 21 //编译方式
22 22 debug : false,
23 23 //版本号
24   - version: "0.7.21",
  24 + version: "0.7.23",
25 25 //Lib库前缀
26 26 packeg : "com.cnlive.module",
27 27 //Lib库名称
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/ShareRecordActivity.java
... ... @@ -2,12 +2,15 @@ package com.cnlive.moudle.pedometer.ui.activity;
2 2  
3 3 import android.Manifest;
4 4 import android.app.Activity;
  5 +import android.content.Context;
5 6 import android.content.Intent;
  7 +import android.content.SharedPreferences;
6 8 import android.graphics.Bitmap;
7 9 import android.support.v7.app.AppCompatActivity;
8 10 import android.os.Bundle;
9 11 import android.text.Editable;
10 12 import android.text.TextWatcher;
  13 +import android.util.Base64;
11 14 import android.widget.EditText;
12 15 import android.widget.ImageView;
13 16 import android.widget.RelativeLayout;
... ... @@ -28,28 +31,31 @@ import com.example.moudle_pedometer.R;
28 31 import com.qmuiteam.qmui.util.QMUIDrawableHelper;
29 32  
30 33 import java.io.ByteArrayOutputStream;
  34 +import java.io.IOException;
  35 +import java.io.ObjectOutputStream;
  36 +
  37 +import static android.provider.Contacts.SettingsColumns.KEY;
31 38  
32 39 /**
33   - *
34 40 * Created by hanyayun 019/05/30.
35 41 */
36 42 public class ShareRecordActivity extends AppCompatActivity {
37 43  
38 44 private ImageView share_back;
39   - private TextView share,cord_name;
  45 + private TextView share, cord_name;
40 46 private RelativeLayout ry_cen;
41 47 private EditText editText;
42 48 private PermissionsUtils mPermissionsUtils = new PermissionsUtils();
43 49 private ImageView record_icon;
44 50 private TextView record_name;
45 51  
46   - public static void newInstance(Activity context,String title,String kilo,String step,String time,String speed){
47   - Intent intent = new Intent(context,ShareRecordActivity.class);
48   - intent.putExtra("raceTitle",title);
49   - intent.putExtra("kilo",kilo);
50   - intent.putExtra("step",step);
51   - intent.putExtra("time",time);
52   - intent.putExtra("speed",speed);
  52 + public static void newInstance(Activity context, String title, String kilo, String step, String time, String speed) {
  53 + Intent intent = new Intent(context, ShareRecordActivity.class);
  54 + intent.putExtra("raceTitle", title);
  55 + intent.putExtra("kilo", kilo);
  56 + intent.putExtra("step", step);
  57 + intent.putExtra("time", time);
  58 + intent.putExtra("speed", speed);
53 59 context.startActivity(intent);
54 60 }
55 61  
... ... @@ -61,7 +67,7 @@ public class ShareRecordActivity extends AppCompatActivity {
61 67 setContentView(R.layout.activity_share_record);
62 68  
63 69 cord_name = findViewById(R.id.cord_name);
64   - cord_name.setText("我在中国网家家" + getIntent().getStringExtra("raceTitle") + "中的最佳成绩");
  70 + cord_name.setText("我在中国网家家\n" + getIntent().getStringExtra("raceTitle") + "中的最佳成绩");
65 71 ((TextView) findViewById(R.id.kilo_share)).setText(getIntent().getStringExtra("kilo"));
66 72 ((TextView) findViewById(R.id.step_share)).setText(getIntent().getStringExtra("step"));
67 73 ((TextView) findViewById(R.id.time_share)).setText(TimeUtil.stampToChronometers(Double.parseDouble(getIntent().getStringExtra("time"))));
... ... @@ -72,11 +78,11 @@ public class ShareRecordActivity extends AppCompatActivity {
72 78 record_icon = findViewById(R.id.record_icon);
73 79 record_name = findViewById(R.id.record_name);
74 80  
75   - if(CommonInfo.getUserNickName(this) != null && CommonInfo.getUserNickName(this).trim().length() > 0){
  81 + if (CommonInfo.getUserNickName(this) != null && CommonInfo.getUserNickName(this).trim().length() > 0) {
76 82 record_name.setText(CommonInfo.getUserNickName(this));
77 83 }
78 84  
79   - if(CommonInfo.getUserIcon(this) != null && CommonInfo.getUserIcon(this).trim().length() > 0){
  85 + if (CommonInfo.getUserIcon(this) != null && CommonInfo.getUserIcon(this).trim().length() > 0) {
80 86 Glide.with(this).load(CommonInfo.getUserIcon(this))
81 87 .apply(RequestOptions.bitmapTransform(new CircleCrop()).placeholder(R.drawable.ic_icon)).into(record_icon);
82 88 }
... ... @@ -105,9 +111,9 @@ public class ShareRecordActivity extends AppCompatActivity {
105 111 int cursorStart = editText.getSelectionStart();
106 112 int cursorEnd = editText.getSelectionEnd();
107 113 if (cursorStart == cursorEnd && cursorStart < str.length() && cursorStart >= 1) {
108   - str = str.substring(0, cursorStart-1) + str.substring(cursorStart);
  114 + str = str.substring(0, cursorStart - 1) + str.substring(cursorStart);
109 115 } else {
110   - str = str.substring(0, s.length()-1);
  116 + str = str.substring(0, s.length() - 1);
111 117 }
112 118 // setText会触发afterTextChanged的递归
113 119 editText.setText(str);
... ... @@ -117,24 +123,40 @@ public class ShareRecordActivity extends AppCompatActivity {
117 123 }
118 124 });
119 125  
120   - QrService service= (QrService) ARouter.getInstance().navigation(QrService.class);
121   - Bitmap bitmap= service.createQRNoIconBitmap("http://apiwjj.cnlive.com/download/index.html",350);
  126 + QrService service = (QrService) ARouter.getInstance().navigation(QrService.class);
  127 + Bitmap bitmap = service.createQRNoIconBitmap("http://apiwjj.cnlive.com/download/index.html", 350);
122 128 ((ImageView) findViewById(R.id.down_img)).setImageBitmap(bitmap);
123 129 }
124 130  
125   - private void share(){
126   - share.setCursorVisible(false);
  131 + private void share() {
  132 + editText.setCursorVisible(false);
127 133 Bitmap qrbm = QMUIDrawableHelper.createBitmapFromView(ry_cen);
128   - ByteArrayOutputStream baos=new ByteArrayOutputStream();
129   - qrbm.compress(Bitmap.CompressFormat.PNG, 100, baos);
130   - byte [] bitmapByte =baos.toByteArray();
131   - share.setCursorVisible(true);
  134 + String Base64 = convertIconToString(qrbm);
  135 + SharedPreferences.Editor editor = getSharedPreferences("sp", Context.MODE_PRIVATE).edit();
  136 + editor.putString("share_img_string", Base64);
  137 + editor.commit();
  138 + editText.setCursorVisible(true);
132 139 ARouter.getInstance().build("/share/ShareImgActivity")
133   - .withByteArray("bitmap", bitmapByte)
  140 + .withString("bitmap", "share_img_string")
134 141 .navigation(this);
135 142 }
136 143  
137 144  
  145 + /**
  146 + * 图片转成string
  147 + *
  148 + * @param bitmap
  149 + * @return
  150 + */
  151 + public String convertIconToString(Bitmap bitmap) {
  152 + ByteArrayOutputStream baos = new ByteArrayOutputStream();// outputstream
  153 + bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
  154 + byte[] appicon = baos.toByteArray();// 转为byte数组
  155 + String img = Base64.encodeToString(appicon, Base64.DEFAULT);
  156 + return img;
  157 +
  158 + }
  159 +
138 160 private void getPermissionsWithTip() {
139 161 mPermissionsUtils
140 162 .setPermissionsListener(new PermissionsListener() {
... ...
moudle_pedometer/src/main/res/layout/activity_share_record.xml
... ... @@ -48,228 +48,239 @@
48 48 android:layout_below="@id/topbar"
49 49 android:background="@drawable/share_background">
50 50  
51   - <RelativeLayout
52   - android:id="@+id/share_ry"
53   - android:layout_width="match_parent"
54   - android:layout_height="wrap_content"
55   - android:layout_marginLeft="20dp"
56   - android:layout_marginTop="50dp"
57   - android:layout_marginRight="20dp"
58   - android:background="@drawable/gray_bg_circle">
59   -
60   - <RelativeLayout
61   - android:id="@id/tv_pr"
62   - android:layout_width="wrap_content"
63   - android:layout_height="70dp"
64   - android:layout_marginTop="5dp"
65   - android:padding="10dp">
66   -
67   - <ImageView
68   - android:id="@+id/record_icon"
69   - android:layout_width="50dp"
70   - android:layout_height="50dp"
71   - android:src="@drawable/ic_icon" />
72   -
73   - <TextView
74   - android:id="@+id/record_name"
75   - android:layout_width="wrap_content"
76   - android:layout_height="wrap_content"
77   - android:layout_centerVertical="true"
78   - android:layout_marginLeft="20dp"
79   - android:layout_toRightOf="@id/record_icon"
80   - android:text="用户昵称"
81   - android:textColor="#333333"
82   - android:textSize="12sp" />
83   -
84   - <LinearLayout
85   - android:layout_width="wrap_content"
86   - android:layout_height="wrap_content"
87   - android:layout_alignParentRight="true"
88   - android:layout_alignParentBottom="true"
89   - android:layout_centerVertical="true"
90   - android:layout_marginRight="20dp">
91   -
92   - <TextView
93   - android:id="@+id/kilo_share"
94   - android:layout_width="wrap_content"
95   - android:layout_height="wrap_content"
96   - android:textColor="#333333"
97   - android:textSize="30sp" />
98   -
99   - <TextView
100   - android:layout_width="wrap_content"
101   - android:layout_height="wrap_content"
102   - android:layout_marginLeft="5dp"
103   - android:text="@string/kilometer"
104   - android:textColor="#333333"
105   - android:textSize="12sp" />
106   - </LinearLayout>
107   - </RelativeLayout>
108   -
109   - <RelativeLayout
110   - android:id="@+id/kilometer_ry"
111   - android:layout_width="match_parent"
112   - android:layout_height="wrap_content"
113   - android:layout_below="@id/tv_pr"
114   - android:layout_marginLeft="20dp"
115   - android:layout_marginTop="10dp"
116   - android:layout_marginRight="20dp">
117   -
118   - <LinearLayout
119   - android:id="@+id/kilometer_ly"
120   - android:layout_width="wrap_content"
121   - android:layout_height="wrap_content"
122   - android:orientation="vertical">
123   -
124   - <TextView
125   - android:layout_width="wrap_content"
126   - android:layout_height="wrap_content"
127   - android:layout_gravity="center"
128   - android:text="@string/stepnum"
129   - android:textColor="#333333"
130   - android:textSize="12sp" />
131   -
132   - <TextView
133   - android:id="@+id/step_share"
134   - android:layout_width="wrap_content"
135   - android:layout_height="wrap_content"
136   - android:layout_marginTop="5dp"
137   - android:textColor="#333333"
138   - android:textSize="23sp" />
139   - </LinearLayout>
140   -
141   -
142   - <LinearLayout
143   - android:layout_width="wrap_content"
144   - android:layout_height="wrap_content"
145   - android:layout_centerInParent="true"
146   - android:orientation="vertical">
147   -
148   - <TextView
149   - android:layout_width="wrap_content"
150   - android:layout_height="wrap_content"
151   - android:layout_gravity="center"
152   - android:text="@string/time_tast"
153   - android:textColor="#333333"
154   - android:textSize="12sp" />
155   -
156   - <TextView
157   - android:id="@+id/time_share"
158   - android:layout_width="wrap_content"
159   - android:layout_height="wrap_content"
160   - android:layout_gravity="center"
161   - android:layout_marginTop="5dp"
162   - android:textColor="#333333"
163   - android:textSize="23sp" />
164   - </LinearLayout>
165   -
166   - <LinearLayout
167   - android:layout_width="wrap_content"
168   - android:layout_height="wrap_content"
169   - android:layout_alignParentRight="true"
170   - android:orientation="vertical">
171   -
172   - <TextView
173   - android:layout_width="wrap_content"
174   - android:layout_height="wrap_content"
175   - android:layout_gravity="center"
176   - android:text="@string/v"
177   - android:textColor="#333333"
178   - android:textSize="12sp" />
179   -
180   - <TextView
181   - android:id="@+id/speed_share"
182   - android:layout_width="wrap_content"
183   - android:layout_height="wrap_content"
184   - android:layout_gravity="center"
185   - android:layout_marginTop="5dp"
186   - android:textColor="#333333"
187   - android:textSize="23sp" />
188   - </LinearLayout>
189   - </RelativeLayout>
190   -
191   - <View
192   - android:layout_width="match_parent"
193   - android:layout_height="1dp"
194   - android:layout_below="@id/kilometer_ry"
195   - android:layout_marginLeft="10dp"
196   - android:layout_marginTop="15dp"
197   - android:layout_marginRight="10dp"
198   - android:background="#CCCCCC" />
199   -
200   - <LinearLayout
201   - android:layout_width="match_parent"
202   - android:layout_height="wrap_content"
203   - android:layout_below="@id/kilometer_ry"
204   - android:layout_marginTop="20dp"
205   - android:orientation="horizontal"
206   - android:weightSum="3"
207   - android:padding="10dp">
208   -
209   - <RelativeLayout
210   - android:layout_width="0dp"
211   - android:layout_height="wrap_content"
212   - android:layout_marginRight="20dp"
213   - android:padding="5dp"
214   - android:layout_weight="2">
215   -
216   - <TextView
217   - android:id="@+id/cord_name"
218   - android:layout_width="match_parent"
219   - android:layout_height="wrap_content"
220   - android:gravity="left"
221   - android:textColor="#333333"
222   - android:maxLines="2"
223   - android:textSize="12sp" />
224   -
225   - <LinearLayout
226   - android:layout_width="match_parent"
227   - android:layout_height="wrap_content"
228   - android:layout_below="@id/cord_name"
229   - android:layout_marginTop="15dp"
230   - android:background="@drawable/cc_bg_circle"
231   - android:orientation="vertical"
232   - android:padding="5dp">
233   -
234   - <TextView
235   - android:id="@+id/tv_tv"
236   - android:layout_width="match_parent"
237   - android:layout_height="wrap_content"
238   - android:text="#心情标签#"
239   - android:textColor="#333333"
240   - android:textSize="10sp" />
241   -
242   - <EditText
243   - android:id="@+id/edit"
244   - android:layout_width="match_parent"
245   - android:layout_height="wrap_content"
246   - android:layout_below="@id/tv_tv"
247   - android:layout_marginTop="7dp"
248   - android:hint="点击这里写下你的心情标签最多两行哦"
249   - android:textColor="#999999"
250   - android:background="@null"
251   - android:maxLines="2"
252   - android:textSize="10sp" />
253   - </LinearLayout>
254   - </RelativeLayout>
255   -
256   -
257   - <ImageView
258   - android:id="@+id/down_img"
259   - android:layout_width="0dp"
260   - android:layout_height="wrap_content"
261   - android:layout_weight="1" />
262   - </LinearLayout>
263   - </RelativeLayout>
  51 + <LinearLayout
  52 + android:layout_width="match_parent"
  53 + android:layout_height="wrap_content"
  54 + android:layout_centerInParent="true"
  55 + android:orientation="vertical">
  56 + <RelativeLayout
  57 + android:id="@+id/share_ry"
  58 + android:layout_width="match_parent"
  59 + android:layout_height="wrap_content"
  60 + android:layout_marginLeft="20dp"
  61 + android:layout_marginRight="20dp"
  62 + android:background="@drawable/gray_bg_circle">
  63 +
  64 + <RelativeLayout
  65 + android:id="@id/tv_pr"
  66 + android:layout_width="wrap_content"
  67 + android:layout_height="70dp"
  68 + android:layout_marginTop="5dp"
  69 + android:padding="10dp">
  70 +
  71 + <ImageView
  72 + android:id="@+id/record_icon"
  73 + android:layout_width="35dp"
  74 + android:layout_height="35dp"
  75 + android:layout_centerVertical="true"
  76 + android:src="@drawable/ic_icon" />
  77 +
  78 + <TextView
  79 + android:id="@+id/record_name"
  80 + android:layout_width="wrap_content"
  81 + android:layout_height="wrap_content"
  82 + android:layout_centerVertical="true"
  83 + android:layout_marginLeft="20dp"
  84 + android:layout_toRightOf="@id/record_icon"
  85 + android:text="用户昵称"
  86 + android:textColor="#333333"
  87 + android:textSize="12sp" />
  88 +
  89 + <LinearLayout
  90 + android:layout_width="wrap_content"
  91 + android:layout_height="wrap_content"
  92 + android:layout_alignParentRight="true"
  93 + android:layout_alignParentBottom="true"
  94 + android:layout_centerVertical="true"
  95 + android:layout_marginRight="20dp">
  96 +
  97 + <TextView
  98 + android:id="@+id/kilo_share"
  99 + android:layout_width="wrap_content"
  100 + android:layout_height="wrap_content"
  101 + android:textColor="#333333"
  102 + android:textStyle="bold"
  103 + android:textSize="30sp" />
  104 +
  105 + <TextView
  106 + android:layout_width="wrap_content"
  107 + android:layout_height="wrap_content"
  108 + android:layout_marginLeft="5dp"
  109 + android:text="@string/kilometer"
  110 + android:textColor="#333333"
  111 + android:textSize="12sp" />
  112 + </LinearLayout>
  113 + </RelativeLayout>
  114 +
  115 + <RelativeLayout
  116 + android:id="@+id/kilometer_ry"
  117 + android:layout_width="match_parent"
  118 + android:layout_height="wrap_content"
  119 + android:layout_below="@id/tv_pr"
  120 + android:layout_marginLeft="20dp"
  121 + android:layout_marginTop="10dp"
  122 + android:layout_marginRight="20dp">
  123 +
  124 + <LinearLayout
  125 + android:id="@+id/kilometer_ly"
  126 + android:layout_width="wrap_content"
  127 + android:layout_height="wrap_content"
  128 + android:orientation="vertical">
  129 +
  130 + <TextView
  131 + android:layout_width="wrap_content"
  132 + android:layout_height="wrap_content"
  133 + android:layout_gravity="center"
  134 + android:text="@string/stepnum"
  135 + android:textColor="#333333"
  136 + android:textSize="12sp" />
  137 +
  138 + <TextView
  139 + android:id="@+id/step_share"
  140 + android:layout_width="wrap_content"
  141 + android:layout_height="wrap_content"
  142 + android:layout_marginTop="5dp"
  143 + android:textColor="#333333"
  144 + android:textStyle="bold"
  145 + android:textSize="23sp" />
  146 + </LinearLayout>
  147 +
  148 +
  149 + <LinearLayout
  150 + android:layout_width="wrap_content"
  151 + android:layout_height="wrap_content"
  152 + android:layout_centerInParent="true"
  153 + android:orientation="vertical">
  154 +
  155 + <TextView
  156 + android:layout_width="wrap_content"
  157 + android:layout_height="wrap_content"
  158 + android:layout_gravity="center"
  159 + android:text="@string/time_tast"
  160 + android:textColor="#333333"
  161 + android:textSize="12sp" />
  162 +
  163 + <TextView
  164 + android:id="@+id/time_share"
  165 + android:layout_width="wrap_content"
  166 + android:layout_height="wrap_content"
  167 + android:layout_gravity="center"
  168 + android:layout_marginTop="5dp"
  169 + android:textColor="#333333"
  170 + android:textStyle="bold"
  171 + android:textSize="23sp" />
  172 + </LinearLayout>
  173 +
  174 + <LinearLayout
  175 + android:layout_width="wrap_content"
  176 + android:layout_height="wrap_content"
  177 + android:layout_alignParentRight="true"
  178 + android:orientation="vertical">
  179 +
  180 + <TextView
  181 + android:layout_width="wrap_content"
  182 + android:layout_height="wrap_content"
  183 + android:layout_gravity="center"
  184 + android:text="@string/v"
  185 + android:textColor="#333333"
  186 + android:textSize="12sp" />
  187 +
  188 + <TextView
  189 + android:id="@+id/speed_share"
  190 + android:layout_width="wrap_content"
  191 + android:layout_height="wrap_content"
  192 + android:layout_gravity="center"
  193 + android:layout_marginTop="5dp"
  194 + android:textStyle="bold"
  195 + android:textColor="#333333"
  196 + android:textSize="23sp" />
  197 + </LinearLayout>
  198 + </RelativeLayout>
  199 +
  200 + <View
  201 + android:layout_width="match_parent"
  202 + android:layout_height="1dp"
  203 + android:layout_below="@id/kilometer_ry"
  204 + android:layout_marginLeft="10dp"
  205 + android:layout_marginTop="15dp"
  206 + android:layout_marginRight="10dp"
  207 + android:background="#CCCCCC" />
  208 +
  209 + <LinearLayout
  210 + android:layout_width="match_parent"
  211 + android:layout_height="wrap_content"
  212 + android:layout_below="@id/kilometer_ry"
  213 + android:layout_marginTop="20dp"
  214 + android:orientation="horizontal"
  215 + android:weightSum="3"
  216 + android:padding="10dp">
  217 +
  218 + <RelativeLayout
  219 + android:layout_width="0dp"
  220 + android:layout_height="wrap_content"
  221 + android:layout_marginRight="20dp"
  222 + android:padding="5dp"
  223 + android:layout_weight="2">
  224 +
  225 + <TextView
  226 + android:id="@+id/cord_name"
  227 + android:layout_width="match_parent"
  228 + android:layout_height="wrap_content"
  229 + android:gravity="left"
  230 + android:textColor="#333333"
  231 + android:maxLines="3"
  232 + android:textSize="12sp" />
  233 +
  234 + <LinearLayout
  235 + android:layout_width="match_parent"
  236 + android:layout_height="wrap_content"
  237 + android:layout_below="@id/cord_name"
  238 + android:layout_marginTop="15dp"
  239 + android:background="@drawable/cc_bg_circle"
  240 + android:orientation="vertical"
  241 + android:padding="5dp">
  242 +
  243 + <TextView
  244 + android:id="@+id/tv_tv"
  245 + android:layout_width="match_parent"
  246 + android:layout_height="wrap_content"
  247 + android:text="#心情标签#"
  248 + android:textColor="#333333"
  249 + android:textSize="10sp" />
  250 +
  251 + <EditText
  252 + android:id="@+id/edit"
  253 + android:layout_width="match_parent"
  254 + android:layout_height="wrap_content"
  255 + android:layout_below="@id/tv_tv"
  256 + android:layout_marginTop="7dp"
  257 + android:hint="点击这里写下你的心情标签最多两行哦"
  258 + android:textColor="#999999"
  259 + android:background="@null"
  260 + android:maxLines="2"
  261 + android:textSize="10sp" />
  262 + </LinearLayout>
  263 + </RelativeLayout>
  264 +
  265 +
  266 + <ImageView
  267 + android:id="@+id/down_img"
  268 + android:layout_width="0dp"
  269 + android:layout_height="wrap_content"
  270 + android:layout_weight="1" />
  271 + </LinearLayout>
  272 + </RelativeLayout>
  273 +
  274 + <ImageView
  275 + android:layout_width="wrap_content"
  276 + android:layout_height="wrap_content"
  277 + android:src="@drawable/share_logo"
  278 + android:layout_gravity="center"
  279 + android:layout_marginTop="30dp"
  280 + android:layout_marginBottom="50dp"
  281 + />
  282 + </LinearLayout>
264 283  
265   - <ImageView
266   - android:layout_width="wrap_content"
267   - android:layout_height="wrap_content"
268   - android:src="@drawable/share_logo"
269   - android:layout_below="@id/share_ry"
270   - android:layout_marginTop="30dp"
271   - android:layout_centerHorizontal="true"
272   - />
273 284 </RelativeLayout>
274 285  
275 286 </RelativeLayout>
... ...