Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Improve Widgetdesign with darkmode #875

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.kabouzeid.gramophone.service.MusicService;
import com.kabouzeid.gramophone.ui.activities.MainActivity;
import com.kabouzeid.gramophone.util.ImageUtil;
import com.kabouzeid.gramophone.util.PreferenceUtil;
import com.kabouzeid.gramophone.util.Util;

public class AppWidgetBig extends BaseAppWidget {
Expand Down Expand Up @@ -65,6 +66,13 @@ public void performUpdate(final MusicService service, final int[] appWidgetIds)
final boolean isPlaying = service.isPlaying();
final Song song = service.getCurrentSong();

int currentTheme = PreferenceUtil.getInstance(service.getApplicationContext()).getGeneralTheme();
if(currentTheme == R.style.Theme_Phonograph || currentTheme == R.style.Theme_Phonograph_Black){
appWidgetView.setInt(R.id.content, "setBackgroundResource", R.drawable.card_dark);
appWidgetView.setTextColor(R.id.title, service.getResources().getColor(R.color.ate_primary_text_dark));
appWidgetView.setTextColor(R.id.text, service.getResources().getColor(R.color.ate_primary_text_dark));
}

// Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.kabouzeid.gramophone.service.MusicService;
import com.kabouzeid.gramophone.ui.activities.MainActivity;
import com.kabouzeid.gramophone.util.ImageUtil;
import com.kabouzeid.gramophone.util.PreferenceUtil;

public class AppWidgetCard extends BaseAppWidget {
public static final String NAME = "app_widget_card";
Expand Down Expand Up @@ -67,6 +68,13 @@ public void performUpdate(final MusicService service, final int[] appWidgetIds)
final boolean isPlaying = service.isPlaying();
final Song song = service.getCurrentSong();

int currentTheme = PreferenceUtil.getInstance(service.getApplicationContext()).getGeneralTheme();
if(currentTheme == R.style.Theme_Phonograph || currentTheme == R.style.Theme_Phonograph_Black){
appWidgetView.setInt(R.id.content, "setBackgroundResource", R.drawable.card_dark);
appWidgetView.setTextColor(R.id.title, service.getResources().getColor(R.color.ate_primary_text_dark));
appWidgetView.setTextColor(R.id.text, service.getResources().getColor(R.color.ate_primary_text_dark));
}

// Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.kabouzeid.gramophone.service.MusicService;
import com.kabouzeid.gramophone.ui.activities.MainActivity;
import com.kabouzeid.gramophone.util.ImageUtil;
import com.kabouzeid.gramophone.util.PreferenceUtil;

public class AppWidgetClassic extends BaseAppWidget {
public static final String NAME = "app_widget_classic";
Expand Down Expand Up @@ -64,6 +65,13 @@ protected void defaultAppWidget(final Context context, final int[] appWidgetIds)
public void performUpdate(final MusicService service, final int[] appWidgetIds) {
final RemoteViews appWidgetView = new RemoteViews(service.getPackageName(), R.layout.app_widget_classic);

int currentTheme = PreferenceUtil.getInstance(service.getApplicationContext()).getGeneralTheme();
if(currentTheme == R.style.Theme_Phonograph || currentTheme == R.style.Theme_Phonograph_Black){
appWidgetView.setInt(R.id.content, "setBackgroundResource", R.drawable.card_dark);
appWidgetView.setTextColor(R.id.title, service.getResources().getColor(R.color.ate_primary_text_dark));
appWidgetView.setTextColor(R.id.text, service.getResources().getColor(R.color.ate_primary_text_dark));
}

final boolean isPlaying = service.isPlaying();
final Song song = service.getCurrentSong();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.kabouzeid.gramophone.service.MusicService;
import com.kabouzeid.gramophone.ui.activities.MainActivity;
import com.kabouzeid.gramophone.util.ImageUtil;
import com.kabouzeid.gramophone.util.PreferenceUtil;

public class AppWidgetSmall extends BaseAppWidget {
public static final String NAME = "app_widget_small";
Expand Down Expand Up @@ -67,6 +68,13 @@ public void performUpdate(final MusicService service, final int[] appWidgetIds)
final boolean isPlaying = service.isPlaying();
final Song song = service.getCurrentSong();

int currentTheme = PreferenceUtil.getInstance(service.getApplicationContext()).getGeneralTheme();
if(currentTheme == R.style.Theme_Phonograph || currentTheme == R.style.Theme_Phonograph_Black){
appWidgetView.setInt(R.id.content, "setBackgroundResource", R.drawable.card_dark);
appWidgetView.setTextColor(R.id.title, service.getResources().getColor(R.color.ate_primary_text_dark));
appWidgetView.setTextColor(R.id.text, service.getResources().getColor(R.color.ate_primary_text_dark));
}

// Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
Expand Down
36 changes: 0 additions & 36 deletions app/src/main/res/drawable/card.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<shape>
<padding
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
android:left="0dp"/>
<solid android:color="@android:color/transparent"/>
</shape>
</item>

<item>
<shape>
<padding
android:top="0dp"
android:right="0dp"
android:bottom="1dp"
android:left="0dp"/>
<solid android:color="#55d4d4d4"/>
<corners android:radius="@dimen/app_widget_card_radius"/>
</shape>
</item>
<item>
<shape>
<padding
android:top="0dp"
android:right="0dp"
android:bottom="1dp"
android:left="0dp"/>
<solid android:color="#55dddddd"/>
<corners android:radius="@dimen/app_widget_card_radius"/>
</shape>
</item>

<item>
<shape>
<solid android:color="@android:color/white"/>
<corners android:radius="@dimen/app_widget_card_radius"/>
</shape>
</item>

</layer-list>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/card_dark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/cardview_dark_background"/>
<corners android:radius="@dimen/app_widget_card_radius"/>
</shape>
</item>
</layer-list>
1 change: 1 addition & 0 deletions app/src/main/res/layout/app_widget_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/app_widget_small.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/card"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
<dimen name="app_widget_card_min_width">250dp</dimen>
<dimen name="app_widget_card_min_height">40dp</dimen>
<dimen name="app_widget_card_buttons_width">128dp</dimen>
<dimen name="app_widget_card_radius">2dp</dimen>
<dimen name="app_widget_card_radius">10dp</dimen>

<dimen name="card_on_app_bar_side_padding">8dp</dimen>

Expand Down