Improve settings screen

This commit is contained in:
2016-04-19 07:49:06 -04:00
parent bd6fcd066c
commit 8938b0c9a6
8 changed files with 73 additions and 34 deletions

View File

@@ -20,15 +20,11 @@
package org.isoron.uhabits;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.View;
import android.widget.TextView;
import org.isoron.uhabits.helpers.ColorHelper;
import org.isoron.uhabits.helpers.UIHelper;
public class AboutActivity extends BaseActivity implements View.OnClickListener
@@ -42,14 +38,8 @@ public class AboutActivity extends BaseActivity implements View.OnClickListener
setContentView(R.layout.about);
setupSupportActionBar(true);
if (android.os.Build.VERSION.SDK_INT >= 21 && !UIHelper.isNightMode())
{
int color = UIHelper.getStyledColor(this, R.attr.aboutScreenColor);
int darkerColor = ColorHelper.mixColors(color, Color.BLACK, 0.75f);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) actionBar.setBackgroundDrawable(new ColorDrawable(color));
getWindow().setStatusBarColor(darkerColor);
}
int color = UIHelper.getStyledColor(this, R.attr.aboutScreenColor);
setupActionBarColor(color);
TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
TextView tvRate = (TextView) findViewById(R.id.tvRate);

View File

@@ -20,6 +20,8 @@
package org.isoron.uhabits;
import android.app.backup.BackupManager;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@@ -29,6 +31,7 @@ import android.support.v7.widget.Toolbar;
import android.widget.Toast;
import org.isoron.uhabits.commands.Command;
import org.isoron.uhabits.helpers.ColorHelper;
import org.isoron.uhabits.helpers.UIHelper;
import java.util.LinkedList;
@@ -162,4 +165,21 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
else
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);
}
}
}

View File

@@ -21,6 +21,8 @@ package org.isoron.uhabits;
import android.os.Bundle;
import org.isoron.uhabits.helpers.UIHelper;
public class SettingsActivity extends BaseActivity
{
@Override
@@ -29,5 +31,8 @@ public class SettingsActivity extends BaseActivity
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
setupSupportActionBar(true);
int color = UIHelper.getStyledColor(this, R.attr.aboutScreenColor);
setupActionBarColor(color);
}
}

View File

@@ -20,15 +20,11 @@
package org.isoron.uhabits;
import android.content.ContentUris;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import org.isoron.uhabits.helpers.ColorHelper;
import org.isoron.uhabits.helpers.UIHelper;
import org.isoron.uhabits.models.Habit;
public class ShowHabitActivity extends BaseActivity
@@ -58,17 +54,7 @@ public class ShowHabitActivity extends BaseActivity
actionBar.setTitle(habit.name);
if (!UIHelper.getStyledBoolean(this, R.attr.useHabitColorAsPrimary)) return;
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);
}
setupActionBarColor(ColorHelper.getColor(this, habit.color));
}
public Habit getHabit()

View File

@@ -22,15 +22,15 @@ package org.isoron.uhabits.fragments;
import android.app.backup.BackupManager;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceFragmentCompat;
import org.isoron.uhabits.MainActivity;
import org.isoron.uhabits.R;
import org.isoron.uhabits.helpers.UIHelper;
public class SettingsFragment extends PreferenceFragment
public class SettingsFragment extends PreferenceFragmentCompat
implements SharedPreferences.OnSharedPreferenceChangeListener
{
@Override
@@ -48,6 +48,12 @@ public class SettingsFragment extends PreferenceFragment
removePreference("translate", "linksCategory");
}
@Override
public void onCreatePreferences(Bundle bundle, String s)
{
}
private void removePreference(String preferenceKey, String categoryKey)
{
PreferenceCategory cat = (PreferenceCategory) findPreference(categoryKey);