Fixed bug with last updated item in updates. Replaced start loading dialog with fragment.
This commit is contained in:
parent
f470ffe187
commit
c1123041a2
6 changed files with 75 additions and 51 deletions
|
@ -13,14 +13,13 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:id="@+id/content"
|
android:id="@+id/content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
</LinearLayout>
|
<LinearLayout android:id="@+id/credentials"
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone"
|
||||||
android:padding="6dp" >
|
android:padding="6dp" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -9,21 +9,19 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
import net.osmand.access.AccessibleAlertBuilder;
|
import net.osmand.access.AccessibleAlertBuilder;
|
||||||
import net.osmand.plus.OsmAndAppCustomization;
|
import net.osmand.plus.OsmAndAppCustomization;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||||
import net.osmand.plus.dashboard.DashFavoritesFragment;
|
import net.osmand.plus.dashboard.*;
|
||||||
import net.osmand.plus.dashboard.DashMapFragment;
|
|
||||||
import net.osmand.plus.dashboard.DashPluginsFragment;
|
|
||||||
import net.osmand.plus.dashboard.DashSearchFragment;
|
|
||||||
import net.osmand.plus.dashboard.DashUpdatesFragment;
|
|
||||||
import net.osmand.plus.download.BaseDownloadActivity;
|
import net.osmand.plus.download.BaseDownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
import net.osmand.plus.render.MapRenderRepositories;
|
import net.osmand.plus.render.MapRenderRepositories;
|
||||||
|
import net.osmand.plus.sherpafy.SherpafyLoadingFragment;
|
||||||
import net.osmand.plus.sherpafy.TourViewActivity;
|
import net.osmand.plus.sherpafy.TourViewActivity;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
@ -73,7 +71,6 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
private static final int HELP_ID = 0;
|
private static final int HELP_ID = 0;
|
||||||
private static final int SETTINGS_ID = 1;
|
private static final int SETTINGS_ID = 1;
|
||||||
private static final int EXIT_ID = 2;
|
private static final int EXIT_ID = 2;
|
||||||
private ProgressDialog startProgressDialog;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -100,9 +97,11 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
getSupportActionBar().setBackgroundDrawable(color);
|
getSupportActionBar().setBackgroundDrawable(color);
|
||||||
getSupportActionBar().setIcon(android.R.color.transparent);
|
getSupportActionBar().setIcon(android.R.color.transparent);
|
||||||
|
|
||||||
setupContributionVersion();
|
|
||||||
addFragments();
|
|
||||||
initApp(this, getMyApplication());
|
initApp(this, getMyApplication());
|
||||||
|
if (getMyApplication().isApplicationInitializing()) {
|
||||||
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
|
fragmentManager.beginTransaction().replace(R.id.content, new DashLoadingFragment()).commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,6 +113,7 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupContributionVersion() {
|
protected void setupContributionVersion() {
|
||||||
|
findViewById(R.id.credentials).setVisibility(View.VISIBLE);
|
||||||
final TextView textVersionView = (TextView) findViewById(R.id.Copyright);
|
final TextView textVersionView = (TextView) findViewById(R.id.Copyright);
|
||||||
final Calendar inst = Calendar.getInstance();
|
final Calendar inst = Calendar.getInstance();
|
||||||
inst.setTime(new Date());
|
inst.setTime(new Date());
|
||||||
|
@ -150,7 +150,7 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
about.setMovementMethod(LinkMovementMethod.getInstance());
|
about.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFragments() {
|
public void addFragments() {
|
||||||
android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
|
android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
|
||||||
android.support.v4.app.FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
android.support.v4.app.FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||||
//after rotation list of fragments in fragment transaction is not cleared
|
//after rotation list of fragments in fragment transaction is not cleared
|
||||||
|
@ -175,6 +175,7 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
DashPluginsFragment pluginsFragment = new DashPluginsFragment();
|
DashPluginsFragment pluginsFragment = new DashPluginsFragment();
|
||||||
fragmentTransaction.add(R.id.content, pluginsFragment, DashPluginsFragment.TAG).commit();
|
fragmentTransaction.add(R.id.content, pluginsFragment, DashPluginsFragment.TAG).commit();
|
||||||
}
|
}
|
||||||
|
setupContributionVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showAboutDialog(final Activity activity, final OsmandApplication app) {
|
public static void showAboutDialog(final Activity activity, final OsmandApplication app) {
|
||||||
|
@ -231,9 +232,6 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
startActivityForResult(mapIndent, 0);
|
startActivityForResult(mapIndent, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
startProgressDialog = new ProgressDialog(this);
|
|
||||||
getMyApplication().checkApplicationIsBeingInitialized(this, startProgressDialog);
|
|
||||||
boolean dialogShown = false;
|
|
||||||
boolean firstTime = false;
|
boolean firstTime = false;
|
||||||
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
|
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
|
||||||
boolean appVersionChanged = false;
|
boolean appVersionChanged = false;
|
||||||
|
@ -248,7 +246,6 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
if (appCustomization.showFirstTimeRunAndTips(firstTime, appVersionChanged)) {
|
if (appCustomization.showFirstTimeRunAndTips(firstTime, appVersionChanged)) {
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
applicationInstalledFirstTime();
|
applicationInstalledFirstTime();
|
||||||
dialogShown = true;
|
|
||||||
} else {
|
} else {
|
||||||
int i = pref.getInt(TIPS_SHOW, 0);
|
int i = pref.getInt(TIPS_SHOW, 0);
|
||||||
if (i < 7) {
|
if (i < 7) {
|
||||||
|
@ -259,48 +256,21 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
|
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
|
||||||
Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
|
Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
|
||||||
dlg.show();
|
dlg.show();
|
||||||
dialogShown = true;
|
|
||||||
} else {
|
} else {
|
||||||
if(appVersionChanged) {
|
if(appVersionChanged) {
|
||||||
final Intent helpIntent = new Intent(activity, HelpActivity.class);
|
final Intent helpIntent = new Intent(activity, HelpActivity.class);
|
||||||
helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(getMyApplication()));
|
helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(getMyApplication()));
|
||||||
helpIntent.putExtra(HelpActivity.URL, "changes-1.9.html");
|
helpIntent.putExtra(HelpActivity.URL, "changes-1.9.html");
|
||||||
activity.startActivity(helpIntent);
|
activity.startActivity(helpIntent);
|
||||||
dialogShown = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!dialogShown && appCustomization.checkBasemapDownloadedOnStart()) {
|
|
||||||
if (startProgressDialog.isShowing()) {
|
|
||||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
||||||
@Override
|
|
||||||
public void onDismiss(DialogInterface dialog) {
|
|
||||||
checkVectorIndexesDownloaded();
|
|
||||||
updateDownloads();
|
|
||||||
// Do some action on close
|
|
||||||
// FIXME uncomment
|
|
||||||
// app.getResourceManager().getRenderer().clearCache();
|
|
||||||
// mapView.refreshMap(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
checkVectorIndexesDownloaded();
|
|
||||||
updateDownloads();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(appCustomization.checkExceptionsOnStart() && !dialogShown){
|
|
||||||
checkPreviousRunsForExceptions(firstTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if(appCustomization.checkExceptionsOnStart()){
|
||||||
protected Dialog onCreateDialog(int id) {
|
checkPreviousRunsForExceptions(firstTime);
|
||||||
if(id == OsmandApplication.PROGRESS_DIALOG){
|
|
||||||
return startProgressDialog;
|
|
||||||
}
|
}
|
||||||
return super.onCreateDialog(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applicationInstalledFirstTime() {
|
private void applicationInstalledFirstTime() {
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.actionbarsherlock.app.SherlockFragment;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.DashboardActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by dummy on 02.12.14.
|
||||||
|
*/
|
||||||
|
public class DashLoadingFragment extends SherlockFragment {
|
||||||
|
OsmandApplication app;
|
||||||
|
private View view;
|
||||||
|
|
||||||
|
public DashLoadingFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||||
|
view = inflater.inflate(R.layout.loading, container, false);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(final View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
if(app.isApplicationInitializing()) {
|
||||||
|
app.checkApplicationIsBeingInitialized(getActivity(), (TextView) view.findViewById(R.id.ProgressMessage),
|
||||||
|
(ProgressBar) view.findViewById(R.id.ProgressBar), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
(view.findViewById(R.id.ProgressMessage)).setVisibility(View.GONE);
|
||||||
|
view.findViewById(R.id.ProgressBar).setVisibility(View.GONE);
|
||||||
|
DashboardActivity dashboardActivity =((DashboardActivity)getSherlockActivity());
|
||||||
|
dashboardActivity.getSupportFragmentManager().beginTransaction().detach(DashLoadingFragment.this);
|
||||||
|
dashboardActivity.updateDownloads();
|
||||||
|
dashboardActivity.addFragments();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
DashboardActivity dashboardActivity =((DashboardActivity)getSherlockActivity());
|
||||||
|
dashboardActivity.getSupportFragmentManager().beginTransaction().detach(DashLoadingFragment.this);
|
||||||
|
dashboardActivity.updateDownloads();
|
||||||
|
dashboardActivity.addFragments();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -75,13 +75,14 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
||||||
downloadButtons.clear();
|
downloadButtons.clear();
|
||||||
mainView.findViewById(R.id.main_progress).setVisibility(View.GONE);
|
mainView.findViewById(R.id.main_progress).setVisibility(View.GONE);
|
||||||
((TextView) mainView.findViewById(R.id.update_count)).setText(String.valueOf(list.size()));
|
((TextView) mainView.findViewById(R.id.update_count)).setText(String.valueOf(list.size()));
|
||||||
if (list.size() < 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LinearLayout updates = (LinearLayout) mainView.findViewById(R.id.updates_items);
|
LinearLayout updates = (LinearLayout) mainView.findViewById(R.id.updates_items);
|
||||||
updates.removeAllViews();
|
updates.removeAllViews();
|
||||||
|
|
||||||
|
if (list.size() < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
final IndexItem item = list.get(i);
|
final IndexItem item = list.get(i);
|
||||||
if (i > 2) {
|
if (i > 2) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class SherpafyLoadingFragment extends SherlockFragment {
|
||||||
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container,
|
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
app = (OsmandApplication) getSherlockActivity().getApplication();
|
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||||
view = inflater.inflate(R.layout.sherpafy_loading, container, false);
|
view = inflater.inflate(R.layout.loading, container, false);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue