Commit 554747a7 authored by Nikolay Kazakov's avatar Nikolay Kazakov
Browse files

Первый коммит. Перевел приложение на фрагменты, чтоб на всех экранах был Navigation Drawer

parent 0a62375c
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<AndroidXmlCodeStyleSettings>
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
</AndroidXmlCodeStyleSettings>
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="testRunner" value="PLATFORM" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Kotlin2JvmCompilerArguments">
<option name="jvmTarget" value="1.8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="TerminalProjectOptionsProvider">
<option name="myStartingDirectory" value="D:\OurPrograms\AndroidStudioProject" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
/build
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
//apply plugin: 'io.fabric'
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "ru.bingosoft.mapquestapp2"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true // Для использования VectorDrawable в Fab кнопке
multiDexEnabled true
}
buildTypes {
debug {
resValue 'string', 'login', accent_login
resValue 'string', 'password', accent_password
buildConfigField "String", "urlServer", '"http://demo.bingosoft-office.ru/redevelopment/"'
}
release {
resValue 'string', 'login', ""
resValue 'string', 'password', ""
buildConfigField "String", "urlServer", '"http://demo.bingosoft-office.ru/redevelopment/"'
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.2.0'
implementation 'androidx.navigation:navigation-ui:2.2.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//MaterialDesign компоненты
implementation 'com.google.android.material:material:1.2.0-alpha02'
//Карта
implementation 'com.mapquest:mapping-android-sdk:2.0.10'
// Иконки Font Awesome
implementation 'info.androidhive:fontawesome:0.0.5'
// Database
def roomVersion = "1.1.1"
implementation "android.arch.persistence.room:runtime:$roomVersion"
kapt "android.arch.persistence.room:compiler:$roomVersion"
implementation "android.arch.persistence.room:rxjava2:$roomVersion"
// RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxkotlin:2.0.3'
// Dagger2
implementation 'com.google.dagger:dagger:2.24'
implementation 'com.google.dagger:dagger-android-support:2.24'
kapt 'com.google.dagger:dagger-android-processor:2.24'
kapt 'com.google.dagger:dagger-compiler:2.24'
// Retrofit 2 для работы с Web запросами
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
//Retrofit 2 + RxJava
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
//Retrofit 2 Logging
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
// GSON для Retrofit 2 конвертирует данные в Json
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
// RecyclerView и CardView
implementation 'androidx.cardview:cardview:1.0.0'
//implementation 'androidx.recyclerview:recyclerview:1.1.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.1.0-rc01'
// Новый логгер
implementation 'com.jakewharton.timber:timber:4.7.1'
// (Recommended) Add the Google Analytics dependency.
implementation 'com.google.firebase:firebase-analytics:17.2.2'
// Add the Firebase Crashlytics dependency.
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package ru.bingosoft.mapquestapp2
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("ru.bingosoft.mapquestapp2", appContext.packageName)
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ru.bingosoft.mapquestapp2">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.login.LoginActivity"
android:label="@string/title_activity_login"
android:theme="@style/AppTheme.NoActionBar" />
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>
</manifest>
\ No newline at end of file
package ru.bingosoft.mapquestapp2
import android.app.Application
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
import ru.bingosoft.mapquestapp2.di.DaggerAppComponent
import timber.log.Timber
import javax.inject.Inject
class App : Application(), HasAndroidInjector {
/*companion object {
lateinit var db: AppDatabase
}*/
@Inject
lateinit var androidInjector: DispatchingAndroidInjector<Any>
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
DaggerAppComponent.builder()
.application(this)
.build()
.inject(this)
/*db=Room.databaseBuilder(
this, AppDatabase::class.java, "mydatabase.db"
).build()*/
}
override fun androidInjector(): AndroidInjector<Any> = androidInjector
}
\ No newline at end of file
package ru.bingosoft.mapquestapp2
import android.os.Bundle
import android.view.Menu
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.drawerlayout.widget.DrawerLayout
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.navigation.NavigationView
import com.google.android.material.snackbar.Snackbar
class MainActivity : AppCompatActivity() {
private lateinit var appBarConfiguration: AppBarConfiguration
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val toolbar: Toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)
val fab: FloatingActionButton = findViewById(R.id.fab)
fab.setOnClickListener { view ->
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navView: NavigationView = findViewById(R.id.nav_view)
val navController = findNavController(R.id.nav_host_fragment)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
appBarConfiguration = AppBarConfiguration(
setOf(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow
), drawerLayout
)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.main, menu)
return true
}
override fun onSupportNavigateUp(): Boolean {
val navController = findNavController(R.id.nav_host_fragment)
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
}
package ru.bingosoft.mapquestapp2.api
import io.reactivex.Single
import retrofit2.http.*
import ru.bingosoft.mapquestapp2.models.Models
interface ApiService {
@POST("redis-session-php/login.php")
@FormUrlEncoded
fun getAuthorization(
@Field("fingerprint") fingerprint: String?,
@Field("login") login: String?,
@Field("password") password: String?
): Single<Models.Auth>
@GET("procs/androidAPI.php")
fun getListOrder(
@Query("action") action: String
): Single<Models.OrderList>
}
\ No newline at end of file
package ru.bingosoft.mapquestapp2.db
import androidx.room.Database
import androidx.room.RoomDatabase
import ru.bingosoft.mapquestapp2.db.Checkup.Checkup
import ru.bingosoft.mapquestapp2.db.Checkup.CheckupDao
import ru.bingosoft.mapquestapp2.db.Orders.Orders
import ru.bingosoft.mapquestapp2.db.Orders.OrdersDao
@Database(entities=arrayOf(Orders::class, Checkup::class),version = 1,exportSchema = false)
abstract class AppDatabase : RoomDatabase() {
abstract fun ordersDao(): OrdersDao?
abstract fun checkupDao(): CheckupDao?
}
\ No newline at end of file
package ru.bingosoft.mapquestapp2.db.Checkup
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.ForeignKey.CASCADE
import androidx.room.PrimaryKey
import ru.bingosoft.mapquestapp2.db.Orders.Orders
@Entity(tableName = "Checkup", foreignKeys = arrayOf(ForeignKey(entity = Orders::class, parentColumns = ["id"], childColumns = ["idOrder"], onDelete = CASCADE)))
data class Checkup (
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var guid: String,
var text: String,
var idOrder: Long? =null
)
package ru.bingosoft.mapquestapp2.db.Checkup
import androidx.room.*
import io.reactivex.Flowable
@Dao
interface CheckupDao {
@Query("SELECT * FROM checkup")
fun getAll(): Flowable<List<Checkup>>
@Query("SELECT * FROM checkup WHERE id = :id")
fun getById(id: Long): Checkup
@Insert
fun insert(orders: Checkup)
@Update
fun update(orders: Checkup)
@Delete
fun delete(orders: Checkup)
}
\ No newline at end of file
package ru.bingosoft.mapquestapp2.db.Orders
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import com.google.gson.annotations.SerializedName
import ru.bingosoft.mapquestapp2.util.DateConverter
import java.util.*
@Entity(tableName = "Orders")
@TypeConverters(DateConverter::class)
data class Orders (
@PrimaryKey(autoGenerate = true)
@SerializedName("id")
var id: Long = 0,
@SerializedName("guid")
var guid: String,
@SerializedName("number")
var number: String? = null,
@SerializedName("name")
var name: String? = null,
@SerializedName("adress")
var adress: String? = null,
@SerializedName("contactFio")
var contactFio: String? = null,
@SerializedName("phone")
var phone: String? = null,
@SerializedName("state")
var state: String? = null,
@SerializedName("comment")
var comment: String? = null,
@SerializedName("dateCreate")
var dateCreate: Date? = null,
@SerializedName("lat")
var lat: Double = 0.0,
@SerializedName("lon")
var lon: Double = 0.0,
var checked: Boolean=false
)
package ru.bingosoft.mapquestapp2.db.Orders
import androidx.room.*
import io.reactivex.Flowable
@Dao
interface OrdersDao {
@Query("SELECT * FROM orders")
fun getAll(): Flowable<List<Orders>>
@Query("SELECT * FROM orders WHERE id = :id")
fun getById(id: Long): Orders
@Query("SELECT count(*) FROM orders")
fun getSize(): Int
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(orders: Orders)
@Update
fun update(orders: Orders)
@Delete
fun delete(orders: Orders)
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment