|
1 | 1 | # Android Calculator |
2 | 2 |
|
3 | | -A modern, feature-rich calculator application for Android devices with a clean interface and powerful computation capabilities. |
| 3 | +An Android calculator application implementing basic and scientific mathematical operations with custom expression parsing. |
4 | 4 |
|
5 | | -## ✨ Features |
| 5 | +## Features |
6 | 6 |
|
7 | | -- **Basic Arithmetic**: Addition, subtraction, multiplication, and division |
8 | | -- **Scientific Functions**: Trigonometric functions, logarithms, exponentials, and more |
9 | | -- **Multiple Themes**: Light, dark, and AMOLED themes with Material Design 3 support |
10 | | -- **Calculation History**: Keep track of previous calculations with persistent storage |
11 | | -- **Expression Parsing**: Custom-built mathematical expression parser for accurate results |
12 | | -- **Responsive Design**: Optimized for both portrait and landscape orientations |
13 | | -- **Precision Control**: Configurable decimal precision and scientific notation |
14 | | -- **Intuitive UI**: Clean, modern interface with haptic feedback support |
| 7 | +- Basic arithmetic operations (addition, subtraction, multiplication, division) |
| 8 | +- Scientific functions (trigonometric, logarithmic, exponential) |
| 9 | +- Expression parsing with operator precedence and parentheses |
| 10 | +- Multiple numbering system support (international, Arabic-Indic, etc.) |
| 11 | +- Calculation history with persistent storage |
| 12 | +- Theme configuration (light, dark, AMOLED) |
| 13 | +- Precision control for decimal output |
| 14 | +- Scientific notation support |
| 15 | +- Quick Settings tile integration |
15 | 16 |
|
16 | | -## 🔧 Technical Details |
| 17 | +## Technical Details |
17 | 18 |
|
18 | | -### Architecture |
| 19 | +### Technology Stack |
19 | 20 | - **Language**: Kotlin |
20 | | -- **UI Framework**: Android Views with View Binding |
21 | | -- **Minimum SDK**: API 21 (Android 5.0) |
22 | | -- **Target SDK**: API 34 (Android 14) |
| 21 | +- **Platform**: Android (API 21-34) |
23 | 22 | - **Build System**: Gradle with Kotlin DSL |
| 23 | +- **UI**: Android Views with View Binding |
| 24 | +- **Architecture**: Activity-based with service components |
24 | 25 |
|
25 | | -### Key Components |
26 | | -- **Custom Calculator Engine**: Built-in mathematical expression evaluator using BigDecimal for precision |
27 | | -- **Theme System**: Dynamic theming with support for system themes and custom color schemes |
28 | | -- **History Management**: JSON-based calculation history with configurable storage limits |
29 | | -- **Preference System**: Comprehensive settings with automatic migration support |
| 26 | +### Core Components |
30 | 27 |
|
31 | | -## 📸 Screenshots |
| 28 | +#### Calculator Engine (`calculator/Calculator.kt`) |
| 29 | +- Mathematical expression evaluation using `BigDecimal` for precision |
| 30 | +- Supports trigonometric, logarithmic, and exponential functions |
| 31 | +- Handles special cases (division by zero, domain errors, syntax errors) |
32 | 32 |
|
33 | | -### Light Theme |
34 | | -<p align="center"> |
35 | | - <img src="app/src/main/res/drawable/screenshots/Screenshot_20250905_235435.png" alt="Light Mode Portrait" width="250"> |
36 | | -</p> |
| 33 | +#### Expression Parser (`calculator/parser/Expression.kt`) |
| 34 | +- Converts user input into evaluable mathematical expressions |
| 35 | +- Handles symbol substitution (× → *, ÷ → /) |
| 36 | +- Manages operator precedence and parentheses |
| 37 | +- Formats percentage calculations |
37 | 38 |
|
38 | | -### Dark Theme |
39 | | -<p align="center"> |
40 | | - <img src="app/src/main/res/drawable/screenshots/Screenshot_20250906_000106.png" alt="Dark Mode Portrait" width="250"> |
41 | | - <img src="app/src/main/res/drawable/screenshots/Screenshot_20250906_000121.png" alt="Dark Mode Settings" width="250"> |
42 | | -</p> |
| 39 | +#### History Management (`history/History.kt`) |
| 40 | +- JSON-based storage using Gson |
| 41 | +- Persistent calculation records with timestamps |
| 42 | +- Configurable history limits |
43 | 43 |
|
44 | | -### Scientific Mode & Features |
45 | | -<p align="center"> |
46 | | - <img src="app/src/main/res/drawable/screenshots/Screenshot_20250906_000718.png" alt="Scientific Mode" width="250"> |
47 | | - <img src="app/src/main/res/drawable/screenshots/Screenshot_20250906_000742.png" alt="History View" width="250"> |
48 | | - <img src="app/src/main/res/drawable/screenshots/Screenshot_20250906_001533.png" alt="Advanced Calculations" width="250"> |
49 | | -</p> |
| 44 | +### Project Structure |
50 | 45 |
|
51 | | -## 🚀 Getting Started |
| 46 | +``` |
| 47 | +app/src/main/ |
| 48 | +├── java/com/android/calculator/ |
| 49 | +│ ├── activities/ # Activity classes (MainActivity, SettingsActivity, AboutActivity) |
| 50 | +│ ├── calculator/ # Core calculation logic |
| 51 | +│ │ ├── Calculator.kt # Mathematical operations implementation |
| 52 | +│ │ └── parser/ # Expression parsing utilities |
| 53 | +│ ├── history/ # Calculation history management |
| 54 | +│ ├── services/ # Background services (Quick Settings tile) |
| 55 | +│ └── util/ # Utility classes (theme, preferences, scientific mode) |
| 56 | +└── res/ # Android resources (layouts, values, drawables) |
| 57 | +``` |
| 58 | + |
| 59 | +## Building the Project |
52 | 60 |
|
53 | 61 | ### Prerequisites |
54 | | -- Android Studio Arctic Fox (2020.3.1) or later |
| 62 | +- Android Studio Hedgehog (2023.1.1) or later |
55 | 63 | - JDK 8 or higher |
56 | 64 | - Android SDK with API 34 |
| 65 | +- Gradle 8.0+ |
57 | 66 |
|
58 | | -### Building the Project |
59 | | - |
60 | | -1. Clone the repository: |
61 | | - ```bash |
62 | | - git clone <your-repository-url> |
63 | | - cd Android_Calculator |
64 | | - ``` |
| 67 | +### Build Commands |
65 | 68 |
|
66 | | -2. Open in Android Studio or build from command line: |
67 | | - ```bash |
68 | | - ./gradlew assembleDebug |
69 | | - ``` |
| 69 | +```bash |
| 70 | +# Clone repository |
| 71 | +git clone https://github.com/HRG-OFFICIAL/Android-Calculator.git |
| 72 | +cd Android-Calculator |
70 | 73 |
|
71 | | -3. Install on device: |
72 | | - ```bash |
73 | | - ./gradlew installDebug |
74 | | - ``` |
| 74 | +# Build debug APK |
| 75 | +./gradlew assembleDebug |
75 | 76 |
|
76 | | -## 🧪 Testing |
| 77 | +# Install on connected device |
| 78 | +./gradlew installDebug |
77 | 79 |
|
78 | | -Run the test suite: |
79 | | -```bash |
80 | | -# Unit tests |
| 80 | +# Run unit tests |
81 | 81 | ./gradlew testDebugUnitTest |
82 | 82 |
|
83 | | -# Instrumented tests |
| 83 | +# Run instrumented tests |
84 | 84 | ./gradlew connectedAndroidTest |
85 | | - |
86 | | -# All tests |
87 | | -./gradlew test |
88 | 85 | ``` |
89 | 86 |
|
90 | | -## 🎨 Customization |
91 | | - |
92 | | -The calculator supports extensive theming through: |
93 | | -- **Color schemes**: Defined in `values/colors.xml` and `values-night/colors.xml` |
94 | | -- **Typography**: Configurable font families and sizes |
95 | | -- **Button styles**: Customizable button appearances and behaviors |
| 87 | +## Configuration |
96 | 88 |
|
97 | | -## 📱 Supported Features |
| 89 | +### Supported Operations |
| 90 | +- Arithmetic: `+`, `-`, `×`, `÷` |
| 91 | +- Exponentiation: `^`, `E` (scientific notation) |
| 92 | +- Functions: `sin`, `cos`, `tan`, `ln`, `log`, `log₂`, `√`, `!` |
| 93 | +- Constants: `π`, `e` |
| 94 | +- Parentheses for precedence control |
98 | 95 |
|
99 | | -### Mathematical Operations |
100 | | -- Basic arithmetic (+, -, ×, ÷) |
101 | | -- Parentheses for operation precedence |
102 | | -- Percentage calculations |
103 | | -- Square root and power operations |
104 | | -- Factorial calculations |
105 | | -- Trigonometric functions (sin, cos, tan) |
106 | | -- Logarithmic functions (ln, log, log₂) |
107 | | -- Constants (π, e) |
| 96 | +### Precision Settings |
| 97 | +- Configurable decimal places (0-15) |
| 98 | +- Scientific notation toggle |
| 99 | +- Rounding mode: HALF_UP |
108 | 100 |
|
109 | | -### User Interface |
110 | | -- Material Design 3 components |
111 | | -- Adaptive layouts for different screen sizes |
112 | | -- Smooth animations and transitions |
113 | | -- Accessibility support |
| 101 | +## Testing |
114 | 102 |
|
115 | | -## 🔒 Privacy |
| 103 | +Unit tests are located in `app/src/test/java/` and cover: |
| 104 | +- Expression parsing |
| 105 | +- Mathematical operations |
| 106 | +- Edge cases (division by zero, invalid operations) |
116 | 107 |
|
117 | | -This calculator app: |
118 | | -- **No network permissions**: All calculations are performed locally |
119 | | -- **No data collection**: No user data is transmitted or stored externally |
120 | | -- **Minimal permissions**: Only requests essential permissions for functionality |
| 108 | +Run tests: |
| 109 | +```bash |
| 110 | +./gradlew test |
| 111 | +``` |
121 | 112 |
|
122 | | -## 🤝 Contributing |
| 113 | +## Permissions |
123 | 114 |
|
124 | | -Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests. |
| 115 | +- `VIBRATE`: Haptic feedback on button presses |
| 116 | +- `SYSTEM_ALERT_WINDOW`: Display overlay for quick access |
| 117 | +- `USE_FULL_SCREEN_INTENT`: Quick Settings tile functionality |
125 | 118 |
|
126 | | -### Development Guidelines |
127 | | -- Follow Kotlin coding conventions |
128 | | -- Write unit tests for new functionality |
129 | | -- Update documentation for significant changes |
130 | | -- Test on multiple screen sizes and orientations |
| 119 | +## Support |
131 | 120 |
|
132 | | -## 📄 License |
| 121 | +If you find this project useful and would like to support its development, you can: |
133 | 122 |
|
134 | | -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 123 | +- Star this repository |
| 124 | +- Report bugs or suggest features |
| 125 | +- [Buy me a coffee](https://buymeacoffee.com/hrgofficial) to support continued development |
135 | 126 |
|
136 | | -## 🏗️ Project Structure |
| 127 | +## License |
137 | 128 |
|
138 | | -``` |
139 | | -app/ |
140 | | -├── src/main/ |
141 | | -│ ├── java/com/android/calculator/ |
142 | | -│ │ ├── activities/ # UI activities |
143 | | -│ │ ├── calculator/ # Core calculation logic |
144 | | -│ │ ├── history/ # History management |
145 | | -│ │ ├── services/ # Background services |
146 | | -│ │ └── util/ # Utility classes |
147 | | -│ └── res/ # Resources (layouts, strings, themes) |
148 | | -└── src/test/ # Unit and integration tests |
149 | | -``` |
| 129 | +This project is licensed under the MIT License - see [LICENSE](LICENSE) file for details. |
0 commit comments