Psyter Android Client Application¶
Version: 2.0.15 (Build 50)
Package: com.psyter.www
Platform: Android 5.0+ (API 21+)
Target SDK: 33 (Android 13)
Last Updated: November 6, 2025
๐ฑ Overview¶
The Psyter Android Client application is a mental health telemedicine platform that connects patients with healthcare providers. It enables users to:
- Search and book appointments with mental health professionals
- Conduct secure video/audio consultations via WebRTC
- Manage their mental health journey (diary, homework, questionnaires)
- Process payments securely
- Receive push notifications for appointments and messages
- Access educational content and resources
โจ Key Features¶
Patient Features¶
- โ User Registration & Authentication - Email/phone-based registration with OTP verification
- โ Google & Apple Sign-In - Social authentication support
- โ Provider Search & Filtering - Find care providers by specialty, language, availability
- โ Appointment Booking - Calendar-based slot selection with payment integration
- โ Video Consultations - Real-time video/audio calls using WebRTC
- โ Secure Messaging - Chat with care providers
- โ Mental Health Diary - Private journaling feature
- โ Homework Management - Complete assignments from providers
- โ Questionnaires - Mental health screening assessments
- โ Payment Integration - Wallet and direct payment options
- โ Push Notifications - Appointment reminders and message alerts
- โ Multi-language Support - English and Arabic (RTL support)
- โ Offline Support - WorkManager for background tasks
Technical Features¶
- ๐ Firebase Integration - Auth, FCM, Crashlytics, Analytics
- ๐น WebRTC Video Calls - Peer-to-peer video/audio communication
- ๐ WebSocket Support - Real-time presence and messaging
- ๐ณ Payment Gateway - STS Payment integration
- ๐ PDF Viewer - View prescriptions and documents
- ๐ Background Processing - WorkManager for notifications
๐ ๏ธ Technology Stack¶
Core Technologies¶
- Language: Java
- Min SDK: 21 (Android 5.0 Lollipop)
- Target SDK: 33 (Android 13)
- Compile SDK: 33
- Build Tools: Gradle 7.x
- Architecture: MVC with Repository Pattern
Major Dependencies¶
AndroidX Libraries¶
androidx.appcompat:appcompat:1.1.0
androidx.constraintlayout:constraintlayout:1.1.3
androidx.navigation:navigation-fragment:2.5.0
androidx.navigation:navigation-ui:2.5.0
androidx.work:work-runtime-ktx:2.7.0
androidx.swiperefreshlayout:swiperefreshlayout:1.0.0
com.google.android.material:material:1.2.0-alpha06
Firebase Services¶
com.google.firebase:firebase-messaging:15.0.0
com.google.firebase:firebase-auth:22.1.1
com.google.firebase:firebase-crashlytics:18.4.1
com.google.firebase:firebase-analytics:21.3.0
Video & Real-time Communication¶
org.webrtc:google-webrtc:1.0.28513
com.neovisionaries:nv-websocket-client:2.3
Networking & Data¶
com.amitshekhar.android:android-networking:1.0.2
com.google.code.gson:gson:2.8.5
com.loopj.android:android-async-http:1.4.9
UI/UX Libraries¶
com.github.bumptech.glide:glide:4.10.0
de.hdodenhof:circleimageview:2.1.0
com.squareup.picasso:picasso:2.4.0
com.github.GrenderG:Toasty:1.4.0
com.github.ybq:Android-SpinKit:1.4.0
com.crystal:crystalrangeseekbar:1.1.3
Document & Media¶
com.github.barteksc:android-pdf-viewer:2.8.2
io.github.ponnamkarthik:richlinkpreview:1.0.9
Authentication¶
com.google.android.gms:play-services-auth:20.4.0
com.github.aabhasr1:OtpView:v1.1.2
nu.aaro.gustav:passwordstrengthmeter:0.4
๐ Prerequisites¶
Development Environment¶
- Android Studio: Arctic Fox (2020.3.1) or later
- JDK: JDK 8 (1.8) or later
- Gradle: 7.0+
- NDK: 23.1.7779620 (for WebRTC native libraries)
Required SDKs & Tools¶
- Android SDK Platform 33
- Android SDK Build-Tools 33.x.x
- Google Play Services
- Android Support Repository
- Google Repository
Optional Tools¶
- Android Emulator with Google Play (for Firebase testing)
- Physical Device (recommended for video call testing)
- Charles Proxy / Proxyman (for network debugging)
๐ Setup Instructions¶
1. Clone the Repository¶
# Clone the main project
git clone <repository-url>
cd Psyter/Android
2. Configure Firebase¶
Development Environment¶
- Download
google-services.jsonfrom Firebase Console (psyterdev project) - Place it in
Android/app/directory - Ensure applicationId matches:
com.psyter.www
Production Environment¶
- Use production Firebase project configuration
- Replace
google-services.jsonwith production file
Firebase Services Used:
- Firebase Authentication (Email/Phone)
- Firebase Cloud Messaging (FCM)
- Firebase Crashlytics
- Firebase Analytics
3. Configure Build Variants¶
The app has commented build configurations in app/build.gradle. Update based on your environment:
For Development:
buildTypes {
debug {
buildConfigField "String", "BaseURL", "\"https://dev2.innotech-sa.com/Psyter/Master/APIs/\""
buildConfigField "String", "BaseURLScheduling", "\"https://team-server.innotech-sa.com/Scheduling/SchedulingAPI/\""
buildConfigField "String", "AppToken", "\"f97f3496-a2c8-4c20-84ef-b5a8e6388038\""
// Add other configurations
}
}
For Production:
- Edit Utils.java and set isLive = true
- Verify URLs point to production servers
- Ensure AppToken is set to production value
4. Install Dependencies¶
# Open Android Studio and let it sync Gradle
# Or use command line:
./gradlew build --refresh-dependencies
5. Update API Endpoints (if needed)¶
Edit Android/app/src/main/java/com/psyter/www/Stats/Utils.java:
// For production
public static boolean isLive = true;
public static String BaseURL = "https://webapis.psyter.com/";
public static String BaseURLScheduling = "http://scheduling.innotech-sa.com/";
public static String AppToken = "9ae12b99-d42f-4006-81d4-87687e64dc32";
// For development
public static boolean isLive = false;
public static String BaseURL = "https://dev2.innotech-sa.com/Psyter/Master/APIs/";
// ... other dev URLs
6. Configure WebSocket Server¶
Edit WebSocket connection settings in relevant collaboration classes or configuration:
- Development: wss://dev-server.innotech-sa.com:3333
- Production: wss://production-server.psyter.com:3333
7. Build the Project¶
Debug Build (Development)¶
./gradlew assembleDebug
Release Build (Production)¶
# Generate signed APK
./gradlew assembleRelease
# Or use Android Studio:
# Build > Generate Signed Bundle / APK
Note: Release builds require:
- Keystore file for signing
- Keystore password
- Key alias and password
- ProGuard configuration (already included)
๐ Running the Application¶
On Emulator¶
# Start emulator
emulator -avd <AVD_NAME>
# Install and run
./gradlew installDebug
adb shell am start -n com.psyter.www/.Registration.Activities.SplashActivity
On Physical Device¶
# Enable USB Debugging on device
# Connect device via USB
# Install
./gradlew installDebug
# Run from Android Studio (recommended for debugging)
Required Permissions (Runtime)¶
The app will request these permissions at runtime:
- โ
Camera (for video calls)
- โ
Microphone (for audio calls)
- โ
Storage (for file uploads/downloads)
- โ
Notifications (for push notifications)
- โ
System Alert Window (for incoming call overlay)
๐ Project Structure¶
Android/
โโโ app/
โ โโโ src/
โ โ โโโ main/
โ โ โ โโโ java/com/psyter/www/
โ โ โ โ โโโ CareProvider/ # Provider-specific features (mostly unused in client app)
โ โ โ โ โ โโโ Activities/
โ โ โ โ โ โโโ Fragments/
โ โ โ โ โ โโโ Adapters/
โ โ โ โ โ โโโ DataModels/
โ โ โ โ โโโ Client/ # Patient/Client features
โ โ โ โ โ โโโ Activities/ # HomeWorkSubmit, PaymentWeb, PDFViewer, etc.
โ โ โ โ โ โโโ Fragments/ # FindCP, MyCPs, Diary, Homework, Profile
โ โ โ โ โ โโโ BookSlots/ # Appointment booking flow
โ โ โ โ โ โโโ Adapters/
โ โ โ โ โ โโโ DataModels/
โ โ โ โ โโโ CommonUser/ # Shared client/provider features
โ โ โ โ โ โโโ Activities/ # CarePList, CarePDetail, ForgotPassword
โ โ โ โ โ โโโ Adapters/
โ โ โ โ โ โโโ DataModel/
โ โ โ โ โโโ Registration/ # Auth & onboarding
โ โ โ โ โ โโโ Activities/ # Splash, Login, Register, Questionnaire
โ โ โ โ โ โโโ Adapters/
โ โ โ โ โ โโโ DataModel/
โ โ โ โ โโโ Collaboration/ # WebRTC video calls
โ โ โ โ โ โโโ Presence/ # CollaborationMain, IncomingCall, WebSocket
โ โ โ โ โ โโโ Common/ # WebRTC helpers, models
โ โ โ โ โโโ Scheduling/ # Appointment scheduling
โ โ โ โ โ โโโ WeeklySchedule/
โ โ โ โ โโโ Stats/ # Utilities & helpers
โ โ โ โ โ โโโ Utils.java # Constants, URLs, API endpoints
โ โ โ โ โ โโโ MySharedPreferences.java # Local storage
โ โ โ โ โ โโโ LocaleUtils.java # Localization
โ โ โ โ โ โโโ ...
โ โ โ โ โโโ views/ # Custom views & fragments
โ โ โ โ โ โโโ activity/ # RegisterActivity, OnboardingActivity
โ โ โ โ โ โโโ fragments/ # Registration flow fragments
โ โ โ โ โโโ workers/ # WorkManager tasks
โ โ โ โ โโโ AlarmWorkManager.java
โ โ โ โ โโโ ...
โ โ โ โโโ res/
โ โ โ โ โโโ layout/ # XML layouts
โ โ โ โ โโโ drawable/ # Images, icons
โ โ โ โ โโโ values/ # Strings, colors, dimensions
โ โ โ โ โโโ values-ar/ # Arabic translations
โ โ โ โโโ assets/ # Static files
โ โ โ โโโ AndroidManifest.xml # App configuration
โ โ โโโ test/ # Unit tests (minimal)
โ โโโ libs/ # Local AAR files
โ โโโ build.gradle # App-level build configuration
โ โโโ google-services.json # Firebase configuration
โ โโโ proguard-rules.pro # Code obfuscation rules
โโโ duo-navigation-drawer/ # Navigation drawer library module
โโโ intlphoneinput/ # International phone input module
โโโ gradle/ # Gradle wrapper
โโโ build.gradle # Project-level build configuration
โโโ settings.gradle # Module settings
โโโ README.md # This file
๐ Key Classes & Components¶
Authentication & User Management¶
LoginActivity.java- User login with email/phone/Google/AppleRegisterActivity.java- New user registration flowRegisterBasicInfo.java- Registration step 1: Basic infoRegisterVerification.java- Registration step 2: OTP verificationMySharedPreferences.java- Local data persistence (user session, preferences)Utils.java- Global constants, API endpoints, utility functions
Main Navigation¶
BaseClientActivityMain.java- Main activity with bottom navigation (Client app)BaseCarePActivityMain.java- Main activity for care providers (minimal use)MainFragmentClient.java- Home screen fragmentFindCPFragment.java- Search care providersMyCPFragment.java- My care providers listMyProfileFragmentClient.java- User profile
Video Calls & WebRTC¶
CollaborationMain.java- WebRTC video call implementationIncomingCall.java- Incoming call notification screenManagePresenceeClient.java- WebSocket presence managementWebAPICall.java- ICE server configuration
Appointment Booking¶
MonthViewClient.java- Calendar month viewSelectSlotActivity.java- Time slot selectionSlotPaymentSuggestActivity.java- Payment optionsPaymentWebActivity.java- Payment gateway WebView
Features¶
MyDiaryFragment.java- Mental health diaryMyHomeWorkFragment.java- Homework assignmentsMyQyestionaireFragment.java- Questionnaires/assessmentsCarePListActivity.java- Care provider listing with filtersCarePDetailActivity.java- Provider profile with YouTube bio
Firebase Services¶
MyFirebaseMessagingService.java- FCM push notification handlerAlarmWorkManager.java- Background notification scheduling
Utilities¶
TransparentProgressDialog.java- Loading dialogsLocaleUtils.java- Language switching (English/Arabic)LangHelper.java- RTL supportclsStoragePermission.java- Runtime permission handlers
๐ง Configuration Files¶
AndroidManifest.xml¶
Defines:
- App permissions (Camera, Mic, Storage, Network, etc.)
- Activities and their launch modes
- Firebase services
- Deep link handling (if configured)
build.gradle (app)¶
- Build variants (debug/release)
- Dependencies
- ProGuard rules
- Build configuration fields
- Data binding enabled
google-services.json¶
- Firebase project configuration
- FCM sender ID
- API keys (auto-configured by plugin)
proguard-rules.pro¶
- Code obfuscation rules for release builds
- Keep rules for models and libraries
๐ Security Considerations¶
Current Implementation¶
- โ HTTPS for all API calls
- โ Bearer token authentication
- โ Firebase Auth for user management
- โ Certificate pinning potential (not currently implemented)
- โ ๏ธ Passwords stored in SharedPreferences (should encrypt)
- โ ๏ธ API tokens hardcoded in source (should use Build Config or secure vault)
- โ ๏ธ No SSL pinning (vulnerable to MITM)
Recommendations¶
- Encrypt SharedPreferences - Use EncryptedSharedPreferences from Security-Crypto library
- Move secrets to BuildConfig - Remove hardcoded tokens from Utils.java
- Implement Certificate Pinning - Add OkHttp certificate pinner
- Add Root Detection - Check for rooted devices
- Obfuscate Release Builds - Ensure ProGuard is working correctly
๐งช Testing¶
Unit Tests¶
Currently minimal unit test coverage. Located in:
app/src/test/java/com/psyter/www/
To run:
./gradlew test
Instrumentation Tests¶
Located in:
app/src/androidTest/java/
To run:
./gradlew connectedAndroidTest
Manual Testing Checklist¶
- User registration with email
- User registration with phone + OTP
- Login with credentials
- Login with Google
- Login with Apple (iOS only, but code present)
- Search care providers
- Filter providers (specialty, language, availability)
- View provider profile
- Book appointment
- Process payment
- Join video call
- Camera/microphone toggle during call
- Screen sharing (if supported)
- Send/receive messages
- Create diary entry
- Complete homework assignment
- Fill questionnaire
- Receive push notifications
- Language switching (EN โ AR)
๐ Common Issues & Troubleshooting¶
Issue: Build fails with “Duplicate class” error¶
Solution: Clean and rebuild
./gradlew clean build
Issue: Firebase services not working¶
Solution:
1. Ensure google-services.json is in app/ directory
2. Verify applicationId matches Firebase project
3. Check build.gradle has apply plugin: 'com.google.gms.google-services' at the bottom
Issue: WebRTC video not showing¶
Solution:
1. Check camera/microphone permissions granted
2. Verify WebSocket connection to signaling server
3. Check ICE server configuration in WebAPICall.java
4. Test on physical device (emulator has limited WebRTC support)
Issue: App crashes on startup¶
Solution:
1. Check logcat for stack trace: adb logcat | grep AndroidRuntime
2. Verify Firebase Crashlytics for crash reports
3. Common causes:
- Missing permissions in manifest
- Network connectivity issues
- Invalid server URLs in Utils.java
Issue: Payment gateway not loading¶
Solution:
1. Check WebView permissions
2. Verify payment URL format in SlotPaymentSuggestActivity
3. Check network security config allows payment gateway domain
4. Test with development payment credentials first
Issue: Push notifications not received¶
Solution:
1. Verify FCM token generation in MyFirebaseMessagingService
2. Check token is sent to backend via API
3. Test with Firebase Console “Send test message”
4. Ensure app is not in Doze mode or battery optimization
5. Check notification channel creation (Android 8+)
Issue: Arabic (RTL) layout issues¶
Solution:
1. Ensure android:supportsRtl="true" in manifest
2. Use start/end instead of left/right in layouts
3. Check LocaleUtils.java for proper RTL configuration
4. Test with “Force RTL layout direction” in Developer Options
Issue: “NetworkOnMainThreadException”¶
Solution:
- All network calls should be on background thread
- Use AndroidNetworking library (already implemented)
- Check for any direct HttpURLConnection usage
๐ Performance Optimization¶
Current Performance¶
- App size: ~50-60 MB (with dependencies)
- Cold start time: ~2-3 seconds
- Memory usage: ~100-150 MB typical
Optimization Recommendations¶
- Enable R8/ProGuard - Reduce APK size by 30-40%
- Use App Bundle - Google Play dynamic delivery
- Lazy Load Images - Already using Glide with caching
- Optimize Layouts - Use ConstraintLayout, avoid nested layouts
- Reduce Dependencies - Remove unused libraries
- Enable Data Binding - Already enabled, use more widely
- Background Task Optimization - Use WorkManager (already implemented)
๐ API Integration¶
Base URLs¶
- Production API:
https://webapis.psyter.com/ - Production Web:
https://www.psyter.com/ - Scheduling API:
http://scheduling.innotech-sa.com/ - Development API:
https://dev2.innotech-sa.com/Psyter/Master/APIs/
Authentication¶
// Example API call with authentication
AndroidNetworking.post(Utils.BaseURL + "endpoint")
.addHeaders("Authorization", "Bearer " + Utils.TokenPsyter)
.addHeaders("Content-Type", "application/json")
.addJSONObjectBody(requestJson)
.setPriority(Priority.HIGH)
.build()
.getAsJSONObject(new JSONObjectRequestListener() {
@Override
public void onResponse(JSONObject response) {
// Handle response
}
@Override
public void onError(ANError anError) {
// Handle error
}
});
Key Endpoints (from Utils.java)¶
- Auth:
Authenticate - Registration:
Patient/RegisterClient - Providers:
ServiceProvider/GetServiceProviderListByCatalogueFilter - Booking:
ServiceProvider/GetServiceProviderAvailableDates - Payment:
Payment/InsertPayForData - Messaging:
Collaboration/SendMessage - Notifications:
Notification/SaveDeviceFcmToken
๐ CI/CD & Deployment¶
Current State¶
- CI/CD: Manual build and deployment
- Distribution: Google Play Store + Direct APK distribution
Recommended CI/CD Setup¶
Using GitHub Actions¶
name: Android CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Run tests
run: ./gradlew test
- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: app
path: app/build/outputs/apk/debug/app-debug.apk
Play Store Deployment¶
- Generate signed release bundle:
./gradlew bundleRelease - Upload AAB to Play Console
- Update release notes
- Roll out to testing track โ production
๐ Contributing Guidelines¶
Code Style¶
- Follow Java naming conventions
- Use meaningful variable names
- Add comments for complex logic
- Keep methods under 100 lines
- Use Android Studio auto-formatting (Ctrl+Alt+L)
Git Workflow¶
- Create feature branch:
feature/feature-name - Make changes with clear commit messages
- Test thoroughly on device
- Create pull request with description
- Wait for code review
- Merge after approval
Pull Request Template¶
## Description
[Describe the changes]
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests added/updated
- [ ] Manual testing completed
- [ ] Tested on multiple devices/Android versions
## Screenshots (if UI changes)
[Add screenshots]
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] No new warnings generated
๐ Additional Resources¶
Documentation¶
Related Repositories¶
- APIs: Backend REST API (ASP.NET)
- NodeServer: WebSocket signaling server (Node.js)
- Web: Web portal (ASP.NET MVC)
- AndroidCareProvider: Provider mobile app
Support¶
- Issue Tracker: [Link to issue tracker]
- Wiki: [Link to project wiki]
- Team Chat: [Link to Slack/Teams channel]
๐ Version History¶
v2.0.15 (Current - Build 50)¶
- Current production version
- Bug fixes and stability improvements
Previous Versions¶
- See git tags for detailed version history
๐ License¶
[Add license information]
๐ฅ Maintainers¶
- Android Team: [Team contact information]
- Project Lead: [Lead contact]
Last Updated: November 6, 2025
Document Version: 1.0
Maintained By: Development Team