Compare commits

...
1 Commits
Author SHA1 Message Date
Andy Scherzinger 1c9d100b04 add scrollable header interface
Signed-off-by: Andy Scherzinger <[email protected]>
2020-08-14 09:21:45 +02:00
4 changed files with 32 additions and 11 deletions

No files matched your search

@@ -49,6 +49,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar;
import com.nextcloud.client.account.User;
import com.nextcloud.client.appinfo.AppInfo;
@@ -144,7 +145,7 @@ import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
*/
public class FileDisplayActivity extends FileActivity
implements FileFragment.ContainerActivity,
implements FileFragment.ScrollableHeaderContainerActivity,
OnEnforceableRefreshListener, SortingOrderDialogFragment.OnSortingOrderListener,
SendShareDialog.SendShareDialogDownloader, Injectable {
@@ -1194,6 +1195,15 @@ public class FileDisplayActivity extends FileActivity
startDownloadForSending(file, OCFileListFragment.DOWNLOAD_SEND, packageName, activityName);
}
@Override
public void resetHeaderScrollingState() {
AppBarLayout appBarLayout = findViewById(R.id.appbar);
if (appBarLayout != null) {
appBarLayout.setExpanded(true);
}
}
private class SyncBroadcastReceiver extends BroadcastReceiver {
/**
@@ -36,6 +36,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.preferences.AppPreferences;
@@ -68,7 +69,7 @@ import androidx.appcompat.app.ActionBar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
public class FolderPickerActivity extends FileActivity implements FileFragment.ContainerActivity,
public class FolderPickerActivity extends FileActivity implements FileFragment.ScrollableHeaderContainerActivity,
OnClickListener,
OnEnforceableRefreshListener,
Injectable,
@@ -468,6 +469,15 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
}
}
@Override
public void resetHeaderScrollingState() {
AppBarLayout appBarLayout = findViewById(R.id.appbar);
if (appBarLayout != null) {
appBarLayout.setExpanded(true);
}
}
private class SyncBroadcastReceiver extends BroadcastReceiver {
/**
@@ -174,4 +174,11 @@ public class FileFragment extends Fragment {
void showSortListGroup(boolean show);
}
/**
* Allow resetting the header scrolling state for activities.
*/
public interface ScrollableHeaderContainerActivity extends ContainerActivity {
void resetHeaderScrollingState();
}
}
@@ -177,7 +177,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
@Inject AppPreferences preferences;
@Inject UserAccountManager accountManager;
@Inject ClientFactory clientFactory;
protected FileFragment.ContainerActivity mContainerActivity;
protected FileFragment.ScrollableHeaderContainerActivity mContainerActivity;
protected OCFile mFile;
protected OCFileListAdapter mAdapter;
@@ -249,7 +249,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
super.onAttach(context);
Log_OC.i(TAG, "onAttach");
try {
mContainerActivity = (FileFragment.ContainerActivity) context;
mContainerActivity = (FileFragment.ScrollableHeaderContainerActivity) context;
} catch (ClassCastException e) {
throw new IllegalArgumentException(context.toString() + " must implement " +
@@ -1865,12 +1865,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
}
private void resetHeaderScrollingState() {
if (requireActivity() instanceof FileDisplayActivity) {
AppBarLayout appBarLayout = ((FileDisplayActivity) requireActivity()).findViewById(R.id.appbar);
if (appBarLayout != null) {
appBarLayout.setExpanded(true);
}
}
mContainerActivity.resetHeaderScrollingState();
}
}