mirror of https://github.com/iSoron/uhabits.git
parent
826ea17cdd
commit
638bc2816f
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2016-2020 Álinson Santos Xavier <isoron@gmail.com>
|
||||
~
|
||||
~ 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 <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="activity_not_found">No app was found to support this action</string>
|
||||
</resources>
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Reference in new issue