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.activity;
18 import android.app.Activity;
19 import android.content.BroadcastReceiver;
20 import android.content.Context;
21 import android.content.Intent;
22 import android.content.IntentFilter;
23 import android.os.Bundle;
24 import android.support.v4.content.LocalBroadcastManager;
26 import com.farmerbb.taskbar.MainActivity;
27 import com.farmerbb.taskbar.R;
29 public class ImportSettingsActivity extends Activity {
31 boolean broadcastSent = false;
33 private BroadcastReceiver settingsReceivedReceiver = new BroadcastReceiver() {
35 public void onReceive(Context context, Intent intent) {
36 Intent restartIntent = new Intent(ImportSettingsActivity.this, MainActivity.class);
37 restartIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
38 startActivity(restartIntent);
39 overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
46 protected void onCreate(Bundle savedInstanceState) {
47 super.onCreate(savedInstanceState);
48 setContentView(R.layout.import_settings);
49 setFinishOnTouchOutside(false);
51 LocalBroadcastManager.getInstance(this).registerReceiver(settingsReceivedReceiver, new IntentFilter("com.farmerbb.taskbar.IMPORT_FINISHED"));
54 sendBroadcast(new Intent("com.farmerbb.taskbar.RECEIVE_SETTINGS"));
60 protected void onDestroy() {
63 LocalBroadcastManager.getInstance(this).unregisterReceiver(settingsReceivedReceiver);
66 // Disable back button
68 public void onBackPressed() {}