aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle1
-rw-r--r--src/main/AndroidManifest.xml9
-rw-r--r--src/main/java/eu/siacs/conversations/ui/startUI.java109
-rw-r--r--src/main/res/layout/activity_start_ui.xml14
-rw-r--r--src/main/res/values-de/strings.xml3
-rw-r--r--src/main/res/values/strings.xml3
6 files changed, 138 insertions, 1 deletions
diff --git a/build.gradle b/build.gradle
index 18705dbbf..1fd702c9e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -56,6 +56,7 @@ dependencies {
compile 'com.github.rtoshiro.fullscreenvideoview:fullscreenvideoview:1.1.0'
compile 'com.google.android.gms:play-services-location:9.0.1'
compile 'com.google.android.gms:play-services-maps:9.0.1'
+ compile 'pub.devrel:easypermissions:0.1.7'
}
ext {
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 4e68a7760..7a95c8b91 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -49,7 +49,8 @@
</receiver>
<activity
- android:name=".ui.ConversationActivity"
+ android:name=".ui.startUI"
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:label="@string/app_name"
android:launchMode="singleTask"
android:windowSoftInputMode="stateHidden">
@@ -60,6 +61,12 @@
</intent-filter>
</activity>
<activity
+ android:name=".ui.ConversationActivity"
+ android:label="@string/app_name"
+ android:launchMode="singleTask"
+ android:windowSoftInputMode="stateHidden">
+ </activity>
+ <activity
android:name=".ui.StartConversationActivity"
android:configChanges="orientation|screenSize"
android:label="@string/title_activity_start_conversation"
diff --git a/src/main/java/eu/siacs/conversations/ui/startUI.java b/src/main/java/eu/siacs/conversations/ui/startUI.java
new file mode 100644
index 000000000..030a707e9
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/ui/startUI.java
@@ -0,0 +1,109 @@
+package eu.siacs.conversations.ui;
+
+import android.Manifest;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+
+import java.util.Arrays;
+import java.util.List;
+
+import eu.siacs.conversations.Config;
+import eu.siacs.conversations.R;
+import pub.devrel.easypermissions.AfterPermissionGranted;
+import pub.devrel.easypermissions.EasyPermissions;
+
+/**
+ * Created by Christian on 10.06.2016.
+ */
+public class startUI extends AppCompatActivity
+ implements EasyPermissions.PermissionCallbacks {
+
+ private static final int NeededPermissions = 1000;
+
+ String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ Manifest.permission.READ_CONTACTS,
+ Manifest.permission.RECORD_AUDIO,
+ Manifest.permission.ACCESS_COARSE_LOCATION,
+ Manifest.permission.ACCESS_FINE_LOCATION,
+ };
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_start_ui);
+ requestNeededPermissions();
+ }
+
+ @AfterPermissionGranted(NeededPermissions)
+ private void requestNeededPermissions() {
+ if (EasyPermissions.hasPermissions(this, perms)) {
+ // Already have permission, start ConversationsActivity
+ startActivity(new Intent(this, ConversationActivity.class));
+ finish();
+ } else {
+ // Do not have permissions, request them now
+ EasyPermissions.requestPermissions(this, getString(R.string.request_permissions_message),
+ NeededPermissions, perms);
+ }
+ }
+
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ // Forward results to EasyPermissions
+ EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
+ }
+
+ @Override
+ public void onPermissionsGranted(int requestCode, List<String> list) {
+ Log.d(Config.LOGTAG, "Permissions granted:" + requestCode);
+ }
+
+ @Override
+ public void onPermissionsDenied(int requestCode, List<String> list) {
+ Log.d(Config.LOGTAG, "Permissions denied:" + requestCode);
+ AlertDialog dialog = new AlertDialog.Builder(this)
+ .setMessage(getString(R.string.request_permissions_message_again))
+ .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+ Uri uri = Uri.fromParts("package", getPackageName(), null);
+ intent.setData(uri);
+ startActivity(intent);
+ }
+ })
+ .setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ })
+ .create();
+ dialog.show();
+ }
+
+ private void restart() {
+ //restart app
+ Log.d(Config.LOGTAG, "Restarting " + getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName()));
+ Intent intent = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ System.exit(0);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+}
diff --git a/src/main/res/layout/activity_start_ui.xml b/src/main/res/layout/activity_start_ui.xml
new file mode 100644
index 000000000..da07b0f43
--- /dev/null
+++ b/src/main/res/layout/activity_start_ui.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ProgressBar
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/progressBar"
+ android:layout_centerVertical="true"
+ android:layout_centerHorizontal="true" />
+
+</RelativeLayout>
diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index 57e4f0e9d..497897a8a 100644
--- a/src/main/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
@@ -620,5 +620,8 @@
<string name="pref_broadcast_last_activity">Zuletzt gesehen senden</string>
<string name="pref_broadcast_last_activity_summary">Lasse deine Kontakte wissen, wann du Pix-Art Messenger nutzt</string>
<string name="invite_user">In Pix-Art Messenger einladen</string>
+ <string name="request_permissions_message">Pix-Art Messenger wird dich nach ein paar Berechtigungen fragen. Es ist wichtig, dass du alle Berechtigungen erlaubst, um alle Funktionen nutzen zu können. Falls du eine dieser Berechtigungen ablehnst wird sich die App schließen.</string>
+ <string name="request_permissions_message_again">Du hast eine oder alle Berechtigungen, welche für Pix-Art Messenger benötigt werden abgelehnt. Willst du zu den Einstellungen springen, um diese Berechtigungen zu erlauben? Falls du eine dieser Berechtigungen ablehnst wird sich die App schließen.</string>
+ <string name="request_permissions_title">Pix-Art Messenger Berechtigungen</string>
</resources>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 550bdbe47..3566ca0d3 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -660,4 +660,7 @@
<string name="pref_broadcast_last_activity_summary">Let all your contacts know when use Pix-Art Messenger</string>
<string name="pref_privacy">Privacy</string>
<string name="invite_user">Invite to Pix-Art Messenger</string>
+ <string name="request_permissions_title">Pix-Art Messenger permissions</string>
+ <string name="request_permissions_message">Pix-Art Messenger will ask you to allow a few permissions. It is important that you allow all these permissions to use all features of this messenger. If you deny any of these permissions the app will close itself.</string>
+ <string name="request_permissions_message_again">You have denied some or all permissions needed for Pix-Art Messenger. Would you like to jump to the settings and allow these permissions? If you denie any of these permissions, the app will close itself.</string>
</resources>