mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Merge pull request #296 from MicheleMas/master
Added the ability to disable history saving
This commit is contained in:
commit
500fe2f68f
|
@ -119,6 +119,8 @@
|
|||
<string name="preferences_play_beep_title">Suona</string>
|
||||
<string name="preferences_remember_duplicates_summary">Mantieni scansioni multiple del codice a barre nella stessa Cronologia</string>
|
||||
<string name="preferences_remember_duplicates_title">Ricorda duplicati</string>
|
||||
<string name="preferences_history_summary">Mantieni le tue scansioni nella Cronologia</string>
|
||||
<string name="preferences_history_title">Aggiungi alla Cronologia</string>
|
||||
<string name="preferences_result_title">Impostazioni risultato</string>
|
||||
<string name="preferences_scanning_title">Durante la scansione di codici a barre, decodifica\u2026</string>
|
||||
<string name="preferences_search_country">Cerca paese</string>
|
||||
|
|
|
@ -119,6 +119,8 @@
|
|||
<string name="preferences_play_beep_title">Beep</string>
|
||||
<string name="preferences_remember_duplicates_summary">Store multiple scans of the same barcode in History</string>
|
||||
<string name="preferences_remember_duplicates_title">Remember duplicates</string>
|
||||
<string name="preferences_history_summary">Store your scans in History</string>
|
||||
<string name="preferences_history_title">Add to History</string>
|
||||
<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>
|
||||
|
|
|
@ -63,6 +63,11 @@
|
|||
android:defaultValue="false"
|
||||
android:title="@string/preferences_remember_duplicates_title"
|
||||
android:summary="@string/preferences_remember_duplicates_summary"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_history"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_history_title"
|
||||
android:summary="@string/preferences_history_summary"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_supplemental"
|
||||
android:defaultValue="true"
|
||||
|
|
|
@ -136,8 +136,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);
|
||||
|
@ -148,6 +146,10 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// historyManager must be initialized here to update the history preference
|
||||
historyManager = new HistoryManager(this);
|
||||
historyManager.trimHistory();
|
||||
|
||||
// CameraManager must be initialized here, not in onCreate(). This is necessary because we don't
|
||||
// want to open the camera driver and measure the screen size if we're going to show the help on
|
||||
|
@ -292,6 +294,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
ambientLightManager.stop();
|
||||
beepManager.close();
|
||||
cameraManager.closeDriver();
|
||||
historyManager = null;
|
||||
if (!hasSurface) {
|
||||
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
|
||||
SurfaceHolder surfaceHolder = surfaceView.getHolder();
|
||||
|
|
|
@ -42,6 +42,7 @@ public final class PreferencesActivity extends Activity {
|
|||
public static final String KEY_FRONT_LIGHT_MODE = "preferences_front_light_mode";
|
||||
public static final String KEY_BULK_MODE = "preferences_bulk_mode";
|
||||
public static final String KEY_REMEMBER_DUPLICATES = "preferences_remember_duplicates";
|
||||
public static final String KEY_ENABLE_HISTORY = "preferences_history";
|
||||
public static final String KEY_SUPPLEMENTAL = "preferences_supplemental";
|
||||
public static final String KEY_AUTO_FOCUS = "preferences_auto_focus";
|
||||
public static final String KEY_INVERT_SCAN = "preferences_invert_scan";
|
||||
|
|
|
@ -69,9 +69,12 @@ public final class HistoryManager {
|
|||
private static final String[] ID_DETAIL_COL_PROJECTION = { DBHelper.ID_COL, DBHelper.DETAILS_COL };
|
||||
|
||||
private final Activity activity;
|
||||
private final boolean enableHistory;
|
||||
|
||||
public HistoryManager(Activity activity) {
|
||||
this.activity = activity;
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
enableHistory = prefs.getBoolean(PreferencesActivity.KEY_ENABLE_HISTORY, true);
|
||||
}
|
||||
|
||||
public boolean hasHistoryItems() {
|
||||
|
@ -152,7 +155,7 @@ public final class HistoryManager {
|
|||
// 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()) {
|
||||
handler.areContentsSecure() || !enableHistory) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue