mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 10:05:49 +01:00
Controllable backgroundColor to item view. Split lines Activity Kind and Activity Name Label to prevent overflow
This commit is contained in:
parent
3bf2d4f086
commit
723bd6fb6e
@ -23,9 +23,11 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ActionMode;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -259,8 +261,10 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setItemAdapter(new ActivitySummariesAdapter(this, mGBDevice,activityFilter,dateFromFilter,dateToFilter,nameContainsFilter));
|
||||
ActivitySummariesAdapter activitySummariesAdapter = new ActivitySummariesAdapter(this, mGBDevice,activityFilter,dateFromFilter,dateToFilter,nameContainsFilter);
|
||||
int backgroundColor = getBackgroundColor(ActivitySummariesActivity.this);
|
||||
activitySummariesAdapter.setBackgroundColor(backgroundColor);
|
||||
setItemAdapter(activitySummariesAdapter);
|
||||
|
||||
getItemListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
@ -465,6 +469,11 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static int getBackgroundColor(Context context) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
Resources.Theme theme = context.getTheme();
|
||||
theme.resolveAttribute(R.attr.sports_activity_summary_background, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -242,6 +242,12 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
TextView activity_name = findViewById(R.id.activityname);
|
||||
activity_name.setText(activityname);
|
||||
|
||||
if (activityname == null || (activityname != null && activityname.length() < 1)) {
|
||||
activity_name.setVisibility(View.GONE);
|
||||
} else {
|
||||
activity_name.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
TextView start_time = findViewById(R.id.starttime);
|
||||
start_time.setText(starttimeS);
|
||||
TextView end_time = findViewById(R.id.endtime);
|
||||
|
@ -18,6 +18,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -25,10 +27,11 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
|
||||
/**
|
||||
@ -43,6 +46,7 @@ public abstract class AbstractItemAdapter<T> extends ArrayAdapter<T> {
|
||||
private final List<T> items;
|
||||
private boolean horizontalAlignment;
|
||||
private int size = SIZE_MEDIUM;
|
||||
private int backgroundColor=0;
|
||||
|
||||
public AbstractItemAdapter(Context context) {
|
||||
this (context, new ArrayList<T>());
|
||||
@ -103,6 +107,7 @@ public abstract class AbstractItemAdapter<T> extends ArrayAdapter<T> {
|
||||
nameView.setText(getName(item));
|
||||
detailsView.setText(getDetails(item));
|
||||
iconView.setImageResource(getIcon(item));
|
||||
iconView.setBackgroundColor(backgroundColor);
|
||||
|
||||
return view;
|
||||
}
|
||||
@ -118,10 +123,12 @@ public abstract class AbstractItemAdapter<T> extends ArrayAdapter<T> {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public List<T> getItems() {
|
||||
return items;
|
||||
}
|
||||
@ -136,4 +143,5 @@ public abstract class AbstractItemAdapter<T> extends ArrayAdapter<T> {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,21 +48,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-black"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="10dp"
|
||||
android:scrollHorizontally="false"
|
||||
android:textSize="18sp" />
|
||||
<TextView
|
||||
android:id="@+id/activityname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-black"
|
||||
android:maxLines="1"
|
||||
android:scrollHorizontally="false"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1" />
|
||||
android:layout_weight="0.1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/activity_summary_detail_edit_name"
|
||||
@ -74,6 +66,15 @@
|
||||
app:srcCompat="@drawable/ic_edit" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activityname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-black"
|
||||
android:scrollHorizontally="false"
|
||||
android:singleLine="true"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/summaryHeader"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -8,7 +8,6 @@
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:background="?attr/sports_activity_summary_background"
|
||||
android:contentDescription="@string/candidate_item_device_image"
|
||||
android:padding="8dp" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user