Hide "QR-code" button from config import menu for Android devices without camera
This commit is contained in:
parent
3e02dfef63
commit
2b61c48303
6 changed files with 25 additions and 2 deletions
|
@ -5,6 +5,7 @@ import android.content.Intent
|
||||||
import android.content.Intent.EXTRA_MIME_TYPES
|
import android.content.Intent.EXTRA_MIME_TYPES
|
||||||
import android.content.Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
|
import android.content.Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
|
||||||
import android.content.ServiceConnection
|
import android.content.ServiceConnection
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.net.VpnService
|
import android.net.VpnService
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -418,6 +419,9 @@ class AmneziaActivity : QtActivity() {
|
||||||
Log.v(TAG, "Set notification text")
|
Log.v(TAG, "Set notification text")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
fun isCameraPresent(): Boolean = applicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun startQrCodeReader() {
|
fun startQrCodeReader() {
|
||||||
Log.v(TAG, "Start camera")
|
Log.v(TAG, "Start camera")
|
||||||
|
|
|
@ -191,6 +191,11 @@ void AndroidController::setNotificationText(const QString &title, const QString
|
||||||
(jint) timerSec);
|
(jint) timerSec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AndroidController::isCameraPresent()
|
||||||
|
{
|
||||||
|
return callActivityMethod<jboolean>("isCameraPresent", "()Z");
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidController::startQrReaderActivity()
|
void AndroidController::startQrReaderActivity()
|
||||||
{
|
{
|
||||||
callActivityMethod("startQrCodeReader", "()V");
|
callActivityMethod("startQrCodeReader", "()V");
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
void setNotificationText(const QString &title, const QString &message, int timerSec);
|
void setNotificationText(const QString &title, const QString &message, int timerSec);
|
||||||
void saveFile(const QString &fileName, const QString &data);
|
void saveFile(const QString &fileName, const QString &data);
|
||||||
QString openFile(const QString &filter);
|
QString openFile(const QString &filter);
|
||||||
|
bool isCameraPresent();
|
||||||
void startQrReaderActivity();
|
void startQrReaderActivity();
|
||||||
void setSaveLogs(bool enabled);
|
void setSaveLogs(bool enabled);
|
||||||
void exportLogsFile(const QString &fileName);
|
void exportLogsFile(const QString &fileName);
|
||||||
|
|
|
@ -206,3 +206,14 @@ void SettingsController::toggleScreenshotsEnabled(bool enable)
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingsController::isCameraPresent()
|
||||||
|
{
|
||||||
|
#if defined Q_OS_IOS
|
||||||
|
return true;
|
||||||
|
#elif defined Q_OS_ANDROID
|
||||||
|
return AndroidController::instance()->isCameraPresent();
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ public slots:
|
||||||
bool isScreenshotsEnabled();
|
bool isScreenshotsEnabled();
|
||||||
void toggleScreenshotsEnabled(bool enable);
|
void toggleScreenshotsEnabled(bool enable);
|
||||||
|
|
||||||
|
bool isCameraPresent();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void primaryDnsChanged();
|
void primaryDnsChanged();
|
||||||
void secondaryDnsChanged();
|
void secondaryDnsChanged();
|
||||||
|
|
|
@ -90,7 +90,7 @@ It's okay as long as it's from someone you trust.")
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
visible: GC.isMobile()
|
visible: SettingsController.isCameraPresent()
|
||||||
|
|
||||||
text: qsTr("QR-code")
|
text: qsTr("QR-code")
|
||||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||||
|
@ -105,7 +105,7 @@ It's okay as long as it's from someone you trust.")
|
||||||
}
|
}
|
||||||
|
|
||||||
DividerType {
|
DividerType {
|
||||||
visible: GC.isMobile()
|
visible: SettingsController.isCameraPresent()
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue