Local repo notification directs to swap wifi connect screen.

Previously it would direct to the LocalRepo screen, then when that code
was ported to the swap workflow, it did nothing :( Now it does as one
might expect, and actually directs the user to the swap screen.
This commit is contained in:
Peter Serwylo 2014-09-03 16:14:51 +09:30
parent ddb9791e11
commit de74d6457d
3 changed files with 36 additions and 21 deletions

View File

@ -167,10 +167,10 @@
<string name="local_repo">Local Repo</string>
<string name="local_repos_title">Local FDroid Repos</string>
<string name="local_repos_scanning">Discovering local FDroid repos&#8230;</string>
<string name="local_repo_running">Your local FDroid repo is accessible.</string>
<string name="local_repo_running">F-Droid is ready to swap</string>
<string name="waiting_for_ipaddress">waiting for IP address…</string>
<string name="setup_repo">Setup Local Repo</string>
<string name="touch_to_configure_local_repo">Touch to setup your local repo.</string>
<string name="touch_to_configure_local_repo">Touch to view details and allow others to swap your apps.</string>
<string name="touch_to_turn_on_local_repo">Touch to turn on your local repo.</string>
<string name="touch_to_turn_off_local_repo">Touch to turn off your local repo.</string>
<string name="updating">Updating&#8230;</string>

View File

@ -2,27 +2,38 @@
package org.fdroid.fdroid.localrepo;
import android.annotation.SuppressLint;
import android.app.*;
import android.content.*;
import android.os.*;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import org.fdroid.fdroid.*;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.Preferences.ChangeListener;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.net.LocalHTTPD;
import org.fdroid.fdroid.net.WifiStateChangeService;
import org.fdroid.fdroid.views.LocalRepoActivity;
import org.fdroid.fdroid.views.swap.SwapActivity;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
import java.io.IOException;
import java.net.BindException;
import java.util.HashMap;
import java.util.Random;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
public class LocalRepoService extends Service {
private static final String TAG = "LocalRepoService";
@ -109,14 +120,14 @@ public class LocalRepoService extends Service {
public void onCreate() {
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// launch LocalRepoActivity if the user selects this notification
Intent intent = new Intent(this, LocalRepoActivity.class);
Intent intent = new Intent(this, SwapActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_CANCEL_CURRENT);
notification = new NotificationCompat.Builder(this)
.setContentTitle(getText(R.string.local_repo_running))
.setContentText(getText(R.string.touch_to_configure_local_repo))
.setSmallIcon(android.R.drawable.ic_dialog_info)
.setSmallIcon(R.drawable.ic_swap)
.setContentIntent(contentIntent)
.build();
startForeground(NOTIFICATION, notification);

View File

@ -30,7 +30,6 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
private static final String STATE_NFC = "nfc";
private static final String STATE_WIFI_QR = "wifiQr";
private Menu menu;
private String nextMenuItemLabel;
private Timer shutdownLocalRepoTimer;
private UpdateAsyncTask updateSwappableAppsTask = null;
@ -69,7 +68,6 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
this.menu = menu;
getMenuInflater().inflate(R.menu.swap_next, menu);
MenuItem nextMenuItem = menu.findItem(R.id.action_next);
nextMenuItem.setVisible(false);
@ -123,12 +121,18 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.replace(android.R.id.content, new StartSwapFragment(), STATE_START_SWAP)
.addToBackStack(STATE_START_SWAP)
.commit();
hideNextButton();
if (FDroidApp.isLocalRepoServiceRunnig()) {
onWifiQr();
} else {
getSupportFragmentManager()
.beginTransaction()
.replace(android.R.id.content, new StartSwapFragment(), STATE_START_SWAP)
.addToBackStack(STATE_START_SWAP)
.commit();
hideNextButton();
}
}