diff --git a/README.md b/README.md index 67f0dca..85dc6c1 100644 --- a/README.md +++ b/README.md @@ -96,8 +96,8 @@ - nodejs - git -- Java JDK -- Android SDK Platform 32 +- Java JDK 11 +- Android SDK Platform 33 - Gradle 7.4.2 ```bash diff --git a/config.xml b/config.xml index 5a4ae6e..38aadf9 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + التقوى تطبيق إسلامي سهل الإستخدام و جامع للكثير من الميزات التي يحتاجها المسلم في يومه Altaqwaa diff --git a/my-plugins/cordova-plugin-downloader/.gitattributes b/my-plugins/cordova-plugin-downloader/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/my-plugins/cordova-plugin-downloader/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/my-plugins/cordova-plugin-downloader/image/android.png b/my-plugins/cordova-plugin-downloader/image/android.png new file mode 100644 index 0000000..9fa64f5 Binary files /dev/null and b/my-plugins/cordova-plugin-downloader/image/android.png differ diff --git a/my-plugins/cordova-plugin-downloader/package.json b/my-plugins/cordova-plugin-downloader/package.json new file mode 100644 index 0000000..2c907b6 --- /dev/null +++ b/my-plugins/cordova-plugin-downloader/package.json @@ -0,0 +1,13 @@ +{ + "name": "cordova-plugin-downloader", + "version": "1.3", + "description": "Android/IOS downloaded", + "cordova": { + "id": "cordova-plugin-downloader", + "platforms": [ + "android", + "ios" + ] + }, + "license": "Apache 2.0" +} diff --git a/my-plugins/cordova-plugin-downloader/plugin.xml b/my-plugins/cordova-plugin-downloader/plugin.xml new file mode 100644 index 0000000..3b3b2a3 --- /dev/null +++ b/my-plugins/cordova-plugin-downloader/plugin.xml @@ -0,0 +1,41 @@ + + + + + Cordova Downloader + + Cordova plugin for downloading files from server + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/my-plugins/cordova-plugin-downloader/src/android/com/whebcraft/android/plugin/Downloader.java b/my-plugins/cordova-plugin-downloader/src/android/com/whebcraft/android/plugin/Downloader.java new file mode 100644 index 0000000..60bad44 --- /dev/null +++ b/my-plugins/cordova-plugin-downloader/src/android/com/whebcraft/android/plugin/Downloader.java @@ -0,0 +1,218 @@ +package com.whebcraft.android.plugin; + +import android.app.Activity; +import android.app.DownloadManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.database.Cursor; +import android.net.Uri; +import java.io.File; + +import android.os.Build; +import android.os.Environment; +import android.preference.PreferenceManager; +import android.util.Log; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.json.JSONObject; +import org.json.JSONArray; +import org.json.JSONException; +import java.util.HashMap; + +public class Downloader extends CordovaPlugin { + + public static final String ACTION_DOWNLOAD = "download"; + + private static final String TAG = "DownloaderPlugin"; + + private Activity cordovaActivity; + private DownloadManager downloadManager; + private HashMap downloadMap; + + @Override + protected void pluginInitialize() { + Log.d(TAG, "PluginInitialize"); + + cordovaActivity = this.cordova.getActivity(); + + downloadManager = (DownloadManager) cordovaActivity.getSystemService(Context.DOWNLOAD_SERVICE); + downloadMap = new HashMap(); + + // Register receiver for Notification actions + cordovaActivity.registerReceiver(downloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); + } + + @Override + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + + Log.d(TAG, "CordovaPlugin: execute " + action); + + if (ACTION_DOWNLOAD.equals(action)) { + + Log.d(TAG, "CordovaPlugin: load " + action); + return download(args, callbackContext); + + } + + return false; + + } + + private boolean download(JSONArray args, CallbackContext callbackContext) { + Log.d(TAG, "CordovaPlugin: " + ACTION_DOWNLOAD); + + try { + + JSONObject arg_object = args.getJSONObject(0); + String path = arg_object.getString("path"); + String title = arg_object.getString("title"); + String folder = arg_object.getString("folder"); + String description = arg_object.getString("description"); + File direct; + Context context = cordovaActivity.getApplicationContext(); // Add this line to get the context + DownloadManager.Request request = new DownloadManager.Request(Uri.parse(arg_object.getString("url"))); // Move this line up + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + direct = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS); + if (direct == null) { + Log.e(TAG, "External storage directory is null"); + // Handle the case where external storage is not available + return false; // Return false as the download cannot proceed without a valid directory + } + } else { + direct = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), folder); + if (!direct.exists()) { + if (!direct.mkdirs()) { + Log.e(TAG, "Failed to create directory"); + // Handle the case where directory creation failed + return false; // Return false as the download cannot proceed without a valid directory + } + } + } + + // Set the destination for the downloaded file + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + if (direct != null) { + request.setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS, path); + } else { + Log.e(TAG, "Failed to set destination: External storage directory is null"); + return false; // Return false as the download cannot proceed without a valid directory + } + } else { + if (direct != null) { + request.setDestinationUri(Uri.fromFile(new File(direct, path))); + } else { + Log.e(TAG, "Failed to set destination: External storage directory is null"); + return false; // Return false as the download cannot proceed without a valid directory + } + } + + File delExisingFile = new File(direct.getPath() + "/" + path); + delExisingFile.delete(); + + Boolean visible = Boolean.valueOf(arg_object.getString("visible")); + + // Move the lines setting other request properties below the destination setup + // Restrict the types of networks over which this download may proceed. + request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE); + // Set whether this download may proceed over a roaming connection. + request.setAllowedOverRoaming(true); + // Set the title of this download, to be displayed in notifications (if + // enabled). + request.setTitle(title); + // Set a description of this download, to be displayed in notifications (if + // enabled) + request.setDescription(description); + // This download doesn't show in the UI or in the notifications. + request.setVisibleInDownloadsUi(true); + if (!visible) { + request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN); + } else { + // This download is visible and shows in the notifications while in progress and + // after completion. + request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); + } + // Set the destination for the downloaded as defined by the user within the + // device files directory + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, path); + + } else { + request.setDestinationInExternalPublicDir("/" + folder, path); + } + + // save the download + downloadMap.put(downloadManager.enqueue(request), new Download(path, folder, callbackContext)); // Use the request directly here + callbackContext.success(); + + return true; + + } catch (Exception e) { + + Log.e(TAG, "Exception: " + e.getMessage()); + callbackContext.error(e.getMessage()); + + return false; + } + } + + private BroadcastReceiver downloadReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + DownloadManager.Query query = new DownloadManager.Query(); + Long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); + query.setFilterById(downloadId); + Cursor cursor = downloadManager.query(query); + + if (cursor != null && cursor.moveToFirst()) { + int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); + int status = cursor.getInt(columnIndex); + int columnReason = cursor.getColumnIndex(DownloadManager.COLUMN_REASON); + int reason = cursor.getInt(columnReason); + + Download currentDownload = downloadMap.get(downloadId); + if (currentDownload != null) { + switch (status) { + case DownloadManager.STATUS_SUCCESSFUL: + try { + JSONObject entry = new JSONObject(); + entry.put("path", "file:///storage/sdcard0/" + currentDownload.folder + "/" + currentDownload.path); + entry.put("file", currentDownload.path); + entry.put("folder", currentDownload.folder); + currentDownload.callbackContext.success(entry); + } catch (Exception e) { + Log.e(TAG, "Exception: " + e.getMessage()); + currentDownload.callbackContext.error(e.getMessage()); + } + break; + case DownloadManager.STATUS_FAILED: + currentDownload.callbackContext.error(reason); + break; + case DownloadManager.STATUS_PAUSED: + case DownloadManager.STATUS_PENDING: + case DownloadManager.STATUS_RUNNING: + default: + break; + } + // Remove the download from the map after processing + downloadMap.remove(downloadId); + } + } + } + }; + + private class Download { + public String path; + public String folder; + public CallbackContext callbackContext; + + public Download(String path, String folder, CallbackContext callbackContext) { + this.path = path; + this.folder = folder; + this.callbackContext = callbackContext; + } + } + +} \ No newline at end of file diff --git a/my-plugins/cordova-plugin-downloader/src/android/libs/support-v4-19.0.0.jar b/my-plugins/cordova-plugin-downloader/src/android/libs/support-v4-19.0.0.jar new file mode 100644 index 0000000..7dad0a7 Binary files /dev/null and b/my-plugins/cordova-plugin-downloader/src/android/libs/support-v4-19.0.0.jar differ diff --git a/my-plugins/cordova-plugin-downloader/www/Downloader.js b/my-plugins/cordova-plugin-downloader/www/Downloader.js new file mode 100644 index 0000000..9fe3610 --- /dev/null +++ b/my-plugins/cordova-plugin-downloader/www/Downloader.js @@ -0,0 +1,22 @@ +var Downloader = { + download: function (arguments, successCallback, errorCallback) { + cordova.exec( + successCallback, + errorCallback, + 'Downloader', + 'download', + [arguments] + ); + } +}; + +function install() { + if (!window.plugins) { + window.plugins = {}; + } + + window.plugins.Downloader = Downloader; + return window.plugins.Downloader; +}; + +cordova.addConstructor(install); diff --git a/package.json b/package.json index 58e0f07..6f19e0d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.rn0x.altaqwaa", "displayName": "التقوى", - "version": "1.2.5", + "version": "1.2.6", "description": "تطبيق إسلامي سهل الإستخدام و جامع للكثير من الميزات التي يحتاجها المسلم في يومه", "main": "index.js", "scripts": { @@ -57,7 +57,7 @@ }, "devDependencies": { "cordova-android": "^12.0.1", - "cordova-plugin-downloader": "github:asadaries/cordova-plugin-downloader", + "cordova-plugin-downloader": "file:my-plugins/cordova-plugin-downloader", "cordova-plugin-local-notification": "file:my-plugins/cordova-plugin-local-notification", "cordova-plugin-navigationbar-color": "file:my-plugins/cordova-plugin-navigationbar-color", "cordova-plugin-network-information": "github:apache/cordova-plugin-network-information", diff --git a/www/css/questions.css b/www/css/questions.css index 0f32159..6ea29e6 100644 --- a/www/css/questions.css +++ b/www/css/questions.css @@ -308,11 +308,11 @@ transition: 0.5s ease-in-out; } -.answers_box li:hover { +/* .answers_box li:hover { transition: 0.5s ease-in-out; background-color: var(--background_div_hover); box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset; -} +} */ .answer { margin-top: 7px !important; @@ -391,12 +391,13 @@ display: block; width: 80%; max-width: 600px; - background-color: var(--white-div); + background-color: var(--background_div); border-radius: 10px; padding: 10px; margin-left: auto; margin-right: auto; margin-top: 100px; + color: var(--white); } #main_alert_icon { @@ -433,14 +434,25 @@ } +#box_alert_ul li p { + color: var(--white) !important; + +} +#box_alert_ul li p span { + color: var(--red) !important; + +} + #questions_alert_text { margin-top: 5px; margin-bottom: 5px; + color: var(--white) !important; } #score { margin-top: 0px; margin-bottom: 0px; + color: var(--white) !important; } #score span { diff --git a/www/css/settings.css b/www/css/settings.css index 8bbffc0..09a186d 100644 --- a/www/css/settings.css +++ b/www/css/settings.css @@ -150,16 +150,58 @@ input:checked+.slider:before { #refresh_location:hover { width: 35px; - animation: rotation 0.5s linear; + animation: rotation 0.5s linear; transition: 0.5s ease-in-out; } +#themes { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; + align-content: center; +} + +#themes>p { + display: flex; + justify-content: center; + align-items: center; + width: 20px; + height: 20px; + margin-left: 5px; + margin-right: 5px; + cursor: pointer; + /* border-style: solid; + border-width: 1px; + border-color: var(--background_div_hover); */ +} + +#theme_1 { + background-color: #2e3338; +} + +#theme_2 { + background-color: #141e46; +} + +#theme_3 { + background-color: #38382e; +} + +#theme_4 { + background-color: #acc2fd; +} + +#theme_5 { + background-color: #0b3f43; +} @keyframes rotation { from { - -webkit-transform: rotate(0deg); + -webkit-transform: rotate(0deg); } + to { - -webkit-transform: rotate(360deg); + -webkit-transform: rotate(360deg); } } \ No newline at end of file diff --git a/www/css/var.css b/www/css/var.css index c32f496..d2193b1 100644 --- a/www/css/var.css +++ b/www/css/var.css @@ -14,5 +14,74 @@ --color_font_grey: #727272; --red: #f34949; --white: #ffffff; + --white-div: #ffffff; +} + +[data-theme="theme_1"] { + --background_body: #2e3338; + --background_div: #232527; + --background_div_2: #252829; + --background_menu: #1b1d1f; + --background_div_hover: #6bc077; + --background_div_hover_2: #53925b; + --green: #335e39; + --color_font_grey: #727272; + --red: #f34949; + --white: #ffffff; + --white-div: #ffffff; +} + +[data-theme="theme_2"] { + --background_body: #141e46; + --background_div: #0c1128; + --background_div_2: #1a275a; + --background_menu: #1a275a; + --background_div_hover: #192f6b; + --background_div_hover_2: #1d2b64; + --green: #3e497c; + --color_font_grey: #8e92b2; + --red: #f34949; + --white: #495584; + --white-div: #3e476c; +} + +[data-theme="theme_3"] { + --background_body: #38382e; + --background_div: #262723; + --background_div_2: #292925; + --background_menu: #1e1f1b; + --background_div_hover: #afc06b; + --background_div_hover_2: #928d53; + --green: #555e33; + --color_font_grey: #727272; + --red: #f34949; + --white: #ffffff; --white-div: #ffffff; +} + +[data-theme="theme_4"] { + --background_body: #acc2fd; + --background_div: #94b0ff; + --background_div_2: #a1baff; + --background_menu: #839ee9; + --background_div_hover: #415aa1; + --background_div_hover_2: #3656b4; + --green: #1a3c6f; + --color_font_grey: #34399d; + --red: #f34949; + --white: #223875; + --white-div: #1c2d5c; +} +[data-theme="theme_5"] { + --background_body: #0b3f43; + --background_div: #062a2d; + --background_div_2: #083336; + --background_menu: #0e3a3d; + --background_div_hover: #0b666c; + --background_div_hover_2: #076e76; + --green: #108d96; + --color_font_grey: #0097a2; + --red: #813434; + --white: #0b8c96; + --white-div: #0e98a1; } \ No newline at end of file diff --git a/www/error.html b/www/error.html index 7858271..2383804 100644 --- a/www/error.html +++ b/www/error.html @@ -1,5 +1,5 @@ - + diff --git a/www/index.html b/www/index.html index 87fa089..16bf0fc 100644 --- a/www/index.html +++ b/www/index.html @@ -1,5 +1,5 @@ - + diff --git a/www/js/adhkar.js b/www/js/adhkar.js index e170434..df36a3f 100644 --- a/www/js/adhkar.js +++ b/www/js/adhkar.js @@ -39,7 +39,7 @@ export default async () => { let text = `${adhkar_random_text.innerText}` text += adhkar_random_description.innerText !== '' ? `\n\n${adhkar_random_description.innerText}` : adhkar_random_description.innerText; text += adhkar_random_reference.innerText !== '' ? `\n\n${adhkar_random_reference.innerText}` : adhkar_random_description.innerText; - cordova.plugins.clipboard.copy(text); + cordova?.plugins?.clipboard?.copy(text); alert.style.display = "block" setTimeout(() => { @@ -82,11 +82,11 @@ export default async () => { if (e === 2) { if (navigator?.app) { - navigator.app.exitApp(); + navigator?.app?.exitApp(); } else if (navigator?.device) { - navigator.device.exitApp(); + navigator?.device?.exitApp(); } else { @@ -200,7 +200,7 @@ export default async () => { text += `・ التكرار: ${iterator?.repetition}\n\n\n` text += `#تطبيق_التقوى` - cordova.plugins.clipboard.copy(text); + cordova?.plugins?.clipboard?.copy(text); alert.style.display = "block" setTimeout(() => { diff --git a/www/js/index.js b/www/js/index.js index 5bbf827..8fff99c 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -13,54 +13,46 @@ import allah from './allah.js'; import settings from './settings.js'; import sabha from './sabha.js'; import notification from './notification.js'; +import ramadanTime from './ramadanTime.js'; import error_handling from './modules/error_handling.js'; import handleAudio from './modules/handleAudio.js'; -import ramadanTime from './ramadanTime.js'; - -// أفحص إذا كانت البيئة تعمل في Cordova -const isCordova = !!window.cordova; document.documentElement.style.setProperty('--animate-duration', '1.5s'); -// أضف شرطًا للتحقق مما إذا كان التطبيق يعمل في Cordova أم لا -if (isCordova) { - document.addEventListener('deviceready', async (event) => { - - event.preventDefault(); - try { - let permissions = cordova.plugins.permissions; - - let list = [ - permissions.ACCESS_COARSE_LOCATION, - permissions.WRITE_EXTERNAL_STORAGE, - permissions.VIBRATE, - permissions.POST_NOTIFICATIONS, - permissions.FOREGROUND_SERVICE - ]; - - permissions.hasPermission(list, (status) => { - if (!status.hasPermission) { - permissions.requestPermissions(list); - } - }); - - if (window.MobileAccessibility) { - window.MobileAccessibility.usePreferredTextZoom(false); +document.addEventListener('deviceready', async (event) => { + event.preventDefault(); + setTheme(); + try { + const permissions = cordova?.plugins?.permissions; + const list = [ + permissions?.ACCESS_COARSE_LOCATION, + permissions?.WRITE_EXTERNAL_STORAGE, + permissions?.VIBRATE, + permissions?.POST_NOTIFICATIONS, + permissions?.SCHEDULE_EXACT_ALARM + ]; + permissions?.hasPermission(list, (status) => { + if (!status.hasPermission) { + permissions?.requestPermissions(list); } - } catch (error) { - error_handling(error); + }); + if (window.MobileAccessibility) { + window.MobileAccessibility.usePreferredTextZoom(false); } + } catch (error) { + error_handling(error); + } - await setupApplication(); - - }, false); -} else { + // قم بإضافة تعليق في حال تغشيل التطبيق في المتصفح await setupApplication(); -} +}, false); -async function setupApplication() { +// قم بإزالة التعليق في حال تغشيل التطبيق في المتصفح +// await setupApplication(); + +async function setupApplication() { await footer(); await adhkar(); await prayer(); @@ -82,10 +74,42 @@ async function setupApplication() { const imagesAll = document.querySelectorAll('img'); // تعيين خاصية loading="lazy" لكل عنصر img - imagesAll.forEach(img => { - img.setAttribute('loading', 'lazy'); + imagesAll?.forEach(img => { + img?.setAttribute('loading', 'lazy'); }); await handleAudio(); // تشغيل الصوت في جميع الصفحات +} + + +function setTheme() { + const storage = window.localStorage; + const getTheme = storage.getItem("themeStorage"); + + if (getTheme === "theme_1" || getTheme === undefined) { + NavigationBar.backgroundColorByHexString("#232527", false); + StatusBar.backgroundColorByHexString('#2e3338'); + document.querySelector("html").setAttribute("data-theme", "theme_1"); + } + if (getTheme === "theme_2") { + NavigationBar.backgroundColorByHexString("#0c1128", false); + StatusBar.backgroundColorByHexString('#141e46'); + document.querySelector("html").setAttribute("data-theme", "theme_2"); + } + if (getTheme === "theme_3") { + NavigationBar.backgroundColorByHexString("#262723", false); + StatusBar.backgroundColorByHexString('#38382e'); + document.querySelector("html").setAttribute("data-theme", "theme_3"); + } + if (getTheme === "theme_4") { + NavigationBar.backgroundColorByHexString("#94b0ff", false); + StatusBar.backgroundColorByHexString('#acc2fd'); + document.querySelector("html").setAttribute("data-theme", "theme_4"); + } + if (getTheme === "theme_5") { + NavigationBar.backgroundColorByHexString("#0b3f43", false); + StatusBar.backgroundColorByHexString('#0b3f43'); + document.querySelector("html").setAttribute("data-theme", "theme_5"); + } } \ No newline at end of file diff --git a/www/js/modules/Downloader.js b/www/js/modules/Downloader.js index 8ed793f..0927d78 100644 --- a/www/js/modules/Downloader.js +++ b/www/js/modules/Downloader.js @@ -4,10 +4,10 @@ export default (url, filename) => { try { - let Downloader = window.plugins.Downloader; + let Downloader = window?.plugins?.Downloader; let downloadSuccessCallback = (result) => { // result is an object - console.log(result.file); + console.log(result?.file); }; let downloadErrorCallback = (error) => { @@ -24,7 +24,7 @@ export default (url, filename) => { folder: "Download" // Folder to save the downloaded file, if not exist it will be created } - Downloader.download(options, downloadSuccessCallback, downloadErrorCallback); + Downloader?.download(options, downloadSuccessCallback, downloadErrorCallback); } catch (error) { diff --git a/www/js/modules/LocalNotification.js b/www/js/modules/LocalNotification.js index 6c65a04..0b0b817 100644 --- a/www/js/modules/LocalNotification.js +++ b/www/js/modules/LocalNotification.js @@ -38,7 +38,7 @@ export function scheduleLocalNotification(options) { // options.actions = [{ id: 'dummyAction', title: 'close', type: 'button' }]; - cordova.plugins.notification.local.schedule(options); + cordova?.plugins?.notification?.local?.schedule(options); } catch (error) { console.error('حدث خطأ في جدولة الإشعار:', error.message); throw error; @@ -78,7 +78,7 @@ export function updateLocalNotification(notificationId, options) { throw new Error('الخيارات المقدمة غير صالحة لتحديث الإشعار.'); } - cordova.plugins.notification.local.update({ + cordova?.plugins?.notification?.local?.update({ id: notificationId, ...options, }); @@ -96,7 +96,7 @@ export function updateLocalNotification(notificationId, options) { */ export function cancelLocalNotification(notificationId, callback = () => { }) { if (typeof cordova !== 'undefined' && cordova.plugins && cordova.plugins.notification) { - cordova.plugins.notification.local.cancel(notificationId, callback); + cordova?.plugins?.notification?.local?.cancel(notificationId, callback); } } @@ -109,7 +109,7 @@ export function cancelLocalNotification(notificationId, callback = () => { }) { */ export function isLocalNotificationExists(notificationId) { if (typeof cordova !== 'undefined' && cordova.plugins && cordova.plugins.notification) { - return cordova.plugins.notification.local.isPresent(notificationId); + return cordova?.plugins?.notification?.local?.isPresent(notificationId); } return false; } @@ -125,7 +125,7 @@ export function registerLocalNotificationClickEvent(callback) { throw new Error('يجب تشغيل هذا الكود داخل تطبيق Cordova وبعد استعراض الأجهزة.'); } - cordova.plugins.notification.local.on('click', function (notification) { + cordova?.plugins?.notification?.local?.on('click', function (notification) { // التحقق من أن النقر تم على الإجراء المطلوب if (notification.action === 'closeAudio') { callback(notification); @@ -146,7 +146,7 @@ export function registerLocalNotificationClickEvent(callback) { */ export function ClickEvent(actionID, callback) { if (typeof cordova !== 'undefined' && cordova.plugins && cordova.plugins.notification) { - cordova.plugins.notification.local.on(actionID, callback); + cordova?.plugins?.notification?.local?.on(actionID, callback); } return false; } diff --git a/www/js/modules/error_handling.js b/www/js/modules/error_handling.js index e5cc042..61fd316 100644 --- a/www/js/modules/error_handling.js +++ b/www/js/modules/error_handling.js @@ -1,3 +1,8 @@ +/** + * + * معالج الأخطاء + */ + export default (error) => { let arr = [ @@ -5,7 +10,7 @@ export default (error) => { "Illegal Access" ] - if (arr.every(e => error?.message !== e)) { + if (arr?.every(e => error?.message !== e)) { navigator?.notification?.confirm( `message: ${error?.message}\ncode: ${error?.code ? error?.code : "null"}\npath: ${window.location.pathname}`, @@ -14,11 +19,11 @@ export default (error) => { if (e === 2) { if (navigator.app) { - navigator.app.exitApp(); + navigator?.app?.exitApp(); } else if (navigator.device) { - navigator.device.exitApp(); + navigator?.device?.exitApp(); } else { @@ -33,9 +38,9 @@ export default (error) => { let message = `message: ${error?.message}\n`; message += `code: ${error?.code ? error?.code : "null"}\n`; message += `path: ${window.location.pathname}\n`; - message += `platform: ${device.platform}\n`; - message += `version: ${device.version}\n`; - message += `model: ${device.model}`; + message += `platform: ${device?.platform}\n`; + message += `version: ${device?.version}\n`; + message += `model: ${device?.model}`; let url = new URL(`${repoUrl}/issues/new`); url.searchParams.set("title", error?.message); diff --git a/www/js/modules/getGPS.js b/www/js/modules/getGPS.js index 44e366d..82a19d3 100644 --- a/www/js/modules/getGPS.js +++ b/www/js/modules/getGPS.js @@ -4,7 +4,7 @@ export default () => { return new Promise((resolve, reject) => { - navigator.geolocation.getCurrentPosition((position) => { + navigator?.geolocation?.getCurrentPosition((position) => { const timezone = getTimezone(); diff --git a/www/js/prayer.js b/www/js/prayer.js index 911232e..e9446c2 100644 --- a/www/js/prayer.js +++ b/www/js/prayer.js @@ -128,8 +128,8 @@ async function checkPermissionStatus() { else { return new Promise((resolve) => { - const permissions = cordova.plugins.permissions; - permissions.hasPermission(permissions.ACCESS_COARSE_LOCATION, async (status) => { + const permissions = cordova?.plugins?.permissions; + permissions?.hasPermission(permissions?.ACCESS_COARSE_LOCATION, async (status) => { resolve(status.hasPermission); }); }); diff --git a/www/js/questions.js b/www/js/questions.js index b6cd786..9fe9174 100644 --- a/www/js/questions.js +++ b/www/js/questions.js @@ -324,7 +324,7 @@ export default async () => { const percentage = (correctAnswers / totalQuestions) * 100; for (const iterator of quizResults.wrongAnswers) { - applyStylesToElement(iterator.element, "#4c7fc7"); + applyStylesToElement(iterator.element, "var(--background_div_hover)"); } const main_alert_icon = document.getElementById("main_alert_icon"); diff --git a/www/js/settings.js b/www/js/settings.js index b992a85..4e481ad 100644 --- a/www/js/settings.js +++ b/www/js/settings.js @@ -27,6 +27,8 @@ const DEFAULT_VALUES = { isha_settings: 0, }; +let themes + /** * الحصول على عنصر DOM باستخدام معرف العنصر * @function @@ -127,6 +129,7 @@ const handleRefreshLocation = async () => { */ const handleSaveSettings = () => { const storage = window.localStorage; + const themeStorage = storage.getItem("themeStorage"); Object.entries(DEFAULT_VALUES).forEach(([key]) => { const element = getElementById(key); @@ -149,6 +152,20 @@ const handleSaveSettings = () => { window.location.href = '/pages/settings.html'; }, 1000); } + + if (themes) { + storage.setItem("themeStorage", themes); + } + + if (!themes && !themeStorage) { + storage.setItem("themeStorage", "theme_1"); + } + + if (!themes && themeStorage) { + storage.setItem("themeStorage", themeStorage); + } + + }; /** @@ -168,8 +185,8 @@ function bool(v = '') { */ async function permissionStatus() { return new Promise((resolve) => { - const permissions = cordova.plugins.permissions; - permissions.hasPermission(permissions.ACCESS_COARSE_LOCATION, (status) => { + const permissions = cordova?.plugins?.permissions; + permissions?.hasPermission(permissions?.ACCESS_COARSE_LOCATION, (status) => { resolve(status.hasPermission); }); }); @@ -184,9 +201,12 @@ export default async () => { setDefaultValues(); const back = getElementById('back'); + const storage = window.localStorage; + const themeStorage = storage.getItem("themeStorage"); const refreshLocation = getElementById('refresh_location'); const saveSettings = getElementById('settings_save'); + if (back) { back.addEventListener('click', () => { window.location.href = '/more.html'; @@ -201,6 +221,22 @@ export default async () => { saveSettings.addEventListener('click', handleSaveSettings); } + const themeParagraphs = document.querySelectorAll('#themes p'); + themeParagraphs.forEach(paragraph => { + paragraph.addEventListener('click', () => { + themeParagraphs.forEach(p => { + p.style.border = 'none'; + }); + console.log(paragraph.id); + themes = paragraph.id + document.getElementById(paragraph.id).style = "border-style: solid; border-width: 1px; border-color: var(--background_div_hover);" + }); + }); + + if (themeStorage) { + document.getElementById(themeStorage).style = "border-style: solid; border-width: 1px; border-color: var(--background_div_hover);" + } + } catch (error) { error_handling(error); } diff --git a/www/more.html b/www/more.html index 6fee74c..895d8a8 100644 --- a/www/more.html +++ b/www/more.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/adhkar/evening.html b/www/pages/adhkar/evening.html index b9dc8b0..6d5504a 100644 --- a/www/pages/adhkar/evening.html +++ b/www/pages/adhkar/evening.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/adhkar/food.html b/www/pages/adhkar/food.html index c6a3475..99f09da 100644 --- a/www/pages/adhkar/food.html +++ b/www/pages/adhkar/food.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/adhkar/morning.html b/www/pages/adhkar/morning.html index 6bbff52..6780e83 100644 --- a/www/pages/adhkar/morning.html +++ b/www/pages/adhkar/morning.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/adhkar/prayer.html b/www/pages/adhkar/prayer.html index 8e42bbc..26ee0d2 100644 --- a/www/pages/adhkar/prayer.html +++ b/www/pages/adhkar/prayer.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/adhkar/sleeping.html b/www/pages/adhkar/sleeping.html index 91f61a0..5de3805 100644 --- a/www/pages/adhkar/sleeping.html +++ b/www/pages/adhkar/sleeping.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/adhkar/tasbih.html b/www/pages/adhkar/tasbih.html index ecc49d7..4773d05 100644 --- a/www/pages/adhkar/tasbih.html +++ b/www/pages/adhkar/tasbih.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/albitaqat.html b/www/pages/albitaqat.html index 2123f55..5cb04a6 100644 --- a/www/pages/albitaqat.html +++ b/www/pages/albitaqat.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/allah.html b/www/pages/allah.html index 0d9e187..42c5f2b 100644 --- a/www/pages/allah.html +++ b/www/pages/allah.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/hisnmuslim.html b/www/pages/hisnmuslim.html index eed9b6c..dc20403 100644 --- a/www/pages/hisnmuslim.html +++ b/www/pages/hisnmuslim.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/images.html b/www/pages/images.html index 1c213aa..5963d79 100644 --- a/www/pages/images.html +++ b/www/pages/images.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/info.html b/www/pages/info.html index c20c9bb..ce4d225 100644 --- a/www/pages/info.html +++ b/www/pages/info.html @@ -1,5 +1,5 @@ - + @@ -57,7 +57,7 @@ version

الإصدار: - v1.2.5 + v1.2.6

diff --git a/www/pages/questions.html b/www/pages/questions.html index 888f93e..efaa343 100644 --- a/www/pages/questions.html +++ b/www/pages/questions.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/questions_page_2.html b/www/pages/questions_page_2.html index d6fc926..48778f6 100644 --- a/www/pages/questions_page_2.html +++ b/www/pages/questions_page_2.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/radio.html b/www/pages/radio.html index ceb2558..a09134f 100644 --- a/www/pages/radio.html +++ b/www/pages/radio.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/ramadanTime.html b/www/pages/ramadanTime.html index 8758f2f..ba479be 100644 --- a/www/pages/ramadanTime.html +++ b/www/pages/ramadanTime.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/sabha.html b/www/pages/sabha.html index 92758b8..19dcfef 100644 --- a/www/pages/sabha.html +++ b/www/pages/sabha.html @@ -1,5 +1,5 @@ - + diff --git a/www/pages/settings.html b/www/pages/settings.html index 7bb94cd..25b2d9f 100644 --- a/www/pages/settings.html +++ b/www/pages/settings.html @@ -1,5 +1,5 @@ - + @@ -235,6 +235,24 @@

+
  • +
    +

    + لون التطبيق +

    +
    + +
    +
    +

    1

    +

    2

    +

    3

    +

    4

    +

    5

    +
    +
    +
  • + diff --git a/www/pages/tfs.html b/www/pages/tfs.html index 32ad75e..b68e8eb 100644 --- a/www/pages/tfs.html +++ b/www/pages/tfs.html @@ -1,5 +1,5 @@ - + diff --git a/www/prayer.html b/www/prayer.html index bc83468..9683055 100644 --- a/www/prayer.html +++ b/www/prayer.html @@ -1,5 +1,5 @@ - + diff --git a/www/quran.html b/www/quran.html index 8e5b420..bfcf4d8 100644 --- a/www/quran.html +++ b/www/quran.html @@ -1,5 +1,5 @@ - +