Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
# TomatoTimer for Android
# 番茄钟/TomatoTimer for Android

## ruin1990的修改说明

我在很多年前就发现这个好用的应用了,后来换了手机又给朋友推荐了它,结果发现在很多人的手机上会崩溃,就自己动手汉化并修复了Android高版本上布局、崩溃的问题,最新的版本号是**v1.0.2**
考虑到原作者似乎没有针对中文做支持,我把Readme也翻译了一下,下面开始基本都是中英文对照。

**注意:因为我没有原作者的签名,所以发布出来的apk是不能覆盖安装的,需要卸载原1.0.1的版本才行**

## 原文档对照翻译

下面这个google play的是v1.0.1的英文版,没有中文版哦,因为我懒
<a href='https://play.google.com/store/apps/details?id=artem122ya.tomatotimer'><img height="100" alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png'/></a>

番茄钟 通过番茄工作法帮助您提高工作效率并对抗拖延症。

TomatoTimer helps you increase productivity and fight procrastination with Pomodoro Technique.

番茄钟 鼓励您将工作时间分成 25 分钟的部分,中间间隔 5 分钟的休息时间。通过这样做,您将能够控制花在完成任务上的时间。
每四个工作间隔,您就必须有 15 分钟的较长休息时间。

TomatoTimer encourages you to divide your work time into 25-minute chunks separated by five-minute breaks. By doing that you'll be able to control how much time you spend working on your task.
Every fourth work interval you have to take a longer break of 15 minutes.

The app lets you fully customize these intervals, to completely fill your needs.
该应用程序可让您完全自定义这些间隔,以完全满足您的需求。

The app lets you fully customize these intervals, to completely fill your needs.

<p align="left">
<img src="https://user-images.githubusercontent.com/25901464/38814619-91db7c00-419a-11e8-9451-8f970aabd0e0.png" width="200"/>
Expand All @@ -19,9 +35,12 @@ The app lets you fully customize these intervals, to completely fill your needs.
</p>




<b>Copyright 2018 Artem Yakushev
[Licensed](https://github.com/artem122ya/TomatoTimer-Android/blob/master/LICENSE) under the Apache License, Version 2.0</b>

<b>版权所有 2018 Artem Yakushev
[Licensed](https://github.com/artem122ya/TomatoTimer-Android/blob/master/LICENSE) 根据 Apache 许可证 2.0 版</b>

Google Play 和 Google Play 徽标是 Google LLC 的商标。

Google Play and the Google Play logo are trademarks of Google LLC.
41 changes: 25 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
compileSdkVersion 31

defaultConfig {
applicationId "artem122ya.tomatotimer"
minSdkVersion 21
targetSdkVersion 26
versionCode 101
versionName "1.0.1"
targetSdkVersion 31
versionCode 102
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand All @@ -22,17 +23,25 @@ android {
includeAndroidResources = true
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
testImplementation "org.robolectric:robolectric:3.6.1"
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0' // AndroidX
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.github.princekin-f:EasyFloat:2.0.4'
}
10 changes: 7 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="artem122ya.tomatotimer">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppThemeLight">
android:theme="@style/AppThemeLight"
tools:replace="android:appComponentFactory"
android:appComponentFactory="android.support.v4.app.CoreComponentFactory">
<activity
android:name=".timer.TimerActivity"
android:launchMode="singleTask"
android:theme="@style/TimerActivityLight">
android:theme="@style/TimerActivityLight"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package artem122ya.tomatotimer.about;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem;

import artem122ya.tomatotimer.R;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.support.annotation.Nullable;
import android.widget.Toast;

import androidx.annotation.Nullable;
import artem122ya.tomatotimer.BuildConfig;
import artem122ya.tomatotimer.R;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
import android.preference.DialogPreference;
import android.support.v4.content.ContextCompat;


import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.NumberPicker;

import androidx.core.content.ContextCompat;
import artem122ya.tomatotimer.R;

public class NumberPickerDialogPreference extends DialogPreference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;


import android.view.MenuItem;


import androidx.appcompat.app.AppCompatActivity;
import artem122ya.tomatotimer.R;
import artem122ya.tomatotimer.utils.ThemeManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

import androidx.appcompat.app.AppCompatActivity;
import artem122ya.tomatotimer.R;
import artem122ya.tomatotimer.about.AboutActivity;
import artem122ya.tomatotimer.settings.SettingsActivity;
Expand Down
23 changes: 18 additions & 5 deletions app/src/main/java/artem122ya/tomatotimer/timer/TimerService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package artem122ya.tomatotimer.timer;

import android.Manifest;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
Expand All @@ -10,18 +11,22 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Binder;
import android.os.IBinder;
import android.preference.PreferenceManager;


import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import artem122ya.tomatotimer.R;

import static artem122ya.tomatotimer.utils.Utils.getTimeString;

public class TimerService extends Service implements SharedPreferences.OnSharedPreferenceChangeListener {

private static final int REQUEST_FOREGROUND_PERMISSION = 200;
public static String ACTION_SEND_TIME = "artem122ya.tomatotimer.time_send";
public static String INT_TIME_MILLIS_LEFT = "artem122ya.tomatotimer.time_extra_millis_left";
public static String INT_TIME_MILLIS_TOTAL = "artem122ya.tomatotimer.time_extra_millis_total";
Expand Down Expand Up @@ -102,6 +107,14 @@ public void onCreate() {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
checkNumberOfSessionsUntilBreak(sharedPreferences);

if (ContextCompat.checkSelfPermission(this, Manifest.permission.FOREGROUND_SERVICE) == PackageManager.PERMISSION_GRANTED) {
// ����������ǰ̨����
} else {
// ���û�л��Ȩ�ޣ���������Ȩ��
//ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.FOREGROUND_SERVICE}, REQUEST_FOREGROUND_PERMISSION);
}

}

@Override
Expand All @@ -125,19 +138,19 @@ private void createIntentFilter(){
private void initControlIntents(){
Intent intentMainActivity = new Intent(this, TimerActivity.class);
intentMainActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
openMainActivityIntent = PendingIntent.getActivity(this, 1, intentMainActivity, PendingIntent.FLAG_UPDATE_CURRENT);
openMainActivityIntent = PendingIntent.getActivity(this, 1, intentMainActivity, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);

Intent startIntent = new Intent(startActionIntentString);
startActionIntent = PendingIntent.getBroadcast(this, 100, startIntent, 0);
startActionIntent = PendingIntent.getBroadcast(this, 100, startIntent, PendingIntent.FLAG_IMMUTABLE);

Intent pauseIntent = new Intent(pauseActionIntentString);
pauseActionIntent = PendingIntent.getBroadcast(this, 100, pauseIntent, 0);
pauseActionIntent = PendingIntent.getBroadcast(this, 100, pauseIntent, PendingIntent.FLAG_IMMUTABLE);

Intent stopIntent = new Intent(stopActionIntentString);
stopActionIntent = PendingIntent.getBroadcast(this, 100, stopIntent, 0);
stopActionIntent = PendingIntent.getBroadcast(this, 100, stopIntent, PendingIntent.FLAG_IMMUTABLE);

Intent skipIntent = new Intent(skipActionIntentString);
skipActionIntent = PendingIntent.getBroadcast(this, 100, skipIntent, 0);
skipActionIntent = PendingIntent.getBroadcast(this, 100, skipIntent, PendingIntent.FLAG_IMMUTABLE);

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager notificationManager =
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/layout-land/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@
app:srcCompat="@drawable/ic_stop" />


<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/startPauseButton"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_column="2"
android:layout_gravity="center"
android:gravity="center"
android:layout_row="1"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
Expand All @@ -57,6 +58,8 @@
android:focusable="true"
app:borderWidth="0dp"
app:elevation="0dp"
app:maxImageSize="50dp"
app:fabCustomSize="80dp"
app:srcCompat="@drawable/ic_play" />


Expand Down
14 changes: 8 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,23 @@
app:srcCompat="@drawable/ic_stop"
android:contentDescription="@string/stop_button_content_description"/>

<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/startPauseButton"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_row="2"
android:layout_rowSpan="1"
android:layout_column="1"
android:layout_columnWeight="0"
android:layout_gravity="center"
android:layout_row="2"
android:layout_rowSpan="1"
android:clickable="true"
android:contentDescription="@string/start_and_pause_button_content_description"
android:focusable="true"
app:borderWidth="0dp"
app:elevation="0dp"
app:srcCompat="@drawable/ic_play"
android:focusable="true"
android:contentDescription="@string/start_and_pause_button_content_description"/>
app:maxImageSize="50dp"
app:fabCustomSize="80dp"
app:srcCompat="@drawable/ic_play" />

<ImageButton
android:id="@+id/skipButton"
Expand Down
61 changes: 61 additions & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<resources>
<string name="app_name">番茄钟</string>
<string name="menu_option_settings">设置</string>
<string name="menu_option_about">关于</string>
<string name="settings_label">设置</string>
<string name="work_minute_picker_title">工作单组时长</string>
<string name="small_break_minute_picker_title">小憩时长</string>
<string name="big_break_minute_picker_title">休息时长</string>
<string name="timer_preference_category_title">计时器</string>
<string name="work_minute_picker_summary">00 分钟</string>
<string name="small_break_minute_picker_summary">00 分钟</string>
<string name="big_break_minute_picker_summary">00 分钟</string>
<string name="sessions_until_big_break_title">工作多组直到休息时长</string>
<string name="sessions_until_big_break_summary">00 组</string>
<string name="stop_button_content_description">停止按钮</string>
<string name="start_and_pause_button_content_description">开始或停止按钮</string>
<string name="skip_button_content_description">跳过按钮</string>
<string name="work_time_text">工作组</string>
<string name="break_time_text">暂停</string>
<string name="notification_text">" 分钟剩余"</string>
<string name="start_notification_action_title">开始</string>
<string name="pause_notification_action_title">暂停</string>
<string name="skip_notification_action_title">跳过</string>
<string name="stop_notification_action_title">停止</string>
<string name="resume_notification_action_title">恢复</string>
<string name="big_break_text">休息</string>
<string name="finished_notification_title">" 结束"</string>
<string name="finished_notification_text">"想要启动一个 "</string>
<string name="work_time_minutes_default_value">25</string>
<string name="small_break_time_minutes_default_value">5</string>
<string name="big_break_time_minutes_default_value">15</string>
<string name="sessions_until_big_break_default_value">4</string>
<string name="number_picker_dialog_positive_button_text">确定</string>
<string name="number_picker_dialog_negative_button_text">取消</string>
<string name="theme_preference_category_title">主题</string>
<string name="dark_mode_title">启用夜间模式</string>

<string name="work_time_minutes_preference_key">work_time_minutes</string>
<string name="small_break_time_minutes_preference_key">small_break_time_minutes</string>
<string name="big_break_time_minutes_preference_key">big_break_time_minutes</string>
<string name="sessions_until_big_break_preference_key">sessions_until_big_break</string>
<string name="dark_mode_preference_key">dark_mode</string>

<string name="one_session_until_big_break_text">这组工作完就休息啦!</string>
<string name="sessions_until_big_break_text">" 组工作后就可休息"</string>
<string name="about_label">关于</string>
<string name="about_app_version_title">App 版本</string>
<string name="about_app_version_key">版本</string>
<string name="about_source_code_title">查看汉化版源码</string>
<string name="about_source_code_key">goToSourceCode</string>
<string name="about_source_code_summary">访问汉化版Github仓库</string>
<string name="about_original_source_code_title">查看原版源码</string>
<string name="about_original_source_code_key">goToOriginalSourceCode</string>
<string name="about_original_source_code_summary">访问原版github仓库(v1.0.1)</string>
<string name="about_send_email_title">上报问题</string>
<string name="about_send_email_key">sendEmail</string>
<string name="about_send_email_summary">给原版作者发送邮件</string>
<string name="github_link">https://github.com/ruin1990/TomatoTimer-Android</string>
<string name="original_github_link">https://github.com/artem122ya/TomatoTimer-Android</string>
<string name="feedback_email">mailto:help.tomatotimer@gmail.com</string>
</resources>
Loading