Show first time

This commit is contained in:
Victor Shcherb 2015-04-23 22:21:48 +02:00
parent dfb6accba2
commit 5ffec46f39
5 changed files with 21 additions and 21 deletions

View file

@ -46,8 +46,6 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import btools.routingapp.BRouterServiceConnection; import btools.routingapp.BRouterServiceConnection;
/** /**
@ -70,6 +68,7 @@ public class AppInitializer implements IProgress {
private boolean initSettings = false; private boolean initSettings = false;
private boolean firstTime; private boolean firstTime;
private boolean activityChangesShowed = false;
private boolean appVersionChanged; private boolean appVersionChanged;
private long startTime; private long startTime;
private long startBgTime; private long startBgTime;
@ -124,17 +123,24 @@ public class AppInitializer implements IProgress {
} }
public boolean isFirstTime(Activity activity) { public boolean isFirstTime(Activity activity) {
SharedPreferences pref = activity.getPreferences(Context.MODE_WORLD_WRITEABLE); initUiVars(activity);
return !pref.contains(FIRST_TIME_APP_RUN); return firstTime;
}
public void setFirstTime(boolean firstTime) {
this.firstTime = firstTime;
} }
public boolean checkAppVersionChanged(Activity activity) { public boolean checkAppVersionChanged(Activity activity) {
initUiVars(activity); initUiVars(activity);
if (!firstTime && appVersionChanged) { boolean showRecentChangesDialog = !firstTime && appVersionChanged;
// showRecentChangesDialog = true;
if (showRecentChangesDialog && !activityChangesShowed) {
final Intent helpIntent = new Intent(activity, HelpActivity.class); final Intent helpIntent = new Intent(activity, HelpActivity.class);
helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(app)); helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(app));
helpIntent.putExtra(HelpActivity.URL, LATEST_CHANGES_URL); helpIntent.putExtra(HelpActivity.URL, LATEST_CHANGES_URL);
activity.startActivity(helpIntent); activity.startActivity(helpIntent);
activityChangesShowed = true;
return true; return true;
} }
return false; return false;

View file

@ -1152,7 +1152,9 @@ public class OsmandSettings {
public static final String EXTERNAL_STORAGE_DIR = "external_storage_dir"; //$NON-NLS-1$ public static final String EXTERNAL_STORAGE_DIR = "external_storage_dir"; //$NON-NLS-1$
public File getExternalStorageDirectory() { public File getExternalStorageDirectory() {
String defaultLocation = Environment.getExternalStorageDirectory().getAbsolutePath(); String defaultLocation =
Environment.getExternalStorageDirectory().getAbsolutePath();
// ctx.getExternalFilesDirs(type)
return new File(settingsAPI.getString(globalPreferences, EXTERNAL_STORAGE_DIR, return new File(settingsAPI.getString(globalPreferences, EXTERNAL_STORAGE_DIR,
defaultLocation)); defaultLocation));
} }

View file

@ -127,16 +127,6 @@ public class MapActivity extends AccessibleActivity {
return notification; return notification;
} }
public boolean isFirstTime(){
return firstTime;
}
public void userClosedWelcomeCard(){
firstTime = false;
dashboardOnMap.refreshDashboardFragments();
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
long tm = System.currentTimeMillis(); long tm = System.currentTimeMillis();
@ -151,12 +141,12 @@ public class MapActivity extends AccessibleActivity {
mapView = new OsmandMapTileView(this, getWindow().getDecorView().getWidth(), mapView = new OsmandMapTileView(this, getWindow().getDecorView().getWidth(),
getWindow().getDecorView().getHeight()); getWindow().getDecorView().getHeight());
app.getAppInitializer().checkAppVersionChanged(this);
mapActions = new MapActivityActions(this); mapActions = new MapActivityActions(this);
mapLayers = new MapActivityLayers(this); mapLayers = new MapActivityLayers(this);
if (mapViewTrackingUtilities == null) { if (mapViewTrackingUtilities == null) {
mapViewTrackingUtilities = new MapViewTrackingUtilities(app); mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
} }
firstTime = app.getAppInitializer().isFirstTime(this);
dashboardOnMap.createDashboardView(); dashboardOnMap.createDashboardView();
checkAppInitialization(); checkAppInitialization();
parseLaunchIntentLocation(); parseLaunchIntentLocation();

View file

@ -67,7 +67,8 @@ public class DashFirstTimeFragment extends DashBaseFragment {
view.findViewById(R.id.hide).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.hide).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
((MapActivity)getActivity()).userClosedWelcomeCard(); getMyApplication().getAppInitializer().setFirstTime(false);
dashboard.refreshDashboardFragments();
} }
}); });

View file

@ -388,7 +388,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
} }
public void refreshDashboardFragments(){ public void refreshDashboardFragments(){
addOrUpdateDashboardFragments(mapActivity.isFirstTime()); addOrUpdateDashboardFragments();
} }
public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem, boolean animation) { public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem, boolean animation) {
@ -415,7 +415,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout); View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
ScrollView scrollView = (ScrollView) dashboardView.findViewById(R.id.main_scroll); ScrollView scrollView = (ScrollView) dashboardView.findViewById(R.id.main_scroll);
if(visibleType == DashboardType.DASHBOARD) { if(visibleType == DashboardType.DASHBOARD) {
addOrUpdateDashboardFragments(mapActivity.isFirstTime()); addOrUpdateDashboardFragments();
scrollView.setVisibility(View.VISIBLE); scrollView.setVisibility(View.VISIBLE);
listViewLayout.setVisibility(View.GONE); listViewLayout.setVisibility(View.GONE);
onScrollChanged(scrollView.getScrollY(), false, false); onScrollChanged(scrollView.getScrollY(), false, false);
@ -636,7 +636,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
} }
private void addOrUpdateDashboardFragments(boolean firstTime) { private void addOrUpdateDashboardFragments() {
boolean firstTime = getMyApplication().getAppInitializer().isFirstTime(mapActivity);
// boolean showCards = mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get(); // boolean showCards = mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get();
boolean showCards = !firstTime; boolean showCards = !firstTime;