mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-27 06:29:54 +00:00
1) Added push messaging toggle to preferences. 2) Added push messaging registration screen to setup flow. 3) Migrated rest of SharedPreferences accessors to TextSecurePreferences.
59 lines
1.8 KiB
Java
59 lines
1.8 KiB
Java
package org.thoughtcrime.securesms.util;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.os.Build;
|
|
import android.preference.PreferenceManager;
|
|
|
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
|
import org.thoughtcrime.securesms.ConversationListActivity;
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
public class DynamicTheme {
|
|
|
|
private int currentTheme;
|
|
|
|
public void onCreate(Activity activity) {
|
|
currentTheme = getSelectedTheme(activity);
|
|
activity.setTheme(currentTheme);
|
|
}
|
|
|
|
public void onResume(Activity activity) {
|
|
if (currentTheme != getSelectedTheme(activity)) {
|
|
Intent intent = activity.getIntent();
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
|
|
activity.startActivity(intent);
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
|
OverridePendingTransition.invoke(activity);
|
|
}
|
|
|
|
activity.finish();
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
|
OverridePendingTransition.invoke(activity);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private static int getSelectedTheme(Activity activity) {
|
|
String theme = TextSecurePreferences.getTheme(activity);
|
|
|
|
if (theme.equals("light")) {
|
|
if (activity instanceof ConversationListActivity) return R.style.TextSecure_LightTheme_NavigationDrawer;
|
|
else return R.style.TextSecure_LightTheme;
|
|
} else if (theme.equals("dark")) {
|
|
if (activity instanceof ConversationListActivity) return R.style.TextSecure_DarkTheme_NavigationDrawer;
|
|
else return R.style.TextSecure_DarkTheme;
|
|
}
|
|
|
|
return R.style.TextSecure_LightTheme;
|
|
}
|
|
|
|
private static final class OverridePendingTransition {
|
|
static void invoke(Activity activity) {
|
|
activity.overridePendingTransition(0, 0);
|
|
}
|
|
}
|
|
}
|