Add motd and fix layout

This commit is contained in:
vshcherb 2014-05-24 02:20:15 +02:00
parent 430e21cea0
commit a1c545c347
9 changed files with 70 additions and 14 deletions

View file

@ -2,10 +2,23 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical" >
<Switch android:id="@+id/enable_tracker" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:focusable="false" android:text="@string/osmo_enable_tracker"/>
<TextView
android:id="@+id/motd"
android:layout_marginBottom="8dip"
android:gravity="center"
android:textSize="18sp" />
<Switch
android:id="@+id/enable_tracker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="center_vertical"
android:text="@string/osmo_enable_tracker" />
</LinearLayout>

View file

@ -19,7 +19,8 @@
<TextView
android:id="@+id/category_name"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="0dp"

View file

@ -10,7 +10,8 @@
<ImageView android:id="@+id/osmo_user_icon" android:layout_width="26dp" android:layout_height="26dp" android:paddingRight="2dp" android:paddingTop="2dp"
/>
<TextView android:id="@+id/osmo_label" android:layout_width="wrap_content" android:layout_marginLeft="10dp"
<TextView android:id="@+id/osmo_label" android:layout_width="fill_parent" android:layout_marginLeft="10dp"
android:layout_weight="1"
android:layout_height="wrap_content" style="@style/ListText"/>
<include layout="@layout/check_item"/>

View file

@ -2,10 +2,23 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical" >
<CheckBox android:id="@+id/enable_tracker" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:focusable="false" android:text="@string/osmo_enable_tracker"/>
<TextView
android:id="@+id/motd"
android:layout_marginBottom="8dip"
android:gravity="center"
android:textSize="18sp" />
<CheckBox
android:id="@+id/enable_tracker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="center_vertical"
android:text="@string/osmo_enable_tracker" />
</LinearLayout>

View file

@ -521,7 +521,7 @@
<string name="route_head">Avancez</string>
<string name="first_time_continue">Continuer</string>
<string name="first_time_download">Téléchargement des régions</string>
<string name="first_time_msg">Merci d\'avoir choisi OsmAnd. La plupart des fonctionnalités de l\'application nécessitent des données régionales, utilisables hors-ligne, que vous pouvez au préalable télécharger ('Paramètres' → 'Données hors-ligne') ou préparer vous-même. Ces données permettront de visualiser les cartes et de rechercher une adresse, un point d\'intérêt (PI) ou un transport en commun.</string>
<string name="first_time_msg">Merci d\'avoir choisi OsmAnd. La plupart des fonctionnalités de l\'application nécessitent des données régionales, utilisables hors-ligne, que vous pouvez au préalable télécharger (\'Paramètres\' → \'Données hors-ligne\') ou préparer vous-même. Ces données permettront de visualiser les cartes et de rechercher une adresse, un point d\'intérêt (PI) ou un transport en commun.</string>
<string name="search_poi_location">Recherche d\'un signal…</string>
<string name="search_near_map">Rechercher près du dernier emplacement</string>
<string name="search_nearby">Rechercher à proximité</string>

View file

@ -27,6 +27,7 @@ import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.activities.OsmandExpandableListActivity;
import net.osmand.plus.osmo.OsMoGroups.OsMoGroup;
import net.osmand.plus.osmo.OsMoGroups.OsMoUser;
import net.osmand.plus.osmo.OsMoService.SessionInfo;
import net.osmand.plus.osmo.OsMoTracker.OsmoTrackerListener;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@ -52,6 +53,7 @@ import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ImageView;
@ -123,6 +125,13 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
}
}
});
TextView mtd = (TextView) findViewById(R.id.motd);
SessionInfo si = osMoPlugin.getService().getCurrentSessionInfo();
boolean visible = si != null && si.motd != null && si.motd.length() > 0;
mtd.setVisibility(visible? View.VISIBLE:View.GONE);
if(visible) {
mtd.setText(si.motd);
}
}
private Path createDirectionPath() {

View file

@ -207,7 +207,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
@Override
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
helper.item(R.string.osmo_groups).icons(R.drawable.ic_action_eye_dark, R.drawable.ic_action_eye_light).position(4)
helper.item(R.string.osmo_groups).icons(R.drawable.ic_action_eye_dark, R.drawable.ic_action_eye_light).position(6)
.listen(new OnContextMenuClick() {
@Override
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {

View file

@ -28,7 +28,7 @@ import org.json.JSONObject;
import android.os.Build;
import android.provider.Settings.Secure;
public class OsMoService implements OsMoSender {
public class OsMoService implements OsMoSender, OsMoReactor {
private OsMoThread thread;
private List<OsMoSender> listSenders = new java.util.concurrent.CopyOnWriteArrayList<OsMoSender>();
private List<OsMoReactor> listReactors = new java.util.concurrent.CopyOnWriteArrayList<OsMoReactor>();
@ -42,6 +42,7 @@ public class OsMoService implements OsMoSender {
public OsMoService(OsmandApplication app) {
this.app = app;
listSenders.add(this);
listReactors.add(this);
}
public boolean isConnected() {
@ -149,6 +150,8 @@ public class OsMoService implements OsMoSender {
public String username;
public long serverTimeDelta;
public long motdTimestamp;
public String motd = "";
}
public SessionInfo getCurrentSessionInfo() {
@ -225,5 +228,17 @@ public class OsMoService implements OsMoSender {
}
return null;
}
@Override
public boolean acceptCommand(String command, String data, JSONObject obj, OsMoThread tread) {
if(command.equals("MOTD")) {
SessionInfo si = getCurrentSessionInfo();
if(si != null) {
si.motd = data;
}
return true;
}
return false;
}
}

View file

@ -306,7 +306,11 @@ public class OsMoThread {
sessionInfo.username = obj.getString("name");
}
if (obj.has("motd")) {
sessionInfo.motdTimestamp = obj.getLong("motd");
long l = obj.getLong("motd");
if(l != sessionInfo.motdTimestamp ){
sessionInfo.motdTimestamp = l;
service.pushCommand("MOTD");
}
}
if(obj.has("tracker_id")) {
sessionInfo.trackerId= obj.getString("tracker_id");