forked from upstream-mirrors/OpenTracks
A few fixes.
- use fill_parent since we are still supporting api level 7. - on the TrackListActivity, hide the empty view content until the check unit dialog has been showned. - fix the ChartView height. ChartView is no longer displayed on the full canvas. The new design has a tab bar and a zoom control. - In TrackDetailActivity, only call methods of a tab fragment if it is the current tab.
This commit is contained in:
@@ -16,17 +16,17 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@android:id/tabhost"
|
android:id="@android:id/tabhost"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_width="match_parent" >
|
android:layout_width="fill_parent" >
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_height="match_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="fill_parent"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
<TabWidget
|
<TabWidget
|
||||||
android:id="@android:id/tabs"
|
android:id="@android:id/tabs"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="fill_parent"
|
||||||
android:orientation="horizontal" />
|
android:orientation="horizontal" />
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@android:id/tabcontent"
|
android:id="@android:id/tabcontent"
|
||||||
@@ -37,6 +37,6 @@ limitations under the License.
|
|||||||
android:id="@+id/realtabcontent"
|
android:id="@+id/realtabcontent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="match_parent" />
|
android:layout_width="fill_parent" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TabHost>
|
</TabHost>
|
||||||
@@ -28,7 +28,9 @@ limitations under the License.
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/track_list_empty_message"
|
||||||
android:text="@string/track_list_empty_message"
|
android:text="@string/track_list_empty_message"
|
||||||
|
android:visibility="gone"
|
||||||
style="@style/ListEmptyTextView" >
|
style="@style/ListEmptyTextView" >
|
||||||
</TextView>
|
</TextView>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
@@ -38,6 +40,7 @@ limitations under the License.
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:src="@drawable/menu_record_track"
|
android:src="@drawable/menu_record_track"
|
||||||
|
android:visibility="gone"
|
||||||
style="@android:style/Widget.DeviceDefault.ImageButton" />
|
style="@android:style/Widget.DeviceDefault.ImageButton" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</merge>
|
</merge>
|
||||||
@@ -76,7 +76,7 @@ public class ChartView extends View {
|
|||||||
/**
|
/**
|
||||||
* Unscaled top border of the chart.
|
* Unscaled top border of the chart.
|
||||||
*/
|
*/
|
||||||
private static final int TOP_BORDER = 15;
|
private static final int TOP_BORDER = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Device scaled top border of the chart.
|
* Device scaled top border of the chart.
|
||||||
@@ -86,7 +86,7 @@ public class ChartView extends View {
|
|||||||
/**
|
/**
|
||||||
* Unscaled bottom border of the chart.
|
* Unscaled bottom border of the chart.
|
||||||
*/
|
*/
|
||||||
private static final float BOTTOM_BORDER = 40;
|
private static final float BOTTOM_BORDER = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Device scaled bottom border of the chart.
|
* Device scaled bottom border of the chart.
|
||||||
@@ -509,10 +509,16 @@ public class ChartView extends View {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
updateEffectiveDimensionsIfChanged(
|
||||||
|
View.MeasureSpec.getSize(widthMeasureSpec), View.MeasureSpec.getSize(heightMeasureSpec));
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas c) {
|
protected void onDraw(Canvas c) {
|
||||||
synchronized (data) {
|
synchronized (data) {
|
||||||
updateEffectiveDimensionsIfChanged(c);
|
|
||||||
|
|
||||||
// Keep original state.
|
// Keep original state.
|
||||||
c.save();
|
c.save();
|
||||||
@@ -742,13 +748,16 @@ public class ChartView extends View {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the effective dimensions where the graph will be drawn, only if the
|
* Updates the effective dimensions where the graph will be drawn, only if the
|
||||||
* dimensions of the given canvas have changed since the last call.
|
* dimensions have changed since the last call.
|
||||||
|
*
|
||||||
|
* @param newWidth the new width
|
||||||
|
* @param newHeight the new height
|
||||||
*/
|
*/
|
||||||
private void updateEffectiveDimensionsIfChanged(Canvas c) {
|
private void updateEffectiveDimensionsIfChanged(int newWidth, int newHeight) {
|
||||||
if (w != c.getWidth() || h != c.getHeight()) {
|
if (w != newWidth || h != newHeight) {
|
||||||
// Dimensions have changed (for example due to orientation change).
|
// Dimensions have changed (for example due to orientation change).
|
||||||
w = c.getWidth();
|
w = newWidth;
|
||||||
h = c.getHeight();
|
h = newHeight;
|
||||||
updateEffectiveDimensions();
|
updateEffectiveDimensions();
|
||||||
setUpPath();
|
setUpPath();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,14 +237,20 @@ public class TrackDetailActivity extends AbstractMyTracksActivity {
|
|||||||
ChartFragment.CHART_FRAGMENT_TAG.equals(currentTabTag));
|
ChartFragment.CHART_FRAGMENT_TAG.equals(currentTabTag));
|
||||||
menu.findItem(R.id.track_detail_my_location)
|
menu.findItem(R.id.track_detail_my_location)
|
||||||
.setVisible(MapFragment.MAP_FRAGMENT_TAG.equals(currentTabTag));
|
.setVisible(MapFragment.MAP_FRAGMENT_TAG.equals(currentTabTag));
|
||||||
|
MenuItem satelliteMode = menu.findItem(R.id.track_detail_satellite_mode)
|
||||||
|
.setVisible(MapFragment.MAP_FRAGMENT_TAG.equals(currentTabTag));
|
||||||
|
|
||||||
// Set map or satellite mode
|
if (satelliteMode.isVisible()) {
|
||||||
MapFragment mapFragment = (MapFragment) getSupportFragmentManager()
|
MapFragment mapFragment = (MapFragment) getSupportFragmentManager()
|
||||||
.findFragmentByTag(MapFragment.MAP_FRAGMENT_TAG);
|
.findFragmentByTag(MapFragment.MAP_FRAGMENT_TAG);
|
||||||
boolean isSatelliteMode = mapFragment != null ? mapFragment.isSatelliteView() : false;
|
/*
|
||||||
menu.findItem(R.id.track_detail_satellite_mode)
|
* The current tag is mapFragment, thus safe to call its methods like
|
||||||
.setVisible(MapFragment.MAP_FRAGMENT_TAG.equals(currentTabTag))
|
* isSatelliteView.
|
||||||
.setTitle(isSatelliteMode ? R.string.menu_map_mode : R.string.menu_satellite_mode);
|
*/
|
||||||
|
boolean isSatelliteMode = mapFragment != null ? mapFragment.isSatelliteView() : false;
|
||||||
|
menu.findItem(R.id.track_detail_satellite_mode).setTitle(
|
||||||
|
isSatelliteMode ? R.string.menu_map_mode : R.string.menu_satellite_mode);
|
||||||
|
}
|
||||||
|
|
||||||
return super.onPrepareOptionsMenu(menu);
|
return super.onPrepareOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileForm
|
|||||||
import com.google.android.apps.mytracks.services.ITrackRecordingService;
|
import com.google.android.apps.mytracks.services.ITrackRecordingService;
|
||||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
|
||||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||||
|
import com.google.android.apps.mytracks.util.CheckUnitsUtils;
|
||||||
import com.google.android.apps.mytracks.util.EulaUtils;
|
import com.google.android.apps.mytracks.util.EulaUtils;
|
||||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||||
import com.google.android.apps.mytracks.util.ListItemUtil;
|
import com.google.android.apps.mytracks.util.ListItemUtil;
|
||||||
@@ -262,6 +263,19 @@ public class TrackListActivity extends FragmentActivity {
|
|||||||
getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (CheckUnitsUtils.getCheckUnitsValue(this)) {
|
||||||
|
enableEmptyView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the content of the empty view.
|
||||||
|
*/
|
||||||
|
public void enableEmptyView() {
|
||||||
|
View emptyMessage = findViewById(R.id.track_list_empty_message);
|
||||||
|
emptyMessage.setVisibility(View.VISIBLE);
|
||||||
|
View recordButton = findViewById(R.id.track_list_record_button);
|
||||||
|
recordButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -133,8 +133,9 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout);
|
ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout);
|
||||||
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
|
@SuppressWarnings("deprecation")
|
||||||
LayoutParams.MATCH_PARENT);
|
LayoutParams layoutParams = new LayoutParams(
|
||||||
|
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
|
||||||
layout.addView(chartView, layoutParams);
|
layout.addView(chartView, layoutParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-3
@@ -17,6 +17,7 @@
|
|||||||
package com.google.android.apps.mytracks.fragments;
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
|
import com.google.android.apps.mytracks.TrackListActivity;
|
||||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||||
import com.google.android.apps.mytracks.util.CheckUnitsUtils;
|
import com.google.android.apps.mytracks.util.CheckUnitsUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
@@ -46,19 +47,18 @@ public class CheckUnitsDialogFragment extends DialogFragment {
|
|||||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
CheckUnitsUtils.setCheckUnitsValue(getActivity());
|
handleButtonClicked();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
CheckUnitsUtils.setCheckUnitsValue(getActivity());
|
|
||||||
|
|
||||||
int position = ((AlertDialog) dialog).getListView().getSelectedItemPosition();
|
int position = ((AlertDialog) dialog).getListView().getSelectedItemPosition();
|
||||||
SharedPreferences sharedPreferences = getActivity()
|
SharedPreferences sharedPreferences = getActivity()
|
||||||
.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
.getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||||
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(sharedPreferences.edit()
|
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(sharedPreferences.edit()
|
||||||
.putBoolean(getString(R.string.metric_units_key), position == 0));
|
.putBoolean(getString(R.string.metric_units_key), position == 0));
|
||||||
|
handleButtonClicked();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setSingleChoiceItems(new CharSequence[] { getString(R.string.preferred_units_metric),
|
.setSingleChoiceItems(new CharSequence[] { getString(R.string.preferred_units_metric),
|
||||||
@@ -66,4 +66,13 @@ public class CheckUnitsDialogFragment extends DialogFragment {
|
|||||||
.setTitle(R.string.preferred_units_title)
|
.setTitle(R.string.preferred_units_title)
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a button click.
|
||||||
|
*/
|
||||||
|
private void handleButtonClicked() {
|
||||||
|
CheckUnitsUtils.setCheckUnitsValue(getActivity());
|
||||||
|
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||||
|
trackListActivity.enableEmptyView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user