/* * Copyright (C) 2023 The Android Open Source Project * * 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 com.android.wallpaper.picker.preview.ui.fragment import android.app.Activity.RESULT_OK import android.content.Context import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.SurfaceView import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.Toolbar import androidx.activity.result.contract.ActivityResultContract import androidx.activity.result.contract.ActivityResultContracts import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController import com.android.wallpaper.R import com.android.wallpaper.picker.AppbarFragment import com.android.wallpaper.picker.preview.ui.binder.FullWallpaperPreviewBinder import com.android.wallpaper.picker.preview.ui.fragment.SmallPreviewFragment.Companion.ARG_EDIT_INTENT import com.android.wallpaper.picker.preview.ui.viewmodel.PreviewActionsViewModel import com.android.wallpaper.picker.preview.ui.viewmodel.WallpaperPreviewViewModel import com.android.wallpaper.util.DisplayUtils import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject /** Shows full preview with an edit activity overlay. */ @AndroidEntryPoint(AppbarFragment::class) class CreativeEditPreviewFragment : Hilt_CreativeEditPreviewFragment() { @Inject @ApplicationContext lateinit var appContext: Context @Inject lateinit var displayUtils: DisplayUtils private lateinit var currentView: View private val wallpaperPreviewViewModel by activityViewModels() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { currentView = inflater.inflate(R.layout.fragment_full_preview, container, false) setUpToolbar(currentView, true, true) wallpaperPreviewViewModel.setDefaultFullPreviewConfigViewModel( deviceDisplayType = displayUtils.getCurrentDisplayType(requireActivity()), ) currentView.requireViewById(R.id.toolbar).isVisible = false currentView.requireViewById(R.id.workspace_surface).isVisible = false currentView.requireViewById