Skip to content
Browse files

improved the layout

  • Loading branch information...
1 parent 8276de4 commit abd4cc8056bd87fc3111b35201227228855b374b @TobiasRoeding committed Jun 2, 2012
View
257 res/layout/newentry_tab.xml
@@ -9,185 +9,174 @@
android:layout_height="wrap_content"
android:orientation="vertical" >
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:layout_marginBottom="@dimen/topMargin"
android:layout_marginTop="@dimen/topMargin"
- android:gravity="top"
- android:orientation="vertical" >
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:layout_weight="1.74"
- android:gravity="left" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginLeft="@dimen/sideMargin"
- android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:gravity="left"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/textViewNewEntry1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginLeft="@dimen/sideMargin"
- android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:text="@string/start"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/font" />
-
- <TimePicker
- android:id="@+id/timePickerNewEntry1"
- android:layout_width="150dp"
- android:layout_height="wrap_content"
- android:scaleX="0.9"
- android:scaleY="0.9" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginLeft="@dimen/sideMargin"
- android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:gravity="right"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/textViewNewEntry2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="right"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginLeft="@dimen/sideMargin"
- android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:text="@string/end"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/font" />
-
- <TimePicker
- android:id="@+id/timePickerNewEntry2"
- android:layout_width="150dp"
- android:layout_height="wrap_content"
- android:scaleX="0.9"
- android:scaleY="0.9" />
- </LinearLayout>
- </RelativeLayout>
+ android:gravity="left" >
<LinearLayout
- android:layout_width="fill_parent"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
android:layout_marginBottom="@dimen/topMargin"
android:layout_marginLeft="@dimen/sideMargin"
android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin" >
+ android:layout_marginTop="@dimen/topMargin"
+ android:gravity="left"
+ android:orientation="vertical" >
<TextView
- android:id="@+id/textViewNewEntry3"
- android:layout_width="180dp"
+ android:id="@+id/textViewNewEntry1"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/topMargin"
android:layout_marginLeft="@dimen/sideMargin"
android:layout_marginRight="@dimen/sideMargin"
android:layout_marginTop="@dimen/topMargin"
- android:text="@string/total"
+ android:text="@string/start"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/font" />
- <TextView
- android:id="@+id/textViewNewEntry5"
- android:layout_width="wrap_content"
+ <TimePicker
+ android:id="@+id/timePickerNewEntry1"
+ android:layout_width="150dp"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginLeft="@dimen/sideMargin"
- android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:text=""
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/font" />
+ android:scaleX="0.9"
+ android:scaleY="0.9" />
</LinearLayout>
<LinearLayout
- android:layout_width="fill_parent"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
android:layout_marginBottom="@dimen/topMargin"
android:layout_marginLeft="@dimen/sideMargin"
android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin" >
+ android:layout_marginTop="@dimen/topMargin"
+ android:gravity="right"
+ android:orientation="vertical" >
<TextView
- android:id="@+id/textViewNewEntry4"
- android:layout_width="180dp"
+ android:id="@+id/textViewNewEntry2"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_gravity="right"
android:layout_marginBottom="@dimen/topMargin"
android:layout_marginLeft="@dimen/sideMargin"
android:layout_marginRight="@dimen/sideMargin"
android:layout_marginTop="@dimen/topMargin"
- android:text="@string/gliding"
+ android:text="@string/end"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/font" />
- <TextView
- android:id="@+id/textViewNewEntry6"
- android:layout_width="wrap_content"
+ <TimePicker
+ android:id="@+id/timePickerNewEntry2"
+ android:layout_width="150dp"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginLeft="@dimen/sideMargin"
- android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:text=""
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/font" />
+ android:scaleX="0.9"
+ android:scaleY="0.9" />
</LinearLayout>
+ </RelativeLayout>
- <LinearLayout
- android:layout_width="fill_parent"
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/topMargin"
+ android:layout_marginLeft="@dimen/sideMargin"
+ android:layout_marginRight="@dimen/sideMargin"
+ android:layout_marginTop="@dimen/topMargin" >
+
+ <TextView
+ android:id="@+id/textViewNewEntry3"
+ android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/topMargin"
android:layout_marginLeft="@dimen/sideMargin"
android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin" >
+ android:layout_marginTop="@dimen/topMargin"
+ android:text="@string/total"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/font" />
- <TextView
- android:id="@+id/textViewNewEntry7"
- android:layout_width="180dp"
- android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginLeft="@dimen/sideMargin"
- android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:text="@string/duty"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/font" />
+ <TextView
+ android:id="@+id/textViewNewEntry5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/topMargin"
+ android:layout_marginLeft="@dimen/sideMargin"
+ android:layout_marginRight="@dimen/sideMargin"
+ android:layout_marginTop="@dimen/topMargin"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/font" />
+ </LinearLayout>
- <TextView
- android:id="@+id/textViewNewEntry8"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/topMargin"
- android:layout_marginLeft="@dimen/sideMargin"
- android:layout_marginRight="@dimen/sideMargin"
- android:layout_marginTop="@dimen/topMargin"
- android:text=""
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/font" />
- </LinearLayout>
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/topMargin"
+ android:layout_marginLeft="@dimen/sideMargin"
+ android:layout_marginRight="@dimen/sideMargin"
+ android:layout_marginTop="@dimen/topMargin" >
+
+ <TextView
+ android:id="@+id/textViewNewEntry4"
+ android:layout_width="180dp"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/topMargin"
+ android:layout_marginLeft="@dimen/sideMargin"
+ android:layout_marginRight="@dimen/sideMargin"
+ android:layout_marginTop="@dimen/topMargin"
+ android:text="@string/gliding"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/font" />
+
+ <TextView
+ android:id="@+id/textViewNewEntry6"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/topMargin"
+ android:layout_marginLeft="@dimen/sideMargin"
+ android:layout_marginRight="@dimen/sideMargin"
+ android:layout_marginTop="@dimen/topMargin"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/font" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/topMargin"
+ android:layout_marginLeft="@dimen/sideMargin"
+ android:layout_marginRight="@dimen/sideMargin"
+ android:layout_marginTop="@dimen/topMargin" >
+
+ <TextView
+ android:id="@+id/textViewNewEntry7"
+ android:layout_width="180dp"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/topMargin"
+ android:layout_marginLeft="@dimen/sideMargin"
+ android:layout_marginRight="@dimen/sideMargin"
+ android:layout_marginTop="@dimen/topMargin"
+ android:text="@string/duty"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/font" />
+
+ <TextView
+ android:id="@+id/textViewNewEntry8"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/topMargin"
+ android:layout_marginLeft="@dimen/sideMargin"
+ android:layout_marginRight="@dimen/sideMargin"
+ android:layout_marginTop="@dimen/topMargin"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/font" />
</LinearLayout>
<DatePicker
View
1 src/eu/roeding/android/glz/fragments/CalculatorFragment.java
@@ -77,7 +77,6 @@ public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
// on Resume reload the TimePicker values (necessary because sometimes the values change at no reason)
@Override
public void onResume() {
- // TODO Auto-generated method stub
super.onResume();
TimeCalculation.reloadPickerValues(startTime, endTime, preference);
}
View
125 src/eu/roeding/android/glz/fragments/NewEntryFragment.java
@@ -49,7 +49,8 @@ public void onActivityCreated(Bundle savedInstanceState) {
startTime = (TimePicker) getActivity().findViewById(
R.id.timePickerNewEntry1);
startTime.setIs24HourView(true);
- startTime.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS);
+ startTime
+ .setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS);
endTime = (TimePicker) getActivity().findViewById(
R.id.timePickerNewEntry2);
endTime.setIs24HourView(true);
@@ -110,41 +111,48 @@ public void onDateChanged(DatePicker view, int year,
System.err.println("Couldn't find the DatePicker! Error: " + e);
}
- // find and setup the save button
- save = (Button) getActivity().findViewById(R.id.buttonNewEntry1);
- save.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- // save a new Gliding Time
- GlidingTimesDataSource datasource;
- datasource = new GlidingTimesDataSource(getActivity());
- datasource.open();
- datasource.createGlidingTime(
- String.valueOf(startTime.getCurrentHour())
- + ":"
- + TimeCalculation.printMinutes(startTime
- .getCurrentMinute()),
- String.valueOf(endTime.getCurrentHour())
- + ":"
- + TimeCalculation.printMinutes(endTime
- .getCurrentMinute()),
- String.valueOf(String.valueOf(date.getYear()) + "-"
- + String.valueOf(date.getMonth()) + "-"
- + String.valueOf(date.getDayOfMonth())),
- String.valueOf(diffTime.getText()));
- datasource.close();
-
- TimeCalculation.updateTotalGLZ(TimeCalculation.timeToInt(String
- .valueOf(diffTime.getText())), preference);
-
- disableSave(existsDate(date.getYear(), date.getMonth(),
- date.getDayOfMonth()));
-
- Toast.makeText(getActivity(), "Ihre Zeit wurde gespeichert!",
- Toast.LENGTH_SHORT).show();
- }
- });
+ try {
+ // find and setup the save button
+ save = (Button) getActivity().findViewById(R.id.buttonNewEntry1);
+ save.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // save a new Gliding Time
+ GlidingTimesDataSource datasource;
+ datasource = new GlidingTimesDataSource(getActivity());
+ datasource.open();
+ datasource.createGlidingTime(
+ String.valueOf(startTime.getCurrentHour())
+ + ":"
+ + TimeCalculation.printMinutes(startTime
+ .getCurrentMinute()),
+ String.valueOf(endTime.getCurrentHour())
+ + ":"
+ + TimeCalculation.printMinutes(endTime
+ .getCurrentMinute()),
+ String.valueOf(String.valueOf(date.getYear()) + "-"
+ + String.valueOf(date.getMonth()) + "-"
+ + String.valueOf(date.getDayOfMonth())),
+ String.valueOf(diffTime.getText()));
+ datasource.close();
+
+ TimeCalculation.updateTotalGLZ(TimeCalculation
+ .timeToInt(String.valueOf(diffTime.getText())),
+ preference);
+
+ disableSave(existsDate(date.getYear(), date.getMonth(),
+ date.getDayOfMonth()));
+
+ Toast.makeText(getActivity(),
+ "Ihre Zeit wurde gespeichert!", Toast.LENGTH_SHORT)
+ .show();
+ }
+ });
+
+ } catch (Exception e) {
+ System.err.println("Couldn't find the SaveButton! Error: " + e);
+ }
calcGLZ();
@@ -189,30 +197,33 @@ public void calcGLZ() {
+ e);
}
- int total = TimeCalculation.calcTotalTime(startHour, startMinute,
- endHour, endMinute);
-
- int duty = TimeCalculation.calcDutyTime(startHour, startMinute);
+ try {
+ int total = TimeCalculation.calcTotalTime(startHour, startMinute,
+ endHour, endMinute);
+
+ int duty = TimeCalculation.calcDutyTime(startHour, startMinute);
+
+ int deltaGlidingTime = TimeCalculation.calcDeltaGlidingTime(total,
+ Constants.getBreakBarrier());
+
+ if (deltaGlidingTime > Constants.getPeriodOfDutyInMinutes()) {
+ diffTime.setText("+ "
+ + TimeCalculation.printTime(total
+ - Constants.getPeriodOfDutyInMinutes()));
+ } else if (total < Constants.getPeriodOfDutyInMinutes()) {
+ diffTime.setText("- "
+ + TimeCalculation.printTime(Constants
+ .getPeriodOfDutyInMinutes() - total));
+ } else {
+ diffTime.setText(" " + TimeCalculation.printTime(0));
+ }
- int deltaGlidingTime = TimeCalculation.calcDeltaGlidingTime(total,
- Constants.getBreakBarrier());
+ totalTime.setText(TimeCalculation.printTime(total));
- if (deltaGlidingTime > Constants.getPeriodOfDutyInMinutes()) {
- diffTime.setText("+ "
- + TimeCalculation.printTime(total
- - Constants.getPeriodOfDutyInMinutes()));
- } else if (total < Constants.getPeriodOfDutyInMinutes()) {
- diffTime.setText("- "
- + TimeCalculation.printTime(Constants
- .getPeriodOfDutyInMinutes() - total));
- } else {
- diffTime.setText(" " + TimeCalculation.printTime(0));
+ dutyTime.setText(TimeCalculation.printTime(duty));
+ } catch (Exception e) {
+ System.err.println("Couldn't set the TextViews! Error: " + e);
}
-
- totalTime.setText(TimeCalculation.printTime(total));
-
- dutyTime.setText(TimeCalculation.printTime(duty));
-
}
@Override
View
1 src/eu/roeding/android/glz/fragments/TimesheetFragment.java
@@ -20,6 +20,7 @@
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.Toast;
public class TimesheetFragment extends ListFragment {

0 comments on commit abd4cc8

Please sign in to comment.
Something went wrong with that request. Please try again.