Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tanujnotes committed Dec 31, 2022
1 parent 60d8a97 commit f3642d6
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 173 deletions.
24 changes: 0 additions & 24 deletions app/src/main/java/app/olauncher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import android.view.View
import android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.NavController
import androidx.navigation.Navigation
Expand Down Expand Up @@ -87,16 +86,6 @@ class MainActivity : AppCompatActivity() {
binding.messageLayout.visibility = View.GONE
viewModel.showMessageDialog("")
}
binding.closeOneLink.setOnClickListener {
binding.supportOlauncherLayout.visibility = View.GONE
}
binding.copyOneLink.setOnClickListener {
copyToClipboard(getAffiliateUrl())
binding.supportOlauncherLayout.visibility = View.GONE
}
binding.openOneLink.setOnClickListener {
openUrl(getAffiliateUrl())
}
}

private fun initObservers(viewModel: MainViewModel) {
Expand All @@ -106,9 +95,6 @@ class MainActivity : AppCompatActivity() {
viewModel.showMessageDialog.observe(this) {
showMessage(it)
}
viewModel.showSupportDialog.observe(this) {
binding.supportOlauncherLayout.isVisible = it
}
}

@SuppressLint("SourceLockedOrientationActivity")
Expand All @@ -121,9 +107,6 @@ class MainActivity : AppCompatActivity() {

private fun backToHomeScreen() {
binding.messageLayout.visibility = View.GONE
binding.supportOlauncherLayout.visibility = View.GONE
// Whenever home button is pressed or user leaves the launcher,
// pop all the fragments except main
if (navController.currentDestination?.id != R.id.mainFragment)
navController.popBackStack(R.id.mainFragment, false)
}
Expand Down Expand Up @@ -155,13 +138,6 @@ class MainActivity : AppCompatActivity() {
binding.messageLayout.visibility = View.VISIBLE
}

private fun getAffiliateUrl(): String {
return if (TimeZone.getDefault().displayName.equals(Constants.IST_NAME, true))
Constants.URL_AFFILIATE_IN
else
Constants.URL_AFFILIATE
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/app/olauncher/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
val launcherResetFailed = MutableLiveData<Boolean>()
val homeAppAlignment = MutableLiveData<Int>()
val showMessageDialog = MutableLiveData<String>()
val showSupportDialog = SingleLiveEvent<Boolean>()

fun selectedApp(appModel: AppModel, flag: Int) {
when (flag) {
Expand Down Expand Up @@ -212,8 +211,4 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
fun showMessageDialog(message: String) {
showMessageDialog.postValue(message)
}

fun showSupportDialog(value: Boolean) {
showSupportDialog.postValue(value)
}
}
10 changes: 5 additions & 5 deletions app/src/main/java/app/olauncher/data/AppModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import android.os.UserHandle
import java.text.CollationKey

data class AppModel(
val appLabel: String,
val key: CollationKey?,
val appPackage: String,
val activityClassName: String?,
val user: UserHandle
val appLabel: String,
val key: CollationKey?,
val appPackage: String,
val activityClassName: String?,
val user: UserHandle,
) : Comparable<AppModel> {
override fun compareTo(other: AppModel): Int = when {
key != null && other.key != null -> key.compareTo(other.key)
Expand Down
10 changes: 2 additions & 8 deletions app/src/main/java/app/olauncher/data/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,17 @@ object Constants {
const val TRIPLE_TAP_DELAY_MS = 300L
const val LONG_PRESS_DELAY_MS = 500L

const val URL_ABOUT_OLAUNCHER =
"https://tanujnotes.notion.site/Olauncher-Minimal-AF-4843e398b05a455bb521b0665b26fbcd"
const val URL_OLAUNCHER_PRIVACY =
"https://tanujnotes.notion.site/Olauncher-Privacy-Policy-dd6ac5101ddd4b3da9d27057889d44ab"
const val URL_ABOUT_OLAUNCHER = "https://tanujnotes.notion.site/Olauncher-Minimal-AF-4843e398b05a455bb521b0665b26fbcd"
const val URL_OLAUNCHER_PRIVACY = "https://tanujnotes.notion.site/Olauncher-Privacy-Policy-dd6ac5101ddd4b3da9d27057889d44ab"
const val URL_OLAUNCHER_GITHUB = "https://www.github.com/tanujnotes/Olauncher"
const val URL_OLAUNCHER_PLAY_STORE = "https://play.google.com/store/apps/details?id=app.olauncher"
const val URL_PLAY_STORE_DEV = "https://play.google.com/store/apps/dev?id=7198807840081074933"
const val URL_TWITTER_TANUJ = "https://twitter.com/tanujnotes"
const val URL_INSTA_OLAUNCHER = "https://instagram.com/olauncherapp"
const val URL_AFFILIATE = "https://amzn.to/3uftwFW"
const val URL_AFFILIATE_IN = "https://www.amazon.in/?tag=tanujnotes-20"
const val URL_NOTIFY = "https://gist.githubusercontent.com/tanujnotes/da9490348422979650ccb3ec9392a40f/raw"
const val URL_WALLPAPERS = "https://gist.githubusercontent.com/tanujnotes/bf400a269746c5c124a599af040dd82e/raw"
const val URL_DEFAULT_DARK_WALLPAPER = "https://images.unsplash.com/photo-1512551980832-13df02babc9e"
const val URL_DEFAULT_LIGHT_WALLPAPER = "https://images.unsplash.com/photo-1515549832467-8783363e19b6"
const val URL_DUCK_SEARCH = "https://duck.co/?q="

const val WALLPAPER_WORKER_NAME = "WALLPAPER_WORKER_NAME"
const val IST_NAME = "India Standard Time"
}
2 changes: 1 addition & 1 deletion app/src/main/java/app/olauncher/helper/FakeHomeActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app.olauncher.helper

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import app.olauncher.R

class FakeHomeActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal open class ViewSwipeTouchListener(c: Context?, v: View) : OnTouchListen
event1: MotionEvent,
event2: MotionEvent,
velocityX: Float,
velocityY: Float
velocityY: Float,
): Boolean {
try {
val diffY = event2.y - event1.y
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/app/olauncher/ui/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongClickListe
prefs.rateClicked = true
rateApp()
}
R.id.affiliate -> {
viewModel.showSupportDialog(true)
findNavController().popBackStack()
}
R.id.twitter -> requireContext().openUrl(Constants.URL_TWITTER_TANUJ)
R.id.instagram -> requireContext().openUrl(Constants.URL_INSTA_OLAUNCHER)
R.id.privacy -> requireContext().openUrl(Constants.URL_OLAUNCHER_PRIVACY)
Expand Down Expand Up @@ -197,7 +193,6 @@ class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongClickListe
binding.instagram.setOnClickListener(this)
binding.privacy.setOnClickListener(this)
binding.github.setOnClickListener(this)
binding.affiliate.setOnClickListener(this)
binding.moreApps.setOnClickListener(this)

binding.maxApps0.setOnClickListener(this)
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout-land/fragment_app_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
android:layout_marginTop="80dp"
android:clipChildren="false"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingBottom="24dp" />
android:fadingEdgeLength="24dp"
android:requiresFadingEdge="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

</FrameLayout>
28 changes: 10 additions & 18 deletions app/src/main/res/layout-land/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -741,48 +741,39 @@
android:gravity="center_horizontal"
android:orientation="horizontal">

<TextView
android:id="@+id/affiliate"
style="@style/TextSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:padding="10dp"
android:text="@string/affiliate" />

<TextView
android:id="@+id/about"
style="@style/TextSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:layout_marginHorizontal="8dp"
android:padding="10dp"
android:text="@string/about" />

<TextView
android:id="@+id/rate"
android:id="@+id/share"
style="@style/TextSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:layout_marginHorizontal="8dp"
android:padding="10dp"
android:text="@string/rate" />
android:text="@string/share" />

<TextView
android:id="@+id/share"
android:id="@+id/rate"
style="@style/TextSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:layout_marginHorizontal="8dp"
android:padding="10dp"
android:text="@string/share" />
android:text="@string/rate" />

<TextView
android:id="@+id/privacy"
style="@style/TextSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:layout_marginHorizontal="8dp"
android:padding="10dp"
android:text="@string/privacy" />

Expand Down Expand Up @@ -829,7 +820,8 @@
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="@string/settings_footer" />
android:text="@string/settings_footer"
android:visibility="gone" />

</LinearLayout>

Expand Down
85 changes: 0 additions & 85 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,89 +71,4 @@
</LinearLayout>

</FrameLayout>

<FrameLayout
android:id="@+id/supportOlauncherLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/dialogShadeColor"
android:clickable="true"
android:clipToPadding="false"
android:focusable="true"
android:padding="24dp"
android:visibility="gone">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/rounded_rectangle_dark"
android:elevation="8dp"
android:orientation="vertical"
android:outlineAmbientShadowColor="@color/colorPrimaryDark"
android:outlineSpotShadowColor="@color/colorPrimaryDark"
android:padding="24dp"
tools:targetApi="p">

<TextView
style="@style/TextSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:text="@string/support_olauncher_for_free"
android:textColor="?attr/primaryColor" />

<TextView
style="@style/TextSmallLight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:lineSpacingExtra="1dp"
android:text="@string/support_olauncher_message"
android:textColor="?attr/primaryColor" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">

<TextView
android:id="@+id/closeOneLink"
style="@style/TextSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="4dp"
android:text="@string/close"
android:textAllCaps="true" />

<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />

<TextView
android:id="@+id/copyOneLink"
style="@style/TextSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:paddingVertical="4dp"
android:text="@string/copy"
android:textAllCaps="true" />

<TextView
android:id="@+id/openOneLink"
style="@style/TextSmallBold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="4dp"
android:text="@string/open"
android:textAllCaps="true" />

</LinearLayout>

</LinearLayout>

</FrameLayout>
</FrameLayout>
5 changes: 2 additions & 3 deletions app/src/main/res/layout/adapter_app_drawer.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
Expand Down Expand Up @@ -30,11 +29,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="?attr/primaryColorInverseTrans90"
android:background="?attr/primaryColorInverseTrans80"
android:clickable="true"
android:focusable="true"
android:paddingHorizontal="@dimen/app_padding_vertical"
android:visibility="visible">
android:visibility="gone">

<TextView
android:id="@+id/appHide"
Expand Down
Loading

0 comments on commit f3642d6

Please sign in to comment.