2018年12月22日 星期六

如何在 Blogger 顯示程式碼


● 設定方式參考:
[探索 3 分鐘] 用 JavaScript 與 css 客製化部落格 blogger
使用Google Code Prettify漂亮顯示讓程式碼自動分辨顏色
在 Google Blogger 顯示程式碼

● 選用樣式:
https://rawgit.com/google/code-prettify/master/styles/index.html
https://jmblog.github.io/color-themes-for-google-code-prettify/

例如:選用 Sunburst 的樣式,把 sunburst.css 裡面的碼,貼到 「HTML / JavaScript 」小工具的 style 區塊中

● 設定 Delphi 語言顯示:
在文章的 code 區塊中,設定 class="pascal"

● 程式碼中有 html 語法標籤的時候要轉碼
http://demo.smarttutorials.net/html-xml-adsense-parser/

<pre class="prettyprint">
<code class="pascal">
</code>
</pre>

Delphi XE10.3 Rio 實作 Android 8 的 Notification Channels

 
{$IFDEF ANDROID}

uses FMX.PushNotification.Android, Androidapi.Helpers, Androidapi.Jni.Os,
  Androidapi.Jni.App, Androidapi.Jni.GraphicsContentViewText,
  Androidapi.Jni.JavaTypes, Androidapi.JNIBridge;
{$ENDIF}

procedure TForm1.createNotificationChannel();
var
  LService: JObject;
  FNotificationManager : JNotificationManager;
  FNotificationChannel: JNotificationChannel;
  LApplicationInfo: JApplicationInfo;
  targetSdkVersion: Integer;
begin
{$IFDEF ANDROID}
  LService := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.NOTIFICATION_SERVICE);
  FNotificationManager  := TJNotificationManager.Wrap((LService as ILocalObject).GetObjectID);

//    if TAndroidHelperEx.CheckBuildAndTarget(TAndroidHelperEx.OREO) then
// Tony 參考 https://github.com/DelphiWorlds/KastriFree/blob/master/Core/DW.Android.Helpers.pas 改寫
  LApplicationInfo := TAndroidHelper.Context.getPackageManager.
    getApplicationInfo(TAndroidHelper.Context.getPackageName, 0);
  targetSdkVersion := LApplicationInfo.targetSdkVersion;

  if (TJBuild_VERSION.JavaClass.SDK_INT >= 26) and (targetSdkVersion >= 26) then
  begin
    FNotificationChannel := TJNotificationChannel.JavaClass.init(TAndroidHelper.Context.getPackageName, StrToJCharSequence('default'), 4);
    FNotificationChannel.enableLights(True);
    FNotificationChannel.enableVibration(True);
    FNotificationChannel.setLightColor(TJColor.JavaClass.GREEN);
    FNotificationChannel.setLockscreenVisibility(TJNotification.JavaClass.VISIBILITY_PRIVATE);
    FNotificationManager.createNotificationChannel(FNotificationChannel);
  end;
{$ENDIF}
end;