
com.gluonhq.charm.down.android.scan.zxing.result.ResultHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of charm-down-android Show documentation
Show all versions of charm-down-android Show documentation
API to access features for the android platform
The newest version!
/*
* Copyright (C) 2008 ZXing authors
*
* 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 com.gluonhq.charm.down.android.scan.zxing.result;
import com.google.zxing.client.result.ParsedResult;
import android.app.Activity;
/**
* A base class for the Android-specific barcode handlers. These allow the app to polymorphically
* suggest the appropriate actions for each data type.
*
* This class also contains a bunch of utility methods to take common actions like opening a URL.
* They could easily be moved into a helper object, but it can't be static because the Activity
* instance is needed to launch an intent.
*
* @author [email protected] (Daniel Switkin)
* @author Sean Owen
*/
public abstract class ResultHandler {
private static final String TAG = ResultHandler.class.getSimpleName();
private final ParsedResult result;
private final Activity activity;
ResultHandler(Activity activity, ParsedResult result) {
this.result = result;
this.activity = activity;
}
public final ParsedResult getResult() {
return result;
}
final Activity getActivity() {
return activity;
}
/**
* Some barcode contents are considered secure, and should not be saved to history, copied to
* the clipboard, or otherwise persisted.
*
* @return If true, do not create any permanent record of these contents.
*/
public boolean areContentsSecure() {
return false;
}
/**
* Create a possibly styled string for the contents of the current barcode.
*
* @return The text to be displayed.
*/
public CharSequence getDisplayContents() {
String contents = result.getDisplayResult();
return contents.replace("\r", "");
}
/**
* A string describing the kind of barcode that was found, e.g. "Found contact info".
*
* @return The resource ID of the string.
*/
public abstract String getDisplayTitle();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy