Skip to content

Commit

Permalink
Internal changes
Browse files Browse the repository at this point in the history
+ Reworked google store dialog
  • Loading branch information
massivemadness committed May 11, 2019
1 parent a3c059a commit 87027a7
Show file tree
Hide file tree
Showing 27 changed files with 297 additions and 175 deletions.
17 changes: 0 additions & 17 deletions .gitattributes

This file was deleted.

45 changes: 38 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
# MacOS files
.DS_Store

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
#*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
/ultimate

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
Binary file removed .images_console/google_play_logo.png
Binary file not shown.
83 changes: 83 additions & 0 deletions .images_console/google_play_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class LocalFileRepository(
val files = FileConverter.toFile(parent)
.listFiles()
.map(FileConverter::toModel)
.toMutableList()
.toList()
emitter.onSuccess(files)
}
}
Expand Down Expand Up @@ -97,19 +97,23 @@ class LocalFileRepository(
override fun propertiesOf(fileModel: FileModel): Single<PropertiesModel> {
return Single.create { emitter ->
val realFile = File(fileModel.path)
val result = PropertiesModel(
fileModel.name,
fileModel.path,
fileModel.lastModified.formatAsDate(),
realFile.size().formatAsSize(),
getLineCount(realFile),
getWordCount(realFile),
getCharCount(realFile),
realFile.canRead(),
realFile.canWrite(),
realFile.canExecute()
)
emitter.onSuccess(result)
if(realFile.exists()) {
val result = PropertiesModel(
fileModel.name,
fileModel.path,
fileModel.lastModified.formatAsDate(),
realFile.size().formatAsSize(),
getLineCount(realFile),
getWordCount(realFile),
getCharCount(realFile),
realFile.canRead(),
realFile.canWrite(),
realFile.canExecute()
)
emitter.onSuccess(result)
} else {
emitter.onError(FileNotFoundException())
}
}
}

Expand All @@ -121,6 +125,7 @@ class LocalFileRepository(
return Single.create { emitter ->
database.documentDao().insert(DocumentConverter.toCache(documentModel)) // Save to Database

// Load from Storage
val file = File(documentModel.path)
val text = if(file.exists()) {
file.inputStream().bufferedReader().use(BufferedReader::readText)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to the Light Team Software (Light Team) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The Light Team licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.lightteam.modpeide.presentation.common.dialogs

import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.view.View
import androidx.appcompat.app.AlertDialog
import com.lightteam.modpeide.BaseApplication
import com.lightteam.modpeide.R

class DialogStore(context: Context, themeResId: Int) : AlertDialog(context, themeResId) {

class Builder(context: Context) : AlertDialog.Builder(context, R.style.Theme_MaterialComponents_Light_Dialog_Alert) {

init {
setView(R.layout.dialog_store)
}

override fun show(): AlertDialog {
val dialog = super.show()
val buttonGetIt = dialog.findViewById<View>(R.id.button_get_it)
val buttonMaybeLater = dialog.findViewById<View>(R.id.button_maybe_later)

buttonGetIt?.setOnClickListener {
val packageName = BaseApplication.ULTIMATE
try {
val intent = Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=$packageName"))
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
val intent = Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=$packageName"))
context.startActivity(intent)
}
dialog.dismiss()
}
buttonMaybeLater?.setOnClickListener {
dialog.dismiss()
}
return dialog
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ package com.lightteam.modpeide.presentation.main.activities

import android.Manifest
import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.net.Uri
import android.os.Bundle
import android.text.InputType
import android.view.Gravity
Expand All @@ -46,14 +44,13 @@ import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.customview.getCustomView
import com.afollestad.materialdialogs.input.getInputField
import com.afollestad.materialdialogs.input.input
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.tabs.TabLayout
import com.google.android.material.textfield.TextInputEditText
import com.lightteam.modpeide.BaseApplication
import com.lightteam.modpeide.R
import com.lightteam.modpeide.databinding.ActivityMainBinding
import com.lightteam.modpeide.domain.model.DocumentModel
import com.lightteam.modpeide.presentation.base.activities.BaseActivity
import com.lightteam.modpeide.presentation.common.dialogs.DialogStore
import com.lightteam.modpeide.presentation.main.activities.interfaces.OnPanelClickListener
import com.lightteam.modpeide.presentation.main.activities.utils.ToolbarManager
import com.lightteam.modpeide.presentation.main.customview.ExtendedKeyboard
Expand All @@ -74,7 +71,7 @@ class MainActivity : BaseActivity(),

companion object {
const val REQUEST_READ_WRITE = 1 // Запрос разрешений через диалог
const val REQUEST_READ_WRITE2 = 2 // Запрос разрешений через настроеки системы
const val REQUEST_READ_WRITE2 = 2 // Запрос разрешений через настройки системы
}

@Inject
Expand Down Expand Up @@ -403,29 +400,6 @@ class MainActivity : BaseActivity(),
return isOpen
}

private fun showStoreDialog() {
val dialog = MaterialAlertDialogBuilder(this, R.style.Theme_MaterialComponents_Light_Dialog_Alert)
.setView(R.layout.dialog_store)
.show()

dialog.findViewById<View>(R.id.button_get_it)?.setOnClickListener {
val packageName = BaseApplication.ULTIMATE
try {
val intent = Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=$packageName"))
startActivity(intent)
} catch (e: ActivityNotFoundException) {
val intent = Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=$packageName"))
startActivity(intent)
}
dialog.dismiss()
}
dialog.findViewById<View>(R.id.button_continue)?.setOnClickListener {
dialog.dismiss()
}
}

// region OTHER

override fun onKey(char: String) {
Expand Down Expand Up @@ -607,7 +581,7 @@ class MainActivity : BaseActivity(),
viewModel.toastEvent.value = R.string.message_no_open_files
}
} else {
showStoreDialog()
DialogStore.Builder(this).show()
}
}

Expand All @@ -632,7 +606,7 @@ class MainActivity : BaseActivity(),
viewModel.toastEvent.value = R.string.message_no_open_files
}
} else {
showStoreDialog()
DialogStore.Builder(this).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.lightteam.modpeide.R
import com.lightteam.modpeide.domain.model.FileModel
import com.lightteam.modpeide.databinding.ItemFileBinding
import com.lightteam.modpeide.presentation.main.adapters.interfaces.RecyclerSelection
import com.lightteam.modpeide.presentation.main.adapters.FileAdapter.FileViewHolder
import com.lightteam.modpeide.presentation.main.adapters.utils.FileDiffCallback

class FileAdapter(private val recyclerSelection: RecyclerSelection) : RecyclerView.Adapter<FileViewHolder>() {

private val data: MutableList<FileModel> = mutableListOf()
private var data: List<FileModel> = emptyList()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FileViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_file, parent, false)
Expand All @@ -41,11 +43,12 @@ class FileAdapter(private val recyclerSelection: RecyclerSelection) : RecyclerVi
override fun getItemCount(): Int = data.size

fun setData(newList: List<FileModel>) {
data.clear()
data.addAll(newList)
}
val diffCallback = FileDiffCallback(data, newList)
val diffResult = DiffUtil.calculateDiff(diffCallback)

fun getData(): List<FileModel> = data
data = newList
diffResult.dispatchUpdatesTo(this)
}

inner class FileViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {

Expand Down
Loading

0 comments on commit 87027a7

Please sign in to comment.