Move the launch activity button to the toolbar
Test: Manual Change-Id: I81155492b39d6c72b0976a738a90ed00226bc1e8
This commit is contained in:
@@ -19,6 +19,6 @@
|
|||||||
android:viewportWidth="24.0"
|
android:viewportWidth="24.0"
|
||||||
android:viewportHeight="24.0">
|
android:viewportHeight="24.0">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FF000000"
|
android:fillColor="#FFFFFFFF"
|
||||||
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z"/>
|
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@@ -95,11 +95,4 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:checkedButton="@+id/radio_launchMode_standard"
|
android:checkedButton="@+id/radio_launchMode_standard"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/launch_button"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:onClick="launchActivity"
|
|
||||||
android:text="@string/launch_activity_button" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/app_bar_launch"
|
android:id="@+id/app_bar_launch_default"
|
||||||
android:title="@string/launch_default_activities"/>
|
android:title="@string/launch_default_activities"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
android:title="@string/run_intent_tests"
|
android:title="@string/run_intent_tests"
|
||||||
android:visible="true"
|
android:visible="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/app_bar_help"
|
android:id="@+id/app_bar_help"
|
||||||
android:icon="@drawable/help_outline"
|
android:icon="@drawable/help_outline"
|
||||||
|
|||||||
43
samples/IntentPlayground/res/menu/launch_menu.xml
Normal file
43
samples/IntentPlayground/res/menu/launch_menu.xml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2019 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.
|
||||||
|
-->
|
||||||
|
<menu
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/app_bar_launch_default"
|
||||||
|
android:title="@string/launch_default_activities"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/app_bar_test"
|
||||||
|
android:icon="@drawable/icon_tests"
|
||||||
|
android:iconTint="@color/white"
|
||||||
|
android:title="@string/run_intent_tests"
|
||||||
|
android:visible="true"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/app_bar_help"
|
||||||
|
android:icon="@drawable/help_outline"
|
||||||
|
android:title="@string/help_action"
|
||||||
|
android:iconTint="@color/white"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/app_bar_launch"
|
||||||
|
android:icon="@drawable/icon_launch"
|
||||||
|
android:title="@string/launch_activity_button"
|
||||||
|
android:visible="true"
|
||||||
|
app:showAsAction="always"/>
|
||||||
|
</menu>
|
||||||
@@ -26,7 +26,6 @@ import android.support.design.widget.FloatingActionButton;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
@@ -153,13 +152,10 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.app_bar_help:
|
|
||||||
showHelpDialog();
|
|
||||||
break;
|
|
||||||
case R.id.app_bar_test:
|
case R.id.app_bar_test:
|
||||||
runIntentTests();
|
runIntentTests();
|
||||||
break;
|
break;
|
||||||
case R.id.app_bar_launch:
|
case R.id.app_bar_launch_default:
|
||||||
askToLaunchTasks();
|
askToLaunchTasks();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -215,37 +211,6 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
|||||||
.getLaunchIntentForPackage("com.example.android.intentplayground.test"));
|
.getLaunchIntentForPackage("com.example.android.intentplayground.test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and displays a help overlay on this activity.
|
|
||||||
*/
|
|
||||||
protected void showHelpDialog() {
|
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
|
||||||
LinearLayout container = findViewById(R.id.fragment_container);
|
|
||||||
container.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
|
|
||||||
ShowcaseFragment demo = new ShowcaseFragment();
|
|
||||||
demo.addStep(R.string.help_step_one, R.id.task_tree_container, () -> {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
|
||||||
TreeFragment frag = (TreeFragment) fragmentManager.findFragmentByTag(TREE_FRAGMENT);
|
|
||||||
if (frag != null) {
|
|
||||||
frag.openTask(0);
|
|
||||||
frag.openTask(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
demo.addStep(R.string.help_step_two, R.id.intent_container);
|
|
||||||
demo.addStep(R.string.help_step_three, R.id.build_intent_container,
|
|
||||||
R.id.build_intent_view);
|
|
||||||
demo.addStep(R.string.help_step_four, R.id.fragment_container_bottom,
|
|
||||||
R.id.launch_button);
|
|
||||||
demo.setScroller(findViewById(R.id.scroll_container));
|
|
||||||
demo.setOnFinish(() -> container.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE));
|
|
||||||
fragmentManager.beginTransaction()
|
|
||||||
.add(R.id.root_container, demo)
|
|
||||||
.addToBackStack(null)
|
|
||||||
.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out)
|
|
||||||
.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Intent prepareLaunchForward() {
|
protected Intent prepareLaunchForward() {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
Intent nextIntent = null;
|
Intent nextIntent = null;
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018 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.example.android.intentplayground;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.app.ActivityManager.AppTask;
|
|
||||||
import android.app.ActivityManager.RecentTaskInfo;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays details about the current task and activity.
|
|
||||||
*/
|
|
||||||
public class CurrentTaskFragment extends Fragment {
|
|
||||||
private TextView mCurrentTaskView, mCurrentActivityView, mLastTaskView, mLastActivityView;
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater,
|
|
||||||
@Nullable ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.fragment_current_task,
|
|
||||||
container, false /* attachToRoot */);
|
|
||||||
mCurrentTaskView = layout.findViewById(R.id.current_task);
|
|
||||||
mCurrentActivityView = layout.findViewById(R.id.current_activity);
|
|
||||||
mLastTaskView = layout.findViewById(R.id.last_task);
|
|
||||||
mLastActivityView = layout.findViewById(R.id.last_activity);
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
Activity activity = getActivity();
|
|
||||||
Resources res = activity.getResources();
|
|
||||||
List<AppTask> tasks = activity.getSystemService(ActivityManager.class).getAppTasks();
|
|
||||||
RecentTaskInfo currentTask = tasks.get(0).getTaskInfo();
|
|
||||||
RecentTaskInfo lastTask = tasks.size() > 1 && tasks.get(1) != null ?
|
|
||||||
tasks.get(1).getTaskInfo() : null;
|
|
||||||
mCurrentTaskView.setText(String.format(Locale.ENGLISH, "#%d", currentTask.persistentId));
|
|
||||||
mCurrentTaskView.setTextColor(res.getColor(ColorManager.getColorForTask(
|
|
||||||
currentTask.persistentId), null /* theme */));
|
|
||||||
mCurrentActivityView.setText(currentTask.topActivity.getShortClassName());
|
|
||||||
mCurrentActivityView.setTextColor(res.getColor(ColorManager.getColorForActivity(
|
|
||||||
currentTask.topActivity), null /* theme */));
|
|
||||||
if (lastTask != null) {
|
|
||||||
mLastTaskView.setText(String.format(Locale.ENGLISH, "#%d", lastTask.persistentId));
|
|
||||||
mLastTaskView.setTextColor(res.getColor(ColorManager.getColorForTask(
|
|
||||||
lastTask.persistentId), null /* theme */));
|
|
||||||
if (lastTask.topActivity != null) {
|
|
||||||
mLastActivityView.setText(lastTask.topActivity.getShortClassName());
|
|
||||||
mLastActivityView.setTextColor(res.getColor(ColorManager.getColorForActivity(
|
|
||||||
lastTask.topActivity), null /* theme */));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,6 @@ import android.util.Log;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@@ -38,6 +37,7 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -66,9 +66,10 @@ public class IntentBuilderView extends FrameLayout implements View.OnClickListen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new IntentBuilderView, in the specified mode.
|
* Constructs a new IntentBuilderView, in the specified mode.
|
||||||
|
*
|
||||||
* @param context The context of the activity that holds this view.
|
* @param context The context of the activity that holds this view.
|
||||||
* @param mode The mode to launch in (if null, default mode turns suggestions off). Passing
|
* @param mode The mode to launch in (if null, default mode turns suggestions off). Passing
|
||||||
* {@link com.example.android.intentplayground.BaseActivity.Mode} will turn on suggestions
|
* {@link BaseActivity.Mode} will turn on suggestions
|
||||||
* by default.
|
* by default.
|
||||||
*/
|
*/
|
||||||
public IntentBuilderView(@NonNull Context context, BaseActivity.Mode mode) {
|
public IntentBuilderView(@NonNull Context context, BaseActivity.Mode mode) {
|
||||||
@@ -138,13 +139,13 @@ public class IntentBuilderView extends FrameLayout implements View.OnClickListen
|
|||||||
rb.setOnClickListener(this);
|
rb.setOnClickListener(this);
|
||||||
activityRadios.addView(actRadio);
|
activityRadios.addView(actRadio);
|
||||||
});
|
});
|
||||||
mLayout.findViewById(R.id.launch_button).setOnClickListener(this);
|
|
||||||
((CompoundButton) mLayout.findViewById(R.id.suggestion_switch))
|
((CompoundButton) mLayout.findViewById(R.id.suggestion_switch))
|
||||||
.setOnCheckedChangeListener(this);
|
.setOnCheckedChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills the {@link ViewGroup} with a list separated by section
|
* Fills the {@link ViewGroup} with a list separated by section
|
||||||
|
*
|
||||||
* @param layout The layout to fill
|
* @param layout The layout to fill
|
||||||
* @param categories A map of category names to list items within that category
|
* @param categories A map of category names to list items within that category
|
||||||
* @param categoryLayoutRes the layout resource of the category header view
|
* @param categoryLayoutRes the layout resource of the category header view
|
||||||
@@ -181,13 +182,10 @@ public class IntentBuilderView extends FrameLayout implements View.OnClickListen
|
|||||||
ActivityInfo tag = (ActivityInfo) view.getTag();
|
ActivityInfo tag = (ActivityInfo) view.getTag();
|
||||||
mActivityToLaunch = new ComponentName(mContext,
|
mActivityToLaunch = new ComponentName(mContext,
|
||||||
getClass(tag.name.substring(tag.name.lastIndexOf(".") + 1)));
|
getClass(tag.name.substring(tag.name.lastIndexOf(".") + 1)));
|
||||||
} else if (view instanceof Button && view.getId() == R.id.launch_button) {
|
|
||||||
// Handles click on Launch Button
|
|
||||||
mLaunchCallback.launchActivity(currentIntent());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent currentIntent() {
|
public Intent currentIntent() {
|
||||||
LinearLayout flagBuilder = mLayout.findViewById(R.id.build_intent_flags);
|
LinearLayout flagBuilder = mLayout.findViewById(R.id.build_intent_flags);
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
// Gather flags from flag builder checkbox list
|
// Gather flags from flag builder checkbox list
|
||||||
@@ -204,9 +202,6 @@ public class IntentBuilderView extends FrameLayout implements View.OnClickListen
|
|||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnLaunchCallback(OnLaunchCallback listener) {
|
|
||||||
mLaunchCallback = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
@@ -230,7 +225,9 @@ public class IntentBuilderView extends FrameLayout implements View.OnClickListen
|
|||||||
if (mVerifyMode) {
|
if (mVerifyMode) {
|
||||||
refreshConstraints();
|
refreshConstraints();
|
||||||
getCheckedFlags().forEach(this::suggestFlags);
|
getCheckedFlags().forEach(this::suggestFlags);
|
||||||
} else enableAllFlags();
|
} else {
|
||||||
|
enableAllFlags();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +284,7 @@ public class IntentBuilderView extends FrameLayout implements View.OnClickListen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve children of a certain type from a {@link ViewGroup}.
|
* Retrieve children of a certain type from a {@link ViewGroup}.
|
||||||
|
*
|
||||||
* @param group the ViewGroup to retrieve children from.
|
* @param group the ViewGroup to retrieve children from.
|
||||||
*/
|
*/
|
||||||
protected static <T> List<T> childrenOfGroup(ViewGroup group, Class<T> viewType) {
|
protected static <T> List<T> childrenOfGroup(ViewGroup group, Class<T> viewType) {
|
||||||
@@ -300,6 +298,7 @@ public class IntentBuilderView extends FrameLayout implements View.OnClickListen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects the checkboxes for the given list of flags.
|
* Selects the checkboxes for the given list of flags.
|
||||||
|
*
|
||||||
* @param flags A list of mIntent flags to select.
|
* @param flags A list of mIntent flags to select.
|
||||||
*/
|
*/
|
||||||
public void selectFlags(List<String> flags) {
|
public void selectFlags(List<String> flags) {
|
||||||
@@ -309,8 +308,10 @@ public class IntentBuilderView extends FrameLayout implements View.OnClickListen
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects the checkboxes for the given list of flags.
|
* Selects the checkboxes for the given list of flags.
|
||||||
|
*
|
||||||
* @param flags A list of mIntent flags to select.
|
* @param flags A list of mIntent flags to select.
|
||||||
*/
|
*/
|
||||||
public void selectFlags(Collection<IntentFlag> flags) {
|
public void selectFlags(Collection<IntentFlag> flags) {
|
||||||
|
|||||||
@@ -1,7 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 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.example.android.intentplayground;
|
package com.example.android.intentplayground;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@@ -17,16 +36,21 @@ import com.example.android.intentplayground.IntentBuilderView.OnLaunchCallback;
|
|||||||
public class LaunchFragment extends Fragment {
|
public class LaunchFragment extends Fragment {
|
||||||
private IntentBuilderView mIntentBuilderView;
|
private IntentBuilderView mIntentBuilderView;
|
||||||
private BaseActivityViewModel mViewModel;
|
private BaseActivityViewModel mViewModel;
|
||||||
|
private OnLaunchCallback mOnLaunchCallback;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
mIntentBuilderView = new IntentBuilderView(getContext(), Mode.LAUNCH);
|
mIntentBuilderView = new IntentBuilderView(getContext(), Mode.LAUNCH);
|
||||||
setOnLaunchCallBack();
|
FragmentActivity activity = getActivity();
|
||||||
return mIntentBuilderView;
|
if (activity instanceof OnLaunchCallback) {
|
||||||
|
mOnLaunchCallback = (OnLaunchCallback) activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
return mIntentBuilderView;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
@@ -40,10 +64,19 @@ public class LaunchFragment extends Fragment {
|
|||||||
mViewModel.actOnFab(BaseActivityViewModel.FabAction.Hide);
|
mViewModel.actOnFab(BaseActivityViewModel.FabAction.Hide);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnLaunchCallBack() {
|
@Override
|
||||||
FragmentActivity activity = this.getActivity();
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
if (activity instanceof OnLaunchCallback) {
|
inflater.inflate(R.menu.launch_menu, menu);
|
||||||
mIntentBuilderView.setOnLaunchCallback((OnLaunchCallback) activity);
|
|
||||||
}
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.app_bar_launch && mOnLaunchCallback != null) {
|
||||||
|
mOnLaunchCallback.launchActivity(mIntentBuilderView.currentIntent());
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user