mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-25 18:52:19 -05:00
cleaned up PluginQR, added main screen
This commit is contained in:
parent
7ca44ab5ec
commit
dd557cb455
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="keepass2android.pluginsdk"
|
||||
android:versionCode="1"
|
||||
|
@ -0,0 +1,10 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
|
||||
-->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
|
||||
</resources>
|
7
src/java/Keepass2AndroidPluginSDK/res/values/dimens.xml
Normal file
7
src/java/Keepass2AndroidPluginSDK/res/values/dimens.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
</resources>
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Keepass2Android Plugin SDK</string>
|
||||
|
@ -3,6 +3,8 @@ package keepass2android.pluginsdk;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@ -11,6 +13,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@ -20,6 +24,7 @@ import android.widget.PopupMenu;
|
||||
|
||||
public class AccessManager
|
||||
{
|
||||
|
||||
private static final String _tag = "Kp2aPluginSDK";
|
||||
private static final String PREF_KEY_SCOPE = "scope";
|
||||
private static final String PREF_KEY_TOKEN = "token";
|
||||
@ -64,6 +69,12 @@ public class AccessManager
|
||||
edit.commit();
|
||||
Log.d(_tag, "stored access token " + accessToken.substring(0, 4)+"... for "+scopes.size()+" scopes ("+scopesString+").");
|
||||
|
||||
SharedPreferences hostPrefs = ctx.getSharedPreferences("KP2A.PluginAccess.hosts", Context.MODE_PRIVATE);
|
||||
if (!hostPrefs.contains(hostPackage))
|
||||
{
|
||||
hostPrefs.edit().putString(hostPackage, "").commit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -143,8 +154,37 @@ public class AccessManager
|
||||
edit.commit();
|
||||
|
||||
}
|
||||
|
||||
SharedPreferences hostPrefs = ctx.getSharedPreferences("KP2A.PluginAccess.hosts", Context.MODE_PRIVATE);
|
||||
if (hostPrefs.contains(hostPackage))
|
||||
{
|
||||
hostPrefs.edit().remove(hostPackage).commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Set<String> getAllHostPackages(Context ctx)
|
||||
{
|
||||
SharedPreferences prefs = ctx.getSharedPreferences("KP2A.PluginAccess.hosts", Context.MODE_PRIVATE);
|
||||
Set<String> result = new HashSet<String>();
|
||||
for (String host: prefs.getAll().keySet())
|
||||
{
|
||||
try
|
||||
{
|
||||
PackageInfo info = ctx.getPackageManager().getPackageInfo(host, PackageManager.GET_META_DATA);
|
||||
//if we get here, the package is still there
|
||||
result.add(host);
|
||||
}
|
||||
catch (PackageManager.NameNotFoundException e)
|
||||
{
|
||||
//host gone. ignore.
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a valid access token or throws PluginAccessException
|
||||
|
@ -46,6 +46,12 @@ public class Strings {
|
||||
*/
|
||||
public static final String ACTION_REVOKE_ACCESS = "keepass2android.ACTION_REVOKE_ACCESS";
|
||||
|
||||
|
||||
/**
|
||||
* Action for startActivity(). Opens an activity in the Plugin Host to edit the plugin settings (i.e. enable it)
|
||||
*/
|
||||
public static final String ACTION_EDIT_PLUGIN_SETTINGS = "keepass2android.ACTION_EDIT_PLUGIN_SETTINGS";
|
||||
|
||||
/**
|
||||
* Action sent from KP2A to the plugin to indicate that an entry was opened.
|
||||
* The Intent contains the full entry data.
|
||||
|
@ -64,10 +64,11 @@
|
||||
android:label="Capture"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
|
||||
</activity>
|
||||
<activity android:name="com.google.zxing.client.android.PreferencesActivity"
|
||||
android:label="Settings" />
|
||||
|
||||
|
||||
</application>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,623 +7,21 @@
|
||||
package keepass2android.pluginsdk;
|
||||
|
||||
public final class R {
|
||||
public static final class anim {
|
||||
public static final int abc_fade_in = 0x7f040000;
|
||||
public static final int abc_fade_out = 0x7f040001;
|
||||
public static final int abc_slide_in_bottom = 0x7f040002;
|
||||
public static final int abc_slide_in_top = 0x7f040003;
|
||||
public static final int abc_slide_out_bottom = 0x7f040004;
|
||||
public static final int abc_slide_out_top = 0x7f040005;
|
||||
}
|
||||
public static final class attr {
|
||||
public static final int actionBarDivider = 0x7f01000f;
|
||||
public static final int actionBarItemBackground = 0x7f010010;
|
||||
public static final int actionBarSize = 0x7f01000e;
|
||||
public static final int actionBarSplitStyle = 0x7f01000c;
|
||||
public static final int actionBarStyle = 0x7f01000b;
|
||||
public static final int actionBarTabBarStyle = 0x7f010008;
|
||||
public static final int actionBarTabStyle = 0x7f010007;
|
||||
public static final int actionBarTabTextStyle = 0x7f010009;
|
||||
public static final int actionBarWidgetTheme = 0x7f01000d;
|
||||
public static final int actionButtonStyle = 0x7f010016;
|
||||
public static final int actionDropDownStyle = 0x7f010047;
|
||||
public static final int actionLayout = 0x7f01004e;
|
||||
public static final int actionMenuTextAppearance = 0x7f010011;
|
||||
public static final int actionMenuTextColor = 0x7f010012;
|
||||
public static final int actionModeBackground = 0x7f01003c;
|
||||
public static final int actionModeCloseButtonStyle = 0x7f01003b;
|
||||
public static final int actionModeCloseDrawable = 0x7f01003e;
|
||||
public static final int actionModeCopyDrawable = 0x7f010040;
|
||||
public static final int actionModeCutDrawable = 0x7f01003f;
|
||||
public static final int actionModeFindDrawable = 0x7f010044;
|
||||
public static final int actionModePasteDrawable = 0x7f010041;
|
||||
public static final int actionModePopupWindowStyle = 0x7f010046;
|
||||
public static final int actionModeSelectAllDrawable = 0x7f010042;
|
||||
public static final int actionModeShareDrawable = 0x7f010043;
|
||||
public static final int actionModeSplitBackground = 0x7f01003d;
|
||||
public static final int actionModeStyle = 0x7f01003a;
|
||||
public static final int actionModeWebSearchDrawable = 0x7f010045;
|
||||
public static final int actionOverflowButtonStyle = 0x7f01000a;
|
||||
public static final int actionProviderClass = 0x7f010050;
|
||||
public static final int actionViewClass = 0x7f01004f;
|
||||
public static final int activityChooserViewStyle = 0x7f01006c;
|
||||
public static final int background = 0x7f01002f;
|
||||
public static final int backgroundSplit = 0x7f010031;
|
||||
public static final int backgroundStacked = 0x7f010030;
|
||||
public static final int buttonBarButtonStyle = 0x7f010018;
|
||||
public static final int buttonBarStyle = 0x7f010017;
|
||||
public static final int customNavigationLayout = 0x7f010032;
|
||||
public static final int disableChildrenWhenDisabled = 0x7f010054;
|
||||
public static final int displayOptions = 0x7f010028;
|
||||
public static final int divider = 0x7f01002e;
|
||||
public static final int dividerHorizontal = 0x7f01001b;
|
||||
public static final int dividerPadding = 0x7f010056;
|
||||
public static final int dividerVertical = 0x7f01001a;
|
||||
public static final int dropDownListViewStyle = 0x7f010021;
|
||||
public static final int dropdownListPreferredItemHeight = 0x7f010048;
|
||||
public static final int expandActivityOverflowButtonDrawable = 0x7f01006b;
|
||||
public static final int height = 0x7f010026;
|
||||
public static final int homeAsUpIndicator = 0x7f010013;
|
||||
public static final int homeLayout = 0x7f010033;
|
||||
public static final int icon = 0x7f01002c;
|
||||
public static final int iconifiedByDefault = 0x7f01005a;
|
||||
public static final int indeterminateProgressStyle = 0x7f010035;
|
||||
public static final int initialActivityCount = 0x7f01006a;
|
||||
public static final int isLightTheme = 0x7f010059;
|
||||
public static final int itemPadding = 0x7f010037;
|
||||
public static final int listChoiceBackgroundIndicator = 0x7f01004c;
|
||||
public static final int listPopupWindowStyle = 0x7f010022;
|
||||
public static final int listPreferredItemHeight = 0x7f01001c;
|
||||
public static final int listPreferredItemHeightLarge = 0x7f01001e;
|
||||
public static final int listPreferredItemHeightSmall = 0x7f01001d;
|
||||
public static final int listPreferredItemPaddingLeft = 0x7f01001f;
|
||||
public static final int listPreferredItemPaddingRight = 0x7f010020;
|
||||
public static final int logo = 0x7f01002d;
|
||||
public static final int navigationMode = 0x7f010027;
|
||||
public static final int paddingEnd = 0x7f010039;
|
||||
public static final int paddingStart = 0x7f010038;
|
||||
public static final int panelMenuListTheme = 0x7f01004b;
|
||||
public static final int panelMenuListWidth = 0x7f01004a;
|
||||
public static final int popupMenuStyle = 0x7f010049;
|
||||
public static final int popupPromptView = 0x7f010053;
|
||||
public static final int progressBarPadding = 0x7f010036;
|
||||
public static final int progressBarStyle = 0x7f010034;
|
||||
public static final int prompt = 0x7f010051;
|
||||
public static final int queryHint = 0x7f01005b;
|
||||
public static final int searchDropdownBackground = 0x7f01005c;
|
||||
public static final int searchResultListItemHeight = 0x7f010065;
|
||||
public static final int searchViewAutoCompleteTextView = 0x7f010069;
|
||||
public static final int searchViewCloseIcon = 0x7f01005d;
|
||||
public static final int searchViewEditQuery = 0x7f010061;
|
||||
public static final int searchViewEditQueryBackground = 0x7f010062;
|
||||
public static final int searchViewGoIcon = 0x7f01005e;
|
||||
public static final int searchViewSearchIcon = 0x7f01005f;
|
||||
public static final int searchViewTextField = 0x7f010063;
|
||||
public static final int searchViewTextFieldRight = 0x7f010064;
|
||||
public static final int searchViewVoiceIcon = 0x7f010060;
|
||||
public static final int selectableItemBackground = 0x7f010019;
|
||||
public static final int showAsAction = 0x7f01004d;
|
||||
public static final int showDividers = 0x7f010055;
|
||||
public static final int spinnerDropDownItemStyle = 0x7f010058;
|
||||
public static final int spinnerMode = 0x7f010052;
|
||||
public static final int spinnerStyle = 0x7f010057;
|
||||
public static final int subtitle = 0x7f010029;
|
||||
public static final int subtitleTextStyle = 0x7f01002b;
|
||||
public static final int textAllCaps = 0x7f01006d;
|
||||
public static final int textAppearanceLargePopupMenu = 0x7f010014;
|
||||
public static final int textAppearanceListItem = 0x7f010023;
|
||||
public static final int textAppearanceListItemSmall = 0x7f010024;
|
||||
public static final int textAppearanceSearchResultSubtitle = 0x7f010067;
|
||||
public static final int textAppearanceSearchResultTitle = 0x7f010066;
|
||||
public static final int textAppearanceSmallPopupMenu = 0x7f010015;
|
||||
public static final int textColorSearchUrl = 0x7f010068;
|
||||
public static final int title = 0x7f010025;
|
||||
public static final int titleTextStyle = 0x7f01002a;
|
||||
public static final int windowActionBar = 0x7f010000;
|
||||
public static final int windowActionBarOverlay = 0x7f010001;
|
||||
public static final int windowFixedHeightMajor = 0x7f010006;
|
||||
public static final int windowFixedHeightMinor = 0x7f010004;
|
||||
public static final int windowFixedWidthMajor = 0x7f010003;
|
||||
public static final int windowFixedWidthMinor = 0x7f010005;
|
||||
public static final int windowSplitActionBar = 0x7f010002;
|
||||
}
|
||||
public static final class bool {
|
||||
public static final int abc_action_bar_embed_tabs_pre_jb = 0x7f080000;
|
||||
public static final int abc_action_bar_expanded_action_views_exclusive = 0x7f080001;
|
||||
public static final int abc_config_actionMenuItemAllCaps = 0x7f080005;
|
||||
public static final int abc_config_allowActionMenuItemTextWithIcon = 0x7f080004;
|
||||
public static final int abc_config_showMenuShortcutsWhenKeyboardPresent = 0x7f080003;
|
||||
public static final int abc_split_action_bar_is_narrow = 0x7f080002;
|
||||
}
|
||||
public static final class color {
|
||||
public static final int abc_search_url_text_holo = 0x7f09000e;
|
||||
public static final int abc_search_url_text_normal = 0x7f090000;
|
||||
public static final int abc_search_url_text_pressed = 0x7f090002;
|
||||
public static final int abc_search_url_text_selected = 0x7f090001;
|
||||
}
|
||||
public static final class dimen {
|
||||
public static final int abc_action_bar_default_height = 0x7f0a0002;
|
||||
public static final int abc_action_bar_icon_vertical_padding = 0x7f0a0003;
|
||||
public static final int abc_action_bar_progress_bar_size = 0x7f0a000a;
|
||||
public static final int abc_action_bar_stacked_max_height = 0x7f0a0009;
|
||||
public static final int abc_action_bar_stacked_tab_max_width = 0x7f0a0001;
|
||||
public static final int abc_action_bar_subtitle_bottom_margin = 0x7f0a0007;
|
||||
public static final int abc_action_bar_subtitle_text_size = 0x7f0a0005;
|
||||
public static final int abc_action_bar_subtitle_top_margin = 0x7f0a0006;
|
||||
public static final int abc_action_bar_title_text_size = 0x7f0a0004;
|
||||
public static final int abc_action_button_min_width = 0x7f0a0008;
|
||||
public static final int abc_config_prefDialogWidth = 0x7f0a0000;
|
||||
public static final int abc_dropdownitem_icon_width = 0x7f0a0010;
|
||||
public static final int abc_dropdownitem_text_padding_left = 0x7f0a000e;
|
||||
public static final int abc_dropdownitem_text_padding_right = 0x7f0a000f;
|
||||
public static final int abc_panel_menu_list_width = 0x7f0a000b;
|
||||
public static final int abc_search_view_preferred_width = 0x7f0a000d;
|
||||
public static final int abc_search_view_text_min_width = 0x7f0a000c;
|
||||
public static final int activity_horizontal_margin = 0x7f0a0015;
|
||||
public static final int activity_vertical_margin = 0x7f0a0016;
|
||||
public static final int dialog_fixed_height_major = 0x7f0a0013;
|
||||
public static final int dialog_fixed_height_minor = 0x7f0a0014;
|
||||
public static final int dialog_fixed_width_major = 0x7f0a0011;
|
||||
public static final int dialog_fixed_width_minor = 0x7f0a0012;
|
||||
public static final int activity_horizontal_margin = 0x7f060000;
|
||||
public static final int activity_vertical_margin = 0x7f060001;
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int abc_ab_bottom_solid_dark_holo = 0x7f020000;
|
||||
public static final int abc_ab_bottom_solid_light_holo = 0x7f020001;
|
||||
public static final int abc_ab_bottom_transparent_dark_holo = 0x7f020002;
|
||||
public static final int abc_ab_bottom_transparent_light_holo = 0x7f020003;
|
||||
public static final int abc_ab_share_pack_holo_dark = 0x7f020004;
|
||||
public static final int abc_ab_share_pack_holo_light = 0x7f020005;
|
||||
public static final int abc_ab_solid_dark_holo = 0x7f020006;
|
||||
public static final int abc_ab_solid_light_holo = 0x7f020007;
|
||||
public static final int abc_ab_stacked_solid_dark_holo = 0x7f020008;
|
||||
public static final int abc_ab_stacked_solid_light_holo = 0x7f020009;
|
||||
public static final int abc_ab_stacked_transparent_dark_holo = 0x7f02000a;
|
||||
public static final int abc_ab_stacked_transparent_light_holo = 0x7f02000b;
|
||||
public static final int abc_ab_transparent_dark_holo = 0x7f02000c;
|
||||
public static final int abc_ab_transparent_light_holo = 0x7f02000d;
|
||||
public static final int abc_cab_background_bottom_holo_dark = 0x7f02000e;
|
||||
public static final int abc_cab_background_bottom_holo_light = 0x7f02000f;
|
||||
public static final int abc_cab_background_top_holo_dark = 0x7f020010;
|
||||
public static final int abc_cab_background_top_holo_light = 0x7f020011;
|
||||
public static final int abc_ic_ab_back_holo_dark = 0x7f020012;
|
||||
public static final int abc_ic_ab_back_holo_light = 0x7f020013;
|
||||
public static final int abc_ic_cab_done_holo_dark = 0x7f020014;
|
||||
public static final int abc_ic_cab_done_holo_light = 0x7f020015;
|
||||
public static final int abc_ic_clear = 0x7f020016;
|
||||
public static final int abc_ic_clear_disabled = 0x7f020017;
|
||||
public static final int abc_ic_clear_holo_light = 0x7f020018;
|
||||
public static final int abc_ic_clear_normal = 0x7f020019;
|
||||
public static final int abc_ic_clear_search_api_disabled_holo_light = 0x7f02001a;
|
||||
public static final int abc_ic_clear_search_api_holo_light = 0x7f02001b;
|
||||
public static final int abc_ic_commit_search_api_holo_dark = 0x7f02001c;
|
||||
public static final int abc_ic_commit_search_api_holo_light = 0x7f02001d;
|
||||
public static final int abc_ic_go = 0x7f02001e;
|
||||
public static final int abc_ic_go_search_api_holo_light = 0x7f02001f;
|
||||
public static final int abc_ic_menu_moreoverflow_normal_holo_dark = 0x7f020020;
|
||||
public static final int abc_ic_menu_moreoverflow_normal_holo_light = 0x7f020021;
|
||||
public static final int abc_ic_menu_share_holo_dark = 0x7f020022;
|
||||
public static final int abc_ic_menu_share_holo_light = 0x7f020023;
|
||||
public static final int abc_ic_search = 0x7f020024;
|
||||
public static final int abc_ic_search_api_holo_light = 0x7f020025;
|
||||
public static final int abc_ic_voice_search = 0x7f020026;
|
||||
public static final int abc_ic_voice_search_api_holo_light = 0x7f020027;
|
||||
public static final int abc_item_background_holo_dark = 0x7f020028;
|
||||
public static final int abc_item_background_holo_light = 0x7f020029;
|
||||
public static final int abc_list_divider_holo_dark = 0x7f02002a;
|
||||
public static final int abc_list_divider_holo_light = 0x7f02002b;
|
||||
public static final int abc_list_focused_holo = 0x7f02002c;
|
||||
public static final int abc_list_longpressed_holo = 0x7f02002d;
|
||||
public static final int abc_list_pressed_holo_dark = 0x7f02002e;
|
||||
public static final int abc_list_pressed_holo_light = 0x7f02002f;
|
||||
public static final int abc_list_selector_background_transition_holo_dark = 0x7f020030;
|
||||
public static final int abc_list_selector_background_transition_holo_light = 0x7f020031;
|
||||
public static final int abc_list_selector_disabled_holo_dark = 0x7f020032;
|
||||
public static final int abc_list_selector_disabled_holo_light = 0x7f020033;
|
||||
public static final int abc_list_selector_holo_dark = 0x7f020034;
|
||||
public static final int abc_list_selector_holo_light = 0x7f020035;
|
||||
public static final int abc_menu_dropdown_panel_holo_dark = 0x7f020036;
|
||||
public static final int abc_menu_dropdown_panel_holo_light = 0x7f020037;
|
||||
public static final int abc_menu_hardkey_panel_holo_dark = 0x7f020038;
|
||||
public static final int abc_menu_hardkey_panel_holo_light = 0x7f020039;
|
||||
public static final int abc_search_dropdown_dark = 0x7f02003a;
|
||||
public static final int abc_search_dropdown_light = 0x7f02003b;
|
||||
public static final int abc_spinner_ab_default_holo_dark = 0x7f02003c;
|
||||
public static final int abc_spinner_ab_default_holo_light = 0x7f02003d;
|
||||
public static final int abc_spinner_ab_disabled_holo_dark = 0x7f02003e;
|
||||
public static final int abc_spinner_ab_disabled_holo_light = 0x7f02003f;
|
||||
public static final int abc_spinner_ab_focused_holo_dark = 0x7f020040;
|
||||
public static final int abc_spinner_ab_focused_holo_light = 0x7f020041;
|
||||
public static final int abc_spinner_ab_holo_dark = 0x7f020042;
|
||||
public static final int abc_spinner_ab_holo_light = 0x7f020043;
|
||||
public static final int abc_spinner_ab_pressed_holo_dark = 0x7f020044;
|
||||
public static final int abc_spinner_ab_pressed_holo_light = 0x7f020045;
|
||||
public static final int abc_tab_indicator_ab_holo = 0x7f020046;
|
||||
public static final int abc_tab_selected_focused_holo = 0x7f020047;
|
||||
public static final int abc_tab_selected_holo = 0x7f020048;
|
||||
public static final int abc_tab_selected_pressed_holo = 0x7f020049;
|
||||
public static final int abc_tab_unselected_pressed_holo = 0x7f02004a;
|
||||
public static final int abc_textfield_search_default_holo_dark = 0x7f02004b;
|
||||
public static final int abc_textfield_search_default_holo_light = 0x7f02004c;
|
||||
public static final int abc_textfield_search_right_default_holo_dark = 0x7f02004d;
|
||||
public static final int abc_textfield_search_right_default_holo_light = 0x7f02004e;
|
||||
public static final int abc_textfield_search_right_selected_holo_dark = 0x7f02004f;
|
||||
public static final int abc_textfield_search_right_selected_holo_light = 0x7f020050;
|
||||
public static final int abc_textfield_search_selected_holo_dark = 0x7f020051;
|
||||
public static final int abc_textfield_search_selected_holo_light = 0x7f020052;
|
||||
public static final int abc_textfield_searchview_holo_dark = 0x7f020053;
|
||||
public static final int abc_textfield_searchview_holo_light = 0x7f020054;
|
||||
public static final int abc_textfield_searchview_right_holo_dark = 0x7f020055;
|
||||
public static final int abc_textfield_searchview_right_holo_light = 0x7f020056;
|
||||
public static final int ic_launcher = 0x7f020057;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int action_bar = 0x7f070023;
|
||||
public static final int action_bar_activity_content = 0x7f070015;
|
||||
public static final int action_bar_container = 0x7f070022;
|
||||
public static final int action_bar_overlay_layout = 0x7f070026;
|
||||
public static final int action_bar_root = 0x7f070021;
|
||||
public static final int action_bar_subtitle = 0x7f07002a;
|
||||
public static final int action_bar_title = 0x7f070029;
|
||||
public static final int action_context_bar = 0x7f070024;
|
||||
public static final int action_menu_divider = 0x7f070016;
|
||||
public static final int action_menu_presenter = 0x7f070017;
|
||||
public static final int action_mode_close_button = 0x7f07002b;
|
||||
public static final int action_settings = 0x7f070070;
|
||||
public static final int activity_chooser_view_content = 0x7f07002c;
|
||||
public static final int always = 0x7f07000b;
|
||||
public static final int beginning = 0x7f070011;
|
||||
public static final int checkbox = 0x7f070034;
|
||||
public static final int collapseActionView = 0x7f07000d;
|
||||
public static final int default_activity_button = 0x7f07002f;
|
||||
public static final int dialog = 0x7f07000e;
|
||||
public static final int disableHome = 0x7f070008;
|
||||
public static final int dropdown = 0x7f07000f;
|
||||
public static final int edit_query = 0x7f070037;
|
||||
public static final int end = 0x7f070013;
|
||||
public static final int expand_activities_button = 0x7f07002d;
|
||||
public static final int expanded_menu = 0x7f070033;
|
||||
public static final int home = 0x7f070014;
|
||||
public static final int homeAsUp = 0x7f070005;
|
||||
public static final int icon = 0x7f070031;
|
||||
public static final int ifRoom = 0x7f07000a;
|
||||
public static final int image = 0x7f07002e;
|
||||
public static final int listMode = 0x7f070001;
|
||||
public static final int list_item = 0x7f070030;
|
||||
public static final int middle = 0x7f070012;
|
||||
public static final int never = 0x7f070009;
|
||||
public static final int none = 0x7f070010;
|
||||
public static final int normal = 0x7f070000;
|
||||
public static final int progress_circular = 0x7f070018;
|
||||
public static final int progress_horizontal = 0x7f070019;
|
||||
public static final int radio = 0x7f070036;
|
||||
public static final int search_badge = 0x7f070039;
|
||||
public static final int search_bar = 0x7f070038;
|
||||
public static final int search_button = 0x7f07003a;
|
||||
public static final int search_close_btn = 0x7f07003f;
|
||||
public static final int search_edit_frame = 0x7f07003b;
|
||||
public static final int search_go_btn = 0x7f070041;
|
||||
public static final int search_mag_icon = 0x7f07003c;
|
||||
public static final int search_plate = 0x7f07003d;
|
||||
public static final int search_src_text = 0x7f07003e;
|
||||
public static final int search_voice_btn = 0x7f070042;
|
||||
public static final int shortcut = 0x7f070035;
|
||||
public static final int showCustom = 0x7f070007;
|
||||
public static final int showHome = 0x7f070004;
|
||||
public static final int showTitle = 0x7f070006;
|
||||
public static final int split_action_bar = 0x7f070025;
|
||||
public static final int submit_area = 0x7f070040;
|
||||
public static final int tabMode = 0x7f070002;
|
||||
public static final int title = 0x7f070032;
|
||||
public static final int top_action_bar = 0x7f070027;
|
||||
public static final int up = 0x7f070028;
|
||||
public static final int useLogo = 0x7f070003;
|
||||
public static final int withText = 0x7f07000c;
|
||||
}
|
||||
public static final class integer {
|
||||
public static final int abc_max_action_buttons = 0x7f0b0000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int abc_action_bar_decor = 0x7f030000;
|
||||
public static final int abc_action_bar_decor_include = 0x7f030001;
|
||||
public static final int abc_action_bar_decor_overlay = 0x7f030002;
|
||||
public static final int abc_action_bar_home = 0x7f030003;
|
||||
public static final int abc_action_bar_tab = 0x7f030004;
|
||||
public static final int abc_action_bar_tabbar = 0x7f030005;
|
||||
public static final int abc_action_bar_title_item = 0x7f030006;
|
||||
public static final int abc_action_bar_view_list_nav_layout = 0x7f030007;
|
||||
public static final int abc_action_menu_item_layout = 0x7f030008;
|
||||
public static final int abc_action_menu_layout = 0x7f030009;
|
||||
public static final int abc_action_mode_bar = 0x7f03000a;
|
||||
public static final int abc_action_mode_close_item = 0x7f03000b;
|
||||
public static final int abc_activity_chooser_view = 0x7f03000c;
|
||||
public static final int abc_activity_chooser_view_include = 0x7f03000d;
|
||||
public static final int abc_activity_chooser_view_list_item = 0x7f03000e;
|
||||
public static final int abc_expanded_menu_layout = 0x7f03000f;
|
||||
public static final int abc_list_menu_item_checkbox = 0x7f030010;
|
||||
public static final int abc_list_menu_item_icon = 0x7f030011;
|
||||
public static final int abc_list_menu_item_layout = 0x7f030012;
|
||||
public static final int abc_list_menu_item_radio = 0x7f030013;
|
||||
public static final int abc_popup_menu_item_layout = 0x7f030014;
|
||||
public static final int abc_search_dropdown_item_icons_2line = 0x7f030015;
|
||||
public static final int abc_search_view = 0x7f030016;
|
||||
public static final int abc_simple_decor = 0x7f030017;
|
||||
public static final int support_simple_spinner_dropdown_item = 0x7f030026;
|
||||
}
|
||||
public static final class menu {
|
||||
public static final int main = 0x7f0f0003;
|
||||
public static final int ic_launcher = 0x7f020000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int abc_action_bar_home_description = 0x7f0c0001;
|
||||
public static final int abc_action_bar_up_description = 0x7f0c0002;
|
||||
public static final int abc_action_menu_overflow_description = 0x7f0c0003;
|
||||
public static final int abc_action_mode_done = 0x7f0c0000;
|
||||
public static final int abc_activity_chooser_view_see_all = 0x7f0c000a;
|
||||
public static final int abc_activitychooserview_choose_application = 0x7f0c0009;
|
||||
public static final int abc_searchview_description_clear = 0x7f0c0006;
|
||||
public static final int abc_searchview_description_query = 0x7f0c0005;
|
||||
public static final int abc_searchview_description_search = 0x7f0c0004;
|
||||
public static final int abc_searchview_description_submit = 0x7f0c0007;
|
||||
public static final int abc_searchview_description_voice = 0x7f0c0008;
|
||||
public static final int abc_shareactionprovider_share_with = 0x7f0c000c;
|
||||
public static final int abc_shareactionprovider_share_with_application = 0x7f0c000b;
|
||||
public static final int action_settings = 0x7f0c0010;
|
||||
public static final int app_name = 0x7f0c000d;
|
||||
public static final int hello_world = 0x7f0c000f;
|
||||
public static final int title_activity_main = 0x7f0c000e;
|
||||
public static final int action_settings = 0x7f070003;
|
||||
public static final int app_name = 0x7f070000;
|
||||
public static final int hello_world = 0x7f070002;
|
||||
public static final int title_activity_main = 0x7f070001;
|
||||
}
|
||||
public static final class style {
|
||||
public static final int AppBaseTheme = 0x7f0d008b;
|
||||
public static final int AppTheme = 0x7f0d008c;
|
||||
public static final int TextAppearance_AppCompat_Base_CompactMenu_Dialog = 0x7f0d0063;
|
||||
public static final int TextAppearance_AppCompat_Base_SearchResult = 0x7f0d006d;
|
||||
public static final int TextAppearance_AppCompat_Base_SearchResult_Subtitle = 0x7f0d006f;
|
||||
public static final int TextAppearance_AppCompat_Base_SearchResult_Title = 0x7f0d006e;
|
||||
public static final int TextAppearance_AppCompat_Base_Widget_PopupMenu_Large = 0x7f0d0069;
|
||||
public static final int TextAppearance_AppCompat_Base_Widget_PopupMenu_Small = 0x7f0d006a;
|
||||
public static final int TextAppearance_AppCompat_Light_Base_SearchResult = 0x7f0d0070;
|
||||
public static final int TextAppearance_AppCompat_Light_Base_SearchResult_Subtitle = 0x7f0d0072;
|
||||
public static final int TextAppearance_AppCompat_Light_Base_SearchResult_Title = 0x7f0d0071;
|
||||
public static final int TextAppearance_AppCompat_Light_Base_Widget_PopupMenu_Large = 0x7f0d006b;
|
||||
public static final int TextAppearance_AppCompat_Light_Base_Widget_PopupMenu_Small = 0x7f0d006c;
|
||||
public static final int TextAppearance_AppCompat_Light_SearchResult_Subtitle = 0x7f0d0035;
|
||||
public static final int TextAppearance_AppCompat_Light_SearchResult_Title = 0x7f0d0034;
|
||||
public static final int TextAppearance_AppCompat_Light_Widget_PopupMenu_Large = 0x7f0d0030;
|
||||
public static final int TextAppearance_AppCompat_Light_Widget_PopupMenu_Small = 0x7f0d0031;
|
||||
public static final int TextAppearance_AppCompat_SearchResult_Subtitle = 0x7f0d0033;
|
||||
public static final int TextAppearance_AppCompat_SearchResult_Title = 0x7f0d0032;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionBar_Menu = 0x7f0d001a;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionBar_Subtitle = 0x7f0d0006;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionBar_Subtitle_Inverse = 0x7f0d0008;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionBar_Title = 0x7f0d0005;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionBar_Title_Inverse = 0x7f0d0007;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionMode_Subtitle = 0x7f0d001e;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionMode_Subtitle_Inverse = 0x7f0d0020;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionMode_Title = 0x7f0d001d;
|
||||
public static final int TextAppearance_AppCompat_Widget_ActionMode_Title_Inverse = 0x7f0d001f;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Menu = 0x7f0d0054;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Subtitle = 0x7f0d0056;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Subtitle_Inverse = 0x7f0d0058;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Title = 0x7f0d0055;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Title_Inverse = 0x7f0d0057;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionMode_Subtitle = 0x7f0d0051;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionMode_Subtitle_Inverse = 0x7f0d0053;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionMode_Title = 0x7f0d0050;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_ActionMode_Title_Inverse = 0x7f0d0052;
|
||||
public static final int TextAppearance_AppCompat_Widget_Base_DropDownItem = 0x7f0d0061;
|
||||
public static final int TextAppearance_AppCompat_Widget_DropDownItem = 0x7f0d0021;
|
||||
public static final int TextAppearance_AppCompat_Widget_PopupMenu_Large = 0x7f0d002e;
|
||||
public static final int TextAppearance_AppCompat_Widget_PopupMenu_Small = 0x7f0d002f;
|
||||
public static final int TextAppearance_Widget_AppCompat_Base_ExpandedMenu_Item = 0x7f0d0062;
|
||||
public static final int TextAppearance_Widget_AppCompat_ExpandedMenu_Item = 0x7f0d0028;
|
||||
public static final int Theme_AppCompat = 0x7f0d0077;
|
||||
public static final int Theme_AppCompat_Base_CompactMenu = 0x7f0d0083;
|
||||
public static final int Theme_AppCompat_Base_CompactMenu_Dialog = 0x7f0d0084;
|
||||
public static final int Theme_AppCompat_CompactMenu = 0x7f0d007c;
|
||||
public static final int Theme_AppCompat_CompactMenu_Dialog = 0x7f0d007d;
|
||||
public static final int Theme_AppCompat_DialogWhenLarge = 0x7f0d007a;
|
||||
public static final int Theme_AppCompat_Light = 0x7f0d0078;
|
||||
public static final int Theme_AppCompat_Light_DarkActionBar = 0x7f0d0079;
|
||||
public static final int Theme_AppCompat_Light_DialogWhenLarge = 0x7f0d007b;
|
||||
public static final int Theme_Base = 0x7f0d007e;
|
||||
public static final int Theme_Base_AppCompat = 0x7f0d0080;
|
||||
public static final int Theme_Base_AppCompat_DialogWhenLarge = 0x7f0d0085;
|
||||
public static final int Theme_Base_AppCompat_DialogWhenLarge_Base = 0x7f0d0089;
|
||||
public static final int Theme_Base_AppCompat_Dialog_FixedSize = 0x7f0d0087;
|
||||
public static final int Theme_Base_AppCompat_Dialog_Light_FixedSize = 0x7f0d0088;
|
||||
public static final int Theme_Base_AppCompat_Light = 0x7f0d0081;
|
||||
public static final int Theme_Base_AppCompat_Light_DarkActionBar = 0x7f0d0082;
|
||||
public static final int Theme_Base_AppCompat_Light_DialogWhenLarge = 0x7f0d0086;
|
||||
public static final int Theme_Base_AppCompat_Light_DialogWhenLarge_Base = 0x7f0d008a;
|
||||
public static final int Theme_Base_Light = 0x7f0d007f;
|
||||
public static final int Widget_AppCompat_ActionBar = 0x7f0d0000;
|
||||
public static final int Widget_AppCompat_ActionBar_Solid = 0x7f0d0002;
|
||||
public static final int Widget_AppCompat_ActionBar_TabBar = 0x7f0d0011;
|
||||
public static final int Widget_AppCompat_ActionBar_TabText = 0x7f0d0017;
|
||||
public static final int Widget_AppCompat_ActionBar_TabView = 0x7f0d0014;
|
||||
public static final int Widget_AppCompat_ActionButton = 0x7f0d000b;
|
||||
public static final int Widget_AppCompat_ActionButton_CloseMode = 0x7f0d000d;
|
||||
public static final int Widget_AppCompat_ActionButton_Overflow = 0x7f0d000f;
|
||||
public static final int Widget_AppCompat_ActionMode = 0x7f0d001b;
|
||||
public static final int Widget_AppCompat_ActivityChooserView = 0x7f0d0038;
|
||||
public static final int Widget_AppCompat_AutoCompleteTextView = 0x7f0d0036;
|
||||
public static final int Widget_AppCompat_Base_ActionBar = 0x7f0d003a;
|
||||
public static final int Widget_AppCompat_Base_ActionBar_Solid = 0x7f0d003c;
|
||||
public static final int Widget_AppCompat_Base_ActionBar_TabBar = 0x7f0d0045;
|
||||
public static final int Widget_AppCompat_Base_ActionBar_TabText = 0x7f0d004b;
|
||||
public static final int Widget_AppCompat_Base_ActionBar_TabView = 0x7f0d0048;
|
||||
public static final int Widget_AppCompat_Base_ActionButton = 0x7f0d003f;
|
||||
public static final int Widget_AppCompat_Base_ActionButton_CloseMode = 0x7f0d0041;
|
||||
public static final int Widget_AppCompat_Base_ActionButton_Overflow = 0x7f0d0043;
|
||||
public static final int Widget_AppCompat_Base_ActionMode = 0x7f0d004e;
|
||||
public static final int Widget_AppCompat_Base_ActivityChooserView = 0x7f0d0075;
|
||||
public static final int Widget_AppCompat_Base_AutoCompleteTextView = 0x7f0d0073;
|
||||
public static final int Widget_AppCompat_Base_DropDownItem_Spinner = 0x7f0d005d;
|
||||
public static final int Widget_AppCompat_Base_ListPopupWindow = 0x7f0d0065;
|
||||
public static final int Widget_AppCompat_Base_ListView_DropDown = 0x7f0d005f;
|
||||
public static final int Widget_AppCompat_Base_ListView_Menu = 0x7f0d0064;
|
||||
public static final int Widget_AppCompat_Base_PopupMenu = 0x7f0d0067;
|
||||
public static final int Widget_AppCompat_Base_ProgressBar = 0x7f0d005a;
|
||||
public static final int Widget_AppCompat_Base_ProgressBar_Horizontal = 0x7f0d0059;
|
||||
public static final int Widget_AppCompat_Base_Spinner = 0x7f0d005b;
|
||||
public static final int Widget_AppCompat_DropDownItem_Spinner = 0x7f0d0024;
|
||||
public static final int Widget_AppCompat_Light_ActionBar = 0x7f0d0001;
|
||||
public static final int Widget_AppCompat_Light_ActionBar_Solid = 0x7f0d0003;
|
||||
public static final int Widget_AppCompat_Light_ActionBar_Solid_Inverse = 0x7f0d0004;
|
||||
public static final int Widget_AppCompat_Light_ActionBar_TabBar = 0x7f0d0012;
|
||||
public static final int Widget_AppCompat_Light_ActionBar_TabBar_Inverse = 0x7f0d0013;
|
||||
public static final int Widget_AppCompat_Light_ActionBar_TabText = 0x7f0d0018;
|
||||
public static final int Widget_AppCompat_Light_ActionBar_TabText_Inverse = 0x7f0d0019;
|
||||
public static final int Widget_AppCompat_Light_ActionBar_TabView = 0x7f0d0015;
|
||||
public static final int Widget_AppCompat_Light_ActionBar_TabView_Inverse = 0x7f0d0016;
|
||||
public static final int Widget_AppCompat_Light_ActionButton = 0x7f0d000c;
|
||||
public static final int Widget_AppCompat_Light_ActionButton_CloseMode = 0x7f0d000e;
|
||||
public static final int Widget_AppCompat_Light_ActionButton_Overflow = 0x7f0d0010;
|
||||
public static final int Widget_AppCompat_Light_ActionMode_Inverse = 0x7f0d001c;
|
||||
public static final int Widget_AppCompat_Light_ActivityChooserView = 0x7f0d0039;
|
||||
public static final int Widget_AppCompat_Light_AutoCompleteTextView = 0x7f0d0037;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar = 0x7f0d003b;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar_Solid = 0x7f0d003d;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar_Solid_Inverse = 0x7f0d003e;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar_TabBar = 0x7f0d0046;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar_TabBar_Inverse = 0x7f0d0047;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar_TabText = 0x7f0d004c;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar_TabText_Inverse = 0x7f0d004d;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar_TabView = 0x7f0d0049;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionBar_TabView_Inverse = 0x7f0d004a;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionButton = 0x7f0d0040;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionButton_CloseMode = 0x7f0d0042;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionButton_Overflow = 0x7f0d0044;
|
||||
public static final int Widget_AppCompat_Light_Base_ActionMode_Inverse = 0x7f0d004f;
|
||||
public static final int Widget_AppCompat_Light_Base_ActivityChooserView = 0x7f0d0076;
|
||||
public static final int Widget_AppCompat_Light_Base_AutoCompleteTextView = 0x7f0d0074;
|
||||
public static final int Widget_AppCompat_Light_Base_DropDownItem_Spinner = 0x7f0d005e;
|
||||
public static final int Widget_AppCompat_Light_Base_ListPopupWindow = 0x7f0d0066;
|
||||
public static final int Widget_AppCompat_Light_Base_ListView_DropDown = 0x7f0d0060;
|
||||
public static final int Widget_AppCompat_Light_Base_PopupMenu = 0x7f0d0068;
|
||||
public static final int Widget_AppCompat_Light_Base_Spinner = 0x7f0d005c;
|
||||
public static final int Widget_AppCompat_Light_DropDownItem_Spinner = 0x7f0d0025;
|
||||
public static final int Widget_AppCompat_Light_ListPopupWindow = 0x7f0d002a;
|
||||
public static final int Widget_AppCompat_Light_ListView_DropDown = 0x7f0d0027;
|
||||
public static final int Widget_AppCompat_Light_PopupMenu = 0x7f0d002c;
|
||||
public static final int Widget_AppCompat_Light_Spinner_DropDown_ActionBar = 0x7f0d0023;
|
||||
public static final int Widget_AppCompat_ListPopupWindow = 0x7f0d0029;
|
||||
public static final int Widget_AppCompat_ListView_DropDown = 0x7f0d0026;
|
||||
public static final int Widget_AppCompat_ListView_Menu = 0x7f0d002d;
|
||||
public static final int Widget_AppCompat_PopupMenu = 0x7f0d002b;
|
||||
public static final int Widget_AppCompat_ProgressBar = 0x7f0d000a;
|
||||
public static final int Widget_AppCompat_ProgressBar_Horizontal = 0x7f0d0009;
|
||||
public static final int Widget_AppCompat_Spinner_DropDown_ActionBar = 0x7f0d0022;
|
||||
}
|
||||
public static final class styleable {
|
||||
public static final int[] ActionBar = { 0x7f010025, 0x7f010026, 0x7f010027, 0x7f010028, 0x7f010029, 0x7f01002a, 0x7f01002b, 0x7f01002c, 0x7f01002d, 0x7f01002e, 0x7f01002f, 0x7f010030, 0x7f010031, 0x7f010032, 0x7f010033, 0x7f010034, 0x7f010035, 0x7f010036, 0x7f010037 };
|
||||
public static final int[] ActionBarLayout = { 0x010100b3 };
|
||||
public static final int ActionBarLayout_android_layout_gravity = 0;
|
||||
public static final int[] ActionBarWindow = { 0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003, 0x7f010004, 0x7f010005, 0x7f010006 };
|
||||
public static final int ActionBarWindow_windowActionBar = 0;
|
||||
public static final int ActionBarWindow_windowActionBarOverlay = 1;
|
||||
public static final int ActionBarWindow_windowFixedHeightMajor = 6;
|
||||
public static final int ActionBarWindow_windowFixedHeightMinor = 4;
|
||||
public static final int ActionBarWindow_windowFixedWidthMajor = 3;
|
||||
public static final int ActionBarWindow_windowFixedWidthMinor = 5;
|
||||
public static final int ActionBarWindow_windowSplitActionBar = 2;
|
||||
public static final int ActionBar_background = 10;
|
||||
public static final int ActionBar_backgroundSplit = 12;
|
||||
public static final int ActionBar_backgroundStacked = 11;
|
||||
public static final int ActionBar_customNavigationLayout = 13;
|
||||
public static final int ActionBar_displayOptions = 3;
|
||||
public static final int ActionBar_divider = 9;
|
||||
public static final int ActionBar_height = 1;
|
||||
public static final int ActionBar_homeLayout = 14;
|
||||
public static final int ActionBar_icon = 7;
|
||||
public static final int ActionBar_indeterminateProgressStyle = 16;
|
||||
public static final int ActionBar_itemPadding = 18;
|
||||
public static final int ActionBar_logo = 8;
|
||||
public static final int ActionBar_navigationMode = 2;
|
||||
public static final int ActionBar_progressBarPadding = 17;
|
||||
public static final int ActionBar_progressBarStyle = 15;
|
||||
public static final int ActionBar_subtitle = 4;
|
||||
public static final int ActionBar_subtitleTextStyle = 6;
|
||||
public static final int ActionBar_title = 0;
|
||||
public static final int ActionBar_titleTextStyle = 5;
|
||||
public static final int[] ActionMenuItemView = { 0x0101013f };
|
||||
public static final int ActionMenuItemView_android_minWidth = 0;
|
||||
public static final int[] ActionMenuView = { };
|
||||
public static final int[] ActionMode = { 0x7f010026, 0x7f01002a, 0x7f01002b, 0x7f01002f, 0x7f010031 };
|
||||
public static final int ActionMode_background = 3;
|
||||
public static final int ActionMode_backgroundSplit = 4;
|
||||
public static final int ActionMode_height = 0;
|
||||
public static final int ActionMode_subtitleTextStyle = 2;
|
||||
public static final int ActionMode_titleTextStyle = 1;
|
||||
public static final int[] ActivityChooserView = { 0x7f01006a, 0x7f01006b };
|
||||
public static final int ActivityChooserView_expandActivityOverflowButtonDrawable = 1;
|
||||
public static final int ActivityChooserView_initialActivityCount = 0;
|
||||
public static final int[] CompatTextView = { 0x7f01006d };
|
||||
public static final int CompatTextView_textAllCaps = 0;
|
||||
public static final int[] LinearLayoutICS = { 0x7f01002e, 0x7f010055, 0x7f010056 };
|
||||
public static final int LinearLayoutICS_divider = 0;
|
||||
public static final int LinearLayoutICS_dividerPadding = 2;
|
||||
public static final int LinearLayoutICS_showDividers = 1;
|
||||
public static final int[] MenuGroup = { 0x0101000e, 0x010100d0, 0x01010194, 0x010101de, 0x010101df, 0x010101e0 };
|
||||
public static final int MenuGroup_android_checkableBehavior = 5;
|
||||
public static final int MenuGroup_android_enabled = 0;
|
||||
public static final int MenuGroup_android_id = 1;
|
||||
public static final int MenuGroup_android_menuCategory = 3;
|
||||
public static final int MenuGroup_android_orderInCategory = 4;
|
||||
public static final int MenuGroup_android_visible = 2;
|
||||
public static final int[] MenuItem = { 0x01010002, 0x0101000e, 0x010100d0, 0x01010106, 0x01010194, 0x010101de, 0x010101df, 0x010101e1, 0x010101e2, 0x010101e3, 0x010101e4, 0x010101e5, 0x0101026f, 0x7f01004d, 0x7f01004e, 0x7f01004f, 0x7f010050 };
|
||||
public static final int MenuItem_actionLayout = 14;
|
||||
public static final int MenuItem_actionProviderClass = 16;
|
||||
public static final int MenuItem_actionViewClass = 15;
|
||||
public static final int MenuItem_android_alphabeticShortcut = 9;
|
||||
public static final int MenuItem_android_checkable = 11;
|
||||
public static final int MenuItem_android_checked = 3;
|
||||
public static final int MenuItem_android_enabled = 1;
|
||||
public static final int MenuItem_android_icon = 0;
|
||||
public static final int MenuItem_android_id = 2;
|
||||
public static final int MenuItem_android_menuCategory = 5;
|
||||
public static final int MenuItem_android_numericShortcut = 10;
|
||||
public static final int MenuItem_android_onClick = 12;
|
||||
public static final int MenuItem_android_orderInCategory = 6;
|
||||
public static final int MenuItem_android_title = 7;
|
||||
public static final int MenuItem_android_titleCondensed = 8;
|
||||
public static final int MenuItem_android_visible = 4;
|
||||
public static final int MenuItem_showAsAction = 13;
|
||||
public static final int[] MenuView = { 0x010100ae, 0x0101012c, 0x0101012d, 0x0101012e, 0x0101012f, 0x01010130, 0x01010131, 0x01010435 };
|
||||
public static final int MenuView_android_headerBackground = 4;
|
||||
public static final int MenuView_android_horizontalDivider = 2;
|
||||
public static final int MenuView_android_itemBackground = 5;
|
||||
public static final int MenuView_android_itemIconDisabledAlpha = 6;
|
||||
public static final int MenuView_android_itemTextAppearance = 1;
|
||||
public static final int MenuView_android_preserveIconSpacing = 7;
|
||||
public static final int MenuView_android_verticalDivider = 3;
|
||||
public static final int MenuView_android_windowAnimationStyle = 0;
|
||||
public static final int[] SearchView = { 0x0101011f, 0x01010220, 0x01010264, 0x7f01005a, 0x7f01005b };
|
||||
public static final int SearchView_android_imeOptions = 2;
|
||||
public static final int SearchView_android_inputType = 1;
|
||||
public static final int SearchView_android_maxWidth = 0;
|
||||
public static final int SearchView_iconifiedByDefault = 3;
|
||||
public static final int SearchView_queryHint = 4;
|
||||
public static final int[] Spinner = { 0x010100af, 0x01010175, 0x01010176, 0x01010262, 0x010102ac, 0x010102ad, 0x7f010051, 0x7f010052, 0x7f010053, 0x7f010054 };
|
||||
public static final int Spinner_android_dropDownHorizontalOffset = 4;
|
||||
public static final int Spinner_android_dropDownSelector = 1;
|
||||
public static final int Spinner_android_dropDownVerticalOffset = 5;
|
||||
public static final int Spinner_android_dropDownWidth = 3;
|
||||
public static final int Spinner_android_gravity = 0;
|
||||
public static final int Spinner_android_popupBackground = 2;
|
||||
public static final int Spinner_disableChildrenWhenDisabled = 9;
|
||||
public static final int Spinner_popupPromptView = 8;
|
||||
public static final int Spinner_prompt = 6;
|
||||
public static final int Spinner_spinnerMode = 7;
|
||||
public static final int[] Theme = { 0x7f010047, 0x7f010048, 0x7f010049, 0x7f01004a, 0x7f01004b, 0x7f01004c };
|
||||
public static final int Theme_actionDropDownStyle = 0;
|
||||
public static final int Theme_dropdownListPreferredItemHeight = 1;
|
||||
public static final int Theme_listChoiceBackgroundIndicator = 5;
|
||||
public static final int Theme_panelMenuListTheme = 4;
|
||||
public static final int Theme_panelMenuListWidth = 3;
|
||||
public static final int Theme_popupMenuStyle = 2;
|
||||
public static final int[] View = { 0x010100da, 0x7f010038, 0x7f010039 };
|
||||
public static final int View_android_focusable = 0;
|
||||
public static final int View_paddingEnd = 2;
|
||||
public static final int View_paddingStart = 1;
|
||||
public static final int AppBaseTheme = 0x7f080000;
|
||||
public static final int AppTheme = 0x7f080001;
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,58 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="keepass2android.plugin.qr.MainActivity$PlaceholderFragment" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnConfigPlugins"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:minHeight="45dp"
|
||||
android:text="@string/enable_as_plugin" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnShowQR"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="15dp"
|
||||
android:drawableTop="@drawable/qrcode"
|
||||
android:minHeight="45dp"
|
||||
android:text="@string/show_qr" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnScanQRCode"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/btnConfigPlugins"
|
||||
android:layout_below="@+id/btnShowQR"
|
||||
android:drawableTop="@android:drawable/ic_menu_camera"
|
||||
android:minHeight="45dp"
|
||||
android:text="@string/scan_qr" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hello"
|
||||
android:id="@+id/tvHostStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hello_world" />
|
||||
android:layout_above="@+id/btnConfigPlugins"
|
||||
android:layout_alignLeft="@+id/btnConfigPlugins"
|
||||
android:text="" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar1"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/btnScanQRCode"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:indeterminate="true"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -15,24 +15,9 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_share"
|
||||
android:title="@string/menu_share"
|
||||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:orderInCategory="1"
|
||||
android:showAsAction="withText|ifRoom"/>
|
||||
<item android:id="@+id/menu_history"
|
||||
android:title="@string/menu_history"
|
||||
android:icon="@android:drawable/ic_menu_recent_history"
|
||||
android:orderInCategory="2"
|
||||
android:showAsAction="withText|ifRoom"/>
|
||||
<item android:id="@+id/menu_settings"
|
||||
android:title="@string/menu_settings"
|
||||
android:icon="@android:drawable/ic_menu_preferences"
|
||||
android:orderInCategory="3"
|
||||
android:showAsAction="withText"/>
|
||||
<item android:id="@+id/menu_help"
|
||||
android:title="@string/menu_help"
|
||||
android:icon="@android:drawable/ic_menu_help"
|
||||
android:orderInCategory="4"
|
||||
android:showAsAction="withText"/>
|
||||
</menu>
|
@ -15,7 +15,6 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
<string name="app_picker_name">Aplicacions</string>
|
||||
<string name="bookmark_picker_name">Adreces d\'interès</string>
|
||||
<string name="button_add_calendar">Afegeix a l\'agenda</string>
|
||||
|
@ -15,7 +15,6 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
<string name="app_picker_name">Aplikace</string>
|
||||
<string name="bookmark_picker_name">Záložky</string>
|
||||
<string name="button_add_calendar">Přidat do kalendáře</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Applikationer</string>
|
||||
<string name="bookmark_picker_name">Bogmærker</string>
|
||||
<string name="button_add_calendar">Tilføj til kalendar</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Anwendungen</string>
|
||||
<string name="bookmark_picker_name">Lesezeichen</string>
|
||||
<string name="button_add_calendar">Termin hinzufügen</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Εφαρμογές</string>
|
||||
<string name="bookmark_picker_name">Σελιδοδείκτες</string>
|
||||
<string name="button_add_calendar">Προσθήκη στο ημερολόγιο</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Aplicaciones</string>
|
||||
<string name="bookmark_picker_name">Marcadores</string>
|
||||
<string name="button_add_calendar">Añadir al calendario</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Ohjelmat</string>
|
||||
<string name="bookmark_picker_name">Kirjanmerkit</string>
|
||||
<string name="button_add_calendar">Lisää kalenteriin</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Applications</string>
|
||||
<string name="bookmark_picker_name">Marque-pages</string>
|
||||
<string name="button_add_calendar">Ajouter à l\'agenda</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Alkalmazások</string>
|
||||
<string name="bookmark_picker_name">Könyvjelzők</string>
|
||||
<string name="button_add_calendar">Hozzáadás a naptárhoz</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Aplikasi</string>
|
||||
<string name="bookmark_picker_name">Bookmarks</string>
|
||||
<string name="button_add_calendar">Tambah ke kalendar</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Applicazioni</string>
|
||||
<string name="bookmark_picker_name">Segnalibri</string>
|
||||
<string name="button_add_calendar">Aggiungi al calendario</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Applicaties</string>
|
||||
<string name="bookmark_picker_name">Bladwijzers</string>
|
||||
<string name="button_add_calendar">Toevoegen aan agenda</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Aplikacje</string>
|
||||
<string name="bookmark_picker_name">Zakładki</string>
|
||||
<string name="button_add_calendar">Dodaj do kalendarza</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Aplicações</string>
|
||||
<string name="bookmark_picker_name">Favoritos</string>
|
||||
<string name="button_add_calendar">Adicionar ao calendário</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Aplicații</string>
|
||||
<string name="bookmark_picker_name">Nume însemnare</string>
|
||||
<string name="button_add_calendar">Adaugă în calendar</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Aplikácie</string>
|
||||
<string name="bookmark_picker_name">Záložky</string>
|
||||
<string name="button_add_calendar">Pridať do kalendára</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Aplikacije</string>
|
||||
<string name="bookmark_picker_name">Zaznamki</string>
|
||||
<string name="button_add_calendar">Dodaj v koledar</string>
|
||||
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
|
||||
<string name="app_picker_name">Applikationer</string>
|
||||
<string name="bookmark_picker_name">Bokmärken</string>
|
||||
<string name="button_add_calendar">Lägg till i kalender</string>
|
||||
|
@ -15,7 +15,6 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
<string name="app_picker_name">Applications</string>
|
||||
<string name="bookmark_picker_name">Bookmarks</string>
|
||||
<string name="button_add_calendar">Add to calendar</string>
|
||||
@ -113,8 +112,6 @@
|
||||
<string name="preferences_result_title">Result settings</string>
|
||||
<string name="preferences_scanning_title">When scanning for barcodes, decode\u2026</string>
|
||||
<string name="preferences_search_country">Search country</string>
|
||||
<string name="preferences_try_bsplus">Try Barcode Scanner+</string>
|
||||
<string name="preferences_try_bsplus_summary">Enhanced with new features and interface</string>
|
||||
<string name="preferences_supplemental_summary">Try to retrieve more information about the barcode contents</string>
|
||||
<string name="preferences_supplemental_title">Retrieve more info</string>
|
||||
<string name="preferences_vibrate_title">Vibrate</string>
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">QR Plugin for KP2A</string>
|
||||
<string name="title_activity_qr">QRActivity</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
@ -12,5 +11,11 @@
|
||||
<string name="kp2aplugin_author">Philipp Crocoll</string>
|
||||
<string name="title_activity_main">MainActivity</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="scan_qr">Scan QR code from other device</string>
|
||||
<string name="show_qr">Select entry to show as QR code</string>
|
||||
<string name="no_host_app">No host app detected! Please install Keepass2Android from Google Play!</string>
|
||||
<string name="not_enabled_as_plugin">Not enabled as plugin in host app!</string>
|
||||
<string name="enabled_as_plugin">Enabled as plugin!</string>
|
||||
<string name="enable_as_plugin">Enable as plugin</string>
|
||||
|
||||
</resources>
|
||||
|
@ -38,26 +38,6 @@
|
||||
android:key="preferences_vibrate"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_vibrate_title"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_copy_to_clipboard"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_copy_to_clipboard_title"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_remember_duplicates"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_remember_duplicates_title"
|
||||
android:summary="@string/preferences_remember_duplicates_summary"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_supplemental"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_supplemental_title"
|
||||
android:summary="@string/preferences_supplemental_summary"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_result_title">
|
||||
<EditTextPreference
|
||||
android:key="preferences_custom_product_search"
|
||||
android:title="@string/preferences_custom_product_search_title"
|
||||
android:summary="@string/preferences_custom_product_search_summary"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_general_title">
|
||||
<ListPreference
|
||||
@ -76,17 +56,7 @@
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_invert_scan_title"
|
||||
android:summary="@string/preferences_invert_scan_summary"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_bulk_mode"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_bulk_mode_title"
|
||||
android:summary="@string/preferences_bulk_mode_summary"/>
|
||||
<ListPreference
|
||||
android:key="preferences_search_country"
|
||||
android:defaultValue="-"
|
||||
android:entries="@array/country_codes"
|
||||
android:entryValues="@array/country_codes"
|
||||
android:title="@string/preferences_search_country"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_device_bug_workarounds_title">
|
||||
<CheckBoxPreference
|
||||
@ -101,10 +71,4 @@
|
||||
android:title="@string/preferences_disable_exposure_title"/>
|
||||
-->
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_try_bsplus">
|
||||
<Preference android:title="@string/preferences_try_bsplus"
|
||||
android:summary="@string/preferences_try_bsplus_summary">
|
||||
<intent android:action="android.intent.action.VIEW" android:data="market://details?id=com.srowen.bs.android" />
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
@ -22,15 +22,9 @@ import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.client.android.camera.CameraManager;
|
||||
import com.google.zxing.client.android.clipboard.ClipboardInterface;
|
||||
import com.google.zxing.client.android.history.HistoryActivity;
|
||||
import com.google.zxing.client.android.history.HistoryItem;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import com.google.zxing.client.android.result.ResultButtonListener;
|
||||
import com.google.zxing.client.android.result.ResultHandler;
|
||||
import com.google.zxing.client.android.result.ResultHandlerFactory;
|
||||
import com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever;
|
||||
import com.google.zxing.client.android.share.ShareActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@ -110,7 +104,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||
private Collection<BarcodeFormat> decodeFormats;
|
||||
private Map<DecodeHintType,?> decodeHints;
|
||||
private String characterSet;
|
||||
private HistoryManager historyManager;
|
||||
private InactivityTimer inactivityTimer;
|
||||
private BeepManager beepManager;
|
||||
private AmbientLightManager ambientLightManager;
|
||||
@ -136,8 +129,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||
setContentView(R.layout.capture);
|
||||
|
||||
hasSurface = false;
|
||||
historyManager = new HistoryManager(this);
|
||||
historyManager.trimHistory();
|
||||
inactivityTimer = new InactivityTimer(this);
|
||||
beepManager = new BeepManager(this);
|
||||
ambientLightManager = new AmbientLightManager(this);
|
||||
@ -185,9 +176,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||
Intent intent = getIntent();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true)
|
||||
&& (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true));
|
||||
|
||||
|
||||
source = IntentSource.NONE;
|
||||
decodeFormats = null;
|
||||
characterSet = null;
|
||||
@ -325,29 +314,12 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||
intent.setClassName(this, PreferencesActivity.class.getName());
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.menu_help:
|
||||
intent.setClassName(this, HelpActivity.class.getName());
|
||||
startActivity(intent);
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == HISTORY_REQUEST_CODE) {
|
||||
int itemNumber = intent.getIntExtra(Intents.History.ITEM_NUMBER, -1);
|
||||
if (itemNumber >= 0) {
|
||||
HistoryItem historyItem = historyManager.buildHistoryItem(itemNumber);
|
||||
decodeOrStoreSavedBitmap(null, historyItem.getResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) {
|
||||
// Bitmap isn't used yet -- will be used soon
|
||||
if (handler == null) {
|
||||
@ -399,7 +371,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||
|
||||
boolean fromLiveScan = barcode != null;
|
||||
if (fromLiveScan) {
|
||||
historyManager.addHistoryItem(rawResult, resultHandler);
|
||||
// Then not from history, so beep/vibrate and we have an image to draw on
|
||||
beepManager.playBeepSoundAndVibrate();
|
||||
drawResultPoints(barcode, scaleFactor, rawResult);
|
||||
@ -530,13 +501,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||
TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
|
||||
supplementTextView.setText("");
|
||||
supplementTextView.setOnClickListener(null);
|
||||
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
|
||||
PreferencesActivity.KEY_SUPPLEMENTAL, true)) {
|
||||
SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView,
|
||||
resultHandler.getResult(),
|
||||
historyManager,
|
||||
this);
|
||||
}
|
||||
|
||||
|
||||
int buttonCount = resultHandler.getButtonCount();
|
||||
ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view);
|
||||
@ -552,9 +517,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||
}
|
||||
}
|
||||
|
||||
if (copyToClipboard && !resultHandler.areContentsSecure()) {
|
||||
ClipboardInterface.setText(displayContents, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Briefly show the contents of the barcode, then handle the result outside Barcode Scanner.
|
||||
@ -580,11 +543,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||
statusView.setText(getString(resultHandler.getDisplayTitle()) + " : " + rawResultString);
|
||||
}
|
||||
|
||||
if (copyToClipboard && !resultHandler.areContentsSecure()) {
|
||||
CharSequence text = resultHandler.getDisplayContents();
|
||||
ClipboardInterface.setText(text, this);
|
||||
}
|
||||
|
||||
if (source == IntentSource.NATIVE_APP_INTENT) {
|
||||
|
||||
// Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
|
||||
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 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.google.zxing.client.android;
|
||||
|
||||
import keepass2android.plugin.qr.R;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.webkit.WebView;
|
||||
|
||||
/**
|
||||
* An HTML-based help screen.
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
public final class HelpActivity extends Activity {
|
||||
|
||||
private static final String BASE_URL =
|
||||
"file:///android_asset/html-" + LocaleManager.getTranslatedAssetLanguage() + '/';
|
||||
|
||||
private WebView webView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
setContentView(R.layout.help);
|
||||
|
||||
webView = (WebView) findViewById(R.id.help_contents);
|
||||
|
||||
if (icicle == null) {
|
||||
webView.loadUrl(BASE_URL + "index.html");
|
||||
} else {
|
||||
webView.restoreState(icicle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle state) {
|
||||
String url = webView.getUrl();
|
||||
if (url != null && !url.isEmpty()) {
|
||||
webView.saveState(state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) {
|
||||
webView.goBack();
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.google.zxing.client.android.clipboard;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
public final class ClipboardInterface {
|
||||
|
||||
private static final String TAG = ClipboardInterface.class.getSimpleName();
|
||||
|
||||
private ClipboardInterface() {
|
||||
}
|
||||
|
||||
public static CharSequence getText(Context context) {
|
||||
ClipboardManager clipboard = getManager(context);
|
||||
ClipData clip = clipboard.getPrimaryClip();
|
||||
return hasText(context) ? clip.getItemAt(0).coerceToText(context) : null;
|
||||
}
|
||||
|
||||
public static void setText(CharSequence text, Context context) {
|
||||
if (text != null) {
|
||||
try {
|
||||
getManager(context).setPrimaryClip(ClipData.newPlainText(null, text));
|
||||
} catch (NullPointerException npe) {
|
||||
// Have seen this in the wild, bizarrely
|
||||
Log.w(TAG, "Clipboard bug", npe);
|
||||
} catch (IllegalStateException ise) {
|
||||
// java.lang.IllegalStateException: beginBroadcast() called while already in a broadcast
|
||||
Log.w(TAG, "Clipboard bug", ise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasText(Context context) {
|
||||
ClipboardManager clipboard = getManager(context);
|
||||
ClipData clip = clipboard.getPrimaryClip();
|
||||
return clip != null && clip.getItemCount() > 0;
|
||||
}
|
||||
|
||||
private static ClipboardManager getManager(Context context) {
|
||||
return (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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.google.zxing.client.android.history;
|
||||
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* @author Sean Owen
|
||||
*/
|
||||
final class DBHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final int DB_VERSION = 5;
|
||||
private static final String DB_NAME = "barcode_scanner_history.db";
|
||||
static final String TABLE_NAME = "history";
|
||||
static final String ID_COL = "id";
|
||||
static final String TEXT_COL = "text";
|
||||
static final String FORMAT_COL = "format";
|
||||
static final String DISPLAY_COL = "display";
|
||||
static final String TIMESTAMP_COL = "timestamp";
|
||||
static final String DETAILS_COL = "details";
|
||||
|
||||
DBHelper(Context context) {
|
||||
super(context, DB_NAME, null, DB_VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase sqLiteDatabase) {
|
||||
sqLiteDatabase.execSQL(
|
||||
"CREATE TABLE " + TABLE_NAME + " (" +
|
||||
ID_COL + " INTEGER PRIMARY KEY, " +
|
||||
TEXT_COL + " TEXT, " +
|
||||
FORMAT_COL + " TEXT, " +
|
||||
DISPLAY_COL + " TEXT, " +
|
||||
TIMESTAMP_COL + " INTEGER, " +
|
||||
DETAILS_COL + " TEXT);");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
|
||||
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||
onCreate(sqLiteDatabase);
|
||||
}
|
||||
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 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.google.zxing.client.android.history;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ListActivity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import com.google.zxing.client.android.CaptureActivity;
|
||||
import com.google.zxing.client.android.Intents;
|
||||
import keepass2android.plugin.qr.R;
|
||||
|
||||
public final class HistoryActivity extends ListActivity {
|
||||
|
||||
private static final String TAG = HistoryActivity.class.getSimpleName();
|
||||
|
||||
private HistoryManager historyManager;
|
||||
private ArrayAdapter<HistoryItem> adapter;
|
||||
private CharSequence originalTitle;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
this.historyManager = new HistoryManager(this);
|
||||
adapter = new HistoryItemAdapter(this);
|
||||
setListAdapter(adapter);
|
||||
View listview = getListView();
|
||||
registerForContextMenu(listview);
|
||||
originalTitle = getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
reloadHistoryItems();
|
||||
}
|
||||
|
||||
private void reloadHistoryItems() {
|
||||
Iterable<HistoryItem> items = historyManager.buildHistoryItems();
|
||||
adapter.clear();
|
||||
for (HistoryItem item : items) {
|
||||
adapter.add(item);
|
||||
}
|
||||
setTitle(originalTitle + " (" + adapter.getCount() + ')');
|
||||
if (adapter.isEmpty()) {
|
||||
adapter.add(new HistoryItem(null, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
if (adapter.getItem(position).getResult() != null) {
|
||||
Intent intent = new Intent(this, CaptureActivity.class);
|
||||
intent.putExtra(Intents.History.ITEM_NUMBER, position);
|
||||
setResult(Activity.RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu,
|
||||
View v,
|
||||
ContextMenu.ContextMenuInfo menuInfo) {
|
||||
int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position;
|
||||
if (position >= adapter.getCount() || adapter.getItem(position).getResult() != null) {
|
||||
menu.add(Menu.NONE, position, position, R.string.history_clear_one_history_text);
|
||||
} // else it's just that dummy "Empty" message
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
int position = item.getItemId();
|
||||
historyManager.deleteHistoryItem(position);
|
||||
reloadHistoryItems();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if (historyManager.hasHistoryItems()) {
|
||||
MenuInflater menuInflater = getMenuInflater();
|
||||
menuInflater.inflate(R.menu.history, menu);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_history_send:
|
||||
CharSequence history = historyManager.buildHistory();
|
||||
Parcelable historyFile = HistoryManager.saveHistory(history.toString());
|
||||
if (historyFile == null) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(R.string.msg_unmount_usb);
|
||||
builder.setPositiveButton(R.string.button_ok, null);
|
||||
builder.show();
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
String subject = getResources().getString(R.string.history_email_title);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, subject);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, historyFile);
|
||||
intent.setType("text/csv");
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException anfe) {
|
||||
Log.w(TAG, anfe.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case R.id.menu_history_clear_text:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(R.string.msg_sure);
|
||||
builder.setCancelable(true);
|
||||
builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int i2) {
|
||||
historyManager.clearHistory();
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.button_cancel, null);
|
||||
builder.show();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 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.google.zxing.client.android.history;
|
||||
|
||||
import com.google.zxing.Result;
|
||||
|
||||
public final class HistoryItem {
|
||||
|
||||
private final Result result;
|
||||
private final String display;
|
||||
private final String details;
|
||||
|
||||
HistoryItem(Result result, String display, String details) {
|
||||
this.result = result;
|
||||
this.display = display;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getDisplayAndDetails() {
|
||||
StringBuilder displayResult = new StringBuilder();
|
||||
if (display == null || display.isEmpty()) {
|
||||
displayResult.append(result.getText());
|
||||
} else {
|
||||
displayResult.append(display);
|
||||
}
|
||||
if (details != null && !details.isEmpty()) {
|
||||
displayResult.append(" : ").append(details);
|
||||
}
|
||||
return displayResult.toString();
|
||||
}
|
||||
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 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.google.zxing.client.android.history;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.Result;
|
||||
import keepass2android.plugin.qr.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
final class HistoryItemAdapter extends ArrayAdapter<HistoryItem> {
|
||||
|
||||
private final Context activity;
|
||||
|
||||
HistoryItemAdapter(Context activity) {
|
||||
super(activity, R.layout.history_list_item, new ArrayList<HistoryItem>());
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup viewGroup) {
|
||||
View layout;
|
||||
if (view instanceof LinearLayout) {
|
||||
layout = view;
|
||||
} else {
|
||||
LayoutInflater factory = LayoutInflater.from(activity);
|
||||
layout = factory.inflate(R.layout.history_list_item, viewGroup, false);
|
||||
}
|
||||
|
||||
HistoryItem item = getItem(position);
|
||||
Result result = item.getResult();
|
||||
|
||||
CharSequence title;
|
||||
CharSequence detail;
|
||||
if (result != null) {
|
||||
title = result.getText();
|
||||
detail = item.getDisplayAndDetails();
|
||||
} else {
|
||||
Resources resources = getContext().getResources();
|
||||
title = resources.getString(R.string.history_empty);
|
||||
detail = resources.getString(R.string.history_empty_detail);
|
||||
}
|
||||
|
||||
((TextView) layout.findViewById(R.id.history_title)).setText(title);
|
||||
((TextView) layout.findViewById(R.id.history_detail)).setText(detail);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
}
|
@ -1,363 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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.google.zxing.client.android.history;
|
||||
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.client.android.Intents;
|
||||
import com.google.zxing.client.android.PreferencesActivity;
|
||||
import com.google.zxing.client.android.result.ResultHandler;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentValues;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Manages functionality related to scan history.</p>
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
public final class HistoryManager {
|
||||
|
||||
private static final String TAG = HistoryManager.class.getSimpleName();
|
||||
|
||||
private static final int MAX_ITEMS = 2000;
|
||||
|
||||
private static final String[] COLUMNS = {
|
||||
DBHelper.TEXT_COL,
|
||||
DBHelper.DISPLAY_COL,
|
||||
DBHelper.FORMAT_COL,
|
||||
DBHelper.TIMESTAMP_COL,
|
||||
DBHelper.DETAILS_COL,
|
||||
};
|
||||
|
||||
private static final String[] COUNT_COLUMN = { "COUNT(1)" };
|
||||
|
||||
private static final String[] ID_COL_PROJECTION = { DBHelper.ID_COL };
|
||||
private static final String[] ID_DETAIL_COL_PROJECTION = { DBHelper.ID_COL, DBHelper.DETAILS_COL };
|
||||
private static final DateFormat EXPORT_DATE_TIME_FORMAT =
|
||||
DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
|
||||
|
||||
private final Activity activity;
|
||||
|
||||
public HistoryManager(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public boolean hasHistoryItems() {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
db = helper.getReadableDatabase();
|
||||
cursor = db.query(DBHelper.TABLE_NAME, COUNT_COLUMN, null, null, null, null, null);
|
||||
cursor.moveToFirst();
|
||||
return cursor.getInt(0) > 0;
|
||||
} finally {
|
||||
close(cursor, db);
|
||||
}
|
||||
}
|
||||
|
||||
public List<HistoryItem> buildHistoryItems() {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
List<HistoryItem> items = new ArrayList<HistoryItem>();
|
||||
SQLiteDatabase db = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
db = helper.getReadableDatabase();
|
||||
cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
|
||||
while (cursor.moveToNext()) {
|
||||
String text = cursor.getString(0);
|
||||
String display = cursor.getString(1);
|
||||
String format = cursor.getString(2);
|
||||
long timestamp = cursor.getLong(3);
|
||||
String details = cursor.getString(4);
|
||||
Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
|
||||
items.add(new HistoryItem(result, display, details));
|
||||
}
|
||||
} finally {
|
||||
close(cursor, db);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public HistoryItem buildHistoryItem(int number) {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
db = helper.getReadableDatabase();
|
||||
cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null, DBHelper.TIMESTAMP_COL + " DESC");
|
||||
cursor.move(number + 1);
|
||||
String text = cursor.getString(0);
|
||||
String display = cursor.getString(1);
|
||||
String format = cursor.getString(2);
|
||||
long timestamp = cursor.getLong(3);
|
||||
String details = cursor.getString(4);
|
||||
Result result = new Result(text, null, null, BarcodeFormat.valueOf(format), timestamp);
|
||||
return new HistoryItem(result, display, details);
|
||||
} finally {
|
||||
close(cursor, db);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteHistoryItem(int number) {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
cursor = db.query(DBHelper.TABLE_NAME,
|
||||
ID_COL_PROJECTION,
|
||||
null, null, null, null,
|
||||
DBHelper.TIMESTAMP_COL + " DESC");
|
||||
cursor.move(number + 1);
|
||||
db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + cursor.getString(0), null);
|
||||
} finally {
|
||||
close(cursor, db);
|
||||
}
|
||||
}
|
||||
|
||||
public void addHistoryItem(Result result, ResultHandler handler) {
|
||||
// Do not save this item to the history if the preference is turned off, or the contents are
|
||||
// considered secure.
|
||||
if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
|
||||
handler.areContentsSecure()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
|
||||
deletePrevious(result.getText());
|
||||
}
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(DBHelper.TEXT_COL, result.getText());
|
||||
values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
|
||||
values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
|
||||
values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());
|
||||
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
// Insert the new entry into the DB.
|
||||
db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
|
||||
} finally {
|
||||
close(null, db);
|
||||
}
|
||||
}
|
||||
|
||||
public void addHistoryItemDetails(String itemID, String itemDetails) {
|
||||
// As we're going to do an update only we don't need need to worry
|
||||
// about the preferences; if the item wasn't saved it won't be udpated
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
cursor = db.query(DBHelper.TABLE_NAME,
|
||||
ID_DETAIL_COL_PROJECTION,
|
||||
DBHelper.TEXT_COL + "=?",
|
||||
new String[] { itemID },
|
||||
null,
|
||||
null,
|
||||
DBHelper.TIMESTAMP_COL + " DESC",
|
||||
"1");
|
||||
String oldID = null;
|
||||
String oldDetails = null;
|
||||
if (cursor.moveToNext()) {
|
||||
oldID = cursor.getString(0);
|
||||
oldDetails = cursor.getString(1);
|
||||
}
|
||||
|
||||
if (oldID != null) {
|
||||
String newDetails;
|
||||
if (oldDetails == null) {
|
||||
newDetails = itemDetails;
|
||||
} else if (oldDetails.contains(itemDetails)) {
|
||||
newDetails = null;
|
||||
} else {
|
||||
newDetails = oldDetails + " : " + itemDetails;
|
||||
}
|
||||
if (newDetails != null) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(DBHelper.DETAILS_COL, newDetails);
|
||||
db.update(DBHelper.TABLE_NAME, values, DBHelper.ID_COL + "=?", new String[] { oldID });
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
close(cursor, db);
|
||||
}
|
||||
}
|
||||
|
||||
private void deletePrevious(String text) {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
db.delete(DBHelper.TABLE_NAME, DBHelper.TEXT_COL + "=?", new String[] { text });
|
||||
} finally {
|
||||
close(null, db);
|
||||
}
|
||||
}
|
||||
|
||||
public void trimHistory() {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
cursor = db.query(DBHelper.TABLE_NAME,
|
||||
ID_COL_PROJECTION,
|
||||
null, null, null, null,
|
||||
DBHelper.TIMESTAMP_COL + " DESC");
|
||||
cursor.move(MAX_ITEMS);
|
||||
while (cursor.moveToNext()) {
|
||||
String id = cursor.getString(0);
|
||||
Log.i(TAG, "Deleting scan history ID " + id);
|
||||
db.delete(DBHelper.TABLE_NAME, DBHelper.ID_COL + '=' + id, null);
|
||||
}
|
||||
} catch (SQLiteException sqle) {
|
||||
// We're seeing an error here when called in CaptureActivity.onCreate() in rare cases
|
||||
// and don't understand it. First theory is that it's transient so can be safely ignored.
|
||||
Log.w(TAG, sqle);
|
||||
// continue
|
||||
} finally {
|
||||
close(cursor, db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Builds a text representation of the scanning history. Each scan is encoded on one
|
||||
* line, terminated by a line break (\r\n). The values in each line are comma-separated,
|
||||
* and double-quoted. Double-quotes within values are escaped with a sequence of two
|
||||
* double-quotes. The fields output are:</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>Raw text</li>
|
||||
* <li>Display text</li>
|
||||
* <li>Format (e.g. QR_CODE)</li>
|
||||
* <li>Timestamp</li>
|
||||
* <li>Formatted version of timestamp</li>
|
||||
* </ul>
|
||||
*/
|
||||
CharSequence buildHistory() {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
cursor = db.query(DBHelper.TABLE_NAME,
|
||||
COLUMNS,
|
||||
null, null, null, null,
|
||||
DBHelper.TIMESTAMP_COL + " DESC");
|
||||
|
||||
StringBuilder historyText = new StringBuilder(1000);
|
||||
while (cursor.moveToNext()) {
|
||||
|
||||
historyText.append('"').append(massageHistoryField(cursor.getString(0))).append("\",");
|
||||
historyText.append('"').append(massageHistoryField(cursor.getString(1))).append("\",");
|
||||
historyText.append('"').append(massageHistoryField(cursor.getString(2))).append("\",");
|
||||
historyText.append('"').append(massageHistoryField(cursor.getString(3))).append("\",");
|
||||
|
||||
// Add timestamp again, formatted
|
||||
long timestamp = cursor.getLong(3);
|
||||
historyText.append('"').append(massageHistoryField(
|
||||
EXPORT_DATE_TIME_FORMAT.format(new Date(timestamp)))).append("\",");
|
||||
|
||||
// Above we're preserving the old ordering of columns which had formatted data in position 5
|
||||
|
||||
historyText.append('"').append(massageHistoryField(cursor.getString(4))).append("\"\r\n");
|
||||
}
|
||||
return historyText;
|
||||
} finally {
|
||||
close(cursor, db);
|
||||
}
|
||||
}
|
||||
|
||||
void clearHistory() {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = null;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
db.delete(DBHelper.TABLE_NAME, null, null);
|
||||
} finally {
|
||||
close(null, db);
|
||||
}
|
||||
}
|
||||
|
||||
static Uri saveHistory(String history) {
|
||||
File bsRoot = new File(Environment.getExternalStorageDirectory(), "BarcodeScanner");
|
||||
File historyRoot = new File(bsRoot, "History");
|
||||
if (!historyRoot.exists() && !historyRoot.mkdirs()) {
|
||||
Log.w(TAG, "Couldn't make dir " + historyRoot);
|
||||
return null;
|
||||
}
|
||||
File historyFile = new File(historyRoot, "history-" + System.currentTimeMillis() + ".csv");
|
||||
OutputStreamWriter out = null;
|
||||
try {
|
||||
out = new OutputStreamWriter(new FileOutputStream(historyFile), Charset.forName("UTF-8"));
|
||||
out.write(history);
|
||||
return Uri.parse("file://" + historyFile.getAbsolutePath());
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, "Couldn't access file " + historyFile + " due to " + ioe);
|
||||
return null;
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ioe) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String massageHistoryField(String value) {
|
||||
return value == null ? "" : value.replace("\"","\"\"");
|
||||
}
|
||||
|
||||
private static void close(Cursor cursor, SQLiteDatabase database) {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
if (database != null) {
|
||||
database.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 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.google.zxing.client.android.result.supplement;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.LocaleManager;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
/**
|
||||
* @author Sean Owen
|
||||
*/
|
||||
final class AmazonInfoRetriever extends SupplementalInfoRetriever {
|
||||
|
||||
private final String type;
|
||||
private final String productID;
|
||||
private final String country;
|
||||
|
||||
AmazonInfoRetriever(TextView textView,
|
||||
String type,
|
||||
String productID,
|
||||
HistoryManager historyManager,
|
||||
Context context) {
|
||||
super(textView, historyManager);
|
||||
String country = LocaleManager.getCountry(context);
|
||||
if ("ISBN".equals(type) && !Locale.US.getCountry().equals(country)) {
|
||||
type = "EAN";
|
||||
}
|
||||
this.type = type;
|
||||
this.productID = productID;
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
void retrieveSupplementalInfo() throws IOException {
|
||||
boolean success = doRetrieveForCountry(country);
|
||||
if (!success && !"US".equals(country)) {
|
||||
// Also show US results to expand scope of results
|
||||
doRetrieveForCountry("US");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean doRetrieveForCountry(String theCountry) throws IOException {
|
||||
|
||||
CharSequence contents =
|
||||
HttpHelper.downloadViaHttp("https://bsplus.srowen.com/ss?c=" + theCountry + "&t=" + type + "&i=" + productID,
|
||||
HttpHelper.ContentType.XML);
|
||||
|
||||
String detailPageURL = null;
|
||||
Collection<String> authors = new ArrayList<String>();
|
||||
String title = null;
|
||||
String formattedNewPrice = null;
|
||||
String formattedUsedPrice = null;
|
||||
boolean error = false;
|
||||
|
||||
try {
|
||||
XmlPullParser xpp = buildParser(contents);
|
||||
|
||||
boolean seenItem = false;
|
||||
boolean seenLowestNewPrice = false;
|
||||
boolean seenLowestUsedPrice = false;
|
||||
|
||||
for (int eventType = xpp.getEventType(); eventType != XmlPullParser.END_DOCUMENT; eventType = xpp.next()) {
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
String name = xpp.getName();
|
||||
if ("Item".equals(name)) {
|
||||
if (seenItem) {
|
||||
break;
|
||||
} else {
|
||||
seenItem = true;
|
||||
}
|
||||
} else if ("DetailPageURL".equals(name)) {
|
||||
assertTextNext(xpp);
|
||||
detailPageURL = xpp.getText();
|
||||
} else if ("Author".equals(name)) {
|
||||
assertTextNext(xpp);
|
||||
authors.add(xpp.getText());
|
||||
} else if ("Title".equals(name)) {
|
||||
assertTextNext(xpp);
|
||||
title = xpp.getText();
|
||||
} else if ("LowestNewPrice".equals(name)) {
|
||||
seenLowestNewPrice = true;
|
||||
seenLowestUsedPrice = false;
|
||||
} else if ("LowestUsedPrice".equals(name)) {
|
||||
seenLowestNewPrice = false;
|
||||
seenLowestUsedPrice = true;
|
||||
} else if ("FormattedPrice".equals(name)) {
|
||||
if (seenLowestNewPrice || seenLowestUsedPrice) {
|
||||
assertTextNext(xpp);
|
||||
String theText = xpp.getText();
|
||||
if (seenLowestNewPrice) {
|
||||
formattedNewPrice = theText;
|
||||
} else {
|
||||
formattedUsedPrice = theText;
|
||||
}
|
||||
seenLowestNewPrice = false;
|
||||
seenLowestUsedPrice = false;
|
||||
}
|
||||
} else if ("Errors".equals(name)) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (XmlPullParserException xppe) {
|
||||
throw new IOException(xppe);
|
||||
}
|
||||
|
||||
if (error || detailPageURL == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Collection<String> newTexts = new ArrayList<String>();
|
||||
maybeAddText(title, newTexts);
|
||||
maybeAddTextSeries(authors, newTexts);
|
||||
if (formattedNewPrice != null) {
|
||||
maybeAddText(formattedNewPrice, newTexts);
|
||||
} else if (formattedUsedPrice != null) {
|
||||
maybeAddText(formattedUsedPrice, newTexts);
|
||||
}
|
||||
|
||||
append(productID, "Amazon " + theCountry, newTexts.toArray(new String[newTexts.size()]), detailPageURL);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void assertTextNext(XmlPullParser xpp) throws XmlPullParserException, IOException {
|
||||
if (xpp.next() != XmlPullParser.TEXT) {
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
|
||||
private static XmlPullParser buildParser(CharSequence contents) throws XmlPullParserException {
|
||||
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
XmlPullParser xpp = factory.newPullParser();
|
||||
xpp.setInput(new StringReader(contents.toString()));
|
||||
return xpp;
|
||||
}
|
||||
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 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.google.zxing.client.android.result.supplement;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.LocaleManager;
|
||||
import keepass2android.plugin.qr.R;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
|
||||
/**
|
||||
* @author Kamil Kaczmarczyk
|
||||
* @author Sean Owen
|
||||
*/
|
||||
final class BookResultInfoRetriever extends SupplementalInfoRetriever {
|
||||
|
||||
private final String isbn;
|
||||
private final String source;
|
||||
private final Context context;
|
||||
|
||||
BookResultInfoRetriever(TextView textView, String isbn, HistoryManager historyManager, Context context) {
|
||||
super(textView, historyManager);
|
||||
this.isbn = isbn;
|
||||
this.source = context.getString(R.string.msg_google_books);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
void retrieveSupplementalInfo() throws IOException {
|
||||
|
||||
CharSequence contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn,
|
||||
HttpHelper.ContentType.JSON);
|
||||
|
||||
if (contents.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String title;
|
||||
String pages;
|
||||
Collection<String> authors = null;
|
||||
|
||||
try {
|
||||
|
||||
JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue();
|
||||
JSONArray items = topLevel.optJSONArray("items");
|
||||
if (items == null || items.isNull(0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo");
|
||||
if (volumeInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
title = volumeInfo.optString("title");
|
||||
pages = volumeInfo.optString("pageCount");
|
||||
|
||||
JSONArray authorsArray = volumeInfo.optJSONArray("authors");
|
||||
if (authorsArray != null && !authorsArray.isNull(0)) {
|
||||
authors = new ArrayList<String>(authorsArray.length());
|
||||
for (int i = 0; i < authorsArray.length(); i++) {
|
||||
authors.add(authorsArray.getString(i));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
Collection<String> newTexts = new ArrayList<String>();
|
||||
maybeAddText(title, newTexts);
|
||||
maybeAddTextSeries(authors, newTexts);
|
||||
maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts);
|
||||
|
||||
String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context)
|
||||
+ "/search?tbm=bks&source=zxing&q=";
|
||||
|
||||
append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn);
|
||||
}
|
||||
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import keepass2android.plugin.qr.R;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import com.google.zxing.client.android.LocaleManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* <p>Retrieves product information from Google Product search.</p>
|
||||
*
|
||||
* <p><strong>Please do not reuse this code.</strong> Using results in this way requires permission
|
||||
* from Google, and that is not granted to users via this project.</p>
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
final class ProductResultInfoRetriever extends SupplementalInfoRetriever {
|
||||
|
||||
private static final Pattern[] PRODUCT_NAME_PRICE_PATTERNS = {
|
||||
Pattern.compile(",event\\)\">([^<]+)</a></h3>.+<span class=psrp>([^<]+)</span>"),
|
||||
Pattern.compile("owb63p\">([^<]+).+zdi3pb\">([^<]+)"),
|
||||
};
|
||||
|
||||
private final String productID;
|
||||
private final String source;
|
||||
private final Context context;
|
||||
|
||||
ProductResultInfoRetriever(TextView textView, String productID, HistoryManager historyManager, Context context) {
|
||||
super(textView, historyManager);
|
||||
this.productID = productID;
|
||||
this.source = context.getString(R.string.msg_google_product);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
void retrieveSupplementalInfo() throws IOException {
|
||||
|
||||
String encodedProductID = URLEncoder.encode(productID, "UTF-8");
|
||||
String uri = "http://www.google." + LocaleManager.getProductSearchCountryTLD(context)
|
||||
+ "/m/products?ie=utf8&oe=utf8&scoring=p&source=zxing&q=" + encodedProductID;
|
||||
CharSequence content = HttpHelper.downloadViaHttp(uri, HttpHelper.ContentType.HTML);
|
||||
|
||||
for (Pattern p : PRODUCT_NAME_PRICE_PATTERNS) {
|
||||
Matcher matcher = p.matcher(content);
|
||||
if (matcher.find()) {
|
||||
append(productID,
|
||||
source,
|
||||
new String[] { unescapeHTML(matcher.group(1)), unescapeHTML(matcher.group(2)) },
|
||||
uri);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String unescapeHTML(String raw) {
|
||||
return Html.fromHtml(raw).toString();
|
||||
}
|
||||
|
||||
}
|
@ -1,192 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import com.google.zxing.client.result.ISBNParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.ProductParsedResult;
|
||||
import com.google.zxing.client.result.URIParsedResult;
|
||||
|
||||
public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,Object> {
|
||||
|
||||
private static final String TAG = "SupplementalInfo";
|
||||
|
||||
public static void maybeInvokeRetrieval(TextView textView,
|
||||
ParsedResult result,
|
||||
HistoryManager historyManager,
|
||||
Context context) {
|
||||
if (result instanceof URIParsedResult) {
|
||||
SupplementalInfoRetriever uriRetriever =
|
||||
new URIResultInfoRetriever(textView, (URIParsedResult) result, historyManager, context);
|
||||
uriRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
SupplementalInfoRetriever titleRetriever =
|
||||
new TitleRetriever(textView, (URIParsedResult) result, historyManager);
|
||||
titleRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else if (result instanceof ProductParsedResult) {
|
||||
ProductParsedResult productParsedResult = (ProductParsedResult) result;
|
||||
String productID = productParsedResult.getProductID();
|
||||
String normalizedProductID = productParsedResult.getNormalizedProductID();
|
||||
SupplementalInfoRetriever productRetriever =
|
||||
new ProductResultInfoRetriever(textView, productID, historyManager, context);
|
||||
productRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
switch (productID.length()) {
|
||||
case 12:
|
||||
SupplementalInfoRetriever upcInfoRetriever =
|
||||
new AmazonInfoRetriever(textView, "UPC", normalizedProductID, historyManager, context);
|
||||
upcInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
break;
|
||||
case 13:
|
||||
SupplementalInfoRetriever eanInfoRetriever =
|
||||
new AmazonInfoRetriever(textView, "EAN", normalizedProductID, historyManager, context);
|
||||
eanInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
break;
|
||||
}
|
||||
} else if (result instanceof ISBNParsedResult) {
|
||||
String isbn = ((ISBNParsedResult) result).getISBN();
|
||||
SupplementalInfoRetriever productInfoRetriever =
|
||||
new ProductResultInfoRetriever(textView, isbn, historyManager, context);
|
||||
productInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
SupplementalInfoRetriever bookInfoRetriever =
|
||||
new BookResultInfoRetriever(textView, isbn, historyManager, context);
|
||||
bookInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
SupplementalInfoRetriever amazonInfoRetriever =
|
||||
new AmazonInfoRetriever(textView, "ISBN", isbn, historyManager, context);
|
||||
amazonInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
private final WeakReference<TextView> textViewRef;
|
||||
private final WeakReference<HistoryManager> historyManagerRef;
|
||||
private final Collection<Spannable> newContents;
|
||||
private final Collection<String[]> newHistories;
|
||||
|
||||
SupplementalInfoRetriever(TextView textView, HistoryManager historyManager) {
|
||||
textViewRef = new WeakReference<TextView>(textView);
|
||||
historyManagerRef = new WeakReference<HistoryManager>(historyManager);
|
||||
newContents = new ArrayList<Spannable>();
|
||||
newHistories = new ArrayList<String[]>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object doInBackground(Object... args) {
|
||||
try {
|
||||
retrieveSupplementalInfo();
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onPostExecute(Object arg) {
|
||||
TextView textView = textViewRef.get();
|
||||
if (textView != null) {
|
||||
for (CharSequence content : newContents) {
|
||||
textView.append(content);
|
||||
}
|
||||
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
HistoryManager historyManager = historyManagerRef.get();
|
||||
if (historyManager != null) {
|
||||
for (String[] text : newHistories) {
|
||||
historyManager.addHistoryItemDetails(text[0], text[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract void retrieveSupplementalInfo() throws IOException;
|
||||
|
||||
final void append(String itemID, String source, String[] newTexts, String linkURL) {
|
||||
|
||||
StringBuilder newTextCombined = new StringBuilder();
|
||||
|
||||
if (source != null) {
|
||||
newTextCombined.append(source).append(' ');
|
||||
}
|
||||
|
||||
int linkStart = newTextCombined.length();
|
||||
|
||||
boolean first = true;
|
||||
for (String newText : newTexts) {
|
||||
if (first) {
|
||||
newTextCombined.append(newText);
|
||||
first = false;
|
||||
} else {
|
||||
newTextCombined.append(" [");
|
||||
newTextCombined.append(newText);
|
||||
newTextCombined.append(']');
|
||||
}
|
||||
}
|
||||
|
||||
int linkEnd = newTextCombined.length();
|
||||
|
||||
String newText = newTextCombined.toString();
|
||||
Spannable content = new SpannableString(newText + "\n\n");
|
||||
if (linkURL != null) {
|
||||
// Strangely, some Android browsers don't seem to register to handle HTTP:// or HTTPS://.
|
||||
// Lower-case these as it should always be OK to lower-case these schemes.
|
||||
if (linkURL.startsWith("HTTP://")) {
|
||||
linkURL = "http" + linkURL.substring(4);
|
||||
} else if (linkURL.startsWith("HTTPS://")) {
|
||||
linkURL = "https" + linkURL.substring(5);
|
||||
}
|
||||
content.setSpan(new URLSpan(linkURL), linkStart, linkEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
newContents.add(content);
|
||||
newHistories.add(new String[] {itemID, newText});
|
||||
}
|
||||
|
||||
static void maybeAddText(String text, Collection<String> texts) {
|
||||
if (text != null && !text.isEmpty()) {
|
||||
texts.add(text);
|
||||
}
|
||||
}
|
||||
|
||||
static void maybeAddTextSeries(Collection<String> textSeries, Collection<String> texts) {
|
||||
if (textSeries != null && !textSeries.isEmpty()) {
|
||||
boolean first = true;
|
||||
StringBuilder authorsText = new StringBuilder();
|
||||
for (String author : textSeries) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
authorsText.append(", ");
|
||||
}
|
||||
authorsText.append(author);
|
||||
}
|
||||
texts.add(authorsText.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 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.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import com.google.zxing.client.result.URIParsedResult;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Retrieves the title of a web page as supplemental info.
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
final class TitleRetriever extends SupplementalInfoRetriever {
|
||||
|
||||
private static final Pattern TITLE_PATTERN = Pattern.compile("<title>([^<]+)");
|
||||
private static final int MAX_TITLE_LEN = 100;
|
||||
|
||||
private final String httpUrl;
|
||||
|
||||
TitleRetriever(TextView textView, URIParsedResult result, HistoryManager historyManager) {
|
||||
super(textView, historyManager);
|
||||
this.httpUrl = result.getURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
void retrieveSupplementalInfo() {
|
||||
CharSequence contents;
|
||||
try {
|
||||
contents = HttpHelper.downloadViaHttp(httpUrl, HttpHelper.ContentType.HTML, 4096);
|
||||
} catch (IOException ioe) {
|
||||
// ignore this
|
||||
return;
|
||||
}
|
||||
if (contents != null && contents.length() > 0) {
|
||||
Matcher m = TITLE_PATTERN.matcher(contents);
|
||||
if (m.find()) {
|
||||
String title = m.group(1);
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.length() > MAX_TITLE_LEN) {
|
||||
title = title.substring(0, MAX_TITLE_LEN) + "...";
|
||||
}
|
||||
append(httpUrl, null, new String[] {title}, httpUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.google.zxing.client.android.result.supplement;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.HttpHelper;
|
||||
import com.google.zxing.client.android.history.HistoryManager;
|
||||
import keepass2android.plugin.qr.R;
|
||||
import com.google.zxing.client.result.URIParsedResult;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
final class URIResultInfoRetriever extends SupplementalInfoRetriever {
|
||||
|
||||
private static final int MAX_REDIRECTS = 5;
|
||||
|
||||
private final URIParsedResult result;
|
||||
private final String redirectString;
|
||||
|
||||
URIResultInfoRetriever(TextView textView, URIParsedResult result, HistoryManager historyManager, Context context) {
|
||||
super(textView, historyManager);
|
||||
redirectString = context.getString(R.string.msg_redirect);
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
void retrieveSupplementalInfo() throws IOException {
|
||||
URI oldURI;
|
||||
try {
|
||||
oldURI = new URI(result.getURI());
|
||||
} catch (URISyntaxException ignored) {
|
||||
return;
|
||||
}
|
||||
URI newURI = HttpHelper.unredirect(oldURI);
|
||||
int count = 0;
|
||||
while (count++ < MAX_REDIRECTS && !oldURI.equals(newURI)) {
|
||||
append(result.getDisplayResult(),
|
||||
null,
|
||||
new String[] { redirectString + " : " + newURI },
|
||||
newURI.toString());
|
||||
oldURI = newURI;
|
||||
newURI = HttpHelper.unredirect(newURI);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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.google.zxing.client.android.share;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
final class AppInfo implements Comparable<AppInfo> {
|
||||
|
||||
private final String packageName;
|
||||
private final String label;
|
||||
private final Drawable icon;
|
||||
|
||||
AppInfo(String packageName, String label, Drawable icon) {
|
||||
this.packageName = packageName;
|
||||
this.label = label;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(AppInfo another) {
|
||||
return label.compareTo(another.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return label.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof AppInfo)) {
|
||||
return false;
|
||||
}
|
||||
AppInfo another = (AppInfo) other;
|
||||
return label.equals(another.label);
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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.google.zxing.client.android.share;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.Browser;
|
||||
import android.view.View;
|
||||
import android.widget.Adapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
public final class AppPickerActivity extends ListActivity {
|
||||
|
||||
private AsyncTask<?,?,?> backgroundTask;
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
backgroundTask = new LoadPackagesAsyncTask(this);
|
||||
backgroundTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
AsyncTask<?,?,?> task = backgroundTask;
|
||||
if (task != null) {
|
||||
task.cancel(true);
|
||||
backgroundTask = null;
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View view, int position, long id) {
|
||||
Adapter adapter = getListAdapter();
|
||||
if (position >= 0 && position < adapter.getCount()) {
|
||||
String packageName = ((AppInfo) adapter.getItem(position)).getPackageName();
|
||||
Intent intent = new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.putExtra(Browser.BookmarkColumns.URL, "market://details?id=" + packageName);
|
||||
setResult(RESULT_OK, intent);
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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.google.zxing.client.android.share;
|
||||
|
||||
import keepass2android.plugin.qr.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* A custom adapter designed to fetch bookmarks from a cursor. Before Honeycomb we used
|
||||
* SimpleCursorAdapter, but it assumes the existence of an _id column, and the bookmark schema was
|
||||
* rewritten for HC without one. This caused the app to crash, hence this new class, which is
|
||||
* forwards and backwards compatible.
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
final class BookmarkAdapter extends BaseAdapter {
|
||||
private final Context context;
|
||||
private final Cursor cursor;
|
||||
|
||||
BookmarkAdapter(Context context, Cursor cursor) {
|
||||
this.context = context;
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return cursor.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int index) {
|
||||
// Not used, so no point in retrieving it.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int index) {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int index, View view, ViewGroup viewGroup) {
|
||||
View layout;
|
||||
if (view instanceof LinearLayout) {
|
||||
layout = view;
|
||||
} else {
|
||||
LayoutInflater factory = LayoutInflater.from(context);
|
||||
layout = factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false);
|
||||
}
|
||||
|
||||
if (!cursor.isClosed()) {
|
||||
cursor.moveToPosition(index);
|
||||
CharSequence title = cursor.getString(BookmarkPickerActivity.TITLE_COLUMN);
|
||||
((TextView) layout.findViewById(R.id.bookmark_title)).setText(title);
|
||||
CharSequence url = cursor.getString(BookmarkPickerActivity.URL_COLUMN);
|
||||
((TextView) layout.findViewById(R.id.bookmark_url)).setText(url);
|
||||
} // Otherwise... just don't update as the object is shutting down
|
||||
return layout;
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* 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.google.zxing.client.android.share;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Browser;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
/**
|
||||
* This class is only needed because I can't successfully send an ACTION_PICK intent to
|
||||
* com.android.browser.BrowserBookmarksPage. It can go away if that starts working in the future.
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
public final class BookmarkPickerActivity extends ListActivity {
|
||||
|
||||
private static final String TAG = BookmarkPickerActivity.class.getSimpleName();
|
||||
|
||||
private static final String[] BOOKMARK_PROJECTION = {
|
||||
Browser.BookmarkColumns.TITLE,
|
||||
Browser.BookmarkColumns.URL
|
||||
};
|
||||
|
||||
static final int TITLE_COLUMN = 0;
|
||||
static final int URL_COLUMN = 1;
|
||||
|
||||
private static final String BOOKMARK_SELECTION =
|
||||
Browser.BookmarkColumns.BOOKMARK + " = 1 AND " + Browser.BookmarkColumns.URL + " IS NOT NULL";
|
||||
|
||||
private Cursor cursor;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
cursor = getContentResolver().query(Browser.BOOKMARKS_URI, BOOKMARK_PROJECTION,
|
||||
BOOKMARK_SELECTION, null, null);
|
||||
if (cursor == null) {
|
||||
Log.w(TAG, "No cursor returned for bookmark query");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
setListAdapter(new BookmarkAdapter(this, cursor));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View view, int position, long id) {
|
||||
if (!cursor.isClosed() && cursor.moveToPosition(position)) {
|
||||
Intent intent = new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.putExtra(Browser.BookmarkColumns.TITLE, cursor.getString(TITLE_COLUMN));
|
||||
intent.putExtra(Browser.BookmarkColumns.URL, cursor.getString(URL_COLUMN));
|
||||
setResult(RESULT_OK, intent);
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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.google.zxing.client.android.share;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageItemInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import keepass2android.plugin.qr.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Loads a list of packages installed on the device asynchronously.
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
final class LoadPackagesAsyncTask extends AsyncTask<Void,Void,List<AppInfo>> {
|
||||
|
||||
private static final String[] PKG_PREFIX_WHITELIST = {
|
||||
"com.google.android.apps.",
|
||||
};
|
||||
private static final String[] PKG_PREFIX_BLACKLIST = {
|
||||
"com.android.",
|
||||
"android",
|
||||
"com.google.android.",
|
||||
"com.htc",
|
||||
};
|
||||
|
||||
private final ListActivity activity;
|
||||
|
||||
LoadPackagesAsyncTask(ListActivity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AppInfo> doInBackground(Void... objects) {
|
||||
List<AppInfo> labelsPackages = new ArrayList<AppInfo>();
|
||||
PackageManager packageManager = activity.getPackageManager();
|
||||
Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
|
||||
for (PackageItemInfo appInfo : appInfos) {
|
||||
String packageName = appInfo.packageName;
|
||||
if (!isHidden(packageName)) {
|
||||
CharSequence label = appInfo.loadLabel(packageManager);
|
||||
Drawable icon = appInfo.loadIcon(packageManager);
|
||||
if (label != null) {
|
||||
labelsPackages.add(new AppInfo(packageName, label.toString(), icon));
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(labelsPackages);
|
||||
return labelsPackages;
|
||||
}
|
||||
|
||||
private static boolean isHidden(String packageName) {
|
||||
if (packageName == null) {
|
||||
return true;
|
||||
}
|
||||
for (String prefix : PKG_PREFIX_WHITELIST) {
|
||||
if (packageName.startsWith(prefix)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (String prefix : PKG_PREFIX_BLACKLIST) {
|
||||
if (packageName.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final List<AppInfo> results) {
|
||||
ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity,
|
||||
R.layout.app_picker_list_item,
|
||||
R.id.app_picker_list_item_label,
|
||||
results) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = super.getView(position, convertView, parent);
|
||||
Drawable icon = results.get(position).getIcon();
|
||||
if (icon != null) {
|
||||
((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
};
|
||||
activity.setListAdapter(listAdapter);
|
||||
}
|
||||
|
||||
}
|
@ -1,298 +0,0 @@
|
||||
/*
|
||||
* 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.google.zxing.client.android.share;
|
||||
|
||||
import android.provider.ContactsContract;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.client.android.Contents;
|
||||
import com.google.zxing.client.android.Intents;
|
||||
import keepass2android.plugin.qr.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.BaseColumns;
|
||||
import android.provider.Browser;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import com.google.zxing.client.android.clipboard.ClipboardInterface;
|
||||
|
||||
/**
|
||||
* Barcode Scanner can share data like contacts and bookmarks by displaying a QR Code on screen,
|
||||
* such that another user can scan the barcode with their phone.
|
||||
*
|
||||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
public final class ShareActivity extends Activity {
|
||||
|
||||
private static final String TAG = ShareActivity.class.getSimpleName();
|
||||
|
||||
private static final int PICK_BOOKMARK = 0;
|
||||
private static final int PICK_CONTACT = 1;
|
||||
private static final int PICK_APP = 2;
|
||||
|
||||
private View clipboardButton;
|
||||
|
||||
private final Button.OnClickListener contactListener = new Button.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
startActivityForResult(intent, PICK_CONTACT);
|
||||
}
|
||||
};
|
||||
|
||||
private final Button.OnClickListener bookmarkListener = new Button.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.setClassName(ShareActivity.this, BookmarkPickerActivity.class.getName());
|
||||
startActivityForResult(intent, PICK_BOOKMARK);
|
||||
}
|
||||
};
|
||||
|
||||
private final Button.OnClickListener appListener = new Button.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.setClassName(ShareActivity.this, AppPickerActivity.class.getName());
|
||||
startActivityForResult(intent, PICK_APP);
|
||||
}
|
||||
};
|
||||
|
||||
private final Button.OnClickListener clipboardListener = new Button.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Should always be true, because we grey out the clipboard button in onResume() if it's empty
|
||||
CharSequence text = ClipboardInterface.getText(ShareActivity.this);
|
||||
if (text != null) {
|
||||
launchSearch(text.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final View.OnKeyListener textListener = new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View view, int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
String text = ((TextView) view).getText().toString();
|
||||
if (text != null && !text.isEmpty()) {
|
||||
launchSearch(text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private void launchSearch(String text) {
|
||||
Intent intent = new Intent(Intents.Encode.ACTION);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
|
||||
intent.putExtra(Intents.Encode.DATA, text);
|
||||
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
setContentView(R.layout.share);
|
||||
|
||||
findViewById(R.id.share_contact_button).setOnClickListener(contactListener);
|
||||
findViewById(R.id.share_bookmark_button).setOnClickListener(bookmarkListener);
|
||||
findViewById(R.id.share_app_button).setOnClickListener(appListener);
|
||||
clipboardButton = findViewById(R.id.share_clipboard_button);
|
||||
clipboardButton.setOnClickListener(clipboardListener);
|
||||
findViewById(R.id.share_text_view).setOnKeyListener(textListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
clipboardButton.setEnabled(ClipboardInterface.hasText(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
switch (requestCode) {
|
||||
case PICK_BOOKMARK:
|
||||
case PICK_APP:
|
||||
showTextAsBarcode(intent.getStringExtra(Browser.BookmarkColumns.URL));
|
||||
break;
|
||||
case PICK_CONTACT:
|
||||
// Data field is content://contacts/people/984
|
||||
showContactAsBarcode(intent.getData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showTextAsBarcode(String text) {
|
||||
Log.i(TAG, "Showing text as barcode: " + text);
|
||||
if (text == null) {
|
||||
return; // Show error?
|
||||
}
|
||||
Intent intent = new Intent(Intents.Encode.ACTION);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
|
||||
intent.putExtra(Intents.Encode.DATA, text);
|
||||
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a contact Uri and does the necessary database lookups to retrieve that person's info,
|
||||
* then sends an Encode intent to render it as a QR Code.
|
||||
*
|
||||
* @param contactUri A Uri of the form content://contacts/people/17
|
||||
*/
|
||||
private void showContactAsBarcode(Uri contactUri) {
|
||||
Log.i(TAG, "Showing contact URI as barcode: " + contactUri);
|
||||
if (contactUri == null) {
|
||||
return; // Show error?
|
||||
}
|
||||
ContentResolver resolver = getContentResolver();
|
||||
|
||||
Cursor cursor;
|
||||
try {
|
||||
// We're seeing about six reports a week of this exception although I don't understand why.
|
||||
cursor = resolver.query(contactUri, null, null, null, null);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return;
|
||||
}
|
||||
if (cursor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String id;
|
||||
String name;
|
||||
boolean hasPhone;
|
||||
try {
|
||||
if (!cursor.moveToFirst()) {
|
||||
return;
|
||||
}
|
||||
|
||||
id = cursor.getString(cursor.getColumnIndex(BaseColumns._ID));
|
||||
name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
|
||||
hasPhone = cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)) > 0;
|
||||
|
||||
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
// Don't require a name to be present, this contact might be just a phone number.
|
||||
Bundle bundle = new Bundle();
|
||||
if (name != null && !name.isEmpty()) {
|
||||
bundle.putString(ContactsContract.Intents.Insert.NAME, massageContactData(name));
|
||||
}
|
||||
|
||||
if (hasPhone) {
|
||||
Cursor phonesCursor = resolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
|
||||
null,
|
||||
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + '=' + id,
|
||||
null,
|
||||
null);
|
||||
if (phonesCursor != null) {
|
||||
try {
|
||||
int foundPhone = 0;
|
||||
int phonesNumberColumn = phonesCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
|
||||
while (phonesCursor.moveToNext() && foundPhone < Contents.PHONE_KEYS.length) {
|
||||
String number = phonesCursor.getString(phonesNumberColumn);
|
||||
if (number != null && !number.isEmpty()) {
|
||||
bundle.putString(Contents.PHONE_KEYS[foundPhone], massageContactData(number));
|
||||
}
|
||||
foundPhone++;
|
||||
}
|
||||
} finally {
|
||||
phonesCursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cursor methodsCursor = resolver.query(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_URI,
|
||||
null,
|
||||
ContactsContract.CommonDataKinds.StructuredPostal.CONTACT_ID + '=' + id,
|
||||
null,
|
||||
null);
|
||||
if (methodsCursor != null) {
|
||||
try {
|
||||
if (methodsCursor.moveToNext()) {
|
||||
String data = methodsCursor.getString(
|
||||
methodsCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS));
|
||||
if (data != null && !data.isEmpty()) {
|
||||
bundle.putString(ContactsContract.Intents.Insert.POSTAL, massageContactData(data));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
methodsCursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
Cursor emailCursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
||||
null,
|
||||
ContactsContract.CommonDataKinds.Email.CONTACT_ID + '=' + id,
|
||||
null,
|
||||
null);
|
||||
if (emailCursor != null) {
|
||||
try {
|
||||
int foundEmail = 0;
|
||||
int emailColumn = emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA);
|
||||
while (emailCursor.moveToNext() && foundEmail < Contents.EMAIL_KEYS.length) {
|
||||
String email = emailCursor.getString(emailColumn);
|
||||
if (email != null && !email.isEmpty()) {
|
||||
bundle.putString(Contents.EMAIL_KEYS[foundEmail], massageContactData(email));
|
||||
}
|
||||
foundEmail++;
|
||||
}
|
||||
} finally {
|
||||
emailCursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
Intent intent = new Intent(Intents.Encode.ACTION);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
intent.putExtra(Intents.Encode.TYPE, Contents.Type.CONTACT);
|
||||
intent.putExtra(Intents.Encode.DATA, bundle);
|
||||
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
|
||||
|
||||
Log.i(TAG, "Sending bundle for encoding: " + bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private static String massageContactData(String data) {
|
||||
// For now -- make sure we don't put newlines in shared contact data. It messes up
|
||||
// any known encoding of contact data. Replace with space.
|
||||
if (data.indexOf('\n') >= 0) {
|
||||
data = data.replace("\n", " ");
|
||||
}
|
||||
if (data.indexOf('\r') >= 0) {
|
||||
data = data.replace("\r", " ");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package keepass2android.plugin.qr;
|
||||
|
||||
import keepass2android.pluginsdk.AccessManager;
|
||||
|
||||
import com.google.zxing.client.android.CaptureActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
@ -7,12 +9,14 @@ import android.app.ActionBar;
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.os.Build;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
@ -47,29 +51,102 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
|
||||
if (requestCode == 0) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
String contents = intent.getStringExtra("SCAN_RESULT");
|
||||
Log.d("QR", contents);
|
||||
|
||||
// Toast.makeText(this, contents, Toast.LENGTH_SHORT).show();
|
||||
} else if (resultCode == RESULT_CANCELED) {
|
||||
// Handle cancel
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A placeholder fragment containing a simple view.
|
||||
*/
|
||||
public static class PlaceholderFragment extends Fragment {
|
||||
|
||||
private View mRootView;
|
||||
|
||||
public PlaceholderFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
mRootView.findViewById(R.id.progressBar1).setVisibility(View.GONE);
|
||||
if (AccessManager.getAllHostPackages(getActivity()).isEmpty())
|
||||
{
|
||||
((TextView)mRootView.findViewById(R.id.tvHostStatus)).setText(getString(R.string.not_enabled_as_plugin));
|
||||
mRootView.findViewById(R.id.btnConfigPlugins).setVisibility(View.VISIBLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
((TextView)mRootView.findViewById(R.id.tvHostStatus)).setText(getString(R.string.enabled_as_plugin));
|
||||
mRootView.findViewById(R.id.btnConfigPlugins).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_main, container,
|
||||
mRootView = inflater.inflate(R.layout.fragment_main, container,
|
||||
false);
|
||||
rootView.findViewById(R.id.hello).setOnClickListener(new OnClickListener() {
|
||||
|
||||
mRootView.findViewById(R.id.btnScanQRCode).setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivityForResult(new Intent(getActivity(), CaptureActivity.class), 0);
|
||||
mRootView.findViewById(R.id.progressBar1).setVisibility(View.VISIBLE);
|
||||
Intent i = new Intent(getActivity(), CaptureActivity.class);
|
||||
i.setAction("com.google.zxing.client.android.SCAN");
|
||||
getActivity().startActivityForResult(i, 0);
|
||||
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
|
||||
|
||||
mRootView.findViewById(R.id.btnShowQR).setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//todo
|
||||
Log.d("QR", "ShowqR");
|
||||
}
|
||||
});
|
||||
|
||||
mRootView.findViewById(R.id.btnConfigPlugins).setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try
|
||||
{
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return mRootView;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user