Commit fc0b8695adf7469f99ba80f38c680997abababc3

Authored by 杜方
1 parent a94485b3

畅游通核销app4.0 1.适配安卓高版本

AndroidManifest.xml
... ... @@ -29,11 +29,14 @@
29 29  
30 30 <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
31 31 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  32 + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
32 33 <uses-permission android:name="android.permission.RESTART_PACKAGES" />
33 34 <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
34 35 <uses-permission android:name="android.permission.BROADCAST_STICKY" />
35 36 <uses-permission android:name="android.permission.CALL_PHONE" />
36 37 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  38 + <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
  39 + <uses-permission android:name="android.permission.CAMERA" />
37 40 <!-- 读写sd卡的权限,用于缓存广告所用到的图片,节省流量 ,并可获得更好的用户体验(所有使用有米android 2.0版本以上sdk的应用都会共享缓存的图片) -->
38 41 <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
39 42 <!-- 连接网络权限 ,用于请求广告(必须) -->
... ...
build.gradle
... ... @@ -33,7 +33,7 @@ buildscript {
33 33 }
34 34  
35 35 dependencies {
36   - implementation files('libs/android-support-v4.jar')
  36 +// implementation files('libs/android-support-v4.jar')
37 37 implementation files('libs/bcprov-jdk16-1.45.jar')
38 38 implementation files('libs/dom4j-1.6.1.jar')
39 39 implementation files('libs/fastjson-1.2.3.jar')
... ... @@ -57,6 +57,7 @@ dependencies {
57 57 implementation files('libs/bw_pos_sdk2.0.18.jar')
58 58 implementation 'com.squareup.okhttp3:okhttp:3.6.0'
59 59 implementation 'com.sunmi:printerx:1.0.18'
  60 + implementation 'com.android.support:appcompat-v7:28.0.0'
60 61 // implementation('com.android.support:support-v4:21.0.0')
61 62 // implementation('com.android.support:appcompat-v7:21.0.0'){ // You should exclude one of them not both of them
62 63 // exclude module: "support-v4"
... ... @@ -79,7 +80,7 @@ dependencies {
79 80 }
80 81  
81 82 android {
82   - compileSdkVersion 21
  83 + compileSdkVersion 30
83 84  
84 85 buildTypes {
85 86 release {
... ... @@ -129,7 +130,7 @@ android {
129 130 }
130 131 defaultConfig {
131 132 minSdkVersion 19
132   - targetSdkVersion 21
  133 + targetSdkVersion 30
133 134 vectorDrawables.useSupportLibrary =true
134 135  
135 136 ndk {
... ...
libs/android-support-v4.jar deleted
No preview for this file type
project.properties
... ... @@ -11,4 +11,4 @@
11 11 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 12  
13 13 # Project target.
14   -target=android-21
  14 +target=android-30
... ...
res/layout-sw360dp/app_top_title.xml
... ... @@ -45,14 +45,14 @@
45 45 android:visibility="gone"
46 46 android:textSize="@dimen/topBtnsSize" />
47 47  
48   - <com.ectrip.trips.view.CheckSwitchButton
49   - android:id="@+id/switchButton"
50   - android:layout_width="wrap_content"
51   - android:layout_height="wrap_content"
52   - android:layout_alignParentRight="true"
53   - android:layout_centerVertical="true"
54   - android:layout_marginRight="5dp"
55   - android:visibility="gone" />
  48 +<!-- <com.ectrip.trips.view.CheckSwitchButton-->
  49 +<!-- android:id="@+id/switchButton"-->
  50 +<!-- android:layout_width="wrap_content"-->
  51 +<!-- android:layout_height="wrap_content"-->
  52 +<!-- android:layout_alignParentRight="true"-->
  53 +<!-- android:layout_centerVertical="true"-->
  54 +<!-- android:layout_marginRight="5dp"-->
  55 +<!-- android:visibility="gone" />-->
56 56  
57 57 <TextView
58 58 android:id="@+id/printText"
... ...
src/com/ectrip/cyt/config/DevicTool.java
... ... @@ -26,6 +26,7 @@ import android.net.wifi.WifiManager;
26 26 import android.os.Build;
27 27 import android.os.Handler;
28 28 import android.os.Message;
  29 +import android.provider.Settings;
29 30 import android.telephony.TelephonyManager;
30 31 import android.text.TextUtils;
31 32 import android.util.DisplayMetrics;
... ... @@ -110,7 +111,9 @@ public class DevicTool {
110 111 .substring(0, 2).equals("DY"))) {
111 112 devId = getSerialNumber();
112 113 } else {
113   - if(Build.VERSION.SDK_INT>=28){
  114 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
  115 + devId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
  116 + }else if(Build.VERSION.SDK_INT>=28){
114 117 devId = getLocalMacIdFromIp();
115 118 }else{
116 119 devId = getLocalMacAddress();
... ...
src/com/ectrip/cyt/config/MyApp.java
... ... @@ -79,7 +79,7 @@ import com.hdx.lib.serial.SerialPortOperaion;
79 79 import com.hdx.lib.serial.SerialPortOperaion.SerialReadData;
80 80  
81 81  
82   -public class MyApp extends BaseApplication {
  82 +public class MyApp extends Application {
83 83 private static final String TAG = "MyApp";
84 84 private static MyApp instance;
85 85 // 是否是手持机
... ...
src/com/ectrip/cyt/ui/BaseActivity.java
... ... @@ -79,7 +79,7 @@ public abstract class BaseActivity extends FragmentActivity {
79 79 /**
80 80 * 设置为横屏
81 81 */
82   - LogUtil.i(TAG, "isTablet == " + isTablet);
  82 +// LogUtil.i(TAG, "isTablet == " + isTablet);
83 83 if (isTablet) {
84 84 if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
85 85 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
... ...
src/com/ectrip/cyt/ui/InputCodeActivity.java
... ... @@ -109,7 +109,18 @@ public class InputCodeActivity extends BaseActivity implements
109 109  
110 110 et_sfz.requestFocus();
111 111  
112   - if (android.os.Build.VERSION.SDK_INT >= 11) {
  112 + if (android.os.Build.VERSION.SDK_INT >= 28) {
  113 + try {
  114 + et_sfz.setShowSoftInputOnFocus(false);
  115 + et_sfz.requestFocus();
  116 + } catch (Exception e) {
  117 + e.printStackTrace();
  118 + textViewShow(et_sfz);
  119 + } catch (Throwable e) {
  120 + e.printStackTrace();
  121 + textViewShow(et_sfz);
  122 + }
  123 + }else if (android.os.Build.VERSION.SDK_INT >= 11) {
113 124 try {
114 125 et_sfz.setShowSoftInputOnFocus(false);
115 126 } catch (Exception e) {
... ...
src/com/ectrip/cyt/ui/InputIdCardActivity.java
... ... @@ -24,6 +24,7 @@ import com.ectrip.cyt.shield_home.LockLayer.MToast;
24 24 import com.ectrip.cyt.utils.ActivitiesManager;
25 25 import com.ectrip.cyt.utils.CommetryUtils;
26 26 import com.ectrip.cyt.utils.CountDownTimer;
  27 +import com.ectrip.cyt.utils.LogUtil;
27 28 import com.ectrip.cyt.utils.RegexUtils;
28 29 import com.ectrip.cyt.utils.SharedPreferences2Obj;
29 30 import com.ectrip.trips.check.R;
... ... @@ -34,253 +35,265 @@ import com.ectrip.trips.view.LongClickButton.LongClickRepeatListener;
34 35 * @author Administrator 身份证输入页面
35 36 */
36 37 public class InputIdCardActivity extends BaseActivity implements
37   - View.OnClickListener,LongClickRepeatListener{
38   -
39   - private String titleName;
40   - // 身份证
41   - private EditText idEdit;
42   - private TextView one, two, three, four, five, six, seven, eight, nine, zero,
43   - X_btn, topBtns;
44   - private LongClickButton delete;
45   - private int tag;
46   -
47   - @Override
48   - protected void onCreate(Bundle savedInstanceState) {
49   - super.onCreate(savedInstanceState);
50   - setContentView(R.layout.app_input_idcard);
51   - ActivitiesManager.getInstance().pushActivity(this);
52   - initConfig();
53   - initView();
54   - initReceiver();
55   - }
56   -
57   - private void initReceiver() {
58   - IntentFilter filter = new IntentFilter("cyt.idcard.action");
59   - registerReceiver(broadcastReceiver,filter);
60   - }
61   -
62   - private void initConfig() {
63   - tag = getIntent().getIntExtra("tag", -1);
64   - titleName = getIntent().getStringExtra("titleName");
65   - if (tag == 0) {
66   - ((TextView) findViewById(R.id.title))
67   - .setText(titleName == null ? getString(R.string.app_name)
68   - : getString(R.string.order_id) + titleName);
69   -
70   - } else {
71   - ((TextView) findViewById(R.id.title))
72   - .setText(titleName == null ? getString(R.string.app_name)
73   - : titleName);
74   - }
75   - findViewById(R.id.topBack).setOnClickListener(new OnClickListener() {
76   - @Override
77   - public void onClick(View arg0) {
78   - finish();
79   - }
80   - });
81   - }
82   -
83   - @SuppressLint("NewApi")
84   - private void initView() {
85   - SharedPreferences2Obj.getInstance(InputIdCardActivity.this)
86   - .setName("SelectAction").setObject("isStatistic", "0"); // 非统计
87   - titleName = getIntent().getStringExtra("titleName");
88   - if (titleName != null) {
89   - ((TextView) findViewById(R.id.title)).setText(titleName);
90   - } else {
91   - ((TextView) findViewById(R.id.title)).setText(R.string.input_id);
92   - }
93   - ((TextView) findViewById(R.id.title)).setVisibility(View.VISIBLE);
94   - topBtns = (Button) findViewById(R.id.topBtns);
95   - topBtns.setVisibility(View.VISIBLE);
96   -
97   - idEdit = (EditText) findViewById(R.id.input_idcard);
98   - one = (TextView) findViewById(R.id.one);
99   - one.setOnClickListener(this);
100   -
101   - two = (TextView) findViewById(R.id.two);
102   - two.setOnClickListener(this);
103   -
104   - three = (TextView) findViewById(R.id.three);
105   - three.setOnClickListener(this);
106   -
107   - four = (TextView) findViewById(R.id.four);
108   - four.setOnClickListener(this);
109   -
110   - five = (TextView) findViewById(R.id.five);
111   - five.setOnClickListener(this);
112   -
113   - six = (TextView) findViewById(R.id.six);
114   - six.setOnClickListener(this);
115   -
116   - seven = (TextView) findViewById(R.id.seven);
117   - seven.setOnClickListener(this);
118   -
119   - eight = (TextView) findViewById(R.id.eight);
120   - eight.setOnClickListener(this);
121   -
122   - nine = (TextView) findViewById(R.id.nine);
123   - nine.setOnClickListener(this);
124   -
125   - zero = (TextView) findViewById(R.id.zero);
126   - zero.setOnClickListener(this);
127   -
128   - X_btn = (TextView) findViewById(R.id.X_btn);
129   - X_btn.setOnClickListener(this);
130   -
131   - delete =(LongClickButton) findViewById(R.id.delete);
132   - delete.setLongClickRepeatListener(this);
133   - delete.setOnClickListener(this);
134   -
135   - topBtns.setText(R.string.topbtn_ok);
136   - topBtns.setOnClickListener(this);
137   -
138   - if (tag == 0) {
139   - idEdit.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
140   - idEdit.setTransformationMethod(PasswordTransformationMethod
141   - .getInstance());
142   - idEdit.setHint(R.string.ticket_counter_pwd);
143   - }
144   -
145   - if (android.os.Build.VERSION.SDK_INT >= 11) {
146   - try {
147   - idEdit.setShowSoftInputOnFocus(false);
148   - } catch (Exception e) {
149   - e.printStackTrace();
150   - textViewShow(idEdit);
151   - } catch (Throwable e) {
152   - e.printStackTrace();
153   - textViewShow(idEdit);
154   - }
155   - } else {
156   - textViewShow(idEdit);
157   - }
158   - }
159   -
160   - private void textViewShow(EditText message) {
161   -
162   - if (android.os.Build.VERSION.SDK_INT <= 10) {
163   - message.setInputType(InputType.TYPE_NULL);
164   - } else {
165   - getWindow().setSoftInputMode(
166   - WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
167   - try {
168   - Class<EditText> cls = EditText.class;
169   - Method setSoftInputShownOnFocus = cls.getMethod(
170   - "setSoftInputShownOnFocus", boolean.class);
171   - setSoftInputShownOnFocus.setAccessible(true);
172   - setSoftInputShownOnFocus.invoke(message, false);
173   - } catch (Exception e) {
174   - }
175   - }
176   -
177   - }
178   -
179   - @Override
180   - public void onClick(View v) {
181   - int index = 0;
182   - Editable editable = null;
183   - if (idEdit.isFocused()) {
184   - index = idEdit.getSelectionStart();
185   - editable = idEdit.getText();
186   - }
187   -
188   - switch (v.getId()) {
189   - case R.id.topBtns:
190   - String str = idEdit.getText().toString();
191   -
192   - if (!RegexUtils.checkIdCard(str)) {
193   - MToast(InputIdCardActivity.this,
194   - getString(R.string.the_idcard_not_valid),
195   - MToast.LENGTH_SHORT);
196   - idEdit.setText("");
197   - return;
198   - }
199   - Intent intent = new Intent(InputIdCardActivity.this,
200   - IDOrderListActivity.class);
201   - CountDownTimer.firstTime = new Date().getTime();// 不必要的可以删除
202   - intent.putExtra("mode", 0);
203   - intent.putExtra("idcardNumber", str);
204   - intent.putExtra("titleName", getString(R.string.order_list));
205   - startActivity(intent);
206   -
207   - break;
208   - case R.id.delete:
209   - if (idEdit.isFocused()) {
210   - index = idEdit.getSelectionStart();
211   - editable = idEdit.getText();
212   - }
213   - if (editable.length() > 0) {
214   - try {
215   - editable.delete(index - 1, index);
216   - } catch (Exception e) {
217   - if (editable.length() > 0) {
218   - editable.delete(index, index + 1);
219   - }
220   - }
221   - }
222   - break;
223   - default:
224   - if (editable.length() < 18) {
225   - editable.insert(index, ((TextView) v).getText());
226   - }
227   - break;
228   - }
229   - }
230   -
231   - @Override
232   - public boolean onKeyDown(int keyCode, KeyEvent event) {
233   - if (keyCode == KeyEvent.KEYCODE_BACK) {
234   - try {
235   - CommetryUtils.releaseCommery(this);
236   - } catch (Exception e) {
237   - e.printStackTrace();
238   - }
239   -
240   - finish();
241   -
242   - }
243   - return false;
244   - }
245   -
246   - @Override
247   - protected void onDestroy() {
248   - super.onDestroy();
249   -
250   - try {
251   - CommetryUtils.releaseCommery(this);
252   - } catch (Exception e) {
253   - e.printStackTrace();
254   - }
255   - }
256   -
257   - @Override
258   - public void repeatAction() {
259   - int index = 0;
260   - Editable editable = null;
261   - if (idEdit.isFocused()) {
262   - index = idEdit.getSelectionStart();
263   - editable = idEdit.getText();
264   - }
265   - if (editable.length() > 0) {
266   - try {
267   - editable.delete(index - 1, index);
268   - } catch (Exception e) {
269   - if (editable.length() > 0) {
270   - editable.delete(index, index + 1);
271   - }
272   - }
273   - }
274   - }
275   -
276   - /**************************查询成功的情况下,清空输入框*****************************/
277   - BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
278   - @Override
279   - public void onReceive(Context context, Intent intent){
280   - boolean sucess=intent.getExtras().getBoolean("sucess",false);
281   - if(sucess){
282   - idEdit.setText("");
283   - }
284   - }
285   - };
  38 + View.OnClickListener, LongClickRepeatListener {
  39 +
  40 + private String titleName;
  41 + // 身份证
  42 + private EditText idEdit;
  43 + private TextView one, two, three, four, five, six, seven, eight, nine, zero,
  44 + X_btn, topBtns;
  45 + private LongClickButton delete;
  46 + private int tag;
  47 +
  48 + @Override
  49 + protected void onCreate(Bundle savedInstanceState) {
  50 + super.onCreate(savedInstanceState);
  51 + setContentView(R.layout.app_input_idcard);
  52 + ActivitiesManager.getInstance().pushActivity(this);
  53 + initConfig();
  54 + initView();
  55 + initReceiver();
  56 + }
  57 +
  58 + private void initReceiver() {
  59 + IntentFilter filter = new IntentFilter("cyt.idcard.action");
  60 + registerReceiver(broadcastReceiver, filter);
  61 + }
  62 +
  63 + private void initConfig() {
  64 + tag = getIntent().getIntExtra("tag", -1);
  65 + titleName = getIntent().getStringExtra("titleName");
  66 + if (tag == 0) {
  67 + ((TextView) findViewById(R.id.title))
  68 + .setText(titleName == null ? getString(R.string.app_name)
  69 + : getString(R.string.order_id) + titleName);
  70 +
  71 + } else {
  72 + ((TextView) findViewById(R.id.title))
  73 + .setText(titleName == null ? getString(R.string.app_name)
  74 + : titleName);
  75 + }
  76 + findViewById(R.id.topBack).setOnClickListener(new OnClickListener() {
  77 + @Override
  78 + public void onClick(View arg0) {
  79 + finish();
  80 + }
  81 + });
  82 + }
  83 +
  84 + @SuppressLint("NewApi")
  85 + private void initView() {
  86 + SharedPreferences2Obj.getInstance(InputIdCardActivity.this)
  87 + .setName("SelectAction").setObject("isStatistic", "0"); // 非统计
  88 + titleName = getIntent().getStringExtra("titleName");
  89 + if (titleName != null) {
  90 + ((TextView) findViewById(R.id.title)).setText(titleName);
  91 + } else {
  92 + ((TextView) findViewById(R.id.title)).setText(R.string.input_id);
  93 + }
  94 + ((TextView) findViewById(R.id.title)).setVisibility(View.VISIBLE);
  95 + topBtns = (Button) findViewById(R.id.topBtns);
  96 + topBtns.setVisibility(View.VISIBLE);
  97 +
  98 + idEdit = (EditText) findViewById(R.id.input_idcard);
  99 + one = (TextView) findViewById(R.id.one);
  100 + one.setOnClickListener(this);
  101 +
  102 + two = (TextView) findViewById(R.id.two);
  103 + two.setOnClickListener(this);
  104 +
  105 + three = (TextView) findViewById(R.id.three);
  106 + three.setOnClickListener(this);
  107 +
  108 + four = (TextView) findViewById(R.id.four);
  109 + four.setOnClickListener(this);
  110 +
  111 + five = (TextView) findViewById(R.id.five);
  112 + five.setOnClickListener(this);
  113 +
  114 + six = (TextView) findViewById(R.id.six);
  115 + six.setOnClickListener(this);
  116 +
  117 + seven = (TextView) findViewById(R.id.seven);
  118 + seven.setOnClickListener(this);
  119 +
  120 + eight = (TextView) findViewById(R.id.eight);
  121 + eight.setOnClickListener(this);
  122 +
  123 + nine = (TextView) findViewById(R.id.nine);
  124 + nine.setOnClickListener(this);
  125 +
  126 + zero = (TextView) findViewById(R.id.zero);
  127 + zero.setOnClickListener(this);
  128 +
  129 + X_btn = (TextView) findViewById(R.id.X_btn);
  130 + X_btn.setOnClickListener(this);
  131 +
  132 + delete = (LongClickButton) findViewById(R.id.delete);
  133 + delete.setLongClickRepeatListener(this);
  134 + delete.setOnClickListener(this);
  135 +
  136 + topBtns.setText(R.string.topbtn_ok);
  137 + topBtns.setOnClickListener(this);
  138 +
  139 + if (tag == 0) {
  140 + idEdit.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
  141 + idEdit.setTransformationMethod(PasswordTransformationMethod
  142 + .getInstance());
  143 + idEdit.setHint(R.string.ticket_counter_pwd);
  144 + }
  145 +
  146 + if (android.os.Build.VERSION.SDK_INT >= 28) {
  147 + try {
  148 + idEdit.setShowSoftInputOnFocus(false);
  149 + idEdit.requestFocus();
  150 + } catch (Exception e) {
  151 + e.printStackTrace();
  152 + textViewShow(idEdit);
  153 + } catch (Throwable e) {
  154 + e.printStackTrace();
  155 + textViewShow(idEdit);
  156 + }
  157 + } else if (android.os.Build.VERSION.SDK_INT >= 11) {
  158 + try {
  159 + idEdit.setShowSoftInputOnFocus(false);
  160 + } catch (Exception e) {
  161 + e.printStackTrace();
  162 + textViewShow(idEdit);
  163 + } catch (Throwable e) {
  164 + e.printStackTrace();
  165 + textViewShow(idEdit);
  166 + }
  167 + } else {
  168 + textViewShow(idEdit);
  169 + }
  170 + }
  171 +
  172 + private void textViewShow(EditText message) {
  173 +
  174 + if (android.os.Build.VERSION.SDK_INT <= 10) {
  175 + message.setInputType(InputType.TYPE_NULL);
  176 + } else {
  177 + getWindow().setSoftInputMode(
  178 + WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  179 + try {
  180 + Class<EditText> cls = EditText.class;
  181 + Method setSoftInputShownOnFocus = cls.getMethod(
  182 + "setSoftInputShownOnFocus", boolean.class);
  183 + setSoftInputShownOnFocus.setAccessible(true);
  184 + setSoftInputShownOnFocus.invoke(message, false);
  185 + } catch (Exception e) {
  186 + }
  187 + }
  188 +
  189 + }
  190 +
  191 + @Override
  192 + public void onClick(View v) {
  193 + int index = 0;
  194 + Editable editable = null;
  195 + if (idEdit.isFocused()) {
  196 + LogUtil.d(TAG, "获取到了焦点");
  197 + index = idEdit.getSelectionStart();
  198 + editable = idEdit.getText();
  199 + }
  200 +
  201 + switch (v.getId()) {
  202 + case R.id.topBtns:
  203 + String str = idEdit.getText().toString();
  204 +
  205 + if (!RegexUtils.checkIdCard(str)) {
  206 + MToast(InputIdCardActivity.this,
  207 + getString(R.string.the_idcard_not_valid),
  208 + MToast.LENGTH_SHORT);
  209 + idEdit.setText("");
  210 + return;
  211 + }
  212 + Intent intent = new Intent(InputIdCardActivity.this,
  213 + IDOrderListActivity.class);
  214 + CountDownTimer.firstTime = new Date().getTime();// 不必要的可以删除
  215 + intent.putExtra("mode", 0);
  216 + intent.putExtra("idcardNumber", str);
  217 + intent.putExtra("titleName", getString(R.string.order_list));
  218 + startActivity(intent);
  219 +
  220 + break;
  221 + case R.id.delete:
  222 + if (idEdit.isFocused()) {
  223 + index = idEdit.getSelectionStart();
  224 + editable = idEdit.getText();
  225 + }
  226 + if (editable.length() > 0) {
  227 + try {
  228 + editable.delete(index - 1, index);
  229 + } catch (Exception e) {
  230 + if (editable.length() > 0) {
  231 + editable.delete(index, index + 1);
  232 + }
  233 + }
  234 + }
  235 + break;
  236 + default:
  237 + if (editable.length() < 18) {
  238 + editable.insert(index, ((TextView) v).getText());
  239 + }
  240 + break;
  241 + }
  242 + }
  243 +
  244 + @Override
  245 + public boolean onKeyDown(int keyCode, KeyEvent event) {
  246 + if (keyCode == KeyEvent.KEYCODE_BACK) {
  247 + try {
  248 + CommetryUtils.releaseCommery(this);
  249 + } catch (Exception e) {
  250 + e.printStackTrace();
  251 + }
  252 +
  253 + finish();
  254 +
  255 + }
  256 + return false;
  257 + }
  258 +
  259 + @Override
  260 + protected void onDestroy() {
  261 + super.onDestroy();
  262 +
  263 + try {
  264 + CommetryUtils.releaseCommery(this);
  265 + } catch (Exception e) {
  266 + e.printStackTrace();
  267 + }
  268 + }
  269 +
  270 + @Override
  271 + public void repeatAction() {
  272 + int index = 0;
  273 + Editable editable = null;
  274 + if (idEdit.isFocused()) {
  275 + index = idEdit.getSelectionStart();
  276 + editable = idEdit.getText();
  277 + }
  278 + if (editable.length() > 0) {
  279 + try {
  280 + editable.delete(index - 1, index);
  281 + } catch (Exception e) {
  282 + if (editable.length() > 0) {
  283 + editable.delete(index, index + 1);
  284 + }
  285 + }
  286 + }
  287 + }
  288 +
  289 + /**************************查询成功的情况下,清空输入框*****************************/
  290 + BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
  291 + @Override
  292 + public void onReceive(Context context, Intent intent) {
  293 + boolean sucess = intent.getExtras().getBoolean("sucess", false);
  294 + if (sucess) {
  295 + idEdit.setText("");
  296 + }
  297 + }
  298 + };
286 299 }
... ...
src/com/ectrip/cyt/ui/InputOridActivity.java
... ... @@ -28,279 +28,292 @@ import com.ectrip.trips.view.LongClickButton.LongClickRepeatListener;
28 28  
29 29 /**
30 30 * @author jigo 输入订单
31   - *
32 31 */
33 32 public class InputOridActivity extends BaseActivity implements
34   - View.OnClickListener, LongClickRepeatListener {
  33 + View.OnClickListener, LongClickRepeatListener {
35 34  
36   - private String titleName;
  35 + private String titleName;
37 36  
38   - private EditText oridEdit, pwdEdit;
  37 + private EditText oridEdit, pwdEdit;
39 38  
40   - private TextView two, three, four, five, six, seven, eight, nine, zero,
41   - X_btn, topBtns;
42   - private LongClickButton delete;
43   - private TextView one;
44   - private View one_layout;
  39 + private TextView two, three, four, five, six, seven, eight, nine, zero,
  40 + X_btn, topBtns;
  41 + private LongClickButton delete;
  42 + private TextView one;
  43 + private View one_layout;
45 44  
46   - @Override
47   - protected void onCreate(Bundle savedInstanceState) {
48   - super.onCreate(savedInstanceState);
49   - setContentView(R.layout.app_input_orid);
50   - ActivitiesManager.getInstance().pushActivity(this);
51   - initConfig();
52   - initView();
53   - initReceiver();
54   - }
  45 + @Override
  46 + protected void onCreate(Bundle savedInstanceState) {
  47 + super.onCreate(savedInstanceState);
  48 + setContentView(R.layout.app_input_orid);
  49 + ActivitiesManager.getInstance().pushActivity(this);
  50 + initConfig();
  51 + initView();
  52 + initReceiver();
  53 + }
55 54  
56   - private void initReceiver() {
  55 + private void initReceiver() {
57 56 // IntentFilter filter = new IntentFilter("cyt.orid.action");
58 57 // registerReceiver(broadcastReceiver, filter);
59   - }
60   -
61   - private void textViewShow(EditText message) {
62   -
63   - if (android.os.Build.VERSION.SDK_INT <= 10) {
64   - message.setInputType(InputType.TYPE_NULL);
65   - } else {
66   - getWindow().setSoftInputMode(
67   - WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
68   - try {
69   - Class<EditText> cls = EditText.class;
70   - Method setSoftInputShownOnFocus = cls.getMethod(
71   - "setSoftInputShownOnFocus", boolean.class);
72   - setSoftInputShownOnFocus.setAccessible(true);
73   - setSoftInputShownOnFocus.invoke(message, false);
74   - } catch (Exception e) {
75   - }
76   - }
77   -
78   - }
79   -
80   - private void initConfig() {
81   - titleName = getIntent().getStringExtra("titleName");
82   - ((TextView) findViewById(R.id.title))
83   - .setText(titleName == null ? getString(R.string.app_name)
84   - : titleName);
85   - findViewById(R.id.topBack).setOnClickListener(new OnClickListener() {
86   -
87   - @Override
88   - public void onClick(View arg0) {
89   - finish();
90   - }
91   - });
92   - }
93   -
94   - @SuppressLint("NewApi")
95   - private void initView() {
96   - SharedPreferences2Obj.getInstance(InputOridActivity.this)
97   - .setName("SelectAction").setObject("isStatistic", "0"); // 非统计
98   - titleName = getIntent().getStringExtra("titleName");
99   - if (titleName != null) {
100   - ((TextView) findViewById(R.id.title)).setText(titleName);
101   - } else {
102   - ((TextView) findViewById(R.id.title))
103   - .setText(R.string.input_order_id);
104   - }
105   - ((TextView) findViewById(R.id.title)).setVisibility(View.VISIBLE);
106   - oridEdit = (EditText) findViewById(R.id.input_orid);
107   - pwdEdit = (EditText) findViewById(R.id.input_pwd);
108   - int Select = SharedPreferences2Obj.getInstance(InputOridActivity.this)
109   - .setName("SelectAction").getObject("Select", Integer.class);
110   - if (Select == 2) {
111   - findViewById(R.id.layout02).setVisibility(View.GONE);
112   - findViewById(R.id.line).setVisibility(View.GONE);
113   - pwdEdit.setVisibility(View.GONE);
114   - findViewById(R.id.pwdText).setVisibility(View.GONE);
115   - }
116   -
117   - topBtns = (Button) findViewById(R.id.topBtns);
118   - topBtns.setVisibility(View.VISIBLE);
119   - one = (TextView) findViewById(R.id.one);
120   - one.setOnClickListener(this);
121   - // one.setTextColor(0X00000000);
122   -
123   - one_layout = findViewById(R.id.one_layout);
124   - one_layout.setOnTouchListener(new OnTouchListener() {
125   - @SuppressLint("ClickableViewAccessibility")
126   - @Override
127   - public boolean onTouch(View arg0, MotionEvent arg1) {
128   - if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
129   - arg0.setBackgroundColor(Color.BLACK);
130   - return false;
131   - } else if (arg1.getAction() == MotionEvent.ACTION_UP) {
132   - arg0.setBackgroundColor(Color.WHITE);
133   - return false;
134   - }
135   - return false;
136   - }
137   - });
138   -
139   - two = (TextView) findViewById(R.id.two);
140   - two.setOnClickListener(this);
141   -
142   - three = (TextView) findViewById(R.id.three);
143   - three.setOnClickListener(this);
144   -
145   - four = (TextView) findViewById(R.id.four);
146   - four.setOnClickListener(this);
147   -
148   - five = (TextView) findViewById(R.id.five);
149   - five.setOnClickListener(this);
150   -
151   - six = (TextView) findViewById(R.id.six);
152   - six.setOnClickListener(this);
153   -
154   - seven = (TextView) findViewById(R.id.seven);
155   - seven.setOnClickListener(this);
156   -
157   - eight = (TextView) findViewById(R.id.eight);
158   - eight.setOnClickListener(this);
159   -
160   - nine = (TextView) findViewById(R.id.nine);
161   - nine.setOnClickListener(this);
162   -
163   - zero = (TextView) findViewById(R.id.zero);
164   - zero.setOnClickListener(this);
165   -
166   - X_btn = (TextView) findViewById(R.id.X_btn);
167   - X_btn.setOnClickListener(this);
168   -
169   - delete = (LongClickButton) findViewById(R.id.delete);
170   - delete.setLongClickRepeatListener(this);
171   - delete.setOnClickListener(this);
172   -
173   - topBtns.setText(getString(R.string.topbtn_ok));
174   - topBtns.setOnClickListener(this);
175   -
176   - textViewShow(oridEdit);
177   - if (Select != 2) {
178   - textViewShow(pwdEdit);
179   - }
180   -
181   - if (android.os.Build.VERSION.SDK_INT >= 11) {
182   - try {
183   - oridEdit.setShowSoftInputOnFocus(false);
184   - pwdEdit.setShowSoftInputOnFocus(false);
185   - } catch (Exception e) {
186   - e.printStackTrace();
187   - textViewShow(oridEdit);
188   - textViewShow(pwdEdit);
189   - } catch (Throwable e) {
190   - e.printStackTrace();
191   - textViewShow(oridEdit);
192   - textViewShow(pwdEdit);
193   - }
194   - } else {
195   - textViewShow(oridEdit);
196   - textViewShow(pwdEdit);
197   - }
198   - }
199   -
200   - @Override
201   - public void onClick(View v) {
202   - int index = 0;
203   - Editable editable = null;
204   -
205   - if (oridEdit.isFocused()) {
206   - index = oridEdit.getSelectionStart();
207   - editable = oridEdit.getText();
208   - } else {
209   - index = pwdEdit.getSelectionStart();
210   - editable = pwdEdit.getText();
211   - }
212   - switch (v.getId()) {
213   - case R.id.topBtns:
214   - String input_oridStr = oridEdit.getText().toString().trim();
215   - String input_pwdStr;
216   - int Select = SharedPreferences2Obj
217   - .getInstance(InputOridActivity.this)
218   - .setName("SelectAction").getObject("Select", Integer.class);
219   - if (Select != 2) {
220   - input_pwdStr = pwdEdit.getText().toString().trim();
221   - } else {
222   - input_pwdStr = "";
223   - }
224   -
225   - if (input_oridStr == null || "".equals(input_oridStr)) {
226   - MToast(InputOridActivity.this,
227   - getString(R.string.order_id_not_null),
228   - MToast.LENGTH_SHORT);
229   - return;
230   - }
231   -
232   - if (Select != 2) {
233   - if (input_pwdStr == null || "".equals(input_pwdStr)) {
234   - MToast(InputOridActivity.this,
235   - getString(R.string.pwd_not_null),
236   - MToast.LENGTH_SHORT);
237   - return;
238   - }
239   - }
240   -
241   - Intent intent = new Intent(InputOridActivity.this,
242   - InputOrderListActivity.class);
243   - intent.putExtra("input_orid", input_oridStr);
244   - intent.putExtra("input_pwd", input_pwdStr);
245   - intent.putExtra("titleName", getString(R.string.show_result));
246   - intent.putExtra("mode", 2);
247   - startActivity(intent);
248   -
249   - break;
250   - case R.id.delete:
251   - if (editable.length() > 0) {
252   - try {
253   - editable.delete(index - 1, index);
254   - } catch (Exception e) {
255   - if (editable.length() > 0) {
256   - editable.delete(index, index + 1);
257   - }
258   - }
259   - }
260   - break;
261   - default:
262   -
263   - if (editable.length() < 18) {
264   - editable.insert(index, ((TextView) v).getText());
265   - }
266   - break;
267   -
268   - }
269   - }
270   -
271   - @Override
272   - public boolean onKeyDown(int keyCode, KeyEvent event) {
273   - if (keyCode == KeyEvent.KEYCODE_BACK) {
274   - try {
275   - CommetryUtils.releaseCommery(this);
276   - } catch (Exception e) {
277   - e.printStackTrace();
278   - }
279   - finish();
280   - }
281   - return false;
282   - }
283   -
284   - @Override
285   - public void repeatAction() {
286   - int index = 0;
287   - Editable editable = null;
288   -
289   - if (oridEdit.isFocused()) {
290   - index = oridEdit.getSelectionStart();
291   - editable = oridEdit.getText();
292   - } else {
293   - index = pwdEdit.getSelectionStart();
294   - editable = pwdEdit.getText();
295   - }
296   - if (editable.length() > 0) {
297   - try {
298   - editable.delete(index - 1, index);
299   - } catch (Exception e) {
300   - if (editable.length() > 0) {
301   - editable.delete(index, index + 1);
302   - }
303   - }
304   - }
305   - }
  58 + }
  59 +
  60 + private void textViewShow(EditText message) {
  61 +
  62 + if (android.os.Build.VERSION.SDK_INT <= 10) {
  63 + message.setInputType(InputType.TYPE_NULL);
  64 + } else {
  65 + getWindow().setSoftInputMode(
  66 + WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  67 + try {
  68 + Class<EditText> cls = EditText.class;
  69 + Method setSoftInputShownOnFocus = cls.getMethod(
  70 + "setSoftInputShownOnFocus", boolean.class);
  71 + setSoftInputShownOnFocus.setAccessible(true);
  72 + setSoftInputShownOnFocus.invoke(message, false);
  73 + } catch (Exception e) {
  74 + }
  75 + }
  76 +
  77 + }
  78 +
  79 + private void initConfig() {
  80 + titleName = getIntent().getStringExtra("titleName");
  81 + ((TextView) findViewById(R.id.title))
  82 + .setText(titleName == null ? getString(R.string.app_name)
  83 + : titleName);
  84 + findViewById(R.id.topBack).setOnClickListener(new OnClickListener() {
  85 +
  86 + @Override
  87 + public void onClick(View arg0) {
  88 + finish();
  89 + }
  90 + });
  91 + }
  92 +
  93 + @SuppressLint("NewApi")
  94 + private void initView() {
  95 + SharedPreferences2Obj.getInstance(InputOridActivity.this)
  96 + .setName("SelectAction").setObject("isStatistic", "0"); // 非统计
  97 + titleName = getIntent().getStringExtra("titleName");
  98 + if (titleName != null) {
  99 + ((TextView) findViewById(R.id.title)).setText(titleName);
  100 + } else {
  101 + ((TextView) findViewById(R.id.title))
  102 + .setText(R.string.input_order_id);
  103 + }
  104 + ((TextView) findViewById(R.id.title)).setVisibility(View.VISIBLE);
  105 + oridEdit = (EditText) findViewById(R.id.input_orid);
  106 + pwdEdit = (EditText) findViewById(R.id.input_pwd);
  107 + int Select = SharedPreferences2Obj.getInstance(InputOridActivity.this)
  108 + .setName("SelectAction").getObject("Select", Integer.class);
  109 + if (Select == 2) {
  110 + findViewById(R.id.layout02).setVisibility(View.GONE);
  111 + findViewById(R.id.line).setVisibility(View.GONE);
  112 + pwdEdit.setVisibility(View.GONE);
  113 + findViewById(R.id.pwdText).setVisibility(View.GONE);
  114 + }
  115 +
  116 + topBtns = (Button) findViewById(R.id.topBtns);
  117 + topBtns.setVisibility(View.VISIBLE);
  118 + one = (TextView) findViewById(R.id.one);
  119 + one.setOnClickListener(this);
  120 + // one.setTextColor(0X00000000);
  121 +
  122 + one_layout = findViewById(R.id.one_layout);
  123 + one_layout.setOnTouchListener(new OnTouchListener() {
  124 + @SuppressLint("ClickableViewAccessibility")
  125 + @Override
  126 + public boolean onTouch(View arg0, MotionEvent arg1) {
  127 + if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
  128 + arg0.setBackgroundColor(Color.BLACK);
  129 + return false;
  130 + } else if (arg1.getAction() == MotionEvent.ACTION_UP) {
  131 + arg0.setBackgroundColor(Color.WHITE);
  132 + return false;
  133 + }
  134 + return false;
  135 + }
  136 + });
  137 +
  138 + two = (TextView) findViewById(R.id.two);
  139 + two.setOnClickListener(this);
  140 +
  141 + three = (TextView) findViewById(R.id.three);
  142 + three.setOnClickListener(this);
  143 +
  144 + four = (TextView) findViewById(R.id.four);
  145 + four.setOnClickListener(this);
  146 +
  147 + five = (TextView) findViewById(R.id.five);
  148 + five.setOnClickListener(this);
  149 +
  150 + six = (TextView) findViewById(R.id.six);
  151 + six.setOnClickListener(this);
  152 +
  153 + seven = (TextView) findViewById(R.id.seven);
  154 + seven.setOnClickListener(this);
  155 +
  156 + eight = (TextView) findViewById(R.id.eight);
  157 + eight.setOnClickListener(this);
  158 +
  159 + nine = (TextView) findViewById(R.id.nine);
  160 + nine.setOnClickListener(this);
  161 +
  162 + zero = (TextView) findViewById(R.id.zero);
  163 + zero.setOnClickListener(this);
  164 +
  165 + X_btn = (TextView) findViewById(R.id.X_btn);
  166 + X_btn.setOnClickListener(this);
  167 +
  168 + delete = (LongClickButton) findViewById(R.id.delete);
  169 + delete.setLongClickRepeatListener(this);
  170 + delete.setOnClickListener(this);
  171 +
  172 + topBtns.setText(getString(R.string.topbtn_ok));
  173 + topBtns.setOnClickListener(this);
  174 +
  175 + textViewShow(oridEdit);
  176 + if (Select != 2) {
  177 + textViewShow(pwdEdit);
  178 + }
  179 +
  180 + if (android.os.Build.VERSION.SDK_INT >= 28) {
  181 + try {
  182 + oridEdit.setShowSoftInputOnFocus(false);
  183 + pwdEdit.setShowSoftInputOnFocus(false);
  184 + oridEdit.requestFocus();
  185 + } catch (Exception e) {
  186 + e.printStackTrace();
  187 + textViewShow(oridEdit);
  188 + textViewShow(pwdEdit);
  189 + } catch (Throwable e) {
  190 + e.printStackTrace();
  191 + textViewShow(oridEdit);
  192 + textViewShow(pwdEdit);
  193 + }
  194 + } else if (android.os.Build.VERSION.SDK_INT >= 11) {
  195 + try {
  196 + oridEdit.setShowSoftInputOnFocus(false);
  197 + pwdEdit.setShowSoftInputOnFocus(false);
  198 + } catch (Exception e) {
  199 + e.printStackTrace();
  200 + textViewShow(oridEdit);
  201 + textViewShow(pwdEdit);
  202 + } catch (Throwable e) {
  203 + e.printStackTrace();
  204 + textViewShow(oridEdit);
  205 + textViewShow(pwdEdit);
  206 + }
  207 + } else {
  208 + textViewShow(oridEdit);
  209 + textViewShow(pwdEdit);
  210 + }
  211 + }
  212 +
  213 + @Override
  214 + public void onClick(View v) {
  215 + int index = 0;
  216 + Editable editable = null;
  217 +
  218 + if (oridEdit.isFocused()) {
  219 + index = oridEdit.getSelectionStart();
  220 + editable = oridEdit.getText();
  221 + } else {
  222 + index = pwdEdit.getSelectionStart();
  223 + editable = pwdEdit.getText();
  224 + }
  225 + switch (v.getId()) {
  226 + case R.id.topBtns:
  227 + String input_oridStr = oridEdit.getText().toString().trim();
  228 + String input_pwdStr;
  229 + int Select = SharedPreferences2Obj
  230 + .getInstance(InputOridActivity.this)
  231 + .setName("SelectAction").getObject("Select", Integer.class);
  232 + if (Select != 2) {
  233 + input_pwdStr = pwdEdit.getText().toString().trim();
  234 + } else {
  235 + input_pwdStr = "";
  236 + }
  237 +
  238 + if (input_oridStr == null || "".equals(input_oridStr)) {
  239 + MToast(InputOridActivity.this,
  240 + getString(R.string.order_id_not_null),
  241 + MToast.LENGTH_SHORT);
  242 + return;
  243 + }
  244 +
  245 + if (Select != 2) {
  246 + if (input_pwdStr == null || "".equals(input_pwdStr)) {
  247 + MToast(InputOridActivity.this,
  248 + getString(R.string.pwd_not_null),
  249 + MToast.LENGTH_SHORT);
  250 + return;
  251 + }
  252 + }
  253 +
  254 + Intent intent = new Intent(InputOridActivity.this,
  255 + InputOrderListActivity.class);
  256 + intent.putExtra("input_orid", input_oridStr);
  257 + intent.putExtra("input_pwd", input_pwdStr);
  258 + intent.putExtra("titleName", getString(R.string.show_result));
  259 + intent.putExtra("mode", 2);
  260 + startActivity(intent);
  261 +
  262 + break;
  263 + case R.id.delete:
  264 + if (editable.length() > 0) {
  265 + try {
  266 + editable.delete(index - 1, index);
  267 + } catch (Exception e) {
  268 + if (editable.length() > 0) {
  269 + editable.delete(index, index + 1);
  270 + }
  271 + }
  272 + }
  273 + break;
  274 + default:
  275 +
  276 + if (editable.length() < 18) {
  277 + editable.insert(index, ((TextView) v).getText());
  278 + }
  279 + break;
  280 +
  281 + }
  282 + }
  283 +
  284 + @Override
  285 + public boolean onKeyDown(int keyCode, KeyEvent event) {
  286 + if (keyCode == KeyEvent.KEYCODE_BACK) {
  287 + try {
  288 + CommetryUtils.releaseCommery(this);
  289 + } catch (Exception e) {
  290 + e.printStackTrace();
  291 + }
  292 + finish();
  293 + }
  294 + return false;
  295 + }
  296 +
  297 + @Override
  298 + public void repeatAction() {
  299 + int index = 0;
  300 + Editable editable = null;
  301 +
  302 + if (oridEdit.isFocused()) {
  303 + index = oridEdit.getSelectionStart();
  304 + editable = oridEdit.getText();
  305 + } else {
  306 + index = pwdEdit.getSelectionStart();
  307 + editable = pwdEdit.getText();
  308 + }
  309 + if (editable.length() > 0) {
  310 + try {
  311 + editable.delete(index - 1, index);
  312 + } catch (Exception e) {
  313 + if (editable.length() > 0) {
  314 + editable.delete(index, index + 1);
  315 + }
  316 + }
  317 + }
  318 + }
306 319 }
... ...
src/com/ectrip/cyt/ui/InputPhoneActivity.java
... ... @@ -31,244 +31,256 @@ import com.ectrip.trips.view.LongClickButton.LongClickRepeatListener;
31 31 * 手机号输入界面
32 32 */
33 33 public class InputPhoneActivity extends BaseActivity implements
34   - View.OnClickListener, LongClickRepeatListener {
  34 + View.OnClickListener, LongClickRepeatListener {
35 35  
36   - private String titleName;
37   - private EditText phoneEdit;// 手机号
38   - private TextView one, two, three, four, five, six, seven, eight, nine,
39   - zero, X_btn, topBtns;
40   - private LongClickButton delete;
  36 + private String titleName;
  37 + private EditText phoneEdit;// 手机号
  38 + private TextView one, two, three, four, five, six, seven, eight, nine,
  39 + zero, X_btn, topBtns;
  40 + private LongClickButton delete;
41 41  
42   - @Override
43   - protected void onCreate(Bundle savedInstanceState) {
44   - super.onCreate(savedInstanceState);
45   - setContentView(R.layout.app_input_idcard);
46   - ActivitiesManager.getInstance().pushActivity(this);
47   - initView();
48   - initReceiver();
49   - }
  42 + @Override
  43 + protected void onCreate(Bundle savedInstanceState) {
  44 + super.onCreate(savedInstanceState);
  45 + setContentView(R.layout.app_input_idcard);
  46 + ActivitiesManager.getInstance().pushActivity(this);
  47 + initView();
  48 + initReceiver();
  49 + }
50 50  
51   - private void initReceiver() {
52   - IntentFilter filter = new IntentFilter("cyt.phone.action");
53   - registerReceiver(broadcastReceiver,filter);
54   - }
  51 + private void initReceiver() {
  52 + IntentFilter filter = new IntentFilter("cyt.phone.action");
  53 + registerReceiver(broadcastReceiver, filter);
  54 + }
55 55  
56   - @Override
57   - protected void onPause() {
58   - super.onPause();
  56 + @Override
  57 + protected void onPause() {
  58 + super.onPause();
59 59  
60 60  
61 61 // unregisterReceiver(broadcastReceiver);
62   - }
63   - @SuppressLint("NewApi")
64   - private void initView() {
65   - SharedPreferences2Obj.getInstance(InputPhoneActivity.this)
66   - .setName("SelectAction").setObject("isStatistic", "0"); // 非统计
67   - titleName = getIntent().getStringExtra("titleName");
68   - if (titleName != null) {
69   - ((TextView) findViewById(R.id.title)).setText(titleName);
70   - } else {
71   - ((TextView) findViewById(R.id.title)).setText(R.string.input_phone);
72   - }
73   - ((TextView) findViewById(R.id.title)).setVisibility(View.VISIBLE);
74   - findViewById(R.id.topBack).setOnClickListener(new OnClickListener() {
75   - @Override
76   - public void onClick(View v) {
77   - finish();
78   - }
79   - });
80   - topBtns = (Button) findViewById(R.id.topBtns);
81   - topBtns.setVisibility(View.VISIBLE);
82   -
83   - phoneEdit = (EditText) findViewById(R.id.input_idcard);
84   - phoneEdit.setHint(R.string.input_phone);
85   - one = (TextView) findViewById(R.id.one);
86   - one.setOnClickListener(this);
87   -
88   - two = (TextView) findViewById(R.id.two);
89   - two.setOnClickListener(this);
90   -
91   - three = (TextView) findViewById(R.id.three);
92   - three.setOnClickListener(this);
93   -
94   - four = (TextView) findViewById(R.id.four);
95   - four.setOnClickListener(this);
96   -
97   - five = (TextView) findViewById(R.id.five);
98   - five.setOnClickListener(this);
99   -
100   - six = (TextView) findViewById(R.id.six);
101   - six.setOnClickListener(this);
102   -
103   - seven = (TextView) findViewById(R.id.seven);
104   - seven.setOnClickListener(this);
105   -
106   - eight = (TextView) findViewById(R.id.eight);
107   - eight.setOnClickListener(this);
108   -
109   - nine = (TextView) findViewById(R.id.nine);
110   - nine.setOnClickListener(this);
111   -
112   - zero = (TextView) findViewById(R.id.zero);
113   - zero.setOnClickListener(this);
114   -
115   - X_btn = (TextView) findViewById(R.id.X_btn);
116   - X_btn.setOnClickListener(this);
117   -
118   - delete = (LongClickButton) findViewById(R.id.delete);
119   - delete.setOnClickListener(this);
120   - delete.setLongClickRepeatListener(this);
121   - topBtns.setText(R.string.topbtn_ok);
122   - topBtns.setOnClickListener(this);
123   -
124   - if (android.os.Build.VERSION.SDK_INT > 14) {
125   - try {
126   - phoneEdit.setShowSoftInputOnFocus(false);
127   - } catch (Exception e) {
128   - e.printStackTrace();
129   - textViewShow(phoneEdit);
130   - } catch (Throwable e) {
131   - e.printStackTrace();
132   - textViewShow(phoneEdit);
133   - }
134   - } else {
135   - textViewShow(phoneEdit);
136   - }
137   - }
138   -
139   - private void textViewShow(EditText message) {
140   -
141   - if (android.os.Build.VERSION.SDK_INT <= 10) {
142   - message.setInputType(InputType.TYPE_NULL);
143   - } else {
144   - getWindow().setSoftInputMode(
145   - WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
146   - try {
147   - Class<EditText> cls = EditText.class;
148   - Method setSoftInputShownOnFocus = cls.getMethod(
149   - "setSoftInputShownOnFocus", boolean.class);
150   - setSoftInputShownOnFocus.setAccessible(true);
151   - setSoftInputShownOnFocus.invoke(message, false);
152   - } catch (Exception e) {
153   - }
154   - }
155   -
156   - }
157   -
158   - @Override
159   - public void onClick(View v) {
160   - int index = 0;
161   - Editable editable = null;
162   - if (phoneEdit.isFocused()) {
163   - index = phoneEdit.getSelectionStart();
164   - editable = phoneEdit.getText();
165   - }
166   -
167   - switch (v.getId()) {
168   - case R.id.topBtns:
169   - String str = phoneEdit.getText().toString();
170   -
171   - if (str == null) {
172   - MToast(InputPhoneActivity.this,
173   - getString(R.string.fill_in_phone), MToast.LENGTH_SHORT);
174   - return;
175   - }
176   -
177   - if (!isNumeric(str)) {
178   - MToast(InputPhoneActivity.this,
179   - getString(R.string.phone_incorrect),
180   - MToast.LENGTH_SHORT);
181   - return;
182   - }
183   -
184   - Intent intent = new Intent(InputPhoneActivity.this,
185   - PhoneOrderListActivity.class);
186   - intent.putExtra("mode", 0);
187   - intent.putExtra("mobile", str);
188   - intent.putExtra("titleName", getString(R.string.order_list));
189   - startActivity(intent);
190   - break;
191   - case R.id.delete:
192   - if (editable.length() > 0) {
193   - try {
194   - editable.delete(index - 1, index);
195   - } catch (Exception e) {
196   - if (editable.length() > 0) {
197   - editable.delete(index, index + 1);
198   - }
199   - }
200   - }
201   - break;
202   - default:
203   - if (editable.length() < 18) {
204   - editable.insert(index, ((TextView) v).getText());
205   - }
206   - break;
207   - }
208   - }
209   -
210   - public boolean isNumeric(String str) {
211   - Pattern pattern = Pattern.compile("[0-9]*");
212   - if (pattern.matcher(str).matches() && str.length() == 11) {
213   - return true;
214   - } else {
215   - return false;
216   - }
217   - }
218   -
219   - @Override
220   - public boolean onKeyDown(int keyCode, KeyEvent event) {
221   - if (keyCode == KeyEvent.KEYCODE_BACK) {
222   - try {
223   - CommetryUtils.releaseCommery(this);
224   - } catch (Exception e) {
225   - e.printStackTrace();
226   - }
227   -
228   - finish();
229   -
230   - }
231   - return false;
232   - }
233   -
234   - @Override
235   - protected void onDestroy() {
236   - super.onDestroy();
237   - unregisterReceiver(broadcastReceiver);
238   - try {
239   - CommetryUtils.releaseCommery(this);
240   - } catch (Exception e) {
241   - e.printStackTrace();
242   - }
243   - }
244   -
245   - @Override
246   - public void repeatAction() {
247   - int index = 0;
248   - Editable editable = null;
249   - if (phoneEdit.isFocused()) {
250   - index = phoneEdit.getSelectionStart();
251   - editable = phoneEdit.getText();
252   - }
253   - if (editable.length() > 0) {
254   - try {
255   - editable.delete(index - 1, index);
256   - } catch (Exception e) {
257   - if (editable.length() > 0) {
258   - editable.delete(index, index + 1);
259   - }
260   - }
261   - }
262   - }
263   -
264   - /**************************查询成功的情况下,清空输入框*****************************/
265   - BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
266   - @Override
267   - public void onReceive(Context context, Intent intent){
268   - boolean sucess=intent.getExtras().getBoolean("sucess",false);
269   - if(sucess){
270   - phoneEdit.setText("");
271   - }
272   - }
273   - };
  62 + }
  63 +
  64 + @SuppressLint("NewApi")
  65 + private void initView() {
  66 + SharedPreferences2Obj.getInstance(InputPhoneActivity.this)
  67 + .setName("SelectAction").setObject("isStatistic", "0"); // 非统计
  68 + titleName = getIntent().getStringExtra("titleName");
  69 + if (titleName != null) {
  70 + ((TextView) findViewById(R.id.title)).setText(titleName);
  71 + } else {
  72 + ((TextView) findViewById(R.id.title)).setText(R.string.input_phone);
  73 + }
  74 + ((TextView) findViewById(R.id.title)).setVisibility(View.VISIBLE);
  75 + findViewById(R.id.topBack).setOnClickListener(new OnClickListener() {
  76 + @Override
  77 + public void onClick(View v) {
  78 + finish();
  79 + }
  80 + });
  81 + topBtns = (Button) findViewById(R.id.topBtns);
  82 + topBtns.setVisibility(View.VISIBLE);
  83 +
  84 + phoneEdit = (EditText) findViewById(R.id.input_idcard);
  85 + phoneEdit.setHint(R.string.input_phone);
  86 + one = (TextView) findViewById(R.id.one);
  87 + one.setOnClickListener(this);
  88 +
  89 + two = (TextView) findViewById(R.id.two);
  90 + two.setOnClickListener(this);
  91 +
  92 + three = (TextView) findViewById(R.id.three);
  93 + three.setOnClickListener(this);
  94 +
  95 + four = (TextView) findViewById(R.id.four);
  96 + four.setOnClickListener(this);
  97 +
  98 + five = (TextView) findViewById(R.id.five);
  99 + five.setOnClickListener(this);
  100 +
  101 + six = (TextView) findViewById(R.id.six);
  102 + six.setOnClickListener(this);
  103 +
  104 + seven = (TextView) findViewById(R.id.seven);
  105 + seven.setOnClickListener(this);
  106 +
  107 + eight = (TextView) findViewById(R.id.eight);
  108 + eight.setOnClickListener(this);
  109 +
  110 + nine = (TextView) findViewById(R.id.nine);
  111 + nine.setOnClickListener(this);
  112 +
  113 + zero = (TextView) findViewById(R.id.zero);
  114 + zero.setOnClickListener(this);
  115 +
  116 + X_btn = (TextView) findViewById(R.id.X_btn);
  117 + X_btn.setOnClickListener(this);
  118 +
  119 + delete = (LongClickButton) findViewById(R.id.delete);
  120 + delete.setOnClickListener(this);
  121 + delete.setLongClickRepeatListener(this);
  122 + topBtns.setText(R.string.topbtn_ok);
  123 + topBtns.setOnClickListener(this);
  124 +
  125 + if (android.os.Build.VERSION.SDK_INT >= 28) {
  126 + try {
  127 + phoneEdit.setShowSoftInputOnFocus(false);
  128 + phoneEdit.requestFocus();
  129 + } catch (Exception e) {
  130 + e.printStackTrace();
  131 + textViewShow(phoneEdit);
  132 + } catch (Throwable e) {
  133 + e.printStackTrace();
  134 + textViewShow(phoneEdit);
  135 + }
  136 + } else if (android.os.Build.VERSION.SDK_INT >= 11) {
  137 + try {
  138 + phoneEdit.setShowSoftInputOnFocus(false);
  139 + } catch (Exception e) {
  140 + e.printStackTrace();
  141 + textViewShow(phoneEdit);
  142 + } catch (Throwable e) {
  143 + e.printStackTrace();
  144 + textViewShow(phoneEdit);
  145 + }
  146 + } else {
  147 + textViewShow(phoneEdit);
  148 + }
  149 + }
  150 +
  151 + private void textViewShow(EditText message) {
  152 +
  153 + if (android.os.Build.VERSION.SDK_INT <= 10) {
  154 + message.setInputType(InputType.TYPE_NULL);
  155 + } else {
  156 + getWindow().setSoftInputMode(
  157 + WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  158 + try {
  159 + Class<EditText> cls = EditText.class;
  160 + Method setSoftInputShownOnFocus = cls.getMethod(
  161 + "setSoftInputShownOnFocus", boolean.class);
  162 + setSoftInputShownOnFocus.setAccessible(true);
  163 + setSoftInputShownOnFocus.invoke(message, false);
  164 + } catch (Exception e) {
  165 + }
  166 + }
  167 +
  168 + }
  169 +
  170 + @Override
  171 + public void onClick(View v) {
  172 + int index = 0;
  173 + Editable editable = null;
  174 + if (phoneEdit.isFocused()) {
  175 + index = phoneEdit.getSelectionStart();
  176 + editable = phoneEdit.getText();
  177 + }
  178 +
  179 + switch (v.getId()) {
  180 + case R.id.topBtns:
  181 + String str = phoneEdit.getText().toString();
  182 +
  183 + if (str == null) {
  184 + MToast(InputPhoneActivity.this,
  185 + getString(R.string.fill_in_phone), MToast.LENGTH_SHORT);
  186 + return;
  187 + }
  188 +
  189 + if (!isNumeric(str)) {
  190 + MToast(InputPhoneActivity.this,
  191 + getString(R.string.phone_incorrect),
  192 + MToast.LENGTH_SHORT);
  193 + return;
  194 + }
  195 +
  196 + Intent intent = new Intent(InputPhoneActivity.this,
  197 + PhoneOrderListActivity.class);
  198 + intent.putExtra("mode", 0);
  199 + intent.putExtra("mobile", str);
  200 + intent.putExtra("titleName", getString(R.string.order_list));
  201 + startActivity(intent);
  202 + break;
  203 + case R.id.delete:
  204 + if (editable.length() > 0) {
  205 + try {
  206 + editable.delete(index - 1, index);
  207 + } catch (Exception e) {
  208 + if (editable.length() > 0) {
  209 + editable.delete(index, index + 1);
  210 + }
  211 + }
  212 + }
  213 + break;
  214 + default:
  215 + if (editable.length() < 18) {
  216 + editable.insert(index, ((TextView) v).getText());
  217 + }
  218 + break;
  219 + }
  220 + }
  221 +
  222 + public boolean isNumeric(String str) {
  223 + Pattern pattern = Pattern.compile("[0-9]*");
  224 + if (pattern.matcher(str).matches() && str.length() == 11) {
  225 + return true;
  226 + } else {
  227 + return false;
  228 + }
  229 + }
  230 +
  231 + @Override
  232 + public boolean onKeyDown(int keyCode, KeyEvent event) {
  233 + if (keyCode == KeyEvent.KEYCODE_BACK) {
  234 + try {
  235 + CommetryUtils.releaseCommery(this);
  236 + } catch (Exception e) {
  237 + e.printStackTrace();
  238 + }
  239 +
  240 + finish();
  241 +
  242 + }
  243 + return false;
  244 + }
  245 +
  246 + @Override
  247 + protected void onDestroy() {
  248 + super.onDestroy();
  249 + unregisterReceiver(broadcastReceiver);
  250 + try {
  251 + CommetryUtils.releaseCommery(this);
  252 + } catch (Exception e) {
  253 + e.printStackTrace();
  254 + }
  255 + }
  256 +
  257 + @Override
  258 + public void repeatAction() {
  259 + int index = 0;
  260 + Editable editable = null;
  261 + if (phoneEdit.isFocused()) {
  262 + index = phoneEdit.getSelectionStart();
  263 + editable = phoneEdit.getText();
  264 + }
  265 + if (editable.length() > 0) {
  266 + try {
  267 + editable.delete(index - 1, index);
  268 + } catch (Exception e) {
  269 + if (editable.length() > 0) {
  270 + editable.delete(index, index + 1);
  271 + }
  272 + }
  273 + }
  274 + }
  275 +
  276 + /**************************查询成功的情况下,清空输入框*****************************/
  277 + BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
  278 + @Override
  279 + public void onReceive(Context context, Intent intent) {
  280 + boolean sucess = intent.getExtras().getBoolean("sucess", false);
  281 + if (sucess) {
  282 + phoneEdit.setText("");
  283 + }
  284 + }
  285 + };
274 286 }
... ...
src/com/ectrip/cyt/ui/SettingsActivity.java
... ... @@ -18,6 +18,7 @@ import android.net.wifi.WifiInfo;
18 18 import android.net.wifi.WifiManager;
19 19 import android.os.Bundle;
20 20 import android.os.IBinder;
  21 +import android.provider.Settings;
21 22 import android.text.InputType;
22 23 import android.text.TextUtils;
23 24 import android.view.KeyEvent;
... ...
src/com/ectrip/cyt/ui/WelcomeActivity.java
1 1 package com.ectrip.cyt.ui;
2 2  
3 3 import java.io.InputStream;
  4 +import java.util.ArrayList;
  5 +import java.util.List;
4 6 import java.util.Timer;
5 7 import java.util.TimerTask;
6 8  
  9 +import android.Manifest;
  10 +import android.app.AlertDialog;
  11 +import android.content.DialogInterface;
7 12 import android.content.Intent;
  13 +import android.content.pm.PackageManager;
8 14 import android.content.res.Configuration;
9 15 import android.graphics.Bitmap;
10 16 import android.graphics.BitmapFactory;
  17 +import android.net.Uri;
  18 +import android.os.Build;
11 19 import android.os.Bundle;
  20 +import android.os.Environment;
  21 +import android.provider.Settings;
  22 +//import android.support.v4.app.ActivityCompat;
  23 +//import android.support.v4.content.ContextCompat;
  24 +import android.support.annotation.NonNull;
  25 +import android.support.annotation.Nullable;
  26 +import android.support.annotation.RequiresApi;
  27 +import android.support.v4.app.ActivityCompat;
  28 +import android.support.v4.content.ContextCompat;
12 29 import android.view.KeyEvent;
13 30 import android.widget.ImageView;
14 31 import android.widget.ImageView.ScaleType;
  32 +import android.widget.Toast;
15 33  
16 34 import com.ectrip.cyt.constant.LogoType;
17 35 import com.ectrip.cyt.constant.constant;
  36 +import com.ectrip.cyt.utils.LogUtil;
18 37 import com.ectrip.trips.check.R;
19 38  
20 39 public class WelcomeActivity extends BaseActivity {
... ... @@ -22,14 +41,22 @@ public class WelcomeActivity extends BaseActivity {
22 41 public final String TAG = "WelcomeActivity";
23 42  
24 43 private ImageView welcomeBg;
  44 + private static final int REQUEST_STORAGE_PERMISSION = 100;
  45 + private static final int REQUEST_MANAGE_STORAGE = 101;
  46 + private static final int INSTALL_PERMISS_CODE = 102;
  47 + private String[] permissions = {
  48 + Manifest.permission.READ_EXTERNAL_STORAGE,
  49 + Manifest.permission.WRITE_EXTERNAL_STORAGE
  50 + };
25 51  
26 52 @Override
27 53 protected void onCreate(Bundle savedInstanceState) {
28 54 super.onCreate(savedInstanceState);
29 55 setContentView(R.layout.app_welcome);
30 56 initView();
31   - Access();
  57 +// Access();
32 58 isScreenChange();
  59 + checkFilePermissions();
33 60 }
34 61  
35 62 private void initView(){
... ... @@ -91,6 +118,170 @@ public class WelcomeActivity extends BaseActivity {
91 118  
92 119 }
93 120  
  121 + private void checkFilePermissions() {
  122 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
  123 + // Android 11+
  124 + if (!Environment.isExternalStorageManager()) {
  125 + showManageStorageDialog();
  126 + } else {
  127 + // 已有权限
  128 + LogUtil.d(TAG, "Android 11+已有权限");
  129 + requestPermission();
  130 + }
  131 + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  132 + // Android 6.0-10
  133 + if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
  134 + != PackageManager.PERMISSION_GRANTED) {
  135 + ActivityCompat.requestPermissions(this, permissions, REQUEST_STORAGE_PERMISSION);
  136 + } else {
  137 + // 已有权限
  138 + LogUtil.d(TAG, "已有权限");
  139 + requestPermission();
  140 + }
  141 +
  142 + } else {
  143 + // Android 5.1及以下,无需动态申请
  144 + }
  145 + }
  146 +
  147 + private void showManageStorageDialog() {
  148 + new AlertDialog.Builder(this)
  149 + .setTitle("需要文件访问权限")
  150 + .setMessage("本应用需要访问设备上的文件以提供完整功能")
  151 + .setPositiveButton("去设置", new DialogInterface.OnClickListener() {
  152 + @Override
  153 + public void onClick(DialogInterface dialog, int which) {
  154 + Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
  155 + intent.setData(Uri.parse("package:" + getPackageName()));
  156 + startActivityForResult(intent, REQUEST_MANAGE_STORAGE);
  157 + }
  158 + })
  159 + .setNegativeButton("取消", new DialogInterface.OnClickListener() {
  160 + @Override
  161 + public void onClick(DialogInterface dialog, int which) {
  162 + finish();
  163 + System.exit(0);
  164 + }
  165 + })
  166 + .show();
  167 + }
  168 +
  169 + private void requestPermission() {
  170 + List<String> permissionsNeeded = new ArrayList<>();
  171 + if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
  172 + == PackageManager.PERMISSION_DENIED) {
  173 + permissionsNeeded.add(Manifest.permission.READ_PHONE_STATE);
  174 + }
  175 + if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
  176 + == PackageManager.PERMISSION_DENIED) {
  177 + permissionsNeeded.add(Manifest.permission.CAMERA);
  178 + }
  179 + if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
  180 + == PackageManager.PERMISSION_DENIED) {
  181 + permissionsNeeded.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
  182 + }
  183 + if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
  184 + == PackageManager.PERMISSION_DENIED) {
  185 + permissionsNeeded.add(Manifest.permission.READ_EXTERNAL_STORAGE);
  186 + }
  187 + if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
  188 + == PackageManager.PERMISSION_DENIED) {
  189 + permissionsNeeded.add(Manifest.permission.READ_PHONE_STATE);
  190 + }
  191 +// if (ContextCompat.checkSelfPermission(this, Manifest.permission.MANAGE_EXTERNAL_STORAGE)
  192 +// == PackageManager.PERMISSION_DENIED) {
  193 +// permissionsNeeded.add(Manifest.permission.MANAGE_EXTERNAL_STORAGE);
  194 +// }
  195 +
  196 + if (permissionsNeeded.size() > 0) {
  197 + ActivityCompat.requestPermissions(this, permissionsNeeded.toArray(new
  198 + String[permissionsNeeded.size()]), 1);
  199 + } else {
  200 + Access();
  201 + }
  202 + }
  203 +
  204 + @Override
  205 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  206 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  207 + switch (requestCode) {
  208 + case 1: {
  209 + boolean allowed = true;
  210 + if (grantResults.length > 0) {
  211 + for (int i = 0; i < grantResults.length; i++) {
  212 + if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
  213 + allowed = false;
  214 + }
  215 + }
  216 + }
  217 +
  218 + if (!allowed) {
  219 + Toast.makeText(this, "部分权限被拒绝,可能无法正常使用系统!", Toast.LENGTH_SHORT).show();
  220 + }
  221 + Access();
  222 + break;
  223 + }
  224 + }
  225 + }
  226 +
  227 + @RequiresApi(api = Build.VERSION_CODES.R)
  228 + @Override
  229 + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
  230 + super.onActivityResult(requestCode, resultCode, data);
  231 + if (requestCode == REQUEST_MANAGE_STORAGE) {
  232 +
  233 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
  234 + if (Environment.isExternalStorageManager()) {
  235 + // 用户已授予权限
  236 + LogUtil.d(TAG, "用户已授予文件权限");
  237 +// requestPermission();
  238 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  239 + boolean haveInstallPermission = getPackageManager().canRequestPackageInstalls();
  240 + LogUtil.d(TAG, "haveInstallPermission = " + haveInstallPermission);
  241 + if (!haveInstallPermission) {
  242 + //弹框提示用户手动打开
  243 + new AlertDialog.Builder(getBaseContext())
  244 + .setTitle("安装权限")
  245 + .setMessage("需要打开允许来自此来源,请去设置中开启此权限")
  246 + .setPositiveButton("去设置", new DialogInterface.OnClickListener() {
  247 + @Override
  248 + public void onClick(DialogInterface dialog, int which) {
  249 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  250 + //此方法需要API>=26才能使用
  251 +// toInstallPermissionSettingIntent();
  252 + }
  253 + }
  254 + })
  255 + .setNegativeButton("取消", new DialogInterface.OnClickListener() {
  256 + @Override
  257 + public void onClick(DialogInterface dialog, int which) {
  258 + dialog.dismiss();
  259 + }
  260 + })
  261 + .show();
  262 + } else {
  263 + requestPermission();
  264 + }
  265 + } else {
  266 + requestPermission();
  267 + }
  268 + } else {
  269 + // 用户拒绝授予权限
  270 + LogUtil.d(TAG, "用户拒绝授予文件权限");
  271 + }
  272 + }
  273 + } else if (requestCode == INSTALL_PERMISS_CODE) {
  274 + if (Environment.isExternalStorageManager()) {
  275 + // 用户已授予权限
  276 + LogUtil.d(TAG, "用户已授予应用安装权限");
  277 + requestPermission();
  278 + } else {
  279 + // 用户拒绝授予权限
  280 + LogUtil.d(TAG, "用户拒绝授予应用安装权限");
  281 + }
  282 + }
  283 + }
  284 +
94 285 @Override
95 286 protected void initNet() {
96 287 }
... ...
src/com/ectrip/trips/view/CheckSwitchButton.java
... ... @@ -320,10 +320,10 @@ public class CheckSwitchButton extends CheckBox {
320 320  
321 321 @Override
322 322 protected void onDraw(Canvas canvas) {
323   - canvas.saveLayerAlpha(mSaveLayerRectF, mAlpha, Canvas.MATRIX_SAVE_FLAG
324   - | Canvas.CLIP_SAVE_FLAG | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
325   - | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
326   - | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
  323 +// canvas.saveLayerAlpha(mSaveLayerRectF, mAlpha, Canvas.MATRIX_SAVE_FLAG
  324 +// | Canvas.CLIP_SAVE_FLAG | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
  325 +// | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
  326 +// | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
327 327 // canvas.saveLayerAlpha(mSaveLayerRectF, mAlpha, Canvas.ALL_SAVE_FLAG);
328 328 // 绘制蒙板
329 329 canvas.drawBitmap(mMask, 0, mExtendOffsetY, mPaint);
... ...