Update: 2026-05-16 20:55:10

This commit is contained in:
Hamza-Ayed
2026-05-16 20:55:10 +03:00
parent 272eb768a0
commit b9d7a975b5
9 changed files with 40 additions and 4 deletions

View File

@@ -14,6 +14,8 @@ import android.view.accessibility.AccessibilityManager
import android.widget.Button import android.widget.Button
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import android.net.Uri
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
@@ -77,12 +79,24 @@ class MainActivity : AppCompatActivity() {
} }
findViewById<Button>(R.id.btn_notification).setOnClickListener { findViewById<Button>(R.id.btn_notification).setOnClickListener {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
showRestrictedSettingsDialog("صلاحية قراءة الإشعارات") {
startActivity(Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS)) startActivity(Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS))
} }
} else {
startActivity(Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS))
}
}
findViewById<Button>(R.id.btn_accessibility).setOnClickListener { findViewById<Button>(R.id.btn_accessibility).setOnClickListener {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
showRestrictedSettingsDialog("صلاحية إمكانية الوصول") {
startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)) startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
} }
} else {
startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
}
}
findViewById<Button>(R.id.btn_overlay).setOnClickListener { findViewById<Button>(R.id.btn_overlay).setOnClickListener {
if (!Settings.canDrawOverlays(this)) { if (!Settings.canDrawOverlays(this)) {
@@ -204,4 +218,26 @@ class MainActivity : AppCompatActivity() {
btnStart.visibility = View.VISIBLE btnStart.visibility = View.VISIBLE
btnStop.visibility = View.GONE btnStop.visibility = View.GONE
} }
private fun showRestrictedSettingsDialog(permissionName: String, onProceed: () -> Unit) {
AlertDialog.Builder(this)
.setTitle("تفعيل $permissionName")
.setMessage("إذا وجدت الزر 'مغلق' أو بلون رمادي (Restricted Setting)، يرجى الضغط على زر 'فتح الإعدادات' أدناه، ثم الضغط على النقاط الثلاث في أعلى الصفحة واختيار 'Allow restricted settings' ثم العودة للتفعيل.\n\nهل تريد فتح الإعدادات الآن؟")
.setPositiveButton("فتح الإعدادات") { _, _ -> onProceed() }
.setNeutralButton("تعليمات فك القيد") { _, _ -> openAppInfo() }
.setNegativeButton("إلغاء", null)
.show()
}
private fun openAppInfo() {
try {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", packageName, null)
intent.data = uri
startActivity(intent)
Toast.makeText(this, "اضغط على النقاط الثلاث في الأعلى ثم Allow restricted settings", Toast.LENGTH_LONG).show()
} catch (e: Exception) {
Toast.makeText(this, "فشل فتح الإعدادات", Toast.LENGTH_SHORT).show()
}
}
} }

View File

@@ -1,4 +1,4 @@
#Sat May 16 20:39:39 EET 2026 #Sat May 16 20:50:18 EET 2026
base.0=/Users/hamzaaleghwairyeen/development/App/jordan_bot/installer/build/intermediates/dex/release/minifyReleaseWithR8/classes.dex base.0=/Users/hamzaaleghwairyeen/development/App/jordan_bot/installer/build/intermediates/dex/release/minifyReleaseWithR8/classes.dex
path.0=classes.dex path.0=classes.dex
renamed.0=classes.dex renamed.0=classes.dex

View File

@@ -1,5 +1,5 @@
repositories { repositories {
system: GIT system: GIT
local_root_path: "$PROJECT_DIR" local_root_path: "$PROJECT_DIR"
revision: "3622328363479e8adf2a7e7c55990fdbf93a4c5d" revision: "272eb768a06623e6c1b1106300cfaea64a6313fb"
} }