Refactor activities

This commit is contained in:
Victor Shcherb 2014-06-04 01:02:39 +02:00
parent dded78403b
commit 918da65e63
5 changed files with 39 additions and 34 deletions

View file

@ -147,7 +147,8 @@
<activity android:name="net.osmand.plus.activities.search.SearchStreetByNameActivity"></activity>
<activity android:name="net.osmand.plus.activities.search.SearchStreet2ByNameActivity"></activity>
<activity android:name="net.osmand.plus.activities.search.SearchBuildingByNameActivity"></activity>
<activity android:name="net.osmand.plus.sherpafy.TourViewActivity" android:exported="true" android:launchMode= "singleInstance"/>
<activity android:name="net.osmand.plus.sherpafy.TourViewActivity" android:exported="true" android:launchMode= "singleInstance"
android:label="Sherpafy"/>
<activity android:name="net.osmand.plus.activities.EditPOIFilterActivity"></activity>
<activity android:name="net.osmand.plus.activities.search.GeoIntentActivity">
<intent-filter>

View file

@ -19,8 +19,9 @@
android:id="@+id/ProgressMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:text="@string/loading_data"
android:textSize="22sp" />
android:textSize="18sp" />
</LinearLayout>
</FrameLayout>

View file

@ -15,6 +15,7 @@
android:id="@+id/select_tour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:singleLine="true"
android:text="@string/select_tour" />
</LinearLayout>
@ -30,6 +31,7 @@
android:id="@+id/download_tour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:singleLine="true"
android:text="@string/download_tour" />
</LinearLayout>

View file

@ -7,7 +7,7 @@
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
@ -30,12 +30,6 @@
android:text="@string/select_tour"
android:textSize="21sp" />
<Button
android:id="@+id/start_tour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="@string/start_tour" />
</LinearLayout>
<ScrollView
@ -86,12 +80,6 @@
android:textSize="16sp" >
</TextView>
<TextView
android:id="@+id/btn_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/settings_Button" />
</LinearLayout>
</ScrollView>

View file

@ -38,6 +38,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
private static final int GO_TO_MAP = 1;
private static final int SETTINGS_ID = 2;
private static final int TOUR_ID = 3;
private static final int STATE_TOUR_VIEW = 1;
private static final int STATE_LOADING = 0;
private static final int STATE_SELECT_TOUR = -1;
@ -121,29 +122,45 @@ public class TourViewActivity extends SherlockFragmentActivity {
setTourSelectionContentView();
state = STATE_SELECT_TOUR;
}
invalidateOptionsMenu();
}
private void setMainContent() {
if(customization.getSelectedTour() != null) {
private void startTourView() {
if(state != STATE_TOUR_VIEW) {
setTourInfoContent();
state = STATE_TOUR_VIEW;
}
getSupportActionBar().setTitle(customization.getSelectedTour().getName());
updateTourView();
invalidateOptionsMenu();
}
private void setMainContent() {
if(customization.getSelectedTour() != null) {
startTourView();
} else {
startSettings();
}
}
@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
createMenuItem(menu, GO_TO_MAP, R.string.start_tour,
0, 0,/*R.drawable.ic_action_marker_light,*/
MenuItem.SHOW_AS_ACTION_ALWAYS| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
createMenuItem(menu, SETTINGS_ID, R.string.osmo_share_session,
R.drawable.ic_action_settings_light, R.drawable.ic_action_settings_dark,
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
if (state == STATE_SELECT_TOUR) {
createMenuItem(menu, GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
createMenuItem(menu, SETTINGS_ID, R.string.osmo_share_session, R.drawable.ic_action_settings_light,
R.drawable.ic_action_settings_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
} else if(state == STATE_TOUR_VIEW) {
if (customization.isTourSelected()) {
createMenuItem(menu, TOUR_ID, R.string.osmo_share_session, R.drawable.ic_action_ok_light,
R.drawable.ic_action_ok_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
}
return super.onCreateOptionsMenu(menu);
}
@ -173,17 +190,10 @@ public class TourViewActivity extends SherlockFragmentActivity {
description.setVisibility(View.VISIBLE);
fullDescription = (TextView) findViewById(R.id.tour_fulldescription);
fullDescription.setVisibility(View.VISIBLE);
Button start_tour = (Button) findViewById(R.id.start_tour);
// in case of reloading view - remove all previous radio buttons
stages.removeAllViews();
start_tour.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
goToMap();
}
});
// get count of radio buttons
final int count = stagesInfo.size() + 1;
final RadioButton[] rb = new RadioButton[count];
@ -251,6 +261,9 @@ public class TourViewActivity extends SherlockFragmentActivity {
} else if (item.getItemId() == SETTINGS_ID) {
startSettings();
return true;
} else if (item.getItemId() == TOUR_ID) {
startTourView();
return true;
} else {
return super.onOptionsItemSelected(item);
}