aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2015-09-20 18:51:49 +0200
committerChristian S <christian@pix-art.de>2015-09-20 18:51:49 +0200
commit0a70e313d145a802a7d64c3ae1615408b2d35d35 (patch)
tree85267baa5c44db80e637bfaf79b61fd15949d031 /src/main
parenteeb7cfc01187bcd15e81d82f0e619f9d5823e28f (diff)
modified AppUpdater
Diffstat (limited to 'src/main')
-rw-r--r--src/main/AndroidManifest.xml3
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java39
-rw-r--r--src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java22
3 files changed, 51 insertions, 13 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 786f9df2d..50a9b0b43 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -151,7 +151,8 @@
</activity>
<activity
android:name=".ui.UpdaterActivity"
- android:theme="@style/Platform.AppCompat.Light.Dialog" >
+ android:screenOrientation="portrait"
+ android:theme="@style/Theme.AppCompat.Light.Dialog" >
</activity>
<service
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 12d80afd9..20f965bbc 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -6,10 +6,12 @@ import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.app.PendingIntent;
import android.content.ClipData;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
+import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -85,7 +87,7 @@ public class ConversationActivity extends XmppActivity
private static final String STATE_PANEL_OPEN = "state_panel_open";
private static final String STATE_PENDING_URI = "state_pending_uri";
- private String mOpenConverstaion = null;
+ private String mOpenConverstaion = null;
private boolean mPanelOpen = true;
final private List<Uri> mPendingImageUris = new ArrayList<>();
final private List<Uri> mPendingFileUris = new ArrayList<>();
@@ -172,11 +174,9 @@ public class ConversationActivity extends XmppActivity
}
}
- setContentView(R.layout.fragment_conversations_overview);
- // run Updater
- Log.d(Config.LOGTAG, "Start automatic AppUpdater");
- Intent AppUpdater = new Intent(ConversationActivity.this, UpdaterActivity.class);
- startActivity(AppUpdater);
+ AppUpdate();
+
+ setContentView(R.layout.fragment_conversations_overview);
this.mConversationFragment = new ConversationFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
@@ -316,6 +316,32 @@ public class ConversationActivity extends XmppActivity
}
}
+ protected void AppUpdate(){
+ String PREFS_NAME = "UpdateTimeStamp";
+ SharedPreferences UpdateTimeStamp = getApplicationContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
+ long lastUpdateTime = UpdateTimeStamp.getLong("lastUpdateTime", 0);
+
+ Log.d(Config.LOGTAG, "AppUpdater - LastUpdateTime: " + lastUpdateTime);
+
+ if ((lastUpdateTime + (60 * 60 * 1000)) < System.currentTimeMillis()) {
+ lastUpdateTime = System.currentTimeMillis();
+ SharedPreferences.Editor editor = UpdateTimeStamp.edit();
+ editor.putLong("lastUpdateTime", lastUpdateTime);
+ editor.commit();
+
+ // run AppUpdater
+ Log.d(Config.LOGTAG, "AppUpdater - CurrentTime: " + lastUpdateTime);
+ Intent AppUpdater = new Intent(this, UpdaterActivity.class);
+ startActivity(AppUpdater);
+ Log.d(Config.LOGTAG, "AppUpdater started");
+
+ } else {
+
+ Log.d(Config.LOGTAG, "AppUpdater stopped");
+ return;
+ }
+ }
+
@Override
public void switchToConversation(Conversation conversation) {
setSelectedConversation(conversation);
@@ -1044,6 +1070,7 @@ public class ConversationActivity extends XmppActivity
sendReadMarkerIfNecessary(getSelectedConversation());
}
+ AppUpdate();
}
@Override
diff --git a/src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java b/src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java
index 65d816560..19712922c 100644
--- a/src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/UpdaterActivity.java
@@ -35,9 +35,9 @@ public class UpdaterActivity extends Activity {
/*
- // run Updater
+ // run AppUpdater
Log.d(Config.LOGTAG, "Start automatic AppUpdater");
- Intent AppUpdater = new Intent(ConversationActivity.this, UpdaterActivity.class);
+ Intent AppUpdater = new Intent(this, UpdaterActivity.class);
startActivity(AppUpdater);
*/
@@ -99,7 +99,17 @@ public class UpdaterActivity extends Activity {
super.onDestroy();
}
- //check for internet connection
+ @Override
+ public void onSaveInstanceState(Bundle savedInstanceState) {
+ super.onSaveInstanceState(savedInstanceState);
+ }
+
+ @Override
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ }
+
+ //check for internet connection
private boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
@@ -161,12 +171,11 @@ public class UpdaterActivity extends Activity {
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
request.setAllowedOverRoaming(false);
request.setTitle("Conversations Update");
- request.setDestinationInExternalFilesDir(UpdaterActivity.this, Environment.DIRECTORY_DOWNLOADS, "MyAndroidApp.apk");
+ request.setDestinationInExternalFilesDir(UpdaterActivity.this, Environment.DIRECTORY_DOWNLOADS, "Conversations.apk");
downloadReference = downloadManager.enqueue(request);
Toast.makeText(getApplicationContext(),
getText(R.string.download_started),
Toast.LENGTH_LONG).show();
- UpdaterActivity.this.finish();
}
})
.setNegativeButton(R.string.remind_later, new DialogInterface.OnClickListener() {
@@ -182,7 +191,8 @@ public class UpdaterActivity extends Activity {
{
Toast.makeText(getApplicationContext(),
getText(R.string.no_update_available),
- Toast.LENGTH_LONG).show();
+ Toast.LENGTH_SHORT).show();
+
UpdaterActivity.this.finish();
}