Add autoupdate checker
This commit is contained in:
parent
e5c3122ba7
commit
9b2c616baa
3 changed files with 497 additions and 418 deletions
|
@ -8,7 +8,6 @@
|
|||
android:background="#252525"
|
||||
android:weightSum="1"
|
||||
tools:context="in.celest.xash3d.LauncherActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_tittle"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -25,7 +24,6 @@
|
|||
android:drawablePadding="10dp"
|
||||
android:singleLine="true"
|
||||
android:gravity="center_vertical" />
|
||||
|
||||
<TabHost
|
||||
android:id="@+id/tabhost"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -35,19 +33,16 @@
|
|||
android:paddingLeft="3dp"
|
||||
android:paddingRight="3dp"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#555555"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:showDividers="middle"></TabWidget>
|
||||
|
||||
android:showDividers="middle" />
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -55,9 +50,7 @@
|
|||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/tab1"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -70,7 +63,6 @@
|
|||
android:orientation="vertical"
|
||||
android:text="@string/text_tab1"
|
||||
android:weightSum="0.6">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_path1"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -84,9 +76,7 @@
|
|||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textSize="20sp"
|
||||
android:gravity="center_vertical|center_horizontal" />
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="10dp"
|
||||
|
@ -96,8 +86,6 @@
|
|||
android:background="#444444"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="1">
|
||||
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/useVolume"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -109,23 +97,23 @@
|
|||
android:text="nothing"
|
||||
android:textOff="@string/no_volume"
|
||||
android:textOn="@string/use_volume" />
|
||||
<!--
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/use_volume"
|
||||
android:id="@+id/useVolume"/>
|
||||
-->
|
||||
|
||||
<!--<CheckBox-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:textAppearance="?android:attr/textAppearanceMedium"-->
|
||||
<!--android:text="@string/use_volume"-->
|
||||
<!--android:id="@+id/useVolume"/>-->
|
||||
|
||||
<!--<CheckBox-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:textAppearance="?android:attr/textAppearanceMedium"-->
|
||||
<!--android:text="@string/tracking"-->
|
||||
<!--android:id="@+id/Tracking"/>-->
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/tracking"
|
||||
android:id="@+id/Tracking"/>
|
||||
-->
|
||||
<Button
|
||||
android:id="@+id/button_select"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -137,14 +125,8 @@
|
|||
android:layout_marginRight="10dp"
|
||||
android:onClick="selectFolder"
|
||||
android:text="@string/select_folder" />
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tab2"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -155,7 +137,6 @@
|
|||
android:background="#333333"
|
||||
android:orientation="vertical"
|
||||
android:text="@string/text_tab2">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_path2"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -169,9 +150,7 @@
|
|||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textSize="20sp"
|
||||
android:gravity="center_vertical|center_horizontal" />
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="10dp"
|
||||
|
@ -181,7 +160,6 @@
|
|||
android:background="#444444"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_args"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -192,7 +170,6 @@
|
|||
android:layout_marginTop="20dp"
|
||||
android:text="@string/cmd_args_text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/cmdArgs"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -201,7 +178,6 @@
|
|||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="3dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_path"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -212,7 +188,6 @@
|
|||
android:layout_marginTop="3dp"
|
||||
android:text="@string/text_res_path"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/cmdPath"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -221,8 +196,6 @@
|
|||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="3dp" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_shortcut"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -241,7 +214,15 @@
|
|||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="10dp" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/check_updates"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/update_button" />
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_marginBottom="10dp"
|
||||
|
@ -252,15 +233,10 @@
|
|||
android:clickable="false" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
</TabHost>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
|
@ -269,16 +245,13 @@
|
|||
android:paddingTop="5dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_about"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
|
||||
android:onClick="aboutXash"
|
||||
android:text="@string/about_button" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_launch"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -288,9 +261,5 @@
|
|||
android:layout_weight="0.87"
|
||||
android:onClick="startXash"
|
||||
android:text="@string/launch_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Xash3D</string>
|
||||
<string name="launcher_name">Xash3D</string>
|
||||
<string name="launcher_name_test">Xash3D (test)</string>
|
||||
<string name="version_string" translatable="false">v0.17.1</string>
|
||||
|
||||
<string name="launch_button">Launch Xash3D!</string>
|
||||
<string name="cmd_args_text">Command line arguments(experts only)</string>
|
||||
|
@ -16,11 +16,11 @@
|
|||
<string name="pkgname">Mod package name (experts only)</string>
|
||||
<string name="shortcut_name">Shortcut name</string>
|
||||
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="about_main">Xash3D Android</string>
|
||||
<string name="about_copyright">SDLash3D is not affiliated with Valve or any of their partners. All copyrights reserved to their respective owners.</string>
|
||||
<string name="version_string" translatable="false">v0.17.1</string>
|
||||
<string name="about_authors">Port to Android by SDLash3D team: \n
|
||||
<!-- Seems Android skips any line breaks and tabs here. -->
|
||||
<string name="about_authors">
|
||||
Port to Android by SDLash3D team: \n
|
||||
• a1batross\n
|
||||
• mittorn \n
|
||||
• nicknekit.\n
|
||||
|
@ -28,14 +28,17 @@
|
|||
Special thanks to:\n
|
||||
• Uncle Mike for Xash3D engine\n
|
||||
• Valve for Half-Life\n
|
||||
• libSDL2 developers.\n</string>
|
||||
<string name="about_links">Follow us in:
|
||||
• <a href="https://vk.com/xashdroid">VK</a>
|
||||
• <a href="http://moddb.com/game/xash3d-android">ModDB</a>
|
||||
• <a href="https://github.com/SDLash3D">GitHub</a></string>
|
||||
<string name="about_button">About Xash3D Android</string>
|
||||
• libSDL2 developers.\n
|
||||
</string>
|
||||
<string name="about_links">
|
||||
Follow us in: \n
|
||||
• <a href="https://vk.com/xashdroid">VK</a>\n
|
||||
• <a href="http://moddb.com/game/xash3d-android">ModDB</a>\n
|
||||
• <a href="https://github.com/SDLash3D">GitHub</a>
|
||||
</string>
|
||||
<string name="about_button">About</string>
|
||||
<string name="create_shortcut_button">Create mod shortcut</string>
|
||||
<string name="select_folder">(select)</string>
|
||||
<string name="select_folder">Select game data location</string>
|
||||
|
||||
<string name="text_tab1">Normal</string>
|
||||
<string name="text_tab2">Advanced</string>
|
||||
|
@ -44,4 +47,11 @@ Special thanks to:\n
|
|||
<string name="use_volume">Gamepad support off!</string>
|
||||
<string name="no_volume">Gamepad support active!</string>
|
||||
<string name="folder">Set current folder</string>
|
||||
|
||||
<string name="update_button">Check updates on start</string>
|
||||
<string name="update_message">%s is available!</string>
|
||||
<string name="update">Update</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="no_updates">No updates was found</string>
|
||||
<string name="checking_updates">Working...</string>
|
||||
</resources>
|
||||
|
|
|
@ -2,44 +2,67 @@ package in.celest.xash3d;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.AlertDialog;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.content.Intent;
|
||||
import android.view.Window;
|
||||
import android.widget.EditText;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.io.File;
|
||||
|
||||
import android.widget.EditText;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.ToggleButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import java.net.URLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import org.json.*;
|
||||
|
||||
import in.celest.xash3d.hl.R;
|
||||
|
||||
public class LauncherActivity extends Activity {
|
||||
// public final static String ARGV = "in.celest.xash3d.MESSAGE";
|
||||
public final static int sdk = Integer.valueOf(Build.VERSION.SDK);
|
||||
public final static String UPDATE_LINK = "https://api.github.com/repos/SDLash3D/xash3d-android-project/releases/latest";
|
||||
static EditText cmdArgs;
|
||||
static ToggleButton useVolume;
|
||||
static CheckBox checkUpdates;
|
||||
static EditText resPath;
|
||||
static SharedPreferences mPref;
|
||||
static Spinner pixelSpinner;
|
||||
|
||||
String getDefaultPath()
|
||||
{
|
||||
File dir = Environment.getExternalStorageDirectory();
|
||||
|
@ -47,8 +70,10 @@ public class LauncherActivity extends Activity {
|
|||
return dir.getPath() + "/xash";
|
||||
return "/sdcard/xash";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
//super.setTheme( 0x01030005 );
|
||||
|
@ -57,7 +82,6 @@ public class LauncherActivity extends Activity {
|
|||
setContentView(R.layout.activity_launcher);
|
||||
|
||||
TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
|
||||
|
||||
tabHost.setup();
|
||||
|
||||
TabHost.TabSpec tabSpec;
|
||||
|
@ -71,6 +95,13 @@ public class LauncherActivity extends Activity {
|
|||
tabSpec.setContent(R.id.tab2);
|
||||
tabHost.addTab(tabSpec);
|
||||
|
||||
mPref = getSharedPreferences("engine", 0);
|
||||
cmdArgs = (EditText)findViewById(R.id.cmdArgs);
|
||||
useVolume = ( ToggleButton ) findViewById( R.id.useVolume );
|
||||
resPath = ( EditText ) findViewById( R.id.cmdPath );
|
||||
checkUpdates = (CheckBox)findViewById(R.id.check_updates);
|
||||
pixelSpinner = (Spinner) findViewById(R.id.pixelSpinner);
|
||||
|
||||
final String[] list = {
|
||||
"RGBA8888",
|
||||
"RGBA888",
|
||||
|
@ -79,46 +110,20 @@ public class LauncherActivity extends Activity {
|
|||
"RGBA4444",
|
||||
"RGB332"
|
||||
};
|
||||
pixelSpinner = (Spinner) findViewById(R.id.pixelSpinner);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, list);
|
||||
//ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, list, android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
|
||||
pixelSpinner.setAdapter(adapter);
|
||||
Button selectFolderButton = ( Button ) findViewById( R.id.button_select );
|
||||
selectFolderButton.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectFolder(v);
|
||||
}
|
||||
});
|
||||
((Button)findViewById( R.id.button_launch )).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startXash(v);
|
||||
}
|
||||
});
|
||||
((Button)findViewById( R.id.button_shortcut )).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createShortcut(v);
|
||||
}
|
||||
});
|
||||
((Button)findViewById( R.id.button_about )).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
aboutXash(v);
|
||||
}
|
||||
});
|
||||
// if ( Build.VERSION.SDK_INT < 21 )
|
||||
// selectFolder.setVisibility( View.GONE );
|
||||
mPref = getSharedPreferences("engine", 0);
|
||||
cmdArgs = (EditText)findViewById(R.id.cmdArgs);
|
||||
cmdArgs.setText(mPref.getString("argv","-dev 3 -log"));
|
||||
useVolume = ( ToggleButton ) findViewById( R.id.useVolume );
|
||||
useVolume.setChecked(mPref.getBoolean("usevolume",true));
|
||||
resPath = ( EditText ) findViewById( R.id.cmdPath );
|
||||
checkUpdates.setChecked(mPref.getBoolean("check_updates",true));
|
||||
resPath.setText(mPref.getString("basedir", getDefaultPath()));
|
||||
cmdArgs.setText(mPref.getString("argv","-dev 3 -log"));
|
||||
pixelSpinner.setSelection(mPref.getInt("pixelformat", 0));
|
||||
|
||||
if(mPref.getBoolean("check_updates", true))
|
||||
{
|
||||
new RetrieveJSON(true).execute(UPDATE_LINK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void startXash(View view)
|
||||
|
@ -131,6 +136,7 @@ public class LauncherActivity extends Activity {
|
|||
editor.putBoolean("usevolume",useVolume.isChecked());
|
||||
editor.putString("basedir", resPath.getText().toString());
|
||||
editor.putInt("pixelformat", pixelSpinner.getSelectedItemPosition());
|
||||
editor.putBoolean("check_updates", checkUpdates.isChecked());
|
||||
editor.commit();
|
||||
startActivity(intent);
|
||||
}
|
||||
|
@ -138,13 +144,13 @@ public class LauncherActivity extends Activity {
|
|||
public void aboutXash(View view)
|
||||
{
|
||||
final Activity a = this;
|
||||
this.runOnUiThread(new Runnable() {
|
||||
this.runOnUiThread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
final Dialog dialog = new Dialog(a);
|
||||
dialog.setContentView(R.layout.about);
|
||||
dialog.setCancelable(true);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
@ -159,10 +165,12 @@ public class LauncherActivity extends Activity {
|
|||
resPath.setEnabled(false);
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
try{
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent resultData)
|
||||
{
|
||||
if (resultCode == RESULT_OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
resPath = ( EditText ) findViewById( R.id.cmdPath );
|
||||
resPath.setText( resultData.getStringExtra("GetPath"));
|
||||
|
||||
|
@ -212,4 +220,96 @@ try{
|
|||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private class RetrieveJSON extends AsyncTask<String, Void, String> {
|
||||
InputStream is = null;
|
||||
ByteArrayOutputStream os = null;
|
||||
boolean mSilent;
|
||||
|
||||
public RetrieveJSON( boolean silent )
|
||||
{
|
||||
mSilent = silent;
|
||||
}
|
||||
|
||||
protected String doInBackground(String... urls) {
|
||||
try
|
||||
{
|
||||
URL url = new URL(urls[0]);
|
||||
is = url.openConnection().getInputStream();
|
||||
os = new ByteArrayOutputStream();
|
||||
|
||||
byte[] buffer = new byte[8196];
|
||||
int len;
|
||||
|
||||
while ((len = is.read(buffer)) > 0)
|
||||
{
|
||||
os.write(buffer, 0, len);
|
||||
}
|
||||
return os.toString();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void onPostExecute(String result)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (is != null)
|
||||
{
|
||||
is.close();
|
||||
is = null;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
JSONObject obj = new JSONObject(os.toString());
|
||||
|
||||
try
|
||||
{
|
||||
if (os != null) {
|
||||
os.close();
|
||||
os = null;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
final String version = obj.getString("tag_name");
|
||||
final String url = obj.getString("html_url");
|
||||
final String name = obj.getString("name");
|
||||
|
||||
Log.d("Xash", "Found: " + version +
|
||||
", I: " + getString(R.string.version_string));
|
||||
|
||||
if( !getString(R.string.version_string).equals(version) )
|
||||
{
|
||||
String dialog_message = getString(R.string.update_message).format(name);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getBaseContext());
|
||||
builder.setMessage(dialog_message)
|
||||
.setPositiveButton(R.string.update, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url));
|
||||
startActivity(intent);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int which){}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
else if( !mSilent )
|
||||
{
|
||||
Toast.makeText(getBaseContext(), R.string.no_updates, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue