From 6d175c4595f9e8e9f8e209dcd5112f0785f16201 Mon Sep 17 00:00:00 2001 From: "LAPTOP-PMQPEEI6\\ezeelinkindonesia" Date: Tue, 8 Oct 2019 23:16:43 +0700 Subject: [PATCH 1/2] Add All Country translations and FIxed Function Calculator --- .idea/.name | 1 + .idea/misc.xml | 2 +- .../com/exuberant/calci/HomeActivity.java | 44 +++++++++++++++---- .../main/res/layout/content_answer_view.xml | 4 +- .../main/res/layout/content_number_board.xml | 38 ++++++++-------- app/src/main/res/values-cs/strings.xml | 24 ++++++++++ app/src/main/res/values-de/strings.xml | 24 ++++++++++ app/src/main/res/values-es/strings.xml | 24 ++++++++++ app/src/main/res/values-fr/strings.xml | 24 ++++++++++ app/src/main/res/values-id/strings.xml | 24 ++++++++++ app/src/main/res/values-it/strings.xml | 24 ++++++++++ app/src/main/res/values-ja/strings.xml | 24 ++++++++++ app/src/main/res/values-nl/strings.xml | 24 ++++++++++ app/src/main/res/values-pl/strings.xml | 24 ++++++++++ app/src/main/res/values-pt-rBR/strings.xml | 24 ++++++++++ app/src/main/res/values-ru/strings.xml | 24 ++++++++++ app/src/main/res/values-sk/strings.xml | 24 ++++++++++ app/src/main/res/values-sv/strings.xml | 24 ++++++++++ app/src/main/res/values-zh-rCN/strings.xml | 24 ++++++++++ app/src/main/res/values/strings.xml | 21 +++++++++ 20 files changed, 415 insertions(+), 31 deletions(-) create mode 100644 .idea/.name create mode 100644 app/src/main/res/values-cs/strings.xml create mode 100644 app/src/main/res/values-de/strings.xml create mode 100644 app/src/main/res/values-es/strings.xml create mode 100644 app/src/main/res/values-fr/strings.xml create mode 100644 app/src/main/res/values-id/strings.xml create mode 100644 app/src/main/res/values-it/strings.xml create mode 100644 app/src/main/res/values-ja/strings.xml create mode 100644 app/src/main/res/values-nl/strings.xml create mode 100644 app/src/main/res/values-pl/strings.xml create mode 100644 app/src/main/res/values-pt-rBR/strings.xml create mode 100644 app/src/main/res/values-ru/strings.xml create mode 100644 app/src/main/res/values-sk/strings.xml create mode 100644 app/src/main/res/values-sv/strings.xml create mode 100644 app/src/main/res/values-zh-rCN/strings.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..1e2600a --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Calci \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 37a7509..dfd2c79 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/src/main/java/com/exuberant/calci/HomeActivity.java b/app/src/main/java/com/exuberant/calci/HomeActivity.java index c0f9ac0..014910c 100644 --- a/app/src/main/java/com/exuberant/calci/HomeActivity.java +++ b/app/src/main/java/com/exuberant/calci/HomeActivity.java @@ -1,23 +1,29 @@ package com.exuberant.calci; import androidx.appcompat.app.AppCompatActivity; - import android.os.Bundle; import android.view.View; import android.widget.TextView; -import android.widget.Toast; - import com.google.android.material.button.MaterialButton; public class HomeActivity extends AppCompatActivity implements View.OnClickListener { private String currentNumber = "", totalCalculation = ""; + private char operator ; + private double firstOperand; + private double secondOperand; private TextView totalCalculationTextView, currentAnswerTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); + + initializeViews(); + + } + + private void initializeViews() { findViewById(R.id.btn_zero).setOnClickListener(this); findViewById(R.id.btn_one).setOnClickListener(this); findViewById(R.id.btn_two).setOnClickListener(this); @@ -62,8 +68,11 @@ public void onClick(View view) { //Handle calculation case R.id.btn_equals: + firstOperand = Double.valueOf(totalCalculation.substring(0,totalCalculation.length()-1)); + secondOperand = Double.valueOf(currentNumber); + operator = totalCalculation.charAt(totalCalculation.length()-1); totalCalculation += currentNumber; - calculateAnswer(); + calculateAnswer(firstOperand, secondOperand, operator); break; //Handle other numerical button clicks @@ -93,20 +102,37 @@ private double add(double a, double b){ } private double sub(double a, double b){ - return a + b; + return a - b; } private double mul(double a, double b){ - return a + b; + return a * b; } private double div(double a, double b){ - return a + b; + return a / b; } - private void calculateAnswer(){ + private void calculateAnswer(Double firstOperand, Double secondOperand, char operator){ //Use totalCalculation string to get final answer and display it double answer = 0.0; + if(operator == '+') + { + answer = add(firstOperand, secondOperand); + } + else if(operator == '-') + { + answer = sub(firstOperand, secondOperand); + } + else if (operator == '/') + { + answer = div(firstOperand, secondOperand); + } + else + { + answer = mul(firstOperand, secondOperand); + } + currentNumber = String.valueOf(answer); updateDisplay(); } -} +} \ No newline at end of file diff --git a/app/src/main/res/layout/content_answer_view.xml b/app/src/main/res/layout/content_answer_view.xml index 970907e..cfeceec 100644 --- a/app/src/main/res/layout/content_answer_view.xml +++ b/app/src/main/res/layout/content_answer_view.xml @@ -11,7 +11,7 @@ android:layout_marginTop="16dp" android:gravity="end" android:textSize="24sp" - android:text="Total Calculation" + android:text="@string/total_calculation" android:textColor="#757575" android:layout_width="match_parent" android:layout_height="wrap_content"/> @@ -24,7 +24,7 @@ android:layout_marginEnd="16dp" android:gravity="end" android:textSize="32sp" - android:text="Current Calculation" + android:text="@string/current_calculation" android:textColor="#757575" android:layout_width="match_parent" android:layout_height="wrap_content"/> diff --git a/app/src/main/res/layout/content_number_board.xml b/app/src/main/res/layout/content_number_board.xml index d98056e..e6a81d6 100644 --- a/app/src/main/res/layout/content_number_board.xml +++ b/app/src/main/res/layout/content_number_board.xml @@ -8,7 +8,7 @@ + Calci + Celkový výpočet + Aktuální výpočet + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml new file mode 100644 index 0000000..062ae54 --- /dev/null +++ b/app/src/main/res/values-de/strings.xml @@ -0,0 +1,24 @@ + + Calci + Gesamtberechnung + Aktuelle Berechnung + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml new file mode 100644 index 0000000..0cfdcc8 --- /dev/null +++ b/app/src/main/res/values-es/strings.xml @@ -0,0 +1,24 @@ + + Calci + Cálculo total + Cálculo actual + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml new file mode 100644 index 0000000..e9bd5aa --- /dev/null +++ b/app/src/main/res/values-fr/strings.xml @@ -0,0 +1,24 @@ + + Calci + Calcul total + Calcul du courant + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml new file mode 100644 index 0000000..8342c86 --- /dev/null +++ b/app/src/main/res/values-id/strings.xml @@ -0,0 +1,24 @@ + + Calci + Total Hitung + Hitungan Saat Ini + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml new file mode 100644 index 0000000..a76a7dc --- /dev/null +++ b/app/src/main/res/values-it/strings.xml @@ -0,0 +1,24 @@ + + Calci + Calcolo totale + Calcolo corrente + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml new file mode 100644 index 0000000..0edc421 --- /dev/null +++ b/app/src/main/res/values-ja/strings.xml @@ -0,0 +1,24 @@ + + Calci + 合計計算 + 現在の計算 + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml new file mode 100644 index 0000000..22eab14 --- /dev/null +++ b/app/src/main/res/values-nl/strings.xml @@ -0,0 +1,24 @@ + + Calci + Totale berekening + Huidige berekening + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml new file mode 100644 index 0000000..dce1940 --- /dev/null +++ b/app/src/main/res/values-pl/strings.xml @@ -0,0 +1,24 @@ + + Calci + Łączna kalkulacja + Obecne obliczenia + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml new file mode 100644 index 0000000..4fcddfb --- /dev/null +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -0,0 +1,24 @@ + + Calci + Calcular Total + Cálculo atual + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml new file mode 100644 index 0000000..f8b70e8 --- /dev/null +++ b/app/src/main/res/values-ru/strings.xml @@ -0,0 +1,24 @@ + + Calci + Общий расчет + Текущий расчет + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml new file mode 100644 index 0000000..1808af5 --- /dev/null +++ b/app/src/main/res/values-sk/strings.xml @@ -0,0 +1,24 @@ + + Calci + Celkový výpočet + Aktuálny výpočet + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml new file mode 100644 index 0000000..2337065 --- /dev/null +++ b/app/src/main/res/values-sv/strings.xml @@ -0,0 +1,24 @@ + + Calci + Total beräkning + Aktuell beräkning + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml new file mode 100644 index 0000000..7855608 --- /dev/null +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -0,0 +1,24 @@ + + Calci + 总计计算 + 当前计算 + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3c3a285..a77dcef 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,24 @@ Calci + Total calculation + Current calculation + C + ( + ) + / + 7 + 8 + 9 + X + 4 + 5 + 6 + - + 1 + 2 + 3 + + + 0 + . + = From a767b8b73266616b70674dabf26a07e92a3ebc43 Mon Sep 17 00:00:00 2001 From: "LAPTOP-PMQPEEI6\\ezeelinkindonesia" Date: Tue, 8 Oct 2019 23:20:48 +0700 Subject: [PATCH 2/2] no message --- .idea/.name | 1 - .idea/codeStyles/Project.xml | 116 ------------------------- .idea/misc.xml | 9 -- .idea/runConfigurations.xml | 12 --- .idea/vcs.xml | 6 -- app/src/main/res/values-it/strings.xml | 24 +---- 6 files changed, 3 insertions(+), 165 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/codeStyles/Project.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/runConfigurations.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 1e2600a..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Calci \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 681f41a..0000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - -
- - - - xmlns:android - - ^$ - - - -
-
- - - - xmlns:.* - - ^$ - - - BY_NAME - -
-
- - - - .*:id - - http://schemas.android.com/apk/res/android - - - -
-
- - - - .*:name - - http://schemas.android.com/apk/res/android - - - -
-
- - - - name - - ^$ - - - -
-
- - - - style - - ^$ - - - -
-
- - - - .* - - ^$ - - - BY_NAME - -
-
- - - - .* - - http://schemas.android.com/apk/res/android - - - ANDROID_ATTRIBUTE_ORDER - -
-
- - - - .* - - .* - - - BY_NAME - -
-
-
-
-
-
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index dfd2c79..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index a76a7dc..b682571 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -1,24 +1,6 @@ + Calci - Calcolo totale Calcolo corrente - C - ( - ) - / - 7 - 8 - 9 - X - 4 - 5 - 6 - - - 1 - 2 - 3 - + - 0 - . - = - + Risultato + \ No newline at end of file