mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
TRACKING APP: Thank you screen
This commit is contained in:
1 parent
d7ffd34dfb
commit
f9c0e3b649
5 files changed
+119
-43
No files matched your search
@@ -125,6 +125,30 @@
|
||||
android:background="@color/sap_yellow" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/thank_you_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_above="@+id/start_tracking_box"
|
||||
android:layout_below="@id/image"
|
||||
android:baselineAligned="false"
|
||||
android:measureWithLargestChild="false"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="invisible"
|
||||
android:padding="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/thank_you_note"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:padding="0dp"
|
||||
android:text="@string/thank_you_you_successfully_participated"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/start_date_layout"
|
||||
android:layout_width="match_parent"
|
||||
@@ -287,6 +311,7 @@
|
||||
android:layout_alignParentLeft="true" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottom_announcement"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
|
||||
@@ -67,5 +67,7 @@
|
||||
<string name="no_qr_code">Sie haben keinen QR-Code?</string>
|
||||
<string name="scan_qr">QR-Code scannen</string>
|
||||
<string name="your_regattas">Ihre Regattas:</string>
|
||||
<string name="close">Schließen</string>
|
||||
<string name="thank_you_you_successfully_participated">Vielen Dank, Sie haben erfolgreich an der Regatta teilgenommen.\n\nIhr SAP Sailing Team</string>
|
||||
|
||||
</resources>
|
||||
@@ -59,5 +59,7 @@
|
||||
<string name="day">Day</string>
|
||||
<string name="please_listen_to_announcements">Please listen to the announcements</string>
|
||||
<string name="your_regattas">Your Regattas:</string>
|
||||
<string name="close">Close</string>
|
||||
<string name="thank_you_you_successfully_participated">Thank you, you have successfully taken part in the regatta.\n\nYour SAP Sailing Team</string>
|
||||
|
||||
</resources>
|
||||
+1
-1
@@ -338,7 +338,7 @@ public class RegattaActivity extends BaseActivity {
|
||||
/**
|
||||
* Check out from regatta;
|
||||
*/
|
||||
private void checkout()
|
||||
public void checkout()
|
||||
{
|
||||
final String checkoutURLStr = prefs.getServerURL()
|
||||
+ prefs.getServerCheckoutPath().replace("{leaderboard-name}",
|
||||
|
||||
+89
-42
@@ -20,6 +20,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
@@ -34,6 +35,8 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
private final int CAMERA_REQUEST_CODE = 3118;
|
||||
private final int SELECT_PHOTO_REQUEST_CODE = 1693;
|
||||
|
||||
private boolean showingThankYouNote;
|
||||
|
||||
private TimerRunnable timer;
|
||||
|
||||
@Override
|
||||
@@ -63,11 +66,55 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
return view;
|
||||
}
|
||||
|
||||
private void switchToThankYouScreen() {
|
||||
showingThankYouNote = true;
|
||||
|
||||
RelativeLayout startsInLayout = (RelativeLayout) getActivity()
|
||||
.findViewById(R.id.start_date_layout);
|
||||
startsInLayout.setVisibility(View.INVISIBLE);
|
||||
|
||||
Button startTrackingButton = (Button) getActivity().findViewById(
|
||||
R.id.start_tracking);
|
||||
startTrackingButton.setBackgroundColor(getActivity().getResources()
|
||||
.getColor(R.color.sap_yellow));
|
||||
startTrackingButton.setText(getActivity().getString(R.string.close));
|
||||
|
||||
TextView bottomAnnouncement = (TextView) getActivity().findViewById(R.id.bottom_announcement);
|
||||
bottomAnnouncement.setVisibility(View.INVISIBLE);
|
||||
|
||||
RelativeLayout thankYouLayout = (RelativeLayout)getActivity().findViewById(R.id.thank_you_layout);
|
||||
thankYouLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
timer = new TimerRunnable();
|
||||
timer.start();
|
||||
|
||||
// TODO delete test
|
||||
|
||||
new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
switchToThankYouScreen();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +127,15 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.start_tracking:
|
||||
if (showingThankYouNote)
|
||||
{
|
||||
RegattaActivity regattaActivity = (RegattaActivity)getActivity();
|
||||
regattaActivity.checkout();
|
||||
}
|
||||
else
|
||||
{
|
||||
showTrackingActivity();
|
||||
}
|
||||
break;
|
||||
case R.id.add_photo_button:
|
||||
showChooseExistingPictureOrTakeNewPhotoAlert();
|
||||
@@ -112,7 +167,8 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
private void showChooseExistingPictureOrTakeNewPhotoAlert() {
|
||||
AlertDialog dialog = new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.add_photo_select)
|
||||
.setMessage(R.string.do_you_want_to_choose_existing_img_or_take_a_new_one)
|
||||
.setMessage(
|
||||
R.string.do_you_want_to_choose_existing_img_or_take_a_new_one)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setPositiveButton(R.string.existing_image,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@@ -128,14 +184,12 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
int which) {
|
||||
showTakePhotoActivity();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
}).create();
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void pickExistingImage()
|
||||
{
|
||||
private void pickExistingImage() {
|
||||
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
||||
photoPickerIntent.setType("image/*");
|
||||
startActivityForResult(photoPickerIntent, SELECT_PHOTO_REQUEST_CODE);
|
||||
@@ -148,23 +202,23 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK)
|
||||
{
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
RegattaActivity activity = (RegattaActivity) getActivity();
|
||||
|
||||
if (requestCode == CAMERA_REQUEST_CODE) {
|
||||
Bitmap photo = (Bitmap) data.getExtras().get("data");
|
||||
activity.updatePictureChosenByUser(photo);
|
||||
}
|
||||
else if (requestCode == SELECT_PHOTO_REQUEST_CODE) {
|
||||
} else if (requestCode == SELECT_PHOTO_REQUEST_CODE) {
|
||||
Uri selectedImage = data.getData();
|
||||
InputStream imageStream;
|
||||
try {
|
||||
imageStream = getActivity().getContentResolver().openInputStream(selectedImage);
|
||||
imageStream = getActivity().getContentResolver()
|
||||
.openInputStream(selectedImage);
|
||||
Bitmap photo = BitmapFactory.decodeStream(imageStream);
|
||||
activity.updatePictureChosenByUser(photo);
|
||||
} catch (FileNotFoundException e) {
|
||||
ExLog.e(getActivity(), TAG, "File not found exception after picking image from gallery");
|
||||
ExLog.e(getActivity(), TAG,
|
||||
"File not found exception after picking image from gallery");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -179,67 +233,60 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
|
||||
private void timerFired()
|
||||
{
|
||||
private void timerFired() {
|
||||
RegattaActivity regattaActivity = (RegattaActivity) getActivity();
|
||||
updateCountdownTimer(regattaActivity.getEventStartMillis());
|
||||
}
|
||||
|
||||
private void updateCountdownTimer(long startTime)
|
||||
{
|
||||
private void updateCountdownTimer(long startTime) {
|
||||
long diff = startTime - System.currentTimeMillis();
|
||||
if (diff < 0) // event is in the past
|
||||
{
|
||||
setCountdownTime(0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int days = (int) TimeUnit.MILLISECONDS.toDays(diff);
|
||||
int hours = (int) TimeUnit.MILLISECONDS.toHours(diff) - (days * 24);
|
||||
int minutes = (int)TimeUnit.MILLISECONDS.toMinutes(diff) - (hours * 60) - (days * 24 * 60);
|
||||
int minutes = (int) TimeUnit.MILLISECONDS.toMinutes(diff)
|
||||
- (hours * 60) - (days * 24 * 60);
|
||||
|
||||
setCountdownTime(days, hours, minutes);
|
||||
}
|
||||
}
|
||||
|
||||
private void setCountdownTime(int days, int hours, int minutes)
|
||||
{
|
||||
TextView daysTextView = (TextView)getActivity().findViewById(R.id.starts_in_days);
|
||||
TextView hoursTextView = (TextView)getActivity().findViewById(R.id.starts_in_hours);
|
||||
TextView minutesTextView = (TextView)getActivity().findViewById(R.id.starts_in_minutes);
|
||||
private void setCountdownTime(int days, int hours, int minutes) {
|
||||
TextView daysTextView = (TextView) getActivity().findViewById(
|
||||
R.id.starts_in_days);
|
||||
TextView hoursTextView = (TextView) getActivity().findViewById(
|
||||
R.id.starts_in_hours);
|
||||
TextView minutesTextView = (TextView) getActivity().findViewById(
|
||||
R.id.starts_in_minutes);
|
||||
|
||||
TextView daysTextViewLabel = (TextView)getActivity().findViewById(R.id.starts_in_days_label);
|
||||
TextView hoursTextViewLabel = (TextView)getActivity().findViewById(R.id.starts_in_hours_label);
|
||||
TextView minutesTextViewLabel = (TextView)getActivity().findViewById(R.id.starts_in_minutes_label);
|
||||
TextView daysTextViewLabel = (TextView) getActivity().findViewById(
|
||||
R.id.starts_in_days_label);
|
||||
TextView hoursTextViewLabel = (TextView) getActivity().findViewById(
|
||||
R.id.starts_in_hours_label);
|
||||
TextView minutesTextViewLabel = (TextView) getActivity().findViewById(
|
||||
R.id.starts_in_minutes_label);
|
||||
|
||||
daysTextView.setText(String.format("%02d", days));
|
||||
hoursTextView.setText(String.format("%02d", hours));
|
||||
minutesTextView.setText(String.format("%02d", minutes));
|
||||
|
||||
if (days == 1)
|
||||
{
|
||||
if (days == 1) {
|
||||
daysTextViewLabel.setText(R.string.day);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
daysTextViewLabel.setText(R.string.days);
|
||||
}
|
||||
|
||||
if (hours == 1)
|
||||
{
|
||||
if (hours == 1) {
|
||||
hoursTextViewLabel.setText(R.string.hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
hoursTextViewLabel.setText(R.string.hours);
|
||||
}
|
||||
|
||||
if (minutes == 1)
|
||||
{
|
||||
if (minutes == 1) {
|
||||
minutesTextViewLabel.setText(R.string.minute);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
minutesTextViewLabel.setText(R.string.minutes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user