Skip to content

Commit

Permalink
Various search fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mario committed Mar 5, 2017
1 parent 20bb144 commit cfe8d3c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.owncloud.android"
android:versionCode="10040203"
android:versionName="1.4.2 RC3">
android:versionCode="10040204"
android:versionName="1.4.2 RC4">

<uses-sdk
android:minSdkVersion="14"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected void onResume() {
Log_OC.e(TAG, "onResume() start");

// refresh list of files
refreshListOfFilesFragment();
refreshListOfFilesFragment(false);

// Listen for sync messages
IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
Expand Down Expand Up @@ -309,10 +309,10 @@ protected OCFile getCurrentFolder() {
return null;
}

protected void refreshListOfFilesFragment() {
public void refreshListOfFilesFragment(boolean fromSearch) {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
fileListFragment.listDirectory(false, false);
fileListFragment.listDirectory(false, fromSearch);
}
}

Expand Down Expand Up @@ -405,7 +405,7 @@ private void onCreateFolderOperationFinish(
) {

if (result.isSuccess()) {
refreshListOfFilesFragment();
refreshListOfFilesFragment(false);
} else {
try {
Toast msg = Toast.makeText(FolderPickerActivity.this,
Expand Down
35 changes: 25 additions & 10 deletions src/com/owncloud/android/ui/fragment/ExtendedListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.ExtendedListView;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.FolderPickerActivity;
import com.owncloud.android.ui.activity.FolderSyncActivity;
import com.owncloud.android.ui.activity.OnEnforceableRefreshListener;
import com.owncloud.android.ui.activity.UploadFilesActivity;
import com.owncloud.android.ui.adapter.FileListListAdapter;
import com.owncloud.android.ui.adapter.LocalFileListAdapter;

Expand Down Expand Up @@ -171,12 +174,19 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
final Handler handler = new Handler();

DisplayMetrics displaymetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int width = displaymetrics.widthPixels;
if (getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE) {
searchView.setMaxWidth((int)(width * 0.4));
} else {
searchView.setMaxWidth((int)(width * 0.7));
Activity activity;
if ((activity = getActivity()) != null) {
activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int width = displaymetrics.widthPixels;
if (getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE) {
searchView.setMaxWidth((int) (width * 0.4));
} else {
if (activity instanceof FolderPickerActivity) {
searchView.setMaxWidth((int) (width * 0.8));
} else {
searchView.setMaxWidth((int) (width * 0.7));
}
}
}

searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
Expand All @@ -189,7 +199,9 @@ public void onFocusChange(View v, final boolean hasFocus) {
handler.postDelayed(new Runnable() {
@Override
public void run() {
setFabEnabled(!hasFocus);
if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)) {
setFabEnabled(!hasFocus);
}
}
}, 100);
}
Expand Down Expand Up @@ -273,9 +285,11 @@ public void run() {
if ((activity = getActivity()) != null) {
if (activity instanceof FileDisplayActivity) {
((FileDisplayActivity) activity).refreshListOfFilesFragment(true);
} else {
} else if (activity instanceof UploadFilesActivity){
LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) mAdapter;
localFileListAdapter.filter(query);
} else if (activity instanceof FolderPickerActivity) {
((FolderPickerActivity)activity).refreshListOfFilesFragment(true);
}

}
Expand Down Expand Up @@ -469,8 +483,9 @@ public void onRefresh() {
if (searchView != null) {
searchView.onActionViewCollapsed();

if (getActivity() != null) {
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) getActivity();
Activity activity;
if ((activity = getActivity()) != null && activity instanceof FileDisplayActivity) {
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) activity;
fileDisplayActivity.setDrawerIndicatorEnabled(fileDisplayActivity.isDrawerIndicatorAvailable());
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/com/owncloud/android/ui/fragment/OCFileListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
package com.owncloud.android.ui.fragment;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
Expand Down Expand Up @@ -795,8 +796,9 @@ public void listDirectory(OCFile directory, boolean onlyOnDevice, boolean fromSe
public void run() {
searchView.setQuery("", false);
searchView.onActionViewCollapsed();
if (getActivity() != null) {
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) getActivity();
Activity activity;
if ((activity = getActivity()) != null && activity instanceof FileDisplayActivity) {
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) activity;
if (getCurrentFile() != null) {
fileDisplayActivity.setDrawerIndicatorEnabled(fileDisplayActivity.isRoot(getCurrentFile()));
}
Expand Down

0 comments on commit cfe8d3c

Please sign in to comment.