diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cb9c54ce..0611528d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,4 +1,3 @@ -import org.jetbrains.kotlin.fir.scopes.debugCollectOverrides import java.text.SimpleDateFormat import java.util.Date @@ -10,7 +9,7 @@ plugins { android { namespace = "bums.lunatic.launcher" - compileSdk = 34 + compileSdk = 35 defaultConfig { applicationId = "bums.lunatic.launcher" @@ -82,20 +81,20 @@ dependencies { implementation ("androidx.appcompat:appcompat:1.7.0") implementation ("androidx.biometric:biometric-ktx:1.2.0-alpha05") implementation ("androidx.browser:browser:1.8.0") - implementation ("androidx.core:core-ktx:1.13.1") + implementation ("androidx.core:core-ktx:1.15.0") implementation ("androidx.core:core-splashscreen:1.0.1") - implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4") + implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7") implementation ("com.google.android.material:material:1.12.0") implementation (kotlin("stdlib", version = kotlinVersion)) implementation ("com.github.cachapa:ExpandableLayout:2.9.2") implementation ("com.squareup.picasso:picasso:2.71828") - implementation ("androidx.work:work-runtime:2.9.1") + implementation ("androidx.work:work-runtime:2.10.0") implementation ("com.google.code.gson:gson:2.11.0") implementation ("io.realm.kotlin:library-base:2.1.0") implementation ("org.jsoup:jsoup:1.18.1") implementation ("org.apache.commons:commons-text:1.12.0") implementation("com.squareup.okhttp:okhttp:2.7.5") - implementation("com.google.android.gms:play-services-location:21.0.1") + implementation("com.google.android.gms:play-services-location:21.3.0") implementation("com.google.android.gms:play-services-tasks:18.2.0") implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-gson:2.6.4") diff --git a/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt b/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt index c7671259..07a2c22a 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt @@ -21,6 +21,7 @@ package bums.lunatic.launcher //import rasel.lunar.launcher.home.LauncherHome.Companion.rssSet import android.Manifest + import android.annotation.SuppressLint import android.app.NotificationManager import android.appwidget.AppWidgetManager @@ -85,7 +86,6 @@ import bums.lunatic.launcher.helpers.Constants.Companion.PREFS_FIRST_LAUNCH import bums.lunatic.launcher.helpers.Constants.Companion.PREFS_SETTINGS import bums.lunatic.launcher.helpers.Constants.Companion.widgetHostId import bums.lunatic.launcher.helpers.PrefHelper -import bums.lunatic.launcher.helpers.ViewPagerAdapter import bums.lunatic.launcher.helpers.letTrue import bums.lunatic.launcher.home.LauncherHome import bums.lunatic.launcher.home.LauncherHome.Companion.lastedFinishedPageUrl @@ -142,7 +142,7 @@ internal class LauncherActivity : AppCompatActivity() { private lateinit var binding: LauncherActivityBinding private lateinit var settingsPrefs: SharedPreferences - lateinit var viewPager: ViewPager2 +// lateinit var viewPager: ViewPager2 companion object { private var mWorkManager: WorkManager? = null @@ -335,6 +335,7 @@ internal class LauncherActivity : AppCompatActivity() { } + override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) @@ -379,16 +380,37 @@ internal class LauncherActivity : AppCompatActivity() { } // BLog.LOGE("onNewIntent intent?.dataString >> ${intent?.dataString}") // BLog.LOGE("onNewIntent intent?.data >> ${intent?.data}") + } else { + BLog.LOGE("onNewIntent intent?.hasExtra >> ${intent?.hasExtra(Intent.EXTRA_STREAM)}") + + + if (intent?.action?.equals(Intent.ACTION_MAIN) == true && intent.categories.contains( + Intent.CATEGORY_HOME + ) && intent.hasExtra("android.intent.extra.EXTRA_START_REASON") && intent.getStringExtra( + "android.intent.extra.EXTRA_START_REASON" + ).equals("startDockOrHome") + ) { + if (binding.home.visibility == View.VISIBLE) { + switchAppDrawer() + } + } else { + intent?.extras?.keySet()?.forEach { + try { + BLog.LOGE( + "onNewIntent :: key >> ${it} :: value >> ${ + intent?.extras?.getString( + it + ) + }" + ) + } catch (e: Exception) { + e.printStackTrace() + } + + } + } } - BLog.LOGE("onNewIntent intent?.hasExtra >> ${intent?.hasExtra(Intent.EXTRA_STREAM)}") - - - intent?.extras?.keySet()?.forEach { - try { - BLog.LOGE("onNewIntent :: key >> ${it} :: value >> ${intent?.extras?.getString(it)}") - } catch (e : Exception) {e.printStackTrace()} - - } +// android.intent.extra.EXTRA_START_REASON :: value >> startDockOrHome // binding.viewPager.invalidate() @@ -397,13 +419,13 @@ internal class LauncherActivity : AppCompatActivity() { // } super.onNewIntent(intent) } - + lateinit var home : LauncherHome @SuppressLint("NewApi", "MissingPermission") override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() mWorkManager = WorkManager.getInstance(this) DynamicColors.applyToActivityIfAvailable(this) - + lActivity = this settingsPrefs = getSharedPreferences(PREFS_SETTINGS, 0) AppCompatDelegate.setDefaultNightMode(settingsPrefs.getInt(KEY_APPLICATION_THEME, MODE_NIGHT_FOLLOW_SYSTEM)) @@ -412,8 +434,6 @@ internal class LauncherActivity : AppCompatActivity() { WindowCompat.setDecorFitsSystemWindows(window, false) binding = LauncherActivityBinding.inflate(layoutInflater) setContentView(binding.root) - - lActivity = this appWidgetManager = AppWidgetManager.getInstance(applicationContext) appWidgetHost = WidgetHost(applicationContext, widgetHostId) appWidgetHost?.startListening() @@ -421,7 +441,7 @@ internal class LauncherActivity : AppCompatActivity() { /* if this is the first launch, then remember the event and show the welcome dialog */ welcomeDialog() - setupView() + home = binding.home.getFragment() /* handle navigation back events */ handleBackPress() @@ -570,19 +590,45 @@ internal class LauncherActivity : AppCompatActivity() { } } - /* set up viewpager2 */ - private fun setupView() { - viewPager = binding.viewPager.apply { - adapter = ViewPagerAdapter( - supportFragmentManager, - mutableListOf(Feeds(), LauncherHome(), AppDrawer()), - lifecycle - ) - offscreenPageLimit = 1 - setCurrentItem(1, false) - reduceDragSensitivity() + val feeds by lazy { Feeds() } + val appDrawer by lazy { AppDrawer() } + + fun switchFeeds(){ + if(supportFragmentManager.findFragmentByTag("Feeds") == null){ + val transaction = supportFragmentManager.beginTransaction() + transaction.add(R.id.feeds, feeds,"Feeds") + transaction.commit() + } + if(binding.feeds.visibility == View.GONE) { + binding.home.visibility = View.GONE + binding.feeds.visibility = View.VISIBLE + supportFragmentManager.beginTransaction().show(feeds).commit() + } else { + binding.feeds.visibility = View.GONE + binding.home.visibility = View.VISIBLE + supportFragmentManager.beginTransaction().hide(feeds).commit() } } + fun switchAppDrawer() { + if(supportFragmentManager.findFragmentByTag("AppDrawer") == null){ + val transaction = supportFragmentManager.beginTransaction() + transaction.add(R.id.app_drawer, appDrawer,"AppDrawer") + transaction.commit() + } + if(binding.appDrawer.visibility == View.GONE) { + supportFragmentManager.beginTransaction().show(appDrawer).commit() + binding.home.visibility = View.GONE + binding.appDrawer.visibility = View.VISIBLE + appDrawer.openSearch() + } else { + supportFragmentManager.beginTransaction().hide(appDrawer).commit() + binding.home.visibility = View.VISIBLE + binding.appDrawer.visibility = View.GONE + } + } + + + private fun setBgColor() { binding.root.setBackgroundColor(Color.parseColor("#22000000")) @@ -614,11 +660,14 @@ internal class LauncherActivity : AppCompatActivity() { private fun handleBackPress() { onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { - /* while in to-do manager, go back to home screen */ - if (supportFragmentManager.backStackEntryCount != 0) supportFragmentManager.popBackStack() - /* while in feeds or app drawer, go back to home screen */ - if (viewPager.currentItem != 1) viewPager.currentItem = 1 + if (binding.feeds.visibility == View.VISIBLE) { + switchFeeds() + } else if (binding.appDrawer.visibility == View.VISIBLE) { + switchAppDrawer() + } else if (binding.home.visibility == View.VISIBLE) { + switchAppDrawer() + } } }) } @@ -637,19 +686,6 @@ internal class LauncherActivity : AppCompatActivity() { } } - private fun ViewPager2.reduceDragSensitivity() { - ViewPager2::class.java.getDeclaredField("mRecyclerView").apply { - isAccessible = true - }.let { recyclerViewField -> - (recyclerViewField.get(this) as RecyclerView).let { recyclerView -> - RecyclerView::class.java.getDeclaredField("mTouchSlop").apply { - isAccessible = true - set(recyclerView, this.get(recyclerView) as Int * 8) - } - } - } - } - fun openSearchMenus(keyword : String, dismissCalback: DismissCalback) { SearchMenu().show(supportFragmentManager,keyword) {dismissCalback?.invoke()} } @@ -678,137 +714,6 @@ internal class LauncherActivity : AppCompatActivity() { startActivity(mapIntent) } -// fun doWebSavor(url : String, callBack :CommadCallabck?) { -// if (true)return -// this.callBack = callBack -// -// binding.searcher01.post { binding.searcher01.visibility = View.VISIBLE } -// BLog.LOGE("binding.otherCheck before ThreadRun") -// binding.searcher01.bringToFront() -// binding.searcher01.alpha = 1f -// binding.searcher01.webViewClient = object : WebViewClient() { -// override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { -// if (url?.contains("missav") == true && isF) { -// BLog.LOGE("binding.otherCheck before reload") -// view?.loadUrl(url!!) -// isF = true -// return false -// } -// return false -// } -// -// override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { -// BLog.LOGE("binding.otherCheck searcher01 in onPageStarted ${url}") -// super.onPageStarted(view, url, favicon) -// } -// override fun onReceivedError( -// view: WebView?, -// request: WebResourceRequest?, -// error: WebResourceError? -// ) { -// -// } -// override fun onReceivedSslError( -// view: WebView?, -// handler: SslErrorHandler?, -// error: SslError? -// ) { -// handler?.proceed() -// } -// -// override fun onPageFinished(view: WebView?, url: String?) { -// super.onPageFinished(view, url) -// autoScrollDown(view,url) -// -// } -// } -// -// WebView.setWebContentsDebuggingEnabled(false) -// binding.searcher01.apply { -// setBackgroundColor(Color.WHITE) // 백그라운드 색상 설정 -// setLayerType(View.LAYER_TYPE_SOFTWARE, null) // 랜더링 이슈 해결 -// try { -// settings.apply { -// userAgentString = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36" -// javaScriptEnabled = true // 자바스크립트 사용 가능하도록 설정 -// loadWithOverviewMode = true // 전체 웹페이지를 화면에 맞게 로드 -// useWideViewPort = true // 화면에 맞게 페이지 확대/축소 -// domStorageEnabled = true // DOM 저장소 사용 가능하도록 설정 -// setSupportMultipleWindows(true) -// javaScriptCanOpenWindowsAutomatically = true // 팝업창 차단 해제 -// cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK -// textZoom = 100 // system 에 의한 글꼴 변형 방지 -// defaultTextEncodingName = "UTF-8" // 인코딩 설정 -// allowContentAccess = true // 웹뷰를 통해 content url에 접근할지 여부 -// layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING // 웹페이지의 레이아웃을 화면에 맞게 자동으로 조정 -// } -// } catch (ignore: NoSuchMethodError) { -// -// }.apply { -// loadUrl(url) // 웹페이지 연결 -// } -// } -// } -// fun autoScrollDown(webView: WebView?, url: String?) { -// webView?.let { webView -> -// val ramdomTimeSec = -// 800L.plus(Math.abs(Random(System.currentTimeMillis()).nextLong().rem(489L))) -// BLog.LOGE("ramdomTime >>> ${ramdomTimeSec}") -// if (((webView?.scrollY ?: 0) + (webView?.height -// ?: 0)) < webView?.contentHeight ?: 0 -// ) { -// webView?.postDelayed({ -// webView?.scrollY = (binding.searcher01.scrollY) + (binding.searcher01.height.toFloat() * 0.4).toInt() -// autoScrollDown(webView, url) -// }, ramdomTimeSec) -// } else { -// webView?.postDelayed({ -// binding.viewPager.bringToFront() -// binding.searcher01.alpha = 0f -// if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) { -// val fileName = url?.toUri()?.path?.replace("/","_")?.replace(".","_") -// val path = File(Environment.getExternalStorageDirectory(),"bums") -// if (path.exists() == false) { -// path.mkdirs() -// } -// val file = File(path, fileName.plus(".pdf")) -// -// BLog.LOGE("file >>> ${file.absolutePath}") -// try { -// PDFPrint.generatePDFFromWebView(file,webView, object : PDFPrint.OnPDFPrintListener { -// override fun onSuccess(file: File?) { -// BLog.LOGE("file >>>> ${file!!.absolutePath}") -// val shareIntent: Intent = Intent().apply { -// action = Intent.ACTION_SEND -// this.`package` = "com.synology.dsdrive" -// val imageUri = FileProvider.getUriForFile( -// this@LauncherActivity, -// "rasel.lunar.launcher.debug.fileprovider", //(use your app signature + ".provider" ) -// file -// ) -// putExtra(Intent.EXTRA_STREAM, imageUri) -// type = "pdf" -// } -// this@LauncherActivity.startActivity(shareIntent) -// } -// -// override fun onError(exception: java.lang.Exception?) { -// Toast.makeText(this@LauncherActivity, -// "Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show() -// exception?.printStackTrace() -// } -// } ) -// } catch (e: IOException) { -// e.printStackTrace() -// } -// } else { -// -// } -// }, ramdomTimeSec) -// } -// } -// } - var callBack : CommadCallabck? = null var isF = false fun doWebParseStart(url : String, callBack :CommadCallabck?) { @@ -1084,7 +989,7 @@ internal class LauncherActivity : AppCompatActivity() { } var postNext : Runnable = Runnable{ - callBack?.collectComplete() + callBack?.collectComplete() } val callBackHandler = Handler(Looper.getMainLooper()) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt index 9ecd69e6..77cdf49a 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppDrawer.kt @@ -73,7 +73,7 @@ internal class AppDrawer : Fragment() { private var isKeyboardShowing: Boolean = false companion object { - private var packageManager: PackageManager? = null + lateinit var packageManager: PackageManager private var appsAdapter: AppsAdapter? = null private var contactAdapter : ContactAdapter? = null private var packageList = mutableListOf() @@ -104,15 +104,26 @@ internal class AppDrawer : Fragment() { } } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + packageManager = lActivity?.packageManager!! + } + + override fun onAttach(context: Context) { + super.onAttach(context) + } + fun getInputText() = binding.searchInput.text.toString() override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + binding = AppDrawerBinding.inflate(inflater, container, false) settingsPrefs = requireContext().getSharedPreferences(PREFS_SETTINGS, 0) appNamesPrefs = requireContext().getSharedPreferences(PREFS_APP_NAMES, 0) layoutType = settingsPrefs!!.getInt(KEY_APPS_LAYOUT, 0) - packageManager = lActivity?.packageManager + appsAdapter = AppsAdapter(layoutType, packageManager!!, childFragmentManager, binding.appsCount) contactAdapter = ContactAdapter(packageManager!!, childFragmentManager) @@ -277,9 +288,10 @@ internal class AppDrawer : Fragment() { fetchApps() binding.appsCount.visibility = if (PrefBoolean.showAppResultCount.get(false)) VISIBLE else GONE - - PrefBoolean.openWithKayboard.get().letTrue { openSearch() } - registCancelSearch() + if (isAdded && isVisible) { + PrefBoolean.openWithKayboard.get().letTrue { openSearch() } + registCancelSearch() + } // BLog.LOGE("onResume after chechHandler.postDelayed(cancelSearch, 3000L)") } @@ -468,13 +480,17 @@ internal class AppDrawer : Fragment() { registCancelSearch() } - private fun openSearch() { - binding.searchInput.apply { - visibility = VISIBLE - requestFocus() - let { - (lActivity?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager)?.showSoftInput(it, InputMethodManager.SHOW_IMPLICIT) + fun openSearch() { + try { + binding.searchInput.apply { + visibility = VISIBLE + requestFocus() + let { + (lActivity?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager)?.showSoftInput(it, InputMethodManager.SHOW_IMPLICIT) + } } + } catch (e : UninitializedPropertyAccessException) { + } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppMenu.kt b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppMenu.kt index 439dd908..c15ee2f1 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/apps/AppMenu.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/apps/AppMenu.kt @@ -283,8 +283,8 @@ internal class AppMenu : BottomSheetDialogFragment() { /* show activity list */ val activityAdapter: ArrayAdapter = ArrayAdapter(requireContext(), R.layout.list_item, R.id.itemText, ArrayList()) - if (activityInfo.activities.isNotEmpty()) { - for (activity in activityInfo.activities) { + if (activityInfo.activities?.isNotEmpty() == true) { + for (activity in activityInfo.activities!!) { if (packageName.contains("com.kakao") == true) { // BLog.LOGE("activity. >>>>> ${Gson().toJson(activity)}") } @@ -418,14 +418,14 @@ internal class AppMenu : BottomSheetDialogFragment() { packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS) } - return if (packageInfo.requestedPermissions.isNotEmpty()) { + return if (packageInfo.requestedPermissions?.isNotEmpty() == true) { val stringBuilder = StringBuilder() - packageInfo.requestedPermissions.indices.forEach { i: Int -> - if (i != packageInfo.requestedPermissions.size - 1) - stringBuilder.append("${packageInfo.requestedPermissions[i]}\n\n") + packageInfo.requestedPermissions?.indices?.forEach { i: Int -> + if (i != packageInfo.requestedPermissions!!.size - 1) + stringBuilder.append("${packageInfo.requestedPermissions!![i]}\n\n") /* don't add any new line after the last entry */ else - stringBuilder.append(packageInfo.requestedPermissions[i]) + stringBuilder.append(packageInfo.requestedPermissions!![i]) } stringBuilder.toString() } else { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt index 43b21eed..9768f890 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/LauncherHome.kt @@ -34,12 +34,15 @@ import android.os.Handler import android.os.Looper import android.os.SystemClock import android.provider.AlarmClock +import android.view.Gravity +import android.view.HapticFeedbackConstants import android.view.KeyEvent import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.CheckBox import android.widget.EditText +import android.widget.PopupWindow import android.widget.TableRow import android.widget.Toast import androidx.annotation.NonNull @@ -246,31 +249,33 @@ internal class LauncherHome : Fragment() { } }) - binding.favAppsGroup.setOnLongClickListener { - binding.otherCheck.isSelected = true - queryVotes() - true - } - binding.favAppsGroup.setOnClickListener { - if (binding.otherCheck.isSelected) { - searchData() - } -// else if (binding.otherCheck.isSelected) { + +// binding.favAppsGroup.setOnLongClickListener { +// binding.otherCheck.isSelected = true +// queryVotes() +// true +// } +// binding.favAppsGroup.setOnClickListener { +// if (binding.otherCheck.isSelected) { // searchData() // } -// else if (binding.otherCheck.isSelected) { -// searchData() +//// else if (binding.otherCheck.isSelected) { +//// searchData() +//// } +//// else if (binding.otherCheck.isSelected) { +//// searchData() +//// } +//// else if (binding.otherCheck.isSelected) { +//// searchData() +//// } +//// else if (binding.otherCheck.isSelected) { +//// searchData() +//// } +// else { +// QuickAccess().show(fragManager, BOTTOM_SHEET_TAG) // } -// else if (binding.otherCheck.isSelected) { -// searchData() -// } -// else if (binding.otherCheck.isSelected) { -// searchData() -// } - else { - QuickAccess().show(fragManager, BOTTOM_SHEET_TAG) - } - } +// } + arrayListOf(binding.mainList,binding.smsList,binding.infoList,binding.notiList).forEach { try { it.removeOnScrollListener(onScrChanged) @@ -415,21 +420,6 @@ internal class LauncherHome : Fragment() { } } } -// .asFlow() -// .collect { changes -> -// if (changes.list.size > 0) { -// Handler(Looper.getMainLooper()).post { -// mWeatherAdapter?.let { -// it.update( -// mutableListOf().apply { -// this.addAll(it.filter(changes.list)) -// } -// ) -// it.notifyDataSetChanged() -// } -// } -// } -// } } @@ -545,11 +535,12 @@ internal class LauncherHome : Fragment() { rssStateVote = true } + //RssDataType.GURU, + // RssDataType.MOST, + // RssDataType.REDDIT_NSFW fun queryInfos( filter: Collection? = arrayListOf( - RssDataType.GURU, - RssDataType.MOST, - RssDataType.REDDIT_NSFW + ), noLimit: Boolean = false ) { beforeQuery() @@ -607,9 +598,11 @@ internal class LauncherHome : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - rootViewGestures() - batteryProgressGestures() - todosGestures() + binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress, mFingerGestureListener)) + binding.root.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.root, mFingerGestureListener)) + binding.functionLayer.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.functionLayer, mFingerGestureListener)) + binding.time.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.time, mFingerGestureListener)) + BLog.LOGE("onViewCreated()") binding.missedCalls.visibility = if (PrefBoolean.showCallHistory.get(false)) View.VISIBLE else View.GONE @@ -721,6 +714,8 @@ internal class LauncherHome : Fragment() { enableSwipeToDeleteAndUndo() } + + fun searchData() { val builder: AlertDialog.Builder = AlertDialog.Builder(requireContext()) builder.setTitle("Command Line") @@ -863,29 +858,45 @@ internal class LauncherHome : Fragment() { private fun enableSwipeToDeleteAndUndo() { val swipeToDeleteCallback: SwipeToDeleteCallback = object : SwipeToDeleteCallback(requireContext()) { - override fun onSwiped(@NonNull viewHolder: RecyclerView.ViewHolder, i: Int) { + override fun onSwiped(@NonNull viewHolder: RecyclerView.ViewHolder, direction: Int) { + BLog.LOGE("onSwiped direction >>>> $direction") (viewHolder.itemView.tag as? RssData)?.let { rss -> WorkersDb.getRealm().apply { writeBlocking { - if(query("chosung == $0",rss.chosung).find().size == 1) { - if (rssStateVote && rss.vote) { - rss.vote = false - rss.read = 0 - } else { - rss.read += nomoreShowCount - } - copyToRealm(rss, UpdatePolicy.ALL) - } else { - query("chosung == $0",rss.chosung).find().forEach { it -> + when(direction) { + ItemTouchHelper.LEFT->{ if (rssStateVote && rss.vote) { - it.vote = false - it.read = 0 + rss.vote = false + rss.read = 0 } else { - it.read += nomoreShowCount + rss.read += nomoreShowCount + } + copyToRealm(rss, UpdatePolicy.ALL) + query("chosung == $0",rss.chosung).find().forEach { it -> + if (!rss.originPage().equals(it.originPage())) { + if (rssStateVote && rss.vote) { + it.vote = false + it.read = 0 + } else { + it.read += nomoreShowCount + } + copyToRealm(it, UpdatePolicy.ALL) + } } - copyToRealm(it, UpdatePolicy.ALL) } + ItemTouchHelper.RIGHT->{ + if (rssStateVote && rss.vote) { + rss.vote = false + rss.read = 0 + } else { + rss.vote = true + + } + copyToRealm(rss,UpdatePolicy.ALL) + } + else ->{} } + binding.infoList.post { mRssAdapter.refresh() } } } } @@ -953,7 +964,9 @@ internal class LauncherHome : Fragment() { ) startActivity(startIntene) } - + 1->{ + lActivity?.switchAppDrawer() + } else -> {} } return false @@ -1009,6 +1022,22 @@ internal class LauncherHome : Fragment() { // mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) // startActivity(mClockIntent) // } + + BLog.LOGE("onSwipeLeft targetView. >>>> ${targetView} && ${targetView.equals(binding.functionLayer)}") + if(targetView.equals(binding.functionLayer)){ + targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM) + when(fingers) { + 1->lActivity?.switchAppDrawer() + 2-> { + + } + else ->{} + } + } else if (targetView.equals(binding.time)) { + val mClockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS) + mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + startActivity(mClockIntent) + } return false } @@ -1018,8 +1047,16 @@ internal class LauncherHome : Fragment() { gestureDuration: Long, gestureDistance: Double ): Boolean { - if (targetView.equals(binding.time)) { - + if(targetView.equals(binding.functionLayer)){ + targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM) + when(fingers) { + 1->lActivity?.switchFeeds() + else ->{} + } + } else if (targetView.equals(binding.time)) { + val intent = Intent(Intent.ACTION_MAIN) + intent.addCategory(Intent.CATEGORY_APP_CALENDAR) + startActivity(intent) } return false } @@ -1030,6 +1067,7 @@ internal class LauncherHome : Fragment() { gestureDuration: Long, gestureDistance: Double ): Boolean { + BLog.LOGE("Maybe GA PINCH is Like Zoom out") return false } @@ -1039,60 +1077,85 @@ internal class LauncherHome : Fragment() { gestureDuration: Long, gestureDistance: Double ): Boolean { + BLog.LOGE("Maybe GA UN PINCH is Like Zoom In") return false } override fun onDoubleTap(targetView: View, fingers: Int): Boolean { - + targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM) when (fingers) { - 1 -> lockMethod( - settingsPrefs.getInt(KEY_LOCK_METHOD, 0), - requireContext(), - binding.favAppsGroup - ) + 1 -> lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.functionLayer) + else -> { - else -> {} - } - return false - } - - override fun onLongPress(targetView: View, fingers: Int): Boolean { - if (view?.equals(binding.batteryProgress) == true) { - lActivity!!.startActivity(Intent(requireContext(), SettingsActivity::class.java)) - } else if (view?.equals(binding.mainList) == true) { - when (settingsPrefs.getBoolean(KEY_TODO_LOCK, false)) { - false -> launchTodoManager() - /* show authentication screen if lock is on */ - true -> { - if (canAuthenticate(requireContext())) { - val biometricPrompt = - BiometricPrompt(lActivity!!, authenticationCallback) - try { - biometricPrompt.authenticate( - biometricPromptInfo( - lActivity!!.getString( - R.string.todo_manager - ) - ) - ) - } catch (exception: Exception) { - exception.printStackTrace() - } - } - } } } return false } + override fun onLongPress(targetView: View, fingers: Int): Boolean { + if (targetView?.equals(binding.batteryProgress) == true) { + lActivity!!.startActivity(Intent(requireContext(), SettingsActivity::class.java)) + } else if (targetView?.equals(binding.mainList) == true) { +// when (settingsPrefs.getBoolean(KEY_TODO_LOCK, false)) { +// false -> launchTodoManager() +// /* show authentication screen if lock is on */ +// true -> { +// if (canAuthenticate(requireContext())) { +// val biometricPrompt = +// BiometricPrompt(lActivity!!, authenticationCallback) +// try { +// biometricPrompt.authenticate( +// biometricPromptInfo( +// lActivity!!.getString( +// R.string.todo_manager +// ) +// ) +// ) +// } catch (exception: Exception) { +// exception.printStackTrace() +// } +// } +// } +// } + } else if (targetView?.equals(binding.functionLayer) == true) { + targetView?.performHapticFeedback(HapticFeedbackConstants.CONFIRM) + if(binding.otherCheck.isSelected && rssStateVote) { + queryInfos() + } else { + binding.otherCheck.isSelected = true + queryVotes() + } + return true + } + return false + } + override fun onClick(targetView: View, fingers: Int): Boolean { -// BLog.LOGE("onClick ${view} , fingers ${fingers}") + BLog.LOGE("onClick ${view} , fingers ${fingers}") + targetView.performHapticFeedback(HapticFeedbackConstants.CONFIRM) when (fingers) { 1 -> { - if (view?.equals(binding.batteryProgress) == true && fingers == 1) { - requireContext().startActivity( - Intent(AlarmClock.ACTION_SHOW_ALARMS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - ) + if (targetView.equals(binding.batteryProgress) == true) { + startActivity(Intent(android.provider.Settings.ACTION_SETTINGS)) + }else if(targetView.equals(binding.functionLayer)) { + if (binding.otherCheck.isSelected) { + searchData() + } +// else if (binding.otherCheck.isSelected) { +// searchData() +// } +// else if (binding.otherCheck.isSelected) { +// searchData() +// } +// else if (binding.otherCheck.isSelected) { +// searchData() +// } +// else if (binding.otherCheck.isSelected) { +// searchData() +// } + else { + QuickAccess().show(fragManager, BOTTOM_SHEET_TAG) + } } } @@ -1100,7 +1163,7 @@ internal class LauncherHome : Fragment() { lockMethod( settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), - binding.favAppsGroup + binding.functionLayer ) } @@ -1109,7 +1172,7 @@ internal class LauncherHome : Fragment() { } } - return false + return true } } @@ -1164,13 +1227,6 @@ internal class LauncherHome : Fragment() { } - /* gestures on battery progress indicator area */ - @SuppressLint("ClickableViewAccessibility") - private fun batteryProgressGestures() { - binding.batteryProgress.setOnClickListener { startActivity(Intent(android.provider.Settings.ACTION_SETTINGS)) } -// binding.time.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.time , mFingerGestureListener)) -// binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress , mFingerGestureListener)) - } /* gestures on to-do area */ @SuppressLint("ClickableViewAccessibility") diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewer.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewer.kt index a8b4bfa1..0adae1f8 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewer.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewer.kt @@ -22,7 +22,6 @@ import android.content.Intent import android.content.pm.PackageManager import android.os.Bundle import android.os.Environment -import android.print.PDFPrint import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -71,47 +70,47 @@ internal class RssViewer : DialogFragment() { binding = RssViewerBinding.inflate(inflater, container, false) binding.webview.loadUrl(tag!!) binding.webview.setDesktopMode(false) - binding.pdfPrint.setOnClickListener { pdfPring() } +// binding.pdfPrint.setOnClickListener { pdfPring() } return binding.root } - fun pdfPring() { - val fileName = tag?.toUri()?.path?.replace("/","_")?.replace(".","_") - val path = File(Environment.getExternalStorageDirectory(),"bums") - if (path.exists() == false) { - path.mkdirs() - } - val file = File(path, fileName.plus(".pdf")) - - BLog.LOGE("file >>> ${file.absolutePath}") - try { - PDFPrint.generatePDFFromWebView(file,binding.webview, object : PDFPrint.OnPDFPrintListener { - override fun onSuccess(file: File?) { - BLog.LOGE("file >>>> ${file!!.absolutePath}") - val shareIntent: Intent = Intent().apply { - action = Intent.ACTION_SEND - this.`package` = "com.synology.dsdrive" - val imageUri = FileProvider.getUriForFile( - lActivity!!, - "bums.lunatic.launcher.fileprovider", //(use your app signature + ".provider" ) - file - ) - putExtra(Intent.EXTRA_STREAM, imageUri) - type = "pdf" - } - lActivity!!.startActivity(shareIntent) - } - - override fun onError(exception: java.lang.Exception?) { - Toast.makeText(lActivity!!, - "Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show() - exception?.printStackTrace() - } - } ) - } catch (e: IOException) { - e.printStackTrace() - } - } +// fun pdfPring() { +// val fileName = tag?.toUri()?.path?.replace("/","_")?.replace(".","_") +// val path = File(Environment.getExternalStorageDirectory(),"bums") +// if (path.exists() == false) { +// path.mkdirs() +// } +// val file = File(path, fileName.plus(".pdf")) +// +// BLog.LOGE("file >>> ${file.absolutePath}") +// try { +// PDFPrint.generatePDFFromWebView(file,binding.webview, object : PDFPrint.OnPDFPrintListener { +// override fun onSuccess(file: File?) { +// BLog.LOGE("file >>>> ${file!!.absolutePath}") +// val shareIntent: Intent = Intent().apply { +// action = Intent.ACTION_SEND +// this.`package` = "com.synology.dsdrive" +// val imageUri = FileProvider.getUriForFile( +// lActivity!!, +// "bums.lunatic.launcher.fileprovider", //(use your app signature + ".provider" ) +// file +// ) +// putExtra(Intent.EXTRA_STREAM, imageUri) +// type = "pdf" +// } +// lActivity!!.startActivity(shareIntent) +// } +// +// override fun onError(exception: java.lang.Exception?) { +// Toast.makeText(lActivity!!, +// "Pdf Save Failk ${exception?.localizedMessage}", Toast.LENGTH_LONG).show() +// exception?.printStackTrace() +// } +// } ) +// } catch (e: IOException) { +// e.printStackTrace() +// } +// } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt index 7c2d932f..3c06e4f2 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/RssItemAdapter.kt @@ -44,6 +44,8 @@ import com.google.gson.Gson import com.squareup.picasso.Picasso import kr.lunaticbum.awesomewebview.AwesomeWebView import io.realm.kotlin.UpdatePolicy +import kr.lunaticbum.awesomewebview.listeners.WebViewListener +import kr.lunaticbum.awesomewebview.objects.CustomMenu import java.text.SimpleDateFormat import java.util.Date @@ -54,7 +56,14 @@ internal class RssItemAdapter ( @SuppressLint("SimpleDateFormat") val dateFormat = SimpleDateFormat("a HH:mm / yy - MM - dd") val emptyDate = " - " + val webViewListener = object : WebViewListener() { + override fun onCustomMenuClick(menuCode: String?) { + super.onCustomMenuClick(menuCode) + if ("PDF".equals(menuCode)) { + } + } + } val dateViewClick = View.OnClickListener { v -> (v?.tag as? RssData)?.let { rss -> WorkersDb.getRealm().apply { @@ -81,7 +90,11 @@ internal class RssItemAdapter ( // RssViewer().apply { // show(lActivity!!.supportFragmentManager,rss.originPage) // } - AwesomeWebView.Builder(lActivity!!).showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0) + AwesomeWebView.Builder(lActivity!!) +// .setWebViewListener(webViewListener).addCustomMenu( +// CustomMenu("PDF 저장","PDF") +// ). + .showIconClose(true).showIconBack(false).showProgressBar(true).backPressToClose(false).webViewMixedContentMode(1) .show(rss.originPage!!) // openOpera(rss.originPage()) } @@ -95,18 +108,22 @@ internal class RssItemAdapter ( // openReddit(rss.originPage()) } RssDataType.DOTAX -> { - RssViewer().apply { - AwesomeWebView.Builder(lActivity!!).show(rss.originPage!!) -// show(lActivity!!.supportFragmentManager,rss.originPage) - } -// openDotax(rss.originPage()) + AwesomeWebView.Builder(lActivity!!) +// .setWebViewListener(webViewListener).addCustomMenu( +// CustomMenu("PDF 저장","PDF") +// ). + .showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0) + .show(rss.originPage!!) } RssDataType.YOUTUBE -> { openYouTube(rss.originPage()) } else -> { - RssViewer().apply { - show(lActivity!!.supportFragmentManager,rss.originPage) - } + AwesomeWebView.Builder(lActivity!!) +// .setWebViewListener(webViewListener).addCustomMenu( +// CustomMenu("PDF 저장","PDF") +// ). + .showIconClose(true).showIconBack(false).showProgressBar(true).webViewMixedContentMode(0) + .show(rss.originPage!!) // openNews(rss.originPage()) } } @@ -148,9 +165,9 @@ internal class RssItemAdapter ( } else { holder.view.date.text = emptyDate } - if(RssDataType.FMKORAE.equals(rssData.category())) { - BLog.LOGE("rssData >>>> ${Gson().toJson(rssData)}") - } +// if(RssDataType.FMKORAE.equals(rssData.category())) { +// BLog.LOGE("rssData >>>> ${Gson().toJson(rssData)}") +// } holder.view.title.text = "".plus(if(rssData.vote) " * " else "").plus(rssData.title().plus("[R:${rssData.read}]")) holder.view.desc.text = rssData.description() @@ -203,6 +220,17 @@ internal class RssItemAdapter ( e.printStackTrace() } } + fun refresh() { + try { + val visibleItemCount = (layoutManager?.findLastVisibleItemPosition() ?: 0) - (layoutManager?.findFirstVisibleItemPosition() ?: 0) + val first = layoutManager?.findLastVisibleItemPosition() ?: 0 + if (visibleItemCount > 0) { + this@RssItemAdapter.notifyItemRangeChanged(first, visibleItemCount) + } + } catch (e: Exception) { + e.printStackTrace() + } + } } internal class RssHolder(var view: ListItemWithBinding) : RecyclerView.ViewHolder(view.root) {} diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/SwipeToDeleteCallback.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/SwipeToDeleteCallback.kt index 2aa7c717..ea583b94 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/SwipeToDeleteCallback.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/adapters/SwipeToDeleteCallback.kt @@ -13,6 +13,7 @@ import androidx.annotation.NonNull import androidx.core.content.ContextCompat import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.RecyclerView +import bums.lunatic.launcher.utils.BLog abstract class SwipeToDeleteCallback internal constructor(context: Context) : @@ -21,6 +22,7 @@ abstract class SwipeToDeleteCallback internal constructor(context: Context) : private val mClearPaint = Paint() private val mBackground = ColorDrawable() private val backgroundColor = Color.parseColor("#55b80f0a") + private val reverseColor = Color.parseColor("#55b80fb8") private val deleteDrawable: Drawable? private val intrinsicWidth: Int private val intrinsicHeight: Int @@ -38,7 +40,7 @@ abstract class SwipeToDeleteCallback internal constructor(context: Context) : @NonNull recyclerView: RecyclerView, @NonNull viewHolder: RecyclerView.ViewHolder ): Int { - return makeMovementFlags(0, ItemTouchHelper.LEFT) + return makeMovementFlags(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT) } override fun onMove( @@ -63,8 +65,7 @@ abstract class SwipeToDeleteCallback internal constructor(context: Context) : val itemView = viewHolder.itemView val itemHeight = itemView.height - val isCancelled = dX == 0f && !isCurrentlyActive - + val isCancelled = (dX == 0f) && !isCurrentlyActive if (isCancelled) { clearCanvas( c, @@ -77,24 +78,35 @@ abstract class SwipeToDeleteCallback internal constructor(context: Context) : return } - mBackground.color = backgroundColor - mBackground.setBounds( - itemView.right + dX.toInt(), - itemView.top, - itemView.right, - itemView.bottom - ) + + if (dX.toInt() < 0) { + mBackground.color = backgroundColor + mBackground.setBounds( + itemView.right + dX.toInt(), + itemView.top, + itemView.right, + itemView.bottom + ) + } else { + mBackground.color = reverseColor + mBackground.setBounds( + itemView.left, + itemView.top, + itemView.left + dX.toInt(), + itemView.bottom + ) + } mBackground.draw(c) - val deleteIconTop = itemView.top + (itemHeight - intrinsicHeight) / 2 - val deleteIconMargin = (itemHeight - intrinsicHeight) / 2 - val deleteIconLeft = itemView.right - deleteIconMargin - intrinsicWidth - val deleteIconRight = itemView.right - deleteIconMargin - val deleteIconBottom = deleteIconTop + intrinsicHeight - - - deleteDrawable!!.setBounds(deleteIconLeft, deleteIconTop, deleteIconRight, deleteIconBottom) - deleteDrawable.draw(c) +// val deleteIconTop = itemView.top + (itemHeight - intrinsicHeight) / 2 +// val deleteIconMargin = (itemHeight - intrinsicHeight) / 2 +// val deleteIconLeft = itemView.right - deleteIconMargin - intrinsicWidth +// val deleteIconRight = itemView.right - deleteIconMargin +// val deleteIconBottom = deleteIconTop + intrinsicHeight +// +// +// deleteDrawable!!.setBounds(deleteIconLeft, deleteIconTop, deleteIconRight, deleteIconBottom) +// deleteDrawable.draw(c) super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/utils/SimpleGesture.kt b/app/src/main/kotlin/bums/lunatic/launcher/utils/SimpleGesture.kt index d54ebad8..228f3047 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/utils/SimpleGesture.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/utils/SimpleGesture.kt @@ -419,7 +419,7 @@ class GestureAnalyser @JvmOverloads constructor( class SimpleFingerGestures : OnTouchListener { private var debug = BuildConfig.DEBUG var consumeTouchEvents: Boolean = false - var screenHeight : Int = 100 + var screenUnit : Int = 100 protected var tracking: BooleanArray = booleanArrayOf(false, false, false, false, false) private var ga: GestureAnalyser private var onFingerGestureListener: OnFingerGestureListener? = null @@ -432,8 +432,8 @@ class SimpleFingerGestures : OnTouchListener { this.targetView = targetView ga = GestureAnalyser() this.mContext?.resources?.displayMetrics?.let { - screenHeight = (it.heightPixels * 0.2).toInt() - ga.minValue = Math.max(screenHeight, 100) + screenUnit = (Math.min(it.widthPixels,it.heightPixels) * 0.3).toInt() + ga.minValue = Math.max(screenUnit, 100) } this.onFingerGestureListener = onFingerGestureListener this.targetView?.setOnClickListener { onFingerGestureListener.onClick(it,1) } @@ -685,17 +685,17 @@ class SimpleFingerGestures : OnTouchListener { } GestureAnalyser.CLICK_1 -> { // BLog.LOGE("GestureAnalyser.CLICK_1") - onFingerGestureListener!!.onClick(targetView, 1) + onFingerGestureListener!!.onClick(targetView, 1).apply { consumeTouchEvents = this } // onFingerGestureListener!!.onDoubleTap(1) } GestureAnalyser.CLICK_2 -> { // BLog.LOGE("GestureAnalyser.CLICK_2") - onFingerGestureListener!!.onClick(targetView, 2) + onFingerGestureListener!!.onClick(targetView, 2).apply { consumeTouchEvents = this } // onFingerGestureListener!!.onDoubleTap(1) } GestureAnalyser.CLICK_3 -> { // BLog.LOGE("GestureAnalyser.CLICK_3") - onFingerGestureListener!!.onClick(targetView, 3) + onFingerGestureListener!!.onClick(targetView, 3).apply { consumeTouchEvents = this } // onFingerGestureListener!!.onDoubleTap(1) } // GestureAnalyser.CLICK_2 -> { @@ -709,15 +709,15 @@ class SimpleFingerGestures : OnTouchListener { GestureAnalyser.LONG_CLICK_1 -> { // BLog.LOGE("GestureAnalyser.LONG_CLICK_1") - onFingerGestureListener!!.onLongPress(targetView,1) + onFingerGestureListener!!.onLongPress(targetView,1).apply { consumeTouchEvents = this } } GestureAnalyser.LONG_CLICK_2 -> { // BLog.LOGE("GestureAnalyser.LONG_CLICK_2") - onFingerGestureListener!!.onLongPress(targetView,2) + onFingerGestureListener!!.onLongPress(targetView,2).apply { consumeTouchEvents = this } } GestureAnalyser.LONG_CLICK_3 -> { // BLog.LOGE("GestureAnalyser.LONG_CLICK_3") - onFingerGestureListener!!.onLongPress(targetView,3) + onFingerGestureListener!!.onLongPress(targetView,3).apply { consumeTouchEvents = this } } GestureAnalyser.DOUBLE_TAP_1 -> onFingerGestureListener!!.onDoubleTap(targetView,1) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/view/DateTimeView.kt b/app/src/main/kotlin/bums/lunatic/launcher/view/DateTimeView.kt index f699809b..9fb63d40 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/view/DateTimeView.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/view/DateTimeView.kt @@ -52,39 +52,39 @@ class DateTimeView : AppCompatTextView { val now = Date(System.currentTimeMillis()) val time = SpannableString(simpleTimeFormat.format(now)) val date = SpannableString(simpleDateFormat.format(now)) - val mClickableSpan = object: ClickableSpan(){ - override fun updateDrawState(textPaint: TextPaint) { -// textPaint.color = this@MainActivity.getColor(R.color.blue) - textPaint.isUnderlineText = false - } - - override fun onClick(v: View) { - val mClockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS) - mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - context.startActivity(mClockIntent) - } - } - val mClickableSpan2 = object: ClickableSpan(){ - override fun updateDrawState(textPaint: TextPaint) { -// textPaint.color = this@MainActivity.getColor(R.color.blue) - textPaint.isUnderlineText = false - } - - override fun onClick(v: View) { - val intent = Intent(Intent.ACTION_MAIN) - intent.addCategory(Intent.CATEGORY_APP_CALENDAR) - context.startActivity(intent) - } - } +// val mClickableSpan = object: ClickableSpan(){ +// override fun updateDrawState(textPaint: TextPaint) { +//// textPaint.color = this@MainActivity.getColor(R.color.blue) +// textPaint.isUnderlineText = false +// } +// +// override fun onClick(v: View) { +// val mClockIntent = Intent(AlarmClock.ACTION_SHOW_ALARMS) +// mClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) +// context.startActivity(mClockIntent) +// } +// } +// val mClickableSpan2 = object: ClickableSpan(){ +// override fun updateDrawState(textPaint: TextPaint) { +//// textPaint.color = this@MainActivity.getColor(R.color.blue) +// textPaint.isUnderlineText = false +// } +// +// override fun onClick(v: View) { +// val intent = Intent(Intent.ACTION_MAIN) +// intent.addCategory(Intent.CATEGORY_APP_CALENDAR) +// context.startActivity(intent) +// } +// } spannableBuilder.append(time) spannableBuilder.setSpan(AbsoluteSizeSpan(resources.getDimensionPixelSize(R.dimen._26sp),false), 0, time.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) - spannableBuilder.setSpan(mClickableSpan, 0, time.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) +// spannableBuilder.setSpan(mClickableSpan, 0, time.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) spannableBuilder.append("\n") spannableBuilder.append(date) var start = time.length + "\n".length spannableBuilder.setSpan(AbsoluteSizeSpan(resources.getDimensionPixelSize(R.dimen._20sp),false), start , start+date.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) - spannableBuilder.setSpan(mClickableSpan2, start , start+date.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) +// spannableBuilder.setSpan(mClickableSpan2, start , start+date.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) mHandler.removeCallbacks(runable) setText(spannableBuilder) mHandler.postDelayed(runable, DateTimeView.DALEY) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/ArcaGetter.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/ArcaGetter.kt index 1c873613..5cac2fdc 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/ArcaGetter.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/ArcaGetter.kt @@ -8,6 +8,7 @@ import bums.lunatic.launcher.model.RssDataType import bums.lunatic.launcher.model.getRssData import bums.lunatic.launcher.model.getT import bums.lunatic.launcher.utils.beforeDay +import bums.lunatic.launcher.workers.WorkersDb.blockKeyword import org.jsoup.Jsoup import org.jsoup.nodes.Element import java.util.Date @@ -26,12 +27,12 @@ class ArcaGetter : BaseGetter { temp.clear() val urls = arrayListOf( "https://arca.live/b/singbung?mode=best", - "https://arca.live/b/headline", +// "https://arca.live/b/headline", // "https://arca.live/b/live", "https://arca.live/b/namuhotnow", "https://arca.live/b/society", // "https://arca.live/b/replay", - "https://arca.live/b/breaking" +// "https://arca.live/b/breaking" ) urls.forEach { Jsoup.connect(it) @@ -73,20 +74,22 @@ class ArcaGetter : BaseGetter { var tumbnail = aracaLi.getElementsByTag("img").attr("src") var link = "https://arca.live".plus(if(aracaLi.getElementsByClass("title hybrid-title").size > 0) aracaLi.getElementsByClass("title hybrid-title").get(0).attr("href") else if(aracaLi.getElementsByTag("a").size > 0) aracaLi.getElementsByTag("a").get(0).attr("href") else "") if (title.length > 0 && link.length > 20) { - Arca().apply { - this.link = link - this.title = title - if (tumbnail.length > 0) { - this.thumbnail = "https:".plus(tumbnail) + if(blockKeyword.filter { desc.contains(it) }.size == 0) { + Arca().apply { + this.link = link + this.title = title + if (tumbnail.length > 0) { + this.thumbnail = "https:".plus(tumbnail) // // BLog.LOGE("Arca thumbnail >>> ${thumbnail}") - } - this.desc = desc - this.dateTiem = dateTime - }.apply { + } + this.desc = desc + this.dateTiem = dateTime + }.apply { // BLog.LOGE("parseArcaLi >>>> ${this}") - if(this.pubDate() > beforeDay(Date(),3)) { - tempArray.add(this) + if (this.pubDate() > beforeDay(Date(), 3)) { + tempArray.add(this) + } } } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt index 0156af33..a52814d6 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt @@ -80,6 +80,7 @@ object WorkersDb { } } + val blockKeyword = arrayListOf("붕괴 스타레일","붕괴 스타일","트릭컬 RE:VIVE","원신","메이플스토리","") fun insertBulkData(rssDatas: Collection) { rssDatas.forEach { try { diff --git a/app/src/main/res/layout/launcher_activity.xml b/app/src/main/res/layout/launcher_activity.xml index a7c0d4f8..8d3f74c2 100644 --- a/app/src/main/res/layout/launcher_activity.xml +++ b/app/src/main/res/layout/launcher_activity.xml @@ -14,11 +14,25 @@ android:alpha="0" android:layout_height="match_parent"/> - + android:layout_height="match_parent"/> + + + + + + + diff --git a/app/src/main/res/layout/launcher_home.xml b/app/src/main/res/layout/launcher_home.xml index 4efb3528..57d84f4a 100644 --- a/app/src/main/res/layout/launcher_home.xml +++ b/app/src/main/res/layout/launcher_home.xml @@ -215,7 +215,7 @@ android:layout_width="match_parent" android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@+id/summaryChoose" - app:layout_constraintBottom_toTopOf="@id/favAppsGroup" + app:layout_constraintBottom_toTopOf="@id/functionLayer" > - + + + + + + + + \ No newline at end of file diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 7748f3ee..491e5bb6 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -5,12 +5,12 @@ plugins { android { namespace = "kr.lunaticbum.awesomewebview" - compileSdk = 34 + compileSdk = 35 defaultConfig { // applicationId = "kr.lunaticbum.awesomewebview" minSdk = 26 - targetSdk = 34 +// targetSdk = 34 // versionCode = 1 // versionName = "0.0.1" } @@ -40,6 +40,6 @@ dependencies { implementation ("androidx.appcompat:appcompat:1.7.0") implementation ("com.google.android.material:material:1.12.0") // implementation ("com.nineoldandroids:library:2.4.0") - implementation ("androidx.core:core-ktx:1.13.1") + implementation ("androidx.core:core-ktx:1.15.0") implementation(project(":utils")) } \ No newline at end of file diff --git a/library/src/main/java/kr/lunaticbum/awesomewebview/AwesomeWebView.kt b/library/src/main/java/kr/lunaticbum/awesomewebview/AwesomeWebView.kt index 52ac6304..ff8fc52d 100644 --- a/library/src/main/java/kr/lunaticbum/awesomewebview/AwesomeWebView.kt +++ b/library/src/main/java/kr/lunaticbum/awesomewebview/AwesomeWebView.kt @@ -92,6 +92,9 @@ class AwesomeWebView { var menuTextPaddingLeft: Float? = null var menuTextPaddingRight: Float? = null + var showMenuPdf: Boolean? = null + var stringResPdf: Int? = null + var showMenuRefresh: Boolean? = null var stringResRefresh: Int? = null var showMenuFind: Boolean? = null diff --git a/library/src/main/java/kr/lunaticbum/awesomewebview/AwesomeWebViewActivity.kt b/library/src/main/java/kr/lunaticbum/awesomewebview/AwesomeWebViewActivity.kt index e90f1b23..474384a6 100644 --- a/library/src/main/java/kr/lunaticbum/awesomewebview/AwesomeWebViewActivity.kt +++ b/library/src/main/java/kr/lunaticbum/awesomewebview/AwesomeWebViewActivity.kt @@ -16,6 +16,7 @@ import android.os.Bundle import android.os.Environment import android.os.Handler import android.os.Message +import android.print.PDFPrint import android.provider.MediaStore import android.util.TypedValue import android.view.Gravity @@ -59,6 +60,7 @@ import androidx.appcompat.widget.Toolbar import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.content.ContextCompat import androidx.core.content.FileProvider +import androidx.core.net.toUri import com.google.android.material.snackbar.Snackbar import kr.lunaticbum.awesomewebview.databinding.AwesomeWebViewBinding import kr.lunaticbum.awesomewebview.enums.Position @@ -81,6 +83,7 @@ import kr.lunaticbum.utils.log.LogUtil import kr.lunaticbum.utils.service.ClipboardManagerUtil import kr.lunaticbum.utils.ui.DisplayUtil import kr.lunaticbum.utils.ui.ViewUtil +import java.io.ByteArrayInputStream import java.io.File import java.io.IOException import java.text.SimpleDateFormat @@ -149,6 +152,8 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, protected var menuTextPaddingLeft: Float = 0f protected var menuTextPaddingRight: Float = 0f + protected var showMenuPdf: Boolean = false + protected var stringResPdf: Int = 0 protected var showMenuRefresh: Boolean = false protected var stringResRefresh: Int = 0 protected var showMenuFind: Boolean = false @@ -416,6 +421,11 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, showMenuRefresh = if (builder?.showMenuRefresh != null) builder?.showMenuRefresh!! else true stringResRefresh = if (builder?.stringResRefresh != null) builder?.stringResRefresh!! else R.string.refresh + + showMenuPdf = if (builder?.showMenuPdf != null) builder?.showMenuPdf!! else true + stringResPdf = + if (builder?.stringResPdf != null) builder?.stringResPdf!! else R.string.save_pdf + showMenuFind = if (builder?.showMenuFind != null) builder?.showMenuFind!! else false stringResFind = if (builder?.stringResFind != null) builder?.stringResFind!! else R.string.find showMenuShareVia = if (builder?.showMenuShareVia != null) builder?.showMenuShareVia!! else true @@ -715,7 +725,8 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, binding.toolbarContent.close.visibility = if (showIconClose) View.VISIBLE else View.GONE binding.toolbarContent.close.isEnabled = !disableIconClose - if (((showMenuRefresh + if (((showMenuPdf + ||showMenuRefresh || showMenuFind || showMenuShareVia || showMenuCopyLink @@ -1076,6 +1087,20 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, params.addRule(if (rtl) RelativeLayout.ALIGN_PARENT_LEFT else RelativeLayout.ALIGN_PARENT_RIGHT) binding.menus.shadowLayout.layoutParams = params + binding.menus.menuPdf.visibility = if (showMenuPdf) View.VISIBLE else View.GONE + binding.menus.menuPdf.setBackgroundResource(menuSelector) + binding.menus.menuPdf.gravity = menuTextGravity + binding.menus.menuPdfTv.setText(stringResPdf) + binding.menus.menuPdfTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, menuTextSize) + binding.menus.menuPdfTv.setTypeface(TypefaceHelper.get(this, menuTextFont)) + binding.menus.menuPdfTv.setTextColor(menuTextColor) + binding.menus.menuPdfTv.setPadding( + menuTextPaddingLeft.toInt(), + 0, + menuTextPaddingRight.toInt(), + 0 + ) + binding.menus.menuRefresh.visibility = if (showMenuRefresh) View.VISIBLE else View.GONE binding.menus.menuRefresh.setBackgroundResource(menuSelector) binding.menus.menuRefresh.gravity = menuTextGravity @@ -1090,6 +1115,7 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, 0 ) + binding.menus.menuFind.visibility = if (showMenuFind) View.VISIBLE else View.GONE binding.menus.menuFind.setBackgroundResource(menuSelector) binding.menus.menuFind.gravity = menuTextGravity @@ -1145,7 +1171,11 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, customMenuLayout.findViewById(R.id.customMenu) customMenuLayout.setBackgroundResource(menuSelector) customMenuLayout.gravity = menuTextGravity - customMenuTv.setText(customMenu.titleRes) + if (customMenu.titleRes > -1) { + customMenuTv.setText(customMenu.titleRes) + } else { + customMenuTv.setText(customMenu.title) + } customMenuTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, menuTextSize) customMenuTv.setTypeface(TypefaceHelper.get(this, menuTextFont)) customMenuTv.setTextColor(menuTextColor) @@ -1320,9 +1350,11 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, load() } - @SuppressLint("MissingSuperCall") - override fun onBackPressed() { + + + override fun onBackPressed() { +LogUtil.e("onBackPressed ${webChromeClient} && ${binding.menus.menuLayout.visibility}") if (webChromeClient is MyWebChromeClient && (webChromeClient as MyWebChromeClient).onBackPressed()) { return } @@ -1366,7 +1398,10 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, } else if (viewId == R.id.menuRefresh) { webView!!.reload() hideMenu() - } else if (viewId == R.id.menuFind) { + } else if (viewId == R.id.menuPdf) { +// PDFPrint + hideMenu() + } else if (viewId == R.id.menuFind) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) webView!!.showFindDialog( "", true @@ -1764,19 +1799,27 @@ class AwesomeWebViewActivity : AppCompatActivity(), View.OnClickListener, } inner class MyWebViewClient : WebViewClient() { - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) override fun shouldInterceptRequest( view: WebView, request: WebResourceRequest ): WebResourceResponse? { LogUtil.e("shouldInterceptRequest request >>> ${request.url.toString()}") + if (request.url.toString().contains("gif")) { + return WebResourceResponse( + "text/plain", "utf-8", + ByteArrayInputStream("".toByteArray()) + ) + } return super.shouldInterceptRequest(view, request) } - override fun shouldInterceptRequest(view: WebView, url: String): WebResourceResponse? { - LogUtil.e("shouldInterceptRequest String >>> $url") - return super.shouldInterceptRequest(view, url) - } +// override fun shouldInterceptRequest(view: WebView, url: String): WebResourceResponse? { +// LogUtil.e("shouldInterceptRequest String >>> $url") +// if (url.contains("gif")) { +// return null +// } +// return super.shouldInterceptRequest(view, url) +// } override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { BroadCastManager.onPageStarted(this@AwesomeWebViewActivity, key, url) diff --git a/library/src/main/java/kr/lunaticbum/awesomewebview/jsInterface/CommonJsHelper.java b/library/src/main/java/kr/lunaticbum/awesomewebview/jsInterface/CommonJsHelper.java index 311c71a3..02d981ef 100644 --- a/library/src/main/java/kr/lunaticbum/awesomewebview/jsInterface/CommonJsHelper.java +++ b/library/src/main/java/kr/lunaticbum/awesomewebview/jsInterface/CommonJsHelper.java @@ -1,5 +1,6 @@ package kr.lunaticbum.awesomewebview.jsInterface; +import android.annotation.SuppressLint; import android.text.TextUtils; import android.util.Pair; import android.webkit.WebView; @@ -44,6 +45,7 @@ public class CommonJsHelper { * do not call, only for internal * @param webView */ + @SuppressLint("JavascriptInterface") public void addJavascriptInterface(WebView webView) { for (Pair, String> pair: interfacesInternal) { if (pair == null || pair.first == null || TextUtils.isEmpty(pair.second)) { diff --git a/library/src/main/java/kr/lunaticbum/awesomewebview/objects/CustomMenu.java b/library/src/main/java/kr/lunaticbum/awesomewebview/objects/CustomMenu.java index 233d40a9..7de36310 100644 --- a/library/src/main/java/kr/lunaticbum/awesomewebview/objects/CustomMenu.java +++ b/library/src/main/java/kr/lunaticbum/awesomewebview/objects/CustomMenu.java @@ -5,18 +5,23 @@ import androidx.annotation.StringRes; import java.io.Serializable; public class CustomMenu implements Serializable { - private int titleRes; + private int titleRes = -1; private String code; - + private String titleString; public CustomMenu(@StringRes int titleRes, String code) { this.titleRes = titleRes; this.code = code; } - + public CustomMenu( String titleString, String code) { + this.titleString = titleString; + this.code = code; + } public int getTitleRes() { return titleRes; } - + public String getTitle() { + return titleString; + } public String getCode() { return code; } diff --git a/library/src/main/res/layout/menus.xml b/library/src/main/res/layout/menus.xml index 76df10f4..8922a445 100644 --- a/library/src/main/res/layout/menus.xml +++ b/library/src/main/res/layout/menus.xml @@ -144,7 +144,27 @@ android:textColor="@color/finestBlack" android:textSize="@dimen/defaultMenuTextSize" /> + + + diff --git a/library/src/main/res/values-ko/strings.xml b/library/src/main/res/values-ko/strings.xml index 21299d57..0ab7a2fd 100644 --- a/library/src/main/res/values-ko/strings.xml +++ b/library/src/main/res/values-ko/strings.xml @@ -6,4 +6,5 @@ 주소 복사하기 다른 앱으로 열기 주소가 복사 되었습니다 + Save Pdf \ No newline at end of file diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml index 0fd3b64a..06bcbbd5 100644 --- a/library/src/main/res/values/strings.xml +++ b/library/src/main/res/values/strings.xml @@ -11,4 +11,5 @@ File Chooser Copied to clipboard Loading video… + Save Pdf \ No newline at end of file diff --git a/utils/build.gradle.kts b/utils/build.gradle.kts index 9f7fdfef..9ec53e4d 100644 --- a/utils/build.gradle.kts +++ b/utils/build.gradle.kts @@ -5,10 +5,10 @@ plugins { android { namespace = "kr.lunaticbum.helpers" - compileSdk = 34 + compileSdk = 35 defaultConfig { minSdk = 26 - targetSdk = 34 +// targetSdk = 34 } buildFeatures { @@ -30,5 +30,5 @@ dependencies { implementation ("com.android.support:appcompat-v7:28.0.0") implementation ("com.android.support:support-annotations:28.0.0") implementation ("androidx.annotation:annotation-jvm:1.9.1") - implementation ("androidx.core:core-ktx:1.13.1") + implementation ("androidx.core:core-ktx:1.15.0") } \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/Base.java b/utils/src/main/java/kr/lunaticbum/Base.java deleted file mode 100644 index 3b44b6cf..00000000 --- a/utils/src/main/java/kr/lunaticbum/Base.java +++ /dev/null @@ -1,57 +0,0 @@ -//package kr.lunaticbum; -// -//import android.content.Context; -//import android.content.res.AssetManager; -//import android.content.res.Configuration; -//import android.content.res.Resources; -//import android.util.DisplayMetrics; -// -//import androidx.annotation.NonNull; -// -///** -// * Base helps to get {@link Context}, {@link Resources}, {@link AssetManager}, {@link Configuration} and {@link DisplayMetrics} in any class. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class Base { -// -// private static Context context; -// -// public static void initialize(@NonNull Context context) { -// Base.context = context; -// } -// -// public static Context getContext() { -// synchronized (Base.class) { -// if (Base.context == null) -// throw new NullPointerException("Call Base.initialize(context) within your Application onCreate() method."); -// -// return Base.context.getApplicationContext(); -// } -// } -// -// public static Resources getResources() { -// return Base.getContext().getResources(); -// } -// -// public static Resources.Theme getTheme() { -// return Base.getContext().getTheme(); -// } -// -// public static AssetManager getAssets() { -// return Base.getContext().getAssets(); -// } -// -// public static Configuration getConfiguration() { -// return Base.getResources().getConfiguration(); -// } -// -// public static DisplayMetrics getDisplayMetrics() { -// return Base.getResources().getDisplayMetrics(); -// } -//} -//// TODO: Thread safety -//// TODO: ripple, bitmap, time, contact list, picture list, video list, connectivity, wake lock, screen lock/off/on, get attributes, cookie, audio -//// TODO: keystore -//// TODO: http://jo.centis1504.net/?p=1189 -//// TODO: Test codes \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/builders/ActivityBuilder.java b/utils/src/main/java/kr/lunaticbum/builders/ActivityBuilder.java deleted file mode 100644 index e62db2a5..00000000 --- a/utils/src/main/java/kr/lunaticbum/builders/ActivityBuilder.java +++ /dev/null @@ -1,82 +0,0 @@ -//package kr.lunaticbum.builders; -// -//import android.annotation.TargetApi; -//import android.app.Activity; -//import android.content.Intent; -//import android.os.Bundle; -//import android.os.Parcelable; -// -//import androidx.annotation.NonNull; -//import androidx.annotation.Nullable; -// -//import kr.lunaticbum.Base; -//import kr.lunaticbum.utils.content.ContextUtil; -// -//import java.io.Serializable; -//import java.util.ArrayList; -// -///** -// * ActivityBuilder helps to build {@link Activity} {@link Intent} and start {@link Activity}. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class ActivityBuilder { -// -// final Intent intent; -// -// public ActivityBuilder(@NonNull Class clazz) { -// intent = new Intent(Base.getContext(), clazz); -// } -// -// public ActivityBuilder set(@NonNull String key, T value) { -// intent.putExtra(key, value); -// return this; -// } -// -// public ActivityBuilder set(@NonNull String key, Parcelable value) { -// intent.putExtra(key, value); -// return this; -// } -// -// public ActivityBuilder set(@NonNull String key, Parcelable[] value) { -// intent.putExtra(key, value); -// return this; -// } -// -// public ActivityBuilder set(@NonNull String key, ArrayList value) { -// intent.putExtra(key, value); -// return this; -// } -// -// public ActivityBuilder remove(@NonNull String key) { -// intent.removeExtra(key); -// return this; -// } -// -// public ActivityBuilder setFlags(int flags) { -// intent.setFlags(flags); -// return this; -// } -// -// public ActivityBuilder addFlags(int flags) { -// intent.addFlags(flags); -// return this; -// } -// -// public Intent buildIntent() { -// return intent; -// } -// -// public void start() { -// ContextUtil.startActivity(intent); -// } -// -// public void startForResult(@NonNull Activity activity, int requestCode) { -// activity.startActivityForResult(intent, requestCode); -// } -// -// @TargetApi(16) -// public void startForResult(@NonNull Activity activity, int requestCode, @Nullable Bundle options) { -// activity.startActivityForResult(intent, requestCode, options); -// } -//} diff --git a/utils/src/main/java/kr/lunaticbum/converters/UnitConverter.java b/utils/src/main/java/kr/lunaticbum/converters/UnitConverter.java deleted file mode 100644 index 71c282a3..00000000 --- a/utils/src/main/java/kr/lunaticbum/converters/UnitConverter.java +++ /dev/null @@ -1,43 +0,0 @@ -//package kr.lunaticbum.converters; -// -//import kr.lunaticbum.Base; -// -///** -// * UnitConverter helps to convert dp or sp size into pixel. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class UnitConverter { -// -// public static float dpToPx(float dp) { -// return dp * Base.getDisplayMetrics().density; -// } -// -// public static int dpToPx(int dp) { -// return (int) (dp * Base.getDisplayMetrics().density + 0.5f); -// } -// -// public static float pxToDp(float px) { -// return px / Base.getDisplayMetrics().density; -// } -// -// public static int pxToDp(int px) { -// return (int) (px / Base.getDisplayMetrics().density + 0.5f); -// } -// -// public static float spToPx(float sp) { -// return sp * Base.getDisplayMetrics().scaledDensity; -// } -// -// public static int spToPx(int sp) { -// return (int) (sp * Base.getDisplayMetrics().scaledDensity + 0.5f); -// } -// -// public static float pxToSp(float px) { -// return px / Base.getDisplayMetrics().scaledDensity; -// } -// -// public static int pxToSp(int px) { -// return (int) (px / Base.getDisplayMetrics().scaledDensity + 0.5f); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/content/ContextUtil.java b/utils/src/main/java/kr/lunaticbum/utils/content/ContextUtil.java deleted file mode 100644 index 7c99a2c2..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/content/ContextUtil.java +++ /dev/null @@ -1,502 +0,0 @@ -//package kr.lunaticbum.utils.content; -// -//import android.annotation.SuppressLint; -//import android.annotation.TargetApi; -//import android.app.WallpaperManager; -//import android.content.BroadcastReceiver; -//import android.content.ComponentCallbacks; -//import android.content.ComponentName; -//import android.content.ContentResolver; -//import android.content.Context; -//import android.content.Intent; -//import android.content.IntentFilter; -//import android.content.IntentSender; -//import android.content.ServiceConnection; -//import android.content.SharedPreferences; -//import android.content.pm.ApplicationInfo; -//import android.content.pm.PackageManager; -//import android.content.res.AssetManager; -//import android.content.res.ColorStateList; -//import android.content.res.Resources; -//import android.content.res.TypedArray; -//import android.database.DatabaseErrorHandler; -//import android.database.sqlite.SQLiteDatabase; -//import android.graphics.Bitmap; -//import android.graphics.drawable.Drawable; -//import android.net.Uri; -//import android.os.Bundle; -//import android.os.Handler; -//import android.os.Looper; -//import android.os.UserHandle; -//import android.util.AttributeSet; -// -//import androidx.annotation.AttrRes; -//import androidx.annotation.ColorInt; -//import androidx.annotation.ColorRes; -//import androidx.annotation.DrawableRes; -//import androidx.annotation.NonNull; -//import androidx.annotation.Nullable; -//import androidx.annotation.StringRes; -//import androidx.annotation.StyleRes; -//import androidx.annotation.StyleableRes; -//import androidx.core.content.ContextCompat; -// -//import kr.lunaticbum.Base; -// -//import java.io.File; -//import java.io.FileInputStream; -//import java.io.FileNotFoundException; -//import java.io.FileOutputStream; -//import java.io.IOException; -//import java.io.InputStream; -// -///** -// * ContextUtil helps to manage {@link Context} conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class ContextUtil { -// -// public static boolean bindService(Intent service, ServiceConnection conn, int flags) { -// return Base.getContext().bindService(service, conn, flags); -// } -// -// public static int checkCallingOrSelfPermission(String permission) { -// return Base.getContext().checkCallingOrSelfPermission(permission); -// } -// -// public static int checkCallingOrSelfUriPermission(Uri uri, int modeFlags) { -// return Base.getContext().checkCallingOrSelfUriPermission(uri, modeFlags); -// } -// -// public static int checkCallingPermission(String permission) { -// return Base.getContext().checkCallingPermission(permission); -// } -// -// public static int checkCallingUriPermission(Uri uri, int modeFlags) { -// return Base.getContext().checkCallingUriPermission(uri, modeFlags); -// } -// -// public static int checkPermission(String permission, int pid, int uid) { -// return Base.getContext().checkPermission(permission, pid, uid); -// } -// -// public static int checkSelfPermission(@NonNull String permission) { -// return ContextCompat.checkSelfPermission(Base.getContext(), permission); -// } -// -// public static int checkUriPermission(Uri uri, int pid, int uid, int modeFlags) { -// return Base.getContext().checkUriPermission(uri, pid, uid, modeFlags); -// } -// -// public static int checkUriPermission(Uri uri, String readPermission, String writePermission, int pid, int uid, int modeFlags) { -// return Base.getContext().checkUriPermission(uri, readPermission, writePermission, pid, uid, modeFlags); -// } -// -// public static Context createPackageContext(String packageName, int flags) throws PackageManager.NameNotFoundException { -// return Base.getContext().createPackageContext(packageName, flags); -// } -// -// public static String[] databaseList() { -// return Base.getContext().databaseList(); -// } -// -// public static boolean deleteDatabase(String name) { -// return Base.getContext().deleteDatabase(name); -// } -// -// public static boolean deleteFile(String name) { -// return Base.getContext().deleteFile(name); -// } -// -// public static void enforceCallingOrSelfPermission(String permission, String message) { -// Base.getContext().enforceCallingOrSelfPermission(permission, message); -// } -// -// public static void enforceCallingOrSelfUriPermission(Uri uri, int modeFlags, String message) { -// Base.getContext().enforceCallingOrSelfUriPermission(uri, modeFlags, message); -// } -// -// public static void enforceCallingPermission(String permission, String message) { -// Base.getContext().enforceCallingPermission(permission, message); -// } -// -// public static void enforceCallingUriPermission(Uri uri, int modeFlags, String message) { -// Base.getContext().enforceCallingUriPermission(uri, modeFlags, message); -// } -// -// public static void enforcePermission(String permission, int pid, int uid, String message) { -// Base.getContext().enforcePermission(permission, pid, uid, message); -// } -// -// public static void enforceUriPermission(Uri uri, int pid, int uid, int modeFlags, String message) { -// Base.getContext().enforceUriPermission(uri, pid, uid, modeFlags, message); -// } -// -// public static void enforceUriPermission(Uri uri, String readPermission, String writePermission, int pid, int uid, int modeFlags, String message) { -// Base.getContext().enforceUriPermission(uri, readPermission, writePermission, pid, uid, modeFlags, message); -// } -// -// public static String[] fileList() { -// return Base.getContext().fileList(); -// } -// -// public static Context getApplicationContext() { -// return Base.getContext().getApplicationContext(); -// } -// -// public static ApplicationInfo getApplicationInfo() { -// return Base.getContext().getApplicationInfo(); -// } -// -// public static AssetManager getAssets() { -// return Base.getContext().getAssets(); -// } -// -// public static File getCacheDir() { -// return Base.getContext().getCacheDir(); -// } -// -// public static ClassLoader getClassLoader() { -// return Base.getContext().getClassLoader(); -// } -// -// public static File getCodeCacheDir() { -// return ContextCompat.getCodeCacheDir(Base.getContext()); -// } -// -// @ColorInt -// public static int getColor(@ColorRes int colorRes) { -// return ContextCompat.getColor(Base.getContext(), colorRes); -// } -// -// public static ColorStateList getColorStateList(@ColorRes int colorRes) { -// return ContextCompat.getColorStateList(Base.getContext(), colorRes); -// } -// -// public static ContentResolver getContentResolver() { -// return Base.getContext().getContentResolver(); -// } -// -// public static File getDatabasePath(String name) { -// return Base.getContext().getDatabasePath(name); -// } -// -// public static File getDir(String name, int mode) { -// return Base.getContext().getDir(name, mode); -// } -// -// public static Drawable getDrawable(@DrawableRes int drawableRes) { -// return ContextCompat.getDrawable(Base.getContext(), drawableRes); -// } -// -// @Nullable -// @TargetApi(8) -// public static File getExternalCacheDir() { -// return Base.getContext().getExternalCacheDir(); -// } -// -// public static File[] getExternalCacheDirs() { -// return ContextCompat.getExternalCacheDirs(Base.getContext()); -// } -// -// @Nullable -// @TargetApi(8) -// public static File getExternalFilesDir(String type) { -// return Base.getContext().getExternalFilesDir(type); -// } -// -// public static File[] getExternalFilesDirs(String type) { -// return ContextCompat.getExternalFilesDirs(Base.getContext(), type); -// } -// -// @TargetApi(21) -// public static File[] getExternalMediaDirs() { -// return Base.getContext().getExternalMediaDirs(); -// } -// -// public static File getFileStreamPath(String name) { -// return Base.getContext().getFileStreamPath(name); -// } -// -// public static File getFilesDir() { -// return Base.getContext().getFilesDir(); -// } -// -// public static Looper getMainLooper() { -// return Base.getContext().getMainLooper(); -// } -// -// public static File getNoBackupFilesDir() { -// return ContextCompat.getNoBackupFilesDir(Base.getContext()); -// } -// -// @TargetApi(11) -// public static File getObbDir() { -// return Base.getContext().getObbDir(); -// } -// -// public static File[] getObbDirs() { -// return ContextCompat.getObbDirs(Base.getContext()); -// } -// -// @TargetApi(8) -// public static String getPackageCodePath() { -// return Base.getContext().getPackageCodePath(); -// } -// -// public static PackageManager getPackageManager() { -// return Base.getContext().getPackageManager(); -// } -// -// public static String getPackageName() { -// return Base.getContext().getPackageName(); -// } -// -// @TargetApi(8) -// public static String getPackageResourcePath() { -// return Base.getContext().getPackageResourcePath(); -// } -// -// public static Resources getResources() { -// return Base.getContext().getResources(); -// } -// -// public static SharedPreferences getSharedPreferences(String name, int mode) { -// return Base.getContext().getSharedPreferences(name, mode); -// } -// -// public static String getString(@StringRes int stringRes) { -// return Base.getContext().getString(stringRes); -// } -// -// public static String getString(@StringRes int stringRes, Object... formatArgs) { -// return Base.getContext().getString(stringRes, formatArgs); -// } -// -// @TargetApi(23) -// public static T getSystemService(Class serviceClass) { -// return Base.getContext().getSystemService(serviceClass); -// } -// -// public static Object getSystemService(String name) { -// return Base.getContext().getSystemService(name); -// } -// -// @TargetApi(23) -// public static String getSystemServiceName(Class serviceClass) { -// return Base.getContext().getSystemServiceName(serviceClass); -// } -// -// public static CharSequence getText(@StringRes int stringRes) { -// return Base.getContext().getText(stringRes); -// } -// -// public static Resources.Theme getTheme() { -// return Base.getContext().getTheme(); -// } -// -// public static Drawable getWallpaper() { -// return WallpaperManager.getInstance(Base.getContext()).getDrawable(); -// } -// -// public static int getWallpaperDesiredMinimumHeight() { -// return WallpaperManager.getInstance(Base.getContext()).getDesiredMinimumHeight(); -// } -// -// public static int getWallpaperDesiredMinimumWidth() { -// return WallpaperManager.getInstance(Base.getContext()).getDesiredMinimumWidth(); -// } -// -// public static void grantUriPermission(String toPackage, Uri uri, int modeFlags) { -// Base.getContext().grantUriPermission(toPackage, uri, modeFlags); -// } -// -// public static boolean isRestricted() { -// return Base.getContext().isRestricted(); -// } -// -// public static TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) { -// return Base.getContext().obtainStyledAttributes(attrs); -// } -// -// public static TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { -// return Base.getContext().obtainStyledAttributes(set, attrs, defStyleAttr, defStyleRes); -// } -// -// public static TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs) { -// return Base.getContext().obtainStyledAttributes(set, attrs); -// } -// -// public static TypedArray obtainStyledAttributes(@StyleRes int resid, @StyleableRes int[] attrs) { -// return Base.getContext().obtainStyledAttributes(resid, attrs); -// } -// -// public static FileInputStream openFileInput(String name) throws FileNotFoundException { -// return Base.getContext().openFileInput(name); -// } -// -// public static FileOutputStream openFileOutput(String name, int mode) throws FileNotFoundException { -// return Base.getContext().openFileOutput(name, mode); -// } -// -// public static SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory) { -// return Base.getContext().openOrCreateDatabase(name, mode, factory); -// } -// -// @TargetApi(11) -// public static SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler) { -// return Base.getContext().openOrCreateDatabase(name, mode, factory, errorHandler); -// } -// -// public static Drawable peekWallpaper() { -// return WallpaperManager.getInstance(Base.getContext()).peekDrawable(); -// } -// -// @TargetApi(14) -// public static void registerComponentCallbacks(ComponentCallbacks callback) { -// Base.getContext().registerComponentCallbacks(callback); -// } -// -// public static Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) { -// return Base.getContext().registerReceiver(receiver, filter); -// } -// -// public static Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler) { -// return Base.getContext().registerReceiver(receiver, filter, broadcastPermission, scheduler); -// } -// -//// public static void removeStickyBroadcast(Intent intent) { -//// Base.getContext().removeStickyBroadcast(intent); -//// } -//// -//// @TargetApi(17) -//// public static void removeStickyBroadcastAsUser(Intent intent, UserHandle user) { -//// Base.getContext().removeStickyBroadcastAsUser(intent, user); -//// } -// -// public static void revokeUriPermission(Uri uri, int modeFlags) { -// Base.getContext().revokeUriPermission(uri, modeFlags); -// } -// -// public static void sendBroadcast(Intent intent, String receiverPermission) { -// Base.getContext().sendBroadcast(intent, receiverPermission); -// } -// -// public static void sendBroadcast(Intent intent) { -// Base.getContext().sendBroadcast(intent); -// } -// -// @TargetApi(17) -// public static void sendBroadcastAsUser(Intent intent, UserHandle user) { -// Base.getContext().sendBroadcastAsUser(intent, user); -// } -// -// @TargetApi(17) -// public static void sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission) { -// Base.getContext().sendBroadcastAsUser(intent, user, receiverPermission); -// } -// -// public static void sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras) { -// Base.getContext().sendOrderedBroadcast(intent, receiverPermission, resultReceiver, scheduler, initialCode, initialData, initialExtras); -// } -// -// public static void sendOrderedBroadcast(Intent intent, String receiverPermission) { -// Base.getContext().sendOrderedBroadcast(intent, receiverPermission); -// } -// -// @TargetApi(17) -// public static void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras) { -// Base.getContext().sendOrderedBroadcastAsUser(intent, user, receiverPermission, resultReceiver, scheduler, initialCode, initialData, initialExtras); -// } -// -//// public static void sendStickyBroadcast(Intent intent) { -//// Base.getContext().sendStickyBroadcast(intent); -//// } -//// -//// @TargetApi(17) -//// public static void sendStickyBroadcastAsUser(Intent intent, UserHandle user) { -//// Base.getContext().sendStickyBroadcastAsUser(intent, user); -//// } -//// -//// public static void sendStickyOrderedBroadcast(Intent intent, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras) { -//// Base.getContext().sendStickyOrderedBroadcast(intent, resultReceiver, scheduler, initialCode, initialData, initialExtras); -//// } -//// -//// @TargetApi(17) -//// public static void sendStickyOrderedBroadcastAsUser(Intent intent, UserHandle user, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras) { -//// Base.getContext().sendStickyOrderedBroadcastAsUser(intent, user, resultReceiver, scheduler, initialCode, initialData, initialExtras); -//// } -// -// public static void setTheme(@StyleRes int styleRes) { -// Base.getContext().setTheme(styleRes); -// } -// -// @SuppressLint("MissingPermission") -// public static void setWallpaper(InputStream data) throws IOException { -// WallpaperManager.getInstance(Base.getContext()).setStream(data); -// } -// -// @SuppressLint("MissingPermission") -// public static void setWallpaper(Bitmap bitmap) throws IOException { -// WallpaperManager.getInstance(Base.getContext()).setBitmap(bitmap); -// } -// -// public static boolean startActivities(Intent[] intents, Bundle options) { -// for (Intent intent : intents) -// if (intent != null) -// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); -// return ContextCompat.startActivities(Base.getContext(), intents, options); -// } -// -// public static boolean startActivities(Intent[] intents) { -// for (Intent intent : intents) -// if (intent != null) -// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); -// return ContextCompat.startActivities(Base.getContext(), intents); -// } -// -// public static void startActivity(@NonNull Intent intent) { -// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); -// Base.getContext().startActivity(intent); -// } -// -// @TargetApi(16) -// public static void startActivity(Intent intent, Bundle options) { -// Base.getContext().startActivity(intent, options); -// } -// -// public static boolean startInstrumentation(ComponentName className, String profileFile, Bundle arguments) { -// return Base.getContext().startInstrumentation(className, profileFile, arguments); -// } -// -// @TargetApi(16) -// public static void startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options) throws IntentSender.SendIntentException { -// Base.getContext().startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags, options); -// } -// -// public static void startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags) throws IntentSender.SendIntentException { -// Base.getContext().startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags); -// } -// -// public static ComponentName startService(Intent service) { -// return Base.getContext().startService(service); -// } -// -// public static boolean stopService(Intent service) { -// return Base.getContext().stopService(service); -// } -// -// public static void unbindService(ServiceConnection conn) { -// Base.getContext().unbindService(conn); -// } -// -// @TargetApi(14) -// public static void unregisterComponentCallbacks(ComponentCallbacks callback) { -// Base.getContext().unregisterComponentCallbacks(callback); -// } -// -// public static void unregisterReceiver(BroadcastReceiver receiver) { -// Base.getContext().unregisterReceiver(receiver); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/content/Res.java b/utils/src/main/java/kr/lunaticbum/utils/content/Res.java deleted file mode 100644 index ada10618..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/content/Res.java +++ /dev/null @@ -1,9 +0,0 @@ -//package kr.lunaticbum.utils.content; -// -///** -// * Res is abbreviation class of {@link ResourcesUtil}. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class Res extends ResourcesUtil { -//} diff --git a/utils/src/main/java/kr/lunaticbum/utils/content/ResourcesUtil.java b/utils/src/main/java/kr/lunaticbum/utils/content/ResourcesUtil.java deleted file mode 100644 index 05d991ba..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/content/ResourcesUtil.java +++ /dev/null @@ -1,278 +0,0 @@ -//package kr.lunaticbum.utils.content; -// -//import android.content.res.AssetFileDescriptor; -//import android.content.res.AssetManager; -//import android.content.res.ColorStateList; -//import android.content.res.Configuration; -//import android.content.res.Resources; -//import android.content.res.TypedArray; -//import android.content.res.XmlResourceParser; -//import android.graphics.Movie; -//import android.graphics.drawable.Drawable; -//import android.os.Bundle; -//import android.util.AttributeSet; -//import android.util.DisplayMetrics; -//import android.util.TypedValue; -// -//import androidx.annotation.AnimRes; -//import androidx.annotation.AnyRes; -//import androidx.annotation.ArrayRes; -//import androidx.annotation.BoolRes; -//import androidx.annotation.ColorInt; -//import androidx.annotation.ColorRes; -//import androidx.annotation.DimenRes; -//import androidx.annotation.DrawableRes; -//import androidx.annotation.IntegerRes; -//import androidx.annotation.LayoutRes; -//import androidx.annotation.PluralsRes; -//import androidx.annotation.RawRes; -//import androidx.annotation.StringRes; -//import androidx.annotation.XmlRes; -// -//import kr.lunaticbum.Base; -//import kr.lunaticbum.utils.etc.APILevel; -// -//import org.xmlpull.v1.XmlPullParserException; -// -//import java.io.IOException; -//import java.io.InputStream; -// -///** -// * ResourcesUtil helps to manage {@link Resources} conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class ResourcesUtil { -// -// private static void finishPreloading() { -// Base.getResources().finishPreloading(); -// } -// -// private static void flushLayoutCache() { -// Base.getResources().flushLayoutCache(); -// } -// -// public static XmlResourceParser getAnimation(@AnimRes int animRes) { -// return Base.getResources().getAnimation(animRes); -// } -// -// public static AssetManager getAssets() { -// return Base.getResources().getAssets(); -// } -// -// public static boolean getBoolean(@BoolRes int boolRes) { -// return Base.getResources().getBoolean(boolRes); -// } -// -// @ColorInt -// public static int getColor(@ColorRes int colorRes) { -// return ContextUtil.getColor(colorRes); -// } -// -// @ColorInt -// public static int getColor(@ColorRes int colorRes, Resources.Theme theme) { -// if (APILevel.require(23)) -// return Base.getResources().getColor(colorRes, theme); -// else -// return getColor(colorRes); -// } -// -// public static ColorStateList getColorStateList(@ColorRes int colorRes) { -// return ContextUtil.getColorStateList(colorRes); -// } -// -// public static ColorStateList getColorStateList(@ColorRes int colorRes, Resources.Theme theme) { -// if (APILevel.require(23)) -// return Base.getResources().getColorStateList(colorRes, theme); -// else -// return getColorStateList(colorRes); -// } -// -// public static Configuration getConfiguration() { -// return Base.getConfiguration(); -// } -// -// public static float getDimension(@DimenRes int dimenRes) { -// return Base.getResources().getDimension(dimenRes); -// } -// -// public static int getDimensionPixelOffset(@DimenRes int dimenRes) { -// return Base.getResources().getDimensionPixelOffset(dimenRes); -// } -// -// public static int getDimensionPixelSize(@DimenRes int dimenRes) { -// return Base.getResources().getDimensionPixelSize(dimenRes); -// } -// -// public static DisplayMetrics getDisplayMetrics() { -// return Base.getDisplayMetrics(); -// } -// -// public static Drawable getDrawable(@DrawableRes int drawableRes) { -// return ContextUtil.getDrawable(drawableRes); -// } -// -// public static Drawable getDrawable(@DrawableRes int drawableRes, Resources.Theme theme) { -// if (APILevel.require(21)) -// return Base.getResources().getDrawable(drawableRes, theme); -// else -// return Base.getResources().getDrawable(drawableRes); -// } -// -// public static Drawable getDrawableForDensity(@DrawableRes int drawableRes, int density) { -// if (APILevel.require(21)) -// return Base.getResources().getDrawableForDensity(drawableRes, density, Base.getContext().getTheme()); -// else if (APILevel.require(15)) -// return Base.getResources().getDrawableForDensity(drawableRes, density); -// else -// return Base.getResources().getDrawable(drawableRes); -// } -// -// public static float getFraction(int id, int base, int pbase) { -// return Base.getResources().getFraction(id, base, pbase); -// } -// -// public static int getIdentifier(String name, String defType, String defPackage) { -// return Base.getResources().getIdentifier(name, defType, defPackage); -// } -// -// public static int[] getIntArray(@ArrayRes int arrayRes) { -// return Base.getResources().getIntArray(arrayRes); -// } -// -// public static int getInteger(@IntegerRes int integerRes) { -// return Base.getResources().getInteger(integerRes); -// } -// -// public static XmlResourceParser getLayout(@LayoutRes int layoutRes) { -// return Base.getResources().getLayout(layoutRes); -// } -// -// public static Movie getMovie(@RawRes int rawRes) { -// return Base.getResources().getMovie(rawRes); -// } -// -// public static String getQuantityString(int id, int quantity, Object... formatArgs) { -// return Base.getResources().getQuantityString(id, quantity, formatArgs); -// } -// -// public static String getQuantityString(@PluralsRes int pluralsRes, int quantity) throws Resources.NotFoundException { -// return Base.getResources().getQuantityString(pluralsRes, quantity); -// } -// -// public static CharSequence getQuantityText(int id, int quantity) { -// return Base.getResources().getQuantityText(id, quantity); -// } -// -// public static String getResourceEntryName(@AnyRes int anyRes) { -// return Base.getResources().getResourceEntryName(anyRes); -// } -// -// public static String getResourceName(@AnyRes int anyRes) { -// return Base.getResources().getResourceName(anyRes); -// } -// -// public static String getResourcePackageName(@AnyRes int anyRes) { -// return Base.getResources().getResourcePackageName(anyRes); -// } -// -// public static String getResourceTypeName(@AnyRes int anyRes) { -// return Base.getResources().getResourceTypeName(anyRes); -// } -// -// public static String getString(@StringRes int stringRes) { -// return Base.getResources().getString(stringRes); -// } -// -// public static String getString(@StringRes int stringRes, Object... formatArgs) { -// return Base.getResources().getString(stringRes, formatArgs); -// } -// -// public static String[] getStringArray(@ArrayRes int arrayRes) { -// return Base.getResources().getStringArray(arrayRes); -// } -// -// public static Resources getSystem() { -// return Base.getResources().getSystem(); -// } -// -// public static CharSequence getText(@StringRes int stringRes, CharSequence def) { -// return Base.getResources().getText(stringRes, def); -// } -// -// public static CharSequence getText(@StringRes int stringRes) { -// return Base.getResources().getText(stringRes); -// } -// -// public static CharSequence[] getTextArray(@ArrayRes int arrayRes) { -// return Base.getResources().getTextArray(arrayRes); -// } -// -// public static void getValue(String name, TypedValue outValue, boolean resolveRefs) { -// Base.getResources().getValue(name, outValue, resolveRefs); -// } -// -// public static void getValue(@AnyRes int anyRes, TypedValue outValue, boolean resolveRefs) { -// Base.getResources().getValue(anyRes, outValue, resolveRefs); -// } -// -// public static void getValueForDensity(@AnyRes int anyRes, int density, TypedValue outValue, boolean resolveRefs) { -// if (APILevel.require(15)) -// Base.getResources().getValueForDensity(anyRes, density, outValue, resolveRefs); -// else -// Base.getResources().getValue(anyRes, outValue, resolveRefs); -// } -// -// public static XmlResourceParser getXml(@XmlRes int xmlRes) { -// return Base.getResources().getXml(xmlRes); -// } -// -// public static Resources.Theme newTheme() { -// return Base.getResources().newTheme(); -// } -// -// public static TypedArray obtainAttributes(AttributeSet set, int[] attrs) { -// return Base.getResources().obtainAttributes(set, attrs); -// } -// -// public static TypedArray obtainTypedArray(@ArrayRes int anyRes) { -// return Base.getResources().obtainTypedArray(anyRes); -// } -// -// public static InputStream openRawResource(@RawRes int rawRes) { -// return Base.getResources().openRawResource(rawRes); -// } -// -// public static InputStream openRawResource(@RawRes int rawRes, TypedValue value) { -// return Base.getResources().openRawResource(rawRes, value); -// } -// -// public static AssetFileDescriptor openRawResourceFd(@RawRes int rawRes) { -// return Base.getResources().openRawResourceFd(rawRes); -// } -// -// public static void parseBundleExtra(String tagName, AttributeSet attrs, Bundle outBundle) throws XmlPullParserException { -// Base.getResources().parseBundleExtra(tagName, attrs, outBundle); -// } -// -// public static void parseBundleExtras(XmlResourceParser parser, Bundle outBundle) throws XmlPullParserException, IOException { -// Base.getResources().parseBundleExtras(parser, outBundle); -// } -// -// public static void updateConfiguration(Configuration config, DisplayMetrics metrics) { -// Base.getResources().updateConfiguration(config, metrics); -// } -// -// // Added methods -// public static int[] getColorArray(@ArrayRes int array) { -// if (array == 0) -// return null; -// -// TypedArray typedArray = Base.getResources().obtainTypedArray(array); -// int[] colors = new int[typedArray.length()]; -// for (int i = 0; i < typedArray.length(); i++) -// colors[i] = typedArray.getColor(i, 0); -// typedArray.recycle(); -// return colors; -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/content/ThemeUtil.java b/utils/src/main/java/kr/lunaticbum/utils/content/ThemeUtil.java deleted file mode 100644 index 0d5f0f91..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/content/ThemeUtil.java +++ /dev/null @@ -1,64 +0,0 @@ -//package kr.lunaticbum.utils.content; -// -//import android.annotation.TargetApi; -//import android.content.res.Resources; -//import android.content.res.TypedArray; -//import android.graphics.drawable.Drawable; -//import android.util.AttributeSet; -//import android.util.TypedValue; -// -//import androidx.annotation.AttrRes; -//import androidx.annotation.DrawableRes; -//import androidx.annotation.StyleRes; -//import androidx.annotation.StyleableRes; -// -//import kr.lunaticbum.Base; -// -///** -// * ThemeUtil helps to manage {@link Resources.Theme} conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class ThemeUtil { -// -// public static void applyStyle(int resId, boolean force) { -// Base.getTheme().applyStyle(resId, force); -// } -// -// public static void dump(int priority, String tag, String prefix) { -// Base.getTheme().dump(priority, tag, prefix); -// } -// -// @TargetApi(23) -// public static int getChangingConfigurations() { -// return Base.getTheme().getChangingConfigurations(); -// } -// -// public static Drawable getDrawable(@DrawableRes int drawableRes) { -// return ResourcesUtil.getDrawable(drawableRes); -// } -// -// public static Resources getResources() { -// return Base.getResources(); -// } -// -// public static TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) { -// return Base.getTheme().obtainStyledAttributes(attrs); -// } -// -// public static TypedArray obtainStyledAttributes(@StyleRes int resid, @StyleableRes int[] attrs) { -// return Base.getTheme().obtainStyledAttributes(resid, attrs); -// } -// -// public static TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { -// return Base.getTheme().obtainStyledAttributes(set, attrs, defStyleAttr, defStyleRes); -// } -// -// public static boolean resolveAttribute(int resid, TypedValue outValue, boolean resolveRefs) { -// return Base.getTheme().resolveAttribute(resid, outValue, resolveRefs); -// } -// -// public static void setTo(Resources.Theme other) { -// Base.getTheme().setTo(other); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/content/TypedValueUtil.java b/utils/src/main/java/kr/lunaticbum/utils/content/TypedValueUtil.java deleted file mode 100644 index 84f0774e..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/content/TypedValueUtil.java +++ /dev/null @@ -1,29 +0,0 @@ -//package kr.lunaticbum.utils.content; -// -//import android.util.TypedValue; -// -//import kr.lunaticbum.Base; -// -///** -// * TypedValueUtil helps to manage {@link TypedValue} class conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class TypedValueUtil { -// -// public static float applyDimension(int unit, float value) { -// return TypedValue.applyDimension(unit, value, Base.getDisplayMetrics()); -// } -// -// public static float complexToDimension(int data) { -// return TypedValue.complexToDimension(data, Base.getDisplayMetrics()); -// } -// -// public static int complexToDimensionPixelOffset(int data) { -// return TypedValue.complexToDimensionPixelOffset(data, Base.getDisplayMetrics()); -// } -// -// public static int complexToDimensionPixelSize(int data) { -// return TypedValue.complexToDimensionPixelSize(data, Base.getDisplayMetrics()); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/etc/PackageUtil.java b/utils/src/main/java/kr/lunaticbum/utils/etc/PackageUtil.java deleted file mode 100644 index 50c0d5dd..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/etc/PackageUtil.java +++ /dev/null @@ -1,58 +0,0 @@ -//package kr.lunaticbum.utils.etc; -// -//import android.content.ActivityNotFoundException; -//import android.content.Intent; -//import android.content.pm.PackageManager; -//import android.net.Uri; -// -//import kr.lunaticbum.Base; -// -///** -// * PackageUtil helps to handle methods related to package. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class PackageUtil { -// -// public static final String FACEBOOK = "com.facebook.katana"; -// public static final String TWITTER = "com.twitter.android"; -// public static final String GOOGLE_PLUS = "com.google.android.apps.plus"; -// public static final String GMAIL = "com.google.android.gm"; -// public static final String PINTEREST = "com.pinterest"; -// public static final String TUMBLR = "com.tumblr"; -// public static final String FANCY = "com.thefancy.app"; -// public static final String FLIPBOARD = "flipboard.app"; -// public static final String KAKAOTALK = "com.kakao.talk"; -// public static final String KAKAOSTORY = "com.kakao.story"; -// -// public static boolean isInstalled(String packageName) { -// PackageManager packageManager = Base.getContext().getPackageManager(); -// try { -// packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); -// return true; -// } catch (PackageManager.NameNotFoundException e) { -// return false; -// } -// } -// -// public static String getPackageName() { -// return Base.getContext().getPackageName(); -// } -// -// public static void openPlayStore() { -// String packageName = Base.getContext().getPackageName(); -// openPlayStore(packageName); -// } -// -// public static void openPlayStore(String packageName) { -// try { -// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)); -// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); -// Base.getContext().startActivity(intent); -// } catch (ActivityNotFoundException exception) { -// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + packageName)); -// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); -// Base.getContext().startActivity(intent); -// } -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/etc/TypefaceUtil.java b/utils/src/main/java/kr/lunaticbum/utils/etc/TypefaceUtil.java deleted file mode 100644 index 121f747f..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/etc/TypefaceUtil.java +++ /dev/null @@ -1,55 +0,0 @@ -//package kr.lunaticbum.utils.etc; -// -//import android.graphics.Typeface; -//import android.widget.TextView; -// -//import androidx.annotation.NonNull; -//import androidx.collection.SimpleArrayMap; -// -//import kr.lunaticbum.Base; -// -///** -// * TypefaceUtil helps to retrieve typeface from assets folder. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class TypefaceUtil { -// -// private static final SimpleArrayMap cache = new SimpleArrayMap<>(); -// -// public static Typeface get(@NonNull String path) { -// synchronized (cache) { -// if (cache.containsKey(path)) -// return cache.get(path); -// -// try { -// Typeface typeface = Typeface.createFromAsset(Base.getContext().getAssets(), path); -// cache.put(path, typeface); -// return typeface; -// } catch (RuntimeException e) { -// return null; -// } -// } -// } -// -// public static void setTypeface(@NonNull String path, TextView... textViews) { -// if (textViews == null) -// return; -// -// for (TextView textView : textViews) -// if (textView != null) -// textView.setTypeface(get(path)); -// } -// -// public static void setTypeface(@NonNull String path, boolean includeFontPadding, TextView... textViews) { -// if (textViews == null) -// return; -// -// for (TextView textView : textViews) { -// if (textView != null) { -// textView.setTypeface(get(path)); -// textView.setIncludeFontPadding(includeFontPadding); -// } -// } -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/log/L.java b/utils/src/main/java/kr/lunaticbum/utils/log/L.java deleted file mode 100644 index 40fcec5d..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/log/L.java +++ /dev/null @@ -1,9 +0,0 @@ -//package kr.lunaticbum.utils.log; -// -///** -// * L is abbreviation class of {@link LogUtil}. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class L extends LogUtil { -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/log/LogHelper.java b/utils/src/main/java/kr/lunaticbum/utils/log/LogHelper.java deleted file mode 100644 index a9ada6c1..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/log/LogHelper.java +++ /dev/null @@ -1,702 +0,0 @@ -//package kr.lunaticbum.utils.log; -// -//import android.text.TextUtils; -//import android.util.Log; -// -//import androidx.annotation.StringRes; -// -//import kr.lunaticbum.enums.LogLevel; -//import kr.lunaticbum.utils.content.ResourcesUtil; -//import kr.lunaticbum.utils.etc.APILevel; -// -//import org.json.JSONArray; -//import org.json.JSONException; -//import org.json.JSONObject; -// -//import java.io.StringReader; -//import java.io.StringWriter; -//import java.util.Arrays; -// -//import javax.xml.transform.OutputKeys; -//import javax.xml.transform.Source; -//import javax.xml.transform.Transformer; -//import javax.xml.transform.TransformerException; -//import javax.xml.transform.TransformerFactory; -//import javax.xml.transform.stream.StreamResult; -//import javax.xml.transform.stream.StreamSource; -// -///** -// * LogHelper helps to deal with {@link Log} conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class LogHelper { -// -// private static final int INDENT_SPACES = 4; -// // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%E2%94%80-%E2%95%BF%EF%BF%A8%5D -// private static final String TOP_DIVIDER = "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"; -// private static final String MIDDLE_DIVIDER = "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"; -// private static final String BOTTOM_DIVIDER = "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"; -// -// protected Settings settings = new Settings(LogHelper.class.getSimpleName()); -// -// // Constructors -// public LogHelper() { -// } -// -// public LogHelper(String tag) { -// settings.setTag(tag); -// } -// -// public LogHelper(@StringRes int tagRes) { -// settings.setTag(ResourcesUtil.getString(tagRes)); -// } -// -// public LogHelper(Class clazz) { -// settings.setTag(clazz.getSimpleName()); -// } -// -// // Setters -// public LogHelper tag(String tag) { -// settings.setTag(tag); -// return this; -// } -// -// public LogHelper tag(@StringRes int tagRes) { -// settings.setTag(tagRes); -// return this; -// } -// -// public LogHelper tag(Class clazz) { -// settings.setTag(clazz); -// return this; -// } -// -// public LogHelper showThreadInfo(boolean showThreadInfo) { -// settings.setShowThreadInfo(showThreadInfo); -// return this; -// } -// -// public LogHelper stackTraceCount(int stackTraceCount) { -// settings.setStackTraceCount(stackTraceCount); -// return this; -// } -// -// public LogHelper logLevel(LogLevel logLevel) { -// settings.setLogLevel(logLevel); -// return this; -// } -// -// public LogHelper showDivider(boolean showDivider) { -// settings.setShowDivider(showDivider); -// return this; -// } -// -// public LogHelper logPrinter(LogPrinter logPrinter) { -// settings.setLogPrinter(logPrinter); -// return this; -// } -// -// // Logging Verbose -// public void v(byte message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(char message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(short message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(int message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(long message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(float message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(double message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(boolean message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(String message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(JSONObject message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(JSONArray message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(Exception message) { -// log(LogLevel.VERBOSE, message); -// } -// -// public void v(Object message) { -// log(LogLevel.VERBOSE, message); -// } -// -// // Logging Debug -// public void d(byte message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(char message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(short message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(int message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(long message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(float message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(double message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(boolean message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(String message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(JSONObject message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(JSONArray message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(Exception message) { -// log(LogLevel.DEBUG, message); -// } -// -// public void d(Object message) { -// log(LogLevel.DEBUG, message); -// } -// -// // Logging Information -// public void i(byte message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(char message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(short message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(int message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(long message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(float message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(double message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(boolean message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(String message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(JSONObject message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(JSONArray message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(Exception message) { -// log(LogLevel.INFO, message); -// } -// -// public void i(Object message) { -// log(LogLevel.INFO, message); -// } -// -// // Logging Warning -// public void w(byte message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(char message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(short message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(int message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(long message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(float message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(double message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(boolean message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(String message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(JSONObject message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(JSONArray message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(Exception message) { -// log(LogLevel.WARN, message); -// } -// -// public void w(Object message) { -// log(LogLevel.WARN, message); -// } -// -// // Logging Error -// public void e(byte message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(char message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(short message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(int message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(long message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(float message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(double message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(boolean message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(String message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(JSONObject message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(JSONArray message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(Exception message) { -// log(LogLevel.ERROR, message); -// } -// -// public void e(Object message) { -// log(LogLevel.ERROR, message); -// } -// -// // Logging Assert -// public void wtf(byte message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(char message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(short message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(int message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(long message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(float message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(double message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(boolean message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(String message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(JSONObject message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(JSONArray message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(Exception message) { -// log(LogLevel.ASSERT, message); -// } -// -// public void wtf(Object message) { -// log(LogLevel.ASSERT, message); -// } -// -// // Logging JsonString -// public void json(String jsonString) { -// json(LogLevel.DEBUG, jsonString); -// } -// -// public void json(LogLevel logLevel, String jsonString) { -// if (TextUtils.isEmpty(jsonString)) { -// log(logLevel, "Json string is empty."); -// } else { -// jsonString = jsonString.trim(); -// -// try { -// if (jsonString.startsWith("{")) { -// JSONObject jsonObject = new JSONObject(jsonString); -// String message = jsonObject.toString(INDENT_SPACES); -// log(logLevel, message); -// return; -// } -// if (jsonString.startsWith("[")) { -// JSONArray jsonArray = new JSONArray(jsonString); -// String message = jsonArray.toString(INDENT_SPACES); -// log(logLevel, message); -// } -// } catch (JSONException e) { -// log(logLevel, e); -// } -// } -// } -// -// // Logging XmlString -// public void xml(String xmlString) { -// xml(LogLevel.DEBUG, xmlString); -// } -// -// public void xml(LogLevel logLevel, String xmlString) { -// if (TextUtils.isEmpty(xmlString)) { -// log(logLevel, "Xml string is empty."); -// } else { -// if (APILevel.require(8)) { -// try { -// Source xmlInput = new StreamSource(new StringReader(xmlString)); -// StreamResult xmlOutput = new StreamResult(new StringWriter()); -// Transformer transformer = TransformerFactory.newInstance().newTransformer(); -// transformer.setOutputProperty(OutputKeys.INDENT, "yes"); -// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); -// transformer.transform(xmlInput, xmlOutput); -// log(logLevel, xmlOutput.getWriter().toString().replaceFirst(">", ">\n")); -// } catch (TransformerException e) { -// log(logLevel, e); -// } -// } else { -// log(logLevel, xmlString); -// } -// } -// } -// -// // Printing -// private void log(LogLevel logLevel, byte message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, String.valueOf(message)); -// } -// -// private void log(LogLevel logLevel, char message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, String.valueOf(message)); -// } -// -// private void log(LogLevel logLevel, short message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, String.valueOf(message)); -// } -// -// private void log(LogLevel logLevel, int message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, String.valueOf(message)); -// } -// -// private void log(LogLevel logLevel, long message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, String.valueOf(message)); -// } -// -// private void log(LogLevel logLevel, float message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, String.valueOf(message)); -// } -// -// private void log(LogLevel logLevel, double message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, String.valueOf(message)); -// } -// -// private void log(LogLevel logLevel, boolean message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, String.valueOf(message)); -// } -// -// private void log(LogLevel logLevel, String message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// printString(logLevel, message); -// } -// -// private void log(LogLevel logLevel, JSONObject message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// try { -// printString(logLevel, message.toString(INDENT_SPACES)); -// } catch (JSONException e) { -// log(logLevel, e); -// } -// } -// -// private void log(LogLevel logLevel, JSONArray message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// try { -// printString(logLevel, message.toString(INDENT_SPACES)); -// } catch (JSONException e) { -// log(logLevel, e); -// } -// } -// -// private void log(LogLevel logLevel, Exception message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// StringBuilder builder = new StringBuilder(); -// builder.append(String.valueOf(message)); -// builder.append("\n"); -// -// StackTraceElement[] traces = message.getStackTrace(); -// for (StackTraceElement trace : traces) { -// builder.append(" at ") -// .append(trace.getClassName()) -// .append(".") -// .append(trace.getMethodName()) -// .append("(") -// .append(trace.getFileName()) -// .append(":") -// .append(trace.getLineNumber()) -// .append(")") -// .append("\n"); -// } -// -// printString(logLevel, builder.toString(), true); -// } -// -// private void log(LogLevel logLevel, Object message) { -// if (logLevel.ordinal() < settings.getLogLevel().ordinal()) -// return; -// -// String log; -// if (message instanceof byte[]) log = Arrays.toString((byte[]) message); -// else if (message instanceof char[]) log = Arrays.toString((char[]) message); -// else if (message instanceof short[]) log = Arrays.toString((short[]) message); -// else if (message instanceof int[]) log = Arrays.toString((int[]) message); -// else if (message instanceof long[]) log = Arrays.toString((long[]) message); -// else if (message instanceof float[]) log = Arrays.toString((float[]) message); -// else if (message instanceof double[]) log = Arrays.toString((double[]) message); -// else if (message instanceof boolean[]) log = Arrays.toString((boolean[]) message); -// else if (message instanceof Object[]) log = Arrays.toString((Object[]) message); -// else log = String.valueOf(message); -// -// printString(logLevel, log); -// } -// -// private void printString(LogLevel logLevel, String message) { -// printString(logLevel, message, false); -// } -// -// private synchronized void printString(LogLevel logLevel, String message, boolean fromException) { -// // Create TAG -// String TAG = settings.getTag(); -// if (settings.getShowThreadInfo()) TAG += "(" + Thread.currentThread().getName() + ")"; -// -// // Top Divider -// if (settings.getShowDivider()) printLine(logLevel, TAG, TOP_DIVIDER); -// -// // Log Content -// String[] lines = message.split(System.getProperty("line.separator")); -// for (String line : lines) -// printLine(logLevel, TAG, settings.getShowDivider() ? -// "┃ " + line : -// line); -// -// if (settings.getStackTraceCount() > 0 && fromException) -// printLine(logLevel, TAG, "Exception occurred"); -// -// // Middle Divider -// if (settings.getShowDivider()) printLine(logLevel, TAG, MIDDLE_DIVIDER); -// -// // Log Stack Trace -// StackTraceElement[] traces = Thread.currentThread().getStackTrace(); -// int startIndex = 2; -// while (LogUtil.class.getCanonicalName().equals(traces[startIndex].getClassName()) -// || LogHelper.class.getCanonicalName().equals(traces[startIndex].getClassName())) -// startIndex++; -// -// for (int i = startIndex; i < Math.min(traces.length, startIndex + settings.getStackTraceCount()); i++) { -// StringBuilder builder = new StringBuilder(); -// builder.append(" at ") -// .append(traces[i].getClassName()) -// .append(".") -// .append(traces[i].getMethodName()) -// .append("(") -// .append(traces[i].getFileName()) -// .append(":") -// .append(traces[i].getLineNumber()) -// .append(")"); -// -// printLine(logLevel, TAG, settings.getShowDivider() ? -// "┃ " + builder.toString() : -// builder.toString()); -// } -// -// // Log ellipsized stack trance -// int leftTraceCount = traces.length - startIndex - settings.getStackTraceCount(); -// if (settings.getStackTraceCount() > 0 && leftTraceCount > 1) -// printLine(logLevel, TAG, settings.getShowDivider() ? -// "┃ at " + leftTraceCount + " more stack traces..." : -// " at " + leftTraceCount + " more stack traces..."); -// if (settings.getStackTraceCount() > 0 && leftTraceCount == 1) -// printLine(logLevel, TAG, settings.getShowDivider() ? -// "┃ at 1 more stack trace..." : -// " at 1 more stack trace..."); -// -// // Middle Divider -// if (settings.getShowDivider()) printLine(logLevel, TAG, BOTTOM_DIVIDER); -// -// // LogUtil setToDefault -// if (this == LogUtil.getInstance()) setToDefault(); -// } -// -// private void printLine(LogLevel logLevel, String tag, String message) { -// switch (logLevel) { -// case FULL: -// case VERBOSE: -// settings.getLogPrinter().v(tag, message); -// break; -// case DEBUG: -// settings.getLogPrinter().d(tag, message); -// break; -// case INFO: -// settings.getLogPrinter().i(tag, message); -// break; -// case WARN: -// settings.getLogPrinter().w(tag, message); -// break; -// case ERROR: -// settings.getLogPrinter().e(tag, message); -// break; -// case ASSERT: -// settings.getLogPrinter().wtf(tag, message); -// break; -// } -// } -// -// protected void setToDefault() { -// settings.setTag(LogUtil.getDefaultSettings().getTag()); -// settings.setShowThreadInfo(LogUtil.getDefaultSettings().getShowThreadInfo()); -// settings.setStackTraceCount(LogUtil.getDefaultSettings().getStackTraceCount()); -// settings.setLogLevel(LogUtil.getDefaultSettings().getLogLevel()); -// settings.setShowDivider(LogUtil.getDefaultSettings().getShowDivider()); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/log/LogUtil.java b/utils/src/main/java/kr/lunaticbum/utils/log/LogUtil.java deleted file mode 100644 index c9bcce46..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/log/LogUtil.java +++ /dev/null @@ -1,406 +0,0 @@ -//package kr.lunaticbum.utils.log; -// -//import android.util.Log; -// -//import androidx.annotation.StringRes; -// -//import kr.lunaticbum.enums.LogLevel; -// -//import org.json.JSONArray; -//import org.json.JSONObject; -// -///** -// * LogUtil helps to manage application-wide {@link Log} conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class LogUtil { -// -// // Defaults -// private static Settings defaultSettings = new Settings(LogUtil.class.getSimpleName()); -// -// // Singleton -// private static volatile LogHelper logHelper = new LogHelper() -// .tag(defaultSettings.getTag()) -// .showThreadInfo(defaultSettings.getShowThreadInfo()) -// .stackTraceCount(defaultSettings.getStackTraceCount()) -// .logLevel(defaultSettings.getLogLevel()) -// .showDivider(defaultSettings.getShowDivider()); -// -// public static Settings getDefaultSettings() { -// return defaultSettings; -// } -// -// public static LogHelper getInstance() { -// return logHelper; -// } -// -// // Builder -// public static LogHelper tag(String tag) { -// return logHelper.tag(tag); -// } -// -// public static LogHelper tag(@StringRes int tagRes) { -// return logHelper.tag(tagRes); -// } -// -// public static LogHelper tag(Class clazz) { -// return logHelper.tag(clazz); -// } -// -// public static LogHelper showThreadInfo(boolean showThreadInfo) { -// return logHelper.showThreadInfo(showThreadInfo); -// } -// -// public static LogHelper stackTraceCount(int stackTraceCount) { -// return logHelper.stackTraceCount(stackTraceCount); -// } -// -// public static LogHelper logLevel(LogLevel logLevel) { -// return logHelper.logLevel(logLevel); -// } -// -// public static LogHelper showDivider(boolean showDivider) { -// return logHelper.showDivider(showDivider); -// } -// -// public LogHelper logPrinter(LogPrinter logPrinter) { -// return logHelper.logPrinter(logPrinter); -// } -// -// // Logging Verbose -// public static void v(byte message) { -// logHelper.v(message); -// } -// -// public static void v(char message) { -// logHelper.v(message); -// } -// -// public static void v(short message) { -// logHelper.v(message); -// } -// -// public static void v(int message) { -// logHelper.v(message); -// } -// -// public static void v(long message) { -// logHelper.v(message); -// } -// -// public static void v(float message) { -// logHelper.v(message); -// } -// -// public static void v(double message) { -// logHelper.v(message); -// } -// -// public static void v(boolean message) { -// logHelper.v(message); -// } -// -// public static void v(String message) { -// logHelper.v(message); -// } -// -// public static void v(JSONObject message) { -// logHelper.v(message); -// } -// -// public static void v(JSONArray message) { -// logHelper.v(message); -// } -// -// public static void v(Exception message) { -// logHelper.v(message); -// } -// -// public static void v(Object message) { -// logHelper.v(message); -// } -// -// // Logging Debug -// public static void d(byte message) { -// logHelper.d(message); -// } -// -// public static void d(char message) { -// logHelper.d(message); -// } -// -// public static void d(short message) { -// logHelper.d(message); -// } -// -// public static void d(int message) { -// logHelper.d(message); -// } -// -// public static void d(long message) { -// logHelper.d(message); -// } -// -// public static void d(float message) { -// logHelper.d(message); -// } -// -// public static void d(double message) { -// logHelper.d(message); -// } -// -// public static void d(boolean message) { -// logHelper.d(message); -// } -// -// public static void d(String message) { -// logHelper.d(message); -// } -// -// public static void d(JSONObject message) { -// logHelper.d(message); -// } -// -// public static void d(JSONArray message) { -// logHelper.d(message); -// } -// -// public static void d(Exception message) { -// logHelper.d(message); -// } -// -// public static void d(Object message) { -// logHelper.d(message); -// } -// -// // Logging Information -// public static void i(byte message) { -// logHelper.i(message); -// } -// -// public static void i(char message) { -// logHelper.i(message); -// } -// -// public static void i(short message) { -// logHelper.i(message); -// } -// -// public static void i(int message) { -// logHelper.i(message); -// } -// -// public static void i(long message) { -// logHelper.i(message); -// } -// -// public static void i(float message) { -// logHelper.i(message); -// } -// -// public static void i(double message) { -// logHelper.i(message); -// } -// -// public static void i(boolean message) { -// logHelper.i(message); -// } -// -// public static void i(String message) { -// logHelper.i(message); -// } -// -// public static void i(JSONObject message) { -// logHelper.i(message); -// } -// -// public static void i(JSONArray message) { -// logHelper.i(message); -// } -// -// public static void i(Exception message) { -// logHelper.i(message); -// } -// -// public static void i(Object message) { -// logHelper.i(message); -// } -// -// // Logging Warning -// public static void w(byte message) { -// logHelper.w(message); -// } -// -// public static void w(char message) { -// logHelper.w(message); -// } -// -// public static void w(short message) { -// logHelper.w(message); -// } -// -// public static void w(int message) { -// logHelper.w(message); -// } -// -// public static void w(long message) { -// logHelper.w(message); -// } -// -// public static void w(float message) { -// logHelper.w(message); -// } -// -// public static void w(double message) { -// logHelper.w(message); -// } -// -// public static void w(boolean message) { -// logHelper.w(message); -// } -// -// public static void w(String message) { -// logHelper.w(message); -// } -// -// public static void w(JSONObject message) { -// logHelper.w(message); -// } -// -// public static void w(JSONArray message) { -// logHelper.w(message); -// } -// -// public static void w(Exception message) { -// logHelper.w(message); -// } -// -// public static void w(Object message) { -// logHelper.w(message); -// } -// -// // Logging Error -// public static void e(byte message) { -// logHelper.e(message); -// } -// -// public static void e(char message) { -// logHelper.e(message); -// } -// -// public static void e(short message) { -// logHelper.e(message); -// } -// -// public static void e(int message) { -// logHelper.e(message); -// } -// -// public static void e(long message) { -// logHelper.e(message); -// } -// -// public static void e(float message) { -// logHelper.e(message); -// } -// -// public static void e(double message) { -// logHelper.e(message); -// } -// -// public static void e(boolean message) { -// logHelper.e(message); -// } -// -// public static void e(String message) { -// logHelper.e(message); -// } -// -// public static void e(JSONObject message) { -// logHelper.e(message); -// } -// -// public static void e(JSONArray message) { -// logHelper.e(message); -// } -// -// public static void e(Exception message) { -// logHelper.e(message); -// } -// -// public static void e(Object message) { -// logHelper.e(message); -// } -// -// // Logging Assert -// public static void wtf(byte message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(char message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(short message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(int message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(long message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(float message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(double message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(boolean message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(String message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(JSONObject message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(JSONArray message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(Exception message) { -// logHelper.wtf(message); -// } -// -// public static void wtf(Object message) { -// logHelper.wtf(message); -// } -// -// // Logging JsonString -// public static void json(String jsonString) { -// json(LogLevel.DEBUG, jsonString); -// } -// -// public static void json(LogLevel logLevel, String jsonString) { -// logHelper.json(logLevel, jsonString); -// } -// -// // Logging XmlString -// public static void xml(String xmlString) { -// xml(LogLevel.DEBUG, xmlString); -// } -// -// public static void xml(LogLevel logLevel, String jsonString) { -// logHelper.xml(logLevel, jsonString); -// } -//} diff --git a/utils/src/main/java/kr/lunaticbum/utils/log/Settings.java b/utils/src/main/java/kr/lunaticbum/utils/log/Settings.java deleted file mode 100644 index b03491db..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/log/Settings.java +++ /dev/null @@ -1,109 +0,0 @@ -//package kr.lunaticbum.utils.log; -// -// -//import androidx.annotation.StringRes; -// -//import kr.lunaticbum.enums.LogLevel; -//import kr.lunaticbum.utils.content.ResourcesUtil; -// -///** -// * Settings for {@link LogHelper}. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class Settings { -// -// private String tag = Settings.class.getSimpleName(); -// private boolean showThreadInfo = false; -// private int stackTraceCount = 0; -// private LogLevel logLevel = LogLevel.FULL; -// private boolean showDivider = false; -// private LogPrinter logPrinter = new AndroidLogPrinter(); -// -// public Settings() { -// } -// -// public Settings(String tag) { -// this.tag = tag; -// } -// -// public Settings(@StringRes int tagRes) { -// this.tag = ResourcesUtil.getString(tagRes); -// } -// -// public Settings(Class clazz) { -// this.tag = clazz.getSimpleName(); -// } -// -// public String getTag() { -// return tag; -// } -// -// public Settings setTag(String tag) { -// this.tag = tag; -// if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault(); -// return this; -// } -// -// public Settings setTag(@StringRes int tagRes) { -// this.tag = ResourcesUtil.getString(tagRes); -// if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault(); -// return this; -// } -// -// public Settings setTag(Class clazz) { -// this.tag = clazz.getSimpleName(); -// if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault(); -// return this; -// } -// -// public boolean getShowThreadInfo() { -// return showThreadInfo; -// } -// -// public Settings setShowThreadInfo(boolean showThreadInfo) { -// this.showThreadInfo = showThreadInfo; -// if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault(); -// return this; -// } -// -// public int getStackTraceCount() { -// return stackTraceCount; -// } -// -// public Settings setStackTraceCount(int stackTraceCount) { -// this.stackTraceCount = stackTraceCount; -// if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault(); -// return this; -// } -// -// public LogLevel getLogLevel() { -// return logLevel; -// } -// -// public Settings setLogLevel(LogLevel logLevel) { -// this.logLevel = logLevel; -// if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault(); -// return this; -// } -// -// public boolean getShowDivider() { -// return showDivider; -// } -// -// public Settings setShowDivider(boolean showDivider) { -// this.showDivider = showDivider; -// if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault(); -// return this; -// } -// -// public LogPrinter getLogPrinter() { -// return logPrinter; -// } -// -// public Settings setLogPrinter(LogPrinter logPrinter) { -// this.logPrinter = logPrinter; -// if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault(); -// return this; -// } -//} diff --git a/utils/src/main/java/kr/lunaticbum/utils/preferences/PreferencesUtil.java b/utils/src/main/java/kr/lunaticbum/utils/preferences/PreferencesUtil.java deleted file mode 100755 index 981cfdd2..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/preferences/PreferencesUtil.java +++ /dev/null @@ -1,271 +0,0 @@ -//package kr.lunaticbum.utils.preferences; -// -//import android.annotation.TargetApi; -//import android.content.Context; -//import android.content.SharedPreferences; -//import android.os.Build; -//import android.util.Base64; -// -//import kr.lunaticbum.Base; -//import kr.lunaticbum.utils.etc.APILevel; -//import kr.lunaticbum.utils.log.LogHelper; -// -//import java.io.ByteArrayInputStream; -//import java.io.ByteArrayOutputStream; -//import java.io.IOException; -//import java.io.ObjectInputStream; -//import java.io.ObjectOutputStream; -//import java.io.Serializable; -//import java.util.Set; -// -///** -// * PreferencesUtil helps to manage application-wide {@link SharedPreferences} conveniently. -// * -// * @author Robin Gustafsson -// */ -//public class PreferencesUtil { -// -// private static final kr.lunaticbum.utils.log.LogHelper LogHelper = new LogHelper(PreferencesUtil.class); -// private static String defaultName = PreferencesUtil.class.getCanonicalName(); -// -// private static SharedPreferences getPreferences(String name) { -// return Base.getContext().getSharedPreferences(name, Context.MODE_PRIVATE); -// } -// -// -// public static String getDefaultName() { -// return defaultName; -// } -// -// public static void setDefaultName(String name) { -// defaultName = name; -// } -// -// -// public static boolean get(String key, boolean defValue) { -// return get(defaultName, key, defValue); -// } -// -// public static int get(String key, int defValue) { -// return get(defaultName, key, defValue); -// } -// -// public static float get(String key, float defValue) { -// return get(defaultName, key, defValue); -// } -// -// public static long get(String key, long defValue) { -// return get(defaultName, key, defValue); -// } -// -// public static String get(String key, String defValue) { -// return get(defaultName, key, defValue); -// } -// -// @TargetApi(Build.VERSION_CODES.HONEYCOMB) -// public static Set get(String key, Set defValue) { -// return get(defaultName, key, defValue); -// } -// -// @TargetApi(Build.VERSION_CODES.FROYO) -// public static C get(String key, C defValue) { -// return get(defaultName, key, defValue); -// } -// -// public static boolean get(String name, String key, boolean defValue) { -// return getPreferences(name).getBoolean(key, defValue); -// } -// -// public static int get(String name, String key, int defValue) { -// return getPreferences(name).getInt(key, defValue); -// } -// -// public static float get(String name, String key, float defValue) { -// return getPreferences(name).getFloat(key, defValue); -// } -// -// public static long get(String name, String key, long defValue) { -// return getPreferences(name).getLong(key, defValue); -// } -// -// public static String get(String name, String key, String defValue) { -// return getPreferences(name).getString(key, defValue); -// } -// -// @TargetApi(Build.VERSION_CODES.HONEYCOMB) -// public static Set get(String name, String key, Set defValue) { -// return getPreferences(name).getStringSet(key, defValue); -// } -// -// @TargetApi(Build.VERSION_CODES.FROYO) -// public static C get(String name, String key, C defValue) { -// ByteArrayInputStream bais = null; -// ObjectInputStream ois = null; -// C result = defValue; -// -// String value = getPreferences(name).getString(key, null); -// if (value != null) { -// try { -// byte[] decoded = Base64.decode(value.getBytes(), Base64.DEFAULT); -// bais = new ByteArrayInputStream(decoded); -// ois = new ObjectInputStream(bais); -// result = (C) ois.readObject(); -// -// } catch (Exception e) { -// LogHelper.e(e); -// } finally { -// if (ois != null) { -// try { -// ois.close(); -// } catch (IOException e) { -// LogHelper.e(e); -// } -// } -// if (bais != null) { -// try { -// bais.close(); -// } catch (IOException e) { -// LogHelper.e(e); -// } -// } -// } -// } -// -// return result; -// } -// -// -// public static void put(String key, boolean value) { -// put(defaultName, key, value); -// } -// -// public static void put(String key, int value) { -// put(defaultName, key, value); -// } -// -// public static void put(String key, float value) { -// put(defaultName, key, value); -// } -// -// public static void put(String key, long value) { -// put(defaultName, key, value); -// } -// -// public static void put(String key, String value) { -// put(defaultName, key, value); -// } -// -// @TargetApi(Build.VERSION_CODES.HONEYCOMB) -// public static void put(String key, Set value) { -// put(defaultName, key, value); -// } -// -// @TargetApi(Build.VERSION_CODES.FROYO) -// public static void put(String key, C value) { -// put(defaultName, key, value); -// } -// -// public static void put(String name, String key, boolean value) { -// if (APILevel.require(9)) -// getPreferences(name).edit().putBoolean(key, value).apply(); -// else -// getPreferences(name).edit().putBoolean(key, value).commit(); -// } -// -// public static void put(String name, String key, int value) { -// if (APILevel.require(9)) -// getPreferences(name).edit().putInt(key, value).apply(); -// else -// getPreferences(name).edit().putInt(key, value).commit(); -// } -// -// public static void put(String name, String key, float value) { -// if (APILevel.require(9)) -// getPreferences(name).edit().putFloat(key, value).apply(); -// else -// getPreferences(name).edit().putFloat(key, value).commit(); -// } -// -// public static void put(String name, String key, long value) { -// if (APILevel.require(9)) -// getPreferences(name).edit().putLong(key, value).apply(); -// else -// getPreferences(name).edit().putLong(key, value).commit(); -// } -// -// public static void put(String name, String key, String value) { -// if (APILevel.require(9)) -// getPreferences(name).edit().putString(key, value).apply(); -// else -// getPreferences(name).edit().putString(key, value).commit(); -// } -// -// @TargetApi(Build.VERSION_CODES.HONEYCOMB) -// public static void put(String name, String key, Set value) { -// if (APILevel.require(9)) -// getPreferences(name).edit().putStringSet(key, value).apply(); -// else -// getPreferences(name).edit().putStringSet(key, value).commit(); -// } -// -// @TargetApi(Build.VERSION_CODES.FROYO) -// public static void put(String name, String key, C value) { -// ByteArrayOutputStream baos = null; -// ObjectOutputStream oos = null; -// -// try { -// baos = new ByteArrayOutputStream(); -// oos = new ObjectOutputStream(baos); -// oos.writeObject(value); -// byte[] encoded = Base64.encode(baos.toByteArray(), Base64.DEFAULT); -// if (APILevel.require(9)) -// getPreferences(name).edit().putString(key, new String(encoded)).apply(); -// else -// getPreferences(name).edit().putString(key, new String(encoded)).commit(); -// -// } catch (IOException e) { -// LogHelper.e(e); -// throw new RuntimeException(e); -// -// } finally { -// if (oos != null) { -// try { -// oos.close(); -// } catch (IOException e) { -// LogHelper.e(e); -// } -// } -// if (baos != null) { -// try { -// baos.close(); -// } catch (IOException e) { -// LogHelper.e(e); -// } -// } -// } -// } -// -// -// public static void remove(String key) { -// remove(defaultName, key); -// } -// -// public static void remove(String name, String key) { -// if (APILevel.require(9)) -// getPreferences(name).edit().remove(key).apply(); -// else -// getPreferences(name).edit().remove(key).commit(); -// } -// -// -// public static void clear() { -// clear(defaultName); -// } -// -// public static void clear(String name) { -// if (APILevel.require(9)) -// getPreferences(name).edit().clear().apply(); -// else -// getPreferences(name).edit().clear().commit(); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/service/ClipboardManagerUtil.java b/utils/src/main/java/kr/lunaticbum/utils/service/ClipboardManagerUtil.java deleted file mode 100644 index 12145bf1..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/service/ClipboardManagerUtil.java +++ /dev/null @@ -1,57 +0,0 @@ -//package kr.lunaticbum.utils.service; -// -//import android.content.ClipData; -//import android.content.ClipDescription; -//import android.content.ClipboardManager; -// -//import kr.lunaticbum.utils.etc.APILevel; -// -///** -// * ClipboardManagerUtil helps to manage {@link ClipboardManager} conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class ClipboardManagerUtil { -// -// public static void setText(CharSequence text) { -// android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager(); -// if (APILevel.require(11)) { -// ClipboardManager cm = (ClipboardManager) clipboardManager; -// ClipData clip = ClipData.newPlainText("ClipboardManagerUtil", text); -// cm.setPrimaryClip(clip); -// } else { -// clipboardManager.setText(text); -// } -// } -// -// public static boolean hasText() { -// android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager(); -// if (APILevel.require(11)) { -// ClipboardManager cm = (ClipboardManager) clipboardManager; -// ClipDescription description = cm.getPrimaryClipDescription(); -// ClipData clipData = cm.getPrimaryClip(); -// return clipData != null -// && description != null -// && (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)); -// } else { -// return clipboardManager.hasText(); -// } -// } -// -// public static CharSequence getText() { -// android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager(); -// if (APILevel.require(11)) { -// ClipboardManager cm = (ClipboardManager) clipboardManager; -// ClipDescription description = cm.getPrimaryClipDescription(); -// ClipData clipData = cm.getPrimaryClip(); -// if (clipData != null -// && description != null -// && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) -// return clipData.getItemAt(0).getText(); -// else -// return null; -// } else { -// return clipboardManager.getText(); -// } -// } -//} diff --git a/utils/src/main/java/kr/lunaticbum/utils/service/ServiceUtil.java b/utils/src/main/java/kr/lunaticbum/utils/service/ServiceUtil.java deleted file mode 100644 index b6225a87..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/service/ServiceUtil.java +++ /dev/null @@ -1,330 +0,0 @@ -//package kr.lunaticbum.utils.service; -// -//import android.accounts.AccountManager; -//import android.annotation.TargetApi; -//import android.app.ActivityManager; -//import android.app.AlarmManager; -//import android.app.AppOpsManager; -//import android.app.DownloadManager; -//import android.app.KeyguardManager; -//import android.app.NotificationManager; -//import android.app.SearchManager; -//import android.app.UiModeManager; -//import android.app.WallpaperManager; -//import android.app.admin.DevicePolicyManager; -//import android.app.job.JobScheduler; -//import android.app.usage.NetworkStatsManager; -//import android.app.usage.UsageStatsManager; -//import android.appwidget.AppWidgetManager; -//import android.bluetooth.BluetoothManager; -//import android.content.Context; -//import android.content.RestrictionsManager; -//import android.content.pm.LauncherApps; -//import android.hardware.ConsumerIrManager; -//import android.hardware.SensorManager; -//import android.hardware.camera2.CameraManager; -//import android.hardware.display.DisplayManager; -//import android.hardware.fingerprint.FingerprintManager; -//import android.hardware.input.InputManager; -//import android.hardware.usb.UsbManager; -//import android.location.LocationManager; -//import android.media.AudioManager; -//import android.media.MediaRouter; -//import android.media.midi.MidiManager; -//import android.media.projection.MediaProjectionManager; -//import android.media.session.MediaSessionManager; -//import android.media.tv.TvInputManager; -//import android.net.ConnectivityManager; -//import android.net.nsd.NsdManager; -//import android.net.wifi.WifiManager; -//import android.net.wifi.p2p.WifiP2pManager; -//import android.nfc.NfcManager; -//import android.os.BatteryManager; -//import android.os.DropBoxManager; -//import android.os.PowerManager; -//import android.os.UserManager; -//import android.os.Vibrator; -//import android.os.storage.StorageManager; -//import android.print.PrintManager; -//import android.telecom.TelecomManager; -//import android.telephony.CarrierConfigManager; -//import android.telephony.SubscriptionManager; -//import android.telephony.TelephonyManager; -//import android.text.ClipboardManager; -//import android.view.LayoutInflater; -//import android.view.WindowManager; -//import android.view.accessibility.AccessibilityManager; -//import android.view.accessibility.CaptioningManager; -//import android.view.inputmethod.InputMethodManager; -//import android.view.textservice.TextServicesManager; -// -//import androidx.annotation.NonNull; -// -//import kr.lunaticbum.Base; -// -///** -// * ServiceUtil helps to manage Android system service conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class ServiceUtil { -// -// public static Object getSystemService(@NonNull String serviceName) { -// return Base.getContext().getSystemService(serviceName); -// } -// -// public static AccessibilityManager getAccessibilityManager() { -// return (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE); -// } -// -// @TargetApi(19) -// public static CaptioningManager getCaptioningManager() { -// return (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE); -// } -// -// public static AccountManager getAccountManager() { -// return (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); -// } -// -// public static ActivityManager getActivityManager() { -// return (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); -// } -// -// public static AlarmManager getAlarmManager() { -// return (AlarmManager) getSystemService(Context.ALARM_SERVICE); -// } -// -// public static AudioManager getAudioManager() { -// return (AudioManager) getSystemService(Context.AUDIO_SERVICE); -// } -// -// @TargetApi(16) -// public static MediaRouter getMediaRouter() { -// return (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE); -// } -// -// @TargetApi(18) -// public static BluetoothManager getBluetoothManager() { -// return (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); -// } -// -// public static ClipboardManager getClipboardManager() { -// return (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); -// } -// -// public static ConnectivityManager getConnectivityManager() { -// return (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); -// } -// -// @TargetApi(8) -// public static DevicePolicyManager getDevicePolicyManager() { -// return (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); -// } -// -// @TargetApi(9) -// public static DownloadManager getDownloadManager() { -// return (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); -// } -// -// @TargetApi(21) -// public static BatteryManager getBatteryManager() { -// return (BatteryManager) getSystemService(Context.BATTERY_SERVICE); -// } -// -// @TargetApi(10) -// public static NfcManager getNfcManager() { -// return (NfcManager) getSystemService(Context.NFC_SERVICE); -// } -// -// @TargetApi(8) -// public static DropBoxManager getDropBoxManager() { -// return (DropBoxManager) getSystemService(Context.DROPBOX_SERVICE); -// } -// -// @TargetApi(16) -// public static InputManager getInputManager() { -// return (InputManager) getSystemService(Context.INPUT_SERVICE); -// } -// -// @TargetApi(17) -// public static DisplayManager getDisplayManager() { -// return (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); -// } -// -// public static InputMethodManager getInputMethodManager() { -// return (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); -// } -// -// @TargetApi(14) -// public static TextServicesManager getTextServicesManager() { -// return (TextServicesManager) getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE); -// } -// -// public static KeyguardManager getKeyguardManager() { -// return (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); -// } -// -// public static LayoutInflater getLayoutInflater() { -// return (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); -// } -// -// public static LocationManager getLocationManager() { -// return (LocationManager) getSystemService(Context.LOCATION_SERVICE); -// } -// -// public static NotificationManager getNotificationManager() { -// return (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); -// } -// -// @TargetApi(16) -// public static NsdManager getNsdManager() { -// return (NsdManager) getSystemService(Context.NSD_SERVICE); -// } -// -// public static PowerManager getPowerManager() { -// return (PowerManager) getSystemService(Context.POWER_SERVICE); -// } -// -// public static SearchManager getSearchManager() { -// return (SearchManager) getSystemService(Context.SEARCH_SERVICE); -// } -// -// public static SensorManager getSensorManager() { -// return (SensorManager) getSystemService(Context.SENSOR_SERVICE); -// } -// -// @TargetApi(9) -// public static StorageManager getStorageManager() { -// return (StorageManager) getSystemService(Context.STORAGE_SERVICE); -// } -// -// public static TelephonyManager getTelephonyManager() { -// return (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); -// } -// -// @TargetApi(22) -// public static SubscriptionManager getSubscriptionManager() { -// return (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); -// } -// -// @TargetApi(23) -// public static CarrierConfigManager getCarrierConfigManager() { -// return (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE); -// } -// -// @TargetApi(21) -// public static TelecomManager getTelecomManager() { -// return (TelecomManager) getSystemService(Context.TELECOM_SERVICE); -// } -// -// @TargetApi(8) -// public static UiModeManager getUiModeManager() { -// return (UiModeManager) getSystemService(Context.UI_MODE_SERVICE); -// } -// -// @TargetApi(12) -// public static UsbManager getUsbManager() { -// return (UsbManager) getSystemService(Context.USB_SERVICE); -// } -// -// public static Vibrator getVibrator() { -// return (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); -// } -// -// public static WallpaperManager getWallpaperManager() { -// return WallpaperManager.getInstance(Base.getContext()); -// } -// -// public static WifiManager getWifiManager() { -// return (WifiManager) getSystemService(Context.WIFI_SERVICE); -// } -// -// @TargetApi(14) -// public static WifiP2pManager getWifiP2pManager() { -// return (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE); -// } -// -// public static WindowManager getWindowManager() { -// return (WindowManager) getSystemService(Context.WINDOW_SERVICE); -// } -// -// @TargetApi(17) -// public static UserManager getUserManager() { -// return (UserManager) getSystemService(Context.USER_SERVICE); -// } -// -// @TargetApi(19) -// public static AppOpsManager getAppOpsManager() { -// return (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE); -// } -// -// @TargetApi(21) -// public static CameraManager getCameraManager() { -// return (CameraManager) getSystemService(Context.CAMERA_SERVICE); -// } -// -// @TargetApi(21) -// public static LauncherApps getLauncherApps() { -// return (LauncherApps) getSystemService(Context.LAUNCHER_APPS_SERVICE); -// } -// -// @TargetApi(21) -// public static RestrictionsManager getRestrictionsManager() { -// return (RestrictionsManager) getSystemService(Context.RESTRICTIONS_SERVICE); -// } -// -// @TargetApi(19) -// public static PrintManager getPrintManager() { -// return (PrintManager) getSystemService(Context.PRINT_SERVICE); -// } -// -// @TargetApi(19) -// public static ConsumerIrManager getConsumerIrManager() { -// return (ConsumerIrManager) getSystemService(Context.CONSUMER_IR_SERVICE); -// } -// -// @TargetApi(21) -// public static MediaSessionManager getMediaSessionManager() { -// return (MediaSessionManager) getSystemService(Context.MEDIA_SESSION_SERVICE); -// } -// -// @TargetApi(23) -// public static FingerprintManager getFingerprintManager() { -// return (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE); -// } -// -// @TargetApi(21) -// public static TvInputManager getTvInputManager() { -// return (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE); -// } -// -// @TargetApi(22) -// public static UsageStatsManager getUsageStatsManager() { -// return (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE); -// } -// -// @TargetApi(23) -// public static NetworkStatsManager getNetworkStatsManager() { -// return (NetworkStatsManager) getSystemService(Context.NETWORK_STATS_SERVICE); -// } -// -// @TargetApi(21) -// public static JobScheduler getJobScheduler() { -// return (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); -// } -// -// @TargetApi(21) -// public static MediaProjectionManager getMediaProjectionManager() { -// return (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); -// } -// -// @TargetApi(21) -// public static AppWidgetManager getAppWidgetManager() { -// return (AppWidgetManager) getSystemService(Context.APPWIDGET_SERVICE); -// } -// -// @TargetApi(23) -// public static MidiManager getMidiManager() { -// return (MidiManager) getSystemService(Context.MIDI_SERVICE); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/service/VibratorUtil.java b/utils/src/main/java/kr/lunaticbum/utils/service/VibratorUtil.java deleted file mode 100755 index bc5eceee..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/service/VibratorUtil.java +++ /dev/null @@ -1,48 +0,0 @@ -//package kr.lunaticbum.utils.service; -// -//import android.annotation.TargetApi; -//import android.media.AudioAttributes; -//import android.os.Vibrator; -// -///** -// * VibratorUtil helps to manage {@link Vibrator} conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class VibratorUtil { -// -// @TargetApi(11) -// public static boolean hasVibrator() { -// return ServiceUtil.getVibrator().hasVibrator(); -// } -// -// public static void vibrate() { -// vibrate(200); -// } -// -// public static void vibrate(long milliseconds) { -// vibrate(new long[]{milliseconds}); -// } -// -// public static void vibrate(long[] pattern) { -// vibrate(pattern, -1); -// } -// -// public static void vibrate(long[] pattern, int repeat) { -// ServiceUtil.getVibrator().vibrate(pattern, repeat); -// } -// -// @TargetApi(21) -// public static void vibrate(long milliseconds, AudioAttributes attributes) { -// vibrate(new long[]{milliseconds}, -1, attributes); -// } -// -// @TargetApi(21) -// public static void vibrate(long[] pattern, int repeat, AudioAttributes attributes) { -// ServiceUtil.getVibrator().vibrate(pattern, repeat, attributes); -// } -// -// public static void cancel() { -// ServiceUtil.getVibrator().cancel(); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/service/WindowManagerUtil.java b/utils/src/main/java/kr/lunaticbum/utils/service/WindowManagerUtil.java deleted file mode 100644 index bc9e99e3..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/service/WindowManagerUtil.java +++ /dev/null @@ -1,21 +0,0 @@ -//package kr.lunaticbum.utils.service; -// -//import android.view.Display; -//import android.view.View; -//import android.view.WindowManager; -// -///** -// * WindowManagerUtil helps to manage {@link WindowManager} conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class WindowManagerUtil { -// -// public static Display getDefaultDisplay() { -// return ServiceUtil.getWindowManager().getDefaultDisplay(); -// } -// -// public static void removeViewImmediate(View view) { -// ServiceUtil.getWindowManager().removeViewImmediate(view); -// } -//} \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/ui/DisplayUtil.java b/utils/src/main/java/kr/lunaticbum/utils/ui/DisplayUtil.java deleted file mode 100644 index 3db246bd..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/ui/DisplayUtil.java +++ /dev/null @@ -1,82 +0,0 @@ -//package kr.lunaticbum.utils.ui; -// -//import android.graphics.Point; -//import android.util.TypedValue; -//import android.view.Display; -// -//import kr.lunaticbum.utils.etc.APILevel; -//import kr.lunaticbum.enums.Rotation; -//import kr.lunaticbum.utils.content.ResourcesUtil; -//import kr.lunaticbum.utils.content.ThemeUtil; -//import kr.lunaticbum.utils.content.TypedValueUtil; -//import kr.lunaticbum.utils.service.WindowManagerUtil; -// -///** -// * DisplayUtil helps to calculate screen size conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class DisplayUtil { -// -// public static int getWidth() { -// Display display = WindowManagerUtil.getDefaultDisplay(); -// if (APILevel.require(13)) { -// Point size = new Point(); -// display.getSize(size); -// return size.x; -// } else { -// return display.getWidth(); -// } -// } -// -// public static int getHeight() { -// Display display = WindowManagerUtil.getDefaultDisplay(); -// if (APILevel.require(13)) { -// Point size = new Point(); -// display.getSize(size); -// return size.y; -// } else { -// return display.getHeight(); -// } -// } -// -// public static Rotation getRotation() { -// if (APILevel.require(8)) -// return Rotation.fromValue(WindowManagerUtil.getDefaultDisplay().getRotation()); -// else -// return Rotation.fromValue(WindowManagerUtil.getDefaultDisplay().getOrientation()); -// } -// -// public static boolean isPortrait() { -// return getHeight() >= getWidth(); -// } -// -// public static boolean isLandscape() { -// return getHeight() < getWidth(); -// } -// -// public static int getStatusBarHeight() { -// int resourceId = ResourcesUtil.getIdentifier("status_bar_height", "dimen", "android"); -// return resourceId > 0 ? -// ResourcesUtil.getDimensionPixelSize(resourceId) : -// 0; -// } -// -// public static int getToolbarHeight() { -// return getActionBarHeight(); -// } -// -// public static int getActionBarHeight() { -// TypedValue tv = new TypedValue(); -// return ThemeUtil.resolveAttribute(android.R.attr.actionBarSize, tv, true) ? -// TypedValueUtil.complexToDimensionPixelSize(tv.data) : -// 0; -// } -// -// public static int getNavigationBarHeight() { -// int resourceId = ResourcesUtil.getIdentifier("navigation_bar_height", "dimen", "android"); -// return resourceId > 0 ? -// ResourcesUtil.getDimensionPixelSize(resourceId) : -// 0; -// } -//} diff --git a/utils/src/main/java/kr/lunaticbum/utils/ui/KeyboardUtil.java b/utils/src/main/java/kr/lunaticbum/utils/ui/KeyboardUtil.java deleted file mode 100644 index 76c12c0a..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/ui/KeyboardUtil.java +++ /dev/null @@ -1,184 +0,0 @@ -//package kr.lunaticbum.utils.ui; -// -//import android.annotation.TargetApi; -//import android.app.Activity; -//import android.app.Dialog; -//import android.content.Context; -//import android.os.Build; -//import android.os.Bundle; -//import android.view.LayoutInflater; -//import android.view.MenuItem; -//import android.view.View; -//import android.view.ViewGroup; -//import android.view.inputmethod.InputMethodManager; -// -//import androidx.fragment.app.Fragment; -// -//import kr.lunaticbum.Base; -//import kr.lunaticbum.utils.etc.ThreadUtil; -//import kr.lunaticbum.converters.UnitConverter; -//import kr.lunaticbum.utils.service.ServiceUtil; -// -///** -// * KeyboardUtil helps to show and hide keyboard conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class KeyboardUtil { -// -// public static int height = 0; -// public static final String KEYBOARD_UTIL_PREF = "KEYBOARD_UTIL_PREF"; -// public static final String KEYBOARD_HEIGHT = "KEYBOARD_HEIGHT"; -// public static final int DEFAULT_KEYBOARD_HEIGHT = 200; -// -// /** -// * Helps to show keyboard in {@link Activity#onCreate(Bundle)}, {@link Activity#onStart()}, -// * {@link Activity#onResume()}, -// * {@link MenuItem.OnActionExpandListener#onMenuItemActionExpand(MenuItem)}, -// * {@link Fragment#onCreateView(LayoutInflater, ViewGroup, Bundle)} and etc -// * This method guarantee to show keyboard every time. -// */ -// public static void show(final View view) { -// if (view == null) -// return; -// -// view.postDelayed(new Runnable() { -// @Override -// public void run() { -// showInMainThread(view); -// } -// }, 200); -// } -// -// /** -// * Please note that this method does not guarantee to show keyboard every time. To guarantee -// * to show keyboard, please use {@link #show(View)} instead. It doesn't have any delay, use -// * this method when it is able to show keyboard immediately. EX) when user click a button to -// * show keyboard -// */ -// public static void showImmediately(final View view) { -// if (view == null) -// return; -// -// if (ThreadUtil.isMain()) { -// showInMainThread(view); -// } else { -// view.post(new Runnable() { -// @Override -// public void run() { -// showInMainThread(view); -// } -// }); -// } -// } -// -// private static void showInMainThread(final View view) { -// if (view == null) -// return; -// -// view.requestFocus(); -// ServiceUtil.getInputMethodManager().showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); -// } -// -// public static void hide(Fragment fragment) { -// if (fragment == null || fragment.getActivity() == null) -// return; -// -// hide(fragment.getActivity()); -// } -// -// public static void hide(Fragment fragment, boolean clearFocus) { -// if (fragment == null || fragment.getActivity() == null) -// return; -// -// hide(fragment.getActivity()); -// } -// -// public static void hide(Activity activity) { -// hide(activity, true); -// } -// -// public static void hide(Activity activity, boolean clearFocus) { -// if (activity == null) -// return; -// -// hide(activity.getCurrentFocus(), clearFocus); -// } -// -// @TargetApi(Build.VERSION_CODES.HONEYCOMB) -// public static void hide(android.app.Fragment fragment) { -// hide(fragment, true); -// } -// -// @TargetApi(Build.VERSION_CODES.HONEYCOMB) -// public static void hide(android.app.Fragment fragment, boolean clearFocus) { -// if (fragment == null || fragment.getActivity() == null) -// return; -// -// hide(fragment.getActivity(), clearFocus); -// } -// -// public static void hide(Dialog dialog) { -// hide(dialog, true); -// } -// -// public static void hide(Dialog dialog, boolean clearFocus) { -// if (dialog == null) -// return; -// -// hide(dialog.getCurrentFocus(), clearFocus); -// } -// -// public static void hide(View view) { -// hide(view, true); -// } -// -// public static void hide(View view, boolean clearFocus) { -// if (view == null) -// return; -// -// if (clearFocus) { -// view.clearFocus(); -// } -// -// ServiceUtil.getInputMethodManager().hideSoftInputFromWindow(view.getWindowToken(), 0); -// } -// -// public static int getHeight() { -// if (height <= 0) -// height = Base.getContext().getSharedPreferences(KEYBOARD_UTIL_PREF, Context.MODE_PRIVATE).getInt(KEYBOARD_HEIGHT, UnitConverter.dpToPx(DEFAULT_KEYBOARD_HEIGHT)); -// -// return height; -// } -// -// public static void setHeight(int height) { -// KeyboardUtil.height = height; -// Base.getContext().getSharedPreferences(KEYBOARD_UTIL_PREF, Context.MODE_PRIVATE).edit().putInt(KEYBOARD_HEIGHT, height).apply(); -// } -// -//// coordinatorLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { -//// @Override -//// public void onGlobalLayout() { -//// Rect r = new Rect(); -//// coordinatorLayout.getWindowVisibleDisplayFrame(r); -//// if (ResourcesUtil.navigationBarHeight == -1) { -//// ResourcesUtil.navigationBarHeight = coordinatorLayout.getRootView().getHeight() - r.height() - ResourcesUtil.statusBarHeight; -//// } -//// int usableHeight = coordinatorLayout.getRootView().getHeight() - ResourcesUtil.statusBarHeight - ResourcesUtil.navigationBarHeight; -//// int keyboardHeight = usableHeight - r.height(); -//// if (isKeyboardOpened) { -//// if (keyboardHeight < 100) { -//// onKeyboardChanged(usableHeight, keyboardHeight, false); -//// isKeyboardOpened = false; -//// } -//// } else { -//// if (keyboardHeight > 100) { -//// onKeyboardChanged(usableHeight, keyboardHeight, true); -//// isKeyboardOpened = true; -//// } -//// } -//// } -//// }); -//} -////TODO: Support keyboard show and hide listener -////TODO: Keyboard height \ No newline at end of file diff --git a/utils/src/main/java/kr/lunaticbum/utils/ui/ViewUtil.java b/utils/src/main/java/kr/lunaticbum/utils/ui/ViewUtil.java deleted file mode 100644 index 0c1d1cf8..00000000 --- a/utils/src/main/java/kr/lunaticbum/utils/ui/ViewUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -//package kr.lunaticbum.utils.ui; -// -//import android.graphics.drawable.Drawable; -//import android.view.View; -// -//import androidx.annotation.DrawableRes; -// -//import kr.lunaticbum.Base; -//import kr.lunaticbum.utils.etc.APILevel; -// -///** -// * ViewUtil helps to set background drawable conveniently. -// * -// * @author Leonardo Taehwan Kim -// */ -//public class ViewUtil { -// -// public static void setBackground(View view, Drawable drawable) { -// if (view == null) -// return; -// -// if (APILevel.require(16)) { -// view.setBackground(drawable); -// } else { -// view.setBackgroundDrawable(drawable); -// } -// } -// -// public static void setBackground(View view, @DrawableRes int drawableRes) { -// if (view == null) -// return; -// -// if (APILevel.require(16)) { -// view.setBackground(Base.getResources().getDrawable(drawableRes)); -// } else { -// view.setBackgroundDrawable(Base.getResources().getDrawable(drawableRes)); -// } -// } -//} \ No newline at end of file