mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Small changes
This commit is contained in:
@@ -21,7 +21,6 @@ package org.isoron.uhabits.activities;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.activities.common.dialogs.*;
|
||||
import org.isoron.uhabits.activities.habits.list.controllers.*;
|
||||
|
||||
import dagger.*;
|
||||
|
||||
@@ -30,7 +29,5 @@ import dagger.*;
|
||||
dependencies = { AppComponent.class })
|
||||
public interface ActivityComponent
|
||||
{
|
||||
CheckmarkButtonControllerFactory getCheckmarkButtonControllerFactory();
|
||||
|
||||
DialogFactory getDialogFactory();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ package org.isoron.uhabits.activities;
|
||||
|
||||
import javax.inject.*;
|
||||
|
||||
/**
|
||||
* Scope used by objects that live as long as the activity is alive.
|
||||
*/
|
||||
@Scope
|
||||
public @interface ActivityScope
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.isoron.uhabits.activities;
|
||||
|
||||
import android.content.*;
|
||||
import android.os.*;
|
||||
import android.support.annotation.*;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.*;
|
||||
@@ -29,6 +28,17 @@ import android.widget.*;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.utils.*;
|
||||
|
||||
import static android.os.Build.VERSION.*;
|
||||
import static android.os.Build.VERSION_CODES.*;
|
||||
|
||||
/**
|
||||
* Base class for all root views in the application.
|
||||
* <p>
|
||||
* A root view is an Android view that is directly attached to an activity. This
|
||||
* view usually includes a toolbar and a progress bar. This abstract class hides
|
||||
* some of the complexity of setting these things up, for every version of
|
||||
* Android.
|
||||
*/
|
||||
public abstract class BaseRootView extends FrameLayout
|
||||
{
|
||||
private final Context context;
|
||||
@@ -44,30 +54,25 @@ public abstract class BaseRootView extends FrameLayout
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ProgressBar getProgressBar()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract Toolbar getToolbar();
|
||||
|
||||
public int getToolbarColor()
|
||||
{
|
||||
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) &&
|
||||
!InterfaceUtils.isNightMode())
|
||||
if (SDK_INT < LOLLIPOP && !InterfaceUtils.isNightMode())
|
||||
{
|
||||
return getContext().getResources().getColor(R.color.grey_900);
|
||||
return context
|
||||
.getResources()
|
||||
.getColor(R.color.grey_900, context.getTheme());
|
||||
}
|
||||
|
||||
StyledResources res = new StyledResources(getContext());
|
||||
StyledResources res = new StyledResources(context);
|
||||
return res.getColor(R.attr.colorPrimary);
|
||||
}
|
||||
|
||||
protected void initToolbar()
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
if (SDK_INT >= LOLLIPOP)
|
||||
{
|
||||
getToolbar().setElevation(InterfaceUtils.dpToPixels(context, 2));
|
||||
View view = findViewById(R.id.toolbarShadow);
|
||||
|
||||
@@ -36,6 +36,8 @@ public class ListHabitsActivity extends BaseActivity
|
||||
|
||||
private ListHabitsScreen screen;
|
||||
|
||||
private ListHabitsComponent component;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
@@ -43,7 +45,7 @@ public class ListHabitsActivity extends BaseActivity
|
||||
|
||||
HabitsApplication app = (HabitsApplication) getApplicationContext();
|
||||
|
||||
ListHabitsComponent component = DaggerListHabitsComponent
|
||||
component = DaggerListHabitsComponent
|
||||
.builder()
|
||||
.appComponent(app.getComponent())
|
||||
.activityModule(new ActivityModule(this))
|
||||
@@ -66,6 +68,11 @@ public class ListHabitsActivity extends BaseActivity
|
||||
controller.onStartup();
|
||||
}
|
||||
|
||||
public ListHabitsComponent getListHabitsComponent()
|
||||
{
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.isoron.uhabits.activities.habits.list;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.activities.*;
|
||||
import org.isoron.uhabits.activities.habits.list.controllers.*;
|
||||
import org.isoron.uhabits.activities.habits.list.model.*;
|
||||
|
||||
import dagger.*;
|
||||
@@ -30,6 +31,8 @@ import dagger.*;
|
||||
dependencies = { AppComponent.class })
|
||||
public interface ListHabitsComponent
|
||||
{
|
||||
CheckmarkButtonControllerFactory getCheckmarkButtonControllerFactory();
|
||||
|
||||
HabitCardListAdapter getAdapter();
|
||||
|
||||
ListHabitsController getController();
|
||||
|
||||
@@ -90,13 +90,6 @@ public class ListHabitsRootView extends BaseRootView
|
||||
hintView.setHints(hintList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public ProgressBar getProgressBar()
|
||||
{
|
||||
return progressBar;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Toolbar getToolbar()
|
||||
|
||||
@@ -155,8 +155,9 @@ public class CheckmarkPanelView extends LinearLayout
|
||||
if (controller == null) return;
|
||||
|
||||
ListHabitsActivity activity = (ListHabitsActivity) getContext();
|
||||
CheckmarkButtonControllerFactory buttonControllerFactory =
|
||||
activity.getComponent().getCheckmarkButtonControllerFactory();
|
||||
CheckmarkButtonControllerFactory buttonControllerFactory = activity
|
||||
.getListHabitsComponent()
|
||||
.getCheckmarkButtonControllerFactory();
|
||||
|
||||
CheckmarkButtonController buttonController =
|
||||
buttonControllerFactory.create(habit, timestamp);
|
||||
|
||||
Reference in New Issue
Block a user