mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-01 06:11:58 -04:00
Add menu option to lock screen when viewing card
When passing a phone to a clerk to scan the barcode, if the phone is rotated and the screen reloads it can be bothersome or confusion. To avoid this situation, a new option is added to lock the screen. A menu icon is now added which defaults as unlocked. When touched the app sets its orientation to the "natural" orientation of the device. When touched again the sensor dictates the orientation of the device.
This commit is contained in:
@@ -2,8 +2,11 @@ package protect.card_locker;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
@@ -53,6 +56,8 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
boolean updateLoyaltyCard;
|
||||
boolean viewLoyaltyCard;
|
||||
|
||||
boolean rotationEnabled;
|
||||
|
||||
DBHelper db;
|
||||
|
||||
@Override
|
||||
@@ -305,6 +310,8 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
getMenuInflater().inflate(R.menu.card_add_menu, menu);
|
||||
}
|
||||
|
||||
rotationEnabled = true;
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@@ -361,6 +368,22 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
finish();
|
||||
return true;
|
||||
|
||||
case R.id.action_lock_unlock:
|
||||
if(rotationEnabled)
|
||||
{
|
||||
item.setIcon(R.drawable.ic_lock_outline_white_24dp);
|
||||
item.setTitle(R.string.unlockScreen);
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setIcon(R.drawable.ic_lock_open_white_24dp);
|
||||
item.setTitle(R.string.lockScreen);
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||
}
|
||||
rotationEnabled = !rotationEnabled;
|
||||
return true;
|
||||
|
||||
case R.id.action_save:
|
||||
doSave();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user