mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 03:05:18 +08:00
Add Android 7.1 launcher shortcut for new session
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
@@ -521,10 +521,16 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
// The service connected while not in foreground - just bail out.
|
// The service connected while not in foreground - just bail out.
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Intent i = getIntent();
|
||||||
|
if (i != null && i.getAction().equals(Intent.ACTION_RUN)) {
|
||||||
|
// Android 7.1 app shortcut from res/xml/shortcuts.xml.
|
||||||
|
addNewSession(false, null);
|
||||||
} else {
|
} else {
|
||||||
switchToSession(getStoredCurrentSessionOrLast());
|
switchToSession(getStoredCurrentSessionOrLast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void switchToSession(boolean forward) {
|
public void switchToSession(boolean forward) {
|
||||||
TerminalSession currentSession = getCurrentTermSession();
|
TerminalSession currentSession = getCurrentTermSession();
|
||||||
|
17
app/src/main/res/drawable/ic_new_session.xml
Normal file
17
app/src/main/res/drawable/ic_new_session.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFF"
|
||||||
|
android:pathData="M 12, 12
|
||||||
|
m -10.5, 0
|
||||||
|
a 10.5,10.5 0 1,0 21,0
|
||||||
|
a 10.5,10.5 0 1,0 -21,0"/>
|
||||||
|
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13h-4v4h-2v-4L7,13v-2h4L11,7h2v4h4v2z"/>
|
||||||
|
</vector>
|
12
app/src/main/res/xml/shortcuts.xml
Normal file
12
app/src/main/res/xml/shortcuts.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<shortcut
|
||||||
|
android:shortcutId="new_session"
|
||||||
|
android:enabled="true"
|
||||||
|
android:icon="@drawable/ic_new_session"
|
||||||
|
android:shortcutShortLabel="@string/new_session">
|
||||||
|
<intent
|
||||||
|
android:action="android.intent.action.RUN"
|
||||||
|
android:targetPackage="com.termux"
|
||||||
|
android:targetClass="com.termux.app.TermuxActivity"/>
|
||||||
|
</shortcut>
|
||||||
|
</shortcuts>
|
Reference in New Issue
Block a user