Dynamic image path in Ionic 2 doesn't work on device - ionic2

I'm using Ionic 2.2 and normally I reference the pictures like this:
<img src="assets/images/img.svg" />
Which works fine in both browser and device.
But our app uses themes, and I need to change the image folder based on which theme the user selects.
In my html:
<img src="{{getImagePath('image1.svg')}}">
In typescript file:
getImagePath(img){
if(this.theme == 'special'){
return 'assets/images/special/' + img;
} else {
return 'assets/images/' + img;
}
}
This works in browser but, not in device.
What is the correct way to do this?
I also tried [src]="getImagePath('image1.svg')" which had the same result. And tried to play with the path like ../assets and couple other variation but couldn't find the right way.

Turns out that reinstalling the platform and plugins solved my issue.
The code in the question is correct and now working on android device.

Related

SwiftUI - open link from my website in the app

I have one SwiftUI - iOS app running, and I need to open the link from email/whatsapp/etc in my app.
So lets say the link is like this (from my website):
https://www.mapplebook.com/welcome;id=123
I have tried the custom Scheme, which works fine, but for that i need to do something like: myScheme://www.mapplebook.com/etc....
Which is bad because Website and Android only understand things without the scheme.
The universal link looks like the best approach, I read a couple of things about Apple docs and some other questions, but could not make it work. :(
Is there any suggestion? Maybe some tutorial that I am missing.
Any help is much appreciated.
Editing the question as requested:
This is my info.plist - In this case I am using the custom scheme mapplebook
In SceneDelegate.swift, I have the followng:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url else {
return
}
if let range = url.absoluteString.range(of:"https//www.mapplebook.com/id=") {
let sharedtoken = url.absoluteString[range.upperBound...]
//with sharedtoken i can redirect internally and open the correct view - working okay
}
}
But, as mentioned, that uses scheme mapplebook right?
Is it possible to have something like in android, where we say like:
android:host="mapplebook.com"
android:pathPattern="/something"
android:scheme="https" />
So it ask to open the https://mapplebook.com/something url in my app.
Thank you Koen for helping.

Extension doesn't get enabled

I'm migrating extension for Opencart 2.3 to Opencart 3. Everything seems to work fine, except that I can't enable the extension. When I go to extension->shipping the status doesn't change it stays disabled, however if I go to settings, the drop down shows that enabled is selected. There aren't any errors on the front-end, or in the log files. I tried debugging but everything seems fine. Any ideas what may be wrong? Also the setting in the database(extensionName_status) is 1
Note: the extension is large, and it will be too much if I post it here. If you need specific fragment of code, I will provide it.
The tricky thing about the 2.3->3.0 migration was that some variable names changed in a subtle way (as noted in my comment above). The status variable could be your problem. Here's Better Together 3.0 (left) vs 2.3 (right) in the controller file:
< $data['total_better_together_status'] = $this->config->get('total_better_together_status');
---
> $data['better_together_status'] = $this->config->get('better_together_status');
If your OpenCart 3.x module is labeled in the Modules category, then:
if (isset($this->request->post['module_mymodule_status'])) {
$data['module_mymodule_status'] = $this->request->post['module_mymodule_status'];
} else {
$data['module_mymodule_status'] = $this->config->get('module_mymodule_status');
}
Or if it's labeled in the Analytics category, then you just change the module to analytics as shown below:
if (isset($this->request->post['analytics_mymodule_status'])) {
$data['analytics_mymodule_status'] = $this->request->post['analytics_mymodule_status'];
} else {
$data['analytics_mymodule_status'] = $this->config->get('analytics_mymodule_status');
}

Unable to get a custom helpfile to work from inside a Qt Application using Qt Assistant

I am trying to learn how to use Qt Assistant for displaying a custom help in an application.
I found an example on Qt site:
http://qt-project.org/doc/qt-4.7/help-simpletextviewer.html
(using Qt 4.7.3)
All the source files needed are at the site above. I created html and png files and placed them in a "help" folder inside the project folder.
Running Qt Assistant from command line works great.
Loading the help file in the Assistant also works. What I can't get to do is to load the start page in the help file, as explained in this section:
http://qt-project.org/doc/qt-4.7/assistant-custom-help-viewer.html#id-0c628592-dd04-4465-94b1-e5d4a91d7cd4
void Assistant::showDocumentation(const QString &page)
{
if (!startAssistant())
return;
QByteArray ba("SetSource ");
ba.append("qthelp://com.trolltech.examples.simpletextviewer/doc/");
proc->write(ba + page.toLocal8Bit() + '\n');
}
With the detailed explanation of SetSource showing
setSource <Url> Displays the given <Url>. The URL can be absolute or relative
to the currently displayed page. If the URL is absolute, it has to be
a valid Qt help system URL; i.e., starting with "qthelp://".
I don't have a web page... but i tried to display the index from the local set of files, and i always get
a 404 error saying "cannot load page blahblah/help/index.html"
How can I create a local path as they say, or how can I create a "valid Qt help system URL" ?``
Note: SetSource and setSource have exactly the same results... and documentation and their own examples use them both... are these options not case sensitive ?
I answered my own question with a solution that doesn't seem right though... I would appreciate a better answer.
There must be something wrong with either my solution or the documentation...
I was able to get the page to display by changing an option...
replace QByteArray ba("SetSource ");
with QByteArray ba("Set Source ");

Getting an incorrect permissions screen in the webview Blackberry 10 Cascades Beta 3 SDK in Dev Alpha Simulator

I am trying to make dynamically generated html 5 graphs show up in a webview in Blackberry 10 Cascades. I have confirmed the html5 that I have generated, draws the correct graphs. My problem is that when I try to implement this in the Blackberry 10 Cascades Beta 3 SDK (using the Blackberry 10 Dev Alpha Simulator), the webview that is supposed to show the graph, just looks like this:
Here is the code that leads to this error:
//html_ already contains the html-5 code to make the graph at this point in the code
//This is the file path to a local file that is actually accessable in the emulator
//and not just from Windows
//
QFile *chartFile = new QFile("app/native/assets/data/chart.html");
if (chartFile->open(QIODevice::WriteOnly)) {
chartFile->write(html_.toUtf8());
chartFile->flush();
chartFile->close();
}
if (chartFile) delete chartFile;
if (graphView_) {
graphView_->setHtml("");
graphView_->setUrl(QUrl::fromLocalFile("app/native/assets/data/chart.html"));
}
I checked the permissions of that file, put they are all Allow (777 permissions for those who know Unix style permissions).
I added access_internet to the bar-descriptor.xml, eventhough my app was already able to access remote sites, just to see if that would fix it, but it did not.
I've been searching around trying to find a solution to this problem, but I have not.
If anyone could help me out with this, it would be greatly appreciated.
-------------------------------------------------------
Update:
I changed the code to set the html directly, now I have this:
if (graphView_) {
graphView_->setHtml(html_, QUrl("app/native/assets/data/chart.html"));
}
But nothing shows. It seems I have the wrong relative path relative to my base url.
My base url is this: QUrl("app/native/assets/data/chart.html")
My relative paths all begin with: ./Highcharts/js/...
My relative paths are located under: app/native/assets/data/Highcharts/js
It seems to me that I this should work, but when I do this, I just a blank screen, as if it can not find my relative paths. So I don't know what's going on here either.
I found a solution that works. I'm using the first approach, not the updated approach, but instead of
graphView_->setUrl(QUrl("app/native/assets/data/chart.html"));
I'm using:
graphView_->setUrl(QUrl("local:///assets/data/chart.html"));
And I have left the rest of the code the same, and it works.

Thumbnail Provider not working

I'm trying to write a Windows Explorer thumbnail handler for our custom file type. I've got this working fine for the preview pane, but am having trouble getting it to work for the thumbnails.
Windows doesn't even seem to be trying to call the DllGetClassObject entry point.
Before I continue, note that I'm using Windows 7 and unmanaged C++.
I've registered the following values in the registry:
HKCR\CLSID\<my guid>
HKCR\CLSID\<my guid>\InprocServer32 (default value = path to my DLL)
HKCR\CLSID\<my guid>\InprocServer32\ThreadingModel (value = "Apartment")
HKCR\.<my ext>\shellex\{E357FCCD-A995-4576-B01F-234630154E96} (value = my guid)
I've also tried using the Win SDK sample, and that doesn't work. And also the sample project in this article (http://www.codemonkeycodes.com/2010/01/11/ithumbnailprovider-re-visited/), and that doesn't work.
I'm new to shell programming, so not really sure the best way of debugging this. I've tried attaching the debugger to explorer.exe, but that doesn't seem to work (breakpoints get disabled, and none of my OutputDebugStrings get displayed in the output window). Note that I tried setting the "DesktopProcess" in the registry as described in the WinSDK docs for debugging the shell, but I'm still only seeing one explorer.exe in the task manager - so that "may" be why I can't debug it??
Any help with this would be greatly appreciated!
Regards,
Dan.
I stumbled across this since you mentioned my blog ( codemonkeycodes.com ).
What problem are you having with my sample? Did you register you DLL using regsvr32? What version of Windows 7 are you on, 32 or 64?
Update:
I can't say what is or isn't working for you. I just downloaded the sample from my site, followed the directions and change the function
STDMETHODIMP CThumbnailProvider::GetThumbnail... to look like
{
*phbmp = NULL;
*pdwAlpha = WTSAT_UNKNOWN;
ULONG_PTR token;
GdiplusStartupInput input;
if (Ok == GdiplusStartup(&token, &input, NULL))
{
//gcImage.LogBuffer();
Bitmap * pBitmap = new Bitmap(188, 141);
if( pBitmap )
{
Color color(0, 0, 0);
pBitmap->GetHBITMAP(color, phbmp);
}
}
GdiplusShutdown(token);
if( *phbmp != NULL )
return NOERROR;
return E_NOTIMPL;
}
I registered the DLL and then created a new file with the proper extension, and tada, I had a nice black thumbnail.
I wish I could help you. Maybe you want to email me your code?
I've exactly the same problem. I cant make SDK or any sample works. I need COM sample because I must call Microsoft.Jet.OLEDB.4.0 which works only on 32 bits system.
I couldnt make this work: link
This works if AnyCPU is specified when compiling. Cant make it works for x86: link
This was nice under XP works like a charm: link
This show Adobe had problems with thumbnail An MS with Office 2007 (32 bits): link