Skip to content

Commit

Permalink
Working on about box etc
Browse files Browse the repository at this point in the history
  • Loading branch information
dsandler committed Jun 21, 2012
1 parent ba1a438 commit fe1d6cf
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 42 deletions.
34 changes: 28 additions & 6 deletions assets/about.html
Expand Up @@ -2,10 +2,11 @@
<head>
<style>
body {
background-color: #333;
color: white;
background-color: #282828;
color: #bebebe;
font-family: Roboto, sans-serif;
font-size: 14px;
margin: 0; padding: 0;
}
h1 {
font-family: "Roboto-Light", Roboto, sans-serif;
Expand All @@ -18,19 +19,40 @@
}
.license {
font-size: 85%;
background-color: #666;
background-color: #444;
padding: 0.5em;
padding-left: 1em;
}
a {
color: white;
}
</style>
</head>
<body>
<h1><img src="large_launcher_icon.png" style="width: 256px;" /><br/>Markers __VERSION__</h1>

<center>
<p>by Daniel Sandler</p>

<h2>Open Source License</h2>
</center>

<div class="license">__LICENSE__</div>
<div class="license">
<p>Copyright &copy; 2012 The Android Open Source Project</p>
<p>
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
</p>
<blockquote>
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
</blockquote>
<p>
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.
</p>
</div>
</body>
</html>
</html>
Binary file removed assets/large_launcher_icon.png
Binary file not shown.
Binary file modified res/drawable-mdpi/qr.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions res/layout/about_box.xml
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent"
android:padding="16dp"
>

<ImageView
android:id="@+id/logo"
Expand All @@ -17,10 +19,21 @@
android:layout_height="wrap_content"
android:layout_below="@+id/logo"
android:layout_centerHorizontal="true"
android:textSize="30sp"
android:layout_marginBottom="16dp"
android:text="Markers"
android:textAppearance="?android:attr/textAppearanceLarge" />
/>

<LinearLayout
<WebView
android:id="@+id/html"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:layout_below="@+id/title"
android:layout_centerHorizontal="true"
/>

<!-- <LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -34,6 +47,6 @@
android:text="Markers on Google Play"
android:onClick="clickMarketLink"
/>
</LinearLayout>
</LinearLayout> -->

</RelativeLayout>
3 changes: 3 additions & 0 deletions res/values/strings.xml
Expand Up @@ -18,4 +18,7 @@
<string name="app_name">Markers</string>
<string name="about_title">About Markers</string>
<string name="qr_title">QR Code for Markers</string>
<string name="about_text">

</string>
</resources>
2 changes: 1 addition & 1 deletion res/values/styles.xml
Expand Up @@ -55,5 +55,5 @@
<style name="ActionBar.Menu">
<item name="android:background">#FF000000</item>
<item name="android:gravity">right|top</item>
</style>
</style>
</resources>
49 changes: 18 additions & 31 deletions src/com/google/android/apps/markers/About.java
Expand Up @@ -16,6 +16,7 @@

package com.google.android.apps.markers;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -42,9 +43,11 @@ class About {
static String loadFileText(Context context, String filename) {
try {
StringBuffer fileData = new StringBuffer();
InputStreamReader reader = new InputStreamReader(context.getAssets().open(filename));
while ( reader.read(buf) > 0 ) {
fileData.append(buf);
final BufferedReader reader = new BufferedReader(
new InputStreamReader(context.getAssets().open(filename)));
String line;
while ( (line = reader.readLine()) != null ) {
fileData.append(line);
}
return fileData.toString();
} catch (IOException e) {
Expand All @@ -65,32 +68,6 @@ static String getVersionString(final Activity activity) {
return version;
}

static void showHtml(final MarkersActivity activity) {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(null);
builder.setCancelable(true);
// builder.setPositiveButton(R.string.about_dismiss_button,
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int which) {
// }
// });
// builder.setMessage(R.string.about_body);

String htmlString = loadFileText(activity, "about.html");
if (htmlString != null) {
String licenseString = loadFileText(activity, "license.html");
String version = getVersionString(activity);
htmlString = htmlString.replaceAll("__VERSION__", version);
htmlString = htmlString.replaceAll("__LICENSE__", licenseString);

WebView webview = new WebView(activity);
webview.loadDataWithBaseURL("file:///android_asset/", htmlString, "text/html", "utf-8", null);
builder.setView(webview);
} else {
builder.setMessage("Markers");
}
}

static void show(final MarkersActivity activity) {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(null);
Expand All @@ -104,14 +81,24 @@ static void show(final MarkersActivity activity) {
title.setTypeface(light);
title.setText(activity.getString(R.string.app_name) + " " + getVersionString(activity));

WebView webview = (WebView) layout.findViewById(R.id.html);
webview.loadDataWithBaseURL("file:///android_asset/",
loadFileText(activity, "about.html"), "text/html", "utf-8", null);

builder.setView(layout);
builder.setNegativeButton("Rate/Share on Google Play", new OnClickListener() {
builder.setNegativeButton("Website", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
activity.clickSiteLink(null);
}});
builder.setNeutralButton("on Play Store", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
activity.clickMarketLink(null);
}});
builder.setNeutralButton("Share via QR code", new OnClickListener() {
builder.setPositiveButton("QR code", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Expand Down
7 changes: 7 additions & 0 deletions src/com/google/android/apps/markers/MarkersActivity.java
Expand Up @@ -631,6 +631,13 @@ public void clickMarketLink(View unused) {
startActivity(urlIntent);
}

public void clickSiteLink(View unused) {
hideOverflow();
Intent urlIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://dsandler.org/markers?from=app"));
startActivity(urlIntent);
}

private void showOverflow() {
mMenuDialog.show();
}
Expand Down

0 comments on commit fe1d6cf

Please sign in to comment.