OSDN Git Service

Taskbar 4.0 (release 2)
[android-x86/packages-apps-Taskbar.git] / app / src / main / java / com / farmerbb / taskbar / activity / TouchAbsorberActivity.java
1 /* Copyright 2018 Braden Farmer
2  *
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
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15
16 package com.farmerbb.taskbar.activity;
17
18 import android.annotation.SuppressLint;
19 import android.app.Activity;
20 import android.content.BroadcastReceiver;
21 import android.content.Context;
22 import android.content.Intent;
23 import android.content.IntentFilter;
24 import android.os.Bundle;
25 import android.support.v4.content.LocalBroadcastManager;
26 import android.widget.FrameLayout;
27 import android.widget.LinearLayout;
28
29 import com.farmerbb.taskbar.R;
30 import com.farmerbb.taskbar.util.DisplayInfo;
31 import com.farmerbb.taskbar.util.FreeformHackHelper;
32 import com.farmerbb.taskbar.util.U;
33
34 public class TouchAbsorberActivity extends Activity {
35
36     private BroadcastReceiver finishReceiver = new BroadcastReceiver() {
37         @Override
38         public void onReceive(Context context, Intent intent) {
39             finish();
40         }
41     };
42
43     @SuppressLint("HardwareIds")
44     @SuppressWarnings("deprecation")
45     @Override
46     protected void onCreate(Bundle savedInstanceState) {
47         super.onCreate(savedInstanceState);
48         setContentView(R.layout.incognito);
49
50         DisplayInfo display = U.getDisplayInfo(this);
51         LinearLayout layout = U.findViewById(this, R.id.incognitoLayout);
52         layout.setLayoutParams(new FrameLayout.LayoutParams(display.width, display.height));
53
54         LocalBroadcastManager.getInstance(this).registerReceiver(finishReceiver, new IntentFilter("com.farmerbb.taskbar.FINISH_FREEFORM_ACTIVITY"));
55         FreeformHackHelper.getInstance().setTouchAbsorberActive(true);
56     }
57
58     @Override
59     protected void onStop() {
60         super.onStop();
61         finish();
62     }
63
64     @Override
65     protected void onDestroy() {
66         LocalBroadcastManager.getInstance(this).unregisterReceiver(finishReceiver);
67         FreeformHackHelper.getInstance().setTouchAbsorberActive(false);
68
69         super.onDestroy();
70     }
71
72     @Override
73     public void onBackPressed() {}
74 }