Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRe1nk0 committed Nov 20, 2024
1 parent 124d447 commit e5a0531
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
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

0 comments on commit e5a0531

Please sign in to comment.