[Android] Alert dialog for advertising new app

Geoffrey Métais git at videolan.org
Fri Dec 19 17:33:10 CET 2014


vlc-ports/android | branch: 1.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Dec 19 17:28:12 2014 +0100| [60fb6ca97835f6613e02f0fa1a825c4d5c55a532] | committer: Geoffrey Métais

Alert dialog for advertising new app

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=60fb6ca97835f6613e02f0fa1a825c4d5c55a532
---

 vlc-android/res/values/strings.xml                 |    4 ++
 .../src/org/videolan/vlc/gui/MainActivity.java     |    5 ++
 .../src/org/videolan/vlc/gui/StartUpDialog.java    |   69 ++++++++++++++++++++
 3 files changed, 78 insertions(+)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index f5f7180..e7bc5a6 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -297,6 +297,10 @@
     <string name="drawer_open">Open navigation drawer</string>
     <string name="drawer_close">Close navigation drawer</string>
 
+    <string name="new_app">New Application available</string>
+    <string name="new_app_msg">VLC for Android Beta test has ended. From now, new versions will only be published for the new application.</string>
+    <string name="new_app_go">Go get it</string>
+
     <string-array name="hardware_acceleration_list">
         <item>@string/automatic</item>
         <item>@string/hardware_acceleration_disabled</item>
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 5a39bc9..ef26533 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -320,6 +320,11 @@ public class MainActivity extends ActionBarActivity {
         super.onPostCreate(savedInstanceState);
         // Sync the toggle state after onRestoreInstanceState has occurred.
         mDrawerToggle.syncState();
+        if ("org.videolan.vlc.betav7neon".equals(getPackageName())) {
+            StartUpDialog newFragment = StartUpDialog.newInstance();
+            newFragment.show(getSupportFragmentManager(), "dialog");
+        }
+
     }
 
     @TargetApi(Build.VERSION_CODES.HONEYCOMB)
diff --git a/vlc-android/src/org/videolan/vlc/gui/StartUpDialog.java b/vlc-android/src/org/videolan/vlc/gui/StartUpDialog.java
new file mode 100644
index 0000000..dc5fde3
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/gui/StartUpDialog.java
@@ -0,0 +1,69 @@
+/**
+ * **************************************************************************
+ * StartUpDialog.java
+ * ****************************************************************************
+ * Copyright © 2011-2014 VLC authors and VideoLAN
+ * <p/>
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * <p/>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * <p/>
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * ***************************************************************************
+ */
+
+package org.videolan.vlc.gui;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+
+import org.videolan.vlc.R;
+
+public class StartUpDialog extends DialogFragment {
+
+    public static StartUpDialog newInstance() {
+        return new StartUpDialog();
+    }
+
+    @Override
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+
+        return new AlertDialog.Builder(getActivity())
+                .setIcon(R.drawable.ic_cone_o)
+                .setTitle(R.string.new_app)
+                .setMessage(R.string.new_app_msg)
+                .setPositiveButton(R.string.new_app_go,
+                        new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int whichButton) {
+                                try {
+                                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=org.videolan.vlc")));
+                                } catch (android.content.ActivityNotFoundException anfe) {
+                                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=org.videolan.vlc")));
+                                }
+                            }
+                        }
+                )
+                .setNegativeButton(android.R.string.cancel,
+                        new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog,
+                                                int which) {
+                                dismiss();
+                            }
+                        })
+                .create();
+    }
+
+}



More information about the Android mailing list