Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
1de748e3
Commit
1de748e3
authored
Feb 04, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preserve dark theme settings
parent
b21a9e47
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
6 deletions
+28
-6
app/src/main/java/app/insti/Constants.java
app/src/main/java/app/insti/Constants.java
+1
-0
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+6
-0
app/src/main/java/app/insti/fragment/SettingsFragment.java
app/src/main/java/app/insti/fragment/SettingsFragment.java
+17
-6
app/src/main/res/values/styles.xml
app/src/main/res/values/styles.xml
+4
-0
No files found.
app/src/main/java/app/insti/Constants.java
View file @
1de748e3
...
...
@@ -6,6 +6,7 @@ public class Constants {
public
static
final
int
MY_PERMISSIONS_REQUEST_LOCATION
=
3
;
public
static
final
int
RESULT_LOAD_IMAGE
=
11
;
public
static
final
int
REQUEST_CAMERA_INT_ID
=
101
;
public
static
final
String
DARK_THEME
=
"dark_theme"
;
public
static
final
String
NOTIFICATIONS_RESPONSE_JSON
=
"notifications_json"
;
public
static
final
String
EVENT_ID
=
"event_id"
;
public
static
final
String
EVENT_LATITUDE
=
"event_latitude"
;
...
...
app/src/main/java/app/insti/activity/MainActivity.java
View file @
1de748e3
...
...
@@ -7,6 +7,7 @@ import android.app.NotificationChannel;
import
android.app.NotificationManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.graphics.Color
;
...
...
@@ -115,6 +116,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
/* Check for dark theme */
SharedPreferences
sharedPref
=
getSharedPreferences
(
Constants
.
PREF_NAME
,
Context
.
MODE_PRIVATE
);
if
(
sharedPref
.
getBoolean
(
Constants
.
DARK_THEME
,
false
))
this
.
setTheme
(
R
.
style
.
AppThemeDark
);
ServiceGenerator
serviceGenerator
=
new
ServiceGenerator
(
getApplicationContext
());
Utils
.
setRetrofitInterface
(
serviceGenerator
.
getRetrofitInterface
());
...
...
app/src/main/java/app/insti/fragment/SettingsFragment.java
View file @
1de748e3
package
app.insti.fragment
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.support.v7.preference.Preference
;
...
...
@@ -22,17 +24,23 @@ import retrofit2.Callback;
import
retrofit2.Response
;
public
class
SettingsFragment
extends
PreferenceFragmentCompat
{
SwitchPreferenceCompat
showContactPref
;
SwitchPreferenceCompat
darkThemePref
;
Preference
profilePref
;
Preference
feedbackPref
;
Preference
aboutPref
;
Preference
logoutPref
;
private
SwitchPreferenceCompat
showContactPref
;
private
SwitchPreferenceCompat
darkThemePref
;
private
Preference
profilePref
;
private
Preference
feedbackPref
;
private
Preference
aboutPref
;
private
Preference
logoutPref
;
private
SharedPreferences
sharedPref
;
private
SharedPreferences
.
Editor
editor
;
@Override
public
void
onCreatePreferences
(
Bundle
savedInstanceState
,
String
rootKey
)
{
setPreferencesFromResource
(
R
.
xml
.
preferences
,
rootKey
);
// Get preferences and editor
sharedPref
=
getActivity
().
getSharedPreferences
(
Constants
.
PREF_NAME
,
Context
.
MODE_PRIVATE
);
editor
=
sharedPref
.
edit
();
// Show contact number
showContactPref
=
(
SwitchPreferenceCompat
)
findPreference
(
"show_contact"
);
showContactPref
.
setOnPreferenceChangeListener
(
new
Preference
.
OnPreferenceChangeListener
()
{
...
...
@@ -53,6 +61,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
return
true
;
}
});
darkThemePref
.
setChecked
(
sharedPref
.
getBoolean
(
Constants
.
DARK_THEME
,
false
));
// Update Profile
profilePref
=
findPreference
(
"profile"
);
...
...
@@ -164,6 +173,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}
public
void
toggleDarkTheme
(
final
SwitchPreferenceCompat
showContactPref
,
Object
o
)
{
editor
.
putBoolean
(
Constants
.
DARK_THEME
,
(
boolean
)
o
);
editor
.
commit
();
Utils
.
changeTheme
(
this
,
(
boolean
)
o
);
}
...
...
app/src/main/res/values/styles.xml
View file @
1de748e3
...
...
@@ -10,6 +10,8 @@
<item
name=
"themeColorInverse"
>
#000000
</item>
<item
name=
"newsColor"
>
#F2F2F2
</item>
<item
name=
"urlColor"
>
@color/colorPrimary
</item>
<item
name=
"windowActionBar"
>
false
</item>
<item
name=
"windowNoTitle"
>
true
</item>
</style>
<style
name=
"AppTheme.NoActionBar"
>
...
...
@@ -25,6 +27,8 @@
<item
name=
"themeColorInverse"
>
#FFFFFF
</item>
<item
name=
"newsColor"
>
#00000000
</item>
<item
name=
"urlColor"
>
@color/colorAccent
</item>
<item
name=
"windowActionBar"
>
false
</item>
<item
name=
"windowNoTitle"
>
true
</item>
</style>
<style
name=
"AppThemeDark.NoActionBar"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment