1 /* Copyright 2016 Braden Farmer
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 package com.farmerbb.taskbar.receiver;
18 import android.content.BroadcastReceiver;
19 import android.content.Context;
20 import android.content.Intent;
21 import android.net.Uri;
22 import androidx.core.content.FileProvider;
24 import com.farmerbb.taskbar.BuildConfig;
25 import com.farmerbb.taskbar.backup.BackupUtils;
26 import com.farmerbb.taskbar.backup.IntentBackupAgent;
27 import com.farmerbb.taskbar.util.U;
31 public class SendSettingsReceiver extends BroadcastReceiver {
33 public void onReceive(Context context, Intent intent) {
34 // Ignore this broadcast if this is the paid version
35 if(context.getPackageName().equals(BuildConfig.BASE_APPLICATION_ID)) {
36 Intent sendSettingsIntent = new Intent("com.farmerbb.taskbar.SEND_SETTINGS");
37 sendSettingsIntent.setPackage(BuildConfig.PAID_APPLICATION_ID);
39 BackupUtils.backup(context, new IntentBackupAgent(sendSettingsIntent));
41 // Get custom start button image
42 File file = new File(context.getFilesDir() + "/tb_images", "custom_image");
43 if(file.exists() && U.isPlayStoreRelease(context, BuildConfig.PAID_APPLICATION_ID)) {
44 Uri uri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
45 context.grantUriPermission(BuildConfig.PAID_APPLICATION_ID, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
46 sendSettingsIntent.putExtra("custom_image", uri);
49 // Finally, send the broadcast
50 context.sendBroadcast(sendSettingsIntent);