Skip to content

Commit

Permalink
#80 Do not make all permissions mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
yvolk committed Jan 3, 2024
1 parent 0092ea6 commit 2c83fae
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 22 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,20 @@ In particular, see these solutions:

## Changelog

<a id="v4.8"/>

### 2024-01-03 v4.8.0 Time zone changes fixed
* Fixed "[Default Time zone in app doesn't change, when Android System Time Zone changes](https://github.com/andstatus/todoagenda/issues/106)".
* Fixed "[Do not make all permissions mandatory](https://github.com/andstatus/todoagenda/issues/80)".
* App converted from Java to Kotlin.

<a id="v4.7"/>

### 2023-12-31 v4.7.3 Show based on keywords in a title
* Date range filtering extended with "[Today and Tomorrow](https://github.com/plusonelabs/calendar-widget/issues/123)"
* Date range filtering extended with "[Today and Tomorrow](https://github.com/andstatus/todoagenda/issues/123)"
option. This is different from the "One day" option as that hides events after current time on the next day,
which is a bit confusing.
* [Show based on keywords in a title](https://github.com/plusonelabs/calendar-widget/issues/122) option added,
* [Show based on keywords in a title](https://github.com/andstatus/todoagenda/issues/122) option added,
allowing to see events that have certain text included.
In addition to existing option "Hide based on keywords in a title".
* Allow changing language of User Interface for Android 13+ in Android System Settings - Apps, see
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
}

defaultConfig {
versionCode 703
versionName '4.7.3'
versionCode 704
versionName '4.8.0'
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class EnvironmentChangedReceiver : BroadcastReceiver() {
val action = if (settings == null || intent.action.isNullOrBlank()) {
RemoteViewsFactory.ACTION_REFRESH
} else if (PermissionsUtil.mustRequestPermissions(context)) {
RemoteViewsFactory.ACTION_CONFIGURE
// Recheck
AllSettings.reInitialize(context)
if (PermissionsUtil.mustRequestPermissions(context)) RemoteViewsFactory.ACTION_CONFIGURE else intent.action
} else {
intent.action
}
Expand Down
26 changes: 11 additions & 15 deletions app/src/main/kotlin/org/andstatus/todoagenda/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.Settings
import android.util.Log
import android.view.View
import android.widget.AdapterView.OnItemClickListener
Expand All @@ -13,13 +14,11 @@ import android.widget.ListView
import android.widget.SimpleAdapter
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback
import org.andstatus.todoagenda.prefs.AllSettings
import org.andstatus.todoagenda.prefs.ApplicationPreferences
import org.andstatus.todoagenda.prefs.ApplicationPreferences.isAskForPermissions
import org.andstatus.todoagenda.provider.EventProviderType
import org.andstatus.todoagenda.provider.EventProviderType.Companion.neededPermissions
import org.andstatus.todoagenda.util.IntentUtil
import org.andstatus.todoagenda.util.PermissionsUtil

Expand Down Expand Up @@ -85,7 +84,9 @@ class MainActivity : AppCompatActivity(), OnRequestPermissionsResultCallback {
findViewById<Button>(R.id.grant_permissions)?.visibility =
if (needToRequestPermission) View.VISIBLE else View.GONE
findViewById<Button>(R.id.dont_ask_for_permissions_button)?.visibility =
if (needToRequestPermission && isAskForPermissions(this)) View.VISIBLE else View.GONE
if (needToRequestPermission && isAskForPermissions(this) &&
EventProviderType.availableSources.isNotEmpty()
) View.VISIBLE else View.GONE
findViewById<Button>(R.id.go_to_home_screen_button)?.visibility =
if (!needToRequestPermission && AllSettings.getInstances(this).isEmpty()) View.VISIBLE else View.GONE

Expand Down Expand Up @@ -125,25 +126,20 @@ class MainActivity : AppCompatActivity(), OnRequestPermissionsResultCallback {
}

fun onGrantPermissionsButtonClick(view: View?) {
neededPermissions.toList().takeIf { it.isNotEmpty() }?.let { neededPermissions ->
Log.d(localClassName, "Requesting permissions: $neededPermissions")
val arr: Array<String> = Array(neededPermissions.size) { i -> neededPermissions[i] }
ActivityCompat.requestPermissions(this, arr, 1)
}
updateScreen()
val intent = Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", packageName, null)
)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
finish()
}

fun onDontAskForPermissionsButtonClick(view: View?) {
ApplicationPreferences.setAskForPermissions(this, false)
onHomeButtonClick(view)
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
AllSettings.reInitialize(this)
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
updateScreen()
}

fun onHomeButtonClick(view: View?) {
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_HOME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.util.Log
import org.andstatus.todoagenda.EnvironmentChangedReceiver
import org.andstatus.todoagenda.calendar.CalendarEventProvider
import org.andstatus.todoagenda.calendar.CalendarEventVisualizer
import org.andstatus.todoagenda.prefs.ApplicationPreferences
import org.andstatus.todoagenda.prefs.EventSource
import org.andstatus.todoagenda.prefs.OrderedEventSource
import org.andstatus.todoagenda.task.TaskVisualizer
Expand Down Expand Up @@ -117,6 +118,9 @@ enum class EventProviderType(
}
}
}
if (availableSources.isEmpty()) {
ApplicationPreferences.setAskForPermissions(context, true)
}
initialized = true
}

Expand Down
7 changes: 6 additions & 1 deletion app/src/main/play/release-notes/en-US/default.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
v4.7.3 Filter for Today and Tomorrow. Show based on keywords in a title. Allow changing language of User Interface for Android 13+
v4.8.0. Fixed "Default Time zone in app doesn't change, when Android System Time Zone changes".
Fixed "Do not make all permissions mandatory".
App converted from Java to Kotlin.
v4.7.3. Filter for Today and Tomorrow.
Show based on keywords in a title.
Allow changing language of User Interface for Android 13+

7 changes: 6 additions & 1 deletion app/src/main/play/release-notes/ru-RU/default.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
v4.7.3 Фильтр "Сегодня и завтра". Показать только при начичии ключевых слов в названии. Изменение языка интерфейса для Android 13+
v4.8.0. Исправлено: Часовой пояс в виджете не менялся до перезапуска приложения.
Исправлено: Не надо делать все разрешения обязательными.
Приложение сконвертировано с Java на Kotlin. Это может быть интересно программистам :-)
v4.7.3. Фильтр "Сегодня и завтра".
Показать только при начичии ключевых слов в названии.
Изменение языка интерфейса для Android 13+
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="no_title">(Без заголовка)</string>
<string name="grant_permissions">Предоставить разрешения</string>
<string name="grant_permissions_verbose">Для Виджета требуется разрешение на чтение календарей и задач. \nНажмите здесь, чтобы предоставить это разрешение.</string>
<string name="dont_ask_for_permissions">Больше не спрашивать разрешения</string>
<string name="past_header">Просроченные</string>
<string name="end_of_list_header">Другие события</string>
<string name="permissions_justification">Добро пожаловать в приложение Todo Agenda - легкий доступ к вашим календарям и задачам.\n\nДля того, чтобы получить максимум от этого виджета, Вам необходимо предоставить этому приложению доступ к календарям и задачам.</string>
Expand Down

0 comments on commit 2c83fae

Please sign in to comment.