File tree Expand file tree Collapse file tree 5 files changed +25
-3
lines changed
java/com/wmods/wppenhacer/xposed Expand file tree Collapse file tree 5 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 44import androidx .annotation .Nullable ;
55
66import com .wmods .wppenhacer .xposed .core .WppCore ;
7+ import com .wmods .wppenhacer .xposed .core .db .MessageStore ;
78import com .wmods .wppenhacer .xposed .core .devkit .Unobfuscator ;
89import com .wmods .wppenhacer .xposed .utils .ReflectionUtils ;
910
@@ -163,8 +164,12 @@ public File getMediaFile() {
163164 if (field .getType ().isPrimitive ()) continue ;
164165 var fileField = ReflectionUtils .getFieldByType (field .getType (), File .class );
165166 if (fileField != null ) {
166- var mediaFile = ReflectionUtils .getObjectField (field , fmessage );
167- return (File ) fileField .get (mediaFile );
167+ var mediaObject = ReflectionUtils .getObjectField (field , fmessage );
168+ var mediaFile = (File ) fileField .get (mediaObject );
169+ if (mediaFile != null ) return mediaFile ;
170+ var filePath = MessageStore .getInstance ().getMediaFromID (getRowId ());
171+ if (filePath == null ) return null ;
172+ return new File (filePath );
168173 }
169174 }
170175 } catch (Exception e ) {
Original file line number Diff line number Diff line change @@ -73,6 +73,10 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
7373 item .setOnMenuItemClickListener (item1 -> {
7474 try {
7575 var file = fMessage .getMediaFile ();
76+ if (file == null ) {
77+ Utils .showToast (Utils .getApplication ().getString (ResId .string .download_not_available ), 1 );
78+ return true ;
79+ }
7680 downloadFile (fMessage .getKey ().remoteJid , file );
7781 } catch (Exception e ) {
7882 Utils .showToast (e .getMessage (), Toast .LENGTH_LONG );
@@ -99,6 +103,10 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
99103 var fmessageObj = WppCore .getFMessageFromKey (keyMessageObj );
100104 var fmessage = new FMessageWpp (fmessageObj );
101105 var file = fmessage .getMediaFile ();
106+ if (file == null ) {
107+ Utils .showToast (Utils .getApplication ().getString (ResId .string .download_not_available ), 1 );
108+ return ;
109+ }
102110 var userJid = fmessage .getKey ().remoteJid ;
103111 try {
104112 downloadFile (userJid , file );
Original file line number Diff line number Diff line change 2525import java .util .Collections ;
2626
2727import de .robv .android .xposed .XSharedPreferences ;
28- import de .robv .android .xposed .XposedHelpers ;
2928
3029public class StatusDownload extends Feature {
3130
@@ -89,6 +88,10 @@ private void sharedStatus(FMessageWpp fMessageWpp) {
8988 return ;
9089 }
9190 var file = fMessageWpp .getMediaFile ();
91+ if (file == null ) {
92+ Utils .showToast (Utils .getApplication ().getString (ResId .string .download_not_available ), 1 );
93+ return ;
94+ }
9295 Intent intent = new Intent ();
9396 var clazz = Unobfuscator .getClassByName ("MediaComposerActivity" , classLoader );
9497 intent .setClassName (Utils .getApplication ().getPackageName (), clazz .getName ());
@@ -104,6 +107,10 @@ private void sharedStatus(FMessageWpp fMessageWpp) {
104107 private void downloadFile (FMessageWpp fMessage ) {
105108 try {
106109 var file = fMessage .getMediaFile ();
110+ if (file == null ) {
111+ Utils .showToast (Utils .getApplication ().getString (ResId .string .download_not_available ), 1 );
112+ return ;
113+ }
107114 var userJid = fMessage .getUserJid ();
108115 var fileType = file .getName ().substring (file .getName ().lastIndexOf ("." ) + 1 );
109116 var destination = getStatusDestination (file );
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ public static class string {
103103 public static int download_folder_permission ;
104104 public static int no_contact_with_custom_privacy ;
105105 public static int select_contacts ;
106+ public static int download_not_available ;
106107 }
107108
108109 public static class array {
Original file line number Diff line number Diff line change 415415 <string name =" disable_the_proximity_sensor_sum" >Disable Screen off on proximity sensor to the whole WhatsApp</string >
416416 <string name =" disable_status_in_the_profile_photo" >Disable Status in the profile photo</string >
417417 <string name =" disable_status_in_the_profile_photo_sum" >Disables the circle that appears in the profile photo of each contact when there is new status</string >
418+ <string name =" download_not_available" >Download not available or media has not been fully downloaded</string >
418419</resources >
You can’t perform that action at this time.
0 commit comments