summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-30 13:11:19 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-10-04 17:39:52 +0200
commit47314618c8d05cedb84bac9f4188cd2866db2805 (patch)
tree7b4ccf4425f04ebd6cfb09a48bef9a68971631d7 /android
parentae863caa9e73d3549d016655047a9aa0d86787c5 (diff)
android: about dialog in properties
Change-Id: I82961efee6415f07248c79062f2b3b8c58266821
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/res/layout/about.xml47
-rw-r--r--android/experimental/LOAndroid3/res/menu/main.xml8
-rw-r--r--android/experimental/LOAndroid3/res/values/strings.xml8
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java72
4 files changed, 114 insertions, 21 deletions
diff --git a/android/experimental/LOAndroid3/res/layout/about.xml b/android/experimental/LOAndroid3/res/layout/about.xml
new file mode 100644
index 000000000000..f1222dcdff5f
--- /dev/null
+++ b/android/experimental/LOAndroid3/res/layout/about.xml
@@ -0,0 +1,47 @@
+<?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"
+ android:padding="20dip">
+
+ <TextView
+ android:id="@+id/about_description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/app_description"
+ android:textColor="@android:color/secondary_text_light"
+ android:textSize="16sp"/>
+
+ <TextView
+ android:id="@+id/about_credits"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:autoLink="web"
+ android:paddingTop="20dip"
+ android:text="@string/app_credits"
+ android:textColor="@android:color/secondary_text_light"
+ android:textSize="16dip"/>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/about_license_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="License"
+ />
+
+ <Button
+ android:id="@+id/about_notice_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Notice"
+ />
+ </LinearLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/android/experimental/LOAndroid3/res/menu/main.xml b/android/experimental/LOAndroid3/res/menu/main.xml
index d51872bed9d1..cdf83bbac6a6 100644
--- a/android/experimental/LOAndroid3/res/menu/main.xml
+++ b/android/experimental/LOAndroid3/res/menu/main.xml
@@ -3,11 +3,11 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.libreoffice.MainActivity">
- <item android:id="@+id/action_settings"
- android:title="@string/action_settings"
+ <item android:id="@+id/action_about"
+ android:title="@string/action_about"
android:orderInCategory="100" />
- <item android:id="@+id/action_list"
- android:title="@string/action_list"
+ <item android:id="@+id/action_parts"
+ android:title="@string/action_parts"
android:orderInCategory="100" />
</menu>
diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml
index d69b33103e96..74dee0023247 100644
--- a/android/experimental/LOAndroid3/res/values/strings.xml
+++ b/android/experimental/LOAndroid3/res/values/strings.xml
@@ -2,8 +2,9 @@
<resources>
<string name="app_name">LibreOffice</string>
- <string name="action_settings">Settings</string>
- <string name="action_list">Parts</string>
+ <string name="app_description">Description</string>
+ <string name="app_credits">Credits</string>
+
<string name="browser_app_name">LibreOfficeUI</string>
<string name="menu_search">Search</string>
<string name="list_view">List</string>
@@ -16,4 +17,7 @@
<string name="EXPLORER_VIEW_TYPE_KEY">EXPLORER_VIEW_TYPE</string>
<string name="CURRENT_DIRECTORY_KEY">CURRENT_DIRECTORY</string>
+ <string name="action_about">About</string>
+ <string name="action_parts">Parts</string>
+
</resources>
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index b6b892a5e8f1..cc86e0bd308b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -1,6 +1,9 @@
package org.libreoffice;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.DrawerLayout;
@@ -10,8 +13,10 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
+import android.widget.Button;
import android.widget.ListView;
import android.widget.RelativeLayout;
+import android.widget.TextView;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.gfx.GeckoLayerClient;
@@ -23,7 +28,7 @@ import java.util.List;
public class LibreOfficeMainActivity extends Activity {
private static final String LOGTAG = "LibreOfficeMainActivity";
- private static final String DEFAULT_DOC_PATH = "/assets/test1.odt";
+ private static final String DEFAULT_DOC_PATH = "/assets/example.odt";
public static LibreOfficeMainActivity mAppContext;
@@ -38,6 +43,7 @@ public class LibreOfficeMainActivity extends Activity {
private ListView mDrawerList;
private List<DocumentPartView> mDocumentPartView = new ArrayList<DocumentPartView>();
private DocumentPartViewListAdpater mDocumentPartViewListAdpater;
+ private String mInputFile;
public static GeckoLayerClient getLayerClient() {
return mLayerClient;
@@ -56,11 +62,9 @@ public class LibreOfficeMainActivity extends Activity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
- if (id == R.id.action_settings) {
+ if (id == R.id.action_about) {
+ showAbout();
return true;
}
return super.onOptionsItemSelected(item);
@@ -69,8 +73,8 @@ public class LibreOfficeMainActivity extends Activity {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// If the nav drawer is open, hide action items related to the content view
- boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
- menu.findItem(R.id.action_list).setVisible(!drawerOpen);
+ boolean isDrawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
+ menu.findItem(R.id.action_parts).setVisible(!isDrawerOpen);
return super.onPrepareOptionsMenu(menu);
}
@@ -82,17 +86,16 @@ public class LibreOfficeMainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
+ Log.w(LOGTAG, "onCreate..");
mAppContext = this;
super.onCreate(savedInstanceState);
mMainHandler = new Handler();
- String inputFile;
-
if (getIntent().getData() != null) {
- inputFile = getIntent().getData().getEncodedPath();
+ mInputFile = getIntent().getData().getEncodedPath();
} else {
- inputFile = DEFAULT_DOC_PATH;
+ mInputFile = DEFAULT_DOC_PATH;
}
setContentView(R.layout.activity_main);
@@ -124,15 +127,13 @@ public class LibreOfficeMainActivity extends Activity {
mLayerController.setLayerClient(mLayerClient);
mGeckoLayout.addView(mLayerController.getView(), 0);
- LOKitShell.sendEvent(LOEvent.load(inputFile));
-
- Log.w(LOGTAG, "UI almost up");
+ LOKitShell.sendEvent(LOEvent.load(mInputFile));
}
@Override
protected void onResume() {
- Log.i(LOGTAG, "Resume..");
super.onResume();
+ Log.i(LOGTAG, "onResume..");
}
@Override
@@ -153,6 +154,47 @@ public class LibreOfficeMainActivity extends Activity {
return mDocumentPartViewListAdpater;
}
+ private void showAbout() {
+ // Inflate the about message contents
+ View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
+
+ // When linking text, force to always use default color. This works
+ // around a pressed color state bug.
+ TextView textView = (TextView) messageView.findViewById(R.id.about_credits);
+ int defaultColor = textView.getTextColors().getDefaultColor();
+ textView.setTextColor(defaultColor);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setIcon(R.drawable.lo_icon);
+ builder.setTitle(R.string.app_name);
+ builder.setView(messageView);
+ builder.create();
+ builder.show();
+
+ Button licenseButton = (Button) messageView.findViewById(R.id.about_license_button);
+ licenseButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(view.getContext(), LibreOfficeMainActivity.class);
+ //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.setData(Uri.parse("file:///assets/license.txt"));
+ startActivity(intent);
+ }
+ });
+
+ Button noticeButton = (Button) messageView.findViewById(R.id.about_notice_button);
+ noticeButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(view.getContext(), LibreOfficeMainActivity.class);
+ //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.setData(Uri.parse("file:///assets/notice.txt"));
+ startActivity(intent);
+ }
+ });
+
+ }
+
private class DocumentPartClickListener implements android.widget.AdapterView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {