Jump to content

RobYost

uniGUI Subscriber
  • Posts

    207
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by RobYost



  1. // =============================================================================
    function rtnAllParms(): String;
    var
      i: Integer;
      p: String;
    begin
      for i := 0 to UniApplication.Parameters.count - 1 do
      begin
        p := p + '&' + UniApplication.Parameters[i];
      end;
      Result := p;
    end;




    //This way you can pass a parameter without '=true'
    //example: www.xxx.com?Demo&LoadData
    // if(ParmExists('Demo') then DoSomething
    // =============================================================================
    function ParmExists(aParm: string): Boolean;
    var
      i: Integer;
    begin
      Result := False;
      for i  := 0 to UniApplication.Parameters.count - 1 do
      begin
        if (UpperCase(aParm) = UpperCase(Copy(UniApplication.Parameters[i], 1, Length(aParm)))) then
        begin
          Result := True;
          Break;
        end;
      end;
    end;




    // =============================================================================
    function DeleteParm(aParm: string): Boolean;
    var
      i: Integer;
    begin
      Result := False;
      for i  := 0 to UniApplication.Parameters.count - 1 do
      begin
        if (UpperCase(aParm) = UpperCase(Copy(UniApplication.Parameters[i], 1, Length(aParm)))) then
        begin
          UniApplication.Parameters.Delete(i);
        end;
      end;
    end;

  2. DelphiDeveloper -  I think what Jahlxx is trying to say is:

     

    In Delphi, if you get an error message (from showmessage, etc.) you can click CTRL-C  and the message is copied to

    the clipboard. This doesn't work with UniGui messages.  

     

    -----------------------------

    One solution I just thought of.

    procedure MyShowMessage(aText: String);
    begin
        Clipboard.AsText := aText;
        ShowMessage(aText);
    end;
    

    I just typed this code in.  I didn't test it.  It is just an idea.

  3. This is not a complaint  I am very happy with UniGUI, BUT

    it seems there are many times I get on the support forum and ask how to do something and the answer is I have to do it in JavaScript.

     

    DelphiDeveloper goes to the trouble to answer the question

     

    for example:

     

    Hi,

     

    Can you try this approach for now ?!:

     

    UnimLabel1 -> ClientEvents -> UniEvents -> function afterCreate:

    function afterCreate(sender)
    {
        var me = sender;
        me.element.on("tap",
            function() {
                me.fireEvent("click");
            }
        )
    }

    Best regards,

     

     
    But really wouldn't it have been easier for everyone if he just added this code to the constructor of UnimCustomLabel?
     
     
    I changed the constructor, and it works (just as a test, I know it will go away next release.
    constructor TUnimCustomLabel.Create(AOwner: TComponent);
    begin
      inherited;
      Width  := 225;
      Height := 23;
    
      ClientEvents.UniEvents.Add
        ('afterCreate=function afterCreate(sender) '#13#10'{'#13#10'    var me = sender;'#13#10'    me.element.on("tap",'#13#10'        function() {'#13#10'               me.fireEvent("click");'#13#10'        }'#13#10'    )'#13#10'}');
    
    end;

    This is just an example.  The font properties are ignored on mLable.  I added the code DelphiDeveloper supplied to the Update function and it also works.  

     

    It just seems to me it would be just as easy to add this functionality than it would be to send me JS code to fix it, then you won't be asked that question again because I see people (including me) ask the same question again.

     
    • Upvote 2
  4. When I rotate my phone when using the android app I wrote it goes back to the sign in form.

     

    If I rotate while in a browser it does not.

     

    My android app is very simple it only has one control on it; a WebView.

     

    Does anyone know where to start looking?  Or is there a setting in UniGui that will disallow the restart.  I have an option on my main form to log out, so if I could disable it elsewhere.

     

     

  5. Add the two lines to MainActivity.java

    package com.simple_landlord.simplelandlord;
    
    import android.support.v7.app.ActionBarActivity;
    
    import android.os.Bundle;
    import android.webkit.WebSettings;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;        ​<====Add this line
    
    public class MainActivity extends ActionBarActivity {
      private WebView mWebView;
    
      @Override
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        mWebView = (WebView) findViewById(R.id.activity_main_webview);
        WebSettings webSettings = mWebView.getSettings();
        mWebView.setInitialScale(1);
        mWebView.getSettings().setLoadWithOverviewMode(true);
        mWebView.getSettings().setUseWideViewPort(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
    
        mWebView.setWebViewClient(new WebViewClient());   <====Add this line
    
        mWebView.loadUrl("https://secure.simple-landlord.com/m");
      }
    }
  6. on my mobile app I have two menu items

     

    1. Go to Full Site

    UniSession.UrlRedirect(URL);

    2. Logout (Which takes you to the login screen)

    UniApplication.Restart;

    Both of these work correctly on my phone while in a browser.

     

    But when I created an android app that only has one component on it, a WebView

    <WebView
    android:id="@+id/activity_main_webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

    They do nothing when clicked.  

     

    I don't really know how WebView works, but it looks like I need to send something different to WebView to get it redirect.

     

     

  7. Got it working...I had uploaded an older apk.

    I need to figure out how to upload to google store, but I think I am almost there.

     

    Hope this helps someone.

     

     

    AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.simple_landlord.simplelandlord">
    <uses-permission android:name="android.permission.INTERNET" />
    
    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppFullScreenTheme">
    <activity android:name=".MainActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    </application>
    
    </manifest>

    styles.xml

    <resources>
    
    <style name="AppFullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    </style>
    
    </resources>
    

    activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.simple_landlord.simplelandlord.MainActivity">
    
    <WebView
    android:id="@+id/activity_main_webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />
    
    </android.support.constraint.ConstraintLayout>

    build.gradle

    dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
       exclude group: 'com.android.support', module: 'support-annotations'
      })
      compile 'com.android.support:appcompat-v7:25.0.0'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
      testCompile 'junit:junit:4.12'
    }
    

    MainActivity.java

    package com.simple_landlord.simplelandlord;
    
    import android.support.v7.app.ActionBarActivity;
    import android.os.Bundle;
    import android.webkit.WebSettings;
    import android.webkit.WebView;
    
    
    
    public class MainActivity extends ActionBarActivity {
      private WebView mWebView;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        mWebView = (WebView) findViewById(R.id.activity_main_webview);
        WebSettings webSettings = mWebView.getSettings();
        mWebView.setInitialScale(1);
        mWebView.getSettings().setLoadWithOverviewMode(true);
        mWebView.getSettings().setUseWideViewPort(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("https://YOUR_URL/m");
      }
    }
    • Like 1
  8. I tried that, but it made no difference.

     

     

    But you can try to use BeginUpdate, EndUpdate methods:
    var
      n1, n2, n3: TUniTreeNode;
    begin
      nl1.BeginUpdate;
      n1 := nl1.Items.Add(nil, '11111');
      n2 := nl1.Items.Add(nil, '22222');
      n3 := nl1.Items.Add(nil, '33333');
    
      nl1.Items.Add(n1, 'aaaa');
      nl1.Items.Add(n2, 'bbbb');
      nl1.Items.Add(n3, 'cccc');
      nl1.EndUpdate;
    end;

     

  9. Mohammad: I went back to my Android Studio and ran it and it worked in the emulator. 

     

    I don't know much about android apps, so what I did was email the apk file to myself.  On my phone, I opened the attachment and clicked install.  It added an app on my phone, but when I click on it pops up a message:

     

    SimpleLandlord has stopped

    X Close

     

    Any ideas?

  10. Mohammad:  I've tried Android Studio but I couldn't get it to work.  I will look back and see what the problem was, it was a few months ago.

     

    Dan: I have XE6 and it won't make an app for the current release of Android.  At this point, I can't afford to update to the latest version of Delphi.

  11. I have attached the whole test project but this is the main code.

    unit Mainm;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics,
      Controls, Forms, uniGUITypes, uniGUIAbstractClasses,
      uniGUIClasses, uniGUImClasses, uniGUIRegClasses, uniGUIForm, uniGUImForm, uniGUImJSForm, uniGUIBaseClasses, uniTreeView, unimNestedList,
      uniButton, unimButton;
    
    type
      TMainmForm = class(TUnimForm)
        nl1: TUnimNestedList;
        btn1: TUnimButton;
        procedure btn1Click(Sender: TObject);
        procedure UnimFormShow(Sender: TObject);
        procedure nl1LeafClick(Sender: TObject);
      private
      public
        { Public declarations }
      end;
    
    function MainmForm: TMainmForm;
    
    implementation
    
    {$R *.dfm}
    
    uses
      uniGUIVars, MainModule, uniGUIApplication;
    
    function MainmForm: TMainmForm;
    begin
      Result := TMainmForm(UniMainModule.GetFormInstance(TMainmForm));
    end;
    
    procedure TMainmForm.nl1LeafClick(Sender: TObject);
    begin
      MessageDlg('Leaf Clicked', mtInformation, [mbOK]);
    end;
    
    procedure addItems(nl: TUnimNestedList);
    var
      n1, n2, n3: TUniTreeNode;
    begin
      n1 := nl.Items.Add(nil, '11111');
      n2 := nl.Items.Add(nil, '22222');
      n3 := nl.Items.Add(nil, '33333');
    
      nl.Items.Add(n1, 'aaaa');
      nl.Items.Add(n2, 'bbbb');
      nl.Items.Add(n3, 'cccc');
    end;
    
    procedure TMainmForm.btn1Click(Sender: TObject);
    begin;
      // only the first item of the list when clicked goes to its subitem.
      addItems(nl1);
    end;
    
    procedure TMainmForm.UnimFormShow(Sender: TObject);
    begin
      // Uncomment below and you will see it works correctly
      // addItems(nl1);
    end;
    
    initialization
    
    RegisterAppFormClass(TMainmForm);
    
    end.
  12. if I add code to the form show I am able to add subItems

    procedure TMainmForm.UnimFormShow(Sender: TObject);
    var
      n1, n2, n3: TUniTreeNode;
    begin
      n1 := nl1.Items.Add(nil, '11111');
      n2 := nl1.Items.Add(nil, '22222');
      n3 := nl1.Items.Add(nil, '33333');
    
      nl1.Items.Add(n1, 'aaaa');
      nl1.Items.Add(n2, 'bbbb');
      nl1.Items.Add(n3, 'cccc');
    end;

    Clicking on 1 goes to a; 2 goes to b etc.

     

    but if I put the very same code in a button

    procedure TMainmForm.btn1Click(Sender: TObject);
    var
      n1, n2, n3: TUniTreeNode;
    begin
      n1 := nl1.Items.Add(nil, '11111');
      n2 := nl1.Items.Add(nil, '22222');
      n3 := nl1.Items.Add(nil, '33333');
    
      nl1.Items.Add(n1, 'aaaa');
      nl1.Items.Add(n2, 'bbbb');
      nl1.Items.Add(n3, 'cccc');
    end;

    clicking on 1 goes to a, but clicking on 2 and 3 trigger OnLeafClick and have no subitems

     

  13. I think I remember a thread that addressed this, but I can not find it.

     

    I want to create an iPhone app and an Android app that just goes to my website that runs my UniGui application.

     

    Does anyone know the easiest way to accomplish this?  I have tried some of the free app builders, with limited success.

     

    People want to download an app not navigate to a web page, or add a shortcut to their phone, plus it is another way to advertise.

     

    Thanks,

    Rob

  14. I tried using the TUnimButton

     

    I changed the iconcls to 'hamburger' (with out quotes)

    and the button is blank.

    If I use one of the ones in the list like 'more' it does work.

     

    also, is there a list of the pictures of what each icon looks like anywhere?

  15. Thanks, Eduardo, That fixed it.

     

    Hayri, I couldn't find sweetalert.js but I did have sweetalert2.min.js and sweetalert2.common.js

     

    I didn't try copying them, I moved the whole folder and it worked.

     

    Thanks for the help.

  16. I added Sistema Fenix to my project to use the  Sweet Alert component.

     

    It works fine on my development machine, but when I put on my server I get:

     

    Ajax Error

    swal is not defined

    swal({
        title: 'Demo',
        html: 'Account Information not available in Demo mode',
        type: 'info',
        showConfirmButton: true,
        showCancelButton: false,
        confirmButtonText:  'OK',
        cancelButtonText:  '',
        animation:  true,
        allowEscapeKey:  false,
        confirmButtonColor: '#BDBF37',
        cancelButtonColor: '#d33',
        timer:  0,
        allowOutsideClick:  false
    });

     

    swal is not defined
     
×
×
  • Create New...