Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a812b02 authored by AdrianDC's avatar AdrianDC Committed by Gerrit Code Review
Browse files

Settings: Apps started on boot shortcut in memory settings



 * Implement an intent extra to retrieve a tab target
 * Use a tab identifer from apps_ops_categories_cm
    to make sure the selection is correct or ignored

Change-Id: I79d963ecbadc624dc45a398387a348691318b6be
Signed-off-by: default avatarAdrianDC <radian.dc@gmail.com>
parent a5e14738
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
<!--
     Copyright (C) 2012-2015 The CyanogenMod Project
     Copyright (C) 2012-2016 The CyanogenMod Project


     Licensed under the Apache License, Version 2.0 (the "License");
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     you may not use this file except in compliance with the License.
@@ -225,4 +225,7 @@
    <!-- Lights settings -->
    <!-- Lights settings -->
    <string name="lights_label">Lights</string>
    <string name="lights_label">Lights</string>


    <!-- Memory -->
    <string name="memory_startup_apps_title">Apps started on boot</string>

</resources>
</resources>
+7 −1
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project
<!--
     Copyright (C) 2015 The Android Open Source Project
     Copyright (C) 2015-2016 The CyanogenMod Project


     Licensed under the Apache License, Version 2.0 (the "License");
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     you may not use this file except in compliance with the License.
@@ -61,4 +63,8 @@
        android:key="apps_list"
        android:key="apps_list"
        android:title="@string/memory_usage_apps" />
        android:title="@string/memory_usage_apps" />


    <Preference
        android:key="apps_startup"
        android:title="@string/memory_startup_apps_title" />

</PreferenceScreen>
</PreferenceScreen>
+2 −1
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (C) 2008 The Android Open Source Project
 * Copyright (C) 2008 The Android Open Source Project
 * Copyright (C) 2016 The CyanogenMod Project
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
+12 −1
Original line number Original line Diff line number Diff line
/**
/**
 * Copyright (C) 2013 The Android Open Source Project
 * Copyright (C) 2013 The Android Open Source Project
 * Copyright (C) 2016 The CyanogenMod Project
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * 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
 * use this file except in compliance with the License. You may obtain a copy
@@ -41,6 +42,7 @@ import android.view.ViewGroup;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.logging.MetricsProto.MetricsEvent;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.List;


import com.android.settings.DevelopmentSettings;
import com.android.settings.DevelopmentSettings;
@@ -133,10 +135,19 @@ public class AppOpsSummary extends InstrumentedFragment {


        mPageNames = getResources().getTextArray(R.array.app_ops_categories_cm);
        mPageNames = getResources().getTextArray(R.array.app_ops_categories_cm);


        int defaultTab = -1;
        Bundle bundle = getArguments();
        if (bundle != null) {
            defaultTab = Arrays.asList(mPageNames).indexOf(bundle.getString("appops_tab", ""));
        }

        mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
        mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
        mAdapter = new MyPagerAdapter(getChildFragmentManager(),
        mAdapter = new MyPagerAdapter(getChildFragmentManager(),
                filterTemplates(AppOpsState.ALL_TEMPLATES));
                filterTemplates(AppOpsState.ALL_TEMPLATES));
        mViewPager.setAdapter(mAdapter);
        mViewPager.setAdapter(mAdapter);
        if (defaultTab >= 0) {
            mViewPager.setCurrentItem(defaultTab);
        }
        mViewPager.setOnPageChangeListener(mAdapter);
        mViewPager.setOnPageChangeListener(mAdapter);
        PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
        PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);


+17 −0
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (C) 2015 The Android Open Source Project
 * Copyright (C) 2015 The Android Open Source Project
 * Copyright (C) 2016 The CyanogenMod Project
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
@@ -17,6 +18,7 @@ package com.android.settings.applications;


import android.app.Activity;
import android.app.Activity;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
@@ -24,6 +26,7 @@ import android.text.format.Formatter;
import android.text.format.Formatter.BytesResult;
import android.text.format.Formatter.BytesResult;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.R;
import com.android.settings.Settings.AppOpsSummaryActivity;
import com.android.settings.SummaryPreference;
import com.android.settings.SummaryPreference;
import com.android.settings.Utils;
import com.android.settings.Utils;
import com.android.settings.applications.ProcStatsData.MemInfo;
import com.android.settings.applications.ProcStatsData.MemInfo;
@@ -38,6 +41,9 @@ public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenc
    private static final String KEY_AVERAGY_USED = "average_used";
    private static final String KEY_AVERAGY_USED = "average_used";
    private static final String KEY_FREE = "free";
    private static final String KEY_FREE = "free";
    private static final String KEY_APP_LIST = "apps_list";
    private static final String KEY_APP_LIST = "apps_list";
    private static final String KEY_APP_STARTUP = "apps_startup";

    private Activity mActivity;


    private SummaryPreference mSummaryPref;
    private SummaryPreference mSummaryPref;


@@ -46,11 +52,14 @@ public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenc
    private Preference mAverageUsed;
    private Preference mAverageUsed;
    private Preference mFree;
    private Preference mFree;
    private Preference mAppListPreference;
    private Preference mAppListPreference;
    private Preference mAppStartupPreference;


    @Override
    @Override
    public void onCreate(Bundle icicle) {
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        super.onCreate(icicle);


        mActivity = getActivity();

        addPreferencesFromResource(R.xml.process_stats_summary);
        addPreferencesFromResource(R.xml.process_stats_summary);
        mSummaryPref = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
        mSummaryPref = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
        int memColor = getContext().getColor(R.color.running_processes_apps_ram);
        int memColor = getContext().getColor(R.color.running_processes_apps_ram);
@@ -63,6 +72,8 @@ public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenc
        mFree = findPreference(KEY_FREE);
        mFree = findPreference(KEY_FREE);
        mAppListPreference = findPreference(KEY_APP_LIST);
        mAppListPreference = findPreference(KEY_APP_LIST);
        mAppListPreference.setOnPreferenceClickListener(this);
        mAppListPreference.setOnPreferenceClickListener(this);
        mAppStartupPreference = findPreference(KEY_APP_STARTUP);
        mAppStartupPreference.setOnPreferenceClickListener(this);
    }
    }


    @Override
    @Override
@@ -116,6 +127,12 @@ public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenc
            startFragment(this, ProcessStatsUi.class.getName(), R.string.app_list_memory_use, 0,
            startFragment(this, ProcessStatsUi.class.getName(), R.string.app_list_memory_use, 0,
                    args);
                    args);
            return true;
            return true;
        } else if (preference == mAppStartupPreference) {
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.putExtra("appops_tab", getString(R.string.app_ops_categories_bootup));
            intent.setClass(mActivity, AppOpsSummaryActivity.class);
            mActivity.startActivity(intent);
            return true;
        }
        }
        return false;
        return false;
    }
    }