Fixes for dark mode, needed after the UX Overhaul
* Replace hardcoded color values with references to style.xml, which in turn has different values for light and dark theme. * Force reload the activity to get the theme applied. TODO: * Swap uses it's own theme, need to figure out a way to handle that. Currently the main Nearby screen which you get to from the bottom navigation is ok, but anything after that is light / custom themed.
This commit is contained in:
parent
46adf47fdf
commit
c2685bf14e
@ -98,7 +98,7 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
fdroidApp = (FDroidApp) getApplication();
|
fdroidApp = (FDroidApp) getApplication();
|
||||||
//fdroidApp.applyTheme(this);
|
fdroidApp.applyTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.app_details2);
|
setContentView(R.layout.app_details2);
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
@ -143,6 +143,24 @@ public class FDroidApp extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force reload the {@link Activity to make theme changes take effect.}
|
||||||
|
* Same as {@link Languages.forceChangeLanguage}
|
||||||
|
*
|
||||||
|
* @param activity the {@code Activity} to force reload
|
||||||
|
*/
|
||||||
|
public static void forceChangeTheme(Activity activity) {
|
||||||
|
Intent intent = activity.getIntent();
|
||||||
|
if (intent == null) { // when launched as LAUNCHER
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
|
activity.finish();
|
||||||
|
activity.overridePendingTransition(0, 0);
|
||||||
|
activity.startActivity(intent);
|
||||||
|
activity.overridePendingTransition(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public static void enableSpongyCastle() {
|
public static void enableSpongyCastle() {
|
||||||
Security.addProvider(SPONGYCASTLE_PROVIDER);
|
Security.addProvider(SPONGYCASTLE_PROVIDER);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.PermissionGroupInfo;
|
import android.content.pm.PermissionGroupInfo;
|
||||||
import android.content.pm.PermissionInfo;
|
import android.content.pm.PermissionInfo;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@ -43,6 +44,8 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
|
import org.fdroid.fdroid.Preferences;
|
||||||
|
import org.fdroid.fdroid.Preferences.Theme;
|
||||||
|
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -172,7 +175,9 @@ public class AppSecurityPermissions {
|
|||||||
label = builder;
|
label = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Theme theme = Preferences.get().getTheme();
|
||||||
permGrpIcon.setImageDrawable(icon);
|
permGrpIcon.setImageDrawable(icon);
|
||||||
|
permGrpIcon.setColorFilter(theme == Theme.light ? Color.BLACK : Color.WHITE);
|
||||||
permNameView.setText(label);
|
permNameView.setText(label);
|
||||||
setOnClickListener(this);
|
setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import info.guardianproject.netcipher.NetCipher;
|
|||||||
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
||||||
import org.fdroid.fdroid.AppDetails2;
|
import org.fdroid.fdroid.AppDetails2;
|
||||||
import org.fdroid.fdroid.CleanCacheService;
|
import org.fdroid.fdroid.CleanCacheService;
|
||||||
|
import org.fdroid.fdroid.FDroidApp;
|
||||||
import org.fdroid.fdroid.Languages;
|
import org.fdroid.fdroid.Languages;
|
||||||
import org.fdroid.fdroid.Preferences;
|
import org.fdroid.fdroid.Preferences;
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
@ -52,6 +53,7 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
private Preference updateAutoDownloadPref;
|
private Preference updateAutoDownloadPref;
|
||||||
private Preference updatePrivilegedExtensionPref;
|
private Preference updatePrivilegedExtensionPref;
|
||||||
private long currentKeepCacheTime;
|
private long currentKeepCacheTime;
|
||||||
|
private FDroidApp fdroidApp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -111,7 +113,13 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
|
|
||||||
case Preferences.PREF_THEME:
|
case Preferences.PREF_THEME:
|
||||||
entrySummary(key);
|
entrySummary(key);
|
||||||
// TODO: Ask MainActivity to restart itself.
|
if (changing) {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
fdroidApp = (FDroidApp) activity.getApplication();
|
||||||
|
fdroidApp.reloadTheme();
|
||||||
|
fdroidApp.applyTheme(activity);
|
||||||
|
fdroidApp.forceChangeTheme(activity);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_INCOMP_VER:
|
case Preferences.PREF_INCOMP_VER:
|
||||||
|
@ -69,6 +69,7 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
((FDroidApp) getApplication()).applyTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
-->
|
-->
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<corners android:radius="4dp" />
|
<corners android:radius="4dp" />
|
||||||
<solid android:color="#faf8ef" />
|
<solid android:color="?attr/categoryPreviewAppCardBackground" />
|
||||||
</shape>
|
</shape>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
tools:context="org.fdroid.fdroid.AppDetails2"
|
tools:context="org.fdroid.fdroid.AppDetails2"
|
||||||
android:background="#fcfcfc"
|
android:background="?attr/appDetailsBackground"
|
||||||
android:id="@+id/rootCoordinator"
|
android:id="@+id/rootCoordinator"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/details_activity_padding"
|
android:layout_margin="@dimen/details_activity_padding"
|
||||||
app:cardBackgroundColor="#ffffff"
|
app:cardBackgroundColor="?attr/appDetailsCardBackground"
|
||||||
app:cardCornerRadius="3dp"
|
app:cardCornerRadius="3dp"
|
||||||
app:cardElevation="3dp">
|
app:cardElevation="3dp">
|
||||||
|
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter" />
|
||||||
android:tint="@android:color/black" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
app:layout_constraintBaseline_toBaselineOf="@+id/button"
|
app:layout_constraintBaseline_toBaselineOf="@+id/button"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textColor="#4a4a4a"
|
android:textColor="?attr/categoryName"
|
||||||
android:paddingLeft="18dp"
|
android:paddingLeft="18dp"
|
||||||
android:paddingStart="18dp"
|
android:paddingStart="18dp"
|
||||||
android:paddingRight="18dp"
|
android:paddingRight="18dp"
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
|
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textColor="#424242"
|
android:textColor="?attr/installedApps"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||||
@ -51,7 +51,7 @@
|
|||||||
tools:text="Version 4.7.3 (recommended)"
|
tools:text="Version 4.7.3 (recommended)"
|
||||||
android:textStyle="italic"
|
android:textStyle="italic"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="#424242"
|
android:textColor="?attr/installedApps"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:fontFamily="sans-serif-light"
|
android:fontFamily="sans-serif-light"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#FAFAFA">
|
android:background="?attr/mainTabSwapBackground">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text1"
|
android:id="@+id/text1"
|
||||||
@ -65,7 +65,7 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/text2"
|
app:layout_constraintTop_toBottomOf="@+id/text2"
|
||||||
android:layout_marginTop="36dp"
|
android:layout_marginTop="36dp"
|
||||||
android:tint="#f5f5f5"
|
android:tint="?attr/mainTabSwapSplashTint"
|
||||||
android:scaleType="fitXY" />
|
android:scaleType="fitXY" />
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
@ -31,7 +31,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
|
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="#424242"
|
android:textColor="?attr/installedApps"
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
|
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="#424242"
|
android:textColor="?attr/installedApps"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||||
|
12
app/src/main/res/values/attrs.xml
Normal file
12
app/src/main/res/values/attrs.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<declare-styleable name="Theme">
|
||||||
|
<attr name="appDetailsBackground" format="color" />
|
||||||
|
<attr name="appDetailsCardBackground" format="color" />
|
||||||
|
<attr name="categoryPreviewAppCardBackground" format="color" />
|
||||||
|
<attr name="mainTabSwapBackground" format="color" />
|
||||||
|
<attr name="mainTabSwapSplashTint" format="color" />
|
||||||
|
<attr name="categoryName" format="color" />
|
||||||
|
<attr name="installedApps" format="color" />
|
||||||
|
</declare-styleable>
|
||||||
|
</resources>
|
@ -12,6 +12,13 @@
|
|||||||
<item name="android:textViewStyle">@style/TextViewStyle</item>
|
<item name="android:textViewStyle">@style/TextViewStyle</item>
|
||||||
<item name="actionBarTheme">@style/AppThemeLight.Toolbar</item>
|
<item name="actionBarTheme">@style/AppThemeLight.Toolbar</item>
|
||||||
<item name="actionBarPopupTheme">@style/AppThemeLight.Toolbar</item>
|
<item name="actionBarPopupTheme">@style/AppThemeLight.Toolbar</item>
|
||||||
|
<item name="appDetailsBackground">#0c0c0c</item>
|
||||||
|
<item name="appDetailsCardBackground">#000000</item>
|
||||||
|
<item name="categoryPreviewAppCardBackground">#000000</item>
|
||||||
|
<item name="mainTabSwapBackground">#0a0a0a</item>
|
||||||
|
<item name="mainTabSwapSplashTint">#050505</item>
|
||||||
|
<item name="categoryName">#ffffff</item>
|
||||||
|
<item name="installedApps">#ffffff</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppBaseThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
|
<style name="AppBaseThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
@ -25,6 +32,13 @@
|
|||||||
<item name="android:textViewStyle">@style/TextViewStyle</item>
|
<item name="android:textViewStyle">@style/TextViewStyle</item>
|
||||||
<item name="actionBarTheme">@style/AppThemeLight.Toolbar</item>
|
<item name="actionBarTheme">@style/AppThemeLight.Toolbar</item>
|
||||||
<item name="actionBarPopupTheme">@style/AppThemeLight.Toolbar</item>
|
<item name="actionBarPopupTheme">@style/AppThemeLight.Toolbar</item>
|
||||||
|
<item name="appDetailsBackground">#fcfcfc</item>
|
||||||
|
<item name="appDetailsCardBackground">#ffffff</item>
|
||||||
|
<item name="categoryPreviewAppCardBackground">#faf8ef</item>
|
||||||
|
<item name="mainTabSwapBackground">#fafafa</item>
|
||||||
|
<item name="mainTabSwapSplashTint">#f5f5f5</item>
|
||||||
|
<item name="categoryName">#4a4a4a</item>
|
||||||
|
<item name="installedApps">#424242</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppThemeDark" parent="AppBaseThemeDark">
|
<style name="AppThemeDark" parent="AppBaseThemeDark">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user