| @@ -1,98 +1,90 @@ | ||
| package com.ushahidi.android.app.views; | ||
|
|
||
| import android.content.Context; | ||
| import android.content.Intent; | ||
| import android.content.pm.PackageManager.NameNotFoundException; | ||
| import android.net.Uri; | ||
| import android.support.v4.app.FragmentActivity; | ||
| import android.text.TextUtils; | ||
| import android.util.Log; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.Button; | ||
| import android.widget.TextView; | ||
|
|
||
| import com.ushahidi.android.app.R; | ||
|
|
||
| public class AboutView extends com.ushahidi.android.app.views.View { | ||
|
|
||
| private TextView version; | ||
|
|
||
| public AboutView(FragmentActivity activity) { | ||
| super(activity); | ||
| // VERSION | ||
| version = (TextView) activity.findViewById(R.id.version); | ||
| try { | ||
| StringBuilder sBuilder = new StringBuilder(); | ||
| sBuilder.append("v"); | ||
| sBuilder.append(activity.getPackageManager().getPackageInfo( | ||
| activity.getPackageName(), 0).versionName); | ||
| version.setText(sBuilder.toString()); | ||
| } catch (NameNotFoundException e) { | ||
| Log.e("About", "NameNotFoundException", e); | ||
| version.setText(""); | ||
| } | ||
|
|
||
| // BUTTONS | ||
| setButtonVisibility((Button) activity.findViewById(R.id.media_link), | ||
| activity.getString(R.string.media_url), activity); | ||
| setButtonVisibility((Button) activity.findViewById(R.id.team_link), | ||
| activity.getString(R.string.team_url), activity); | ||
| setButtonVisibility((Button) activity.findViewById(R.id.twitter_link), | ||
| activity.getString(R.string.twitter_url), activity); | ||
| setButtonVisibility((Button) activity.findViewById(R.id.facebook_link), | ||
| activity.getString(R.string.facebook_url), activity); | ||
| setButtonVisibility((Button) activity.findViewById(R.id.contact_link), | ||
| activity.getString(R.string.contact_url), activity); | ||
| } | ||
|
|
||
| public AboutView(ViewGroup viewGroup, Context context) { | ||
| super(viewGroup); | ||
|
|
||
| // VERSION | ||
| version = (TextView) viewGroup.findViewById(R.id.version); | ||
| try { | ||
| version.setText(context.getPackageManager().getPackageInfo( | ||
| context.getPackageName(), 0).versionName); | ||
| } catch (NameNotFoundException e) { | ||
| Log.e("About", "NameNotFoundException", e); | ||
| version.setText(""); | ||
| } | ||
|
|
||
| // BUTTONS | ||
| setButtonVisibility((Button) viewGroup.findViewById(R.id.media_link), | ||
| context.getString(R.string.media_url), context); | ||
| setButtonVisibility((Button) viewGroup.findViewById(R.id.team_link), | ||
| context.getString(R.string.team_url), context); | ||
| setButtonVisibility((Button) viewGroup.findViewById(R.id.twitter_link), | ||
| context.getString(R.string.twitter_url), context); | ||
| setButtonVisibility( | ||
| (Button) viewGroup.findViewById(R.id.facebook_link), | ||
| context.getString(R.string.facebook_url), context); | ||
| setButtonVisibility((Button) viewGroup.findViewById(R.id.contact_link), | ||
| context.getString(R.string.contact_url), context); | ||
| } | ||
|
|
||
| private void setButtonVisibility(final Button button, final String url, | ||
| final Context context) { | ||
| if (!TextUtils.isEmpty(url)) { | ||
| button.setVisibility(View.VISIBLE); | ||
| button.setOnClickListener(new View.OnClickListener() { | ||
| public void onClick(View v) { | ||
| context.startActivity(new Intent( | ||
| android.content.Intent.ACTION_VIEW, Uri.parse(url))); | ||
| } | ||
| }); | ||
| } else { | ||
| button.setVisibility(View.GONE); | ||
| } | ||
| } | ||
| } |
| @@ -13,8 +13,6 @@ | ||
|
|
||
| import com.google.android.maps.OverlayItem; | ||
| import com.ushahidi.android.app.R; | ||
|
|
||
| public class BalloonOverlayView<Item extends OverlayItem> extends FrameLayout { | ||
|
|
||
| @@ -20,7 +20,6 @@ | ||
|
|
||
| package com.ushahidi.android.app.views; | ||
|
|
||
| import android.app.Activity; | ||
| import android.view.View; | ||
| import android.widget.ArrayAdapter; | ||
| @@ -0,0 +1,134 @@ | ||
| /** | ||
| ** Copyright (c) 2010 Ushahidi Inc | ||
| ** All rights reserved | ||
| ** Contact: team@ushahidi.com | ||
| ** Website: http://www.ushahidi.com | ||
| ** | ||
| ** GNU Lesser General Public License Usage | ||
| ** This file may be used under the terms of the GNU Lesser | ||
| ** General Public License version 3 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU Lesser General Public License version 3 requirements | ||
| ** will be met: http://www.gnu.org/licenses/lgpl.html. | ||
| ** | ||
| ** | ||
| ** If you have questions regarding the use of this file, please contact | ||
| ** Ushahidi developers at team@ushahidi.com. | ||
| ** | ||
| **/ | ||
| package com.ushahidi.android.app.views; | ||
|
|
||
| import android.content.Context; | ||
| import android.graphics.Bitmap; | ||
| import android.support.v4.app.FragmentActivity; | ||
| import android.util.Log; | ||
| import android.view.animation.Animation; | ||
| import android.view.animation.AnimationUtils; | ||
| import android.webkit.WebSettings; | ||
| import android.webkit.WebView; | ||
| import android.webkit.WebViewClient; | ||
| import android.widget.ProgressBar; | ||
| import android.widget.Toast; | ||
| import android.widget.ViewAnimator; | ||
|
|
||
| import com.ushahidi.android.app.R; | ||
|
|
||
| /** | ||
| * @author eyedol | ||
| * | ||
| */ | ||
| public class ReportNewsView extends View { | ||
|
|
||
| public ViewAnimator viewAnimator; | ||
|
|
||
| public WebView webView; | ||
|
|
||
| public Context context; | ||
|
|
||
| private ProgressBar loadingSpinner; | ||
|
|
||
| public String url; | ||
|
|
||
| private static boolean CLEAR_CACHE_ON_LOAD = false; | ||
|
|
||
| /** | ||
| * @param activity | ||
| */ | ||
| public ReportNewsView(FragmentActivity activity) { | ||
| super(activity); | ||
| this.context = activity; | ||
| viewAnimator = (ViewAnimator) activity | ||
| .findViewById(R.id.news_View_animator); | ||
| webView = (WebView) activity.findViewById(R.id.news_webview); | ||
| loadingSpinner = (ProgressBar) activity | ||
| .findViewById(R.id.news_loading_spinner); | ||
| } | ||
|
|
||
| public void goNext(String url) { | ||
| Animation out = AnimationUtils.loadAnimation(context, | ||
| android.R.anim.slide_out_right); | ||
| Animation in = AnimationUtils.loadAnimation(context, | ||
| android.R.anim.slide_in_left); | ||
| viewAnimator.setInAnimation(in); | ||
| viewAnimator.setOutAnimation(out); | ||
| this.url = url; | ||
| setWebView(); | ||
| } | ||
|
|
||
| public void goPrevious(String url) { | ||
| Animation out = AnimationUtils.loadAnimation(context, R.anim.fade_in); | ||
| Animation in = AnimationUtils.loadAnimation(context, R.anim.fade_out); | ||
| viewAnimator.setInAnimation(in); | ||
| viewAnimator.setOutAnimation(out); | ||
| this.url = url; | ||
| setWebView(); | ||
| } | ||
|
|
||
| public void setWebView() { | ||
| WebSettings settings = webView.getSettings(); | ||
| settings.setJavaScriptEnabled(true); | ||
| settings.setPluginsEnabled(true); | ||
| settings.setLightTouchEnabled(true); | ||
| webView.setWebViewClient(webClient); | ||
| webView.post(new Runnable() { | ||
| public void run() { | ||
| if (CLEAR_CACHE_ON_LOAD) { | ||
| webView.clearCache(true); | ||
| } | ||
| webView.loadUrl(url); | ||
| } | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| private WebViewClient webClient = new WebViewClient() { | ||
|
|
||
| @Override | ||
| public void onPageStarted(WebView view, String url, Bitmap favicon) { | ||
| super.onPageStarted(view, url, favicon); | ||
| loadingSpinner.setVisibility(android.view.View.VISIBLE); | ||
| webView.setVisibility(android.view.View.INVISIBLE); | ||
| } | ||
|
|
||
| @Override | ||
| public void onPageFinished(WebView view, String url) { | ||
| super.onPageFinished(view, url); | ||
| loadingSpinner.setVisibility(android.view.View.GONE); | ||
| webView.setVisibility(android.view.View.VISIBLE); | ||
| } | ||
|
|
||
| @Override | ||
| public void onReceivedError(WebView view, int errorCode, | ||
| String description, String failingUrl) { | ||
|
|
||
| // TODO move this the appropriate method | ||
| Log.e(ReportVideoView.class.getSimpleName(), "Error " + errorCode | ||
| + ": " + description); | ||
| Toast.makeText(view.getContext(), | ||
| "Error " + errorCode + ": " + description, | ||
| Toast.LENGTH_LONG).show(); | ||
| super.onReceivedError(view, errorCode, description, failingUrl); | ||
| } | ||
| }; | ||
| } |
| @@ -0,0 +1,78 @@ | ||
| /** | ||
| ** Copyright (c) 2010 Ushahidi Inc | ||
| ** All rights reserved | ||
| ** Contact: team@ushahidi.com | ||
| ** Website: http://www.ushahidi.com | ||
| ** | ||
| ** GNU Lesser General Public License Usage | ||
| ** This file may be used under the terms of the GNU Lesser | ||
| ** General Public License version 3 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU Lesser General Public License version 3 requirements | ||
| ** will be met: http://www.gnu.org/licenses/lgpl.html. | ||
| ** | ||
| ** | ||
| ** If you have questions regarding the use of this file, please contact | ||
| ** Ushahidi developers at team@ushahidi.com. | ||
| ** | ||
| **/ | ||
| package com.ushahidi.android.app.views; | ||
|
|
||
| import android.content.Context; | ||
| import android.graphics.drawable.Drawable; | ||
| import android.support.v4.app.FragmentActivity; | ||
| import android.view.animation.Animation; | ||
| import android.view.animation.AnimationUtils; | ||
| import android.widget.ImageSwitcher; | ||
| import android.widget.ImageView; | ||
|
|
||
| import com.ushahidi.android.app.R; | ||
|
|
||
| /** | ||
| * @author eyedol | ||
| * | ||
| */ | ||
| public class ReportPhotoView extends View { | ||
|
|
||
| public ImageSwitcher imageSwitcher; | ||
|
|
||
| public Context context; | ||
|
|
||
| public ReportPhotoView(FragmentActivity activity) { | ||
| super(activity); | ||
| this.context = activity; | ||
| imageSwitcher = (ImageSwitcher) activity | ||
| .findViewById(R.id.imageSwitcher); | ||
| } | ||
|
|
||
| public void goNext(Drawable drawable) { | ||
| Animation out = AnimationUtils.loadAnimation(context, | ||
| android.R.anim.slide_out_right); | ||
| Animation in = AnimationUtils.loadAnimation(context, | ||
| android.R.anim.slide_in_left); | ||
| imageSwitcher.setInAnimation(in); | ||
| imageSwitcher.setOutAnimation(out); | ||
| imageSwitcher.setImageDrawable(drawable); | ||
| } | ||
|
|
||
| public void goPrevious(Drawable drawable) { | ||
| Animation out = AnimationUtils.loadAnimation(context, | ||
| R.anim.slide_left_out); | ||
| Animation in = AnimationUtils.loadAnimation(context, | ||
| R.anim.slide_right_in); | ||
| imageSwitcher.setInAnimation(in); | ||
| imageSwitcher.setOutAnimation(out); | ||
| imageSwitcher.setImageDrawable(drawable); | ||
| } | ||
|
|
||
| public ImageView imageView() { | ||
| ImageView i = new ImageView(context); | ||
| i.setScaleType(ImageView.ScaleType.FIT_CENTER); | ||
| i.setLayoutParams(new ImageSwitcher.LayoutParams( | ||
| android.view.ViewGroup.LayoutParams.MATCH_PARENT, | ||
| android.view.ViewGroup.LayoutParams.MATCH_PARENT)); | ||
| return i; | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,134 @@ | ||
| /** | ||
| ** Copyright (c) 2010 Ushahidi Inc | ||
| ** All rights reserved | ||
| ** Contact: team@ushahidi.com | ||
| ** Website: http://www.ushahidi.com | ||
| ** | ||
| ** GNU Lesser General Public License Usage | ||
| ** This file may be used under the terms of the GNU Lesser | ||
| ** General Public License version 3 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU Lesser General Public License version 3 requirements | ||
| ** will be met: http://www.gnu.org/licenses/lgpl.html. | ||
| ** | ||
| ** | ||
| ** If you have questions regarding the use of this file, please contact | ||
| ** Ushahidi developers at team@ushahidi.com. | ||
| ** | ||
| **/ | ||
| package com.ushahidi.android.app.views; | ||
|
|
||
| import android.content.Context; | ||
| import android.graphics.Bitmap; | ||
| import android.support.v4.app.FragmentActivity; | ||
| import android.util.Log; | ||
| import android.view.animation.Animation; | ||
| import android.view.animation.AnimationUtils; | ||
| import android.webkit.WebSettings; | ||
| import android.webkit.WebView; | ||
| import android.webkit.WebViewClient; | ||
| import android.widget.ProgressBar; | ||
| import android.widget.Toast; | ||
| import android.widget.ViewAnimator; | ||
|
|
||
| import com.ushahidi.android.app.R; | ||
|
|
||
| /** | ||
| * @author eyedol | ||
| * | ||
| */ | ||
| public class ReportVideoView extends View { | ||
|
|
||
| public ViewAnimator viewAnimator; | ||
|
|
||
| public WebView webView; | ||
|
|
||
| public Context context; | ||
|
|
||
| private ProgressBar loadingSpinner; | ||
|
|
||
| public String url; | ||
|
|
||
| private static boolean CLEAR_CACHE_ON_LOAD = false; | ||
|
|
||
| /** | ||
| * @param activity | ||
| */ | ||
| public ReportVideoView(FragmentActivity activity) { | ||
| super(activity); | ||
| this.context = activity; | ||
| viewAnimator = (ViewAnimator) activity | ||
| .findViewById(R.id.videoViewAnimator); | ||
| webView = (WebView) activity.findViewById(R.id.videoWebView); | ||
| loadingSpinner = (ProgressBar) activity | ||
| .findViewById(R.id.loading_spinner); | ||
| } | ||
|
|
||
| public void goNext(String url) { | ||
| Animation out = AnimationUtils.loadAnimation(context, | ||
| android.R.anim.slide_out_right); | ||
| Animation in = AnimationUtils.loadAnimation(context, | ||
| android.R.anim.slide_in_left); | ||
| viewAnimator.setInAnimation(in); | ||
| viewAnimator.setOutAnimation(out); | ||
| this.url = url; | ||
| setWebView(); | ||
| } | ||
|
|
||
| public void goPrevious(String url) { | ||
| Animation out = AnimationUtils.loadAnimation(context, R.anim.fade_in); | ||
| Animation in = AnimationUtils.loadAnimation(context, R.anim.fade_out); | ||
| viewAnimator.setInAnimation(in); | ||
| viewAnimator.setOutAnimation(out); | ||
| this.url = url; | ||
| setWebView(); | ||
| } | ||
|
|
||
| public void setWebView() { | ||
| WebSettings settings = webView.getSettings(); | ||
| settings.setJavaScriptEnabled(true); | ||
| settings.setPluginsEnabled(true); | ||
| settings.setLightTouchEnabled(true); | ||
| webView.setWebViewClient(webClient); | ||
| webView.post(new Runnable() { | ||
| public void run() { | ||
| if (CLEAR_CACHE_ON_LOAD) { | ||
| webView.clearCache(true); | ||
| } | ||
| webView.loadUrl(url); | ||
| } | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| private WebViewClient webClient = new WebViewClient() { | ||
|
|
||
| @Override | ||
| public void onPageStarted(WebView view, String url, Bitmap favicon) { | ||
| super.onPageStarted(view, url, favicon); | ||
| loadingSpinner.setVisibility(android.view.View.VISIBLE); | ||
| webView.setVisibility(android.view.View.INVISIBLE); | ||
| } | ||
|
|
||
| @Override | ||
| public void onPageFinished(WebView view, String url) { | ||
| super.onPageFinished(view, url); | ||
| loadingSpinner.setVisibility(android.view.View.GONE); | ||
| webView.setVisibility(android.view.View.VISIBLE); | ||
| } | ||
|
|
||
| @Override | ||
| public void onReceivedError(WebView view, int errorCode, | ||
| String description, String failingUrl) { | ||
|
|
||
| // TODO move this the appropriate method | ||
| Log.e(ReportVideoView.class.getSimpleName(), "Error " + errorCode | ||
| + ": " + description); | ||
| Toast.makeText(view.getContext(), | ||
| "Error " + errorCode + ": " + description, | ||
| Toast.LENGTH_LONG).show(); | ||
| super.onReceivedError(view, errorCode, description, failingUrl); | ||
| } | ||
| }; | ||
| } |