@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); settings = ((OsmandApplication) getApplication()).getSettings(); if (downloadListIndexThread == null) { downloadListIndexThread = new DownloadIndexesThread(this); } setContentView(R.layout.download_index); indeterminateProgressBar = (ProgressBar) findViewById(R.id.IndeterminateProgressBar); determinateProgressBar = (ProgressBar) findViewById(R.id.DeterminateProgressBar); progressView = findViewById(R.id.ProgressView); progressMessage = (TextView) findViewById(R.id.ProgressMessage); progressPercent = (TextView) findViewById(R.id.ProgressPercent); cancel = (ImageView) findViewById(R.id.Cancel); int d = settings.isLightContent() ? R.drawable.a_1_navigation_cancel_small_light : R.drawable.a_1_navigation_cancel_small_dark; cancel.setImageDrawable(getResources().getDrawable(d)); cancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { makeSureUserCancelDownload(); } }); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setTitle(R.string.local_index_download); // recreation upon rotation is prevented in manifest file findViewById(R.id.DownloadButton) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { downloadFilesCheckFreeVersion(); } }); filterText = (EditText) findViewById(R.id.search_box); textWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) {} @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { DownloadIndexAdapter adapter = ((DownloadIndexAdapter) getExpandableListAdapter()); if (adapter != null) { adapter.getFilter().filter(s); } } }; filterText.addTextChangedListener(textWatcher); final Intent intent = getIntent(); if (intent != null && intent.getExtras() != null) { final String filter = intent.getExtras().getString(FILTER_KEY); if (filter != null) { filterText.setText(filter); } } List<IndexItem> list = new ArrayList<IndexItem>(); downloadListIndexThread.setUiActivity(this); if (downloadListIndexThread.getCachedIndexFiles() != null && downloadListIndexThread.isDownloadedFromInternet()) { downloadListIndexThread.runCategorization(type); } else { downloadListIndexThread.runReloadIndexFiles(); } DownloadIndexAdapter adapter = new DownloadIndexAdapter(this, list); setListAdapter(adapter); if (getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) { boolean showedDialog = false; if (Build.VERSION.SDK_INT < OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) { SuggestExternalDirectoryDialog.showDialog(this, null, null); } if (!showedDialog) { showDialogOfFreeDownloadsIfNeeded(); } } else { showDialogOfFreeDownloadsIfNeeded(); } final DownloadActivityType[] downloadTypes = getDownloadTypes(); spinnerAdapter = new ArrayAdapter<String>( getSupportActionBar().getThemedContext(), R.layout.sherlock_spinner_item, new ArrayList<String>(Arrays.asList(toString(downloadTypes)))); spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); getSupportActionBar() .setListNavigationCallbacks( spinnerAdapter, new OnNavigationListener() { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { changeType(downloadTypes[itemPosition]); return true; } }); if (Build.VERSION.SDK_INT >= OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) { if (!settings .getExternalStorageDirectory() .getAbsolutePath() .equals(settings.getDefaultExternalStorageLocation())) { AccessibleAlertBuilder ab = new AccessibleAlertBuilder(this); ab.setMessage( getString( R.string.android_19_location_disabled, settings.getExternalStorageDirectory())); ab.setPositiveButton( R.string.default_buttons_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { copyFilesForAndroid19(); } }); ab.setNegativeButton(R.string.default_buttons_cancel, null); ab.show(); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); settings = ((OsmandApplication) getApplication()).getSettings(); if (downloadListIndexThread == null) { downloadListIndexThread = new DownloadIndexListThread(this); } // recreation upon rotation is prevented in manifest file CustomTitleBar titleBar = new CustomTitleBar( this, R.string.local_index_download, R.drawable.tab_download_screen_icon); setContentView(R.layout.download_index); titleBar.afterSetContentView(); downloadFileHelper = new DownloadFileHelper(this); findViewById(R.id.DownloadButton) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { downloadFilesCheckFreeVersion(); } }); updateLoadedFiles(); filterText = (EditText) findViewById(R.id.search_box); textWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) {} @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { DownloadIndexAdapter adapter = ((DownloadIndexAdapter) getExpandableListAdapter()); if (adapter != null) { adapter.getFilter().filter(s); } } }; filterText.addTextChangedListener(textWatcher); final Intent intent = getIntent(); if (intent != null && intent.getExtras() != null) { final String filter = intent.getExtras().getString(FILTER_KEY); if (filter != null) { filterText.setText(filter); } } if (downloadListIndexThread.getCachedIndexFiles() != null) { setListAdapter(new DownloadIndexAdapter(downloadListIndexThread.getCachedIndexFiles())); } else { downloadIndexList(); } if (Version.isFreeVersion(this) && settings.checkFreeDownloadsNumberZero()) { Builder msg = new AlertDialog.Builder(this); msg.setTitle(R.string.free_version_title); msg.setMessage( getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + "", "")); msg.show(); } }