shared image when app its close

This commit is contained in:
Eudes Inácio
2023-10-28 17:04:17 +01:00
parent 1865240569
commit 2d08c5b776
5 changed files with 14 additions and 31 deletions
+2 -1
View File
@@ -14,7 +14,7 @@
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<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="image/*" /> <data android:mimeType="image/*" />
@@ -30,6 +30,7 @@
<data android:mimeType="image/*" /> <data android:mimeType="image/*" />
</intent-filter> </intent-filter>
</activity> </activity>
<provider android:authorities="${applicationId}.fileprovider" android:exported="false" <provider android:authorities="${applicationId}.fileprovider" android:exported="false"
android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider"> android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
+2
View File
@@ -87,6 +87,7 @@ import { CreateProcessPageModule } from './modals/create-process/create-process.
import { CreateProcessPage } from './modals/create-process/create-process.page'; import { CreateProcessPage } from './modals/create-process/create-process.page';
import { LoggingInterceptorService } from './services/logging-interceptor.service'; import { LoggingInterceptorService } from './services/logging-interceptor.service';
import { PopupQuestionPipe } from './modals/popup-question.pipe'; import { PopupQuestionPipe } from './modals/popup-question.pipe';
import { SendIntentService } from './services/shareIntent';
// import { ServiceWorkerModule } from '@angular/service-worker'; // import { ServiceWorkerModule } from '@angular/service-worker';
@@ -213,6 +214,7 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
FileOpener, FileOpener,
DocumentViewer, DocumentViewer,
{ provide: HTTP_INTERCEPTORS, useClass: LoggingInterceptorService, multi: true }, { provide: HTTP_INTERCEPTORS, useClass: LoggingInterceptorService, multi: true },
SendIntentService
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
+3 -23
View File
@@ -152,7 +152,7 @@ export class HomePage implements OnInit {
async checkSendIntentReceived(result) { async checkSendIntentReceived() {
SendIntent.checkSendIntentReceived().then((result: any) => { SendIntent.checkSendIntentReceived().then((result: any) => {
@@ -294,29 +294,9 @@ export class HomePage implements OnInit {
if (!this.platform.is('desktop')) { if (!this.platform.is('desktop')) {
App.addListener('appStateChange', ({ isActive }) => { App.addListener('appStateChange', ({ isActive }) => {
if (isActive) { if (isActive) {
/* this.checkSendIntentReceived("value") */ /* sendIntent.setRouteService(this.router) */
// The app is in the foreground.
/* fetchData()
.then((value) => {
console.log('fetchData was successful in file2.ts', value);
this.imageToBase64(value)
.then((base64Data) => {s
if (base64Data) {
// Use the base64 data as needed
console.log('Base64 data:', base64Data);
} else {
console.error('Base64 data is null');
}
});
if (value)
this.checkSendIntentReceived(value)
})
.catch((error) => {
console.error('Error in file2.ts:', error);
}); */
console.log('App is in the foreground'); console.log('App is in the foreground');
/* this.checkSendIntentReceived() */ this.checkSendIntentReceived()
} else { } else {
// The app is in the background. // The app is in the background.
console.log('App is in the background'); console.log('App is in the background');
@@ -70,13 +70,12 @@ export class PublicationsPage implements OnInit {
public ThemeService: ThemeService, public ThemeService: ThemeService,
public p: PermissionService, public p: PermissionService,
private storage: Storage, private storage: Storage,
private navParams: NavParams,
) { ) {
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
this.intent = this.navParams.get('intent');
} }
ngOnInit() { ngOnInit() {
@@ -91,6 +90,7 @@ export class PublicationsPage implements OnInit {
}); });
this.hideRefreshButton(); this.hideRefreshButton();
this.intent = window["sharedContent"]
} }
+5 -5
View File
@@ -3,7 +3,7 @@ import { SendIntent } from "send-intent";
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { CallbackScheduler } from './callbackScheduler'; import { CallbackScheduler } from './callbackScheduler';
class SendIntent { export class SendIntentService {
Router!: Router Router!: Router
@@ -20,6 +20,7 @@ class SendIntent {
// event handler // event handler
if (result.url) { if (result.url) {
this.onReceive(result) this.onReceive(result)
} }
}).catch(err => console.error(err)); }).catch(err => console.error(err));
} }
@@ -38,13 +39,12 @@ class SendIntent {
let resultUrl = decodeURIComponent(result.url); let resultUrl = decodeURIComponent(result.url);
Filesystem.readFile({path: resultUrl}).then(async (content) => { Filesystem.readFile({path: resultUrl}).then(async (content) => {
this.Router.navigateByUrl("/home/publication"); this.Router.navigateByUrl("/home/publications");
alert('shared') window["sharedContent"] = content.data;
console.log(content.data);
}) })
}) })
} }
export const sendIntent = new SendIntent() export const sendIntent = new SendIntentService()