// Set OnClickListeners for certain preferences
findPreference("enable_recents").setOnPreferenceClickListener(this);
findPreference("max_num_of_recents").setOnPreferenceClickListener(this);
+ findPreference("refresh_frequency").setOnPreferenceClickListener(this);
- bindPreferenceSummaryToValue(findPreference("refresh_frequency"));
bindPreferenceSummaryToValue(findPreference("recents_amount"));
bindPreferenceSummaryToValue(findPreference("sort_order"));
bindPreferenceSummaryToValue(findPreference("disable_scrolling_list"));
actionBar.setDisplayHomeAsUpEnabled(true);
updateMaxNumOfRecents(false);
+ updateRefreshFrequency(false);
finishedLoadingPrefs = true;
}
final int max = 26;
AlertDialog.Builder builder6 = new AlertDialog.Builder(getActivity());
- LinearLayout dialogLayout2 = (LinearLayout) View.inflate(getActivity(), R.layout.max_num_of_recents, null);
+ LinearLayout dialogLayout2 = (LinearLayout) View.inflate(getActivity(), R.layout.seekbar_pref, null);
String value = pref.getString("max_num_of_recents", "10");
final TextView textView = (TextView) dialogLayout2.findViewById(R.id.seekbar_value);
+ textView.setText("0");
+
final SeekBar seekBar = (SeekBar) dialogLayout2.findViewById(R.id.seekbar);
seekBar.setMax(max);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
seekBar.setProgress(Integer.parseInt(value));
+ TextView blurb = (TextView) dialogLayout2.findViewById(R.id.blurb);
+ blurb.setText(R.string.num_of_recents_blurb);
+
builder6.setView(dialogLayout2)
.setTitle(R.string.pref_max_num_of_recents)
.setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() {
AlertDialog dialog6 = builder6.create();
dialog6.show();
break;
+ case "refresh_frequency":
+ final int max2 = 20;
+
+ AlertDialog.Builder builder7 = new AlertDialog.Builder(getActivity());
+ LinearLayout dialogLayout3 = (LinearLayout) View.inflate(getActivity(), R.layout.seekbar_pref, null);
+
+ String value2 = pref.getString("refresh_frequency", "2");
+
+ final TextView textView2 = (TextView) dialogLayout3.findViewById(R.id.seekbar_value);
+ textView2.setText(R.string.infinity);
+
+ final SeekBar seekBar2 = (SeekBar) dialogLayout3.findViewById(R.id.seekbar);
+ seekBar2.setMax(max2);
+ seekBar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ if(progress == 0)
+ textView2.setText(R.string.infinity);
+ else
+ textView2.setText(Double.toString(progress * 0.5));
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {}
+ });
+
+ seekBar2.setProgress((int) (Double.parseDouble(value2) * 2));
+
+ TextView blurb2 = (TextView) dialogLayout3.findViewById(R.id.blurb);
+ blurb2.setText(R.string.refresh_frequency_blurb);
+
+ builder7.setView(dialogLayout3)
+ .setTitle(R.string.pref_title_recents_refresh_interval)
+ .setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ double progress = seekBar2.getProgress() * 0.5;
+
+ pref.edit().putString("refresh_frequency", Double.toString(progress)).apply();
+ updateRefreshFrequency(true);
+ }
+ })
+ .setNegativeButton(R.string.action_cancel, null);
+
+ AlertDialog dialog7 = builder7.create();
+ dialog7.show();
+ break;
}
return true;
if(restartTaskbar) restartTaskbar();
}
+
+ protected void updateRefreshFrequency(boolean restartTaskbar) {
+ SharedPreferences pref = U.getSharedPreferences(getActivity());
+ String value = pref.getString("refresh_frequency", "2");
+ double doubleValue = Double.parseDouble(value);
+ int intValue = (int) doubleValue;
+
+ if(doubleValue == 0)
+ findPreference("refresh_frequency").setSummary(R.string.refresh_frequency_continuous);
+ else if(doubleValue == 1)
+ findPreference("refresh_frequency").setSummary(R.string.refresh_frequency_singular);
+ else if(doubleValue == (double) intValue)
+ findPreference("refresh_frequency").setSummary(getString(R.string.refresh_frequency, Integer.toString(intValue)));
+ else
+ findPreference("refresh_frequency").setSummary(getString(R.string.refresh_frequency, value));
+
+ if(restartTaskbar) restartTaskbar();
+ }
}
\ No newline at end of file
}
});
- refreshInterval = Integer.parseInt(pref.getString("refresh_frequency", "2")) * 1000;
+ refreshInterval = (int) (Float.parseFloat(pref.getString("refresh_frequency", "2")) * 1000);
sortOrder = pref.getString("sort_order", "false");
switch(pref.getString("recents_amount", "past_day")) {
<TextView
android:id="@+id/seekbar_value"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="0"/>
+ android:layout_height="wrap_content" />
</LinearLayout>
<TextView
+ android:id="@+id/blurb"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/num_of_recents_blurb" />
+ android:layout_height="wrap_content" />
</LinearLayout>
\ No newline at end of file
<string name="pref_title_enable_recents">使用状況アクセスを有効/無効にする</string>
<string name="pref_title_recents_refresh_interval">リストのリフレッシュ間隔</string>
- <string-array name="pref_refresh_frequency">
- <item>1 秒</item>
- <item>2 秒</item>
- <item>5 秒</item>
- </string-array>
<string name="pref_title_amount_of_recents">起動したアプリの表示</string>
<string-array name="pref_recents_amount">
<string name="max_num_of_recents_singular">1 app</string>
<string name="max_num_of_recents_unlimited">Unlimited</string>
+ <string name="refresh_frequency_blurb">Ensure that usage access is enabled before changing this setting.\n\nLower values will increase CPU usage and may decrease battery life.</string>
+ <string name="refresh_frequency">%1$s 秒</string>
+ <string name="refresh_frequency_singular">1 秒</string>
+ <string name="refresh_frequency_continuous">Continuous</string>
+
</resources>
<string name="pref_title_enable_recents">Включить/выключить разрешение</string>
<string name="pref_title_recents_refresh_interval">Обновлять список через</string>
- <string-array name="pref_refresh_frequency">
- <item>1 секунду</item>
- <item>2 секунды</item>
- <item>5 секунд</item>
- </string-array>
<string name="pref_title_amount_of_recents">Показывать список</string>
<string-array name="pref_recents_amount">
<string name="max_num_of_recents_singular">1 приложений</string>
<string name="max_num_of_recents_unlimited">Без ограничений</string>
+ <string name="refresh_frequency_blurb">Ensure that usage access is enabled before changing this setting.\n\nLower values will increase CPU usage and may decrease battery life.</string>
+ <string name="refresh_frequency">%1$s секунд</string>
+ <string name="refresh_frequency_singular">1 секунду</string>
+ <string name="refresh_frequency_continuous">Continuous</string>
+
</resources>
<string name="right_arrow" translatable="false">❯</string>
<string name="x" translatable="false">×</string>
<string name="dashboard_grid_description" translatable="false">%1$d × %2$d</string>
- <string name="infinity">∞</string>
+ <string name="infinity" translatable="false">∞</string>
<string-array name="pref_start_menu_list_values">
<item>list</item>
<item>grid</item>
</string-array>
- <string-array name="pref_refresh_frequency_values">
- <item>1</item>
- <item>2</item>
- <item>5</item>
- </string-array>
-
<string-array name="pref_recents_amount_values">
<item>past_day</item>
<item>app_start</item>
<item>phone_size</item>
</string-array>
- <string-array name="pref_max_num_of_recents_list_values">
- <item>10</item>
- <item>15</item>
- <item>20</item>
- <item>2147483647</item>
- </string-array>
-
<string-array name="pref_show_search_bar_list_values">
<item>always</item>
<item>keyboard</item>
<string name="pref_header_recent_apps">Recent apps</string>
<string name="pref_title_enable_recents">Enable/disable usage access</string>
- <string name="pref_title_recents_refresh_interval">Refresh list every</string>
- <string-array name="pref_refresh_frequency">
- <item>1 second</item>
- <item>2 seconds</item>
- <item>5 seconds</item>
- </string-array>
+ <string name="pref_title_recents_refresh_interval">Refresh rate</string>
<string name="pref_title_amount_of_recents">Display apps launched</string>
<string-array name="pref_recents_amount">
<string name="max_num_of_recents_singular">1 app</string>
<string name="max_num_of_recents_unlimited">Unlimited</string>
+ <string name="refresh_frequency_blurb">Ensure that usage access is enabled before changing this setting.\n\nLower values will increase CPU usage and may decrease battery life.</string>
+ <string name="refresh_frequency">%1$s seconds</string>
+ <string name="refresh_frequency_singular">1 second</string>
+ <string name="refresh_frequency_continuous">Continuous</string>
+
</resources>
android:key="enable_recents"
android:title="@string/pref_title_enable_recents"/>
- <ListPreference
- android:defaultValue="2"
- android:entries="@array/pref_refresh_frequency"
- android:entryValues="@array/pref_refresh_frequency_values"
+ <Preference
android:key="refresh_frequency"
- android:negativeButtonText="@null"
- android:positiveButtonText="@null"
android:title="@string/pref_title_recents_refresh_interval"/>
<ListPreference