Commit 66266976 authored by Tiago Cunha's avatar Tiago Cunha Committed by GitHub

Merge pull request #107 from RocketChat/fix/external-storage-permission

Ask for permission
parents c0001283 ce95423e
...@@ -123,6 +123,9 @@ dependencies { ...@@ -123,6 +123,9 @@ dependencies {
compile 'frankiesardo:icepick:3.2.0' compile 'frankiesardo:icepick:3.2.0'
provided 'frankiesardo:icepick-processor:3.2.0' provided 'frankiesardo:icepick-processor:3.2.0'
compile 'com.github.hotchemi:permissionsdispatcher:2.3.0'
annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.3.0'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="chat.rocket.android"> package="chat.rocket.android">
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:name=".RocketChatApplication" android:name=".RocketChatApplication"
...@@ -16,23 +17,23 @@ ...@@ -16,23 +17,23 @@
android:name=".activity.MainActivity" android:name=".activity.MainActivity"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="adjustResize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".activity.AddServerActivity" android:name=".activity.AddServerActivity"
android:windowSoftInputMode="adjustResize"/> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".activity.ServerConfigActivity" android:name=".activity.ServerConfigActivity"
android:windowSoftInputMode="adjustResize"/> android:windowSoftInputMode="adjustResize" />
<service android:name=".service.RocketChatService"/> <service android:name=".service.RocketChatService" />
<service android:name=".service.notification.NotificationDismissalCallbackService"/> <service android:name=".service.notification.NotificationDismissalCallbackService" />
</application> </application>
</manifest> </manifest>
package chat.rocket.android.fragment.chatroom; package chat.rocket.android.fragment.chatroom;
import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
...@@ -31,6 +33,7 @@ import chat.rocket.android.layouthelper.chatroom.MessageComposerManager; ...@@ -31,6 +33,7 @@ import chat.rocket.android.layouthelper.chatroom.MessageComposerManager;
import chat.rocket.android.layouthelper.chatroom.MessageListAdapter; import chat.rocket.android.layouthelper.chatroom.MessageListAdapter;
import chat.rocket.android.layouthelper.chatroom.PairedMessage; import chat.rocket.android.layouthelper.chatroom.PairedMessage;
import chat.rocket.android.log.RCLog; import chat.rocket.android.log.RCLog;
import chat.rocket.android.message.AbstractMessageSpec;
import chat.rocket.android.message.AudioUploadMessageSpec; import chat.rocket.android.message.AudioUploadMessageSpec;
import chat.rocket.android.message.AbstractUploadMessageSpec; import chat.rocket.android.message.AbstractUploadMessageSpec;
import chat.rocket.android.message.ImageUploadMessageSpec; import chat.rocket.android.message.ImageUploadMessageSpec;
...@@ -48,10 +51,13 @@ import chat.rocket.android.realm_helper.RealmObjectObserver; ...@@ -48,10 +51,13 @@ import chat.rocket.android.realm_helper.RealmObjectObserver;
import chat.rocket.android.realm_helper.RealmStore; import chat.rocket.android.realm_helper.RealmStore;
import chat.rocket.android.service.RocketChatService; import chat.rocket.android.service.RocketChatService;
import chat.rocket.android.widget.message.MessageComposer; import chat.rocket.android.widget.message.MessageComposer;
import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.RuntimePermissions;
/** /**
* Chat room screen. * Chat room screen.
*/ */
@RuntimePermissions
public class RoomFragment extends AbstractChatRoomFragment public class RoomFragment extends AbstractChatRoomFragment
implements OnBackPressListener, RealmModelListAdapter.OnItemClickListener<PairedMessage> { implements OnBackPressListener, RealmModelListAdapter.OnItemClickListener<PairedMessage> {
...@@ -67,7 +73,8 @@ public class RoomFragment extends AbstractChatRoomFragment ...@@ -67,7 +73,8 @@ public class RoomFragment extends AbstractChatRoomFragment
private MessageComposerManager messageComposerManager; private MessageComposerManager messageComposerManager;
private MessageSelectionDialogFragment.ClickListener messageSelectionClickListener = private MessageSelectionDialogFragment.ClickListener messageSelectionClickListener =
messageSpec -> messageSpec.onSelect(RoomFragment.this); messageSpec -> RoomFragmentPermissionsDispatcher
.onMessageSpecSelectedWithCheck(RoomFragment.this, messageSpec);
public RoomFragment() { public RoomFragment() {
} }
...@@ -365,4 +372,16 @@ public class RoomFragment extends AbstractChatRoomFragment ...@@ -365,4 +372,16 @@ public class RoomFragment extends AbstractChatRoomFragment
public boolean onBackPressed() { public boolean onBackPressed() {
return closeSideMenuIfNeeded(); return closeSideMenuIfNeeded();
} }
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
RoomFragmentPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
}
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
protected void onMessageSpecSelected(AbstractMessageSpec messageSpec) {
messageSpec.onSelect(RoomFragment.this);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment