diff --git a/android/android-base/src/main/java/org/isoron/androidbase/activities/BaseActivity.kt b/android/android-base/src/main/java/org/isoron/androidbase/activities/BaseActivity.kt
index 7d02aaf50..efb68c278 100644
--- a/android/android-base/src/main/java/org/isoron/androidbase/activities/BaseActivity.kt
+++ b/android/android-base/src/main/java/org/isoron/androidbase/activities/BaseActivity.kt
@@ -93,12 +93,4 @@ abstract class BaseActivity : AppCompatActivity() {
super.onResume()
screen?.reattachDialogs()
}
-
- override fun startActivity(intent: Intent?) {
- try {
- super.startActivity(intent)
- } catch(e: ActivityNotFoundException) {
- this.screen?.showMessage(R.string.activity_not_found)
- }
- }
}
\ No newline at end of file
diff --git a/android/android-base/src/main/res/values/strings.xml b/android/android-base/src/main/res/values/strings.xml
deleted file mode 100644
index 032239605..000000000
--- a/android/android-base/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- No app was found to support this action
-
\ No newline at end of file
diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutActivity.java b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutActivity.kt
similarity index 56%
rename from android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutActivity.java
rename to android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutActivity.kt
index 58cf49681..24628a7fd 100644
--- a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutActivity.java
+++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutActivity.kt
@@ -16,30 +16,25 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*/
+package org.isoron.uhabits.activities.about
-package org.isoron.uhabits.activities.about;
-
-import android.os.*;
-
-import org.isoron.uhabits.*;
-import org.isoron.uhabits.activities.*;
+import android.os.*
+import androidx.appcompat.app.*
+import org.isoron.uhabits.*
+import org.isoron.uhabits.activities.*
/**
* Activity that allows the user to see information about the app itself.
* Display current version, link to Google Play and list of contributors.
*/
-public class AboutActivity extends HabitsActivity
-{
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- HabitsApplication app = (HabitsApplication) getApplication();
- AboutScreen screen = new AboutScreen(this,
- app.getComponent().getIntentFactory(),
- app.getComponent().getPreferences());
- AboutRootView rootView = new AboutRootView(this, screen);
- screen.setRootView(rootView);
- setScreen(screen);
+class AboutActivity : AppCompatActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ val app = application as HabitsApplication
+ val screen = AboutScreen(this,
+ app.component.intentFactory,
+ app.component.preferences)
+ AndroidThemeSwitcher(this, app.component.preferences).apply()
+ setContentView(AboutView(this, screen))
}
-}
+}
\ No newline at end of file
diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutRootView.java b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutRootView.java
deleted file mode 100644
index 68cb68551..000000000
--- a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutRootView.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2016 Álinson Santos Xavier
- *
- * This file is part of Loop Habit Tracker.
- *
- * Loop Habit Tracker is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version.
- *
- * Loop Habit Tracker is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see .
- */
-
-package org.isoron.uhabits.activities.about;
-
-import android.content.*;
-import android.widget.*;
-
-import androidx.annotation.*;
-
-import org.isoron.androidbase.activities.*;
-import org.isoron.androidbase.utils.*;
-import org.isoron.uhabits.BuildConfig;
-import org.isoron.uhabits.R;
-
-import javax.inject.*;
-
-import butterknife.*;
-
-public class AboutRootView extends BaseRootView
-{
- @BindView(R.id.tvVersion)
- TextView tvVersion;
-
- @NonNull
- private final AboutScreen screen;
-
- @Inject
- public AboutRootView(@NonNull @ActivityContext Context context,
- @NonNull AboutScreen screen)
- {
- super(context);
- this.screen = screen;
-
- addView(inflate(getContext(), R.layout.about, null));
- ButterKnife.bind(this);
-
- String version = getResources().getString(R.string.version_n);
- tvVersion.setText(String.format(version, BuildConfig.VERSION_NAME));
-
- setDisplayHomeAsUp(true);
- }
-
- @Override
- public int getToolbarColor()
- {
- StyledResources res = new StyledResources(getContext());
- if (!res.getBoolean(R.attr.useHabitColorAsPrimary))
- return super.getToolbarColor();
-
- return res.getColor(R.attr.aboutScreenColor);
- }
-
- @OnClick(R.id.tvFeedback)
- public void onClickFeedback()
- {
- screen.showSendFeedbackScreen();
- }
-
- @OnClick(R.id.tvVersion)
- public void onClickIcon()
- {
- screen.onPressDeveloperCountdown();
- }
-
- @OnClick(R.id.tvRate)
- public void onClickRate()
- {
- screen.showRateAppWebsite();
- }
-
- @OnClick(R.id.tvSource)
- public void onClickSource()
- {
- screen.showSourceCodeWebsite();
- }
-
- @OnClick(R.id.tvTranslate)
- public void onClickTranslate()
- {
- screen.showTranslationWebsite();
- }
-
- @OnClick(R.id.tvPrivacy)
- public void onClickPrivacy()
- {
- screen.showPrivacyPolicyWebsite();
- }
-
- @OnClick(R.id.tvContributors)
- public void onClickContributors()
- {
- screen.showCodeContributorsWebsite();
- }
-
- @Override
- protected void initToolbar()
- {
- super.initToolbar();
- getToolbar().setTitle(getResources().getString(R.string.about));
- }
-}
diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutScreen.java b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutScreen.java
deleted file mode 100644
index c5b668ae8..000000000
--- a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutScreen.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2017 Álinson Santos Xavier
- *
- * This file is part of Loop Habit Tracker.
- *
- * Loop Habit Tracker is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version.
- *
- * Loop Habit Tracker is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see .
- */
-
-package org.isoron.uhabits.activities.about;
-
-import android.widget.*;
-
-import androidx.annotation.*;
-
-import org.isoron.androidbase.activities.*;
-import org.isoron.uhabits.core.preferences.*;
-import org.isoron.uhabits.intents.*;
-
-public class AboutScreen extends BaseScreen
-{
- @NonNull
- private final Preferences prefs;
-
- private int developerCountdown = 5;
-
- @NonNull
- private final IntentFactory intents;
-
- public AboutScreen(@NonNull BaseActivity activity,
- @NonNull IntentFactory intents,
- @NonNull Preferences prefs)
- {
- super(activity);
- this.intents = intents;
- this.prefs = prefs;
- }
-
- public void showRateAppWebsite()
- {
- activity.startActivity(intents.rateApp(activity));
- }
-
- public void showSendFeedbackScreen()
- {
- activity.startActivity(intents.sendFeedback(activity));
- }
-
- public void showSourceCodeWebsite()
- {
- activity.startActivity(intents.viewSourceCode(activity));
- }
-
- public void showTranslationWebsite()
- {
- activity.startActivity(intents.helpTranslate(activity));
- }
-
- public void showPrivacyPolicyWebsite()
- {
- activity.startActivity(intents.privacyPolicy(activity));
- }
-
- public void showCodeContributorsWebsite()
- {
- activity.startActivity(intents.codeContributors(activity));
- }
-
- public void onPressDeveloperCountdown()
- {
- developerCountdown--;
- if (developerCountdown == 0) {
- prefs.setDeveloper(true);
- Toast.makeText(activity, "You are now a developer", Toast.LENGTH_LONG).show();
- }
- }
-}
diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutScreen.kt b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutScreen.kt
new file mode 100644
index 000000000..5711669d5
--- /dev/null
+++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutScreen.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 Álinson Santos Xavier
+ *
+ * This file is part of Loop Habit Tracker.
+ *
+ * Loop Habit Tracker is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * Loop Habit Tracker is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+package org.isoron.uhabits.activities.about
+
+import org.isoron.uhabits.*
+import org.isoron.uhabits.core.preferences.*
+import org.isoron.uhabits.intents.*
+import org.isoron.uhabits.utils.*
+
+class AboutScreen(
+ private val activity: AboutActivity,
+ private val intents: IntentFactory,
+ private val prefs: Preferences,
+) {
+
+ private var developerCountdown = 5
+
+ fun showRateAppWebsite() =
+ activity.startActivitySafely(intents.rateApp(activity))
+
+ fun showSendFeedbackScreen() =
+ activity.startActivitySafely(intents.sendFeedback(activity))
+
+ fun showSourceCodeWebsite() =
+ activity.startActivitySafely(intents.viewSourceCode(activity))
+
+ fun showTranslationWebsite() =
+ activity.startActivitySafely(intents.helpTranslate(activity))
+
+ fun showPrivacyPolicyWebsite() =
+ activity.startActivitySafely(intents.privacyPolicy(activity))
+
+ fun showCodeContributorsWebsite() =
+ activity.startActivitySafely(intents.codeContributors(activity))
+
+ fun onPressDeveloperCountdown() {
+ developerCountdown--
+ if (developerCountdown == 0) {
+ prefs.isDeveloper = true
+ activity.showMessage(R.string.you_are_now_a_developer)
+ }
+ }
+}
\ No newline at end of file
diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutView.kt b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutView.kt
new file mode 100644
index 000000000..719a1d0ab
--- /dev/null
+++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/about/AboutView.kt
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2016 Álinson Santos Xavier
+ *
+ * This file is part of Loop Habit Tracker.
+ *
+ * Loop Habit Tracker is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * Loop Habit Tracker is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+package org.isoron.uhabits.activities.about
+
+import android.annotation.*
+import android.content.*
+import android.view.*
+import android.widget.*
+import org.isoron.uhabits.*
+import org.isoron.uhabits.core.models.*
+import org.isoron.uhabits.databinding.*
+import org.isoron.uhabits.utils.*
+
+@SuppressLint("ViewConstructor")
+class AboutView(
+ context: Context,
+ private val screen: AboutScreen,
+) : FrameLayout(context) {
+
+ private var binding = AboutBinding.inflate(LayoutInflater.from(context))
+
+ init {
+ addView(binding.root)
+ setupToolbar(
+ toolbar = binding.toolbar,
+ color = PaletteColor(11),
+ title = resources.getString(R.string.about)
+ )
+ val version = resources.getString(R.string.version_n)
+ binding.tvContributors.setOnClickListener { screen.showCodeContributorsWebsite() }
+ binding.tvFeedback.setOnClickListener { screen.showSendFeedbackScreen() }
+ binding.tvPrivacy.setOnClickListener { screen.showPrivacyPolicyWebsite() }
+ binding.tvRate.setOnClickListener { screen.showRateAppWebsite() }
+ binding.tvSource.setOnClickListener { screen.showSourceCodeWebsite() }
+ binding.tvTranslate.setOnClickListener { screen.showTranslationWebsite() }
+ binding.tvVersion.setOnClickListener { screen.onPressDeveloperCountdown() }
+ binding.tvVersion.text = String.format(version, BuildConfig.VERSION_NAME)
+ }
+}
\ No newline at end of file
diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/utils/ViewExtensions.kt b/android/uhabits-android/src/main/java/org/isoron/uhabits/utils/ViewExtensions.kt
index 74e3000b6..432b58382 100644
--- a/android/uhabits-android/src/main/java/org/isoron/uhabits/utils/ViewExtensions.kt
+++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/utils/ViewExtensions.kt
@@ -23,6 +23,7 @@ import android.app.*
import android.content.*
import android.graphics.*
import android.graphics.drawable.*
+import android.util.*
import android.view.*
import android.view.ViewGroup.LayoutParams.*
import android.widget.*
@@ -105,6 +106,14 @@ fun Activity.showSendFileScreen(archiveFilename: String) {
})
}
+fun Activity.startActivitySafely(intent: Intent) {
+ try {
+ startActivity(intent)
+ } catch(e: ActivityNotFoundException) {
+ this.showMessage(R.string.activity_not_found)
+ }
+}
+
fun View.setupToolbar(
toolbar: Toolbar,
title: String,
diff --git a/android/uhabits-android/src/main/res/values/strings.xml b/android/uhabits-android/src/main/res/values/strings.xml
index a7c7cf397..c152d87a1 100644
--- a/android/uhabits-android/src/main/res/values/strings.xml
+++ b/android/uhabits-android/src/main/res/values/strings.xml
@@ -217,4 +217,6 @@
Sync key already installed
Show question marks for missing data
Differentiate days without data from actual lapses. To enter a lapse, toggle twice.
+ You are now a developer
+ No app was found to support this action
\ No newline at end of file