Skip to content

Commit

Permalink
Add more Credits
Browse files Browse the repository at this point in the history
Fix Weather Icon Summary
  • Loading branch information
DHD2280 committed Apr 22, 2024
1 parent 771cb8c commit 0515b55
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,26 @@ public void createDefaultAdapter(Drawable[] drawables) {
}
});
}

public void createDefaultAdapter(Drawable[] drawables, onItemClick listener) {
mHasImages = true;
mEntryDrawables = drawables;
mAdapter = new ListPreferenceAdapter(getEntries(),
getEntryValues(),
drawables,
getKey(),
mHasImages,
(view1, position) -> {
if (callChangeListener(getEntryValues()[position].toString())) {
setValueIndex(position);
}
if (listener != null) {
listener.onItemClick(position);
}
});
}

public interface onItemClick {
void onItemClick(int position);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.net.Uri;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -73,7 +74,11 @@ public ItemViewHolder(@NonNull CreditsItemViewBinding binding) {

public void bind(CreditsModel model) {
binding.title.setText(model.getTitle());
binding.desc.setText(model.getSummary());
if (!TextUtils.isEmpty(model.getSummary())) {
binding.desc.setVisibility(View.VISIBLE);
binding.desc.setText(model.getSummary());
} else
binding.desc.setVisibility(View.GONE);
if (model.getIcon() != 0) {
binding.icon.setImageResource(model.getIcon());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
For some customizations
github/SuperiorExtended""", "https://github.com/SuperiorExtended/", R.drawable.ic_superior));

credits.add(new CreditsModel("Testers"));
credits.add(new CreditsModel(VIEW_TYPE_ITEM, "Max", "", "", R.drawable.ic_default_person));
credits.add(new CreditsModel(VIEW_TYPE_ITEM, "Siri00", "", "", R.drawable.ic_default_person));
credits.add(new CreditsModel(VIEW_TYPE_ITEM, "Pasqui1978", "", "", R.drawable.ic_default_person));
credits.add(new CreditsModel(VIEW_TYPE_ITEM, "ZioProne", "", "", R.drawable.ic_default_person));

CreditsAdapter adapter = new CreditsAdapter(credits);
binding.creditsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
binding.creditsRecyclerView.setAdapter(adapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ public void doLoadPreferences() {
getAvailableWeatherIconPacks(entries, values, drawables);
mWeatherIconPack.setEntries(entries.toArray(new String[0]));
mWeatherIconPack.setEntryValues(values.toArray(new String[0]));
mWeatherIconPack.createDefaultAdapter(drawables.toArray(new Drawable[0]));
mWeatherIconPack.createDefaultAdapter(drawables.toArray(new Drawable[0]),
(position) -> mWeatherIconPack.setSummary(entries.get(position)));
int valueIndex = mWeatherIconPack.findIndexOfValue(settingHeaderPackage);
if (valueIndex == -1) {
// no longer found
Expand All @@ -272,7 +273,7 @@ public void doLoadPreferences() {
mWeatherIconPack.setSummary(mWeatherIconPack.getEntry());
mWeatherIconPack.setOnPreferenceChangeListener(this);
} else {
prefScreen.removePreference(mWeatherIconPack);
if (mWeatherIconPack != null) prefScreen.removePreference(mWeatherIconPack);
}
mUpdateStatus = findPreference(PREF_KEY_UPDATE_STATUS);
if (mUpdateStatus != null) {
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/res/layout/credits_item_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/list_info_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -14,7 +15,7 @@
android:layout_marginStart="24dp"
android:contentDescription="@string/credits_title" />

<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
Expand All @@ -29,14 +30,21 @@
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color_primary" />
android:textColor="@color/text_color_primary"
app:layout_constraintBottom_toTopOf="@+id/desc"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<TextView
android:id="@+id/desc"
android:visibility="visible"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color_secondary" />
android:textColor="@color/text_color_secondary"
android:layout_marginTop="6dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title"/>

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>

0 comments on commit 0515b55

Please sign in to comment.