Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
updated maven plugin version, added capability to open document viewe…
Browse files Browse the repository at this point in the history
…rs from search interface
  • Loading branch information
Benjamin Winger committed May 20, 2015
1 parent 4e1487b commit eadf934
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
5 changes: 3 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package="ca.dracode.ais"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="0.7.0">
android:versionName="0.7.1">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
Expand All @@ -43,7 +43,8 @@
<activity
android:name=".ui.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
android:launchMode="singleTop"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.dracode</groupId>
<artifactId>ais</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>
<packaging>apk</packaging>
<name>AndroidIndexingService</name>
<dependencies>
Expand Down Expand Up @@ -67,7 +67,7 @@
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<version>3.9.0-rc.3</version>
<extensions>true</extensions>
</plugin>
</plugins>
Expand Down
37 changes: 36 additions & 1 deletion src/ca/dracode/ais/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@
import android.app.SearchManager;
import android.content.Intent;
import android.database.DataSetObserver;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.MimeTypeMap;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.TextView;
import android.widget.Toast;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
Expand All @@ -60,6 +63,38 @@ public void onCreate(Bundle savedInstanceState) {
this.resultView = (ExpandableListView)this.findViewById(R.id.list);
this.result = new SearchResult();
this.resultView.setAdapter(la);
this.resultView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView expandableListView, View view,
int groupPosition, int childPosition, long id) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
LinkedHashMap<Integer, List<String>> data = result.getResultAtIndex(groupPosition);
int page = data.keySet().toArray(new Integer[0])[childPosition];
String term = ((List<String>)data.values().toArray()[childPosition]).get(0);
term = term.substring(term.indexOf("<B>"), term.lastIndexOf("</B>"));
term = term.replace("<B>", "").replace("</B>", "");
File f = new File(result.getFileNames().toArray(new String[0])[groupPosition]);
if(f.getName().contains(".")) {
String extension = "";

int i = f.getName().lastIndexOf('.');
if (i > 0) {
extension = f.getName().substring(i+1);
}
String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
intent.setDataAndType(Uri.fromFile(f), mime);
intent.putExtra("page", page); // makes sure that the search goes forwards
Log.i(TAG, "Requesting launch of " + f.getName() + " at page " + page + " " +
"highlighting " + term);
intent.putExtra("search", term);
startActivity(intent);
} else {
return false;
}
return true;
}
});
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
this.handleIntent(getIntent());
}
Expand Down Expand Up @@ -230,7 +265,7 @@ public View getChildView(int i, int i2, boolean b, View view, ViewGroup viewGrou
view = getLayoutInflater().inflate(R.layout.result_page, null);
}
TextView page = (TextView)view.findViewById(R.id.pagenum);
page.setText(child.getKey() + " ");
page.setText((child.getKey() + 1) + " ");
TextView text = (TextView)view.findViewById(R.id.text);
StringBuilder sb = new StringBuilder();
for(String s : child.getValue()){
Expand Down

0 comments on commit eadf934

Please sign in to comment.