mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Fix toolbars
This commit is contained in:
@@ -31,6 +31,7 @@ import android.support.v7.widget.Toolbar;
|
|||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
|
||||||
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.tasks.ProgressBar;
|
import org.isoron.uhabits.tasks.ProgressBar;
|
||||||
import org.isoron.uhabits.utils.*;
|
import org.isoron.uhabits.utils.*;
|
||||||
|
|
||||||
@@ -60,6 +61,39 @@ public abstract class BaseScreen
|
|||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static void setupActionBarColor(AppCompatActivity activity,
|
||||||
|
int color)
|
||||||
|
{
|
||||||
|
|
||||||
|
Toolbar toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
|
||||||
|
if (toolbar == null) return;
|
||||||
|
|
||||||
|
activity.setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
ActionBar actionBar = activity.getSupportActionBar();
|
||||||
|
if (actionBar == null) return;
|
||||||
|
|
||||||
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
ColorDrawable drawable = new ColorDrawable(color);
|
||||||
|
actionBar.setBackgroundDrawable(drawable);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
{
|
||||||
|
int darkerColor = ColorUtils.mixColors(color, Color.BLACK, 0.75f);
|
||||||
|
activity.getWindow().setStatusBarColor(darkerColor);
|
||||||
|
|
||||||
|
toolbar.setElevation(InterfaceUtils.dpToPixels(activity, 2));
|
||||||
|
|
||||||
|
View view = activity.findViewById(R.id.toolbarShadow);
|
||||||
|
if (view != null) view.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
view = activity.findViewById(R.id.headerShadow);
|
||||||
|
if (view != null) view.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends the current selection operation.
|
* Ends the current selection operation.
|
||||||
*/
|
*/
|
||||||
@@ -210,6 +244,7 @@ public abstract class BaseScreen
|
|||||||
int color = rootView.getToolbarColor();
|
int color = rootView.getToolbarColor();
|
||||||
setActionBarColor(actionBar, color);
|
setActionBarColor(actionBar, color);
|
||||||
setStatusBarColor(color);
|
setStatusBarColor(color);
|
||||||
|
setupToolbarElevation(toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setActionBarColor(@NonNull ActionBar actionBar, int color)
|
private void setActionBarColor(@NonNull ActionBar actionBar, int color)
|
||||||
@@ -220,12 +255,23 @@ public abstract class BaseScreen
|
|||||||
|
|
||||||
private void setStatusBarColor(int baseColor)
|
private void setStatusBarColor(int baseColor)
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
|
||||||
{
|
|
||||||
int darkerColor =
|
int darkerColor = ColorUtils.mixColors(baseColor, Color.BLACK, 0.75f);
|
||||||
ColorUtils.mixColors(baseColor, Color.BLACK, 0.75f);
|
|
||||||
activity.getWindow().setStatusBarColor(darkerColor);
|
activity.getWindow().setStatusBarColor(darkerColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupToolbarElevation(Toolbar toolbar)
|
||||||
|
{
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
|
||||||
|
|
||||||
|
toolbar.setElevation(InterfaceUtils.dpToPixels(activity, 2));
|
||||||
|
|
||||||
|
View view = activity.findViewById(R.id.toolbarShadow);
|
||||||
|
if (view != null) view.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
view = activity.findViewById(R.id.headerShadow);
|
||||||
|
if (view != null) view.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ActionModeWrapper implements ActionMode.Callback
|
private class ActionModeWrapper implements ActionMode.Callback
|
||||||
|
|||||||
@@ -19,16 +19,15 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.ui.about;
|
package org.isoron.uhabits.ui.about;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.*;
|
||||||
import android.net.Uri;
|
import android.net.*;
|
||||||
import android.os.Bundle;
|
import android.os.*;
|
||||||
import android.view.View;
|
import android.view.*;
|
||||||
import android.widget.TextView;
|
import android.widget.*;
|
||||||
|
|
||||||
import org.isoron.uhabits.BuildConfig;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.ui.*;
|
||||||
import org.isoron.uhabits.ui.BaseActivity;
|
import org.isoron.uhabits.utils.*;
|
||||||
import org.isoron.uhabits.utils.InterfaceUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity that allows the user to see information about the app itself.
|
* Activity that allows the user to see information about the app itself.
|
||||||
@@ -76,11 +75,11 @@ public class AboutActivity extends BaseActivity implements View.OnClickListener
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.about);
|
setContentView(R.layout.about);
|
||||||
// setupSupportActionBar(true);
|
|
||||||
|
|
||||||
int color =
|
int color =
|
||||||
InterfaceUtils.getStyledColor(this, R.attr.aboutScreenColor);
|
InterfaceUtils.getStyledColor(this, R.attr.aboutScreenColor);
|
||||||
// setupActionBarColor(color);
|
|
||||||
|
BaseScreen.setupActionBarColor(this, color);
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -19,21 +19,21 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.ui.habits.show;
|
package org.isoron.uhabits.ui.habits.show;
|
||||||
|
|
||||||
import android.content.ContentUris;
|
import android.content.*;
|
||||||
import android.net.Uri;
|
import android.net.*;
|
||||||
import android.os.Bundle;
|
import android.os.*;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.*;
|
||||||
|
|
||||||
import org.isoron.uhabits.HabitsApplication;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.models.*;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.ui.*;
|
||||||
import org.isoron.uhabits.models.HabitList;
|
import org.isoron.uhabits.utils.*;
|
||||||
import org.isoron.uhabits.ui.BaseActivity;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity that allows the user to see more information about a single habit.
|
* Activity that allows the user to see more information about a single habit.
|
||||||
|
*
|
||||||
* Shows all the metadata for the habit, in addition to several charts.
|
* Shows all the metadata for the habit, in addition to several charts.
|
||||||
*/
|
*/
|
||||||
public class ShowHabitActivity extends BaseActivity
|
public class ShowHabitActivity extends BaseActivity
|
||||||
@@ -53,7 +53,8 @@ public class ShowHabitActivity extends BaseActivity
|
|||||||
habit = habitList.getById(ContentUris.parseId(data));
|
habit = habitList.getById(ContentUris.parseId(data));
|
||||||
|
|
||||||
setContentView(R.layout.show_habit_activity);
|
setContentView(R.layout.show_habit_activity);
|
||||||
// setupSupportActionBar(true);
|
BaseScreen.setupActionBarColor(this, ColorUtils.getColor(this, habit.getColor()));
|
||||||
|
|
||||||
setupHabitActionBar();
|
setupHabitActionBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +66,6 @@ public class ShowHabitActivity extends BaseActivity
|
|||||||
if (actionBar == null) return;
|
if (actionBar == null) return;
|
||||||
|
|
||||||
actionBar.setTitle(habit.getName());
|
actionBar.setTitle(habit.getName());
|
||||||
// setupActionBarColor(ColorUtils.getColor(this, habit.color));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Habit getHabit()
|
public Habit getHabit()
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.ui.settings;
|
package org.isoron.uhabits.ui.settings;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.*;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.ui.BaseActivity;
|
import org.isoron.uhabits.ui.*;
|
||||||
import org.isoron.uhabits.utils.InterfaceUtils;
|
import org.isoron.uhabits.utils.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity that allows the user to view and modify the app settings.
|
* Activity that allows the user to view and modify the app settings.
|
||||||
@@ -35,10 +35,9 @@ public class SettingsActivity extends BaseActivity
|
|||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.settings_activity);
|
setContentView(R.layout.settings_activity);
|
||||||
// setupSupportActionBar(true);
|
|
||||||
|
|
||||||
int color =
|
int color =
|
||||||
InterfaceUtils.getStyledColor(this, R.attr.aboutScreenColor);
|
InterfaceUtils.getStyledColor(this, R.attr.aboutScreenColor);
|
||||||
// setupActionBarColor(color);
|
BaseScreen.setupActionBarColor(this, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,16 +75,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
private void setResultOnPreferenceClick(String key, final int result)
|
private void setResultOnPreferenceClick(String key, final int result)
|
||||||
{
|
{
|
||||||
Preference pref = findPreference(key);
|
Preference pref = findPreference(key);
|
||||||
pref.setOnPreferenceClickListener(
|
pref.setOnPreferenceClickListener(preference -> {
|
||||||
new Preference.OnPreferenceClickListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference)
|
|
||||||
{
|
|
||||||
getActivity().setResult(result);
|
getActivity().setResult(result);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user