mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Improve settings screen
This commit is contained in:
@@ -35,7 +35,7 @@ dependencies {
|
|||||||
compile 'com.android.support:support-v4:23.2.1'
|
compile 'com.android.support:support-v4:23.2.1'
|
||||||
compile 'com.android.support:appcompat-v7:23.2.1'
|
compile 'com.android.support:appcompat-v7:23.2.1'
|
||||||
compile 'com.android.support:design:23.2.1'
|
compile 'com.android.support:design:23.2.1'
|
||||||
compile 'com.android.support:preference-v7:23.2.1'
|
compile 'com.android.support:preference-v14:23.2.1'
|
||||||
compile 'com.github.paolorotolo:appintro:3.4.0'
|
compile 'com.github.paolorotolo:appintro:3.4.0'
|
||||||
compile 'org.apmem.tools:layouts:1.10@aar'
|
compile 'org.apmem.tools:layouts:1.10@aar'
|
||||||
compile 'com.opencsv:opencsv:3.7'
|
compile 'com.opencsv:opencsv:3.7'
|
||||||
|
|||||||
@@ -20,15 +20,11 @@
|
|||||||
package org.isoron.uhabits;
|
package org.isoron.uhabits;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.helpers.UIHelper;
|
||||||
|
|
||||||
public class AboutActivity extends BaseActivity implements View.OnClickListener
|
public class AboutActivity extends BaseActivity implements View.OnClickListener
|
||||||
@@ -42,14 +38,8 @@ public class AboutActivity extends BaseActivity implements View.OnClickListener
|
|||||||
setContentView(R.layout.about);
|
setContentView(R.layout.about);
|
||||||
setupSupportActionBar(true);
|
setupSupportActionBar(true);
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21 && !UIHelper.isNightMode())
|
|
||||||
{
|
|
||||||
int color = UIHelper.getStyledColor(this, R.attr.aboutScreenColor);
|
int color = UIHelper.getStyledColor(this, R.attr.aboutScreenColor);
|
||||||
int darkerColor = ColorHelper.mixColors(color, Color.BLACK, 0.75f);
|
setupActionBarColor(color);
|
||||||
ActionBar actionBar = getSupportActionBar();
|
|
||||||
if(actionBar != null) actionBar.setBackgroundDrawable(new ColorDrawable(color));
|
|
||||||
getWindow().setStatusBarColor(darkerColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
|
TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
|
||||||
TextView tvRate = (TextView) findViewById(R.id.tvRate);
|
TextView tvRate = (TextView) findViewById(R.id.tvRate);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
package org.isoron.uhabits;
|
package org.isoron.uhabits;
|
||||||
|
|
||||||
import android.app.backup.BackupManager;
|
import android.app.backup.BackupManager;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -29,6 +31,7 @@ import android.support.v7.widget.Toolbar;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.isoron.uhabits.commands.Command;
|
import org.isoron.uhabits.commands.Command;
|
||||||
|
import org.isoron.uhabits.helpers.ColorHelper;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.helpers.UIHelper;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -162,4 +165,21 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
|||||||
else
|
else
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setupActionBarColor(int color)
|
||||||
|
{
|
||||||
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
if(actionBar == null) return;
|
||||||
|
|
||||||
|
if (!UIHelper.getStyledBoolean(this, R.attr.useHabitColorAsPrimary)) return;
|
||||||
|
|
||||||
|
ColorDrawable drawable = new ColorDrawable(color);
|
||||||
|
actionBar.setBackgroundDrawable(drawable);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
{
|
||||||
|
int darkerColor = ColorHelper.mixColors(color, Color.BLACK, 0.75f);
|
||||||
|
getWindow().setStatusBarColor(darkerColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ package org.isoron.uhabits;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.isoron.uhabits.helpers.UIHelper;
|
||||||
|
|
||||||
public class SettingsActivity extends BaseActivity
|
public class SettingsActivity extends BaseActivity
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -29,5 +31,8 @@ public class SettingsActivity extends BaseActivity
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.settings_activity);
|
setContentView(R.layout.settings_activity);
|
||||||
setupSupportActionBar(true);
|
setupSupportActionBar(true);
|
||||||
|
|
||||||
|
int color = UIHelper.getStyledColor(this, R.attr.aboutScreenColor);
|
||||||
|
setupActionBarColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,11 @@
|
|||||||
package org.isoron.uhabits;
|
package org.isoron.uhabits;
|
||||||
|
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.helpers.ColorHelper;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
public class ShowHabitActivity extends BaseActivity
|
public class ShowHabitActivity extends BaseActivity
|
||||||
@@ -58,17 +54,7 @@ public class ShowHabitActivity extends BaseActivity
|
|||||||
|
|
||||||
actionBar.setTitle(habit.name);
|
actionBar.setTitle(habit.name);
|
||||||
|
|
||||||
if (!UIHelper.getStyledBoolean(this, R.attr.useHabitColorAsPrimary)) return;
|
setupActionBarColor(ColorHelper.getColor(this, habit.color));
|
||||||
|
|
||||||
int color = ColorHelper.getColor(this, habit.color);
|
|
||||||
ColorDrawable drawable = new ColorDrawable(color);
|
|
||||||
actionBar.setBackgroundDrawable(drawable);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
{
|
|
||||||
int darkerColor = ColorHelper.mixColors(color, Color.BLACK, 0.75f);
|
|
||||||
getWindow().setStatusBarColor(darkerColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Habit getHabit()
|
public Habit getHabit()
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ package org.isoron.uhabits.fragments;
|
|||||||
import android.app.backup.BackupManager;
|
import android.app.backup.BackupManager;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.preference.PreferenceCategory;
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceFragment;
|
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
import org.isoron.uhabits.MainActivity;
|
import org.isoron.uhabits.MainActivity;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.helpers.UIHelper;
|
||||||
|
|
||||||
public class SettingsFragment extends PreferenceFragment
|
public class SettingsFragment extends PreferenceFragmentCompat
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener
|
implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -48,6 +48,12 @@ public class SettingsFragment extends PreferenceFragment
|
|||||||
removePreference("translate", "linksCategory");
|
removePreference("translate", "linksCategory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle bundle, String s)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void removePreference(String preferenceKey, String categoryKey)
|
private void removePreference(String preferenceKey, String categoryKey)
|
||||||
{
|
{
|
||||||
PreferenceCategory cat = (PreferenceCategory) findPreference(categoryKey);
|
PreferenceCategory cat = (PreferenceCategory) findPreference(categoryKey);
|
||||||
|
|||||||
26
app/src/main/res/layout/preference_category_custom.xml
Normal file
26
app/src/main/res/layout/preference_category_custom.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2015 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License
|
||||||
|
-->
|
||||||
|
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@android:id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="0dip"
|
||||||
|
android:textColor="?aboutScreenColor"
|
||||||
|
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingLeft"
|
||||||
|
android:paddingTop="8dip" />
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
|
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
|
||||||
|
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
<item name="android:dialogTheme">@style/MyDialogStyle</item>
|
<item name="android:dialogTheme">@style/MyDialogStyle</item>
|
||||||
<item name="android:alertDialogTheme">@style/MyDialogStyle</item>
|
<item name="android:alertDialogTheme">@style/MyDialogStyle</item>
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
|
|
||||||
<item name="colorPrimary">@color/blue_grey_800</item>
|
<item name="colorPrimary">@color/blue_grey_800</item>
|
||||||
<item name="colorPrimaryDark">@color/blue_grey_900</item>
|
<item name="colorPrimaryDark">@color/blue_grey_900</item>
|
||||||
|
<item name="colorAccent">?aboutScreenColor</item>
|
||||||
<item name="cardBackgroundColor">@color/grey_50</item>
|
<item name="cardBackgroundColor">@color/grey_50</item>
|
||||||
<item name="windowBackgroundColor">@color/grey_200</item>
|
<item name="windowBackgroundColor">@color/grey_200</item>
|
||||||
<item name="headerBackgroundColor">@color/grey_200</item>
|
<item name="headerBackgroundColor">@color/grey_200</item>
|
||||||
@@ -56,10 +58,11 @@
|
|||||||
<item name="dialogFormSpinnerTheme">@style/dialogFormSpinnerLight</item>
|
<item name="dialogFormSpinnerTheme">@style/dialogFormSpinnerLight</item>
|
||||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||||
|
|
||||||
<item name="aboutScreenColor">@color/blue_700</item>
|
<item name="aboutScreenColor">@color/blue_800</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AppBaseThemeDark" parent="@style/Theme.AppCompat.NoActionBar">
|
<style name="AppBaseThemeDark" parent="@style/Theme.AppCompat.NoActionBar">
|
||||||
|
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||||
<item name="windowActionModeOverlay">true</item>
|
<item name="windowActionModeOverlay">true</item>
|
||||||
<item name="android:dialogTheme">@style/MyDialogStyleDark</item>
|
<item name="android:dialogTheme">@style/MyDialogStyleDark</item>
|
||||||
<item name="android:alertDialogTheme">@style/MyDialogStyleDark</item>
|
<item name="android:alertDialogTheme">@style/MyDialogStyleDark</item>
|
||||||
@@ -70,6 +73,7 @@
|
|||||||
|
|
||||||
<item name="colorPrimary">@color/grey_950</item>
|
<item name="colorPrimary">@color/grey_950</item>
|
||||||
<item name="colorPrimaryDark">@color/black</item>
|
<item name="colorPrimaryDark">@color/black</item>
|
||||||
|
<item name="colorAccent">?aboutScreenColor</item>
|
||||||
<item name="cardBackgroundColor">@color/grey_850</item>
|
<item name="cardBackgroundColor">@color/grey_850</item>
|
||||||
<item name="windowBackgroundColor">@color/grey_900</item>
|
<item name="windowBackgroundColor">@color/grey_900</item>
|
||||||
<item name="headerBackgroundColor">@color/grey_900</item>
|
<item name="headerBackgroundColor">@color/grey_900</item>
|
||||||
@@ -215,5 +219,7 @@
|
|||||||
<item name="android:spinnerDropDownItemStyle">@style/dialogFormSpinnerDropDown</item>
|
<item name="android:spinnerDropDownItemStyle">@style/dialogFormSpinnerDropDown</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Preference.Category.Material">
|
||||||
|
<item name="android:layout">@layout/preference_category_custom</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user