Merge branch 'new-ui/dark-mode' into 'master'

Fixes for dark mode, needed after the UX Overhaul

Closes #907

See merge request !473
This commit is contained in:
Hans-Christoph Steiner 2017-04-13 16:11:44 +00:00
commit a89323b183
16 changed files with 72 additions and 15 deletions

View File

@ -98,7 +98,7 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
@Override
protected void onCreate(Bundle savedInstanceState) {
fdroidApp = (FDroidApp) getApplication();
//fdroidApp.applyTheme(this);
fdroidApp.applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.app_details2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

View File

@ -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() {
Security.addProvider(SPONGYCASTLE_PROVIDER);
}

View File

@ -26,6 +26,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
@ -43,6 +44,8 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.Preferences.Theme;
import java.text.Collator;
import java.util.ArrayList;
@ -172,7 +175,9 @@ public class AppSecurityPermissions {
label = builder;
}
Theme theme = Preferences.get().getTheme();
permGrpIcon.setImageDrawable(icon);
permGrpIcon.setColorFilter(theme == Theme.light ? Color.BLACK : Color.WHITE);
permNameView.setText(label);
setOnClickListener(this);
}

View File

@ -17,6 +17,7 @@ import info.guardianproject.netcipher.NetCipher;
import info.guardianproject.netcipher.proxy.OrbotHelper;
import org.fdroid.fdroid.AppDetails2;
import org.fdroid.fdroid.CleanCacheService;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Languages;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
@ -52,6 +53,7 @@ public class PreferencesFragment extends PreferenceFragment
private Preference updateAutoDownloadPref;
private Preference updatePrivilegedExtensionPref;
private long currentKeepCacheTime;
private FDroidApp fdroidApp;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -111,7 +113,13 @@ public class PreferencesFragment extends PreferenceFragment
case Preferences.PREF_THEME:
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;
case Preferences.PREF_INCOMP_VER:

View File

@ -69,6 +69,7 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
((FDroidApp) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

View File

@ -5,5 +5,5 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />
<solid android:color="#faf8ef" />
</shape>
<solid android:color="?attr/categoryPreviewAppCardBackground" />
</shape>

View File

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="org.fdroid.fdroid.AppDetails2"
android:background="#fcfcfc"
android:background="?attr/appDetailsBackground"
android:id="@+id/rootCoordinator"
>

View File

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/details_activity_padding"
app:cardBackgroundColor="#ffffff"
app:cardBackgroundColor="?attr/appDetailsCardBackground"
app:cardCornerRadius="3dp"
app:cardElevation="3dp">

View File

@ -32,8 +32,7 @@
android:layout_marginStart="16dp"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"
android:scaleType="fitCenter"
android:tint="@android:color/black" />
android:scaleType="fitCenter" />
<ImageView
android:layout_width="wrap_content"

View File

@ -14,7 +14,7 @@
app:layout_constraintBaseline_toBaselineOf="@+id/button"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textSize="18sp"
android:textColor="#4a4a4a"
android:textColor="?attr/categoryName"
android:paddingLeft="18dp"
android:paddingStart="18dp"
android:paddingRight="18dp"

View File

@ -32,7 +32,7 @@
android:layout_height="wrap_content"
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
android:textSize="18sp"
android:textColor="#424242"
android:textColor="?attr/installedApps"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintStart_toEndOf="@+id/icon"
@ -51,7 +51,7 @@
tools:text="Version 4.7.3 (recommended)"
android:textStyle="italic"
android:textSize="14sp"
android:textColor="#424242"
android:textColor="?attr/installedApps"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="sans-serif-light"

View File

@ -5,7 +5,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FAFAFA">
android:background="?attr/mainTabSwapBackground">
<TextView
android:id="@+id/text1"
@ -65,7 +65,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text2"
android:layout_marginTop="36dp"
android:tint="#f5f5f5"
android:tint="?attr/mainTabSwapSplashTint"
android:scaleType="fitXY" />
</android.support.constraint.ConstraintLayout>

View File

@ -31,7 +31,7 @@
android:layout_height="wrap_content"
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
android:textSize="16sp"
android:textColor="#424242"
android:textColor="?attr/installedApps"
android:lines="1"
android:ellipsize="end"
android:layout_marginStart="8dp"

View File

@ -27,7 +27,7 @@
android:layout_height="wrap_content"
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
android:textSize="16sp"
android:textColor="#424242"
android:textColor="?attr/installedApps"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintStart_toEndOf="@+id/icon"

View 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>

View File

@ -12,6 +12,13 @@
<item name="android:textViewStyle">@style/TextViewStyle</item>
<item name="actionBarTheme">@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 name="AppBaseThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
@ -25,6 +32,13 @@
<item name="android:textViewStyle">@style/TextViewStyle</item>
<item name="actionBarTheme">@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 name="AppThemeDark" parent="AppBaseThemeDark">