Fixed according to https://github.com/TouchInstinct/RoboSwag/pull/45#discussion_r314240139
* Removed module "templates"
This commit is contained in:
parent
9c810c8421
commit
67f89bb9b1
|
|
@ -1,8 +1,31 @@
|
|||
package ru.touchin.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.ActivityManager
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
|
||||
fun Activity.safeStartActivityForResult(intent: Intent, requestCode: Int, options: Bundle? = null, resolveFlags: Int = 0): Boolean =
|
||||
packageManager.resolveActivity(intent, resolveFlags)?.let { startActivityForResult(intent, requestCode, options) } != null
|
||||
|
||||
/**
|
||||
* Setup task description of application for Android 5.0 and later. It is showing when user opens task bar.
|
||||
*
|
||||
* @param label Name of application to show in task bar;
|
||||
* @param iconRes Icon of application to show in task bar;
|
||||
* @param primaryColorRes Color of application to show in task bar.
|
||||
*/
|
||||
fun Activity.setupTaskDescriptor(label: String, @DrawableRes iconRes: Int, @ColorRes primaryColorRes: Int) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
val taskDescription = ActivityManager.TaskDescription(
|
||||
label,
|
||||
iconRes,
|
||||
ContextCompat.getColor(this, primaryColorRes)
|
||||
)
|
||||
setTaskDescription(taskDescription)
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,6 @@ include ':lifecycle-rx'
|
|||
include ':views'
|
||||
include ':recyclerview-adapters'
|
||||
include ':kotlin-extensions'
|
||||
include ':templates'
|
||||
include ':tabbar-navigation'
|
||||
|
||||
project(':utils').projectDir = new File(rootDir, 'utils')
|
||||
|
|
@ -31,5 +30,4 @@ project(':lifecycle-rx').projectDir = new File(rootDir, 'lifecycle-rx')
|
|||
project(':views').projectDir = new File(rootDir, 'views')
|
||||
project(':recyclerview-adapters').projectDir = new File(rootDir, 'recyclerview-adapters')
|
||||
project(':kotlin-extensions').projectDir = new File(rootDir, 'kotlin-extensions')
|
||||
project(':templates').projectDir = new File(rootDir, 'templates')
|
||||
project(':tabbar-navigation').projectDir = new File(rootDir, 'tabbar-navigation')
|
||||
|
|
|
|||
|
|
@ -17,9 +17,18 @@ android {
|
|||
dependencies {
|
||||
api project(":utils")
|
||||
api project(":logging")
|
||||
api project(":api-logansquare")
|
||||
|
||||
api 'androidx.multidex:multidex:2.0.1'
|
||||
|
||||
api 'net.danlew:android.joda:2.9.9.4'
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
implementation "androidx.appcompat:appcompat:$versions.appcompat"
|
||||
|
||||
implementation("com.crashlytics.sdk.android:crashlytics:$versions.crashlytics@aar") {
|
||||
transitive = true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
package ru.touchin.templates;
|
||||
package ru.touchin.roboswag.components.navigation;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.StrictMode;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.multidex.MultiDex;
|
||||
import android.util.Log;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
|
|
@ -34,6 +31,9 @@ import net.danlew.android.joda.JodaTimeAndroid;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.multidex.MultiDex;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import ru.touchin.roboswag.core.log.ConsoleLogProcessor;
|
||||
import ru.touchin.roboswag.core.log.Lc;
|
||||
|
|
@ -41,6 +41,7 @@ import ru.touchin.roboswag.core.log.LcGroup;
|
|||
import ru.touchin.roboswag.core.log.LcLevel;
|
||||
import ru.touchin.roboswag.core.log.LogProcessor;
|
||||
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
||||
import ru.touchin.templates.ApiModel;
|
||||
|
||||
/**
|
||||
* Created by Gavriil Sitnikov on 10/03/16.
|
||||
|
|
@ -21,6 +21,7 @@ package ru.touchin.roboswag.components.navigation.activities
|
|||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.PersistableBundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import ru.touchin.roboswag.components.navigation.keyboard_resizeable.KeyboardBehaviorDetector
|
||||
import ru.touchin.roboswag.components.navigation.viewcontrollers.LifecycleLoggingObserver
|
||||
|
|
@ -41,6 +42,17 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||
lifecycle.addObserver(LifecycleLoggingObserver())
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
|
||||
super.onCreate(savedInstanceState, persistentState)
|
||||
// Possible work around for market launches. See http://code.google.com/p/android/issues/detail?id=2373
|
||||
// for more details. Essentially, the market launches the main activity on top of other activities.
|
||||
// we never want this to happen. Instead, we check if we are the root and if not, we finish.
|
||||
if (!isTaskRoot && intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN == intent.action) {
|
||||
Lc.e("Finishing activity as it is launcher but not root")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
LcGroup.UI_LIFECYCLE.i("${Lc.getCodePoint(this)} requestCode: $requestCode; resultCode: $resultCode")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package ru.touchin.roboswag.components.navigation.activities
|
||||
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import ru.touchin.roboswag.components.navigation.viewcontrollers.ViewControllerNavigation
|
||||
|
||||
/**
|
||||
* Created by Daniil Borisovskii on 15/08/2019.
|
||||
* Base activity with nested navigation.
|
||||
*/
|
||||
abstract class BaseNavigationActivity : BaseActivity() {
|
||||
|
||||
protected abstract val fragmentContainerViewId: Int
|
||||
|
||||
protected open val transition = FragmentTransaction.TRANSIT_NONE
|
||||
|
||||
val navigation by lazy {
|
||||
ViewControllerNavigation<BaseNavigationActivity>(
|
||||
this,
|
||||
supportFragmentManager,
|
||||
fragmentContainerViewId,
|
||||
transition
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,7 +16,6 @@ android {
|
|||
|
||||
dependencies {
|
||||
api project(":navigation")
|
||||
api project(":templates")
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,18 @@
|
|||
package ru.touchin.roboswag.components.tabbarnavigation
|
||||
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import ru.touchin.roboswag.components.navigation.viewcontrollers.ViewControllerNavigation
|
||||
import ru.touchin.templates.TouchinActivity
|
||||
import ru.touchin.roboswag.components.navigation.activities.BaseNavigationActivity
|
||||
|
||||
abstract class BaseNavigationActivity : TouchinActivity() {
|
||||
val navigation by lazy {
|
||||
ViewControllerNavigation<BaseNavigationActivity>(
|
||||
this,
|
||||
supportFragmentManager,
|
||||
fragmentContainerViewId,
|
||||
transition
|
||||
)
|
||||
}
|
||||
/**
|
||||
* Created by Daniil Borisovskii on 15/08/2019.
|
||||
* Activity to manage tab container navigation.
|
||||
*/
|
||||
abstract class BottomNavigationActivity : BaseNavigationActivity() {
|
||||
|
||||
val innerNavigation by lazy {
|
||||
getNavigationContainer(supportFragmentManager)?.navigation ?: navigation
|
||||
}
|
||||
|
||||
protected abstract val fragmentContainerViewId: Int
|
||||
|
||||
protected open val transition = FragmentTransaction.TRANSIT_NONE
|
||||
|
||||
private fun getNavigationContainer(fragmentManager: FragmentManager?): NavigationContainerFragment? =
|
||||
fragmentManager
|
||||
?.primaryNavigationFragment
|
||||
|
|
@ -30,4 +20,5 @@ abstract class BaseNavigationActivity : TouchinActivity() {
|
|||
navigationFragment as? NavigationContainerFragment
|
||||
?: getNavigationContainer(navigationFragment.childFragmentManager)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ import androidx.fragment.app.Fragment
|
|||
import ru.touchin.roboswag.components.navigation.activities.OnBackPressedListener
|
||||
import ru.touchin.roboswag.components.navigation.viewcontrollers.ViewController
|
||||
|
||||
abstract class BaseNavigationFragment : Fragment() {
|
||||
abstract class BottomNavigationFragment : Fragment() {
|
||||
|
||||
private lateinit var bottomNavigationController: BottomNavigationController
|
||||
|
||||
|
|
@ -54,17 +54,17 @@ abstract class BaseNavigationFragment : Fragment() {
|
|||
|
||||
bottomNavigationController.attach(fragmentView.findViewById(navigationContainerViewId))
|
||||
|
||||
(activity as BaseNavigationActivity).addOnBackPressedListener(backPressedListener)
|
||||
(activity as BottomNavigationActivity).addOnBackPressedListener(backPressedListener)
|
||||
|
||||
return fragmentView
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
(activity as BaseNavigationActivity).removeOnBackPressedListener(backPressedListener)
|
||||
(activity as BottomNavigationActivity).removeOnBackPressedListener(backPressedListener)
|
||||
bottomNavigationController.detach()
|
||||
}
|
||||
|
||||
private fun getNavigationActivity() = requireActivity() as BaseNavigationActivity
|
||||
private fun getNavigationActivity() = requireActivity() as BottomNavigationActivity
|
||||
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ class NavigationContainerFragment : Fragment() {
|
|||
}
|
||||
|
||||
val navigation by lazy {
|
||||
ViewControllerNavigation<BaseNavigationActivity>(
|
||||
ViewControllerNavigation<BottomNavigationActivity>(
|
||||
requireContext(),
|
||||
childFragmentManager,
|
||||
containerViewId,
|
||||
|
|
@ -53,8 +53,8 @@ class NavigationContainerFragment : Fragment() {
|
|||
private var transition = 0
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun getViewControllerClass(): Class<out ViewController<out BaseNavigationActivity, Parcelable>> =
|
||||
arguments?.getSerializable(VIEW_CONTROLLER_CLASS_ARG) as Class<out ViewController<out BaseNavigationActivity, Parcelable>>
|
||||
fun getViewControllerClass(): Class<out ViewController<out BottomNavigationActivity, Parcelable>> =
|
||||
arguments?.getSerializable(VIEW_CONTROLLER_CLASS_ARG) as Class<out ViewController<out BottomNavigationActivity, Parcelable>>
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
/build
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion versions.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":utils")
|
||||
api project(":logging")
|
||||
api project(":api-logansquare")
|
||||
api project(":navigation")
|
||||
|
||||
api 'androidx.multidex:multidex:2.0.1'
|
||||
|
||||
api 'net.danlew:android.joda:2.9.9.4'
|
||||
|
||||
implementation "androidx.appcompat:appcompat:$versions.appcompat"
|
||||
|
||||
implementation("com.crashlytics.sdk.android:crashlytics:$versions.crashlytics@aar") {
|
||||
transitive = true
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="ru.touchin.templates"/>
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Touch Instinct
|
||||
*
|
||||
* This file is part of RoboSwag library.
|
||||
*
|
||||
* Licensed 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 ru.touchin.templates;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import ru.touchin.roboswag.components.navigation.activities.BaseActivity;
|
||||
import ru.touchin.roboswag.core.log.Lc;
|
||||
|
||||
/**
|
||||
* Created by Gavriil Sitnikov on 11/03/16.
|
||||
* Base class of activity to extends for Touch Instinct related projects.
|
||||
*/
|
||||
public abstract class TouchinActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// Possible work around for market launches. See http://code.google.com/p/android/issues/detail?id=2373
|
||||
// for more details. Essentially, the market launches the main activity on top of other activities.
|
||||
// we never want this to happen. Instead, we check if we are the root and if not, we finish.
|
||||
if (!isTaskRoot() && getIntent().hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(getIntent().getAction())) {
|
||||
Lc.e("Finishing activity as it is launcher but not root");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup task description of application for Android 5.0 and later. It is showing when user opens task bar.
|
||||
*
|
||||
* @param label Name of application to show in task bar;
|
||||
* @param iconRes Icon of application to show in task bar;
|
||||
* @param primaryColorRes Color of application to show in task bar.
|
||||
*/
|
||||
protected void setupTaskDescriptor(@NonNull final String label, @DrawableRes final int iconRes, @ColorRes final int primaryColorRes) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
final ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(label,
|
||||
iconRes,
|
||||
ContextCompat.getColor(this, primaryColorRes));
|
||||
setTaskDescription(taskDescription);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue