Simplified History Logging
This commit is contained in:
parent
c270d39639
commit
448c168513
@ -701,7 +701,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void clearHistory() {
|
||||
deleteDatabase(DatabaseHandler.DATABASE_NAME);
|
||||
deleteDatabase(HistoryDatabaseHandler.DATABASE_NAME);
|
||||
WebViewDatabase m = WebViewDatabase.getInstance(this);
|
||||
m.clearFormData();
|
||||
m.clearHttpAuthUsernamePassword();
|
||||
|
@ -14,8 +14,6 @@ import android.content.res.Configuration;
|
||||
import android.content.res.Resources.Theme;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
import android.database.DatabaseUtils;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
@ -99,8 +97,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
private Bitmap mDefaultVideoPoster;
|
||||
private View mVideoProgressView;
|
||||
private DatabaseHandler mHistoryHandler;
|
||||
private SQLiteDatabase mHistoryDatabase;
|
||||
private HistoryDatabaseHandler mHistoryHandler;
|
||||
private SharedPreferences mPreferences;
|
||||
private SharedPreferences.Editor mEditPrefs;
|
||||
private Context mContext;
|
||||
@ -189,11 +186,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
mDrawerListRight.setOnItemLongClickListener(new BookmarkItemLongClickListener());
|
||||
|
||||
if (mHistoryHandler == null) {
|
||||
mHistoryHandler = new DatabaseHandler(this);
|
||||
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||
} else if (!mHistoryHandler.isOpen()) {
|
||||
mHistoryHandler = new DatabaseHandler(this);
|
||||
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||
}
|
||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
||||
|
||||
// set display options of the ActionBar
|
||||
mActionBar.setDisplayShowTitleEnabled(false);
|
||||
@ -412,7 +408,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
|
||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
|
||||
initializePreferences();
|
||||
initializeTabs();
|
||||
|
||||
@ -1166,7 +1162,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void clearHistory() {
|
||||
this.deleteDatabase(DatabaseHandler.DATABASE_NAME);
|
||||
this.deleteDatabase(HistoryDatabaseHandler.DATABASE_NAME);
|
||||
WebViewDatabase m = WebViewDatabase.getInstance(this);
|
||||
m.clearFormData();
|
||||
m.clearHttpAuthUsernamePassword();
|
||||
@ -1226,11 +1222,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
mCurrentView.pauseTimers();
|
||||
mCurrentView.onPause();
|
||||
}
|
||||
if (mHistoryDatabase != null) {
|
||||
if (mHistoryDatabase.isOpen()) {
|
||||
mHistoryDatabase.close();
|
||||
}
|
||||
}
|
||||
if (mHistoryHandler != null) {
|
||||
if (mHistoryHandler.isOpen()) {
|
||||
mHistoryHandler.close();
|
||||
@ -1255,11 +1246,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Log.i(Constants.TAG, "onDestroy");
|
||||
if (mHistoryDatabase != null) {
|
||||
if (mHistoryDatabase.isOpen()) {
|
||||
mHistoryDatabase.close();
|
||||
}
|
||||
}
|
||||
if (mHistoryHandler != null) {
|
||||
if (mHistoryHandler.isOpen()) {
|
||||
mHistoryHandler.close();
|
||||
@ -1288,11 +1274,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
mCurrentView.onResume();
|
||||
|
||||
if (mHistoryHandler == null) {
|
||||
mHistoryHandler = new DatabaseHandler(this);
|
||||
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||
} else if (!mHistoryHandler.isOpen()) {
|
||||
mHistoryHandler = new DatabaseHandler(this);
|
||||
mHistoryHandler = new HistoryDatabaseHandler(this);
|
||||
}
|
||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
||||
mBookmarkList = getBookmarks();
|
||||
notifyBookmarkDataSetChanged();
|
||||
} else {
|
||||
@ -1742,31 +1727,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
}
|
||||
}
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder("url" + " = ");
|
||||
DatabaseUtils.appendEscapedSQLString(sb, url);
|
||||
|
||||
if (mHistoryHandler == null) {
|
||||
mHistoryHandler = new DatabaseHandler(mContext);
|
||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
||||
} else if (!mHistoryHandler.isOpen()) {
|
||||
mHistoryHandler = new DatabaseHandler(mContext);
|
||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
||||
} else if (mHistoryDatabase == null) {
|
||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
||||
} else if (!mHistoryDatabase.isOpen()) {
|
||||
mHistoryDatabase = mHistoryHandler.getReadableDatabase();
|
||||
if (mHistoryHandler == null && !mHistoryHandler.isOpen()) {
|
||||
mHistoryHandler = new HistoryDatabaseHandler(mContext);
|
||||
}
|
||||
Cursor cursor = mHistoryDatabase.query(DatabaseHandler.TABLE_HISTORY,
|
||||
new String[] { "id", "url", "title" }, sb.toString(), null, null, null,
|
||||
null);
|
||||
if (!cursor.moveToFirst()) {
|
||||
mHistoryHandler.addHistoryItem(new HistoryItem(url, title));
|
||||
} else {
|
||||
mHistoryHandler.delete(url);
|
||||
mHistoryHandler.addHistoryItem(new HistoryItem(url, title));
|
||||
}
|
||||
cursor.close();
|
||||
cursor = null;
|
||||
mHistoryHandler.visitHistoryItem(url, title);
|
||||
} catch (IllegalStateException e) {
|
||||
Log.e(Constants.TAG, "IllegalStateException in updateHistory");
|
||||
} catch (NullPointerException e) {
|
||||
@ -1884,7 +1848,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
||||
* returns a list of HistoryItems
|
||||
*/
|
||||
private List<HistoryItem> getLatestHistory() {
|
||||
DatabaseHandler historyHandler = new DatabaseHandler(mContext);
|
||||
HistoryDatabaseHandler historyHandler = new HistoryDatabaseHandler(mContext);
|
||||
return historyHandler.getLastHundredItems();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
public class HistoryDatabaseHandler extends SQLiteOpenHelper {
|
||||
|
||||
// All Static variables
|
||||
// Database Version
|
||||
@ -33,7 +33,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
|
||||
public static SQLiteDatabase mDatabase;
|
||||
|
||||
public DatabaseHandler(Context context) {
|
||||
public HistoryDatabaseHandler(Context context) {
|
||||
super(context.getApplicationContext(), DATABASE_NAME, null, DATABASE_VERSION);
|
||||
mDatabase = this.getWritableDatabase();
|
||||
}
|
||||
@ -83,12 +83,19 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void visitHistoryItem(String url, String title){
|
||||
mDatabase.delete(TABLE_HISTORY, KEY_URL + " = ?", new String[] { url });
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_URL, url);
|
||||
values.put(KEY_TITLE, title);
|
||||
mDatabase.insert(TABLE_HISTORY, null, values);
|
||||
}
|
||||
|
||||
// Adding new item
|
||||
public synchronized void addHistoryItem(HistoryItem item) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_URL, item.getUrl()); // HistoryItem Name
|
||||
values.put(KEY_TITLE, item.getTitle()); // HistoryItem Phone
|
||||
// Inserting Row
|
||||
values.put(KEY_URL, item.getUrl());
|
||||
values.put(KEY_TITLE, item.getTitle());
|
||||
mDatabase.insert(TABLE_HISTORY, null, values);
|
||||
}
|
||||
|
@ -9,14 +9,12 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
||||
|
||||
// private variables
|
||||
private int mId;
|
||||
|
||||
private String mUrl;
|
||||
|
||||
private String mTitle;
|
||||
|
||||
private Bitmap mBitmap;
|
||||
|
||||
private String mFolder;
|
||||
private int mImageId;
|
||||
private int mOrder;
|
||||
|
||||
// Empty constructor
|
||||
public HistoryItem() {
|
||||
@ -68,6 +66,22 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
||||
mBitmap = image;
|
||||
}
|
||||
|
||||
public void setFolder(String folder) {
|
||||
mFolder = folder;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
mOrder = order;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return mOrder;
|
||||
}
|
||||
|
||||
public String getFolder() {
|
||||
return mFolder;
|
||||
}
|
||||
|
||||
public Bitmap getBitmap() {
|
||||
return mBitmap;
|
||||
}
|
||||
|
@ -32,14 +32,14 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
private List<HistoryItem> mSuggestions;
|
||||
private List<HistoryItem> mFilteredList;
|
||||
private List<HistoryItem> mAllBookmarks;
|
||||
private DatabaseHandler mDatabaseHandler;
|
||||
private HistoryDatabaseHandler mDatabaseHandler;
|
||||
private SharedPreferences mPreferences;
|
||||
private boolean mUseGoogle = true;
|
||||
private Context mContext;
|
||||
private boolean mIncognito;
|
||||
|
||||
public SearchAdapter(Context context, boolean incognito) {
|
||||
mDatabaseHandler = new DatabaseHandler(context);
|
||||
mDatabaseHandler = new HistoryDatabaseHandler(context);
|
||||
mFilteredList = new ArrayList<HistoryItem>();
|
||||
mHistory = new ArrayList<HistoryItem>();
|
||||
mBookmarks = new ArrayList<HistoryItem>();
|
||||
@ -188,7 +188,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
}
|
||||
if (mDatabaseHandler == null || !mDatabaseHandler.isOpen()) {
|
||||
mDatabaseHandler = new DatabaseHandler(mContext);
|
||||
mDatabaseHandler = new HistoryDatabaseHandler(mContext);
|
||||
}
|
||||
mHistory = mDatabaseHandler.findItemsContaining(constraint.toString());
|
||||
for (int n = 0; n < mHistory.size(); n++) {
|
||||
|
Loading…
Reference in New Issue
Block a user