Browse Source

Merge pull request #154 from DF1E/add-searchbar

master
Anthony Restaino 10 years ago
parent
commit
f06170ebfd
  1. BIN
      res/drawable-hdpi/ic_action_collapse.png
  2. BIN
      res/drawable-hdpi/ic_action_expand.png
  3. BIN
      res/drawable-hdpi/ic_action_incognito.png
  4. BIN
      res/drawable-hdpi/ic_stat_download.png
  5. BIN
      res/drawable-xhdpi/ic_action_collapse.png
  6. BIN
      res/drawable-xhdpi/ic_action_expand.png
  7. BIN
      res/drawable-xhdpi/ic_action_incognito.png
  8. BIN
      res/drawable-xhdpi/ic_stat_download.png
  9. BIN
      res/drawable-xxhdpi/ic_action_collapse.png
  10. BIN
      res/drawable-xxhdpi/ic_action_expand.png
  11. 15
      res/layout/activity_main.xml
  12. 68
      res/layout/search_interface.xml
  13. 22
      res/values-de/strings.xml
  14. 1
      res/values/dimens.xml
  15. 46
      src/acr/browser/lightning/BookmarkActivity.java
  16. 57
      src/acr/browser/lightning/BrowserActivity.java
  17. 29
      src/acr/browser/lightning/SettingsController.java

BIN
res/drawable-hdpi/ic_action_collapse.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

BIN
res/drawable-hdpi/ic_action_expand.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

BIN
res/drawable-hdpi/ic_action_incognito.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

BIN
res/drawable-hdpi/ic_stat_download.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

BIN
res/drawable-xhdpi/ic_action_collapse.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

BIN
res/drawable-xhdpi/ic_action_expand.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

BIN
res/drawable-xhdpi/ic_action_incognito.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B

BIN
res/drawable-xhdpi/ic_stat_download.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 B

BIN
res/drawable-xxhdpi/ic_action_collapse.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

BIN
res/drawable-xxhdpi/ic_action_expand.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

15
res/layout/activity_main.xml

@ -29,10 +29,19 @@ @@ -29,10 +29,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<include layout="@layout/search_interface" />
</LinearLayout>
<RelativeLayout
android:id="@+id/left_drawer"

68
res/layout/search_interface.xml

@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/search_bar_height"
android:background="@color/white"
android:visibility="gone">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="center_vertical"
android:background="?android:attr/dividerVertical" />
<TextView
android:id="@+id/search_query"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="@color/black"
android:layout_alignParentLeft="true"
android:paddingLeft="10dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:textSize="22sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:orientation="horizontal">
<ImageButton
android:id="@+id/button_next"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="@null"
android:src="@drawable/ic_action_collapse"
style="?android:attr/buttonBarButtonStyle" />
<View
android:layout_width="1dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:background="?android:attr/dividerVertical" />
<ImageButton
android:id="@+id/button_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="@null"
android:src="@drawable/ic_action_expand"
style="?android:attr/buttonBarButtonStyle" />
<View
android:layout_width="1dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:background="?android:attr/dividerVertical" />
<ImageButton
android:id="@+id/button_quit"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="@null"
android:src="@drawable/ic_action_delete"
style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>
</RelativeLayout>

22
res/values-de/strings.xml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014 The Android Open Source Project
@ -168,16 +168,24 @@ @@ -168,16 +168,24 @@
<string name="folder_default">Standard</string>
<string name="folder_custom">Andere</string>
<string name="untitled">Ohne Titel</string>
<string name="mpl_license">Mozilla Public License v2.0</string>
<string name="mpl_license">Mozilla Public License v. 2.0</string>
<string name="freeware">Freeware</string>
<string name="android_open_source_project">Android Open Source Project</string>
<string name="hphosts_ad_server_list">hpHosts AdServer-List</string>
<string name="deleted_tab">Alten Reiter erneut öffnen</string>
<string name="rendering_mode">Rendermodus</string>
<string name="hphosts_ad_server_list">hpHosts Ad Server Liste</string>
<string name="deleted_tab">Alten Tab geöffnet</string>
<string name="rendering_mode">Rendering Modus</string>
<string name="name_inverted">Invertiert</string>
<string name="name_grayscale">Graustufen</string>
<string name="name_inverted_grayscale">Invertierte Graustufen</string>
<string name="name_normal">Normal</string>
<string name="sync_history">Verlauf nach Google abgleichen</string>
<string name="title_file_chooser">Datei-Browser</string>
<string name="sync_history">Verlauf mit Google synchronisieren</string>
<string name="title_file_chooser">Dateiauswahl</string>
<string name="library_netcipher">NetCipher</string>
<string name="license_gnu">GNU Lesser General Public License</string>
<string name="export_bookmarks">Exportiere Backup</string>
<string name="import_backup">Importiere Backup</string>
<string name="bookmark_export_path">Lesezeichen exportiert nach</string>
<string name="bookmark_settings">Lesezeichen Einstellungen</string>
<string name="import_bookmark_error">Lesezeichen konnten nicht imprortiert werden</string>
<string name="title_chooser">Wähle Datei aus</string>
</resources>

1
res/values/dimens.xml

@ -4,5 +4,6 @@ @@ -4,5 +4,6 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="navigation_width">260dp</dimen>
<dimen name="search_bar_height">48dp</dimen>
</resources>

46
src/acr/browser/lightning/BookmarkActivity.java

@ -105,8 +105,7 @@ public class BookmarkActivity extends Activity implements OnClickListener { @@ -105,8 +105,7 @@ public class BookmarkActivity extends Activity implements OnClickListener {
mFileList = new File[0];
}
Arrays.sort(mFileList, new SortFileName());
Arrays.sort(mFileList, new SortFolders());
Arrays.sort(mFileList, new SortName());
if (mFileList == null) {
mFileNameList = new String[0];
@ -119,6 +118,26 @@ public class BookmarkActivity extends Activity implements OnClickListener { @@ -119,6 +118,26 @@ public class BookmarkActivity extends Activity implements OnClickListener {
}
}
public class SortName implements Comparator<File> {
@Override
public int compare(File a, File b) {
if (a.isDirectory() && b.isDirectory())
return a.getName().compareTo(b.getName());
if (a.isDirectory())
return -1;
if (b.isDirectory())
return 1;
if (a.isFile() && b.isFile())
return a.getName().compareTo(b.getName());
else
return 1;
}
}
protected Dialog onCreateDialog(int id) {
Dialog dialog = null;
final AlertDialog.Builder builder = new Builder(this);
@ -149,27 +168,4 @@ public class BookmarkActivity extends Activity implements OnClickListener { @@ -149,27 +168,4 @@ public class BookmarkActivity extends Activity implements OnClickListener {
dialog = builder.show();
return dialog;
}
public class SortFileName implements Comparator<File> {
@Override
public int compare(File f1, File f2) {
return f1.getName().compareTo(f2.getName());
}
}
public class SortFolders implements Comparator<File> {
@Override
public int compare(File f1, File f2) {
if (f1.isDirectory() == f2.isDirectory())
return 0;
else if (f1.isDirectory() && !f2.isDirectory())
return -1;
else
return 1;
}
}
}

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

@ -74,7 +74,6 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -74,7 +74,6 @@ public class BrowserActivity extends Activity implements BrowserController {
private RelativeLayout mNewTab;
private ActionBarDrawerToggle mDrawerToggle;
private List<LightningView> mWebViews = new ArrayList<LightningView>();
private List<Integer> mIdList = new ArrayList<Integer>();
private LightningView mCurrentView;
private int mIdGenerator;
private LightningViewAdapter mTitleAdapter;
@ -135,11 +134,6 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -135,11 +134,6 @@ public class BrowserActivity extends Activity implements BrowserController {
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mEditPrefs = mPreferences.edit();
mContext = this;
if (mIdList != null) {
mIdList.clear();
} else {
mIdList = new ArrayList<Integer>();
}
if (mWebViews != null) {
mWebViews.clear();
} else {
@ -764,15 +758,50 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -764,15 +758,50 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = getHome.getText().toString();
if (mCurrentView != null) {
mCurrentView.find(text);
}
String query = getHome.getText().toString();
if (query.length() > 0)
showSearchInterfaceBar(query);
}
});
finder.show();
}
private void showSearchInterfaceBar(String text) {
if (mCurrentView != null) {
mCurrentView.find(text);
}
final RelativeLayout bar = (RelativeLayout) findViewById(R.id.search_bar);
bar.setVisibility(View.VISIBLE);
TextView tw = (TextView) findViewById(R.id.search_query);
tw.setText("'" + text + "'");
ImageButton up = (ImageButton) findViewById(R.id.button_next);
up.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCurrentView.getWebView().findNext(true);
}
});
ImageButton down = (ImageButton) findViewById(R.id.button_back);
down.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCurrentView.getWebView().findNext(false);
}
});
ImageButton quit = (ImageButton) findViewById(R.id.button_quit);
quit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCurrentView.getWebView().clearMatches();
bar.setVisibility(View.GONE);
}
});
}
/**
* The click listener for ListView in the navigation drawer
*/
@ -1022,7 +1051,6 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1022,7 +1051,6 @@ public class BrowserActivity extends Activity implements BrowserController {
if (mIdGenerator == 0) {
startingTab.resumeTimers();
}
mIdList.add(mIdGenerator);
mIdGenerator++;
mWebViews.add(startingTab);
@ -1050,12 +1078,10 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1050,12 +1078,10 @@ public class BrowserActivity extends Activity implements BrowserController {
}
boolean isShown = reference.isShown();
if (current > position) {
mIdList.remove(position);
mWebViews.remove(position);
mDrawerListLeft.setItemChecked(current - 1, true);
reference.onDestroy();
} else if (mWebViews.size() > position + 1) {
mIdList.remove(position);
if (current == position) {
showTab(mWebViews.get(position + 1));
mWebViews.remove(position);
@ -1066,7 +1092,6 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1066,7 +1092,6 @@ public class BrowserActivity extends Activity implements BrowserController {
reference.onDestroy();
} else if (mWebViews.size() > 1) {
mIdList.remove(position);
if (current == position) {
showTab(mWebViews.get(position - 1));
mWebViews.remove(position);
@ -1081,7 +1106,6 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1081,7 +1106,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|| mCurrentView.getUrl().equals(mHomepage)) {
closeActivity();
} else {
mIdList.remove(position);
mWebViews.remove(position);
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, false)
&& mCurrentView != null && !isIncognito()) {
@ -1173,7 +1197,6 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1173,7 +1197,6 @@ public class BrowserActivity extends Activity implements BrowserController {
} catch (NullPointerException ignored) {
}
}
SettingsController.setClearHistory(true);
Utils.trimCache(this);
}
@ -1255,8 +1278,6 @@ public class BrowserActivity extends Activity implements BrowserController { @@ -1255,8 +1278,6 @@ public class BrowserActivity extends Activity implements BrowserController {
protected void onResume() {
super.onResume();
Log.i(Constants.TAG, "onResume");
if (SettingsController.getClearHistory()) {
}
if (mSearchAdapter != null) {
mSearchAdapter.refreshPreferences();
mSearchAdapter.refreshBookmarks();

29
src/acr/browser/lightning/SettingsController.java

@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
/*
* Copyright 2014 A.C.R. Development
*/
package acr.browser.lightning;
public class SettingsController {
private static boolean clearHistory;
/**
* The purpose of this class is so that I can clear the dropdown history in
* the main activities if the user selects to clear the history from the
* disk in advanced settings
*/
public static void setClearHistory(boolean choice) {
clearHistory = choice;
}
/**
* return the choice
*/
public static boolean getClearHistory() {
if (clearHistory) {
clearHistory = false;
return true;
}
return false;
}
}
Loading…
Cancel
Save