Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Removed features that are not minimal. #355

Merged
merged 1 commit into from
Mar 9, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/close-inactive-issues_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
stale-issue-label: "Status: Stale"
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
exempt-issue-labels: "Status: Help wanted, Status: Work In Progress, Status: Waiting For a Response, Status: Todo, Type: Breaking Change"
exempt-issue-labels: "Status: Help wanted, Status: Work In Progress, Status: Waiting For a Response, Status: Todo"
days-before-pr-stale: 90
days-before-pr-close: 30
close-issue-reason: "not_planned"
stale-pr-label: "Status: Stale"
close-pr-label: "Status: Stale"
stale-pr-message: "This pull request is stale because it has been open for 30 days with no activity."
close-pr-message: "This pull request was closed because it has been inactive for 14 days since being marked as stale."
exempt-pr-labels: "Status: Help wanted, Status: Work In Progress, Status: Waiting For a Response, Status: Todo, Type: Breaking Change"
exempt-pr-labels: "Status: Help wanted, Status: Work In Progress, Status: Waiting For a Response, Status: Todo"
repo-token: ${{ secrets.GIT_BOT_TOKEN }}
2 changes: 1 addition & 1 deletion .github_changelog_generator
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ project=mLauncher
date_format=%e, %B %Y
summary_labels=Release summary,release-summary,Summary,summary,Type: Summary
summary_prefix=**Release Summary**
exclude_labels=Status: Stale,Type: Wont Fix,Type: Question,Status: Invalid,Ignore Release,Status: Duplicate
exclude_labels=Status: Stale,Status: Wont Fix,Type: Question,Status: Invalid,Ignore Release,Status: Duplicate,Status: Not Planned
breaking_labels=backwards-incompatible,Backwards incompatible,breaking,Type: Breaking Change
bug_labels=bug,Bug,Type: Bug Report
14 changes: 7 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ dependencies {
//noinspection GradleDependency
implementation("androidx.activity:activity-compose:1.8.2")
// Compose Material Design
implementation("androidx.compose.material:material:1.6.2")
implementation("androidx.compose.material:material:1.6.3")
implementation("com.github.SmartToolFactory:Compose-Colorful-Sliders:1.2.0")
// Animations
implementation("androidx.compose.animation:animation:1.6.2")
implementation("androidx.compose.animation:animation:1.6.3")
implementation("androidx.navigation:navigation-ui-ktx:2.7.7")

// AndroidX
implementation("androidx.compose.ui:ui:1.6.2")
implementation("androidx.compose.ui:ui-tooling:1.6.2")
implementation("androidx.compose.foundation:foundation:1.6.2")
implementation("androidx.compose.ui:ui:1.6.3")
implementation("androidx.compose.ui:ui-tooling:1.6.3")
implementation("androidx.compose.foundation:foundation:1.6.3")

implementation("com.google.code.gson:gson:2.10.1")
implementation("androidx.biometric:biometric-ktx:1.2.0-alpha05")
Expand All @@ -130,9 +130,9 @@ dependencies {
implementation("androidx.test.espresso:espresso-idling-resource:$androidxTestEspresso")

// Test rules and transitive dependencies:
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.2")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.3")
// Needed for createComposeRule, but not createAndroidComposeRule:
debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.2")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.3")
androidTestImplementation("androidx.navigation:navigation-testing:2.7.7")
debugImplementation("androidx.fragment:fragment-testing:1.6.2")
implementation("androidx.test:core-ktx:1.5.0")
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
tools:ignore="QueryAllPackagesPermission" />
<!--For opening alarm app-->
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.READ_CALENDAR" />

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

<application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ private const val DRAWER_ALIGNMENT = "DRAWER_ALIGNMENT"
private const val TIME_ALIGNMENT = "TIME_ALIGNMENT"
private const val STATUS_BAR = "STATUS_BAR"
private const val SHOW_BATTERY = "SHOW_BATTERY"
private const val SHOW_CALENDER_EVENT = "SHOW_CALENDER_EVENT"
private const val SHOW_DATE = "SHOW_DATE"
private const val HOME_LOCKED = "HOME_LOCKED"
private const val SHOW_TIME = "SHOW_TIME"
Expand Down Expand Up @@ -203,10 +202,6 @@ class Prefs(val context: Context) {
get() = prefs.getBoolean(SHOW_BATTERY, true)
set(value) = prefs.edit().putBoolean(SHOW_BATTERY, value).apply()

var showCalendarEvent: Boolean
get() = prefs.getBoolean(SHOW_CALENDER_EVENT, false)
set(value) = prefs.edit().putBoolean(SHOW_CALENDER_EVENT, value).apply()

var homeLocked: Boolean
get() = prefs.getBoolean(HOME_LOCKED, false)
set(value) = prefs.edit().putBoolean(HOME_LOCKED, value).apply()
Expand Down
139 changes: 0 additions & 139 deletions app/src/main/java/com/github/hecodes2much/mlauncher/ui/HomeFragment.kt
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
package com.github.hecodes2much.mlauncher.ui

import android.Manifest
import android.annotation.SuppressLint
import android.app.admin.DevicePolicyManager
import android.content.Context
import android.content.Context.VIBRATOR_SERVICE
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.database.Cursor
import android.os.Build
import android.os.Bundle
import android.os.Vibrator
import android.provider.CalendarContract
import android.text.format.DateFormat
import android.util.Log
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
import androidx.biometric.BiometricManager
import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_WEAK
Expand Down Expand Up @@ -61,10 +56,6 @@ import com.github.hecodes2much.mlauncher.listener.OnSwipeTouchListener
import com.github.hecodes2much.mlauncher.listener.ViewSwipeTouchListener
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
import java.util.TimeZone

class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener {

Expand All @@ -77,8 +68,6 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
private var _binding: FragmentHomeBinding? = null
private val binding get() = _binding!!

private val calendarPermission = Manifest.permission.READ_CALENDAR

private lateinit var biometricPrompt: BiometricPrompt
private lateinit var promptInfo: BiometricPrompt.PromptInfo

Expand All @@ -100,20 +89,6 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// Check for calendar permission
if (prefs.showCalendarEvent) {
if (isCalendarPermissionGranted()) {
// Permission already granted, retrieve calendar events
retrieveCalendarEvents()
} else {
// Permission not granted, request it
requestCalendarPermission()
}
} else {
binding.latestEventText.visibility = View.GONE
binding.latestEventDate.visibility = View.GONE
}

val hex = getHexForOpacity(requireContext(), prefs)
binding.mainLayout.setBackgroundColor(hex)

Expand Down Expand Up @@ -147,8 +122,6 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
binding.date.typeface = typeface
binding.batteryText.typeface = typeface
binding.setDefaultLauncher.typeface = typeface
binding.latestEventText.typeface = typeface
binding.latestEventDate.typeface = typeface
}
binding.batteryIcon.typeface = typeface

Expand All @@ -161,13 +134,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
binding.batteryIcon.setTextColor(fontColor)
binding.batteryText.setTextColor(fontColor)
binding.setDefaultLauncher.setTextColor(fontColor)
binding.latestEventText.setTextColor(fontColor)
binding.latestEventDate.setTextColor(fontColor)
}

// After retrieving the latest calendar event
binding.latestEventText.textSize = prefs.textSizeLauncher.toFloat() / 1.2f
binding.latestEventDate.textSize = prefs.textSizeLauncher.toFloat() / 1.2f
}

override fun onResume() {
Expand Down Expand Up @@ -242,112 +209,6 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
return true
}

// Function to check if the device is set to a 24-hour format
private fun is24HourFormat(): Boolean {
val calendar = Calendar.getInstance()
val is24Hour = DateFormat.is24HourFormat(context)

// Get the time format based on the device's settings
return if (is24Hour) {
// Device is set to 24-hour format
true
} else {
// Device is set to 12-hour format
val hour = calendar.get(Calendar.HOUR_OF_DAY) // Use HOUR_OF_DAY for 24-hour time
val amPm = DateFormat.format("a", calendar).toString()

// Check if the time format is actually 12-hour or 24-hour
hour in 1..11 && amPm.equals("am", ignoreCase = true) || hour == 12 && amPm.equals(
"pm",
ignoreCase = true
)
}
}

private fun isCalendarPermissionGranted(): Boolean {
return ContextCompat.checkSelfPermission(
requireContext(),
calendarPermission
) == PackageManager.PERMISSION_GRANTED
}

private val requestCalendarPermissionLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted: Boolean ->
if (isGranted) {
// Permission granted, retrieve calendar events
retrieveCalendarEvents()
} else {
// Permission denied, handle accordingly
Log.d("Calendar Event", getString(R.string.denied_calender_permission))
binding.latestEventText.text = getString(R.string.denied_calender_permission)
binding.latestEventDate.visibility = View.GONE
}
}

private fun requestCalendarPermission() {
requestCalendarPermissionLauncher.launch(calendarPermission)
}

private fun retrieveCalendarEvents() {
val calendarUri = CalendarContract.Events.CONTENT_URI
val projection = arrayOf(
CalendarContract.Events._ID,
CalendarContract.Events.TITLE,
CalendarContract.Events.DTSTART
)
val selection = CalendarContract.Events.DTSTART + ">= ?"
val selectionArgs = arrayOf(System.currentTimeMillis().toString())
val sortOrder = CalendarContract.Events.DTSTART + " ASC"

val cursor: Cursor? = requireContext().contentResolver.query(
calendarUri,
projection,
selection,
selectionArgs,
sortOrder
)

cursor?.use {
if (it.moveToFirst()) {
val titleIndex = it.getColumnIndex(CalendarContract.Events.TITLE)
val title = it.getString(titleIndex)

val startDateIndex = it.getColumnIndex(CalendarContract.Events.DTSTART)
val startDateMillis = it.getLong(startDateIndex)

val calendar = Calendar.getInstance()
calendar.timeInMillis = startDateMillis

val localTimeZone = TimeZone.getDefault()
calendar.timeZone = localTimeZone

val locale = prefs.language.locale()
val localTime = if (is24HourFormat()) {
DateFormat.getBestDateTimePattern(locale, "HHmm")
} else {
DateFormat.getBestDateTimePattern(locale, "hhmma")
}
val localDate = DateFormat.getBestDateTimePattern(locale, "eeeddMMM")

val localTimeDate = SimpleDateFormat("$localTime $localDate", Locale.getDefault())
val localTimeFormatted = localTimeDate.format(calendar.time)

val titleFormatted = "$title @"

// Use the title and start date as needed
binding.latestEventText.text = titleFormatted
binding.latestEventDate.text = localTimeFormatted
binding.latestEventText.visibility = View.VISIBLE
binding.latestEventDate.visibility = View.VISIBLE
Log.d("Calendar Event", "Title: $title, Start Date: $localTimeFormatted")
} else {
// No calendar events found
binding.latestEventText.visibility = View.GONE
binding.latestEventDate.visibility = View.GONE
}
}
}

@SuppressLint("ClickableViewAccessibility")
private fun initSwipeTouchListener() {
binding.touchArea.setOnTouchListener(getHomeScreenGestureListener(requireContext()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,6 @@ class SettingsFragment : Fragment() {
state = remember { mutableStateOf(prefs.showBattery) }
) { toggleShowBattery() }
},
{ _, onChange ->
SettingsToggle(
title = stringResource(R.string.show_calendar_event),
fontSize = iconFs,
onChange = onChange,
state = remember { mutableStateOf(prefs.showCalendarEvent) }
) { toggleShowCalendarEvent() }
},
{ _, onChange ->
SettingsToggle(
title = stringResource(R.string.lock_home_apps),
Expand Down Expand Up @@ -623,10 +615,6 @@ class SettingsFragment : Fragment() {
prefs.showBattery = !prefs.showBattery
}

private fun toggleShowCalendarEvent() {
prefs.showCalendarEvent = !prefs.showCalendarEvent
}

private fun toggleHomeLocked() {
prefs.homeLocked = !prefs.homeLocked
}
Expand Down
17 changes: 0 additions & 17 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,6 @@
android:textSize="@dimen/date_size"
tools:text="Thu, 30 Dec" />


<TextView
android:id="@+id/latestEventText"
style="@style/TextDefault"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="2dp"
android:textSize="@dimen/date_size" />

<TextView
android:id="@+id/latestEventDate"
style="@style/TextDefault"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="2dp"
android:textSize="@dimen/date_size" />

<LinearLayout
android:id="@+id/batteryLayout"
android:layout_width="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Sep 15 19:58:15 BST 2023
#Sat Mar 09 14:32:51 UTC 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists