mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-27 12:29:53 +01:00
Allow start ShortcutActivity from launcher
This commit is contained in:
parent
b4ead9c0ac
commit
2b65b71538
@ -73,8 +73,9 @@
|
||||
<!-- OpenGL ES 1.1 -->
|
||||
<uses-feature android:glEsVersion="0x00010000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<!-- Permissions -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
</manifest>
|
||||
|
@ -64,6 +64,12 @@
|
||||
android:text="@string/about_button"
|
||||
android:id="@+id/button"
|
||||
android:onClick="aboutXash" />
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/create_shortcut_button"
|
||||
android:id="@+id/button"
|
||||
android:onClick="createShortcut" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
@ -16,9 +16,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shortcut_button_save"
|
||||
android:id="@+id/shortcut_buttonOk"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:onClick="saveShortcut"/>
|
||||
android:onClick="saveShortcut"
|
||||
android:layout_below="@+id/shortcut_gamedir"/>
|
||||
|
||||
<EditText
|
||||
android:layout_height="wrap_content"
|
||||
@ -32,7 +32,7 @@
|
||||
android:id="@+id/shortcut_name_text"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/shortcut_name"
|
||||
/>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/cmd_args_text"
|
||||
android:id="@+id/shortcut_textView_args"
|
||||
android:layout_alignParentRight="true"
|
||||
@ -62,7 +62,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/gamedir"
|
||||
android:id="@+id/shortcut_gamedir_text"
|
||||
android:layout_below="@+id/shortcut_cmdArgs"
|
||||
|
@ -23,4 +23,5 @@
|
||||
<string name="about_copyright" translatable="false">SDLash3D не связан с Valve или с любыми из их партнеров. Все авторские права принадлежат их соотвественным обладателям.</string>
|
||||
<string name="action_settings">Настройки</string>
|
||||
<string name="text_shortcut_test">Ярлык Xash3D (тест)</string>
|
||||
<string name="create_shortcut_button">Создать ярлык</string>
|
||||
</resources>
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
<string name="app_name" translatable="false">Xash3D</string>
|
||||
<string name="launcher_name" translatable="false">Xash3D</string>
|
||||
<string name="launcher_name_test" translatable="false">Xash3D_test</string>
|
||||
<string name="launcher_name_test" translatable="false">Xash3D (test)</string>
|
||||
<string-array name="double_tap_actions">
|
||||
<item>None</item>
|
||||
<item>Shoot</item>
|
||||
@ -38,4 +38,5 @@ Special thanks to:\n
|
||||
• Beloko Games for touch controls support\n
|
||||
• libSDL2 developers.\n</string>
|
||||
<string name="about_button">About Xash3D Android</string>
|
||||
<string name="create_shortcut_button">Create mod shortcut</string>
|
||||
</resources>
|
||||
|
@ -75,6 +75,12 @@ public class LauncherActivity extends Activity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createShortcut(View view)
|
||||
{
|
||||
Intent intent = new Intent(this, ShortcutActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
@ -5,6 +5,7 @@ import android.view.View;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.widget.Toast;
|
||||
import in.celest.xash3d.hl.R;
|
||||
import android.widget.EditText;
|
||||
import java.io.File;
|
||||
@ -66,7 +67,21 @@ public class ShortcutActivity extends Activity
|
||||
icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
|
||||
}
|
||||
wrapIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
|
||||
setResult(RESULT_OK, wrapIntent);
|
||||
finish();
|
||||
if(getIntent().getAction() == "android.intent.action.CREATE_SHORTCUT" ) // Called from launcher
|
||||
{
|
||||
setResult(RESULT_OK, wrapIntent);
|
||||
finish();
|
||||
}
|
||||
else try
|
||||
{
|
||||
wrapIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
getApplicationContext().sendBroadcast(wrapIntent);
|
||||
Toast.makeText(getApplicationContext(), "Shortcut created!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Toast.makeText(getApplicationContext(), "Problem creating shortcut: " + e.toString() +
|
||||
"\nTry create it manually from laucnher", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +73,9 @@
|
||||
<!-- OpenGL ES 1.1 -->
|
||||
<uses-feature android:glEsVersion="0x00010000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<!-- Permissions -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
</manifest>
|
||||
|
Loading…
Reference in New Issue
Block a user