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:
parent
ddb9791e11
commit
de74d6457d
@ -167,10 +167,10 @@
|
|||||||
<string name="local_repo">Local Repo</string>
|
<string name="local_repo">Local Repo</string>
|
||||||
<string name="local_repos_title">Local FDroid Repos</string>
|
<string name="local_repos_title">Local FDroid Repos</string>
|
||||||
<string name="local_repos_scanning">Discovering local FDroid repos…</string>
|
<string name="local_repos_scanning">Discovering local FDroid repos…</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="waiting_for_ipaddress">waiting for IP address…</string>
|
||||||
<string name="setup_repo">Setup Local Repo</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_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="touch_to_turn_off_local_repo">Touch to turn off your local repo.</string>
|
||||||
<string name="updating">Updating…</string>
|
<string name="updating">Updating…</string>
|
||||||
|
@ -2,27 +2,38 @@
|
|||||||
package org.fdroid.fdroid.localrepo;
|
package org.fdroid.fdroid.localrepo;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.*;
|
import android.app.Notification;
|
||||||
import android.content.*;
|
import android.app.NotificationManager;
|
||||||
import android.os.*;
|
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.app.NotificationCompat;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import org.fdroid.fdroid.FDroidApp;
|
||||||
import org.fdroid.fdroid.*;
|
import org.fdroid.fdroid.Preferences;
|
||||||
import org.fdroid.fdroid.Preferences.ChangeListener;
|
import org.fdroid.fdroid.Preferences.ChangeListener;
|
||||||
|
import org.fdroid.fdroid.R;
|
||||||
import org.fdroid.fdroid.net.LocalHTTPD;
|
import org.fdroid.fdroid.net.LocalHTTPD;
|
||||||
import org.fdroid.fdroid.net.WifiStateChangeService;
|
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.io.IOException;
|
||||||
import java.net.BindException;
|
import java.net.BindException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.jmdns.JmDNS;
|
|
||||||
import javax.jmdns.ServiceInfo;
|
|
||||||
|
|
||||||
public class LocalRepoService extends Service {
|
public class LocalRepoService extends Service {
|
||||||
private static final String TAG = "LocalRepoService";
|
private static final String TAG = "LocalRepoService";
|
||||||
|
|
||||||
@ -109,14 +120,14 @@ public class LocalRepoService extends Service {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
// launch LocalRepoActivity if the user selects this notification
|
// 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);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent,
|
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent,
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
notification = new NotificationCompat.Builder(this)
|
notification = new NotificationCompat.Builder(this)
|
||||||
.setContentTitle(getText(R.string.local_repo_running))
|
.setContentTitle(getText(R.string.local_repo_running))
|
||||||
.setContentText(getText(R.string.touch_to_configure_local_repo))
|
.setContentText(getText(R.string.touch_to_configure_local_repo))
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
.setSmallIcon(R.drawable.ic_swap)
|
||||||
.setContentIntent(contentIntent)
|
.setContentIntent(contentIntent)
|
||||||
.build();
|
.build();
|
||||||
startForeground(NOTIFICATION, notification);
|
startForeground(NOTIFICATION, notification);
|
||||||
|
@ -30,7 +30,6 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
|
|||||||
private static final String STATE_NFC = "nfc";
|
private static final String STATE_NFC = "nfc";
|
||||||
private static final String STATE_WIFI_QR = "wifiQr";
|
private static final String STATE_WIFI_QR = "wifiQr";
|
||||||
|
|
||||||
private Menu menu;
|
|
||||||
private String nextMenuItemLabel;
|
private String nextMenuItemLabel;
|
||||||
private Timer shutdownLocalRepoTimer;
|
private Timer shutdownLocalRepoTimer;
|
||||||
private UpdateAsyncTask updateSwappableAppsTask = null;
|
private UpdateAsyncTask updateSwappableAppsTask = null;
|
||||||
@ -69,7 +68,6 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
this.menu = menu;
|
|
||||||
getMenuInflater().inflate(R.menu.swap_next, menu);
|
getMenuInflater().inflate(R.menu.swap_next, menu);
|
||||||
MenuItem nextMenuItem = menu.findItem(R.id.action_next);
|
MenuItem nextMenuItem = menu.findItem(R.id.action_next);
|
||||||
nextMenuItem.setVisible(false);
|
nextMenuItem.setVisible(false);
|
||||||
@ -123,12 +121,18 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
|
|||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
|
||||||
getSupportFragmentManager()
|
if (FDroidApp.isLocalRepoServiceRunnig()) {
|
||||||
.beginTransaction()
|
onWifiQr();
|
||||||
.replace(android.R.id.content, new StartSwapFragment(), STATE_START_SWAP)
|
} else {
|
||||||
.addToBackStack(STATE_START_SWAP)
|
|
||||||
.commit();
|
getSupportFragmentManager()
|
||||||
hideNextButton();
|
.beginTransaction()
|
||||||
|
.replace(android.R.id.content, new StartSwapFragment(), STATE_START_SWAP)
|
||||||
|
.addToBackStack(STATE_START_SWAP)
|
||||||
|
.commit();
|
||||||
|
hideNextButton();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user