forked from upstream-mirrors/OpenTracks
Theming: activity icons are now in textColorPrimary.
And replaced spinner in StatisticsRecordedFragment.
This commit is contained in:
@@ -19,21 +19,19 @@ package de.dennisguse.opentracks.fragments;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Spinner;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.constraintlayout.widget.Group;
|
import androidx.constraintlayout.widget.Group;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.TrackRecordedActivity;
|
|
||||||
import de.dennisguse.opentracks.content.data.Track;
|
import de.dennisguse.opentracks.content.data.Track;
|
||||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
import de.dennisguse.opentracks.stats.TrackStatistics;
|
||||||
@@ -76,7 +74,7 @@ public class StatisticsRecordedFragment extends Fragment {
|
|||||||
private TextView distanceValue;
|
private TextView distanceValue;
|
||||||
private TextView distanceUnit;
|
private TextView distanceUnit;
|
||||||
private View activityLabel;
|
private View activityLabel;
|
||||||
private Spinner activitySpinner;
|
private ImageView activitySpinner;
|
||||||
private TextView movingTimeValue;
|
private TextView movingTimeValue;
|
||||||
private TextView speedAvgLabel;
|
private TextView speedAvgLabel;
|
||||||
private TextView speedAvgValue;
|
private TextView speedAvgValue;
|
||||||
@@ -141,26 +139,6 @@ public class StatisticsRecordedFragment extends Fragment {
|
|||||||
elevationTotalGainUnit = view.findViewById(R.id.stats_elevation_gain_unit);
|
elevationTotalGainUnit = view.findViewById(R.id.stats_elevation_gain_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
|
|
||||||
Spinner activityTypeIcon = getView().findViewById(R.id.stats_activity_type_icon);
|
|
||||||
activityTypeIcon.setAdapter(TrackIconUtils.getIconSpinnerAdapter(getActivity(), ""));
|
|
||||||
activityTypeIcon.setOnTouchListener((v, event) -> {
|
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
|
||||||
((TrackRecordedActivity) getActivity()).chooseActivityType(category);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
activityTypeIcon.setOnKeyListener((v, keyCode, event) -> {
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
|
||||||
((TrackRecordedActivity) getActivity()).chooseActivityType(category);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -215,8 +193,6 @@ public class StatisticsRecordedFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
String trackIconValue = TrackIconUtils.getIconValue(getContext(), category);
|
|
||||||
|
|
||||||
boolean metricUnits = PreferencesUtils.isMetricUnits(getContext());
|
boolean metricUnits = PreferencesUtils.isMetricUnits(getContext());
|
||||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(getContext(), category);
|
boolean reportSpeed = PreferencesUtils.isReportSpeed(getContext(), category);
|
||||||
|
|
||||||
@@ -231,12 +207,14 @@ public class StatisticsRecordedFragment extends Fragment {
|
|||||||
|
|
||||||
// Set activity type
|
// Set activity type
|
||||||
{
|
{
|
||||||
|
String trackIconValue = TrackIconUtils.getIconValue(getContext(), category);
|
||||||
|
|
||||||
activityLabel.setVisibility(trackIconValue != null ? View.VISIBLE : View.GONE);
|
activityLabel.setVisibility(trackIconValue != null ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
activitySpinner.setVisibility(trackIconValue != null ? View.VISIBLE : View.GONE);
|
activitySpinner.setVisibility(trackIconValue != null ? View.VISIBLE : View.GONE);
|
||||||
activitySpinner.setEnabled(false);
|
activitySpinner.setEnabled(false);
|
||||||
if (trackIconValue != null) {
|
if (trackIconValue != null) {
|
||||||
TrackIconUtils.setIconSpinner(activitySpinner, trackIconValue);
|
activitySpinner.setImageDrawable(ContextCompat.getDrawable(getContext(), TrackIconUtils.getIconDrawable(trackIconValue)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,8 @@ public class TrackIconUtils {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param activityType the activity type
|
* @param activityType the activity type
|
||||||
*/
|
*/
|
||||||
public static String getIconValue(Context context, String activityType) {
|
public static @NonNull
|
||||||
|
String getIconValue(Context context, String activityType) {
|
||||||
if (activityType == null || activityType.equals("")) {
|
if (activityType == null || activityType.equals("")) {
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
@@ -57,7 +58,8 @@ limitations under the License.
|
|||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:contentDescription="@string/image_track" />
|
android:contentDescription="@string/image_track"
|
||||||
|
app:tint="?android:textColorPrimary" />
|
||||||
<!-- Table 1: Row 1: Column 2: (Table 2) -->
|
<!-- Table 1: Row 1: Column 2: (Table 2) -->
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -68,15 +68,16 @@
|
|||||||
app:layout_constraintRight_toLeftOf="@+id/guideline3"
|
app:layout_constraintRight_toLeftOf="@+id/guideline3"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<Spinner
|
<ImageView
|
||||||
android:id="@+id/stats_activity_type_icon"
|
android:id="@+id/stats_activity_type_icon"
|
||||||
style="@style/StatsLargeValue"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintLeft_toRightOf="@+id/guideline2"
|
app:layout_constraintLeft_toRightOf="@+id/guideline2"
|
||||||
app:layout_constraintRight_toLeftOf="@+id/guideline3"
|
app:layout_constraintRight_toLeftOf="@+id/guideline3"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/stats_distance_value"
|
app:layout_constraintBottom_toBottomOf="@+id/stats_distance_value"
|
||||||
app:layout_constraintTop_toTopOf="@+id/stats_distance_value" />
|
app:layout_constraintTop_toTopOf="@+id/stats_distance_value"
|
||||||
|
app:tint="?android:attr/textColorPrimary"
|
||||||
|
app:tintMode="src_atop" />
|
||||||
|
|
||||||
<!-- Total time -->
|
<!-- Total time -->
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
Reference in New Issue
Block a user