Skip to content

Commit

Permalink
prepare first public release
Browse files Browse the repository at this point in the history
  • Loading branch information
newhinton committed Jan 9, 2024
1 parent 7d53393 commit 2f9b2c4
Show file tree
Hide file tree
Showing 14 changed files with 298 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'kotlinx-serialization'

android {
defaultConfig {
applicationId "de.felixnuesse.timedsilence"
applicationId "de.felixnuesse.timedsilence.debug"
minSdkVersion 26
targetSdk 34
compileSdk 34
Expand Down
23 changes: 12 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,39 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<uses-permission android:name="android.permission.READ_CONTACTS" /> <!-- Needed for warnings if dnd is set -->

<uses-permission android:name="android.permission.READ_CONTACTS" />

<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".AboutActivity"
android:theme="@style/AboutStyle"
android:exported="false" />
<activity
android:name=".IntroActivity"
android:exported="true">
</activity>
android:theme="@style/BaseStyle.NoActionBar"
android:exported="true" />
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/BaseStyle.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SettingsActivity"
android:theme="@style/BaseStyle" />

<!-- Registering the BroadcastReceiver ! -->
<activity
android:name=".SettingsActivity"
android:theme="@style/BaseStyle" /> <!-- Registering the BroadcastReceiver ! -->
<receiver android:name=".receiver.AlarmBroadcastReciever" />
<receiver
android:name=".receiver.NoisyBroadcastReciever"
Expand Down Expand Up @@ -74,7 +76,6 @@
</intent-filter>
</receiver>
<receiver android:name=".ui.notifications.PausedNotification" />

<receiver
android:name=".widgets.StartStopWidget"
android:exported="true">
Expand Down
61 changes: 61 additions & 0 deletions app/src/main/java/de/felixnuesse/timedsilence/AboutActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package de.felixnuesse.timedsilence

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import de.felixnuesse.timedsilence.databinding.ActivityAboutBinding
import java.util.Calendar


class AboutActivity : AppCompatActivity() {

private lateinit var binding: ActivityAboutBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivityAboutBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.toolbar.title = "";
setSupportActionBar(binding.toolbar)


binding.help.setOnClickListener {
openURL("https://github.com/newhinton/Timed-Silence/issues")
}


binding.donate.setOnClickListener {
openURL("https://github.com/sponsors/newhinton")
}

binding.copyright.setOnClickListener {
openURL("https://github.com/newhinton/Timed-Silence")
}

binding.copyright.text = this.getString(R.string.copyright, Calendar.getInstance().get(Calendar.YEAR).toString())
}


override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_about, menu)
return true
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.action_exit -> {
finish()
true
}
else -> super.onOptionsItemSelected(item)
}
}

fun openURL(url: String) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
import com.github.appintro.AppIntro
import com.github.appintro.AppIntroFragment
import de.felixnuesse.timedsilence.util.PermissionManager
import de.felixnuesse.timedsilence.util.PrepareDefaultsUtil

class IntroActivity : AppIntro() {

Expand Down Expand Up @@ -122,6 +123,7 @@ class IntroActivity : AppIntro() {
putBoolean(getString(R.string.pref_key_intro_v1_0_0), true)
apply()
}
PrepareDefaultsUtil.addDefaults(this)
startActivity(Intent(this, MainActivity::class.java))
finish()
}
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/de/felixnuesse/timedsilence/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ package de.felixnuesse.timedsilence
*/

import android.annotation.SuppressLint
import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.PorterDuff
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.text.format.DateFormat
Expand Down Expand Up @@ -66,7 +64,6 @@ import de.felixnuesse.timedsilence.fragments.graph.GraphFragment
import de.felixnuesse.timedsilence.handler.*
import de.felixnuesse.timedsilence.handler.trigger.Trigger
import de.felixnuesse.timedsilence.handler.volume.VolumeHandler
import de.felixnuesse.timedsilence.model.contacts.ContactUtil
import de.felixnuesse.timedsilence.services.`interface`.TimerInterface
import de.felixnuesse.timedsilence.volumestate.StateGenerator

Expand Down Expand Up @@ -204,6 +201,7 @@ class MainActivity : AppCompatActivity(), TimerInterface {


when (item.itemId) {
R.id.action_about -> openAbout()
R.id.action_goto_dnd -> openDnDSettings()
R.id.action_settings -> openSettings()
R.id.action_set_manual_loud -> {
Expand Down Expand Up @@ -253,7 +251,11 @@ class MainActivity : AppCompatActivity(), TimerInterface {
return true
}


private fun openAbout(): Boolean {
val intent = Intent(this, AboutActivity::class.java).apply {}
startActivity(intent)
return true
}

private fun openDnDSettings(): Boolean {
startActivity(Intent("android.settings.ZEN_MODE_SETTINGS"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package de.felixnuesse.timedsilence.util

import android.content.Context
import de.felixnuesse.timedsilence.R
import de.felixnuesse.timedsilence.handler.volume.VolumeState
import de.felixnuesse.timedsilence.model.data.ScheduleObject
import de.felixnuesse.timedsilence.model.database.DatabaseHandler

class PrepareDefaultsUtil {

companion object {
fun addDefaults(context: Context) {
val db = DatabaseHandler(context)

var nightStartHour = 21
var nightStarMinutes = 0
var nightEndHour = 8
var nightEndMinutes = 0
val night = ScheduleObject(
context.getString(R.string.default_schedule_night),
(nightStartHour * 60 * 60 * 1000 + nightStarMinutes * 60 * 1000).toLong(),
(nightEndHour * 60 * 60 * 1000 + nightEndMinutes * 60 * 1000).toLong(),
VolumeState.TIME_SETTING_VIBRATE,
0,
pmon = true,
ptue = true,
pwed = true,
pthu = true,
pfri = true,
psat = true,
psun = true
)

db.createScheduleEntry(night)


var dayStartHour = 8
var dayStarMinutes = 15
var dayEndHour = 21
var dayEndMinutes = 0
val day = ScheduleObject(
context.getString(R.string.default_schedule_day),
(dayStartHour * 60 * 60 * 1000 + dayStarMinutes * 60 * 1000).toLong(),
(dayEndHour * 60 * 60 * 1000 + dayEndMinutes * 60 * 1000).toLong(),
VolumeState.TIME_SETTING_LOUD,
0,
pmon = true,
ptue = true,
pwed = true,
pthu = true,
pfri = true,
psat = true,
psun = true
)
db.createScheduleEntry(day)

}
}

}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/icon_close.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="@color/iconColor"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M480,536L284,732Q273,743 256,743Q239,743 228,732Q217,721 217,704Q217,687 228,676L424,480L228,284Q217,273 217,256Q217,239 228,228Q239,217 256,217Q273,217 284,228L480,424L676,228Q687,217 704,217Q721,217 732,228Q743,239 743,256Q743,273 732,284L536,480L732,676Q743,687 743,704Q743,721 732,732Q721,743 704,743Q687,743 676,732L480,536Z" />
</vector>
94 changes: 94 additions & 0 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AboutActivity">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@null"
android:theme="@style/AboutStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<ImageView
android:id="@+id/imageView"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_marginTop="48dp"
android:scaleType="fitStart"
android:scaleX="2"
android:scaleY="2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
app:srcCompat="@drawable/ic_launcher_foreground" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/app_name"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/toolbar"
app:layout_constraintTop_toBottomOf="@+id/imageView" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/made_by"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Felix Nüsse"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />

<Button
android:id="@+id/donate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="72dp"
android:text="@string/donate"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView4" />

<Button
android:id="@+id/help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/help"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/donate" />

<TextView
android:id="@+id/copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_checkup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="32dp"
android:gravity="center"
android:text="@string/contact_permission_hint"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/menu/menu_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="de.felixnuesse.timedsilence.MainActivity">
<item
android:id="@+id/action_exit"
android:icon="@drawable/icon_close"
android:orderInCategory="1"
android:title="@string/back"
app:showAsAction="always" />

</menu>
6 changes: 6 additions & 0 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="de.felixnuesse.timedsilence.MainActivity">
<item
android:id="@+id/action_about"
android:icon="@drawable/icon_help"
android:orderInCategory="100"
android:title="@string/about"
app:showAsAction="never" />
<item
android:id="@+id/action_goto_dnd"
android:icon="@drawable/icon_dnd"
Expand Down
Loading

0 comments on commit 2f9b2c4

Please sign in to comment.