diff options
Diffstat (limited to 'src/main')
3 files changed, 24 insertions, 4 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 5455cea52..ec13ba1ad 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -42,6 +42,9 @@ <uses-feature android:name="android.hardware.location.network" android:required="false" /> + <uses-feature + android:name="android.hardware.microphone" + android:required="false" /> <application android:name="android.support.multidex.MultiDexApplication" diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index c49e78d81..5f8b0c18a 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -83,6 +83,7 @@ import de.pixart.messenger.ui.interfaces.OnConversationRead; import de.pixart.messenger.ui.interfaces.OnConversationSelected; import de.pixart.messenger.ui.interfaces.OnConversationsListItemUpdated; import de.pixart.messenger.ui.util.ActivityResult; +import de.pixart.messenger.ui.util.ConversationMenuConfigurator; import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.utils.ExceptionHelper; import de.pixart.messenger.utils.MenuDoubleTabUtil; @@ -428,6 +429,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + ConversationMenuConfigurator.reloadFeatures(this); OmemoSetting.load(this); new EmojiService(this).init(useBundledEmoji()); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations); diff --git a/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java b/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java index c82b34760..eb7217b95 100644 --- a/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java +++ b/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java @@ -29,6 +29,8 @@ package de.pixart.messenger.ui.util; +import android.content.Context; +import android.content.pm.PackageManager; import android.support.annotation.NonNull; import android.view.Menu; import android.view.MenuItem; @@ -42,18 +44,29 @@ import de.pixart.messenger.entities.Message; public class ConversationMenuConfigurator { + private static boolean microphoneAvailable = false; + private static boolean locationAvailable = false; + + public static void reloadFeatures(Context context) { + microphoneAvailable = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE); + locationAvailable = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS) || context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_NETWORK); + } + public static void configureAttachmentMenu(@NonNull Conversation conversation, Menu menu) { final MenuItem menuAttach = menu.findItem(R.id.action_attach_file); final boolean visible; - if (OmemoSetting.isAlways()) { - visible = false; - } else if (conversation.getMode() == Conversation.MODE_MULTI) { + if (conversation.getMode() == Conversation.MODE_MULTI) { visible = conversation.getAccount().httpUploadAvailable() && conversation.getMucOptions().participating(); } else { visible = true; } menuAttach.setVisible(visible); + if (!visible) { + return; + } + menu.findItem(R.id.attach_record_voice).setVisible(microphoneAvailable); + menu.findItem(R.id.attach_location).setVisible(locationAvailable); } public static void configureEncryptionMenu(@NonNull Conversation conversation, Menu menu) { @@ -64,7 +77,9 @@ public class ConversationMenuConfigurator { final MenuItem axolotl = menu.findItem(R.id.encryption_choice_axolotl); boolean visible; - if (conversation.getMode() == Conversation.MODE_MULTI) { + if (OmemoSetting.isAlways()) { + visible = false; + } else if (conversation.getMode() == Conversation.MODE_MULTI) { visible = (Config.supportOpenPgp() || Config.supportOmemo()) && Config.multipleEncryptionChoices(); } else { visible = Config.multipleEncryptionChoices(); |