カテゴリー: IDE・ツール・ライブラリ関連

コンテキストメニューの”編集”からストアアプリ版Paint.Netを開く

<あらすじ>
前回(一年半ほど前)、ストアアプリ版Paint.Netに複数画像を"送る"で、ストアアプリ版のPaint.Netで選択した複数画像を開く方法を確立し、自らを天才かと錯覚し歓喜していた俺氏だったが、日に日にその操作量に不満を募らせていた…

( ゜σ・゚)ホジホジ。oO(コンテキストメニューから[送る]-[ToPaintDotNET.cmd]を選択するのってめんどくせぇな…)

というわけでなんか作業量を減らす方法を調べてみる。


面倒くさいから結論から書くが、レジストリエディタ開いて、
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit\command]の値というかデータで指定されている実行プログラム("%systemroot%\system32\mspaint.exe")の部分を、どっかに置いた"ToPaintDotNET.cmd"のフルパスにすれば良いだけだった。

具体的には[ 『"C:\Users\username\AppData\Roaming\Microsoft\Windows\SendTo\ToPaintDotNET.cmd" "%1"』という感じにする。面倒くさいのでSendToに置いてあるのをそのまま指定した(ノ∀`)

※ちなみにパスを直書きではなく
"%APPDATA%\Roaming\Microsoft\Windows\SendTo\ToPaintDotNET.cmd" "%1"』とすると下記の確認というか選択ダイアログが出てきて、うざいことこの上なくなるので注意が必要である(ヽ'ω`)ナゼカハシラン


ストアアプリの実体exeらしきものの場所は調べてわかったけれど、単純にそれを指定しても権限だかなんかで実行出来なかったので、前回同様にbatをはさんだ。もっと良い方法があるのかもしれないが、まあこの方法でも複数画像を開けるので、これはこれで良しとする(`・ω・´)

本当はコンソールウィンドウの表示も抑制したいけど、VBSとかで起動しないと駄目そうだからやめとこうw

『Android Kotlin Fundamentals』をやった(4)

Android Kotlin Fundamentals: Lifecycles and logging

3. Explore the lifecycle methods and add basic logging

Step 1: Examine the onCreate() method and add logging

項番6が改行されていない。


4. Use Timber for logging

Step 2: Create an Application class and initialize Timber

Warning: It might be tempting to add your own code to the Application class, because the class is created before all of your activities and can hold global state. But just as it's error-prone to make readable and writable static variables that are globally available, it's easy to abuse the Application class. Avoid putting any activity code in the Application class unless the code is really needed.

ふーむ、Applicationクラスには余計なコードを書かないのがお作法なのね(´・ω・`)


5. Explore lifecycle use cases

Use case 3: Partially hide the activity

Whatever code runs in onPause() blocks other things from displaying, so keep the code in onPause() lightweight.

onPause()内は軽めに…φ(・ω・` )メモメモ…


6. Explore the fragment lifecycle

Lifecycles and loggingの後は次のComplex Lifecycle Situationsへのリンクがない?


Android Kotlin Fundamentals: Complex Lifecycle Situations

4. Task: Use the Android lifecycle library

Step 1: Turn DessertTimer into a LifecycleObserver

LifecycleOwnerをimplementしてるのはFragmentActivityのsuperclassのComponentActivityではなかろうか…


5. Task: Simulate app shutdown and use onSaveInstanceState()

Step 1: Use adb to simulate a process shutdown

The Android Debug Bridge (adb) is a command-line tool that lets you send instructions to emulators and devices attached to your computer.

Android Debug Bridge(adb)はコンピュータに接続されたデバイスまたはエミュレータへ指示を送るコマンドラインツールと…φ(・ω・` )メモメモ…

4.Type adb and press Return.
今も向こうではエンターじゃなくてリターンキー呼びが主流なんだろうか。

んー、
adb shell am kill com.example.android.dessertclicker
が上手く動いてないのか、Recents Screenから復帰(?)させても、前の状態が残ってるな…
何か間違ってるな(ノ∀`)

adb server version (41) doesn't match this client (40); killing...
could not read ok from ADB Server
* failed to start daemon
error: cannot connect to daemon

って出てるけど、これは問題あるのかないのかがまずわからん(・∀・)

コマンドプロンプトで上のコマンドを放ったら、何のエラーメッセージも出さずに終了出来た模様。Recents Screenから復帰させたら、無事に前の状態がリセットされていた。

なんでASだと上手く行かないんだろうと悩んだが、一回コマンドプロント側で上手く行ったら、ASでも上手く行くようになった。原因はよくわからないが、取り敢えず解決したからいいか(ノ∀`)
adb.exeが複数起動してたんかな?

Step 2: Use onSaveInstanceState() to save bundle data

A bundle is a collection of key-value pairs, where the keys are always strings.

前にも説明があったが、キーは必ず文字列なんだねぇ。

Generally you should store far less than 100k, otherwise you risk crashing your app with the TransactionTooLargeException error.

サイズは100KB以下に抑えないと駄目と…φ(・ω・` )メモメモ…

The putInt() method (and similar methods from the Bundle class like putFloat() and putString() takes two arguments:
putString()の後に閉じ括弧が抜けてる?

Step 3: Use onCreate() to restore bundle data

So if the bundle is not null, you know you're "re-creating" the activity from a previously known point.

それで判定が出来るわけか。

which in turn
which in turnって何?非制限用法(付加用法)って?
「which in turn,」の訳し方について 下記の文章で「which in turn,」はどう訳せば良いでし…


ようやっとここまででLesson4が終わった…(ヽ'ω`)
勉強になるけど長いなw

『Android Kotlin Fundamentals』をやった(3)

Android Kotlin Fundamentals 02.4:Data binding basics

an object that contains a reference to each view. This object, called a Binding object,

Bindingオブジェクトとは各Viewへの参照を包含するオブジェクト…φ(・ω・` )メモメモ…

To use data binding, you need to enable data binding in your Gradle file, as it's not enabled by default.
To work with data binding, you need to wrap your XML layout with a <layout> tag.
The namespace declarations for a layout must be in the outermost tag.

build.gradle(:app)でdatabindingを有効にして、
<layout>タグで全体を囲って、xmlnsを最外である<layout>タグ内に移動。

あれ…
なんかアプリが繰り返し停止するとか言ってエラーが(ノ∀`)
kaptを追加していないのがいけないかと思い、pluginのところに

id 'kotlin-kapt'

を追加したが、関係なかった模様。

    buildFeatures {
        dataBinding true
    }

ではなく、

    dataBinding {
        enabled true
    }

にしてみたけど、
別に関係なく…まあそれはそうかw

あー、中身は空でもいいけど<data></data>を追加しないと駄目ってことなのかな?
<layout>タグで囲んだ後は<data>タグも一緒に追加しないと起動でこけるみたいだな、少なからず、うちの今の環境だと。

おお、エラーになっていたMainActivity.ktの
import com.example.aboutme.databinding.ActivityMainBinding
が自動追加された。サンプルと違って、うちのコードのパッケージにandroidがないな…
まあそこはどうでもいいかw

import androidx.databinding.DataBindingUtil
を追加するとエラーになって
import android.databinding.DataBindingUtilが追加されるな…
jetpackから移動したんだろうか(´・ω・`)?

Step 4: Use the binding object to replace all calls to findViewById()

When the binding object is created, the compiler generates the names of the views in the binding object from the IDs of the views in the layout, converting them to camel case. So, for example, done_button is doneButton in the binding object, nickname_edit becomes becomes nicknameEdit, and nickname_text becomes nicknameText.

ほーん、なるほど…( ゜σ・゚)ホジホジ
ってbecomesが二回出てきてるなw

findViewById(id)で指定してたら、自動的にbindingオブジェクトを追加するか、同じメソッド内にあるbindingオブジェクトを選択して、~.キャメルケース化したidとかに変更する機能はないんかな。それは一括でリファクタリング出来る機能として存在した方がいいのかな…

完成形の方にupdateNicknameがないな…
いずれ削除するのかな?

thorough 徹底的に 充分な, 十分な, 念入りな
一瞬、throughかと思ったら、こんな英単語があるんだな…


4. Task: Use data binding to display data

Step 2: Add data to the layout

この段階でタグを挿入するのか…
他の環境だと上記のエラーは起きないのであろうか?
何はともあれThis is where you will connect the view with the data.ということらしい。


Android Kotlin Fundamentals:Create a fragment

2. App overview

The top of the app displays a view called the *app bar (*or action bar) which shows the app's name.

この*はなんだろうか…
もしかして強調表示とかの制御文字の一部?


4. Task: Add a fragment

Step 1: Add a Fragment class

Create a binding object

これ項番5でplaceholder_layout.xmlを削除するけど、これってなんなんだろう?

Step 2: Add the new fragment to the main layout file

今まで、ずっとtext tabと言ってたのに、ここでようやくCode tabという表記になった。


Android Kotlin Fundamentals:03.2 Define navigation paths

5. Task: Add fragments to the navigation graph

Step 1: Add two fragments to the navigation graph and connect them with an action

placeholder_layout.xmlを削除し忘れていた為かなんか知らないけど、titleFragmentが出てこなくて悩んだ(ノ∀`)

Step 2: Add a click handler to the Play button

最後のopens.と画像の間に改行が欲しいところか。


7. Task: Change the Back button's destination

Step 1: Set the pop behavior for the navigation actions

あれ? popUpTo属性がよくわからないと思ってぐぐったら、
コードラボを翻訳しているサイトを見つけた(ノ∀`)

まあしばらくは原文サイトで読み続けようかな。

項番4の
Select the action for navigating from the gameFragment to the gameWonFragment. Again, set popUpTo to gameFragment in the Attributes pane and select the popUpToInclusive checkbox.
ってあるけど、画像だとgameWonFragmentになっているような気がするけど、これはなんなんだろうか…

Step 2: Add more navigation actions and add onClick handlers

val navController = this.findNavController(R.id.myNavHostFragment)
NavigationUI.setupActionBarWithNavController(this,navController)

はbindingの後に書かないとまたエラーが発生して起動しなくなった。

Step 2: Add the options-menu resource

追加したmenu itemにはidが入っていないのがデフォ?
取り敢えずaboutFragmentにしたけれど。


10. Task: Add the navigation drawer

Step 3: Create the drawer menu and the drawer layout

Note: If you use the same ID for the menu item as for the destination Fragment, you don't need to write any code at all to implement the onClick listener!

へぇ(・∀・)
随分と簡略化されてるんだなぁ。


Android Kotlin Fundamentals: 03.3 Start an external Activity

3. Task: Set up and use the Safe Args plugin

An Android Bundle is a key-value store.

Bundleはキーバリューペアを格納するオブジェクトと…φ(・ω・` )メモメモ…

Android's Navigation Architecture Component includes a feature called Safe Args. Safe Args is a Gradle plugin that generates code and classes that help detect errors at compile-time that might not otherwise be surfaced until the app runs.

Safe Argsはアプリ実行時まで表面化しないかもしれないエラーをコンパイル時に発見する手助けをするコードとクラスを生成するGradleプラグイン?

Step 3: Add a NavDirection class to the game Fragment

GameFragmentDirectionsというか~Directions.javaファイルってASから見られるのかな?
なんか見えない気がする。エクスプローラで開くと表示されるんだけども…
\android-kotlin-fundamentals-starter-apps-master\AndroidTrivia-Starter\app\build\generated\source\navigation-args\debug\com\example\android\navigation

import androidx.annotation.NonNull;
import androidx.navigation.ActionOnlyNavDirections;
import androidx.navigation.NavDirections;

public class GameFragmentDirections {
  private GameFragmentDirections() {
  }

  @NonNull
  public static NavDirections actionGameFragmentToGameOverFragment() {
    return new ActionOnlyNavDirections(R.id.action_gameFragment_to_gameOverFragment);
  }

  @NonNull
  public static NavDirections actionGameFragmentToGameWonFragment() {
    return new ActionOnlyNavDirections(R.id.action_gameFragment_to_gameWonFragment);
  }
}

NavDirectionsはインターフェースなのか。

ActionOnlyNavDirectionsはその継承クラスでnavの矢印のidを保持して、getArguments()は常に新しいBundleを返す…?

Android の各種リソースの ID は int 型で管理されています。 この値を変数に格納したり、メソッドのパラメータとして受け取るように実装した場合、不正な int 値が渡されて実行時に落ちてしまうリスクがあります。

@IdRes R.id.xxx で参照するリソースID

へぇ(・∀・)

4. Task: Add and pass arguments

Step 2: Pass the arguments

ここでnumQuestionsとquestionIndexをパラメータとして追加したら何故か変な補完がされてエラーに。余計なvarやらany以降を削除したら、エラーは消えた。

『Android Kotlin Fundamentals』をやった(2)

Android Kotlin Fundamentals: Add user interactivity

3.Task: Add an EditText for text input

This the same code you finished in a previous codelab.
be動詞ってなくてもええんかな?

Step 2: Add an EditText

In the Palette pane, notice how the icon for TextView shows the letters Ab with no underscoring. The EditText icons, however, show Ab underscored. The underscoring indicates that the view is editable.

下線の有無はそういう違いだったのか(・∀・)シランカッタ


5. Task: Add a button and style it

Step 1: Add a DONE button

またcolorAccentがcolors.xmlにないな。
これは今はない設定なのか?

と思ったが、themes.xmlに
@color/teal_200
という指定があったので"teal_200"を"colorAccent"に変えたら変更された模様。
関係ないがstyles.xmlで指定してもthemes.xmlで指定されていたら、こっちが優先されるんだろうか?


6. Task: Add a TextView to display the nickname

Step 2: Change the visibility of the TextView

何故か、指定してもテキスト(コード)の方で以下の2つが出て来ないな…なんだろうか。

style="@style/NameStyle"
android:text=""

7. Task: Add a click listener to the DONE button

Step 1: Add a click listener

5.Hide the nickname EditText view by setting the visibility property of editText to View.GONE.

なんか強調表示の範囲がおかしいというか、EditTextが強調表示されているが故に文が読みにくくなっているような。


Android Kotlin Fundamentals:02.3 ConstraintLayout using the Layout Editor

4. Task: Use Layout Editor to build a ConstraintLayout

Step 1: Set up your Android Studio work area

日本語化してるからAutoconnect toggle buttonがどれかわからない…
Enable Autoconnection to Parentでいいのかな?

と思ったら下でアイコンが表示されてた。
名前は違うけど、これでいいのか。

default marginが何故かGUIで設定できない。
数値を押しに行くとドロワー(?)パネルが消えちゃう…
うちの環境がおかしいのかな?

bias slidersが見当たらないΣ(・ω・`≡´・ω・)
と思ったら、Constraint Widgetのとこにあったわ(ノ∀`) ← view inspectorが正式名称
ダーク設定にしていたからか、ボケてきているからか、見落としていたわ。

Step 2: Add margins for the Hello World text view

なぜかTextViewに左右のmarginをセットしてもキャンセルされてしまう…
上下には設定出来るのに…なぜだ(´・ω・`)?

あれ? 既存の制約を消して(黒丸クリック)からもう一回 +したら設定できるようになった。

Step 3: Adjust constraints and margins for the text view

In the view inspector, click the Delete Bottom Constraint dot 8b8e6d915b2b4a9c.pngon the square to delete the bottom constraint.

ここで間に入ってる画像、上下逆じゃない(´・ω・`)?
これだとBottomじゃなくてTopの方じゃない?


5. Task: Style the TextView

Step 1: Add a font

ここも"Add font to project"の手順が後だな…

Step 2: Add a style

styles.xmlはなくてthemes.xmlしかないな
Android Studio4.1辺りから変更になったのか…

このような色の実際の定義は、テーマ内で提供されています。デバイスが夜間モードになると、アプリは「ライト」テーマから「ダークテーマ」テーマに切り替えることができます。またリソース名の値も変更できます。スタイルは特定の色の定義ではなくセマンティック名を使用しているため、スタイルを変更する必要はありません。
themes

ってあるけど、実際の色の設定でcolors.xmlとかでやってんじゃね(´・ω・`)?

「ライト」テーマと「ダーク」テーマの切り替え用のスタイルセットのように思えるけど、そういうことではないのか…

どうでもいいが"「ダークテーマ」テーマ"になってるな…
原文だとyour app can switch from its "light" theme to its "dark" themeだけども、翻訳AIがおかしいんかな( ゜σ・゚)ホジホジ

テーマの方に書いても上手く適用されなかったので、styles.xmlを新規に作ってそこに値をペーストしたら適用された。

あ(ノ∀`)
styleに指定しようとして蹴られてるだけだったw
android:themeの方に指定したら上手く行ったわ。


6. Task: Add a second TextView and add constraints

Step 1: Add a new text view

constraint handleは緑にならずに青丸が表示されるだけかな。

Step 3: Set attributes for the new text view

属性ペインだとlayout_widthの方が上に来てるな。
まあいいんだけどもw


10. Task: Add a baseline constraint

Baseline constraint

Edit Baselineアイコンが出て来ない。
ああ、ベースラインアイコンとかサンプルデータのセットは右クリックすればコンテキストメニューで出てくるんだな。


11. Task: Add a chain of buttons

Step 2: Create a horizontal chain and constrain it

16dpを@dimen/margin_wideに差し替えたり、visibilityを設定したりしてないな…
なぜかgreen_buttonのandroid:layout_marginEndだけ16dpのままだなw


12. Task: Add click handlers to the buttons

項番4のview's background Add
ピリオド抜け?

whenのとこでR.id.box_~_textと指定してるけど、これでアクセス出来るのか?
取り敢えずfindViewById(R.id.box_~_text)に差し替えたけども。