mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Name the request codes. Wondering how this was editable before.
This commit is contained in:
@@ -49,6 +49,19 @@ public class BaseFragment {
|
||||
protected boolean swipeBackEnabled = true;
|
||||
protected boolean hasOwnBackground = false;
|
||||
|
||||
// IDs forwarded from startActivityForResult() to onActivityResultFragment()
|
||||
public final static int
|
||||
RC0_CHAT_IMAGE_CAPTURE = 0,
|
||||
RC1_CHAT_PICK = 1,
|
||||
RC2_CHAT_VIDEO_CAPTURE = 2,
|
||||
RC10_WALLPAPER_IMAGE_CAPTURE = 10,
|
||||
RC11_WALLPAPER_PICK = 11,
|
||||
RC12_PROFILE_RINGTONE_PICKER = 12,
|
||||
RC13_AVATAR_IMAGE_CAPTURE = 13,
|
||||
RC14_AVATAR_GET_CONTENT = 14,
|
||||
RC21_CHAT_PICK_WO_COMPR = 21,
|
||||
RC500_PHOTO_VIEW = 500;
|
||||
|
||||
public BaseFragment() {
|
||||
classGuid = ConnectionsManager.getInstance().generateClassGuid();
|
||||
}
|
||||
|
||||
@@ -1192,7 +1192,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
|
||||
currentPicturePath = image.getAbsolutePath();
|
||||
}
|
||||
startActivityForResult(takePictureIntent, 0);
|
||||
startActivityForResult(takePictureIntent, RC0_CHAT_IMAGE_CAPTURE);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
@@ -1223,7 +1223,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
Intent chooserIntent = Intent.createChooser(photoPickerIntent, null);
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{videoPickerIntent});
|
||||
|
||||
startActivityForResult(chooserIntent, 1);
|
||||
startActivityForResult(chooserIntent, RC1_CHAT_PICK);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
@@ -1253,7 +1253,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, (long) (1024 * 1024 * 1536));
|
||||
currentPicturePath = video.getAbsolutePath();
|
||||
}
|
||||
startActivityForResult(takeVideoIntent, 2);
|
||||
startActivityForResult(takeVideoIntent, RC2_CHAT_VIDEO_CAPTURE);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
@@ -1276,7 +1276,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
try {
|
||||
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
||||
photoPickerIntent.setType("*/*");
|
||||
startActivityForResult(photoPickerIntent, 21);
|
||||
startActivityForResult(photoPickerIntent, RC21_CHAT_PICK_WO_COMPR);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
@@ -1677,7 +1677,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (requestCode == 0) {
|
||||
if (requestCode == RC0_CHAT_IMAGE_CAPTURE) {
|
||||
PhotoViewer.getInstance().setParentActivity(getParentActivity());
|
||||
final ArrayList<Object> arrayList = new ArrayList<>();
|
||||
int orientation = 0;
|
||||
@@ -1708,7 +1708,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
}, this);
|
||||
AndroidUtilities.addMediaToGallery(currentPicturePath);
|
||||
currentPicturePath = null;
|
||||
} else if (requestCode == 1) {
|
||||
} else if (requestCode == RC1_CHAT_PICK) {
|
||||
if (data == null || data.getData() == null) {
|
||||
showAttachmentError();
|
||||
return;
|
||||
@@ -1737,7 +1737,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
SendMessagesHelper.prepareSendingPhoto(null, uri, dialog_id, null, null);
|
||||
}
|
||||
m_mrChat.cleanDraft();
|
||||
} else if (requestCode == 2) {
|
||||
} else if (requestCode == RC2_CHAT_VIDEO_CAPTURE) {
|
||||
String videoPath = null;
|
||||
FileLog.d("messenger", "pic path " + currentPicturePath);
|
||||
if (data != null && currentPicturePath != null) {
|
||||
@@ -1777,7 +1777,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, null);
|
||||
m_mrChat.cleanDraft();
|
||||
}
|
||||
} else if (requestCode == 21) {
|
||||
} else if (requestCode == RC21_CHAT_PICK_WO_COMPR) {
|
||||
if (data == null || data.getData() == null) {
|
||||
showAttachmentError();
|
||||
return;
|
||||
@@ -2606,6 +2606,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
return 0;
|
||||
}
|
||||
|
||||
// PhotoViewerProvider
|
||||
public void sendPhoto(MediaController.PhotoEntry photoEntry) {
|
||||
if (photoEntry.imagePath != null) {
|
||||
SendMessagesHelper.prepareSendingPhoto(photoEntry.imagePath, null, dialog_id, null, photoEntry.caption);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
|
||||
currentPicturePath = image.getAbsolutePath();
|
||||
}
|
||||
parentFragment.startActivityForResult(takePictureIntent, 13);
|
||||
parentFragment.startActivityForResult(takePictureIntent, BaseFragment.RC13_AVATAR_IMAGE_CAPTURE);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||
try {
|
||||
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
photoPickerIntent.setType("image/*");
|
||||
parentFragment.startActivityForResult(photoPickerIntent, 14);
|
||||
parentFragment.startActivityForResult(photoPickerIntent, BaseFragment.RC14_AVATAR_GET_CONTENT);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (requestCode == 13) {
|
||||
if (requestCode == BaseFragment.RC13_AVATAR_IMAGE_CAPTURE) {
|
||||
PhotoViewer.getInstance().setParentActivity(parentFragment.getParentActivity());
|
||||
int orientation = 0;
|
||||
try {
|
||||
@@ -188,7 +188,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||
}, null);
|
||||
AndroidUtilities.addMediaToGallery(currentPicturePath);
|
||||
currentPicturePath = null;
|
||||
} else if (requestCode == 14) {
|
||||
} else if (requestCode == BaseFragment.RC14_AVATAR_GET_CONTENT) {
|
||||
if (data == null || data.getData() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_TEXT, MrMailbox.getInviteText());
|
||||
startActivityForResult(Intent.createChooser(intent, LocaleController.getString("InviteMenuEntry", R.string.InviteMenuEntry)), 500);
|
||||
startActivity(Intent.createChooser(intent, LocaleController.getString("InviteMenuEntry", R.string.InviteMenuEntry)));
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ import com.b44t.messenger.ConnectionsManager;
|
||||
import com.b44t.messenger.TLRPC;
|
||||
import com.b44t.messenger.MessageObject;
|
||||
import com.b44t.messenger.Utilities;
|
||||
import com.b44t.ui.ActionBar.BaseFragment;
|
||||
import com.b44t.ui.ActionBar.Theme;
|
||||
import com.b44t.messenger.AnimatorListenerAdapterProxy;
|
||||
import com.b44t.ui.ActionBar.ActionBar;
|
||||
@@ -4188,7 +4189,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.fromFile(file), "video/mp4");
|
||||
parentActivity.startActivityForResult(intent, 500);
|
||||
parentActivity.startActivityForResult(intent, BaseFragment.RC500_PHOTO_VIEW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
}
|
||||
|
||||
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
||||
startActivityForResult(tmpIntent, 12);
|
||||
startActivityForResult(tmpIntent, RC12_PROFILE_RINGTONE_PICKER);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
@@ -482,7 +482,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
if (requestCode == 12) {
|
||||
if (requestCode == RC12_PROFILE_RINGTONE_PICKER) {
|
||||
if (name != null) {
|
||||
editor.putString("sound_" + dialog_id, name);
|
||||
editor.putString("sound_path_" + dialog_id, ringtone.toString());
|
||||
|
||||
@@ -91,9 +91,6 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
private final static int RC10_TAKE_WALLPAPER_PICTURE = 10;
|
||||
private final static int RC11_SELECT_WALLPAPER_FROM_GALLERY = 11;
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
@@ -233,11 +230,11 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
|
||||
currentPicturePath = image.getAbsolutePath();
|
||||
}
|
||||
startActivityForResult(takePictureIntent, RC10_TAKE_WALLPAPER_PICTURE);
|
||||
startActivityForResult(takePictureIntent, RC10_WALLPAPER_IMAGE_CAPTURE);
|
||||
} else if (i == 1) {
|
||||
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
|
||||
photoPickerIntent.setType("image/*");
|
||||
startActivityForResult(photoPickerIntent, RC11_SELECT_WALLPAPER_FROM_GALLERY);
|
||||
startActivityForResult(photoPickerIntent, RC11_WALLPAPER_PICK);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
@@ -265,7 +262,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (requestCode == RC10_TAKE_WALLPAPER_PICTURE) {
|
||||
if (requestCode == RC10_WALLPAPER_IMAGE_CAPTURE) {
|
||||
AndroidUtilities.addMediaToGallery(currentPicturePath);
|
||||
FileOutputStream stream = null;
|
||||
try {
|
||||
@@ -290,7 +287,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
|
||||
}
|
||||
}
|
||||
currentPicturePath = null;
|
||||
} else if (requestCode == RC11_SELECT_WALLPAPER_FROM_GALLERY) {
|
||||
} else if (requestCode == RC11_WALLPAPER_PICK) {
|
||||
if (data == null || data.getData() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user