Commit c6e35c34 authored by Romain Hunault's avatar Romain Hunault
Browse files

Merge branch 'issue_1727' into 'master'

Issue 1727

See merge request e/apps/notes!13
parents 89fb3c79 baab5e03
Pipeline #72733 passed with stage
in 2 minutes and 42 seconds
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
......@@ -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();
}
});
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();
}
});
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);
}
@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);
}
}
}
......@@ -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);
}
}
......@@ -3,33 +3,42 @@ package foundation.e.notes.android.activity;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.SearchManager;
import android.content.Context;
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;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.AppCompatImageView;
......@@ -102,6 +111,8 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
private final static String login_account_eelo = "login_account_eelo";
private final static String key_email_address = "email_address";
public static int ACCENT_COLOR;
@BindView(R.id.notesListActivityActionBar)
Toolbar toolbar;
......@@ -236,6 +247,11 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
// dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(getResources().getColor(R.color.fg_default));
// dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(getResources().getColor(R.color.fg_default));
//}
ACCENT_COLOR= fetchAccentColor(this);
fabCreate.setBackgroundTintList(ColorStateList.valueOf(darkenColor20(ACCENT_COLOR)));
headerView.setBackgroundColor(ACCENT_COLOR);
}
private void migrateUrl() {
......@@ -931,4 +947,48 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
adapter.notifyDataSetChanged();
}
}
/*
* get Accent color from OS
* */
private int fetchAccentColor(Context context) {
TypedValue typedValue = new TypedValue();
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(this,
android.R.style.Theme_DeviceDefault);
contextThemeWrapper.getTheme().resolveAttribute(android.R.attr.colorAccent,
typedValue, true);
int color_accent = typedValue.data;
Log.e("TAG", "accent Colour #"+Integer.toHexString(color_accent));
//change toolbar color
getSupportActionBar().setBackgroundDrawable(
new ColorDrawable(color_accent));
//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(color_accent));
}
return color_accent;
}
@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);
}
@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);
}
}
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);
}
}
......@@ -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);
}
}
......@@ -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);
}
}
......@@ -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);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment