Add "Light Theme" setting
Default theme is dark (Holo dark on >=11), addition is light on <11, Holo.Ligt on >=11 and Holo.Light.DarkActionbar on >=14
This commit is contained in:
parent
d6a66017e9
commit
50f0856f67
@ -29,6 +29,7 @@
|
|||||||
android:name="FDroidApp"
|
android:name="FDroidApp"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme"
|
||||||
android:supportsRtl="false" >
|
android:supportsRtl="false" >
|
||||||
<activity
|
<activity
|
||||||
android:name="FDroid"
|
android:name="FDroid"
|
||||||
|
11
res/values-v11/styles.xml
Normal file
11
res/values-v11/styles.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<style name="AppBaseTheme" parent="android:Theme.Holo">
|
||||||
|
<!-- API 11 theme customizations go here -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppBaseThemeLight" parent="android:Theme.Holo.Light">
|
||||||
|
<!-- API 11 theme customizations go here -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
11
res/values-v14/styles.xml
Normal file
11
res/values-v14/styles.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<style name="AppBaseTheme" parent="android:Theme.Holo">
|
||||||
|
<!-- API 14 theme customizations go here -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppBaseThemeLight" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||||
|
<!-- API 14 theme customizations go here -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
@ -186,5 +186,7 @@
|
|||||||
<string name="no_handler_app">You don\'t have any available app that can handle %s</string>
|
<string name="no_handler_app">You don\'t have any available app that can handle %s</string>
|
||||||
<string name="compactlayout">Compact Layout</string>
|
<string name="compactlayout">Compact Layout</string>
|
||||||
<string name="compactlayout_long">Only show app names and summaries in list</string>
|
<string name="compactlayout_long">Only show app names and summaries in list</string>
|
||||||
|
<string name="lightTheme">Light Theme</string>
|
||||||
|
<string name="lightTheme_long">Use a light theme</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
19
res/values/styles.xml
Normal file
19
res/values/styles.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<style name="AppBaseTheme" parent="android:Theme.Black">
|
||||||
|
<!-- backward-compatibility theme options go here -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppBaseThemeLight" parent="android:Theme.Light">
|
||||||
|
<!-- backward-compatibility theme options go here -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme" parent="AppBaseTheme">
|
||||||
|
<!-- customizations that are not API-level specific go here. -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppThemeLight" parent="AppBaseThemeLight">
|
||||||
|
<!-- customizations that are not API-level specific go here. -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
@ -33,6 +33,9 @@
|
|||||||
<CheckBoxPreference android:title="@string/compactlayout"
|
<CheckBoxPreference android:title="@string/compactlayout"
|
||||||
android:defaultValue="false" android:summary="@string/compactlayout_long"
|
android:defaultValue="false" android:summary="@string/compactlayout_long"
|
||||||
android:key="compactlayout"/>
|
android:key="compactlayout"/>
|
||||||
|
<CheckBoxPreference android:title="@string/lightTheme"
|
||||||
|
android:defaultValue="false" android:summary="@string/lightTheme_long"
|
||||||
|
android:key="lightTheme"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/antifeatures">
|
<PreferenceCategory android:title="@string/antifeatures">
|
||||||
<CheckBoxPreference android:title="@string/antiads"
|
<CheckBoxPreference android:title="@string/antiads"
|
||||||
|
@ -184,6 +184,10 @@ public class AppDetails extends ListActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
if (PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
.getBoolean("lightTheme", false))
|
||||||
|
setTheme(R.style.AppThemeLight);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
ActionBarCompat abCompat = ActionBarCompat.create(this);
|
ActionBarCompat abCompat = ActionBarCompat.create(this);
|
||||||
abCompat.setDisplayHomeAsUpEnabled(true);
|
abCompat.setDisplayHomeAsUpEnabled(true);
|
||||||
|
@ -33,6 +33,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.ResultReceiver;
|
import android.os.ResultReceiver;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -61,6 +62,7 @@ public class FDroid extends FragmentActivity {
|
|||||||
private ProgressDialog pd;
|
private ProgressDialog pd;
|
||||||
|
|
||||||
private ViewPager viewPager;
|
private ViewPager viewPager;
|
||||||
|
private AppListFragmentPageAdapter viewPageAdapter;
|
||||||
|
|
||||||
private AppListManager manager = null;
|
private AppListManager manager = null;
|
||||||
|
|
||||||
@ -73,6 +75,10 @@ public class FDroid extends FragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
if (PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
.getBoolean("lightTheme", false))
|
||||||
|
setTheme(R.style.AppThemeLight);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
manager = new AppListManager(this);
|
manager = new AppListManager(this);
|
||||||
setContentView(R.layout.fdroid);
|
setContentView(R.layout.fdroid);
|
||||||
@ -242,6 +248,13 @@ public class FDroid extends FragmentActivity {
|
|||||||
UpdateService.schedule(getBaseContext());
|
UpdateService.schedule(getBaseContext());
|
||||||
if (data != null && data.hasExtra("update")) {
|
if (data != null && data.hasExtra("update")) {
|
||||||
updateRepos();
|
updateRepos();
|
||||||
|
} else if (data != null && data.hasExtra("restart")) {
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
|
finish();
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
repopulateViews();
|
repopulateViews();
|
||||||
}
|
}
|
||||||
@ -252,7 +265,7 @@ public class FDroid extends FragmentActivity {
|
|||||||
|
|
||||||
private void createViews() {
|
private void createViews() {
|
||||||
viewPager = (ViewPager)findViewById(R.id.main_pager);
|
viewPager = (ViewPager)findViewById(R.id.main_pager);
|
||||||
AppListFragmentPageAdapter viewPageAdapter = new AppListFragmentPageAdapter(this);
|
viewPageAdapter = new AppListFragmentPageAdapter(this);
|
||||||
viewPager.setAdapter(viewPageAdapter);
|
viewPager.setAdapter(viewPageAdapter);
|
||||||
viewPager.setOnPageChangeListener( new ViewPager.SimpleOnPageChangeListener() {
|
viewPager.setOnPageChangeListener( new ViewPager.SimpleOnPageChangeListener() {
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
|
@ -77,6 +77,10 @@ public class ManageRepo extends ListActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
if (PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
.getBoolean("lightTheme", false))
|
||||||
|
setTheme(R.style.AppThemeLight);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.repolist);
|
setContentView(R.layout.repolist);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import android.app.ActionBar;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -32,28 +33,48 @@ import org.fdroid.fdroid.compat.ActionBarCompat;
|
|||||||
public class PreferencesActivity extends PreferenceActivity implements
|
public class PreferencesActivity extends PreferenceActivity implements
|
||||||
OnPreferenceClickListener {
|
OnPreferenceClickListener {
|
||||||
|
|
||||||
|
|
||||||
|
private boolean ignoreTouchscreenChanged = false;
|
||||||
|
private boolean showIncompatibleChanged = false;
|
||||||
|
private boolean lightThemeChanged = false;
|
||||||
|
|
||||||
|
Intent ret;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
if (PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
.getBoolean("lightTheme", false))
|
||||||
|
setTheme(R.style.AppThemeLight);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
ActionBarCompat.create(this).setDisplayHomeAsUpEnabled(true);
|
ActionBarCompat.create(this).setDisplayHomeAsUpEnabled(true);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
for (String prefkey : new String[] { "ignoreTouchscreen",
|
for (String prefkey : new String[] { "ignoreTouchscreen",
|
||||||
"showIncompatible" }) {
|
"showIncompatible", "lightTheme" }) {
|
||||||
Preference pref = findPreference(prefkey);
|
Preference pref = findPreference(prefkey);
|
||||||
pref.setOnPreferenceClickListener(this);
|
pref.setOnPreferenceClickListener(this);
|
||||||
}
|
}
|
||||||
|
ret = new Intent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
// Currently only one action is returned.
|
String key = preference.getKey();
|
||||||
//String key = preference.getKey();
|
if (key.equals("ignoreTouchscreen"))
|
||||||
//if (key.equals("ignoreTouchscreen") || key.equals("showIncompatible")) {
|
ignoreTouchscreenChanged ^= true;
|
||||||
Intent ret = new Intent();
|
else if (key.equals("showIncompatible"))
|
||||||
|
showIncompatibleChanged ^= true;
|
||||||
|
else
|
||||||
|
lightThemeChanged ^= true;
|
||||||
|
|
||||||
|
if (lightThemeChanged)
|
||||||
|
ret.putExtra("restart", true);
|
||||||
|
else if (ignoreTouchscreenChanged || showIncompatibleChanged)
|
||||||
ret.putExtra("update", true);
|
ret.putExtra("update", true);
|
||||||
|
|
||||||
setResult(RESULT_OK, ret);
|
setResult(RESULT_OK, ret);
|
||||||
return true;
|
return true;
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user