Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added different Currency Option in Logbook #957

Open
wants to merge 2 commits into
base: gsoc2022
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
Expand Down Expand Up @@ -233,11 +234,17 @@
android:text="@string/logbook_priceperlitre"
android:textSize="12sp"/>

<Spinner
android:id="@+id/currency_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>

<EditText
android:id="@+id/logbook_add_fueling_priceperlitretext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/spacing_large"
android:layout_marginRight="16dp"
android:layout_weight="2"
android:hint="0.00 €/l"
android:inputType="numberDecimal"/>
Expand Down
8 changes: 8 additions & 0 deletions org.envirocar.app/res/values/strings_logbook.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,12 @@
<string name="logbook_background_no_cars_second">Please create a car before accessing this feature.</string>
<string name="logbook_background_no_internet_first">NO INTERNET CONNECTION</string>
<string name="logbook_background_no_internet_second">You are offline,To access the logs you need an active internet connection</string>

<string-array name="currency">
<item>€</item>
<item>$</item>
<item>¥</item>
<item>£</item>
</string-array>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
Expand Down Expand Up @@ -131,6 +134,8 @@ public class LogbookAddFuelingFragment extends BaseInjectorFragment {
protected TextView infoBackgroundFirst;
@BindView(R.id.layout_general_info_background_secondline)
protected TextView infoBackgroundSecond;
@BindView(R.id.currency_options)
protected Spinner currencySpinner;

@Inject
protected CarPreferenceHandler carHandler;
Expand All @@ -149,6 +154,25 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
View view = inflater.inflate(R.layout.activity_logbook_add_fueling_card, container, false);
ButterKnife.bind(this, view);

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(),R.array.currency, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
currencySpinner.setAdapter(adapter);
currencySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

String text = adapterView.getItemAtPosition(i).toString();
addFuelingPricePerLitreText.setHint("0.00 "+text+"/l");
addFuelingTotalCostText.setHint("0.00 "+text);

}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});

view.setOnClickListener(v -> hideKeyboard(view));
contentView.setOnClickListener(v -> hideKeyboard(contentView));

Expand Down