Replace rotation lock icon with barcode orientation setting (#901)

This commit is contained in:
Sylvia van Os
2022-06-19 00:20:56 +02:00
committed by GitHub
parent d3487cc535
commit 4ad73a754e
44 changed files with 50 additions and 188 deletions

View File

@@ -252,13 +252,25 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = new Settings(this);
String cardOrientation = settings.getCardViewOrientation();
if (cardOrientation.equals(getString(R.string.settings_key_lock_on_opening_orientation))) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
} else if (cardOrientation.equals(getString(R.string.settings_key_portrait_orientation))) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if (cardOrientation.equals(getString(R.string.settings_key_landscape_orientation))) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
if (savedInstanceState != null) {
mainImageIndex = savedInstanceState.getInt(STATE_IMAGEINDEX);
isFullscreen = savedInstanceState.getBoolean(STATE_FULLSCREEN);
bottomSheetState = savedInstanceState.getInt(STATE_BOTTOMSHEET);
}
settings = new Settings(this);
extractIntentFields(getIntent());
@@ -687,15 +699,6 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.card_view_menu, menu);
// Always calculate lockscreen icon, it may need a black color
boolean lockBarcodeScreenOrientation = settings.getLockBarcodeScreenOrientation();
MenuItem item = menu.findItem(R.id.action_lock_unlock);
setOrientatonLock(item, lockBarcodeScreenOrientation);
if (lockBarcodeScreenOrientation) {
item.setVisible(false);
}
loyaltyCard = DBHelper.getLoyaltyCard(database, loyaltyCardId);
starred = loyaltyCard.starStatus != 0;
@@ -756,15 +759,6 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
startActivity(intent);
return true;
case R.id.action_lock_unlock:
if (rotationEnabled) {
setOrientatonLock(item, true);
} else {
setOrientatonLock(item, false);
}
rotationEnabled = !rotationEnabled;
return true;
case R.id.action_star_unstar:
starred = !starred;
DBHelper.updateLoyaltyCardStarStatus(database, loyaltyCardId, starred ? 1 : 0);
@@ -838,19 +832,6 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
}
}
private void setOrientatonLock(MenuItem item, boolean lock) {
if (lock) {
item.setIcon(getIcon(R.drawable.ic_lock_outline_white_24dp, backgroundNeedsDarkIcons));
item.setTitle(R.string.unlockScreen);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
} else {
item.setIcon(getIcon(R.drawable.ic_lock_open_white_24dp, backgroundNeedsDarkIcons));
item.setTitle(R.string.lockScreen);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}
private void makeBottomSheetVisibleIfUseful() {
if (noteView.getVisibility() == View.VISIBLE || groupsView.getVisibility() == View.VISIBLE || balanceView.getVisibility() == View.VISIBLE || expiryView.getVisibility() == View.VISIBLE) {
bottomSheet.setVisibility(View.VISIBLE);