Simplify help screen and make consistent with dark Holo theme

git-svn-id: https://zxing.googlecode.com/svn/trunk@2829 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-06-23 16:14:12 +00:00
parent 0ad4759e14
commit c9364b49a3
5 changed files with 34 additions and 144 deletions

View file

@ -1,9 +1,27 @@
body {
font-family:sans-serif;
background-color: #000000;
color: #FFFFFF;
}
img {
margin: 3px;
}
li {
padding-top: 3px;
padding-bottom: 3px;
margin-left: -3px;
}
ul.touchable li {
padding-top:8px;
padding-bottom:8px;
padding-top: 8px;
padding-bottom: 8px;
}
a:link {
color: #FFFFFF;
}
a:visited {
color: #C0C0C0;
}
td {
vertical-align: top;
}
p.imgcenter {
text-align:center;

View file

@ -14,37 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<WebView android:id="@+id/help_contents"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:gravity="center"
android:paddingTop="@dimen/half_padding"
android:weightSum="1">
<Button android:id="@+id/back_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/button_back"/>
<Button android:id="@+id/done_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/button_done"/>
</LinearLayout>
</LinearLayout>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/help_contents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"/>

View file

@ -35,8 +35,6 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@ -147,8 +145,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
ambientLightManager = new AmbientLightManager(this);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
showHelpOnFirstLaunch();
}
@Override
@ -679,33 +675,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
}
}
/**
* We want the help screen to be shown automatically the first time a new version of the app is
* run. The easiest way to do this is to check android:versionCode from the manifest, and compare
* it to a value stored as a preference.
*/
private boolean showHelpOnFirstLaunch() {
try {
PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0);
int currentVersion = info.versionCode;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
int lastVersion = prefs.getInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, 0);
if (currentVersion > lastVersion) {
prefs.edit().putInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, currentVersion).commit();
Intent intent = new Intent(this, HelpActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
// Show the default page on a clean install, and the what's new page on an upgrade.
String page = lastVersion == 0 ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE;
intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, page);
startActivity(intent);
return true;
}
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, e);
}
return false;
}
private void initCamera(SurfaceHolder surfaceHolder) {
if (surfaceHolder == null) {
throw new IllegalStateException("No SurfaceHolder provided");

View file

@ -17,78 +17,34 @@
package com.google.zxing.client.android;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
/**
* An HTML-based help screen with Back and Done buttons at the bottom.
* An HTML-based help screen.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class HelpActivity extends Activity {
// Use this key and one of the values below when launching this activity via intent. If not
// present, the default page will be loaded.
public static final String REQUESTED_PAGE_KEY = "requested_page_key";
public static final String DEFAULT_PAGE = "index.html";
public static final String WHATS_NEW_PAGE = "whatsnew.html";
private static final String BASE_URL =
"file:///android_asset/html-" + LocaleManager.getTranslatedAssetLanguage() + '/';
private static final String WEBVIEW_STATE_PRESENT = "webview_state_present";
private WebView webView;
private Button backButton;
private final Button.OnClickListener backListener = new Button.OnClickListener() {
@Override
public void onClick(View view) {
webView.goBack();
}
};
private final Button.OnClickListener doneListener = new Button.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
};
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.help);
webView = (WebView)findViewById(R.id.help_contents);
webView.setWebViewClient(new HelpClient());
webView = (WebView) findViewById(R.id.help_contents);
// Froyo has a bug with calling onCreate() twice in a row, which causes the What's New page
// that's auto-loaded on first run to appear blank. As a workaround we only call restoreState()
// if a valid URL was loaded at the time the previous activity was torn down.
Intent intent = getIntent();
if (icicle != null && icicle.getBoolean(WEBVIEW_STATE_PRESENT, false)) {
webView.restoreState(icicle);
} else if (intent != null) {
String page = intent.getStringExtra(REQUESTED_PAGE_KEY);
if (page != null && !page.isEmpty()) {
webView.loadUrl(BASE_URL + page);
} else {
webView.loadUrl(BASE_URL + DEFAULT_PAGE);
}
if (icicle == null) {
webView.loadUrl(BASE_URL + "index.html");
} else {
webView.loadUrl(BASE_URL + DEFAULT_PAGE);
webView.restoreState(icicle);
}
backButton = (Button) findViewById(R.id.back_button);
backButton.setOnClickListener(backListener);
View doneButton = findViewById(R.id.done_button);
doneButton.setOnClickListener(doneListener);
}
@Override
@ -96,38 +52,16 @@ public final class HelpActivity extends Activity {
String url = webView.getUrl();
if (url != null && !url.isEmpty()) {
webView.saveState(state);
state.putBoolean(WEBVIEW_STATE_PRESENT, true);
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (webView.canGoBack()) {
webView.goBack();
return true;
}
if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) {
webView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
private final class HelpClient extends WebViewClient {
@Override
public void onPageFinished(WebView view, String url) {
setTitle(view.getTitle());
backButton.setEnabled(view.canGoBack());
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("file")) {
// Keep local assets in this WebView.
return false;
} else {
// Open external URLs in Browser.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
}
}
}

View file

@ -53,8 +53,6 @@ public final class PreferencesActivity extends PreferenceActivity
public static final String KEY_DISABLE_CONTINUOUS_FOCUS = "preferences_disable_continuous_focus";
//public static final String KEY_DISABLE_EXPOSURE = "preferences_disable_exposure";
public static final String KEY_HELP_VERSION_SHOWN = "preferences_help_version_shown";
private CheckBoxPreference decode1D;
private CheckBoxPreference decodeQR;
private CheckBoxPreference decodeDataMatrix;