|
8 | 8 | import android.content.Context; |
9 | 9 | import android.content.Intent; |
10 | 10 | import android.content.SharedPreferences; |
| 11 | +import android.graphics.Color; |
11 | 12 | import android.graphics.drawable.BitmapDrawable; |
12 | 13 | import android.graphics.drawable.Drawable; |
13 | 14 | import android.net.Uri; |
|
20 | 21 | import android.provider.Settings; |
21 | 22 | import android.text.TextUtils; |
22 | 23 | import android.util.Log; |
| 24 | +import android.util.TypedValue; |
23 | 25 | import android.view.KeyEvent; |
24 | 26 | import android.view.View; |
25 | 27 | import android.view.Window; |
26 | 28 | import android.view.WindowManager; |
| 29 | +import android.widget.CheckBox; |
| 30 | +import android.widget.LinearLayout; |
| 31 | +import android.widget.TextView; |
27 | 32 | import android.widget.Toast; |
28 | 33 |
|
29 | 34 | import com.android.launcher3.LauncherFiles; |
@@ -78,6 +83,7 @@ public void onCreate(Bundle savedInstanceState) { |
78 | 83 | alertForMeizu(); |
79 | 84 | alertForDoze(); |
80 | 85 | mDirectlyBack = sharedPreferences.getBoolean(SettingsActivity.DIRECTLY_BACK_KEY, false); |
| 86 | + alertForExp(); |
81 | 87 | } |
82 | 88 |
|
83 | 89 | private void installXposed() { |
@@ -251,6 +257,61 @@ private void alertForMeizu() { |
251 | 257 | }, 2000); |
252 | 258 | } |
253 | 259 |
|
| 260 | + protected int dp2px(float dp) { |
| 261 | + final float scale = getResources().getDisplayMetrics().density; |
| 262 | + return (int) (dp * scale + 0.5f); |
| 263 | + } |
| 264 | + |
| 265 | + private void alertForExp() { |
| 266 | + final String shown = "_exp_has_alert"; |
| 267 | + boolean aBoolean = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(shown, false); |
| 268 | + if (aBoolean) { |
| 269 | + return; |
| 270 | + } |
| 271 | + |
| 272 | + LinearLayout layout = new LinearLayout(this); |
| 273 | + layout.setOrientation(LinearLayout.VERTICAL); |
| 274 | + |
| 275 | + int _20dp = dp2px(20); |
| 276 | + layout.setPadding(_20dp, _20dp, _20dp, _20dp); |
| 277 | + |
| 278 | + TextView tv = new TextView(this); |
| 279 | + tv.setTextColor(Color.BLACK); |
| 280 | + tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); |
| 281 | + tv.setText(R.string.exp_tips); |
| 282 | + layout.addView(tv); |
| 283 | + |
| 284 | + CheckBox checkBox = new CheckBox(this); |
| 285 | + checkBox.setText("不再提示"); |
| 286 | + checkBox.setOnClickListener(v -> { |
| 287 | + if (checkBox.isChecked()) { |
| 288 | + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean(shown, true).apply(); |
| 289 | + } |
| 290 | + }); |
| 291 | + |
| 292 | + layout.addView(checkBox); |
| 293 | + mUiHandler.postDelayed(() -> { |
| 294 | + AlertDialog alertDialog = new AlertDialog.Builder(getContext()) |
| 295 | + .setTitle("关于新项目EXP的说明") |
| 296 | + .setView(layout) |
| 297 | + .setPositiveButton("查看详情说明", (dialog, which) -> { |
| 298 | + Intent t = new Intent(Intent.ACTION_VIEW); |
| 299 | + t.setData(Uri.parse("https://vxposed.com/exp.html")); |
| 300 | + startActivity(t); |
| 301 | + }).setNegativeButton("支持我", (dialog, which) -> { |
| 302 | + Intent t = new Intent(Intent.ACTION_VIEW); |
| 303 | + t.setData(Uri.parse("https://vxposed.com/donate.html")); |
| 304 | + startActivity(t); |
| 305 | + }) |
| 306 | + .create(); |
| 307 | + try { |
| 308 | + alertDialog.show(); |
| 309 | + |
| 310 | + } catch (Throwable ignored) { |
| 311 | + } |
| 312 | + }, 2000); |
| 313 | + } |
| 314 | + |
254 | 315 | private void alertForDoze() { |
255 | 316 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { |
256 | 317 | return; |
|
0 commit comments