Skip to content

Commit 76f943a

Browse files
Merge pull request #1979 from nextcloud/agp-8
chore(deps): AGP 8, Java 17, Kotlin 1.9.22, SSO 1.0.0
2 parents 7a8d837 + adf1a21 commit 76f943a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+241
-303
lines changed

.github/workflows/android.yml

+27-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ jobs:
1515
steps:
1616
- name: Checkout
1717
uses: actions/[email protected]
18+
- uses: actions/setup-java@v4
19+
with:
20+
distribution: 'temurin'
21+
java-version: '17'
22+
check-latest: true
23+
cache: 'gradle'
1824
- name: Validate Gradle Wrapper
1925
uses: gradle/wrapper-validation-action@v1
2026

@@ -24,26 +30,44 @@ jobs:
2430
steps:
2531
- name: Checkout
2632
uses: actions/[email protected]
33+
- uses: actions/setup-java@v4
34+
with:
35+
distribution: 'temurin'
36+
java-version: '17'
37+
check-latest: true
38+
cache: 'gradle'
2739
- name: Lint
28-
run: bash ./gradlew lintDevDebug --stacktrace
40+
run: bash ./gradlew lintDevDebug --stacktrace --no-configuration-cache
2941

3042
test:
3143
name: Unit tests
3244
runs-on: ubuntu-latest
3345
steps:
3446
- name: Checkout
3547
uses: actions/[email protected]
48+
- uses: actions/setup-java@v4
49+
with:
50+
distribution: 'temurin'
51+
java-version: '17'
52+
check-latest: true
53+
cache: 'gradle'
3654
- name: Unit tests
37-
run: bash ./gradlew test --stacktrace
55+
run: bash ./gradlew test --stacktrace --no-configuration-cache
3856

3957
apk:
4058
name: Generate APK
4159
runs-on: ubuntu-latest
4260
steps:
4361
- name: Checkout
4462
uses: actions/[email protected]
63+
- uses: actions/setup-java@v4
64+
with:
65+
distribution: 'temurin'
66+
java-version: '17'
67+
check-latest: true
68+
cache: 'gradle'
4569
- name: Build debug APK
46-
run: bash ./gradlew assembleDev --stacktrace
70+
run: bash ./gradlew assembleDev --stacktrace --no-configuration-cache
4771
- name: Upload APK
4872
uses: actions/upload-artifact@v4
4973
with:

.github/workflows/codeql.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ jobs:
3838
- name: Set up JDK 17
3939
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
4040
with:
41-
distribution: "temurin"
42-
java-version: 17
41+
distribution: 'temurin'
42+
java-version: '17'
4343
- name: Assemble
4444
run: |
4545
mkdir -p "$HOME/.gradle"
4646
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
47-
./gradlew assembleDebug
47+
./gradlew assembleDebug --no-configuration-cache
4848
- name: Perform CodeQL Analysis
4949
uses: github/codeql-action/analyze@b374143c1149a9115d881581d29b8390bbcbb59c # v3.22.11

app/build.gradle

+29-23
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@ apply plugin: 'com.android.application'
22
apply plugin: 'org.jetbrains.kotlin.android'
33

44
android {
5-
compileSdkVersion 33
6-
7-
compileOptions {
8-
coreLibraryDesugaringEnabled true
9-
sourceCompatibility JavaVersion.VERSION_11
10-
targetCompatibility JavaVersion.VERSION_11
11-
}
5+
compileSdk 34
6+
namespace 'it.niedermann.owncloud.notes'
127

138
defaultConfig {
149
applicationId "it.niedermann.owncloud.notes"
15-
minSdkVersion 24
16-
targetSdkVersion 33
10+
minSdk 24
11+
targetSdk 34
1712
versionCode 40020000
1813
versionName "4.2.0 Alpha1"
1914
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -24,8 +19,19 @@ android {
2419
}
2520
}
2621

22+
compileOptions {
23+
coreLibraryDesugaringEnabled true
24+
sourceCompatibility JavaVersion.VERSION_17
25+
targetCompatibility JavaVersion.VERSION_17
26+
}
27+
28+
kotlinOptions {
29+
jvmTarget = '17'
30+
}
31+
2732
buildFeatures {
2833
viewBinding true
34+
buildConfig true
2935
}
3036

3137
buildTypes {
@@ -40,7 +46,7 @@ android {
4046
}
4147

4248

43-
flavorDimensions "version"
49+
flavorDimensions = ["version"]
4450

4551
productFlavors {
4652
fdroid {
@@ -60,25 +66,25 @@ android {
6066
includeAndroidResources true
6167
}
6268
}
63-
lint {
69+
70+
lintOptions {
6471
abortOnError false
6572
disable 'MissingTranslation'
6673
}
67-
namespace 'it.niedermann.owncloud.notes'
6874
}
6975

7076
ext {
7177
glideVersion = '4.16.0'
72-
roomVersion = "2.5.1"
78+
roomVersion = "2.6.1"
7379
}
7480

7581
dependencies {
76-
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
82+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
7783

7884
// Nextcloud SSO
79-
implementation 'com.github.nextcloud.android-common:ui:0.12.0'
80-
implementation 'com.github.nextcloud:Android-SingleSignOn:0.8.1'
81-
implementation 'com.github.stefan-niedermann:android-commons:0.2.9'
85+
implementation 'com.github.nextcloud.android-common:ui:0.13.0'
86+
implementation 'com.github.nextcloud:Android-SingleSignOn:1.0.0'
87+
implementation 'com.github.stefan-niedermann:android-commons:1.0.0'
8288
implementation "com.github.stefan-niedermann.nextcloud-commons:sso-glide:$commonsVersion"
8389
implementation "com.github.stefan-niedermann.nextcloud-commons:exception:$commonsVersion"
8490
implementation("com.github.stefan-niedermann.nextcloud-commons:markdown:$commonsVersion") {
@@ -91,16 +97,16 @@ dependencies {
9197

9298
// Android X
9399
implementation 'androidx.appcompat:appcompat:1.6.1'
94-
implementation 'androidx.core:core-ktx:1.10.1'
100+
implementation 'androidx.core:core-ktx:1.12.0'
95101
implementation 'androidx.core:core-splashscreen:1.0.1'
96-
implementation 'androidx.fragment:fragment:1.6.1'
97-
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
102+
implementation 'androidx.fragment:fragment:1.6.2'
103+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
98104
implementation 'androidx.preference:preference:1.2.1'
99105
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'
100106
implementation 'androidx.recyclerview:recyclerview:1.3.2'
101107
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
102-
implementation 'androidx.work:work-runtime:2.8.1'
103-
implementation 'com.google.android.material:material:1.9.0'
108+
implementation 'androidx.work:work-runtime:2.9.0'
109+
implementation 'com.google.android.material:material:1.11.0'
104110

105111
// Database
106112
implementation "androidx.room:room-runtime:${roomVersion}"
@@ -120,7 +126,7 @@ dependencies {
120126
testImplementation 'androidx.test:core:1.5.0'
121127
testImplementation 'androidx.arch.core:core-testing:2.2.0'
122128
testImplementation 'junit:junit:4.13.2'
123-
testImplementation 'org.mockito:mockito-core:5.7.0'
129+
testImplementation 'org.mockito:mockito-core:5.9.0'
124130
testImplementation 'org.robolectric:robolectric:4.11.1'
125131

126132
implementation fileTree(dir: 'libs', include: ['*.jar'])

app/src/main/java/it/niedermann/owncloud/notes/about/AboutActivity.java

+12-22
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,13 @@ protected void onCreate(Bundle savedInstanceState) {
3434
binding.pager.setAdapter(new TabsStateAdapter(this));
3535
// generate title based on given position
3636
new TabLayoutMediator(binding.tabs, binding.pager, (tab, position) -> {
37-
switch (position) {
38-
default: // Fall-through to credits tab
39-
case POS_CREDITS:
40-
tab.setText(R.string.about_credits_tab_title);
41-
break;
42-
case POS_CONTRIB:
43-
tab.setText(R.string.about_contribution_tab_title);
44-
break;
45-
case POS_LICENSE:
46-
tab.setText(R.string.about_license_tab_title);
47-
break;
37+
switch (position) { // Fall-through to credits tab
38+
default ->
39+
tab.setText(R.string.about_credits_tab_title);
40+
case POS_CONTRIB ->
41+
tab.setText(R.string.about_contribution_tab_title);
42+
case POS_LICENSE ->
43+
tab.setText(R.string.about_license_tab_title);
4844
}
4945
}).attach();
5046
}
@@ -74,17 +70,11 @@ public int getItemCount() {
7470
@NonNull
7571
@Override
7672
public Fragment createFragment(int position) {
77-
switch (position) {
78-
default: // Fall-through to credits tab
79-
case POS_CREDITS:
80-
return new AboutFragmentCreditsTab();
81-
82-
case POS_CONTRIB:
83-
return new AboutFragmentContributingTab();
84-
85-
case POS_LICENSE:
86-
return new AboutFragmentLicenseTab();
87-
}
73+
return switch (position) { // Fall-through to credits tab
74+
default -> new AboutFragmentCreditsTab();
75+
case POS_CONTRIB -> new AboutFragmentContributingTab();
76+
case POS_LICENSE -> new AboutFragmentLicenseTab();
77+
};
8878
}
8979
}
9080

app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import androidx.annotation.ColorInt;
99
import androidx.appcompat.app.AppCompatActivity;
1010

11-
import it.niedermann.owncloud.notes.R;
11+
import com.google.android.material.R;
1212

1313
public abstract class BrandedActivity extends AppCompatActivity implements Branded {
1414

app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedFragment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public void onStart() {
2323

2424
final var context = requireContext();
2525
final var typedValue = new TypedValue();
26-
context.getTheme().resolveAttribute(R.attr.colorAccent, typedValue, true);
26+
context.getTheme().resolveAttribute(com.google.android.material.R.attr.colorAccent, typedValue, true);
2727
colorAccent = typedValue.data;
28-
context.getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
28+
context.getTheme().resolveAttribute(com.google.android.material.R.attr.colorPrimary, typedValue, true);
2929
colorPrimary = typedValue.data;
3030

3131
@ColorInt final int color = BrandingUtil.readBrandMainColor(context);

app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ private Switch findSwitchWidget(View view) {
7474
if (view instanceof Switch) {
7575
return (Switch) view;
7676
}
77-
if (view instanceof ViewGroup) {
78-
final var viewGroup = (ViewGroup) view;
77+
if (view instanceof ViewGroup viewGroup) {
7978
for (int i = 0; i < viewGroup.getChildCount(); i++) {
8079
final var child = viewGroup.getChildAt(i);
8180
if (child instanceof ViewGroup) {

app/src/main/java/it/niedermann/owncloud/notes/branding/NotesViewThemeUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public int getTextHighlightBackgroundColor(@NonNull Context context,
125125
@ColorInt int colorPrimary,
126126
@ColorInt int colorAccent) {
127127
if (isDarkMode(context)) { // Dark background
128-
if (ColorUtil.INSTANCE.isColorDark(mainColor)) { // Dark brand color
128+
if (ColorUtil.isColorDark(mainColor)) { // Dark brand color
129129
if (NotesColorUtil.contrastRatioIsSufficient(mainColor, colorPrimary)) { // But also dark text
130130
return mainColor;
131131
} else {
@@ -139,7 +139,7 @@ public int getTextHighlightBackgroundColor(@NonNull Context context,
139139
}
140140
}
141141
} else { // Light background
142-
if (ColorUtil.INSTANCE.isColorDark(mainColor)) { // Dark brand color
142+
if (ColorUtil.isColorDark(mainColor)) { // Dark brand color
143143
if (NotesColorUtil.contrastRatioIsSufficient(mainColor, colorAccent)) { // But also dark text
144144
return Color.argb(77, Color.red(mainColor), Color.green(mainColor), Color.blue(mainColor));
145145
} else {

app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
103103
if (accountId > 0) {
104104
/* Switch account if account id has been provided */
105105
this.localAccount = repo.getAccountById(accountId);
106-
SingleAccountHelper.setCurrentAccount(requireContext().getApplicationContext(), localAccount.getAccountName());
106+
SingleAccountHelper.commitCurrentAccount(requireContext().getApplicationContext(), localAccount.getAccountName());
107107
}
108108
isNew = false;
109109
note = originalNote = repo.getNoteById(id);

app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java

+5-12
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected void onCreate(final Bundle savedInstanceState) {
7171

7272
try {
7373
if (SingleAccountHelper.getCurrentSingleSignOnAccount(this) == null) {
74-
throw new NoCurrentAccountSelectedException();
74+
throw new NoCurrentAccountSelectedException(this);
7575
}
7676
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
7777
Toast.makeText(this, R.string.no_account_configured_yet, Toast.LENGTH_LONG).show();
@@ -397,17 +397,10 @@ public void onNoteUpdated(Note note) {
397397
@Override
398398
public void changeMode(@NonNull Mode mode, boolean reloadNote) {
399399
switch (mode) {
400-
case EDIT:
401-
launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_edit), reloadNote);
402-
break;
403-
case PREVIEW:
404-
launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_preview), reloadNote);
405-
break;
406-
case DIRECT_EDIT:
407-
launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_direct_edit), reloadNote);
408-
break;
409-
default:
410-
throw new IllegalStateException("Unknown mode: " + mode);
400+
case EDIT -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_edit), reloadNote);
401+
case PREVIEW -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_preview), reloadNote);
402+
case DIRECT_EDIT -> launchExistingNote(getAccountId(), getNoteId(), getString(R.string.pref_value_mode_direct_edit), reloadNote);
403+
default -> throw new IllegalStateException("Unknown mode: " + mode);
411404
}
412405
}
413406

app/src/main/java/it/niedermann/owncloud/notes/edit/SearchableBaseNoteFragment.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import androidx.annotation.NonNull;
1515
import androidx.annotation.Nullable;
1616
import androidx.appcompat.widget.SearchView;
17+
import androidx.core.content.ContextCompat;
1718

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

4849
@Override
4950
public void onStart() {
50-
this.color = getResources().getColor(R.color.defaultBrand);
51+
this.color = ContextCompat.getColor(
52+
requireContext(), R.color.defaultBrand);
5153
super.onStart();
5254
}
5355

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

118120
searchMenuItem.collapseActionView();
119121

120-
final var searchEditFrame = searchView.findViewById(R.id
121-
.search_edit_frame);
122+
final var searchEditFrame = searchView.findViewById(
123+
androidx.appcompat.R.id.search_edit_frame);
122124

123125
searchEditFrame.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
124126
int oldVisibility = -1;

app/src/main/java/it/niedermann/owncloud/notes/edit/category/CategoryAdapter.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import java.util.ArrayList;
1818
import java.util.List;
19+
import java.util.Objects;
1920

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

5253
switch (category.id) {
53-
case addItemId:
54-
final var wrapDrawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, category.icon));
54+
case addItemId -> {
55+
final var wrapDrawable = DrawableCompat.wrap(
56+
Objects.requireNonNull(ContextCompat.getDrawable(
57+
context, category.icon)));
5558
DrawableCompat.setTint(wrapDrawable, ContextCompat.getColor(context, R.color.icon_color_default));
5659
categoryViewHolder.getIcon().setImageDrawable(wrapDrawable);
5760
categoryViewHolder.getCategoryWrapper().setOnClickListener((v) -> listener.onCategoryAdded());
58-
break;
59-
case clearItemId:
61+
}
62+
case clearItemId -> {
6063
categoryViewHolder.getIcon().setImageDrawable(ContextCompat.getDrawable(context, category.icon));
6164
categoryViewHolder.getCategoryWrapper().setOnClickListener((v) -> listener.onCategoryCleared());
62-
break;
63-
default:
65+
}
66+
default -> {
6467
categoryViewHolder.getIcon().setImageDrawable(ContextCompat.getDrawable(context, category.icon));
6568
categoryViewHolder.getCategoryWrapper().setOnClickListener((v) -> listener.onCategoryChosen(category.label));
66-
break;
69+
}
6770
}
6871
categoryViewHolder.getCategory().setText(NoteUtil.extendCategory(category.label));
6972
if (category.count != null && category.count > 0) {

0 commit comments

Comments
 (0)