Permalink
Browse files

initial (broken) commit

  • Loading branch information...
frioux committed Oct 25, 2008
0 parents commit 195ec14de5baff408170bc2bc1fd7e9f7bbac0dc
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.lvlv.supersearch"
android:versionCode="1"
android:versionName="1.0.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".SuperSearch"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ModifySearches" android:label="@string/modify_title">
</activity>
</application>
</manifest>
BIN +3.11 KB res/drawable/icon.png
Binary file not shown.
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/search_location"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/search_hint"
android:id="@+id/search_input"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/go_label"
android:id="@+id/go_button"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/manage_label"
android:id="@+id/manage_button"
/>
</LinearLayout>
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/name_input"
android:hint="@string/name_hint"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/location_input"
android:hint="@string/location_hint"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/term_input"
android:hint="@string/term_hint"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/add_search_label"
android:id="@+id/add_search_button"
/>
</LinearLayout>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SuperSearch</string>
<string name="go_label">Go!</string>
<string name="modify_title">Manage Searches</string>
<string name="search_hint">Search Text</string>
<string name="name_hint">Search Name</string>
<string name="location_hint">Search URL</string>
<string name="term_hint">Term</string>
<string name="add_search_label">Add New Search</string>
<string name="manage_label">Manage Searches</string>
</resources>
@@ -0,0 +1,13 @@
package org.lvlv.supersearch;

import android.provider.BaseColumns;

public interface Constants extends BaseColumns {
public static final String TABLE_NAME = "searches";

//Columns
public static final String NAME = "name";
public static final String URL = "url";
public static final String TERM = "term";

}
@@ -0,0 +1,15 @@
package org.lvlv.supersearch;

import android.app.Activity;
import android.os.Bundle;

public class ModifySearches extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.modifysearches);
}



}
@@ -0,0 +1,41 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package org.lvlv.supersearch;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int add_search_button=0x7f050007;
public static final int go_button=0x7f050002;
public static final int location_input=0x7f050005;
public static final int manage_button=0x7f050003;
public static final int name_input=0x7f050004;
public static final int search_input=0x7f050001;
public static final int search_location=0x7f050000;
public static final int term_input=0x7f050006;
}
public static final class layout {
public static final int main=0x7f030000;
public static final int modifysearches=0x7f030001;
}
public static final class string {
public static final int add_search_label=0x7f040007;
public static final int app_name=0x7f040000;
public static final int go_label=0x7f040001;
public static final int location_hint=0x7f040005;
public static final int manage_label=0x7f040008;
public static final int modify_title=0x7f040002;
public static final int name_hint=0x7f040004;
public static final int search_hint=0x7f040003;
public static final int term_hint=0x7f040006;
}
}
@@ -0,0 +1,66 @@
package org.lvlv.supersearch;

import android.database.Cursor;
import android.database.sqlite.SQLiteOpenHelper;
import static android.provider.BaseColumns._ID;
import static org.lvlv.supersearch.Constants.TABLE_NAME;
import static org.lvlv.supersearch.Constants.NAME;
import static org.lvlv.supersearch.Constants.URL;
import static org.lvlv.supersearch.Constants.TERM;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;


public class SearchesData extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "searches.db";
private static final int DATABASE_VERSION = 1;

public SearchesData(Context ctx) {
super(ctx, DATABASE_NAME, null, DATABASE_VERSION );
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE "+ TABLE_NAME + " ("
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ NAME + " VARCHAR(25) NOT NULL, "
+ URL + " VARCHAR(255) NOT NULL, "
+ TERM + " VARCHAR(25) DEFAULT 'Search');"
);
prepopulate();
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}

public void prepopulate() {
addSearch("Answers.com", "http://answers.com/%s", "Search");
addSearch("Google", "http://www.google.com/#/search?q=%s", "Search");
addSearch("Merriam-Webster", "http://www.merriam-webster.com/dictionary/%s", "Word");
}

public void addSearch(String name, String url, String term) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(NAME, name);
values.put(URL, url);
values.put(TERM, term);
db.insertOrThrow(TABLE_NAME, null, values);
}

private static String[] FROM = { _ID, NAME, URL, TERM};
private static String ORDER_BY = NAME + " ASC" ;
public Cursor getSearches() {
// Perform a managed query. The Activity will handle closing
// and re-querying the cursor when needed.
SQLiteDatabase db = this .getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null,
null, ORDER_BY);
return cursor;
}

}
@@ -0,0 +1,79 @@
package org.lvlv.supersearch;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

public class SuperSearch extends Activity implements OnClickListener,OnKeyListener
{
private Button goButton;
private Button manageButton;
private EditText location;
private EditText inputText;
private SearchesData searches;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
searches = new SearchesData(this);
try {
Cursor cursor = searches.getSearches();
setupSearches(cursor);
} finally {
searches.close();
}

goButton = (Button) findViewById(R.id.go_button);
manageButton = (Button) findViewById(R.id.manage_button);
location = (EditText) findViewById(R.id.search_location);
inputText = (EditText) findViewById(R.id.search_input);

goButton.setOnClickListener(this);
manageButton.setOnClickListener(this);
location.setOnKeyListener(this);
inputText.setOnKeyListener(this);
}
private void setupSearches(Cursor cursor) {
Log.d("foo", "bar");

}
private void doSearch() {
// Uri uri = Uri.parse(location.getText().toString().replaceAll("%s", inputText.getText().toString()));
// Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// startActivity(intent);

}
public void onClick(View v) {
switch (v.getId()) {
case R.id.go_button:
doSearch();
break;
case R.id.manage_button:
Intent i = new Intent(this, ModifySearches.class);
startActivity(i);
break;
}

}

public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
doSearch();
return true;
}
return false;
}
}

0 comments on commit 195ec14

Please sign in to comment.