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
+143
-67
No files matched your search
@@ -123,6 +123,30 @@
|
|||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:background="@color/sap_yellow" />
|
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>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@@ -287,6 +311,7 @@
|
|||||||
android:layout_alignParentLeft="true" >
|
android:layout_alignParentLeft="true" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/bottom_announcement"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
|
|||||||
@@ -67,5 +67,7 @@
|
|||||||
<string name="no_qr_code">Sie haben keinen QR-Code?</string>
|
<string name="no_qr_code">Sie haben keinen QR-Code?</string>
|
||||||
<string name="scan_qr">QR-Code scannen</string>
|
<string name="scan_qr">QR-Code scannen</string>
|
||||||
<string name="your_regattas">Ihre Regattas:</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>
|
</resources>
|
||||||
@@ -59,5 +59,7 @@
|
|||||||
<string name="day">Day</string>
|
<string name="day">Day</string>
|
||||||
<string name="please_listen_to_announcements">Please listen to the announcements</string>
|
<string name="please_listen_to_announcements">Please listen to the announcements</string>
|
||||||
<string name="your_regattas">Your Regattas:</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>
|
</resources>
|
||||||
+1
-1
@@ -338,7 +338,7 @@ public class RegattaActivity extends BaseActivity {
|
|||||||
/**
|
/**
|
||||||
* Check out from regatta;
|
* Check out from regatta;
|
||||||
*/
|
*/
|
||||||
private void checkout()
|
public void checkout()
|
||||||
{
|
{
|
||||||
final String checkoutURLStr = prefs.getServerURL()
|
final String checkoutURLStr = prefs.getServerURL()
|
||||||
+ prefs.getServerCheckoutPath().replace("{leaderboard-name}",
|
+ prefs.getServerCheckoutPath().replace("{leaderboard-name}",
|
||||||
|
|||||||
+113
-66
@@ -20,6 +20,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.sap.sailing.android.shared.logging.ExLog;
|
import com.sap.sailing.android.shared.logging.ExLog;
|
||||||
@@ -30,12 +31,14 @@ import com.sap.sailing.android.tracking.app.ui.activities.TrackingActivity;
|
|||||||
public class RegattaFragment extends BaseFragment implements OnClickListener {
|
public class RegattaFragment extends BaseFragment implements OnClickListener {
|
||||||
|
|
||||||
private final String TAG = RegattaFragment.class.toString();
|
private final String TAG = RegattaFragment.class.toString();
|
||||||
|
|
||||||
private final int CAMERA_REQUEST_CODE = 3118;
|
private final int CAMERA_REQUEST_CODE = 3118;
|
||||||
private final int SELECT_PHOTO_REQUEST_CODE = 1693;
|
private final int SELECT_PHOTO_REQUEST_CODE = 1693;
|
||||||
|
|
||||||
|
private boolean showingThankYouNote;
|
||||||
|
|
||||||
private TimerRunnable timer;
|
private TimerRunnable timer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@@ -63,24 +66,76 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
|||||||
return view;
|
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
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
timer = new TimerRunnable();
|
timer = new TimerRunnable();
|
||||||
timer.start();
|
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
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
timer.stop();
|
timer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.start_tracking:
|
case R.id.start_tracking:
|
||||||
showTrackingActivity();
|
if (showingThankYouNote)
|
||||||
|
{
|
||||||
|
RegattaActivity regattaActivity = (RegattaActivity)getActivity();
|
||||||
|
regattaActivity.checkout();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showTrackingActivity();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.add_photo_button:
|
case R.id.add_photo_button:
|
||||||
showChooseExistingPictureOrTakeNewPhotoAlert();
|
showChooseExistingPictureOrTakeNewPhotoAlert();
|
||||||
@@ -112,7 +167,8 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
|||||||
private void showChooseExistingPictureOrTakeNewPhotoAlert() {
|
private void showChooseExistingPictureOrTakeNewPhotoAlert() {
|
||||||
AlertDialog dialog = new AlertDialog.Builder(getActivity())
|
AlertDialog dialog = new AlertDialog.Builder(getActivity())
|
||||||
.setTitle(R.string.add_photo_select)
|
.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)
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setPositiveButton(R.string.existing_image,
|
.setPositiveButton(R.string.existing_image,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@@ -128,17 +184,15 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
|||||||
int which) {
|
int which) {
|
||||||
showTakePhotoActivity();
|
showTakePhotoActivity();
|
||||||
}
|
}
|
||||||
})
|
}).create();
|
||||||
.create();
|
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pickExistingImage()
|
private void pickExistingImage() {
|
||||||
{
|
|
||||||
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
||||||
photoPickerIntent.setType("image/*");
|
photoPickerIntent.setType("image/*");
|
||||||
startActivityForResult(photoPickerIntent, SELECT_PHOTO_REQUEST_CODE);
|
startActivityForResult(photoPickerIntent, SELECT_PHOTO_REQUEST_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showTakePhotoActivity() {
|
private void showTakePhotoActivity() {
|
||||||
@@ -148,23 +202,23 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (resultCode == Activity.RESULT_OK)
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
{
|
|
||||||
RegattaActivity activity = (RegattaActivity) getActivity();
|
RegattaActivity activity = (RegattaActivity) getActivity();
|
||||||
|
|
||||||
if (requestCode == CAMERA_REQUEST_CODE) {
|
if (requestCode == CAMERA_REQUEST_CODE) {
|
||||||
Bitmap photo = (Bitmap) data.getExtras().get("data");
|
Bitmap photo = (Bitmap) data.getExtras().get("data");
|
||||||
activity.updatePictureChosenByUser(photo);
|
activity.updatePictureChosenByUser(photo);
|
||||||
}
|
} else if (requestCode == SELECT_PHOTO_REQUEST_CODE) {
|
||||||
else if (requestCode == SELECT_PHOTO_REQUEST_CODE) {
|
|
||||||
Uri selectedImage = data.getData();
|
Uri selectedImage = data.getData();
|
||||||
InputStream imageStream;
|
InputStream imageStream;
|
||||||
try {
|
try {
|
||||||
imageStream = getActivity().getContentResolver().openInputStream(selectedImage);
|
imageStream = getActivity().getContentResolver()
|
||||||
|
.openInputStream(selectedImage);
|
||||||
Bitmap photo = BitmapFactory.decodeStream(imageStream);
|
Bitmap photo = BitmapFactory.decodeStream(imageStream);
|
||||||
activity.updatePictureChosenByUser(photo);
|
activity.updatePictureChosenByUser(photo);
|
||||||
} catch (FileNotFoundException e) {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,74 +232,67 @@ public class RegattaFragment extends BaseFragment implements OnClickListener {
|
|||||||
Intent intent = new Intent(getActivity(), TrackingActivity.class);
|
Intent intent = new Intent(getActivity(), TrackingActivity.class);
|
||||||
getActivity().startActivity(intent);
|
getActivity().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void timerFired()
|
private void timerFired() {
|
||||||
{
|
RegattaActivity regattaActivity = (RegattaActivity) getActivity();
|
||||||
RegattaActivity regattaActivity = (RegattaActivity)getActivity();
|
|
||||||
updateCountdownTimer(regattaActivity.getEventStartMillis());
|
updateCountdownTimer(regattaActivity.getEventStartMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCountdownTimer(long startTime)
|
private void updateCountdownTimer(long startTime) {
|
||||||
{
|
|
||||||
long diff = startTime - System.currentTimeMillis();
|
long diff = startTime - System.currentTimeMillis();
|
||||||
if (diff < 0) // event is in the past
|
if (diff < 0) // event is in the past
|
||||||
{
|
{
|
||||||
setCountdownTime(0, 0, 0);
|
setCountdownTime(0, 0, 0);
|
||||||
}
|
} else {
|
||||||
else
|
int days = (int) TimeUnit.MILLISECONDS.toDays(diff);
|
||||||
{
|
int hours = (int) TimeUnit.MILLISECONDS.toHours(diff) - (days * 24);
|
||||||
int days = (int)TimeUnit.MILLISECONDS.toDays(diff);
|
int minutes = (int) TimeUnit.MILLISECONDS.toMinutes(diff)
|
||||||
int hours = (int)TimeUnit.MILLISECONDS.toHours(diff) - (days * 24);
|
- (hours * 60) - (days * 24 * 60);
|
||||||
int minutes = (int)TimeUnit.MILLISECONDS.toMinutes(diff) - (hours * 60) - (days * 24 * 60);
|
|
||||||
|
setCountdownTime(days, hours, minutes);
|
||||||
setCountdownTime(days, hours, minutes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCountdownTime(int days, int hours, int minutes)
|
private void setCountdownTime(int days, int hours, int minutes) {
|
||||||
{
|
TextView daysTextView = (TextView) getActivity().findViewById(
|
||||||
TextView daysTextView = (TextView)getActivity().findViewById(R.id.starts_in_days);
|
R.id.starts_in_days);
|
||||||
TextView hoursTextView = (TextView)getActivity().findViewById(R.id.starts_in_hours);
|
TextView hoursTextView = (TextView) getActivity().findViewById(
|
||||||
TextView minutesTextView = (TextView)getActivity().findViewById(R.id.starts_in_minutes);
|
R.id.starts_in_hours);
|
||||||
|
TextView minutesTextView = (TextView) getActivity().findViewById(
|
||||||
TextView daysTextViewLabel = (TextView)getActivity().findViewById(R.id.starts_in_days_label);
|
R.id.starts_in_minutes);
|
||||||
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));
|
daysTextView.setText(String.format("%02d", days));
|
||||||
hoursTextView.setText(String.format("%02d", hours));
|
hoursTextView.setText(String.format("%02d", hours));
|
||||||
minutesTextView.setText(String.format("%02d", minutes));
|
minutesTextView.setText(String.format("%02d", minutes));
|
||||||
|
|
||||||
if (days == 1)
|
if (days == 1) {
|
||||||
{
|
|
||||||
daysTextViewLabel.setText(R.string.day);
|
daysTextViewLabel.setText(R.string.day);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
daysTextViewLabel.setText(R.string.days);
|
daysTextViewLabel.setText(R.string.days);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hours == 1)
|
if (hours == 1) {
|
||||||
{
|
|
||||||
hoursTextViewLabel.setText(R.string.hour);
|
hoursTextViewLabel.setText(R.string.hour);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
hoursTextViewLabel.setText(R.string.hours);
|
hoursTextViewLabel.setText(R.string.hours);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minutes == 1)
|
if (minutes == 1) {
|
||||||
{
|
|
||||||
minutesTextViewLabel.setText(R.string.minute);
|
minutesTextViewLabel.setText(R.string.minute);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
minutesTextViewLabel.setText(R.string.minutes);
|
minutesTextViewLabel.setText(R.string.minutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TimerRunnable implements Runnable {
|
private class TimerRunnable implements Runnable {
|
||||||
|
|
||||||
public Thread t;
|
public Thread t;
|
||||||
public volatile boolean running = true;
|
public volatile boolean running = true;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user