Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): AGP 8, Java 17, Kotlin 1.9.22, SSO 1.0.0 #1979

Merged
merged 9 commits into from
Jan 21, 2024
30 changes: 27 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
cache: 'gradle'
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

Expand All @@ -24,26 +30,44 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
cache: 'gradle'
- name: Lint
run: bash ./gradlew lintDevDebug --stacktrace
run: bash ./gradlew lintDevDebug --stacktrace --no-configuration-cache

test:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
cache: 'gradle'
- name: Unit tests
run: bash ./gradlew test --stacktrace
run: bash ./gradlew test --stacktrace --no-configuration-cache

apk:
name: Generate APK
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
cache: 'gradle'
- name: Build debug APK
run: bash ./gradlew assembleDev --stacktrace
run: bash ./gradlew assembleDev --stacktrace --no-configuration-cache
- name: Upload APK
uses: actions/upload-artifact@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
distribution: "temurin"
java-version: 17
distribution: 'temurin'
java-version: '17'
- name: Assemble
run: |
mkdir -p "$HOME/.gradle"
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
./gradlew assembleDebug
./gradlew assembleDebug --no-configuration-cache
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@b374143c1149a9115d881581d29b8390bbcbb59c # v3.22.11
52 changes: 29 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'

android {
compileSdkVersion 33

compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
compileSdk 34
namespace 'it.niedermann.owncloud.notes'

defaultConfig {
applicationId "it.niedermann.owncloud.notes"
minSdkVersion 24
targetSdkVersion 33
minSdk 24
targetSdk 34
versionCode 40020000
versionName "4.2.0 Alpha1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -24,8 +19,19 @@ android {
}
}

compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '17'
}

buildFeatures {
viewBinding true
buildConfig true
}

buildTypes {
Expand All @@ -40,7 +46,7 @@ android {
}


flavorDimensions "version"
flavorDimensions = ["version"]

productFlavors {
fdroid {
Expand All @@ -60,25 +66,25 @@ android {
includeAndroidResources true
}
}
lint {

lintOptions {
abortOnError false
disable 'MissingTranslation'
}
namespace 'it.niedermann.owncloud.notes'
}

ext {
glideVersion = '4.16.0'
roomVersion = "2.5.1"
roomVersion = "2.6.1"
}

dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

// Nextcloud SSO
implementation 'com.github.nextcloud.android-common:ui:0.12.0'
implementation 'com.github.nextcloud:Android-SingleSignOn:0.8.1'
implementation 'com.github.stefan-niedermann:android-commons:0.2.9'
implementation 'com.github.nextcloud.android-common:ui:0.13.0'
implementation 'com.github.nextcloud:Android-SingleSignOn:1.0.0'
implementation 'com.github.stefan-niedermann:android-commons:1.0.0'
implementation "com.github.stefan-niedermann.nextcloud-commons:sso-glide:$commonsVersion"
implementation "com.github.stefan-niedermann.nextcloud-commons:exception:$commonsVersion"
implementation("com.github.stefan-niedermann.nextcloud-commons:markdown:$commonsVersion") {
Expand All @@ -91,16 +97,16 @@ dependencies {

// Android X
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation 'androidx.fragment:fragment:1.6.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
implementation 'androidx.fragment:fragment:1.6.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
implementation 'androidx.preference:preference:1.2.1'
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.work:work-runtime:2.8.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.work:work-runtime:2.9.0'
implementation 'com.google.android.material:material:1.11.0'

// Database
implementation "androidx.room:room-runtime:${roomVersion}"
Expand All @@ -120,7 +126,7 @@ dependencies {
testImplementation 'androidx.test:core:1.5.0'
testImplementation 'androidx.arch.core:core-testing:2.2.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.7.0'
testImplementation 'org.mockito:mockito-core:5.9.0'
testImplementation 'org.robolectric:robolectric:4.11.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@ protected void onCreate(Bundle savedInstanceState) {
binding.pager.setAdapter(new TabsStateAdapter(this));
// generate title based on given position
new TabLayoutMediator(binding.tabs, binding.pager, (tab, position) -> {
switch (position) {
default: // Fall-through to credits tab
case POS_CREDITS:
tab.setText(R.string.about_credits_tab_title);
break;
case POS_CONTRIB:
tab.setText(R.string.about_contribution_tab_title);
break;
case POS_LICENSE:
tab.setText(R.string.about_license_tab_title);
break;
switch (position) { // Fall-through to credits tab
default ->
tab.setText(R.string.about_credits_tab_title);
case POS_CONTRIB ->
tab.setText(R.string.about_contribution_tab_title);
case POS_LICENSE ->
tab.setText(R.string.about_license_tab_title);
}
}).attach();
}
Expand Down Expand Up @@ -74,17 +70,11 @@ public int getItemCount() {
@NonNull
@Override
public Fragment createFragment(int position) {
switch (position) {
default: // Fall-through to credits tab
case POS_CREDITS:
return new AboutFragmentCreditsTab();

case POS_CONTRIB:
return new AboutFragmentContributingTab();

case POS_LICENSE:
return new AboutFragmentLicenseTab();
}
return switch (position) { // Fall-through to credits tab
default -> new AboutFragmentCreditsTab();
case POS_CONTRIB -> new AboutFragmentContributingTab();
case POS_LICENSE -> new AboutFragmentLicenseTab();
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;

import it.niedermann.owncloud.notes.R;
import com.google.android.material.R;

public abstract class BrandedActivity extends AppCompatActivity implements Branded {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public void onStart() {

final var context = requireContext();
final var typedValue = new TypedValue();
context.getTheme().resolveAttribute(R.attr.colorAccent, typedValue, true);
context.getTheme().resolveAttribute(com.google.android.material.R.attr.colorAccent, typedValue, true);
colorAccent = typedValue.data;
context.getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
context.getTheme().resolveAttribute(com.google.android.material.R.attr.colorPrimary, typedValue, true);
colorPrimary = typedValue.data;

@ColorInt final int color = BrandingUtil.readBrandMainColor(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ private Switch findSwitchWidget(View view) {
if (view instanceof Switch) {
return (Switch) view;
}
if (view instanceof ViewGroup) {
final var viewGroup = (ViewGroup) view;
if (view instanceof ViewGroup viewGroup) {
for (int i = 0; i < viewGroup.getChildCount(); i++) {
final var child = viewGroup.getChildAt(i);
if (child instanceof ViewGroup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public int getTextHighlightBackgroundColor(@NonNull Context context,
@ColorInt int colorPrimary,
@ColorInt int colorAccent) {
if (isDarkMode(context)) { // Dark background
if (ColorUtil.INSTANCE.isColorDark(mainColor)) { // Dark brand color
if (ColorUtil.isColorDark(mainColor)) { // Dark brand color
if (NotesColorUtil.contrastRatioIsSufficient(mainColor, colorPrimary)) { // But also dark text
return mainColor;
} else {
Expand All @@ -139,7 +139,7 @@ public int getTextHighlightBackgroundColor(@NonNull Context context,
}
}
} else { // Light background
if (ColorUtil.INSTANCE.isColorDark(mainColor)) { // Dark brand color
if (ColorUtil.isColorDark(mainColor)) { // Dark brand color
if (NotesColorUtil.contrastRatioIsSufficient(mainColor, colorAccent)) { // But also dark text
return Color.argb(77, Color.red(mainColor), Color.green(mainColor), Color.blue(mainColor));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (accountId > 0) {
/* Switch account if account id has been provided */
this.localAccount = repo.getAccountById(accountId);
SingleAccountHelper.setCurrentAccount(requireContext().getApplicationContext(), localAccount.getAccountName());
SingleAccountHelper.commitCurrentAccount(requireContext().getApplicationContext(), localAccount.getAccountName());
}
isNew = false;
note = originalNote = repo.getNoteById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected void onCreate(final Bundle savedInstanceState) {

try {
if (SingleAccountHelper.getCurrentSingleSignOnAccount(this) == null) {
throw new NoCurrentAccountSelectedException();
throw new NoCurrentAccountSelectedException(this);
}
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
Toast.makeText(this, R.string.no_account_configured_yet, Toast.LENGTH_LONG).show();
Expand Down Expand Up @@ -397,17 +397,10 @@ public void onNoteUpdated(Note note) {
@Override
public void changeMode(@NonNull Mode mode, boolean reloadNote) {
switch (mode) {
case EDIT:
launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_edit), reloadNote);
break;
case PREVIEW:
launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_preview), reloadNote);
break;
case DIRECT_EDIT:
launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_direct_edit), reloadNote);
break;
default:
throw new IllegalStateException("Unknown mode: " + mode);
case EDIT -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_edit), reloadNote);
case PREVIEW -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_preview), reloadNote);
case DIRECT_EDIT -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_direct_edit), reloadNote);
default -> throw new IllegalStateException("Unknown mode: " + mode);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;
import androidx.core.content.ContextCompat;

import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
Expand Down Expand Up @@ -47,7 +48,8 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment {

@Override
public void onStart() {
this.color = getResources().getColor(R.color.defaultBrand);
this.color = ContextCompat.getColor(
requireContext(), R.color.defaultBrand);
super.onStart();
}

Expand Down Expand Up @@ -117,8 +119,8 @@ public void onPrepareOptionsMenu(@NonNull Menu menu) {

searchMenuItem.collapseActionView();

final var searchEditFrame = searchView.findViewById(R.id
.search_edit_frame);
final var searchEditFrame = searchView.findViewById(
androidx.appcompat.R.id.search_edit_frame);

searchEditFrame.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
int oldVisibility = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ItemCategoryBinding;
Expand Down Expand Up @@ -50,20 +51,22 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
final var categoryViewHolder = (CategoryViewHolder) holder;

switch (category.id) {
case addItemId:
final var wrapDrawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, category.icon));
case addItemId -> {
final var wrapDrawable = DrawableCompat.wrap(
Objects.requireNonNull(ContextCompat.getDrawable(
context, category.icon)));
DrawableCompat.setTint(wrapDrawable, ContextCompat.getColor(context, R.color.icon_color_default));
categoryViewHolder.getIcon().setImageDrawable(wrapDrawable);
categoryViewHolder.getCategoryWrapper().setOnClickListener((v) -> listener.onCategoryAdded());
break;
case clearItemId:
}
case clearItemId -> {
categoryViewHolder.getIcon().setImageDrawable(ContextCompat.getDrawable(context, category.icon));
categoryViewHolder.getCategoryWrapper().setOnClickListener((v) -> listener.onCategoryCleared());
break;
default:
}
default -> {
categoryViewHolder.getIcon().setImageDrawable(ContextCompat.getDrawable(context, category.icon));
categoryViewHolder.getCategoryWrapper().setOnClickListener((v) -> listener.onCategoryChosen(category.label));
break;
}
}
categoryViewHolder.getCategory().setText(NoteUtil.extendCategory(category.label));
if (category.count != null && category.count > 0) {
Expand Down
Loading
Loading