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

Update M3 library, Increase target sdk to 34 #12106

Merged
merged 4 commits into from
Nov 17, 2023
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
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ android {

defaultConfig {
minSdkVersion 24
targetSdkVersion 33
compileSdk 33
targetSdkVersion 34
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for latest M3 library

compileSdk 34

buildConfigField 'boolean', 'CI', ciBuild.toString()
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
Expand Down Expand Up @@ -246,7 +246,7 @@ dependencies {
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5' // remove after entire switch to lib v2
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation "androidx.appcompat:appcompat:$appCompatVersion"
implementation 'androidx.webkit:webkit:1.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ActivitiesActivityIT : AbstractIT() {
sut.dismissSnackbar()
}

shortSleep()
longSleep()
waitForIdleSync()

screenshot(sut)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import javax.inject.Inject;

import androidx.activity.OnBackPressedCallback;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
Expand Down Expand Up @@ -115,6 +116,8 @@ protected void onCreate(Bundle savedInstanceState) {
}
transaction.commit();
}

getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);
}

@Override
Expand All @@ -137,12 +140,14 @@ public void onTransferStateChanged(OCFile file, boolean downloading, boolean upl
// not needed
}

@Override
public void onBackPressed() {
if (getSupportFragmentManager().findFragmentByTag(BackupListFragment.TAG) != null) {
getSupportFragmentManager().popBackStack(BACKUP_TO_LIST, FragmentManager.POP_BACK_STACK_INCLUSIVE);
} else {
finish();
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (getSupportFragmentManager().findFragmentByTag(BackupListFragment.TAG) != null) {
getSupportFragmentManager().popBackStack(BACKUP_TO_LIST, FragmentManager.POP_BACK_STACK_INCLUSIVE);
} else {
finish();
}
}
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import android.view.ActionMode
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.google.android.material.button.MaterialButton
import com.nextcloud.client.di.Injectable
Expand Down Expand Up @@ -125,9 +126,33 @@ open class FolderPickerActivity :

// sets message for empty list of folders
setBackgroundText()

handleOnBackPressed()

Log_OC.d(TAG, "onCreate() end")
}

private fun handleOnBackPressed() {
onBackPressedDispatcher.addCallback(
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
val listOfFiles = listOfFilesFragment
if (listOfFiles != null) {
// should never be null, indeed
val levelsUp = listOfFiles.onBrowseUp()
if (levelsUp == 0) {
finish()
return
}
file = listOfFiles.currentFile
updateUiElements()
}
}
}
)
}

override fun onActionModeStarted(mode: ActionMode) {
super.onActionModeStarted(mode)
if (account != null) {
Expand Down Expand Up @@ -321,20 +346,6 @@ open class FolderPickerActivity :
}
}

override fun onBackPressed() {
val listOfFiles = listOfFilesFragment
if (listOfFiles != null) {
// should never be null, indeed
val levelsUp = listOfFiles.onBrowseUp()
if (levelsUp == 0) {
finish()
return
}
file = listOfFiles.currentFile
updateUiElements()
}
}

private fun updateUiElements() {
toggleChooseEnabled()
updateNavigationElementsInActionBar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

import javax.inject.Inject;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.ActionBar;
Expand Down Expand Up @@ -258,6 +259,8 @@ public void onNothingSelected(AdapterView<?> parent) {

checkWritableFolder(mCurrentDir);

getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);

Log_OC.d(TAG, "onCreate() end");
}

Expand Down Expand Up @@ -369,43 +372,45 @@ private boolean isSearchOpen() {
}
}

@Override
public void onBackPressed() {
if (isSearchOpen() && mSearchView != null) {
mSearchView.setQuery("", false);
mFileListFragment.onClose();
mSearchView.onActionViewCollapsed();
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
} else {
if (mDirectories.getCount() <= SINGLE_DIR) {
finish();
return;
}
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (isSearchOpen() && mSearchView != null) {
mSearchView.setQuery("", false);
mFileListFragment.onClose();
mSearchView.onActionViewCollapsed();
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
} else {
if (mDirectories.getCount() <= SINGLE_DIR) {
finish();
return;
}

File parentFolder = mCurrentDir.getParentFile();
if (!parentFolder.canRead()) {
checkLocalStoragePathPickerPermission();
return;
}
File parentFolder = mCurrentDir.getParentFile();
if (!parentFolder.canRead()) {
checkLocalStoragePathPickerPermission();
return;
}

popDirname();
mFileListFragment.onNavigateUp();
mCurrentDir = mFileListFragment.getCurrentDirectory();
checkWritableFolder(mCurrentDir);
popDirname();
mFileListFragment.onNavigateUp();
mCurrentDir = mFileListFragment.getCurrentDirectory();
checkWritableFolder(mCurrentDir);

if (mCurrentDir.getParentFile() == null) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
if (mCurrentDir.getParentFile() == null) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
}
}
}

// invalidate checked state when navigating directories
if (!mLocalFolderPickerMode) {
setSelectAllMenuItem(mOptionsMenu.findItem(R.id.action_select_all), false);
// invalidate checked state when navigating directories
if (!mLocalFolderPickerMode) {
setSelectAllMenuItem(mOptionsMenu.findItem(R.id.action_select_all), false);
}
}
}
}
};

@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class LocalConnectionTest {

// THEN
// no binding is performed
verify(exactly = 0) { context.bindService(any(), any(), any()) }
verify(exactly = 0) { context.bindService(any(), any(), Context.BIND_AUTO_CREATE) }
}

@Test
Expand All @@ -76,12 +76,12 @@ class LocalConnectionTest {

// WHEN
// bind requested
every { context.bindService(mockIntent, any(), any()) } returns true
every { context.bindService(mockIntent!!, any(), Context.BIND_AUTO_CREATE) } returns true
connection.bind()

// THEN
// service bound
verify { context.bindService(mockIntent, any(), any()) }
verify { context.bindService(mockIntent!!, any(), Context.BIND_AUTO_CREATE) }
}

@Test
Expand Down
Loading