diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-08 14:09:01 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-08 14:09:01 +0200 |
commit | bcf0a5482643f6d00b15db364d7c5544e25f7414 (patch) | |
tree | b74596b34c57bbd83a8c9b42ba260f8434253b25 /src | |
parent | 25d05543e9932bae0b606fc1783051e305c218f8 (diff) |
make camera feature optional
Diffstat (limited to 'src')
7 files changed, 28 insertions, 19 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 9880e00eb..28e47675b 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -26,6 +26,9 @@ <uses-sdk tools:overrideLibrary="net.ypresto.androidtranscoder" /> + <uses-feature android:name="android.hardware.camera" android:required="false" /> + <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> + <application android:networkSecurityConfig="@xml/network_security_configuration" android:name="android.support.multidex.MultiDexApplication" diff --git a/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java b/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java index 64e47b1f3..1f991e8a0 100644 --- a/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ChooseContactActivity.java @@ -183,7 +183,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity { super.onCreateOptionsMenu(menu); final Intent i = getIntent(); boolean showEnterJid = i != null && i.getBooleanExtra("show_enter_jid", false); - menu.findItem(R.id.action_scan_qr_code).setVisible(showEnterJid); + menu.findItem(R.id.action_scan_qr_code).setVisible(isCameraFeatureAvailable() && showEnterJid); return true; } diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index ce4dad47e..841961a14 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -584,7 +584,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } else { binding.showInactiveDevices.setVisibility(View.GONE); } - binding.scanButton.setVisibility(hasKeys ? View.VISIBLE : View.GONE); + binding.scanButton.setVisibility(hasKeys && isCameraFeatureAvailable() ? View.VISIBLE : View.GONE); if (hasKeys) { binding.scanButton.setOnClickListener((v) -> ScanActivity.scan(this)); } diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index 40572a71a..69deb91e3 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -447,11 +447,15 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); final MenuItem menuEditProfiles = menu.findItem(R.id.action_accounts); if (qrCodeScanMenuItem != null) { - Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment); - boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan) - && fragment != null - && fragment instanceof ConversationsOverviewFragment; - qrCodeScanMenuItem.setVisible(visible); + if (isCameraFeatureAvailable()) { + Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment); + boolean visible = getResources().getBoolean(R.bool.show_qr_code_scan) + && fragment != null + && fragment instanceof ConversationsOverviewFragment; + qrCodeScanMenuItem.setVisible(visible); + } else { + qrCodeScanMenuItem.setVisible(false); + } } if (xmppConnectionServiceBound && xmppConnectionService.getAccounts().size() == 1 && !xmppConnectionService.multipleAccounts()) { menuEditProfiles.setTitle(R.string.mgmt_account_edit); diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 1e58f88e5..3660ddf81 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -624,8 +624,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU menuActionAccounts.setTitle(R.string.action_accounts); } MenuItem joinGroupChat = menu.findItem(R.id.action_join_conference); + MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); ActionBar bar = getSupportActionBar(); joinGroupChat.setVisible(bar != null && bar.getSelectedNavigationIndex() == 1); + qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable()); menuHideOffline.setChecked(this.mHideOfflineContacts); mMenuSearchView = menu.findItem(R.id.action_search); mMenuSearchView.setOnActionExpandListener(mOnActionExpandListener); diff --git a/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java b/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java index 1f408138d..be4c86549 100644 --- a/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java +++ b/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java @@ -110,7 +110,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.trust_keys, menu); MenuItem scanQrCode = menu.findItem(R.id.action_scan_qr_code); - scanQrCode.setVisible(ownKeysToTrust.size() > 0 || foreignActuallyHasKeys()); + scanQrCode.setVisible((ownKeysToTrust.size() > 0 || foreignActuallyHasKeys()) && isCameraFeatureAvailable()); return super.onCreateOptionsMenu(menu); } @@ -221,7 +221,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat } } - if ((hasOwnKeys || foreignActuallyHasKeys()) && mUseCameraHintShown.compareAndSet(false,true)) { + if ((hasOwnKeys || foreignActuallyHasKeys()) && isCameraFeatureAvailable() && mUseCameraHintShown.compareAndSet(false, true)) { showCameraToast(); } diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 8bfe7d2fa..5e2e4856b 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -94,14 +94,13 @@ public abstract class XmppActivity extends AppCompatActivity { public boolean xmppConnectionServiceBound = false; protected boolean registeredListeners = false; - protected int mPrimaryBackgroundColor; - protected int mSecondaryBackgroundColor; protected int mColorRed; protected int mColorWarningButton; protected int mColorWhite; protected int mColorOrange; protected int mColorGreen; - protected int mPrimaryColor; + + private boolean isCameraFeatureAvailable = false; protected boolean mUseSubject = true; @@ -410,14 +409,12 @@ public abstract class XmppActivity extends AppCompatActivity { super.onCreate(savedInstanceState); metrics = getResources().getDisplayMetrics(); ExceptionHelper.init(getApplicationContext()); + this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); mColorRed = ContextCompat.getColor(this, R.color.red800); mColorWarningButton = ContextCompat.getColor(this, R.color.warning_button); mColorWhite = ContextCompat.getColor(this, R.color.white70); mColorOrange = ContextCompat.getColor(this, R.color.orange500); mColorGreen = ContextCompat.getColor(this, R.color.realgreen); - mPrimaryColor = ContextCompat.getColor(this, R.color.primary); - mPrimaryBackgroundColor = ContextCompat.getColor(this, R.color.grey50); - mSecondaryBackgroundColor = ContextCompat.getColor(this, R.color.grey200); this.mTheme = findTheme(); setTheme(this.mTheme); this.mUsingEnterKey = usingEnterKey(); @@ -428,10 +425,13 @@ public abstract class XmppActivity extends AppCompatActivity { } } - // todo theme -// public boolean isDarkTheme() { -// return this.mTheme == R.style.ConversationsTheme_Dark; -// } + protected boolean isCameraFeatureAvailable() { + return this.isCameraFeatureAvailable; + } + + public boolean isDarkTheme() { + return this.mTheme == R.style.ConversationsTheme_Dark; + } public int getThemeResource(int r_attr_name, int r_drawable_def) { int[] attrs = { r_attr_name }; |