Skip to content
Merged
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
10 changes: 9 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ android {
compileSdk = 35

defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
applicationId = "com.best.deskclock"
minSdk = 23
targetSdk = 35
Expand Down Expand Up @@ -71,7 +72,9 @@ android {
}

lintOptions {
abortOnError = false
baseline file("lint-baseline.xml")
abortOnError true
fatal "InconsistentArrays"
}

compileOptions {
Expand All @@ -94,6 +97,11 @@ android {
}

dependencies {
androidTestImplementation "androidx.test.ext:junit:1.2.1"
androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1"
androidTestImplementation "androidx.test:runner:1.6.1"
androidTestImplementation "androidx.test:rules:1.6.1"
androidTestImplementation "androidx.test.espresso:espresso-intents:3.6.1"
// Room components
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"
Expand Down
32,794 changes: 32,794 additions & 0 deletions app/lint-baseline.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.best.deskclock.settings;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;

import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;

import com.best.deskclock.DeskClock;
import com.best.deskclock.R;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class SettingsSmokeTest {

@Rule
public ActivityScenarioRule<DeskClock> mActivityScenarioRule =
new ActivityScenarioRule<>(DeskClock.class);

@Test
public void testAppLaunches() {
// Just verify DeskClock launches and displays the "Clock" tab or similar
onView(withText(R.string.menu_clock)).check(matches(isDisplayed()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only

package com.best.deskclock.settings.custompreference;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceViewHolder;

import com.best.deskclock.R;

/**
* A {@link ListPreference} with a custom Material-style layout.
*
* <p>This class applies a custom card-based appearance to the preference row
* and updates its typography and visual styling based on the user's settings
* (font, card background, card border, etc.).</p>
*
* <p>The preference behavior remains identical to a standard {@link ListPreference};
* only its visual presentation is customized.</p>
*/
public class CustomListPreference extends ListPreference {

public CustomListPreference(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.settings_preference_layout);
}

@Override
public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
PreferenceStyler.apply(holder);
super.onBindViewHolder(holder);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only

package com.best.deskclock.settings.custompreference;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;

import com.best.deskclock.R;

/**
* A {@link Preference} with a custom Material-style layout.
*
* <p>This class applies a custom card-based appearance to the preference row
* and updates its typography and visual styling based on the user's settings
* (font, card background, card border, etc.).</p>
*
* <p>The preference behavior remains identical to a standard {@link Preference};
* only its visual presentation is customized.</p>
*/
public class CustomPreference extends Preference {

public CustomPreference(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.settings_preference_layout);
}

@Override
public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
PreferenceStyler.apply(holder);
super.onBindViewHolder(holder);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.best.deskclock.settings.custompreference;

import static com.best.deskclock.DeskClockApplication.getDefaultSharedPreferences;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.AttributeSet;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceViewHolder;

import com.best.deskclock.R;
import com.best.deskclock.data.SettingsDAO;
import com.best.deskclock.utils.ThemeUtils;

/**
* A {@link PreferenceCategory} with a custom layout.
*
* <p>This class updates its typography and visual styling based on the user's settings
* (font, accent color, etc.).</p>
*
* <p>The preference behavior remains identical to a standard {@link PreferenceCategory};
* only its visual presentation is customized.</p>
*/
public class CustomPreferenceCategory extends PreferenceCategory {

public CustomPreferenceCategory(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.settings_preference_category_layout);
}

@Override
public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
if (holder.itemView.isInEditMode()) {
// Skip logic during Android Studio preview
return;
}

super.onBindViewHolder(holder);

SharedPreferences prefs = getDefaultSharedPreferences(getContext());

TextView prefTitle = (TextView) holder.findViewById(android.R.id.title);
prefTitle.setTypeface(ThemeUtils.boldTypeface(SettingsDAO.getGeneralFont(prefs)));
}
}
Loading
Loading