| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,59 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| package="net.minetest.minetest" | ||
| android:installLocation="auto"> | ||
|
|
||
| <uses-feature | ||
| android:glEsVersion="0x00010000" | ||
| android:required="true" /> | ||
|
|
||
| <uses-permission android:name="android.permission.INTERNET" /> | ||
| <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
|
|
||
| <application | ||
| android:allowBackup="true" | ||
| android:icon="@mipmap/ic_launcher" | ||
| android:label="${project}" | ||
| android:resizeableActivity="false"> | ||
|
|
||
| <meta-data | ||
| android:name="android.max_aspect" | ||
| android:value="2.1" /> | ||
|
|
||
| <activity | ||
| android:name=".MainActivity" | ||
| android:configChanges="orientation|keyboardHidden|navigation|screenSize" | ||
| android:label="${project}" | ||
| android:launchMode="singleTask" | ||
| android:screenOrientation="sensorLandscape" | ||
| android:theme="@style/AppTheme"> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
| <category android:name="android.intent.category.LAUNCHER" /> | ||
| </intent-filter> | ||
| </activity> | ||
| <activity | ||
| android:name=".MtNativeActivity" | ||
| android:configChanges="orientation|keyboard|keyboardHidden|navigation|screenSize|smallestScreenSize" | ||
| android:hardwareAccelerated="true" | ||
| android:launchMode="singleTask" | ||
| android:screenOrientation="sensorLandscape" | ||
| android:theme="@style/AppTheme"> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN" /> | ||
| </intent-filter> | ||
| <meta-data | ||
| android:name="android.app.lib_name" | ||
| android:value="minetest" /> | ||
| </activity> | ||
| <activity | ||
| android:name=".MinetestTextEntry" | ||
| android:configChanges="keyboardHidden|orientation|screenSize" | ||
| android:theme="@style/Theme.Dialog" | ||
| android:windowSoftInputMode="stateAlwaysHidden"/> | ||
| <activity | ||
| android:name=".MinetestAssetCopy" | ||
| android:screenOrientation="sensorLandscape" | ||
| android:theme="@style/AppTheme"/> | ||
| </application> | ||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package net.minetest.minetest; | ||
|
|
||
| import android.Manifest; | ||
| import android.app.Activity; | ||
| import android.content.Intent; | ||
| import android.content.pm.PackageManager; | ||
| import android.os.Build; | ||
| import android.os.Bundle; | ||
| import android.support.annotation.NonNull; | ||
| import android.support.v4.app.ActivityCompat; | ||
| import android.support.v4.content.ContextCompat;; | ||
| import android.widget.Toast; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| public class MainActivity extends Activity { | ||
|
|
||
| private final static int PERMISSIONS = 1; | ||
| private static final String[] REQUIRED_SDK_PERMISSIONS = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}; | ||
|
|
||
| @Override | ||
| public void onCreate(Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
| checkPermission(); | ||
| } else { | ||
| next(); | ||
| } | ||
| } | ||
|
|
||
| protected void checkPermission() { | ||
| final List<String> missingPermissions = new ArrayList<String>(); | ||
| // check required permission | ||
| for (final String permission : REQUIRED_SDK_PERMISSIONS) { | ||
| final int result = ContextCompat.checkSelfPermission(this, permission); | ||
| if (result != PackageManager.PERMISSION_GRANTED) { | ||
| missingPermissions.add(permission); | ||
| } | ||
| } | ||
| if (!missingPermissions.isEmpty()) { | ||
| // request permission | ||
| final String[] permissions = missingPermissions | ||
| .toArray(new String[missingPermissions.size()]); | ||
| ActivityCompat.requestPermissions(this, permissions, PERMISSIONS); | ||
| } else { | ||
| final int[] grantResults = new int[REQUIRED_SDK_PERMISSIONS.length]; | ||
| Arrays.fill(grantResults, PackageManager.PERMISSION_GRANTED); | ||
| onRequestPermissionsResult(PERMISSIONS, REQUIRED_SDK_PERMISSIONS, | ||
| grantResults); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], | ||
| @NonNull int[] grantResults) { | ||
| switch (requestCode) { | ||
| case PERMISSIONS: | ||
| for (int index = 0; index < permissions.length; index++) { | ||
| if (grantResults[index] != PackageManager.PERMISSION_GRANTED) { | ||
| // permission not granted - toast and exit | ||
| Toast.makeText(this, R.string.not_granted, Toast.LENGTH_LONG).show(); | ||
| finish(); | ||
| return; | ||
| } | ||
| } | ||
| // permission were granted - run | ||
| next(); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| public void next() { | ||
| Intent intent = new Intent(this, MtNativeActivity.class); | ||
| intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK); | ||
| startActivity(intent); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <bitmap xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:src="@drawable/background" | ||
| android:tileMode="repeat" /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,24 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:id="@+id/activity_main" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent"> | ||
|
|
||
| <ProgressBar | ||
| android:id="@+id/progressBar1" | ||
| style="?android:attr/progressBarStyleHorizontal" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="30dp" | ||
| android:layout_centerInParent="true" | ||
| android:layout_marginLeft="90dp" | ||
| android:layout_marginRight="90dp" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textView1" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_below="@+id/progressBar1" | ||
| android:layout_centerInParent="true" | ||
| android:text="@string/preparing_media" /> | ||
|
|
||
| </RelativeLayout> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
|
|
||
| <style name="AppTheme" parent="@android:style/android:Theme.Material.Light.NoActionBar.Fullscreen"> | ||
| <item name="android:windowNoTitle">true</item> | ||
| <item name="android:windowAnimationStyle">@null</item> | ||
| <item name="android:background">@drawable/bg</item> | ||
| </style> | ||
|
|
||
| <style name="Theme.Dialog" parent="@android:style/Theme.Material.Light.Dialog.NoActionBar"/> | ||
|
|
||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <string name="preparing_media">Preparing media…</string> | ||
| <string name="not_granted">Required permission wasn\'t granted, Minetest can\'t run without it</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
|
|
||
| <style name="AppTheme" parent="@android:style/android:Theme.Holo.Light.NoActionBar.Fullscreen"> | ||
| <item name="android:windowNoTitle">true</item> | ||
| <item name="android:windowAnimationStyle">@null</item> | ||
| <item name="android:background">@drawable/bg</item> | ||
| </style> | ||
|
|
||
| <style name="Theme.Dialog" parent="@android:style/android:Theme.Holo.Light.Dialog.NoActionBar"/> | ||
|
|
||
| </resources> |