diff --git a/app/src/main/java/brice_bastien/epicture/AccountSetting.java b/app/src/main/java/brice_bastien/epicture/AccountSetting.java index 9654c3e..0adf679 100644 --- a/app/src/main/java/brice_bastien/epicture/AccountSetting.java +++ b/app/src/main/java/brice_bastien/epicture/AccountSetting.java @@ -10,13 +10,15 @@ import android.widget.RadioButton; import android.widget.Switch; import android.widget.TextView; +import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; +import androidx.preference.PreferenceManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import brice_bastien.epicture.ImgurApi.ImgurApi; import brice_bastien.epicture.Settings.SettingItem; -public class AccountSetting extends AppCompatActivity { +public class AccountSetting extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener { private String Token = ""; private String Username = ""; @@ -37,6 +39,18 @@ public class AccountSetting extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); + Boolean switchPref = sharedPrefs.getBoolean(SettingsActivity.KEY_PREF_EXAMPLE_SWITCH, false); + if (switchPref) { + setTheme(R.style.AppTheme_DARK); + getWindow().setNavigationBarColor(getResources().getColor(R.color.colorAccentDarker)); + } else { + setTheme(R.style.AppTheme); + getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimary)); + } + sharedPrefs.registerOnSharedPreferenceChangeListener(this); + setContentView(R.layout.activity_account_setting); mature = findViewById(R.id.switch_mature_content); @@ -116,4 +130,21 @@ public void initSetting(SettingItem settingItem) { } } + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if (key.equals(SettingsActivity.KEY_PREF_EXAMPLE_SWITCH)) { + if (sharedPreferences.getBoolean(SettingsActivity.KEY_PREF_EXAMPLE_SWITCH, false)) { + setTheme(R.style.AppTheme_DARK); + getWindow().setNavigationBarColor(getResources().getColor(R.color.colorAccentDarker)); + } else { + setTheme(R.style.AppTheme); + getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimary)); + } + recreate(); + } + + } + + + } diff --git a/app/src/main/java/brice_bastien/epicture/PostComment.java b/app/src/main/java/brice_bastien/epicture/PostComment.java index f906486..73dacd7 100644 --- a/app/src/main/java/brice_bastien/epicture/PostComment.java +++ b/app/src/main/java/brice_bastien/epicture/PostComment.java @@ -35,7 +35,6 @@ public class PostComment extends AppCompatActivity implements SharedPreferences. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_post_comment); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); Boolean switchPref = sharedPrefs.getBoolean(SettingsActivity.KEY_PREF_EXAMPLE_SWITCH, false); @@ -48,6 +47,7 @@ protected void onCreate(Bundle savedInstanceState) { } sharedPrefs.registerOnSharedPreferenceChangeListener(this); + setContentView(R.layout.activity_post_comment); sharedPreferences = getSharedPreferences(getString(R.string.user_info_pref), Context.MODE_PRIVATE); Token = sharedPreferences.getString("User_Token", null); @@ -58,7 +58,7 @@ protected void onCreate(Bundle savedInstanceState) { startActivity(intent); finish(); } - + RecyclerView recyclerView = findViewById(R.id.commentList); Intent intent = getIntent(); @@ -72,7 +72,6 @@ protected void onCreate(Bundle savedInstanceState) { Context context = recyclerView.getContext(); recyclerView.setLayoutManager(new LinearLayoutManager(context)); - View loadingView = getLayoutInflater().inflate(R.layout.view_loading, recyclerView, false); View emptyView = getLayoutInflater().inflate(R.layout.view_empty, recyclerView, false); View errorView = getLayoutInflater().inflate(R.layout.view_error, recyclerView, false); diff --git a/app/src/main/java/brice_bastien/epicture/PostDetails.java b/app/src/main/java/brice_bastien/epicture/PostDetails.java index fc2d0ce..dae2c1b 100644 --- a/app/src/main/java/brice_bastien/epicture/PostDetails.java +++ b/app/src/main/java/brice_bastien/epicture/PostDetails.java @@ -57,7 +57,6 @@ public class PostDetails extends AppCompatActivity implements SharedPreferences. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_post_details); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); Boolean switchPref = sharedPrefs.getBoolean(SettingsActivity.KEY_PREF_EXAMPLE_SWITCH, false); @@ -70,6 +69,8 @@ protected void onCreate(Bundle savedInstanceState) { } sharedPrefs.registerOnSharedPreferenceChangeListener(this); + setContentView(R.layout.activity_post_details); + sharedPreferences = getSharedPreferences(getString(R.string.user_info_pref), Context.MODE_PRIVATE); Token = sharedPreferences.getString("User_Token", null); Username = sharedPreferences.getString("Username", null); diff --git a/app/src/main/res/drawable/ic_edit.xml b/app/src/main/res/drawable/ic_edit.xml index 163e5bb..b847b28 100644 --- a/app/src/main/res/drawable/ic_edit.xml +++ b/app/src/main/res/drawable/ic_edit.xml @@ -4,6 +4,6 @@ android:viewportWidth="24" android:viewportHeight="24"> diff --git a/app/src/main/res/layout/activity_post_comment.xml b/app/src/main/res/layout/activity_post_comment.xml index 8576bef..98ebc17 100644 --- a/app/src/main/res/layout/activity_post_comment.xml +++ b/app/src/main/res/layout/activity_post_comment.xml @@ -49,7 +49,6 @@ android:layout_height="@dimen/bottom_bar_height" android:layout_gravity="center_vertical|center_horizontal" android:layout_weight="5" - android:background="@color/white" android:gravity="center|start" android:hint="@string/add_comment_hint" android:inputType="textMultiLine|textCapSentences" diff --git a/app/src/main/res/layout/fragment_bottomsheet.xml b/app/src/main/res/layout/fragment_bottomsheet.xml index 84830a3..40f04d0 100644 --- a/app/src/main/res/layout/fragment_bottomsheet.xml +++ b/app/src/main/res/layout/fragment_bottomsheet.xml @@ -15,7 +15,7 @@ android:layout_marginTop="8dp" android:layout_marginEnd="8dp" app:itemIconTint="@color/colorPrimary" - app:itemTextColor="@color/colorPrimaryText" + app:itemTextColor="@color/colorPrimary" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/app/src/main/res/layout/fragment_comments.xml b/app/src/main/res/layout/fragment_comments.xml index 74cdb19..eb942f2 100644 --- a/app/src/main/res/layout/fragment_comments.xml +++ b/app/src/main/res/layout/fragment_comments.xml @@ -23,7 +23,6 @@ android:layout_marginStart="@dimen/basic_margin" android:layout_marginTop="4dp" android:layout_marginBottom="@dimen/basic_margin" - android:textColor="@color/colorPrimaryText" android:padding="0dp" /> @@ -49,7 +48,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="40dp" - android:textColor="@color/colorSecondaryText" android:textSize="10sp" /> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8e0ae58..cb95685 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -6,6 +6,7 @@ @color/colorPrimaryDark @color/colorAccent @color/colorIcon + #000 @color/colorPrimary 90% 90% @@ -18,7 +19,8 @@ 90% - + + -