Alarm Manager policy TARE page implementation
An alarm manager policy page is needed in the TARE developer option settings to allow developers to both view and edit the current values of all the factors under the alarm manager policy. The page uses a dropdown so that the user can easily switch between the different policies. For the factors with subfactors, the user simply clicks on the factor and the subfactors will pop up under it. Bug: 191876714 Bug: 191876567 Test: Manual (open Settings > System > Developer Options > TARE > Alarm Manger and verify all factors are there) Change-Id: Ie036e26df80947d23041bedfd5b1385e48069b6b
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.development.tare;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Dropdown activity to allow for the user to easily switch between the different TARE
|
||||
* policies in the developer options of settings. Depending on what is chosen, the fragment
|
||||
* containing that specific policies' factors will be generated.
|
||||
*/
|
||||
public class DropdownActivity extends Activity {
|
||||
|
||||
private Fragment mAlarmManagerFragment;
|
||||
private Spinner mSpinner;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tare_dropdown_page);
|
||||
|
||||
mSpinner = findViewById(R.id.spinner);
|
||||
mAlarmManagerFragment = new AlarmManagerFragment();
|
||||
|
||||
String[] policies = getResources().getStringArray(R.array.tare_policies);
|
||||
|
||||
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(DropdownActivity.this,
|
||||
android.R.layout.simple_list_item_1, policies);
|
||||
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mSpinner.setAdapter(arrayAdapter);
|
||||
|
||||
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position,
|
||||
long id) {
|
||||
openFragment(mAlarmManagerFragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Selects the correct policy fragment to display */
|
||||
private void openFragment(Fragment fragment) {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.frame_layout, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user