Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
Notes
Commits
baab5e03
Commit
baab5e03
authored
Sep 04, 2020
by
Narinder Rana
Browse files
Manage Accent color all Activity, Feb button, navigation drawer, some Button
parent
ccaf4205
Pipeline
#71534
passed with stage
in 7 minutes and 19 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/foundation/e/notes/android/activity/AboutActivity.java
View file @
baab5e03
package
foundation.e.notes.android.activity
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
androidx.annotation.ColorInt
;
import
androidx.appcompat.app.AppCompatActivity
;
import
butterknife.ButterKnife
;
import
foundation.e.notes.R
;
...
...
@@ -15,6 +20,27 @@ public class AboutActivity extends AppCompatActivity {
setContentView
(
R
.
layout
.
activity_about
);
ButterKnife
.
bind
(
this
);
getFragmentManager
().
beginTransaction
().
replace
(
R
.
id
.
container
,
new
AboutFragment
()).
commit
();
updateAccentColor
();
}
private
void
updateAccentColor
(){
//change toolbar color
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
NotesListViewActivity
.
ACCENT_COLOR
));
//change status bar color
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
darkenColor
(
NotesListViewActivity
.
ACCENT_COLOR
));
}
}
@ColorInt
int
darkenColor
(
@ColorInt
int
color
)
{
float
[]
hsv
=
new
float
[
3
];
android
.
graphics
.
Color
.
colorToHSV
(
color
,
hsv
);
hsv
[
2
]
*=
0.8f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
}
\ No newline at end of file
app/src/main/java/foundation/e/notes/android/activity/AccountActivity.java
View file @
baab5e03
...
...
@@ -4,10 +4,17 @@ import android.accounts.Account;
import
android.accounts.AccountManager
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.preference.PreferenceManager
;
import
androidx.annotation.ColorInt
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
foundation.e.notes.R
;
...
...
@@ -23,7 +30,7 @@ import static foundation.e.notes.android.activity.SettingsActivity.CREDENTIALS_C
* @author Nihar Thakkar
*/
public
class
AccountActivity
extends
AppCompatActivity
{
public
class
AccountActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
private
final
static
String
key_login_account
=
"login_account"
;
private
final
static
String
login_account_eelo
=
"login_account_eelo"
;
...
...
@@ -34,6 +41,8 @@ public class AccountActivity extends AppCompatActivity {
private
AccountManager
accountManager
;
private
SharedPreferences
sharedPreferences
;
private
Button
btn_eelo_Login
;
private
Button
btn_manualLogin
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -67,35 +76,19 @@ public class AccountActivity extends AppCompatActivity {
}
}
findViewById
(
R
.
id
.
eelo_account_login_button
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
[]
accountTypes
=
new
String
[]{
eelo_account_type
};
Intent
intent
=
AccountManager
.
newChooseAccountIntent
(
null
,
null
,
accountTypes
,
null
,
null
,
null
,
null
);
startActivityForResult
(
intent
,
pick_account_request_code
);
}
});
initview
();
updateAccentColor
();
}
private
void
initview
()
{
btn_eelo_Login
=(
Button
)
findViewById
(
R
.
id
.
eelo_account_login_button
);
btn_eelo_Login
.
setBackgroundColor
(
NotesListViewActivity
.
ACCENT_COLOR
);
btn_eelo_Login
.
setOnClickListener
(
this
);
btn_manualLogin
=(
Button
)
findViewById
(
R
.
id
.
manual_account_login_button
);
btn_manualLogin
.
setBackgroundColor
(
NotesListViewActivity
.
ACCENT_COLOR
);
btn_manualLogin
.
setOnClickListener
(
this
);
findViewById
(
R
.
id
.
manual_account_login_button
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(
getIntent
().
getBooleanExtra
(
"preference"
,
false
))
{
startActivity
(
new
Intent
(
AccountActivity
.
this
,
SettingsActivity
.
class
));
}
else
{
Intent
resultIntent
=
new
Intent
();
resultIntent
.
putExtra
(
key_login_account
,
login_account_manual
);
setResult
(
RESULT_OK
,
resultIntent
);
}
finish
();
}
});
}
@Override
...
...
@@ -128,4 +121,53 @@ public class AccountActivity extends AppCompatActivity {
}
}
}
private
void
updateAccentColor
(){
//change toolbar color
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
NotesListViewActivity
.
ACCENT_COLOR
));
//change status bar color
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
darkenColor
(
NotesListViewActivity
.
ACCENT_COLOR
));
}
}
@ColorInt
int
darkenColor
(
@ColorInt
int
color
)
{
float
[]
hsv
=
new
float
[
3
];
android
.
graphics
.
Color
.
colorToHSV
(
color
,
hsv
);
hsv
[
2
]
*=
0.8f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
@Override
public
void
onClick
(
View
view
)
{
if
(
view
==
btn_manualLogin
){
if
(
getIntent
().
getBooleanExtra
(
"preference"
,
false
))
{
startActivity
(
new
Intent
(
AccountActivity
.
this
,
SettingsActivity
.
class
));
}
else
{
Intent
resultIntent
=
new
Intent
();
resultIntent
.
putExtra
(
key_login_account
,
login_account_manual
);
setResult
(
RESULT_OK
,
resultIntent
);
}
finish
();
}
else
if
(
view
==
btn_eelo_Login
){
String
[]
accountTypes
=
new
String
[]{
eelo_account_type
};
Intent
intent
=
AccountManager
.
newChooseAccountIntent
(
null
,
null
,
accountTypes
,
null
,
null
,
null
,
null
);
startActivityForResult
(
intent
,
pick_account_request_code
);
}
}
}
app/src/main/java/foundation/e/notes/android/activity/EditNoteActivity.java
View file @
baab5e03
...
...
@@ -3,12 +3,17 @@ package foundation.e.notes.android.activity;
import
android.app.Fragment
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.preference.PreferenceManager
;
import
android.util.Log
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
androidx.annotation.ColorInt
;
import
androidx.appcompat.app.ActionBar
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -48,6 +53,8 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
if
(
actionBar
!=
null
)
{
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
}
updateAccentColor
();
}
@Override
...
...
@@ -214,4 +221,25 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
}
}
}
private
void
updateAccentColor
(){
//change toolbar color
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
NotesListViewActivity
.
ACCENT_COLOR
));
//change status bar color
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
darkenColor
(
NotesListViewActivity
.
ACCENT_COLOR
));
}
}
@ColorInt
int
darkenColor
(
@ColorInt
int
color
)
{
float
[]
hsv
=
new
float
[
3
];
android
.
graphics
.
Color
.
colorToHSV
(
color
,
hsv
);
hsv
[
2
]
*=
0.8f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
}
app/src/main/java/foundation/e/notes/android/activity/NotesListViewActivity.java
View file @
baab5e03
...
...
@@ -8,6 +8,7 @@ import android.content.Intent;
import
android.content.SharedPreferences
;
import
android.content.pm.ShortcutInfo
;
import
android.content.pm.ShortcutManager
;
import
android.content.res.ColorStateList
;
import
android.content.res.Configuration
;
import
android.graphics.Canvas
;
import
android.graphics.drawable.ColorDrawable
;
...
...
@@ -249,6 +250,8 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
ACCENT_COLOR
=
fetchAccentColor
(
this
);
fabCreate
.
setBackgroundTintList
(
ColorStateList
.
valueOf
(
darkenColor20
(
ACCENT_COLOR
)));
headerView
.
setBackgroundColor
(
ACCENT_COLOR
);
}
private
void
migrateUrl
()
{
...
...
@@ -980,4 +983,12 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
hsv
[
2
]
*=
0.8f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
@ColorInt
int
darkenColor20
(
@ColorInt
int
color
)
{
float
[]
hsv
=
new
float
[
3
];
android
.
graphics
.
Color
.
colorToHSV
(
color
,
hsv
);
hsv
[
2
]
*=
0.6f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
}
app/src/main/java/foundation/e/notes/android/activity/PreferencesActivity.java
View file @
baab5e03
package
foundation.e.notes.android.activity
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
androidx.annotation.ColorInt
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -21,5 +26,28 @@ public class PreferencesActivity extends AppCompatActivity {
getFragmentManager
().
beginTransaction
()
.
replace
(
android
.
R
.
id
.
content
,
new
PreferencesFragment
())
.
commit
();
updateAccentColor
();
}
private
void
updateAccentColor
(){
//change toolbar color
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
NotesListViewActivity
.
ACCENT_COLOR
));
//change status bar color
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
darkenColor
(
NotesListViewActivity
.
ACCENT_COLOR
));
}
}
@ColorInt
int
darkenColor
(
@ColorInt
int
color
)
{
float
[]
hsv
=
new
float
[
3
];
android
.
graphics
.
Color
.
colorToHSV
(
color
,
hsv
);
hsv
[
2
]
*=
0.8f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
}
app/src/main/java/foundation/e/notes/android/activity/SelectSingleNoteActivity.java
View file @
baab5e03
...
...
@@ -4,11 +4,16 @@ import android.app.Activity;
import
android.appwidget.AppWidgetManager
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.preference.PreferenceManager
;
import
android.view.Menu
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
androidx.annotation.ColorInt
;
import
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
;
import
butterknife.BindView
;
...
...
@@ -43,6 +48,8 @@ public class SelectSingleNoteActivity extends NotesListViewActivity {
}
swipeRefreshLayout
.
setEnabled
(
false
);
swipeRefreshLayout
.
setRefreshing
(
false
);
updateAccentColor
();
}
@Override
...
...
@@ -76,4 +83,25 @@ public class SelectSingleNoteActivity extends NotesListViewActivity {
getApplicationContext
().
sendBroadcast
(
updateIntent
);
finish
();
}
private
void
updateAccentColor
(){
//change toolbar color
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
NotesListViewActivity
.
ACCENT_COLOR
));
//change status bar color
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
darkenColor
(
NotesListViewActivity
.
ACCENT_COLOR
));
}
}
@ColorInt
int
darkenColor
(
@ColorInt
int
color
)
{
float
[]
hsv
=
new
float
[
3
];
android
.
graphics
.
Color
.
colorToHSV
(
color
,
hsv
);
hsv
[
2
]
*=
0.8f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
}
app/src/main/java/foundation/e/notes/android/activity/SettingsActivity.java
View file @
baab5e03
...
...
@@ -2,6 +2,7 @@ package foundation.e.notes.android.activity;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.graphics.drawable.ColorDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.net.http.SslCertificate
;
import
android.net.http.SslError
;
...
...
@@ -15,6 +16,8 @@ import android.text.TextWatcher;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.webkit.SslErrorHandler
;
import
android.webkit.WebSettings
;
import
android.webkit.WebView
;
...
...
@@ -35,6 +38,8 @@ import foundation.e.notes.persistence.NoteServerSyncHelper;
import
foundation.e.notes.util.ExceptionHandler
;
import
foundation.e.notes.util.NotesClientUtil
;
import
foundation.e.notes.util.NotesClientUtil.LoginStatus
;
import
androidx.annotation.ColorInt
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.core.content.ContextCompat
;
...
...
@@ -137,6 +142,9 @@ public class SettingsActivity extends AppCompatActivity {
setPasswordHint
(
false
);
handleSubmitButtonEnabled
();
updateAccentColor
();
}
private
void
setupListener
()
{
...
...
@@ -544,4 +552,27 @@ public class SettingsActivity extends AppCompatActivity {
String
username
;
String
password
;
}
private
void
updateAccentColor
(){
//change toolbar color
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
NotesListViewActivity
.
ACCENT_COLOR
));
//change status bar color
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
darkenColor
(
NotesListViewActivity
.
ACCENT_COLOR
));
}
btn_submit
.
setBackgroundColor
(
NotesListViewActivity
.
ACCENT_COLOR
);
}
@ColorInt
int
darkenColor
(
@ColorInt
int
color
)
{
float
[]
hsv
=
new
float
[
3
];
android
.
graphics
.
Color
.
colorToHSV
(
color
,
hsv
);
hsv
[
2
]
*=
0.8f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
}
app/src/main/java/foundation/e/notes/android/appwidget/NoteListWidgetConfiguration.java
View file @
baab5e03
...
...
@@ -4,14 +4,20 @@ import android.app.Activity;
import
android.appwidget.AppWidgetManager
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.preference.PreferenceManager
;
import
androidx.annotation.ColorInt
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.util.Log
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.Toast
;
import
java.util.ArrayList
;
...
...
@@ -116,6 +122,8 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
layoutManager
=
new
LinearLayoutManager
(
this
);
recyclerView
.
setLayoutManager
(
layoutManager
);
recyclerView
.
setAdapter
(
adapterCategories
);
updateAccentColor
();
}
@Override
...
...
@@ -162,4 +170,26 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
adapterCategories
.
setItems
(
items
);
}
}
private
void
updateAccentColor
(){
//change toolbar color
getSupportActionBar
().
setBackgroundDrawable
(
new
ColorDrawable
(
NotesListViewActivity
.
ACCENT_COLOR
));
//change status bar color
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
Window
window
=
getWindow
();
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
);
window
.
setStatusBarColor
(
darkenColor
(
NotesListViewActivity
.
ACCENT_COLOR
));
}
}
@ColorInt
int
darkenColor
(
@ColorInt
int
color
)
{
float
[]
hsv
=
new
float
[
3
];
android
.
graphics
.
Color
.
colorToHSV
(
color
,
hsv
);
hsv
[
2
]
*=
0.8f
;
return
android
.
graphics
.
Color
.
HSVToColor
(
hsv
);
}
}
Write
Preview
Supports
Markdown
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