Skip to content

Commit bda7817

Browse files
committed
Add auto-translation in Admin Panel and fix UI issues
- Add bidirectional auto-translation (English ↔ Kannada) in Admin content form - Translation triggers after 1 second pause with visual feedback - Fix modal scrolling issue by restructuring TouchableOpacity wrappers - Add getDirectImageUrl for Google Drive image previews - Update locale files with translation status messages
1 parent 8eae59b commit bda7817

6 files changed

Lines changed: 2312 additions & 1765 deletions

File tree

App.tsx

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import * as Notifications from 'expo-notifications';
1111
import { db } from './firebase.config';
1212
import { doc, setDoc } from 'firebase/firestore';
1313
import AsyncStorage from '@react-native-async-storage/async-storage';
14-
// Ads implementation
15-
import { useInterstitialAd } from './hooks/useInterstitialAd';
16-
import { useExitAd } from './hooks/useExitAd';
17-
import MobileAds from 'react-native-google-mobile-ads';
14+
// Ads implementation - COMMENTED OUT
15+
// import { useInterstitialAd } from './hooks/useInterstitialAd';
16+
// import { useExitAd } from './hooks/useExitAd';
17+
// import MobileAds from 'react-native-google-mobile-ads';
1818

1919
// Create context for notifications navigation
2020
const NotificationsContext = createContext<{
@@ -163,32 +163,31 @@ const AppContent = () => {
163163
checkFirstLaunch();
164164
}, []);
165165

166-
// Track AdMob initialization state
167-
const [adMobInitialized, setAdMobInitialized] = useState(false);
168-
169-
// Initialize Google Mobile Ads
170-
useEffect(() => {
171-
console.log('🚀 Starting AdMob initialization...');
172-
MobileAds()
173-
.initialize()
174-
.then(adapterStatuses => {
175-
console.log('✅ AdMob initialized successfully:', adapterStatuses);
176-
setAdMobInitialized(true);
177-
})
178-
.catch(error => {
179-
console.error('❌ AdMob initialization error:', error);
180-
console.error('Error details:', JSON.stringify(error));
181-
// Still set to true to allow ads to attempt loading
182-
setAdMobInitialized(true);
183-
});
184-
}, []);
185-
186-
// Interstitial ad hook for tab navigation - ONLY AFTER initialization
187-
const { showAd, isLoaded } = useInterstitialAd();
188-
189-
// Exit ad hook - shows rewarded interstitial when user presses back button
190-
// ONLY enable after AdMob is initialized
191-
useExitAd({ enabled: adMobInitialized });
166+
// Track AdMob initialization state - COMMENTED OUT
167+
// const [adMobInitialized, setAdMobInitialized] = useState(false);
168+
169+
// Initialize Google Mobile Ads - COMMENTED OUT
170+
// useEffect(() => {
171+
// console.log('🚀 Starting AdMob initialization...');
172+
// MobileAds()
173+
// .initialize()
174+
// .then(adapterStatuses => {
175+
// console.log('✅ AdMob initialized successfully:', adapterStatuses);
176+
// setAdMobInitialized(true);
177+
// })
178+
// .catch(error => {
179+
// console.error('❌ AdMob initialization error:', error);
180+
// console.error('Error details:', JSON.stringify(error));
181+
// // Still set to true to allow ads to attempt loading
182+
// setAdMobInitialized(true);
183+
// });
184+
// }, []);
185+
186+
// Interstitial ad hook for tab navigation - COMMENTED OUT
187+
// const { showAd, isLoaded } = useInterstitialAd();
188+
189+
// Exit ad hook - shows rewarded interstitial when user presses back button - COMMENTED OUT
190+
// useExitAd({ enabled: adMobInitialized });
192191

193192
useEffect(() => {
194193
registerForPushNotificationsAsync().then(token => {
@@ -225,29 +224,28 @@ const AppContent = () => {
225224
};
226225
}, []);
227226

228-
// Handle navigation state changes to show interstitial ads
227+
// Handle navigation state changes to show interstitial ads - COMMENTED OUT
229228
const handleNavigationStateChange = (state: any) => {
230229
if (!state) return;
231230

232231
const currentRoute = state.routes[state.index]?.name;
233232

234-
// Log navigation changes
233+
// Log navigation changes - ads disabled
235234
if (currentRoute && currentRoute !== previousRoute) {
236235
console.log(`📱 Tab changed: ${previousRoute}${currentRoute}`);
237-
console.log('Ad state - isLoaded:', isLoaded, 'adMobInitialized:', adMobInitialized);
236+
// Ads disabled - no ad state logging
238237
}
239238

240-
// Show interstitial ad occasionally when switching tabs (not every time to avoid annoyance)
241-
// Show ad 30% of the time when changing tabs
242-
const randomValue = Math.random();
243-
if (currentRoute && currentRoute !== previousRoute && isLoaded && randomValue < 0.3) {
244-
console.log(`🎲 Random value: ${randomValue.toFixed(2)} < 0.3 - Showing interstitial ad`);
245-
showAd();
246-
} else if (currentRoute && currentRoute !== previousRoute && isLoaded) {
247-
console.log(`🎲 Random value: ${randomValue.toFixed(2)} >= 0.3 - Skipping ad this time`);
248-
} else if (currentRoute && currentRoute !== previousRoute && !isLoaded) {
249-
console.log('⚠️ Tab changed but ad not loaded yet');
250-
}
239+
// Interstitial ads disabled
240+
// const randomValue = Math.random();
241+
// if (currentRoute && currentRoute !== previousRoute && isLoaded && randomValue < 0.3) {
242+
// console.log(`🎲 Random value: ${randomValue.toFixed(2)} < 0.3 - Showing interstitial ad`);
243+
// showAd();
244+
// } else if (currentRoute && currentRoute !== previousRoute && isLoaded) {
245+
// console.log(`🎲 Random value: ${randomValue.toFixed(2)} >= 0.3 - Skipping ad this time`);
246+
// } else if (currentRoute && currentRoute !== previousRoute && !isLoaded) {
247+
// console.log('⚠️ Tab changed but ad not loaded yet');
248+
// }
251249

252250
setPreviousRoute(currentRoute);
253251
};

locales/en.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,5 +436,13 @@
436436
"allowLocation": "Allow Location Access",
437437
"locationRequired": "Location Required",
438438
"locationRequiredForFeatures": "Location access is required to provide weather-based care suggestions and local market information. You can enable it later from settings.",
439-
"ok": "OK"
439+
"ok": "OK",
440+
"optional": "Optional",
441+
"autoTranslateHint": "Will be auto-translated if left empty",
442+
"autoTranslateFromEnglish": "Will auto-translate from English if left empty",
443+
"autoTranslateBidirectional": "Auto-translates between English ↔ Kannada",
444+
"translating": "Translating...",
445+
"enterVideoDescription": "Enter video description",
446+
"enterImageDescription": "Enter image description",
447+
"enterPdfDescription": "Enter PDF description"
440448
}

locales/kn.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,5 +430,13 @@
430430
"allowLocation": "ಸ್ಥಳ ಪ್ರವೇಶವನ್ನು ಅನುಮತಿಸಿ",
431431
"locationRequired": "ಸ್ಥಳ ಅಗತ್ಯವಿದೆ",
432432
"locationRequiredForFeatures": "ಹವಾಮಾನ-ಆಧಾರಿತ ಆರೈಕೆ ಸಲಹೆಗಳು ಮತ್ತು ಸ್ಥಳೀಯ ಮಾರುಕಟ್ಟೆ ಮಾಹಿತಿಯನ್ನು ಒದಗಿಸಲು ಸ್ಥಳ ಪ್ರವೇಶ ಅಗತ್ಯವಿದೆ. ನೀವು ಅದನ್ನು ನಂತರ ಸೆಟ್ಟಿಂಗ್‌ಗಳಿಂದ ಸಕ್ರಿಯಗೊಳಿಸಬಹುದು.",
433-
"ok": "ಸರಿ"
433+
"ok": "ಸರಿ",
434+
"optional": "ಐಚ್ಛಿಕ",
435+
"autoTranslateHint": "ಖಾಲಿ ಬಿಟ್ಟರೆ ಸ್ವಯಂ ಅನುವಾದವಾಗುತ್ತದೆ",
436+
"autoTranslateFromEnglish": "ಖಾಲಿ ಬಿಟ್ಟರೆ ಇಂಗ್ಲಿಷ್‌ನಿಂದ ಸ್ವಯಂ ಅನುವಾದವಾಗುತ್ತದೆ",
437+
"autoTranslateBidirectional": "ಇಂಗ್ಲಿಷ್ ↔ ಕನ್ನಡ ನಡುವೆ ಸ್ವಯಂ ಅನುವಾದಿಸುತ್ತದೆ",
438+
"translating": "ಅನುವಾದಿಸಲಾಗುತ್ತಿದೆ...",
439+
"enterVideoDescription": "ವೀಡಿಯೊ ವಿವರಣೆ ನಮೂದಿಸಿ",
440+
"enterImageDescription": "ಚಿತ್ರ ವಿವರಣೆ ನಮೂದಿಸಿ",
441+
"enterPdfDescription": "PDF ವಿವರಣೆ ನಮೂದಿಸಿ"
434442
}

0 commit comments

Comments
 (0)