Skip to content

Commit e742f3c

Browse files
committed
made showing hints configurable
1 parent bbe6437 commit e742f3c

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ allprojects {
2424
}
2525

2626
project.ext {
27-
sdkVersion='0.9.0-beta4'
27+
sdkVersion='0.9.0-beta5'
2828
versionCode=1
2929

3030
compileSdkVersion=28

ui-integration/src/main/java/io/snabble/sdk/ui/integration/SelfScanningFragment.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class SelfScanningFragment extends Fragment {
2929
private Button askForPermission;
3030
private boolean canAskAgain = false;
3131
private boolean isStart;
32+
private boolean allowShowingHints;
3233

3334
@Override
3435
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -69,10 +70,11 @@ public void onResume() {
6970
private void createSelfScanningView() {
7071
if(selfScanningView == null) {
7172
selfScanningView = new SelfScanningView(getContext());
73+
selfScanningView.setAllowShowingHints(allowShowingHints);
74+
7275
rootView.addView(selfScanningView);
7376
permissionContainer.setVisibility(View.GONE);
7477
canAskAgain = true;
75-
7678
handleBundleArgs();
7779
}
7880
}
@@ -127,6 +129,10 @@ public void click() {
127129
}
128130
}
129131

132+
public void setAllowShowingHints(boolean allowShowingHints) {
133+
this.allowShowingHints = allowShowingHints;
134+
}
135+
130136
public void goToSettings() {
131137
Intent intent = new Intent();
132138
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);

ui/src/main/java/io/snabble/sdk/ui/scanner/SelfScanningView.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class SelfScanningView extends CoordinatorLayout implements Checkout.OnCh
5656
private long detectAfterTimeMs;
5757
private boolean ignoreNextDialog;
5858
private ShoppingCart shoppingCart;
59+
private boolean allowShowingHints;
5960

6061
public SelfScanningView(Context context) {
6162
super(context);
@@ -312,23 +313,29 @@ public void onClick(DialogInterface dialog, int which) {
312313
}
313314
}
314315

315-
public void showHints() {
316-
Project project = SnabbleUI.getProject();
317-
Shop currentShop = project.getCheckout().getShop();
316+
public void setAllowShowingHints(boolean allowShowingHints) {
317+
this.allowShowingHints = allowShowingHints;
318+
}
318319

319-
if(currentShop != null) {
320-
Context context = getContext();
320+
private void showHints() {
321+
if(allowShowingHints) {
322+
Project project = SnabbleUI.getProject();
323+
Shop currentShop = project.getCheckout().getShop();
321324

322-
final AlertDialog alertDialog = new AlertDialog.Builder(context)
323-
.setTitle(context.getString(R.string.Snabble_Hints_title, currentShop.getName()))
324-
.setMessage(context.getString(R.string.Snabble_Hints_closedBags))
325-
.setPositiveButton(R.string.Snabble_OK, null)
326-
.setCancelable(true)
327-
.create();
325+
if (currentShop != null) {
326+
Context context = getContext();
328327

329-
alertDialog.setCanceledOnTouchOutside(true);
328+
final AlertDialog alertDialog = new AlertDialog.Builder(context)
329+
.setTitle(context.getString(R.string.Snabble_Hints_title, currentShop.getName()))
330+
.setMessage(context.getString(R.string.Snabble_Hints_closedBags))
331+
.setPositiveButton(R.string.Snabble_OK, null)
332+
.setCancelable(true)
333+
.create();
330334

331-
alertDialog.show();
335+
alertDialog.setCanceledOnTouchOutside(true);
336+
337+
alertDialog.show();
338+
}
332339
}
333340
}
334341

0 commit comments

Comments
 (0)