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