diff options
author | Iain Billett <Iain@Iains-MacBook-Pro.local> | 2012-06-13 21:08:21 +0100 |
---|---|---|
committer | Iain Billett <Iain@Iains-MacBook-Pro.local> | 2012-06-14 12:49:16 +0100 |
commit | 246ba71f56a06ac9d34a9292df2e018253eefafa (patch) | |
tree | 47da5b748ee07996ce4cae1daaa46b6f95e1074c /android | |
parent | 12d76ae5c01a792de07a541ba20df5f28f42c927 (diff) |
some eclipse projects with pure Android UI stuff. LO code not yet integrated.
Diffstat (limited to 'android')
50 files changed, 1307 insertions, 0 deletions
diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.classpath b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.classpath new file mode 100644 index 000000000000..a4763d1eeced --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="gen"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> + <classpathentry kind="output" path="bin/classes"/> +</classpath> diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.project b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.project new file mode 100644 index 000000000000..f3a4c444a738 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.project @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>LibreOfficeUI</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.ApkBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>com.android.ide.eclipse.adt.AndroidNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.settings/org.eclipse.jdt.core.prefs b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..416f4fb69607 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/AndroidManifest.xml b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/AndroidManifest.xml new file mode 100644 index 000000000000..82ec24c2f775 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/AndroidManifest.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.libreoffice.ui" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11"/> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> + + <application + android:icon="@drawable/lo_icon" + android:label="@string/app_name" android:theme="@android:style/Theme.Holo.Light"> + <activity + android:name=".LibreOfficeUIActivity" + 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:theme="@android:style/Theme.Holo.Light" android:name="WriterViewerActivity"> + <intent-filter android:label="writer_viewer"></intent-filter> + </activity> + </application> + +</manifest>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/proguard.cfg b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/proguard.cfg new file mode 100644 index 000000000000..b1cdf17b5bb4 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/proguard.cfg @@ -0,0 +1,40 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native <methods>; +} + +-keepclasseswithmembers class * { + public <init>(android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public <init>(android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/project.properties b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/project.properties new file mode 100644 index 000000000000..d79abae19a25 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-11 diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/action_search.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/action_search.png Binary files differnew file mode 100644 index 000000000000..e6b70451863a --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/action_search.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/base.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/base.png Binary files differnew file mode 100644 index 000000000000..729dbcd82ebf --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/base.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/calc.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/calc.png Binary files differnew file mode 100644 index 000000000000..a3f5fd4d80c0 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/calc.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/draw.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/draw.png Binary files differnew file mode 100644 index 000000000000..b3ee11426a04 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/draw.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/dummy_page.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/dummy_page.png Binary files differnew file mode 100644 index 000000000000..c58d276e7085 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/dummy_page.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/folder.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/folder.png Binary files differnew file mode 100644 index 000000000000..9c9b42c83956 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/folder.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/ic_launcher.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..8074c4c571b8 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/ic_launcher.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/impress.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/impress.png Binary files differnew file mode 100644 index 000000000000..5909f05bf089 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/impress.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/lo_icon.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/lo_icon.png Binary files differnew file mode 100644 index 000000000000..2ef86417e69e --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/lo_icon.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/main.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/main.png Binary files differnew file mode 100644 index 000000000000..7e8e2a05e2da --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/main.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/math.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/math.png Binary files differnew file mode 100644 index 000000000000..50b8dc863bff --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/math.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/startcenter.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/startcenter.png Binary files differnew file mode 100644 index 000000000000..7e8e2a05e2da --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/startcenter.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/writer.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/writer.png Binary files differnew file mode 100644 index 000000000000..2f4abcb280cd --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-hdpi/writer.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/dummy_page.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/dummy_page.png Binary files differnew file mode 100644 index 000000000000..c58d276e7085 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/dummy_page.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/ic_launcher.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..1095584ec21f --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/ic_launcher.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/lo_icon.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/lo_icon.png Binary files differnew file mode 100644 index 000000000000..95b3113b6f95 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-ldpi/lo_icon.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-mdpi/ic_launcher.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..a07c69fa5a0f --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-mdpi/ic_launcher.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-mdpi/lo_icon.png b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-mdpi/lo_icon.png Binary files differnew file mode 100644 index 000000000000..4f3f89beadc2 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/drawable-mdpi/lo_icon.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/file_explorer.xml b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/file_explorer.xml new file mode 100644 index 000000000000..1e241c00a13a --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/file_explorer.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <GridView + android:id="@+id/file_explorer_grid_view" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:columnWidth="120dp" + android:numColumns="auto_fit" + android:verticalSpacing="10dp" + android:horizontalSpacing="10dp" + android:stretchMode="columnWidth" + android:gravity="center"> + </GridView> + + +</LinearLayout>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/file_explorer_grid_item.xml b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/file_explorer_grid_item.xml new file mode 100644 index 000000000000..a53bc1b57b2b --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/file_explorer_grid_item.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <ImageView + android:id="@+id/grid_item_image" + android:layout_width="50dp" + android:layout_height="75dp" + android:paddingTop="15dp" + android:paddingBottom="10dp" + android:layout_gravity="center" > + </ImageView> + + <TextView + android:id="@+id/grid_item_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@+id/label" + android:paddingLeft="10dp" + android:paddingRight="10dp" + android:layout_gravity="center" + android:textSize="15dp" > + </TextView> + +</LinearLayout>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/main.xml b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/main.xml new file mode 100644 index 000000000000..6b97fe101177 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/layout/main.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="#aaa" + android:orientation="vertical" + > + + <org.libreoffice.ui.PageView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + /> + + +</LinearLayout>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml new file mode 100644 index 000000000000..71d04d6317b1 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/menu/view_menu.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/menu_search" + android:icon="@drawable/action_search" + android:title="@string/menu_search" + android:showAsAction="ifRoom|withText" /> +</menu>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml new file mode 100644 index 000000000000..1dfa48989749 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/res/values/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="hello">Hello World, LibreOfficeUIActivity!</string> + <string name="app_name">LibreOfficeUI</string> + <string name="menu_search">Search</string> + +</resources>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/GridItemAdapter.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/GridItemAdapter.java new file mode 100644 index 000000000000..a2cf56ab1713 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/GridItemAdapter.java @@ -0,0 +1,89 @@ +package org.libreoffice.ui; + +import java.io.File; + +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +public class GridItemAdapter extends BaseAdapter{ + Context mContext; + File[] filePaths; + File currentDirectory; + String tag = "GridItemAdapter"; + + public GridItemAdapter(Context mContext, File[] filePaths) { + this.mContext = mContext; + this.filePaths = filePaths; + for(File fn : filePaths){ + Log.d(tag, fn.getName()); + } + } + + public GridItemAdapter(Context mContext, File currentDirectory) { + this.mContext = mContext; + this.currentDirectory = currentDirectory; + filePaths = currentDirectory.listFiles(); + } + + public int getCount() { + return filePaths.length; + } + + public Object getItem(int position) { + return null;//filePaths[ position ]; + } + + public long getItemId(int arg0) { + // TODO Auto-generated method stub + return 0; + } + + public View getView(int position, View convertView, ViewGroup parent) { + LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + + View gridView; + + if (convertView == null) { + + + + } else { + gridView = (View) convertView; + } + gridView = new View(mContext); + + // get layout from mobile.xml + gridView = inflater.inflate(R.layout.file_explorer_grid_item, null); + + // set value into textview + TextView textView = (TextView) gridView + .findViewById(R.id.grid_item_label); + textView.setText(filePaths[position].getName()); + // set image based on selected text + ImageView imageView = (ImageView) gridView + .findViewById(R.id.grid_item_image); + if( filePaths[position].getName().contains(".odt") ){ + imageView.setImageResource(R.drawable.writer); + } + if( filePaths[position].getName().contains(".ods") ){ + imageView.setImageResource(R.drawable.calc); + } + if( filePaths[position].getName().contains(".odp") ){ + imageView.setImageResource(R.drawable.impress); + } + if( filePaths[position].isDirectory() ){//Is a folder + //Eventually have thumbnails of each sub file on a black circle + //For now just a folder icon + imageView.setImageResource(R.drawable.folder); + } + return gridView; + } + +} diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java new file mode 100644 index 000000000000..05ef291f040d --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -0,0 +1,206 @@ +package org.libreoffice.ui; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; + +import android.app.Activity; +import android.app.ListActivity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.Environment; +import android.support.v4.*; +import android.support.v4.app.FragmentActivity; +import android.util.Log; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.BaseAdapter; +import android.widget.GridView; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +public class LibreOfficeUIActivity extends Activity { + private String tag = "file_manager"; + private File homeDirectory;//make final? + private File currentDirectory; + private String[] fileNames; + private File[] filePaths; + + private String currentDirectoryKey = "CURRENT_DIRECTORY"; + GridView gv; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.file_explorer); + gv = (GridView)findViewById(R.id.file_explorer_grid_view); + + //Need to sort out how best to maintain application state (directory, basically) + Intent i = this.getIntent(); + if( i.hasExtra( currentDirectoryKey ) ){ + //This isn't what I think it is. It's not a full path + currentDirectory = new File( i.getStringExtra( currentDirectoryKey ) ); + } + + homeDirectory = new File(Environment.getExternalStorageDirectory(),"LibreOffice"); + currentDirectory = homeDirectory; + //createDummyFileSystem(); + filePaths = new File[ currentDirectory.listFiles().length ]; + fileNames = new String[ filePaths.length ]; + filePaths = currentDirectory.listFiles();// Need to write a class to order lists of Files + fileNames = currentDirectory.list();// should be based on filePaths -> keep same order + + // code to make a grid view + GridItemAdapter gridAdapter = new GridItemAdapter(getApplicationContext(), filePaths ); + gv.setAdapter(gridAdapter); + gv.setOnItemClickListener(new OnItemClickListener() { + public void onItemClick(AdapterView<?> parent, View view, + int position, long id) { + File file = filePaths[position]; + if(!file.isDirectory()){ + open(fileNames[position]); + }else{ + /*fileNames = file.list(); + filePaths = file.listFiles(); + GridItemAdapter gridAdapter = new GridItemAdapter(getApplicationContext(), filePaths ); + gv.setAdapter(gridAdapter);*/ + file = new File( currentDirectory, file.getName() ); + openDirectory( file ); + } + + } + }); + + + } + + public void openDirectory(File dir){ + currentDirectory = dir; + fileNames = currentDirectory.list(); + filePaths = currentDirectory.listFiles(); + gv.setAdapter( new GridItemAdapter(getApplicationContext(), currentDirectory ) ); + } + + public void open(String file){ + //Should add file to the intent as an extra + Intent i = new Intent( this , WriterViewerActivity.class ); + i.putExtra( currentDirectoryKey, currentDirectory.getName() ); + startActivity( i ); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.view_menu, menu); + return true; + } + + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + // app icon in action bar clicked; go home + Intent intent = new Intent(this, LibreOfficeUIActivity.class); + //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + if( !currentDirectory.equals( homeDirectory ) ){ + openDirectory( currentDirectory.getParentFile() ); + } + + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + public void createDummyFileSystem(){ + boolean mExternalStorageAvailable = false; + boolean mExternalStorageWriteable = false; + String state = Environment.getExternalStorageState(); + + if (Environment.MEDIA_MOUNTED.equals(state)) { + mExternalStorageAvailable = mExternalStorageWriteable = true; + } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { + mExternalStorageAvailable = true; + mExternalStorageWriteable = false; + } else { + mExternalStorageAvailable = mExternalStorageWriteable = false; + } + if( mExternalStorageAvailable && mExternalStorageWriteable ){//can also check if its writeable + Log.d(tag, Boolean.toString( currentDirectory.mkdir() ) ); + try { + File[] removeList = currentDirectory.listFiles(); + for(File item : removeList){ + if(item.isDirectory()) + continue;//Log.d(tag, item.getPath()); + item.delete(); + } + new File( currentDirectory , "d0.odp" ).createNewFile(); + new File( currentDirectory , "d1.odt" ).createNewFile(); + new File( currentDirectory , "d2.odt" ).createNewFile(); + new File( currentDirectory , "d3.odp" ).createNewFile(); + new File( currentDirectory , "d4.ods" ).createNewFile(); + new File( currentDirectory , "d5.odt" ).createNewFile(); + new File( currentDirectory , "d6.odp" ).createNewFile(); + new File( currentDirectory , "d7.odt" ).createNewFile(); + new File( currentDirectory , "d8.odt" ).createNewFile(); + new File( currentDirectory , "d9.odp" ).createNewFile(); + new File( currentDirectory , "d10.odp" ).createNewFile(); + new File( currentDirectory , "d11.odt" ).createNewFile(); + new File( currentDirectory , "d12.odt" ).createNewFile(); + new File( currentDirectory , "d13.odp" ).createNewFile(); + new File( currentDirectory , "d14.ods" ).createNewFile(); + new File( currentDirectory , "d15.odt" ).createNewFile(); + File templatesDirectory = new File( currentDirectory , "Templates" ); + templatesDirectory.mkdir(); + new File( templatesDirectory , "template1.odt" ).createNewFile(); + new File( templatesDirectory , "template2.odt" ).createNewFile(); + new File( templatesDirectory , "template3.ods" ).createNewFile(); + new File( templatesDirectory , "template4.odp" ).createNewFile(); + File regularDirectory = new File( currentDirectory , "Folder" ); + regularDirectory.mkdir(); + new File( regularDirectory , "yetAnotherDoc.odt" ).createNewFile(); + //Should put a folder in at some stage. + + } catch (IOException e) { + Log.d(tag, "file io failure"); + e.printStackTrace(); + } + //Log.d(tag, fileStore.toString()); + } + else{ + Log.d(tag, "No External Storage"); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + // TODO Auto-generated method stub + super.onSaveInstanceState(outState); + outState.putString( currentDirectoryKey , currentDirectory.getName() ); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onRestoreInstanceState(savedInstanceState); + currentDirectory = new File( savedInstanceState.getString( currentDirectoryKey ) ); + } + + @Override + protected void onPause() { + // TODO need to save fileSystem state here. + + super.onPause(); + } + +} + + diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/PageView.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/PageView.java new file mode 100644 index 000000000000..5edb6ea20926 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/PageView.java @@ -0,0 +1,63 @@ +package org.libreoffice.ui; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; + +public class PageView extends View{ + private Bitmap bmp; + private Paint mPaintBlack; + private String tag = "PageView"; + + public PageView(Context context ) { + super(context); + bmp = BitmapFactory.decodeResource(getResources(), R.drawable.dummy_page); + intialise(); + } + public PageView(Context context, AttributeSet attrs) { + super(context, attrs); + bmp = BitmapFactory.decodeResource(getResources(), R.drawable.dummy_page); + Log.d( tag , bmp.toString()); + intialise(); + } + public PageView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + bmp = BitmapFactory.decodeResource(getResources(), R.drawable.dummy_page);//load a "page" + intialise(); + } + + private void intialise(){ + mPaintBlack = new Paint(); + mPaintBlack.setARGB(255, 0, 0, 0); + Log.d(tag, " Doing some set-up"); + } + + public void setBitmap(Bitmap bmp){ + this.bmp = bmp; + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + Log.d(tag, "Draw"); + Log.d(tag, Integer.toString(bmp.getHeight())); + if( bmp != null ){ + int horizontalMargin = (int) (canvas.getWidth()*0.1); + //int verticalMargin = (int) (canvas.getHeight()*0.1); + int verticalMargin = horizontalMargin; + canvas.drawBitmap(bmp, new Rect(0, 0, bmp.getWidth(), bmp.getHeight()), + new Rect(horizontalMargin,verticalMargin,canvas.getWidth()-horizontalMargin, + canvas.getHeight()-verticalMargin), + mPaintBlack);// + } + if( bmp == null) + canvas.drawText("Bmp is null!", 100, 100, new Paint()); + } + +} diff --git a/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java new file mode 100644 index 000000000000..f56e577b141e --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/LibreOfficeUI/src/org/libreoffice/ui/WriterViewerActivity.java @@ -0,0 +1,46 @@ +package org.libreoffice.ui; + +import java.io.File; + +import android.app.ActionBar; +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Environment; +import android.util.Log; +import android.view.MenuItem; + +public class WriterViewerActivity extends Activity{ + private String currentDirectoryKey = "CURRENT_DIRECTORY"; + File file; + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + Intent i = new Intent(); + i = this.getIntent(); + if( i.hasExtra( currentDirectoryKey ) ){ + Log.d(currentDirectoryKey, i.getStringExtra( currentDirectoryKey ) ); + file = new File( i.getStringExtra( currentDirectoryKey ) ); + } + setContentView(R.layout.main); + ActionBar actionBar = getActionBar(); + actionBar.setDisplayHomeAsUpEnabled(true); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + // app icon in action bar clicked; go home + Intent intent = new Intent(this, LibreOfficeUIActivity.class); + intent.putExtra(currentDirectoryKey, file ); + //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + +} diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/.classpath b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/.classpath new file mode 100644 index 000000000000..a4763d1eeced --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="gen"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> + <classpathentry kind="output" path="bin/classes"/> +</classpath> diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/.project b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/.project new file mode 100644 index 000000000000..59b93ac3f38c --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/.project @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>TextturePage</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.ApkBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>com.android.ide.eclipse.adt.AndroidNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/AndroidManifest.xml b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/AndroidManifest.xml new file mode 100644 index 000000000000..a9e146032f01 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/AndroidManifest.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="libreoffice.android.ui" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk android:minSdkVersion="11" /> + + <application + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" > + <activity + android:name=".TextturePageActivity" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/proguard-project.txt b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/proguard-project.txt new file mode 100644 index 000000000000..f2fe1559a217 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/project.properties b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/project.properties new file mode 100644 index 000000000000..4d07452b5f04 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-11 diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/dummy_page.png b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/dummy_page.png Binary files differnew file mode 100644 index 000000000000..c58d276e7085 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/dummy_page.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/ic_launcher.png b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..96a442e5b8e9 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/ic_launcher.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/jay.png b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/jay.png Binary files differnew file mode 100644 index 000000000000..03a72c16aab7 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/jay.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/ph_800_1280_dddddd.png b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/ph_800_1280_dddddd.png Binary files differnew file mode 100644 index 000000000000..a7c632a84db1 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-hdpi/ph_800_1280_dddddd.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-ldpi/ic_launcher.png b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-ldpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..99238729d875 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-ldpi/ic_launcher.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-mdpi/ic_launcher.png b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..359047dfa4ed --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-mdpi/ic_launcher.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-xhdpi/ic_launcher.png b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..71c6d760f051 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/drawable-xhdpi/ic_launcher.png diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/layout/main.xml b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/layout/main.xml new file mode 100644 index 000000000000..bc12cd82317f --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/layout/main.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</LinearLayout>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/values/strings.xml b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/values/strings.xml new file mode 100644 index 000000000000..afe8c5c24c7a --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/res/values/strings.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="hello">Hello World, TextturePageActivity!</string> + <string name="app_name">TextturePage</string> + +</resources>
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/Mesh.java b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/Mesh.java new file mode 100644 index 000000000000..5f3229119bcd --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/Mesh.java @@ -0,0 +1,262 @@ +/** + * Copyright 2010 Per-Erik Bergman (per-erik.bergman@jayway.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package libreoffice.android.ui; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.nio.ShortBuffer; + +import javax.microedition.khronos.opengles.GL10; + +import android.graphics.Bitmap; +import android.opengl.GLUtils; +import android.util.Log; + +/** + * Mesh is a base class for 3D objects making it easier to create and maintain + * new primitives. + * + * @author Per-Erik Bergman (per-erik.bergman@jayway.com) + * + */ +public class Mesh { + // Our vertex buffer. + private FloatBuffer mVerticesBuffer = null; + + // Our index buffer. + private ShortBuffer mIndicesBuffer = null; + + // Our UV texture buffer. + private FloatBuffer mTextureBuffer; // New variable. + + // Our texture id. + private int mTextureId = -1; // New variable. + + // The bitmap we want to load as a texture. + private Bitmap mBitmap; // New variable. + + // Indicates if we need to load the texture. + private boolean mShouldLoadTexture = false; // New variable. + + // The number of indices. + private int mNumOfIndices = -1; + + // Flat Color + private final float[] mRGBA = new float[] { 1.0f, 1.0f, 1.0f, 1.0f }; + + // Smooth Colors + private FloatBuffer mColorBuffer = null; + + // Translate params. + public float x = 0; + + public float y = 0; + + public float z = -2; + + // Rotate params. + public float rx = 0; + + public float ry = 0; + + public float rz = 0; + + /** + * Render the mesh. + * + * @param gl + * the OpenGL context to render to. + */ + public void draw(GL10 gl) { + // Counter-clockwise winding. + gl.glFrontFace(GL10.GL_CCW); + // Enable face culling. + gl.glEnable(GL10.GL_CULL_FACE); + // What faces to remove with the face culling. + gl.glCullFace(GL10.GL_BACK); + // Enabled the vertices buffer for writing and to be used during + // rendering. + gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); + // Specifies the location and data format of an array of vertex + // coordinates to use when rendering. + gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVerticesBuffer); + // Set flat color + gl.glColor4f(mRGBA[0], mRGBA[1], mRGBA[2], mRGBA[3]); + // Smooth color + if (mColorBuffer != null) { + // Enable the color array buffer to be used during rendering. + gl.glEnableClientState(GL10.GL_COLOR_ARRAY); + gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer); + } + + // New part... + if (mShouldLoadTexture) { + loadGLTexture(gl); + mShouldLoadTexture = false; + } + if (mTextureId != -1 && mTextureBuffer != null) { + gl.glEnable(GL10.GL_TEXTURE_2D); + // Enable the texture state + gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); + + // Point to our buffers + gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureBuffer); + gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureId); + } + // ... end new part. + + gl.glTranslatef(x, y, z); + gl.glRotatef(rx, 1, 0, 0); + gl.glRotatef(ry, 0, 1, 0); + gl.glRotatef(rz, 0, 0, 1); + + // Point out the where the color buffer is. + gl.glDrawElements(GL10.GL_TRIANGLES, mNumOfIndices, + GL10.GL_UNSIGNED_SHORT, mIndicesBuffer); + // Disable the vertices buffer. + gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); + + // New part... + if (mTextureId != -1 && mTextureBuffer != null) { + gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); + } + // ... end new part. + + // Disable face culling. + gl.glDisable(GL10.GL_CULL_FACE); + } + + /** + * Set the vertices. + * + * @param vertices + */ + protected void setVertices(float[] vertices) { + // a float is 4 bytes, therefore we multiply the number if + // vertices with 4. + ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4); + vbb.order(ByteOrder.nativeOrder()); + mVerticesBuffer = vbb.asFloatBuffer(); + mVerticesBuffer.put(vertices); + mVerticesBuffer.position(0); + } + + /** + * Set the indices. + * + * @param indices + */ + protected void setIndices(short[] indices) { + // short is 2 bytes, therefore we multiply the number if + // vertices with 2. + ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2); + ibb.order(ByteOrder.nativeOrder()); + mIndicesBuffer = ibb.asShortBuffer(); + mIndicesBuffer.put(indices); + mIndicesBuffer.position(0); + mNumOfIndices = indices.length; + } + + /** + * Set the texture coordinates. + * + * @param textureCoords + */ + protected void setTextureCoordinates(float[] textureCoords) { // New + // function. + // float is 4 bytes, therefore we multiply the number if + // vertices with 4. + ByteBuffer byteBuf = ByteBuffer + .allocateDirect(textureCoords.length * 4); + byteBuf.order(ByteOrder.nativeOrder()); + mTextureBuffer = byteBuf.asFloatBuffer(); + mTextureBuffer.put(textureCoords); + mTextureBuffer.position(0); + } + + /** + * Set one flat color on the mesh. + * + * @param red + * @param green + * @param blue + * @param alpha + */ + protected void setColor(float red, float green, float blue, float alpha) { + mRGBA[0] = red; + mRGBA[1] = green; + mRGBA[2] = blue; + mRGBA[3] = alpha; + } + + /** + * Set the colors + * + * @param colors + */ + protected void setColors(float[] colors) { + // float has 4 bytes. + ByteBuffer cbb = ByteBuffer.allocateDirect(colors.length * 4); + cbb.order(ByteOrder.nativeOrder()); + mColorBuffer = cbb.asFloatBuffer(); + mColorBuffer.put(colors); + mColorBuffer.position(0); + } + + /** + * Set the bitmap to load into a texture. + * + * @param bitmap + */ + public void loadBitmap(Bitmap bitmap) { // New function. + this.mBitmap = bitmap; + mShouldLoadTexture = true; + } + + /** + * Loads the texture. + * + * @param gl + */ + private void loadGLTexture(GL10 gl) { // New function + // Generate one texture pointer... + int[] textures = new int[1]; + gl.glGenTextures(1, textures, 0); + mTextureId = textures[0]; + + // ...and bind it to our array + gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureId); + + // Create Nearest Filtered Texture + gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, + GL10.GL_LINEAR); + gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, + GL10.GL_LINEAR); + + // Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE + gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, + GL10.GL_CLAMP_TO_EDGE); + gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, + GL10.GL_REPEAT); + + // Use the Android GLUtils to specify a two-dimensional texture image + // from our bitmap + GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, mBitmap, 0); + Log.d("gl-load-texture", Integer.toString(mTextureId) ); + } +}
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/Page.java b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/Page.java new file mode 100644 index 000000000000..2f98d5b3d556 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/Page.java @@ -0,0 +1,90 @@ +/** + * Copyright 2010 Per-Erik Bergman (per-erik.bergman@jayway.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package libreoffice.android.ui; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.nio.ShortBuffer; + +import javax.microedition.khronos.opengles.GL10; + +import android.graphics.Bitmap; +import android.opengl.GLUtils; +import android.util.Log; + + +public class Page extends Mesh { + /** + * Create a plane with a default with and height of 1 unit. + */ + public Page() { + this(1, 1); + } + + /** + * Create a plane. + * + * @param width + * the width of the plane. + * @param height + * the height of the plane. + */ + public Page(float width, float height) { + // Mapping coordinates for the vertices + float textureCoordinates[] = { + 0.0f, 1.0f, // + 1.0f, 1.0f, // + 0.0f, 0.0f, // + 1.0f, 0.0f, // + }; + + short[] indices = new short[] { 0, 1, 2, 1, 3, 2 }; + + float[] vertices = new float[] { -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, + -0.5f, 0.5f, 0.0f, 0.5f, 0.5f, 0.0f }; + + setIndices(indices); + setVertices(vertices); + setTextureCoordinates(textureCoordinates); + } + + public void zoomBy(float z){ + this.z += z; + if ( this.z > mMaxZoom) + this.z = mMaxZoom; + return; + } + + public void translateBy(float x, float y){ + this.x += x; + this.y += y; + if( Math.abs( this.x ) > 0.5f ) + this.x -= x; + if( Math.abs( this.y ) > 0.5f ) + this.y -= y; + return; + } + + float mMaxZoom = -0.1f; //positive z values are not visible + + + + + + +}
\ No newline at end of file diff --git a/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/TextturePageActivity.java b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/TextturePageActivity.java new file mode 100644 index 000000000000..eb90d47c44d3 --- /dev/null +++ b/android/experimental/GSoC-2012-eclipse-workspace/TextturePage/src/libreoffice/android/ui/TextturePageActivity.java @@ -0,0 +1,227 @@ +package libreoffice.android.ui; + +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.opengles.GL10; +import android.opengl.GLES20; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.opengl.GLSurfaceView; +import android.opengl.GLU; +import android.os.Bundle; +import android.util.Log; +import android.view.GestureDetector; +import android.view.MotionEvent; + +public class TextturePageActivity extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Page page = new Page(1, 1); + PageView view = new PageView(this,page); + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inScaled = false; + page.loadBitmap(BitmapFactory.decodeResource(getResources(), + R.drawable.ph_800_1280_dddddd,options) ); + view.setRenderer(new PageRenderer(page)); + view.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); + setContentView(view); + } +} + +class PageView extends GLSurfaceView { + Page mPage; + float zCumulative = 0;//can use this to limit zoom etc. + + + float dragX = -1.0f; + float dragY = -1.0f; + + float ptr0x = 0; + float ptr0y = 0; + float ptr1x = 0; + float ptr1y = 0; + + //The smaller this is the more sensitive the surface is to pinching + float zoomThreshold = 0.025f; + //The amout to zoom per event. + //Could calculate this dynamically but it seems smoother this way. + float zoomIncrement = 0.025f; + float dragIncrement = 0.01f; + + public PageView(Context context, Page mPage) { + super(context); + this.mPage = mPage; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + Log.d("onTouch", "********"); + String str = new String(); + + Log.d(" Screen -> Object ","" ); + Log.d("ptr count", Integer.toString( ev.getPointerCount() )); + Log.d("action", Integer.toString( ev.getAction() ) ); + Log.d("action-masked", Integer.toString( ev.getActionMasked() ) ); + + int action = ev.getActionMasked(); + int numDigits = ev.getPointerCount(); + float z = 0; + + + if( action == ev.ACTION_MOVE && numDigits == 2){ + MotionEvent.PointerCoords ptr0Curr = new MotionEvent.PointerCoords(); + MotionEvent.PointerCoords ptr1Curr = new MotionEvent.PointerCoords(); + ev.getPointerCoords(0, ptr0Curr); + ev.getPointerCoords(1, ptr1Curr); + float currentDistance = (ptr1Curr.x - ptr0Curr.x)*(ptr1Curr.x - ptr0Curr.x) + + (ptr1Curr.y - ptr0Curr.y)*(ptr1Curr.y - ptr0Curr.y); + float prevDistance = ( ptr1x - ptr0x )*( ptr1x - ptr0x ) + + ( ptr1y - ptr0y)*( ptr1y - ptr0y ); + Log.d("distance", " Curr = " + Float.toString(currentDistance) + + " Prev = " + Float.toString(prevDistance) ); + if(currentDistance >= (1+zoomThreshold)*prevDistance){//zoom in + z = zoomIncrement; + zCumulative += z; + } + if(currentDistance <= (1-zoomThreshold)*prevDistance){//zoom in + z = -zoomIncrement; + zCumulative -= z; + } + + mPage.zoomBy( z ); + this.requestRender(); + + ptr0x = ptr0Curr.x; + ptr0y = ptr0Curr.y; + ptr1x = ptr1Curr.x; + ptr1y = ptr1Curr.y; + } + + if(action == ev.ACTION_POINTER_UP && numDigits == 1){ + // End two finger gesture + //end zoom + } + + if(action == ev.ACTION_UP ){ + // gesture finished + //reset state variables + float zCumulative = 0; + float ptr0x = 0; + float ptr0y = 0; + float ptr1x = 0; + float ptr1y = 0; + } + + if( action == ev.ACTION_DOWN && numDigits == 1){ + //one finger pressed + dragX = ev.getX(); + dragY = ev.getY(); + } + + if( action == ev.ACTION_MOVE && numDigits == 1){ + //get normal vector in direction of motion + //multiply by increment scalar + //translate by x , y + float currX = ev.getX(); + float currY = ev.getY(); + + if( dragX == -1.0f || dragY == -1.0f ){//a bit dodgey + dragX = currX; + dragY = currY; + }else{ + Log.d("drag", Float.toString( dragX ) + " " + Float.toString( dragY ) ); + Log.d("drag-diff", Float.toString( currX - dragX ) + " " + Float.toString( currY - dragY ) ); + + float mag = ( currX - dragX )*( currX - dragX ) + + ( currY - dragY )*( currY - dragY ); + float xComp = ( currX - dragX )/mag; + float yComp = -( currY - dragY )/mag; + + mPage.translateBy( 0.025f*xComp , 0.025f*yComp ); + this.requestRender(); + + dragX = currX; + dragY = currY; + } + + } + return true; + } + + //public float[] getObjectCoordinates +} + +class PageRenderer implements GLSurfaceView.Renderer { + private Page mPage; + + public PageRenderer(Page page) { + // Initialize our square. + mPage = page; + } + /* + * (non-Javadoc) + * + * @see + * android.opengl.GLSurfaceView.Renderer#onSurfaceCreated(javax.microedition + * .khronos.opengles.GL10, javax.microedition.khronos.egl.EGLConfig) + */ + public void onSurfaceCreated(GL10 gl, EGLConfig config) { + // Set the background color to black ( rgba ). + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); + // Enable Smooth Shading, default not really needed. + gl.glShadeModel(GL10.GL_SMOOTH); + // Depth buffer setup. + gl.glClearDepthf(1.0f); + // Enables depth testing. + gl.glEnable(GL10.GL_DEPTH_TEST); + // The type of depth testing to do. + gl.glDepthFunc(GL10.GL_LEQUAL); + // Really nice perspective calculations. + gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); + } + + /* + * (non-Javadoc) + * + * @see + * android.opengl.GLSurfaceView.Renderer#onDrawFrame(javax.microedition. + * khronos.opengles.GL10) + */ + public void onDrawFrame(GL10 gl) { + // Clears the screen and depth buffer. + gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); + // Replace the current matrix with the identity matrix + gl.glLoadIdentity(); + // Translates 4 units into the screen. + //gl.glTranslatef(0, 0, -2); + // Draw our square. + mPage.draw(gl); + } + + /* + * (non-Javadoc) + * + * @see + * android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(javax.microedition + * .khronos.opengles.GL10, int, int) + */ + public void onSurfaceChanged(GL10 gl, int width, int height) { + // Sets the current view port to the new size. + gl.glViewport(0, 0, width, height); + // Select the projection matrix + gl.glMatrixMode(GL10.GL_PROJECTION);//TODO Should really use ModelView... + // Reset the projection matrix + gl.glLoadIdentity(); + // Calculate the aspect ratio of the window + GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, + 100.0f); + // Select the modelview matrix + gl.glMatrixMode(GL10.GL_MODELVIEW); + // Reset the modelview matrix + gl.glLoadIdentity(); + } + }
\ No newline at end of file |