Skip to content

Commit

Permalink
Show All Widgets and Better CPU Control
Browse files Browse the repository at this point in the history
  • Loading branch information
mightynoodle committed Feb 25, 2013
1 parent 971d408 commit f4639d9
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 6 deletions.
4 changes: 4 additions & 0 deletions res/layout/keyguard_appwidget_picker_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
android:layout_gravity="center_horizontal"
android:listSelector="@android:color/transparent"
android:id="@+id/widget_list" />
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/widget_showall"
android:text="@string/keyguard_picker_all_widgets_title"/>
</LinearLayout>
5 changes: 5 additions & 0 deletions res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@

<!-- Volume rocker support. Some devices does not have volume rocker. -->
<bool name="has_volume_rocker">true</bool>

<!-- Processor menu, freq cap files -->
<string name="max_cpu_freq_file" translatable="false">/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq</string>
<string name="min_cpu_freq_file" translatable="false">/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</string>

<!-- **** CYANOGENMOD ADDITIONS END **** -->
</resources>
4 changes: 4 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5123,6 +5123,7 @@
<string name="sms_security_check_limit_summary">Apps can send %d messages in 30 minutes before requiring confirmation</string>
<string name="sms_security_check_limit_default">30 (Default)</string>


<!--- Lock clock -->
<string name="lock_clock_title">Clock widget</string>
<string name="lock_clock_summary">View or change how the \'cLock\' Home and Lock screen widgets will display</string>
Expand Down Expand Up @@ -5213,6 +5214,9 @@
<string name="navring_action_google_now">Google Now</string>
<string name="navring_choose_action_title">Choose action</string>

<!-- Show All Widgets -->
<string name="keyguard_picker_all_widgets_title">Show all widgets</string>

<!-- **** CYANOGENMOD ADDITIONS END **** -->

<!-- Hybrid -->
Expand Down
10 changes: 8 additions & 2 deletions src/com/android/settings/AppWidgetLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public interface ItemConstructor<Item> {
* installed {@link AppWidgetProviderInfo} and those provided through
* {@link AppWidgetManager#EXTRA_CUSTOM_INFO}, sorting them alphabetically.
*/
protected List<Item> getItems(Intent intent) {
protected List<Item> getItems(Intent intent, boolean showall) {
boolean sortCustomAppWidgets =
intent.getBooleanExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, true);

Expand All @@ -151,7 +151,7 @@ protected List<Item> getItems(Intent intent) {
int categoryFilter = intent.getIntExtra(AppWidgetManager.EXTRA_CATEGORY_FILTER,
AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN);

putInstalledAppWidgets(items, categoryFilter);
putInstalledAppWidgets(items, categoryFilter, showall);

// Sort all items together by label
if (sortCustomAppWidgets) {
Expand All @@ -175,9 +175,15 @@ public int compare(Item lhs, Item rhs) {
/**
* Create list entries for installed {@link AppWidgetProviderInfo} widgets.
*/

void putInstalledAppWidgets(List<Item> items, int categoryFilter) {
List<AppWidgetProviderInfo> installed =
mAppWidgetManager.getInstalledProviders(categoryFilter);
putAppWidgetItems(installed, null, items, categoryFilter, false);

void putInstalledAppWidgets(List<Item> items, int categoryFilter, boolean showall) {
List<AppWidgetProviderInfo> installed = mAppWidgetManager.getInstalledProviders();
putAppWidgetItems(installed, null, items, categoryFilter, showall);

}
}
2 changes: 1 addition & 1 deletion src/com/android/settings/AppWidgetPickActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void onCreate(Bundle icicle) {
*/
@Override
protected List<PickAdapter.Item> getItems() {
mItems = mAppWidgetLoader.getItems(getIntent());
mItems = mAppWidgetLoader.getItems(getIntent(), false);
return mItems;
}

Expand Down
13 changes: 12 additions & 1 deletion src/com/android/settings/KeyguardAppWidgetPickActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
Expand Down Expand Up @@ -115,12 +116,22 @@ protected void onCreate(Bundle savedInstanceState) {
}
mAppWidgetManager = AppWidgetManager.getInstance(this);
mAppWidgetLoader = new AppWidgetLoader<Item>(this, mAppWidgetManager, this);
mItems = mAppWidgetLoader.getItems(getIntent());
mItems = mAppWidgetLoader.getItems(getIntent(), false);
mAppWidgetAdapter = new AppWidgetAdapter(this, mItems);
mGridView.setAdapter(mAppWidgetAdapter);
mGridView.setOnItemClickListener(this);

mLockPatternUtils = new LockPatternUtils(this); // TEMP-- we want to delete this
final Button showAll = (Button) findViewById(R.id.widget_showall);
showAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mItems = mAppWidgetLoader.getItems(getIntent(), true);
mAppWidgetAdapter = new AppWidgetAdapter(getBaseContext(), mItems);
mGridView.setAdapter(mAppWidgetAdapter);
showAll.setEnabled(false);
}
});
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/com/android/settings/cyanogenmod/BootReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.preference.PreferenceManager;
import android.util.Log;

import com.android.settings.R;
import com.android.settings.Utils;

import java.util.Arrays;
Expand Down Expand Up @@ -66,6 +67,14 @@ public void onReceive(Context ctx, Intent intent) {
}
}

private void initFreqCapFiles(Context ctx)
{
if (Processor.freqCapFilesInitialized) return;
Processor.FREQ_MAX_FILE = ctx.getResources().getString(R.string.max_cpu_freq_file);
Processor.FREQ_MIN_FILE = ctx.getResources().getString(R.string.min_cpu_freq_file);
Processor.freqCapFilesInitialized = true;
}

private void configureCPU(Context ctx) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);

Expand All @@ -87,6 +96,7 @@ private void configureCPU(Context ctx) {
if (noSettings) {
Log.d(TAG, "No CPU settings saved. Nothing to restore.");
} else {
initFreqCapFiles(ctx);
if (availableGovernorsLine != null){
governors = Arrays.asList(availableGovernorsLine.split(" "));
}
Expand Down
20 changes: 18 additions & 2 deletions src/com/android/settings/cyanogenmod/Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ public class Processor extends SettingsPreferenceFragment implements
public static final String FREQ_MIN_PREF = "pref_cpu_freq_min";
public static final String FREQ_MAX_PREF = "pref_cpu_freq_max";
public static final String FREQ_LIST_FILE = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies";
public static final String FREQ_MAX_FILE = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq";
public static final String FREQ_MIN_FILE = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq";
public static String FREQ_MAX_FILE = null;
public static String FREQ_MIN_FILE = null;
public static final String SOB_PREF = "pref_cpu_set_on_boot";

protected static boolean freqCapFilesInitialized = false;

private static final String TAG = "CPUSettings";

private String mGovernorFormat;
Expand Down Expand Up @@ -87,10 +89,20 @@ public void handleMessage(Message msg) {
}
};

private void initFreqCapFiles()
{
if (freqCapFilesInitialized) return;
FREQ_MAX_FILE = getString(R.string.max_cpu_freq_file);
FREQ_MIN_FILE = getString(R.string.min_cpu_freq_file);
freqCapFilesInitialized = true;
}

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

initFreqCapFiles();

mGovernorFormat = getString(R.string.cpu_governors_summary);
mMinFrequencyFormat = getString(R.string.cpu_min_freq_summary);
mMaxFrequencyFormat = getString(R.string.cpu_max_freq_summary);
Expand Down Expand Up @@ -185,6 +197,8 @@ public void onResume() {

super.onResume();

initFreqCapFiles();

if (Utils.fileExists(FREQ_MIN_FILE) && (temp = Utils.fileReadOneLine(FREQ_MIN_FILE)) != null) {
mMinFrequencyPref.setValue(temp);
mMinFrequencyPref.setSummary(String.format(mMinFrequencyFormat, toMHz(temp)));
Expand All @@ -211,6 +225,8 @@ public void onDestroy() {
}

public boolean onPreferenceChange(Preference preference, Object newValue) {
initFreqCapFiles();

String fname = "";

if (newValue != null) {
Expand Down

0 comments on commit f4639d9

Please sign in to comment.