Commit 9698ed72 authored by Your Name's avatar Your Name

Merge remote-tracking branch 'origin/master'

parents 509b0f1e 1831c101
Pipeline #1409 canceled with stages
...@@ -33,6 +33,7 @@ import com.swiftcleaner.chovey.view.MainActivity; ...@@ -33,6 +33,7 @@ import com.swiftcleaner.chovey.view.MainActivity;
import com.zxdemo.ZxApplication; import com.zxdemo.ZxApplication;
import com.zxdemo.admob.AdmobHelper; import com.zxdemo.admob.AdmobHelper;
import com.zxdemo.http.ZxHttp; import com.zxdemo.http.ZxHttp;
import com.zxdemo.utils.ActivityLauncher;
import com.zxdemo.utils.NonBlockingCountdown; import com.zxdemo.utils.NonBlockingCountdown;
import java.util.Objects; import java.util.Objects;
...@@ -49,6 +50,7 @@ public class StartActivity extends AppCompatActivity { ...@@ -49,6 +50,7 @@ public class StartActivity extends AppCompatActivity {
private NonBlockingCountdown nonBlockingCountdown = new NonBlockingCountdown(this::jumpNext); private NonBlockingCountdown nonBlockingCountdown = new NonBlockingCountdown(this::jumpNext);
private int outJumpTime = 15; private int outJumpTime = 15;
public AtomicBoolean jumped = new AtomicBoolean(false); public AtomicBoolean jumped = new AtomicBoolean(false);
private ActivityLauncher launcher;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -56,11 +58,19 @@ public class StartActivity extends AppCompatActivity { ...@@ -56,11 +58,19 @@ public class StartActivity extends AppCompatActivity {
binding = ActivityStartBinding.inflate(getLayoutInflater()); binding = ActivityStartBinding.inflate(getLayoutInflater());
View view = binding.getRoot(); View view = binding.getRoot();
setContentView(view); setContentView(view);
launcher = new ActivityLauncher(this);
ZxHttp.INSTANCE.getHttpReportInterface("page_StartActivity", "", null); ZxHttp.INSTANCE.getHttpReportInterface("page_StartActivity", "", null);
initBar(); initBar();
initPermission(); initPermission();
sharedPreferences = getSharedPreferences("AppPreferences", MODE_PRIVATE); sharedPreferences = getSharedPreferences("AppPreferences", MODE_PRIVATE);
Log.e("NOTIFICATIONS", "NOTIFICATIONS 1");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Log.e("NOTIFICATIONS", "NOTIFICATIONS 2");
String[] stringArray = {Manifest.permission.POST_NOTIFICATIONS};
launcher.launch(stringArray, null);
}
boolean isFirstTime = sharedPreferences.getBoolean("isFirstTime", true); boolean isFirstTime = sharedPreferences.getBoolean("isFirstTime", true);
......
package com.zxdemo.utils
import android.content.Intent
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultCallback
import androidx.activity.result.ActivityResultCaller
import androidx.activity.result.contract.ActivityResultContracts
class ActivityLauncher(activityResultCaller: ActivityResultCaller) {
//region 权限
private var permissionCallback: ActivityResultCallback<Map<String, Boolean>>? = null
private val permissionLauncher =
activityResultCaller.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result: Map<String, Boolean> ->
permissionCallback?.onActivityResult(result)
}
fun launch(
permissionArray: Array<String>,
permissionCallback: ActivityResultCallback<Map<String, Boolean>>?
) {
this.permissionCallback = permissionCallback
permissionLauncher.launch(permissionArray)
}
//endregion
//region intent跳转
private var activityResultCallback: ActivityResultCallback<ActivityResult>? = null
private val intentLauncher =
activityResultCaller.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult: ActivityResult ->
activityResultCallback?.onActivityResult(activityResult)
}
/**
* it.resultCode == Activity.RESULT_OK
*/
fun launch(
intent: Intent,
activityResultCallback: ActivityResultCallback<ActivityResult>? = null
) {
this.activityResultCallback = activityResultCallback
intentLauncher.launch(intent)
}
//endregion
//region saf
// private var safResultCallback: ActivityResultCallback<Uri?>? = null
// private val safLauncher =
// activityResultCaller.registerForActivityResult(
// ActivityResultContracts.OpenDocument(),
// ) { uri ->
// safResultCallback?.onActivityResult(uri)
// }
//
// fun launch(array: Array<String>, safResultCallback: ActivityResultCallback<Uri?>?) {
// this.safResultCallback = safResultCallback
// safLauncher.launch(array)
// }
//end region
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment