mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Merge branch 'dev' into agp-update
This commit is contained in:
@@ -5,8 +5,10 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.1'
|
||||
classpath 'com.android.tools.build:gradle:3.0.0'
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.4'
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||
classpath 'org.jacoco:org.jacoco.core:0.8.4'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
|
||||
classpath 'org.ajoberstar:grgit:1.5.0'
|
||||
|
||||
@@ -17,52 +17,41 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.activities.intro;
|
||||
package org.isoron.uhabits.activities.intro
|
||||
|
||||
import android.graphics.*;
|
||||
import android.os.*;
|
||||
import android.graphics.*
|
||||
import android.os.*
|
||||
|
||||
import com.github.paolorotolo.appintro.*;
|
||||
import com.github.paolorotolo.appintro.*
|
||||
|
||||
import org.isoron.uhabits.R;
|
||||
import org.isoron.uhabits.R
|
||||
|
||||
/**
|
||||
* Activity that introduces the app to the user, shown only after the app is
|
||||
* launched for the first time.
|
||||
*/
|
||||
public class IntroActivity extends AppIntro2
|
||||
{
|
||||
@Override
|
||||
public void init(Bundle savedInstanceState)
|
||||
{
|
||||
showStatusBar(false);
|
||||
class IntroActivity : AppIntro2() {
|
||||
override fun init(savedInstanceState: Bundle?) {
|
||||
showStatusBar(false)
|
||||
|
||||
addSlide(AppIntroFragment.newInstance(getString(R.string.intro_title_1),
|
||||
getString(R.string.intro_description_1), R.drawable.intro_icon_1,
|
||||
Color.parseColor("#194673")));
|
||||
getString(R.string.intro_description_1), R.drawable.intro_icon_1,
|
||||
Color.parseColor("#194673")))
|
||||
|
||||
addSlide(AppIntroFragment.newInstance(getString(R.string.intro_title_2),
|
||||
getString(R.string.intro_description_2), R.drawable.intro_icon_2,
|
||||
Color.parseColor("#ffa726")));
|
||||
getString(R.string.intro_description_2), R.drawable.intro_icon_2,
|
||||
Color.parseColor("#ffa726")))
|
||||
|
||||
addSlide(AppIntroFragment.newInstance(getString(R.string.intro_title_4),
|
||||
getString(R.string.intro_description_4), R.drawable.intro_icon_4,
|
||||
Color.parseColor("#9575cd")));
|
||||
getString(R.string.intro_description_4), R.drawable.intro_icon_4,
|
||||
Color.parseColor("#9575cd")))
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNextPressed()
|
||||
{
|
||||
override fun onNextPressed() {}
|
||||
|
||||
override fun onDonePressed() {
|
||||
finish()
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDonePressed()
|
||||
{
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlideChanged()
|
||||
{
|
||||
}
|
||||
override fun onSlideChanged() {}
|
||||
}
|
||||
@@ -35,8 +35,10 @@ class EditSettingActivity : BaseActivity() {
|
||||
.setCompletedAllowed(true)
|
||||
.build())
|
||||
|
||||
val args = SettingUtils.parseIntent(this.intent, habits)
|
||||
|
||||
val controller = EditSettingController(this)
|
||||
val rootView = EditSettingRootView(this, habits, controller)
|
||||
val rootView = EditSettingRootView(this, habits, controller, args)
|
||||
val screen = BaseScreen(this)
|
||||
screen.setRootView(rootView)
|
||||
setScreen(screen)
|
||||
|
||||
@@ -34,7 +34,8 @@ import java.util.*
|
||||
class EditSettingRootView(
|
||||
context: Context,
|
||||
private val habitList: HabitList,
|
||||
private val controller: EditSettingController
|
||||
private val controller: EditSettingController,
|
||||
args: SettingUtils.Arguments?
|
||||
) : BaseRootView(context) {
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
@@ -50,6 +51,11 @@ class EditSettingRootView(
|
||||
addView(inflate(getContext(), R.layout.automation, null))
|
||||
ButterKnife.bind(this)
|
||||
populateHabitSpinner()
|
||||
|
||||
args?.let {
|
||||
habitSpinner.setSelection(habitList.indexOf(it.habit))
|
||||
actionSpinner.setSelection(it.action)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getToolbar(): Toolbar {
|
||||
|
||||
@@ -44,7 +44,7 @@ class FireSettingReceiver : BroadcastReceiver() {
|
||||
.habitsApplicationComponent(app.component)
|
||||
.build()
|
||||
allHabits = app.component.habitList
|
||||
val args = parseIntent(intent) ?: return
|
||||
val args = SettingUtils.parseIntent(intent, allHabits) ?: return
|
||||
val timestamp = DateUtils.getToday()
|
||||
val controller = component.widgetController
|
||||
|
||||
@@ -55,19 +55,9 @@ class FireSettingReceiver : BroadcastReceiver() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseIntent(intent: Intent): Arguments? {
|
||||
val bundle = intent.getBundleExtra(EXTRA_BUNDLE) ?: return null
|
||||
val action = bundle.getInt("action")
|
||||
if (action < 0 || action > 2) return null
|
||||
val habit = allHabits.getById(bundle.getLong("habit")) ?: return null
|
||||
return Arguments(action, habit)
|
||||
}
|
||||
|
||||
@ReceiverScope
|
||||
@Component(dependencies = arrayOf(HabitsApplicationComponent::class))
|
||||
internal interface ReceiverComponent {
|
||||
val widgetController: WidgetBehavior
|
||||
}
|
||||
|
||||
private class Arguments(var action: Int, var habit: Habit)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.isoron.uhabits.automation
|
||||
|
||||
import android.content.Intent
|
||||
import org.isoron.uhabits.core.models.Habit
|
||||
import org.isoron.uhabits.core.models.HabitList
|
||||
|
||||
object SettingUtils {
|
||||
@JvmStatic
|
||||
fun parseIntent(intent: Intent, allHabits: HabitList): Arguments? {
|
||||
val bundle = intent.getBundleExtra(EXTRA_BUNDLE) ?: return null
|
||||
val action = bundle.getInt("action")
|
||||
if (action < 0 || action > 2) return null
|
||||
val habit = allHabits.getById(bundle.getLong("habit")) ?: return null
|
||||
return Arguments(action, habit)
|
||||
}
|
||||
|
||||
class Arguments(var action: Int, var habit: Habit)
|
||||
}
|
||||
@@ -84,11 +84,11 @@ class ListHabitsMenuTest : BaseAndroidJVMTest() {
|
||||
verify(behavior).onViewAbout()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnSelected_add() {
|
||||
onItemSelected(R.id.actionAdd)
|
||||
verify(behavior).onCreateHabit()
|
||||
}
|
||||
// @Test
|
||||
// fun testOnSelected_add() {
|
||||
// onItemSelected(R.id.actionAdd)
|
||||
// verify(behavior).onCreateHabit()
|
||||
// }
|
||||
|
||||
@Test
|
||||
fun testOnSelected_faq() {
|
||||
|
||||
@@ -92,12 +92,12 @@ public class ListHabitsMenuBehaviorTest extends BaseUnitTest
|
||||
assertFalse(matcherCaptor.getValue().isCompletedAllowed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnCreateHabit()
|
||||
{
|
||||
behavior.onCreateHabit();
|
||||
verify(screen).showCreateHabitScreen();
|
||||
}
|
||||
// @Test
|
||||
// public void testOnCreateHabit()
|
||||
// {
|
||||
// behavior.onCreateHabit();
|
||||
// verify(screen).showCreateHabitScreen();
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testOnSortByColor()
|
||||
|
||||
Reference in New Issue
Block a user