mirror of
				https://github.com/akaessens/NoFbEventScraper
				synced 2025-06-05 23:29:13 +02:00 
			
		
		
		
	create intent receiver to fix share issues
This commit is contained in:
		| @@ -11,61 +11,61 @@ | |||||||
|         android:roundIcon="@mipmap/ic_launcher_round" |         android:roundIcon="@mipmap/ic_launcher_round" | ||||||
|         android:supportsRtl="true" |         android:supportsRtl="true" | ||||||
|         android:theme="@style/AppTheme"> |         android:theme="@style/AppTheme"> | ||||||
|  |         <activity android:name=".IntentReceiver"> | ||||||
|         <activity android:name=".SettingsActivity" |             <!-- Accepts open with --> | ||||||
|             android:label="@string/action_settings" > |  | ||||||
|             <meta-data |  | ||||||
|             android:name="android.support.PARENT_ACTIVITY" |  | ||||||
|             android:value=".MainActivity"/> |  | ||||||
|         </activity> |  | ||||||
|         <activity android:name=".HelpActivity" |  | ||||||
|             android:label="@string/action_help" > |  | ||||||
|             <meta-data |  | ||||||
|                 android:name="android.support.PARENT_ACTIVITY" |  | ||||||
|                 android:value=".MainActivity"/> |  | ||||||
|         </activity> |  | ||||||
|         <activity android:name=".AboutActivity" |  | ||||||
|             android:label="@string/action_about" > |  | ||||||
|             <meta-data |  | ||||||
|                 android:name="android.support.PARENT_ACTIVITY" |  | ||||||
|                 android:value=".MainActivity"/> |  | ||||||
|         </activity> |  | ||||||
|         <activity |  | ||||||
|             android:name=".MainActivity" |  | ||||||
|             android:launchMode="singleTop" |  | ||||||
|             android:windowSoftInputMode="stateVisible|adjustPan" |  | ||||||
|             android:label="@string/app_name" |  | ||||||
|             android:theme="@style/AppTheme.NoActionBar"> |  | ||||||
|  |  | ||||||
|             <intent-filter> |  | ||||||
|                 <action android:name="android.intent.action.MAIN" /> |  | ||||||
|  |  | ||||||
|                 <category android:name="android.intent.category.LAUNCHER" /> |  | ||||||
|             </intent-filter> |  | ||||||
|             <intent-filter> |             <intent-filter> | ||||||
|                 <action android:name="android.intent.action.VIEW" /> |                 <action android:name="android.intent.action.VIEW" /> | ||||||
|  |  | ||||||
|                 <category android:name="android.intent.category.DEFAULT" /> |                 <category android:name="android.intent.category.DEFAULT" /> | ||||||
|                 <category android:name="android.intent.category.BROWSABLE" /> |                 <category android:name="android.intent.category.BROWSABLE" /> | ||||||
|                 <!-- Accepts URIs that begin with "https://*.facebook.com/events” --> |  | ||||||
|                 <data |                 <data | ||||||
|                     android:host="*.facebook.com" |                     android:host="*.facebook.com" | ||||||
|                     android:scheme="https" /> |                     android:scheme="https" /> | ||||||
|                 <!-- Accepts URIs that begin with "https://facebook.com/events” --> |  | ||||||
|                 <data |                 <data | ||||||
|                     android:host="facebook.com" |                     android:host="facebook.com" | ||||||
|                     android:scheme="https" /> |                     android:scheme="https" /> | ||||||
|             </intent-filter> |             </intent-filter> | ||||||
|  |  | ||||||
|             <!-- Accepts share intents” --> |             <!-- Accepts share intents --> | ||||||
|             <intent-filter> |             <intent-filter> | ||||||
|                 <action android:name="android.intent.action.SEND" /> |                 <action android:name="android.intent.action.SEND" /> | ||||||
|  |  | ||||||
|                 <category android:name="android.intent.category.DEFAULT" /> |                 <category android:name="android.intent.category.DEFAULT" /> | ||||||
|  |  | ||||||
|                 <data android:mimeType="text/plain" /> |                 <data android:mimeType="text/plain" /> | ||||||
|             </intent-filter> |             </intent-filter> | ||||||
|         </activity> |         </activity> | ||||||
|  |         <activity | ||||||
|  |             android:name=".SettingsActivity" | ||||||
|  |             android:label="@string/action_settings"> | ||||||
|  |             <meta-data | ||||||
|  |                 android:name="android.support.PARENT_ACTIVITY" | ||||||
|  |                 android:value=".MainActivity" /> | ||||||
|  |         </activity> | ||||||
|  |         <activity | ||||||
|  |             android:name=".HelpActivity" | ||||||
|  |             android:label="@string/action_help"> | ||||||
|  |             <meta-data | ||||||
|  |                 android:name="android.support.PARENT_ACTIVITY" | ||||||
|  |                 android:value=".MainActivity" /> | ||||||
|  |         </activity> | ||||||
|  |         <activity | ||||||
|  |             android:name=".AboutActivity" | ||||||
|  |             android:label="@string/action_about"> | ||||||
|  |             <meta-data | ||||||
|  |                 android:name="android.support.PARENT_ACTIVITY" | ||||||
|  |                 android:value=".MainActivity" /> | ||||||
|  |         </activity> | ||||||
|  |         <activity | ||||||
|  |             android:name=".MainActivity" | ||||||
|  |             android:label="@string/app_name" | ||||||
|  |             android:launchMode="singleTop" | ||||||
|  |             android:theme="@style/AppTheme.NoActionBar" | ||||||
|  |             android:windowSoftInputMode="stateVisible|adjustPan"> | ||||||
|  |             <intent-filter> | ||||||
|  |                 <action android:name="android.intent.action.MAIN" /> | ||||||
|  |  | ||||||
|  |                 <category android:name="android.intent.category.LAUNCHER" /> | ||||||
|  |             </intent-filter> | ||||||
|  |  | ||||||
|  |         </activity> | ||||||
|     </application> |     </application> | ||||||
|  |  | ||||||
| </manifest> | </manifest> | ||||||
| @@ -0,0 +1,34 @@ | |||||||
|  | package com.akdev.nofbeventscraper; | ||||||
|  |  | ||||||
|  | import androidx.appcompat.app.AppCompatActivity; | ||||||
|  |  | ||||||
|  | import android.content.Intent; | ||||||
|  | import android.net.Uri; | ||||||
|  | import android.os.Bundle; | ||||||
|  |  | ||||||
|  | public class IntentReceiver extends AppCompatActivity { | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     protected void onCreate(Bundle savedInstanceState) { | ||||||
|  |         super.onCreate(savedInstanceState); | ||||||
|  |  | ||||||
|  |         /* | ||||||
|  |          * Get data from intent: if launched by other application | ||||||
|  |          * via "share to" or "open with" | ||||||
|  |          */ | ||||||
|  |         Intent intent = getIntent(); | ||||||
|  |         setResult(RESULT_OK, intent); | ||||||
|  |  | ||||||
|  |         String data = intent.getDataString(); | ||||||
|  |         String extra = intent.getStringExtra(Intent.EXTRA_TEXT); | ||||||
|  |  | ||||||
|  |         String input = (data != null) ? data : extra; | ||||||
|  |  | ||||||
|  |         Intent main = new Intent(this, MainActivity.class); | ||||||
|  |         main.putExtra("InputLink", input); | ||||||
|  |  | ||||||
|  |         this.startActivity(main); | ||||||
|  |  | ||||||
|  |         finish(); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -75,6 +75,15 @@ public class MainActivity extends AppCompatActivity { | |||||||
|         events.clear(); |         events.clear(); | ||||||
|         events.addAll(getSavedEvents()); |         events.addAll(getSavedEvents()); | ||||||
|         adapter.notifyDataSetChanged(); |         adapter.notifyDataSetChanged(); | ||||||
|  |  | ||||||
|  |         Intent intent = getIntent(); | ||||||
|  |         String data = intent.getStringExtra("InputLink"); | ||||||
|  |  | ||||||
|  |         if (data != null) { | ||||||
|  |             intent.removeExtra("InputLink"); | ||||||
|  |             edit_text_uri_input.setText(data); | ||||||
|  |             startScraping(); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -196,27 +205,7 @@ public class MainActivity extends AppCompatActivity { | |||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         /* |  | ||||||
|          * Get data from intent: if launched by other application |  | ||||||
|          * via "share to" or "open with" |  | ||||||
|          */ |  | ||||||
|         Intent intent = getIntent(); |  | ||||||
|  |  | ||||||
|         if (intent.getAction() != null) { |  | ||||||
|             // only use this intent once, not every onCreate (e.g. rotation) |  | ||||||
|             intent.setAction(null); |  | ||||||
|             Uri data = intent.getData(); |  | ||||||
|             String shared_text = intent.getStringExtra(Intent.EXTRA_TEXT); |  | ||||||
|             if (data != null) { |  | ||||||
|                 // opening external fb link |  | ||||||
|                 edit_text_uri_input.setText(data.toString()); |  | ||||||
|                 startScraping(); |  | ||||||
|             } else if (shared_text != null) { |  | ||||||
|                 //share to nofb |  | ||||||
|                 edit_text_uri_input.setText(shared_text); |  | ||||||
|                 startScraping(); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user