Skip to content

Commit

Permalink
Merge branch 'r4.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chumva committed Nov 20, 2024
2 parents 739ab13 + 8d64cc8 commit 505cad6
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 57 deletions.
31 changes: 16 additions & 15 deletions OsmAnd/res/layout/speedometer_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/content_padding_medium"
android:clipToPadding="false"
android:clipChildren="false"
>
android:clipToPadding="false"
android:orientation="horizontal"
android:padding="@dimen/content_padding_medium">

<LinearLayout
android:id="@+id/speedometer_container"
Expand All @@ -18,24 +17,23 @@
android:elevation="2dp"
android:orientation="vertical"
android:paddingHorizontal="9dp"
android:paddingVertical="9dp"
>
android:paddingVertical="9dp">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/speedometer_value"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="start|top"
android:gravity="start|center_vertical"
android:layout_weight="1"
android:autoSizeMinTextSize="16sp"
android:autoSizeMaxTextSize="80sp"
android:autoSizeMinTextSize="16sp"
android:autoSizeStepGranularity="1sp"
android:autoSizeTextType="uniform"
android:ellipsize="none"
android:gravity="start|center_vertical"
android:includeFontPadding="false"
android:textColor="@color/widgettext_day"
android:textSize="36sp"
android:includeFontPadding="false"
tools:text="85" />

<net.osmand.plus.widgets.TextViewEx
Expand All @@ -49,8 +47,8 @@
android:textAllCaps="true"
android:textColor="?android:textColorSecondary"
android:textSize="11dp"
tools:text="KM/H"
tools:ignore="SpUsage" />
tools:ignore="SpUsage"
tools:text="KM/H" />

</LinearLayout>

Expand All @@ -59,20 +57,22 @@
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginVertical="9dp"
android:layout_marginStart="-6dp"
android:layout_marginEnd="6dp"
android:background="@drawable/speed_limit_shape"
android:elevation="2dp"
android:gravity="center"
android:orientation="vertical"
android:paddingHorizontal="9dp"
android:paddingVertical="9dp"
android:translationX="-6dp"
android:translationZ="2dp">

<TextView
android:id="@+id/limit_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center_horizontal"
android:layout_weight="1"
android:gravity="center"
android:includeFontPadding="false"
android:text="@string/shared_string_limit"
android:textAllCaps="true"
Expand All @@ -83,6 +83,7 @@
android:id="@+id/speed_limit_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ellipsize="none"
android:gravity="center"
android:includeFontPadding="false"
Expand Down
2 changes: 1 addition & 1 deletion OsmAnd/res/layout/vehicle_metrics_recording_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
android:layout_height="0dp"
android:layout_weight="1" />

<include layout="@layout/bottom_buttons" />
<include layout="@layout/control_bottom_buttons" />

</LinearLayout>
2 changes: 1 addition & 1 deletion OsmAnd/res/xml/monitoring_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<Preference
android:key="record_obd_data"
android:layout="@layout/preference_with_descr"
android:title="@string/record_obd_data"
android:title="@string/obd_widget_group"
tools:icon="@drawable/ic_action_car_info" />

<Preference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,18 @@ private void setupShowTripRecNotificationPref() {

public void setupObdRecordingPref() {
Preference preference = findPreference(RECORD_OBD_DATA);

@ColorRes int iconColor = isNightMode() ? R.color.icon_color_default_light : R.color.icon_color_default_dark;
int iconId = R.drawable.ic_action_car_info;
Drawable prefIcon = getIcon(iconId, iconColor);
String summary = app.getString(R.string.shared_string_none);;

VehicleMetricsPlugin plugin = PluginsHelper.getPlugin(VehicleMetricsPlugin.class);
if (plugin != null) {
List<String> enabledCommands = plugin.getTRIP_RECORDING_VEHICLE_METRICS().getStringsListForProfile(getSelectedAppMode());
if (!Algorithms.isEmpty(enabledCommands)) {
summary = String.valueOf(enabledCommands.size());
prefIcon = getActiveIcon(iconId);
}
}
preference.setSummary(summary);
Expand All @@ -288,8 +294,7 @@ public void setupObdRecordingPref() {
preference.setVisible(purchased && PluginsHelper.isEnabled(VehicleMetricsPlugin.class));
promo.setVisible(!purchased);

int iconId = R.drawable.ic_action_car_info;
preference.setIcon(getPersistentPrefIcon(iconId));
preference.setIcon(prefIcon);
promo.setIcon(getContentIcon(iconId));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static net.osmand.plus.plugins.monitoring.VehicleMetricsRecordingFragment.*;

import android.annotation.SuppressLint;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -20,6 +21,7 @@
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.utils.AndroidUtils;
import net.osmand.plus.utils.ColorUtilities;
import net.osmand.plus.utils.UiUtilities;
import net.osmand.shared.obd.OBDCommand;
Expand Down Expand Up @@ -185,11 +187,13 @@ private void updateIcon(boolean checked, @DrawableRes int iconId) {
class CategoryHolder extends RecyclerView.ViewHolder {
private final View itemView;
private final TextView textView;
private final ImageView imageView;

public CategoryHolder(@NonNull View itemView) {
super(itemView);
this.itemView = itemView;
textView = itemView.findViewById(android.R.id.title);
imageView = itemView.findViewById(android.R.id.icon);
}

public void bindView(@NonNull VehicleMetricsRecordingCategory category) {
Expand All @@ -199,6 +203,13 @@ public void bindView(@NonNull VehicleMetricsRecordingCategory category) {
int dp36 = getDimen(app, R.dimen.showAllButtonHeight);
itemView.setMinimumHeight(dp36);
textView.setText(category.titleId);

LinearLayout.LayoutParams currentImageParams = (LinearLayout.LayoutParams) imageView.getLayoutParams();
int size = app.getResources().getDimensionPixelSize(R.dimen.standard_icon_size);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(size, size);
params.gravity = Gravity.CENTER;
params.setMargins(currentImageParams.leftMargin, currentImageParams.topMargin, AndroidUtils.dpToPx(app, 8), currentImageParams.bottomMargin);
imageView.setLayoutParams(params);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

Expand All @@ -20,6 +21,7 @@
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
Expand Down Expand Up @@ -82,6 +84,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
updateNightMode();
View view = themedInflater.inflate(R.layout.vehicle_metrics_recording_fragment, container, false);
AndroidUtils.addStatusBarPadding21v(requireMyActivity(), view);
Window window = requireMapActivity().getWindow();
if (window != null) {
window.setStatusBarColor(ContextCompat.getColor(requireMapActivity(), getStatusBarColorId()));
AndroidUiHelper.setStatusBarContentColor(window.getDecorView(), nightMode);
}

toolbar = view.findViewById(R.id.toolbar);
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar);
Expand All @@ -108,15 +115,15 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
}

updateSelectAllButton();
setupButtons(view);
setupButtons();
setupToolbar();
setupItems();

return view;
}

@SuppressLint("NotifyDataSetChanged")
private void setupButtons(@NonNull View view) {
private void setupButtons() {
selectAllButton.setOnClickListener(v -> {
if (areAllCommandsSelected()) {
selectedCommands.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public boolean setPreference(String key, Object value, ApplicationMode mode) {
} else if (preference instanceof ListStringPreference listStringPreference) {
if (value instanceof List<?> || (value == null && listStringPreference.isNullSupported(mode))) {
if (value == null) {
listStringPreference.setStringsListForProfile(mode,null);
listStringPreference.setStringsListForProfile(mode, null);
} else {
List<?> list = (List<?>) value;
boolean isListOfString = list.stream().allMatch(element -> element instanceof String);
Expand Down
Loading

0 comments on commit 505cad6

Please sign in to comment.