1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.storagemanager;
18
19import android.app.Activity;
20import android.app.Fragment;
21import android.app.FragmentManager;
22import android.app.FragmentTransaction;
23import android.os.Bundle;
24import android.view.ViewGroup;
25import android.widget.Button;
26import com.android.storagemanager.deletionhelper.DeletionHelperSettings;
27
28/**
29 * The DeletionHelperActivity is an activity for deleting apps, photos, and downloaded files which
30 * have not been recently used.
31 */
32public class DeletionHelperActivity extends Activity implements ButtonBarProvider {
33    private ViewGroup mButtonBar;
34    private Button mNextButton, mSkipButton;
35    private Fragment f;
36
37    @Override
38    protected void onCreate(Bundle savedInstanceState) {
39        super.onCreate(savedInstanceState);
40        setContentView(R.layout.settings_main_prefs);
41
42        // If we are not returning from an existing activity, create a new fragment.
43        if (savedInstanceState == null) {
44            FragmentManager manager = getFragmentManager();
45            f = DeletionHelperSettings.newInstance();
46            FragmentTransaction transaction = manager.beginTransaction();
47            transaction.replace(R.id.main_content, f);
48            transaction.commit();
49        }
50
51        mButtonBar = (ViewGroup) findViewById(R.id.button_bar);
52        mNextButton = (Button) findViewById(R.id.next_button);
53        mSkipButton = (Button) findViewById(R.id.skip_button);
54    }
55
56    @Override
57    public void onRequestPermissionsResult(int requestCode, String permissions[],
58            int[] grantResults) {
59        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
60        f.onRequestPermissionsResult(requestCode, permissions, grantResults);
61    }
62
63    @Override
64    public ViewGroup getButtonBar() {
65        return mButtonBar;
66    }
67
68    @Override
69    public Button getNextButton() {
70        return mNextButton;
71    }
72
73    @Override
74    public Button getSkipButton() {
75        return mSkipButton;
76    }
77}