Browse Source

Fixed search bug and deleteTab bug

master
Anthony Restaino 11 years ago
parent
commit
77097041dd
  1. 35
      src/acr/browser/lightning/BrowserActivity.java

35
src/acr/browser/lightning/BrowserActivity.java

@ -19,8 +19,11 @@ import java.net.URISyntaxException; @@ -19,8 +19,11 @@ import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
@ -837,12 +840,17 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -837,12 +840,17 @@ public class BrowserActivity extends Activity implements BrowserController {
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
Collections.sort(mBookmarkList);
Collections.sort(mBookmarkList, new SortIgnoreCase());
notifyBookmarkDataSetChanged();
if (mCurrentView != null) {
if (mCurrentView.getUrl().startsWith(Constants.FILE)
&& mCurrentView.getUrl().endsWith("bookmarks.html")) {
openBookmarkPage(mCurrentView.getWebView());
}
}
}
});
homePicker.show();
}
/**
@ -1214,7 +1222,7 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1214,7 +1222,7 @@ public class BrowserActivity extends Activity implements BrowserController {
if (isSearch) {
try {
URLEncoder.encode(query, "UTF-8");
query = URLEncoder.encode(query, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
@ -1334,10 +1342,9 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1334,10 +1342,9 @@ public class BrowserActivity extends Activity implements BrowserController {
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView;
LightningViewHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity) context)
.getLayoutInflater();
@ -1357,8 +1364,7 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1357,8 +1364,7 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override
public void onClick(View view) {
Integer index = (Integer) view.getTag();
deleteTab(index);
deleteTab(position);
}
});
@ -1712,7 +1718,7 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1712,7 +1718,7 @@ public class BrowserActivity extends Activity implements BrowserController {
} catch (FileNotFoundException ignored) {
} catch (IOException ignored) {
}
Collections.sort(bookmarks);
Collections.sort(bookmarks, new SortIgnoreCase());
return bookmarks;
}
@ -1839,7 +1845,7 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1839,7 +1845,7 @@ public class BrowserActivity extends Activity implements BrowserController {
bookWriter.close();
urlWriter.close();
mBookmarkList.add(bookmark);
Collections.sort(mBookmarkList);
Collections.sort(mBookmarkList, new SortIgnoreCase());
notifyBookmarkDataSetChanged();
} catch (FileNotFoundException ignored) {
} catch (IOException ignored) {
@ -2385,4 +2391,13 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -2385,4 +2391,13 @@ public class BrowserActivity extends Activity implements BrowserController {
}
}
}
public class SortIgnoreCase implements Comparator<HistoryItem> {
public int compare(HistoryItem o1, HistoryItem o2) {
return o1.getTitle().toLowerCase(Locale.getDefault()).compareTo(
o2.getTitle().toLowerCase(Locale.getDefault()));
}
}
}

Loading…
Cancel
Save