diff options
author | Chung-yih Wang <cywang@google.com> | 2011-11-11 20:46:43 +0800 |
---|---|---|
committer | Chung-yih Wang <cywang@google.com> | 2011-11-14 15:05:20 +0800 |
commit | 419d20ae123f53226ccefb7d28d8a40add8ffd0a (patch) | |
tree | b40c50d9fef68804ce91190a44101fc6a2af00fa /src/com/android/camera/ui/RotateTextToast.java | |
parent | 8d51fc281ca4e14c87eac278d153e162c0e1fcf2 (diff) | |
download | LegacyCamera-419d20ae123f53226ccefb7d28d8a40add8ffd0a.zip LegacyCamera-419d20ae123f53226ccefb7d28d8a40add8ffd0a.tar.gz LegacyCamera-419d20ae123f53226ccefb7d28d8a40add8ffd0a.tar.bz2 |
Add a rotatable toast class.
bug:5575970
In order to show the toast in a landscape orientation with portrait
layout. The rotatable toast helper class is implementated and is also
applied for first-hint toast messages.
Change-Id: I942e87df1c1a4509d01cd41e2ecbdc2e2dfec049
Diffstat (limited to 'src/com/android/camera/ui/RotateTextToast.java')
-rw-r--r-- | src/com/android/camera/ui/RotateTextToast.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/com/android/camera/ui/RotateTextToast.java b/src/com/android/camera/ui/RotateTextToast.java new file mode 100644 index 0000000..8ff381a --- /dev/null +++ b/src/com/android/camera/ui/RotateTextToast.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011 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.camera.ui; + +import com.android.camera.R; +import com.android.camera.Util; + +import android.app.Activity; +import android.os.Handler; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +public class RotateTextToast { + private static final int TOAST_DURATION = 5000; // milliseconds + ViewGroup mLayoutRoot; + RotateLayout mToast; + Handler mHandler; + + public RotateTextToast(Activity activity, int textResourceId, int orientation) { + mLayoutRoot = (ViewGroup) activity.getWindow().getDecorView(); + LayoutInflater inflater = activity.getLayoutInflater(); + View v = inflater.inflate(R.layout.rotate_text_toast, mLayoutRoot); + mToast = (RotateLayout) v.findViewById(R.id.rotate_toast); + TextView tv = (TextView) mToast.findViewById(R.id.message); + tv.setText(textResourceId); + mToast.setOrientation(orientation); + mHandler = new Handler(); + } + + private final Runnable mRunnable = new Runnable() { + public void run() { + Util.fadeOut(mToast); + mLayoutRoot.removeView(mToast); + mToast = null; + } + }; + + public void show() { + mToast.setVisibility(View.VISIBLE); + mHandler.postDelayed(mRunnable, TOAST_DURATION); + } +} |