hide record audio feature if mircophone is not available

This commit is contained in:
Daniel Gultsch 2018-05-03 17:01:16 +02:00
parent b5423b39a0
commit 756c1a1004
3 changed files with 14 additions and 2 deletions

View file

@ -43,6 +43,10 @@
android:name="android.hardware.camera.autofocus" android:name="android.hardware.camera.autofocus"
android:required="false"/> android:required="false"/>
<uses-feature
android:name="android.hardware.microphone"
android:required="false"/>
<application <application
android:allowBackup="true" android:allowBackup="true"

View file

@ -72,6 +72,7 @@ import eu.siacs.conversations.ui.interfaces.OnConversationSelected;
import eu.siacs.conversations.ui.interfaces.OnConversationsListItemUpdated; import eu.siacs.conversations.ui.interfaces.OnConversationsListItemUpdated;
import eu.siacs.conversations.ui.service.EmojiService; import eu.siacs.conversations.ui.service.EmojiService;
import eu.siacs.conversations.ui.util.ActivityResult; import eu.siacs.conversations.ui.util.ActivityResult;
import eu.siacs.conversations.ui.util.ConversationMenuConfigurator;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil; import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.PendingItem; import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.utils.ExceptionHelper;
@ -364,6 +365,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
@Override @Override
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ConversationMenuConfigurator.reloadFeatures(this);
OmemoSetting.load(this); OmemoSetting.load(this);
new EmojiService(this).init(); new EmojiService(this).init();
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations);

View file

@ -29,6 +29,7 @@
package eu.siacs.conversations.ui.util; package eu.siacs.conversations.ui.util;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.provider.MediaStore; import android.provider.MediaStore;
@ -45,6 +46,12 @@ import eu.siacs.conversations.entities.Message;
public class ConversationMenuConfigurator { public class ConversationMenuConfigurator {
private static boolean microphoneAvailable = false;
public static void reloadFeatures(Context context) {
microphoneAvailable = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE);
}
public static void configureAttachmentMenu(@NonNull Conversation conversation, Menu menu) { public static void configureAttachmentMenu(@NonNull Conversation conversation, Menu menu) {
final MenuItem menuAttach = menu.findItem(R.id.action_attach_file); final MenuItem menuAttach = menu.findItem(R.id.action_attach_file);
@ -54,12 +61,11 @@ public class ConversationMenuConfigurator {
} else { } else {
visible = true; visible = true;
} }
menuAttach.setVisible(visible); menuAttach.setVisible(visible);
if (!visible) { if (!visible) {
return; return;
} }
menu.findItem(R.id.attach_record_voice).setVisible(microphoneAvailable);
} }
public static void configureEncryptionMenu(@NonNull Conversation conversation, Menu menu) { public static void configureEncryptionMenu(@NonNull Conversation conversation, Menu menu) {